Skip to content

Commit fe3a4e3

Browse files
committed
implement methods for organization and location
1 parent b913639 commit fe3a4e3

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/viam/app/app_client.py

+40
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,16 @@
5454
GetFragmentResponse,
5555
GetLocationRequest,
5656
GetLocationResponse,
57+
GetLocationMetadataRequest,
58+
GetLocationMetadataResponse,
5759
GetModuleRequest,
5860
GetModuleResponse,
5961
GetOrganizationNamespaceAvailabilityRequest,
6062
GetOrganizationNamespaceAvailabilityResponse,
6163
GetOrganizationRequest,
6264
GetOrganizationResponse,
65+
GetOrganizationMetadataRequest,
66+
GetOrganizationMetadataResponse,
6367
GetOrganizationsWithAccessToLocationRequest,
6468
GetOrganizationsWithAccessToLocationResponse,
6569
GetRegistryItemRequest,
@@ -2523,3 +2527,39 @@ async def rotate_key(self, id: str) -> Tuple[str, str]:
25232527
request = RotateKeyRequest(id=id)
25242528
response: RotateKeyResponse = await self._app_client.RotateKey(request, metadata=self._metadata)
25252529
return response.key, response.id
2530+
2531+
async def get_organization_metadata(self, org_id: str) -> Mapping[str, Any]:
2532+
"""Get an organization's user-defined metadata.
2533+
2534+
::
2535+
2536+
metadata = await cloud.get_organization_metadata(org_id="<YOUR-ORG-ID>")
2537+
2538+
Args:
2539+
org_id (str): The ID of the organization with which the user-defined metadata is associated.
2540+
You can obtain your organization ID from the Viam app's organization settings page.
2541+
2542+
Returns:
2543+
Mapping[str, Any]: The user-defined metadata converted from JSON to a Python dictionary
2544+
"""
2545+
request = GetOrganizationMetadataRequest(organization_id=org_id)
2546+
response: GetOrganizationMetadataResponse = await self._app_client.GetOrganizationMetadata(request)
2547+
return struct_to_dict(response.data)
2548+
2549+
async def get_location_metadata(self, location_id: str) -> Mapping[str, Any]:
2550+
"""Get a location's user-defined metadata.
2551+
2552+
::
2553+
2554+
metadata = await cloud.get_location_metadata(location_id="<YOUR-LOCATION-ID>")
2555+
2556+
Args:
2557+
org_id (str): The ID of the location with which the user-defined metadata is associated.
2558+
You can obtain your location ID from the Viam app's locations page.
2559+
2560+
Returns:
2561+
Mapping[str, Any]: The user-defined metadata converted from JSON to a Python dictionary
2562+
"""
2563+
request = GetLocationMetadataRequest(location_id=location_id)
2564+
response: GetLocationMetadataResponse = await self._app_client.GetLocationMetadata(request)
2565+
return struct_to_dict(response.data)

0 commit comments

Comments
 (0)