Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RSDK-10127] Add get and update metadata functions #360

Merged
merged 3 commits into from
Mar 18, 2025
Merged

Conversation

JosephBorodach
Copy link
Member

@JosephBorodach JosephBorodach commented Mar 18, 2025

Description

Add user-defined metadata CRUD operations

See ticket here

@JosephBorodach JosephBorodach requested a review from a team as a code owner March 18, 2025 15:15
/// Retrieves user-defined [Metadata] for an organization.
///
/// For more information, see [Fleet Management API](https://docs.viam.com/appendix/apis/fleet/).
Future<GetOrganizationMetadataResponse> getOrganizationMetadata(String id) async {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(minor/nit) can we rename to organizationId or orgId? it's more specific and more consistent with similar calls elsewhere in the SDK.

Same comment applies to below methods.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great catch, thanks for calling this out

Future<void> updateOrganizationMetadata(String id, Map<String, dynamic> data) async {
final request = UpdateOrganizationMetadataRequest()
..organizationId = id
..data = _mapToStruct(data);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_mapToStruct is undefined, which is causing errors. I think what you're looking for is data.toStruct().

Comment on lines +758 to +763
test('getOrganizationMetadata', () async {
final expected = GetOrganizationMetadataResponse()..data = (Struct()..fields['key'] = (Value()..stringValue = 'value'));
when(serviceClient.getOrganizationMetadata(any)).thenAnswer((_) => MockResponseFuture.value(expected));
final response = await appClient.getOrganizationMetadata('orgId');
expect(response, equals(expected));
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test looks good, but we should probably add tests for all the other methods you implemented as well!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! Naveed and I were just debugging before I put all of the tests up - thanks for calling this out!

Copy link
Member

@stuqdog stuqdog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@JosephBorodach JosephBorodach changed the title Add get and update metadata functions [RSDK-10127] Add get and update metadata functions Mar 18, 2025
@JosephBorodach JosephBorodach merged commit fa8e9bf into main Mar 18, 2025
4 checks passed
@JosephBorodach JosephBorodach deleted the RSDK-10127 branch March 18, 2025 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants