-
Notifications
You must be signed in to change notification settings - Fork 31
[RSDK-10127] Add get and update metadata functions #360
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -729,4 +729,76 @@ class AppClient { | |
final request = CreateKeyFromExistingKeyAuthorizationsRequest()..id = id; | ||
return await _client.createKeyFromExistingKeyAuthorizations(request); | ||
} | ||
|
||
/// 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 { | ||
final request = GetOrganizationMetadataRequest()..organizationId = id; | ||
return await _client.getOrganizationMetadata(request); | ||
} | ||
|
||
/// Updates user-defined [Metadata] for an organization. | ||
/// | ||
/// For more information, see [Fleet Management API](https://docs.viam.com/appendix/apis/fleet/). | ||
Future<void> updateOrganizationMetadata(String id, Map<String, dynamic> data) async { | ||
final request = UpdateOrganizationMetadataRequest() | ||
..organizationId = id | ||
..data = _mapToStruct(data); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
await _client.updateOrganizationMetadata(request); | ||
} | ||
|
||
/// Retrieves user-defined [Metadata] for a location. | ||
/// | ||
/// For more information, see [Fleet Management API](https://docs.viam.com/appendix/apis/fleet/). | ||
Future<GetLocationMetadataResponse> getLocationMetadata(String id) async { | ||
final request = GetLocationMetadataRequest()..locationId = id; | ||
return await _client.getLocationMetadata(request); | ||
} | ||
|
||
/// Updates user-defined [Metadata] for a location. | ||
/// | ||
/// For more information, see [Fleet Management API](https://docs.viam.com/appendix/apis/fleet/). | ||
Future<void> updateLocationMetadata(String id, Map<String, dynamic> data) async { | ||
final request = UpdateLocationMetadataRequest() | ||
..locationId = id | ||
..data = _mapToStruct(data); | ||
await _client.updateLocationMetadata(request); | ||
} | ||
|
||
/// Retrieves user-defined [Metadata] for a robot. | ||
/// | ||
/// For more information, see [Fleet Management API](https://docs.viam.com/appendix/apis/fleet/). | ||
Future<GetRobotMetadataResponse> getRobotMetadata(String id) async { | ||
final request = GetRobotMetadataRequest()..id = id; | ||
return await _client.getRobotMetadata(request); | ||
} | ||
|
||
/// Updates user-defined [Metadata] for a robot. | ||
/// | ||
/// For more information, see [Fleet Management API](https://docs.viam.com/appendix/apis/fleet/). | ||
Future<void> updateRobotMetadata(String id, Map<String, dynamic> data) async { | ||
final request = UpdateRobotMetadataRequest() | ||
..id = id | ||
..data = _mapToStruct(data); | ||
await _client.updateRobotMetadata(request); | ||
} | ||
|
||
/// Retrieves user-defined [Metadata] for a robot part. | ||
/// | ||
/// For more information, see [Fleet Management API](https://docs.viam.com/appendix/apis/fleet/). | ||
Future<GetRobotPartMetadataResponse> getRobotPartMetadata(String id) async { | ||
final request = GetRobotPartMetadataRequest()..id = id; | ||
return await _client.getRobotPartMetadata(request); | ||
} | ||
|
||
/// Updates user-defined [Metadata] for a robot part. | ||
/// | ||
/// For more information, see [Fleet Management API](https://docs.viam.com/appendix/apis/fleet/). | ||
Future<void> updateRobotPartMetadata(String id, Map<String, dynamic> data) async { | ||
final request = UpdateRobotPartMetadataRequest() | ||
..id = id | ||
..data = _mapToStruct(data); | ||
await _client.updateRobotPartMetadata(request); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -754,5 +754,12 @@ void main() { | |
final response = await appClient.createKeyFromExistingKeyAuthorizations('id'); | ||
expect(response, equals(expected)); | ||
}); | ||
|
||
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)); | ||
}); | ||
Comment on lines
+758
to
+763
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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! There was a problem hiding this comment. Choose a reason for hiding this commentThe 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! |
||
}); | ||
} |
There was a problem hiding this comment.
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
ororgId
? it's more specific and more consistent with similar calls elsewhere in the SDK.Same comment applies to below methods.
There was a problem hiding this comment.
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