viam-sdk 0.45.1__py3-none-linux_armv7l.whl → 0.46.0__py3-none-linux_armv7l.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of viam-sdk might be problematic. Click here for more details.
- viam/app/app_client.py +178 -9
- viam/app/data_client.py +167 -148
- viam/gen/app/v1/app_pb2.py +511 -511
- viam/gen/app/v1/app_pb2.pyi +37 -18
- viam/gen/module/v1/module_pb2.py +4 -4
- viam/gen/module/v1/module_pb2.pyi +7 -2
- viam/gen/robot/v1/robot_pb2.pyi +1 -1
- viam/gen/service/slam/v1/slam_pb2.pyi +1 -1
- viam/rpc/libviam_rust_utils.so +0 -0
- viam/version_metadata.py +2 -2
- {viam_sdk-0.45.1.dist-info → viam_sdk-0.46.0.dist-info}/METADATA +1 -1
- {viam_sdk-0.45.1.dist-info → viam_sdk-0.46.0.dist-info}/RECORD +14 -14
- {viam_sdk-0.45.1.dist-info → viam_sdk-0.46.0.dist-info}/WHEEL +0 -0
- {viam_sdk-0.45.1.dist-info → viam_sdk-0.46.0.dist-info}/licenses/LICENSE +0 -0
viam/app/app_client.py
CHANGED
|
@@ -52,10 +52,14 @@ from viam.proto.app import (
|
|
|
52
52
|
GetFragmentHistoryResponse,
|
|
53
53
|
GetFragmentRequest,
|
|
54
54
|
GetFragmentResponse,
|
|
55
|
+
GetLocationMetadataRequest,
|
|
56
|
+
GetLocationMetadataResponse,
|
|
55
57
|
GetLocationRequest,
|
|
56
58
|
GetLocationResponse,
|
|
57
59
|
GetModuleRequest,
|
|
58
60
|
GetModuleResponse,
|
|
61
|
+
GetOrganizationMetadataRequest,
|
|
62
|
+
GetOrganizationMetadataResponse,
|
|
59
63
|
GetOrganizationNamespaceAvailabilityRequest,
|
|
60
64
|
GetOrganizationNamespaceAvailabilityResponse,
|
|
61
65
|
GetOrganizationRequest,
|
|
@@ -66,10 +70,14 @@ from viam.proto.app import (
|
|
|
66
70
|
GetRegistryItemResponse,
|
|
67
71
|
GetRobotAPIKeysRequest,
|
|
68
72
|
GetRobotAPIKeysResponse,
|
|
73
|
+
GetRobotMetadataRequest,
|
|
74
|
+
GetRobotMetadataResponse,
|
|
69
75
|
GetRobotPartHistoryRequest,
|
|
70
76
|
GetRobotPartHistoryResponse,
|
|
71
77
|
GetRobotPartLogsRequest,
|
|
72
78
|
GetRobotPartLogsResponse,
|
|
79
|
+
GetRobotPartMetadataRequest,
|
|
80
|
+
GetRobotPartMetadataResponse,
|
|
73
81
|
GetRobotPartRequest,
|
|
74
82
|
GetRobotPartResponse,
|
|
75
83
|
GetRobotPartsRequest,
|
|
@@ -134,15 +142,23 @@ from viam.proto.app import (
|
|
|
134
142
|
UnshareLocationRequest,
|
|
135
143
|
UpdateFragmentRequest,
|
|
136
144
|
UpdateFragmentResponse,
|
|
145
|
+
UpdateLocationMetadataRequest,
|
|
146
|
+
UpdateLocationMetadataResponse,
|
|
137
147
|
UpdateLocationRequest,
|
|
138
148
|
UpdateLocationResponse,
|
|
139
149
|
UpdateModuleRequest,
|
|
140
150
|
UpdateModuleResponse,
|
|
141
151
|
UpdateOrganizationInviteAuthorizationsRequest,
|
|
142
152
|
UpdateOrganizationInviteAuthorizationsResponse,
|
|
153
|
+
UpdateOrganizationMetadataRequest,
|
|
154
|
+
UpdateOrganizationMetadataResponse,
|
|
143
155
|
UpdateOrganizationRequest,
|
|
144
156
|
UpdateOrganizationResponse,
|
|
145
157
|
UpdateRegistryItemRequest,
|
|
158
|
+
UpdateRobotMetadataRequest,
|
|
159
|
+
UpdateRobotMetadataResponse,
|
|
160
|
+
UpdateRobotPartMetadataRequest,
|
|
161
|
+
UpdateRobotPartMetadataResponse,
|
|
146
162
|
UpdateRobotPartRequest,
|
|
147
163
|
UpdateRobotPartResponse,
|
|
148
164
|
UpdateRobotRequest,
|
|
@@ -193,6 +209,7 @@ class RobotPart:
|
|
|
193
209
|
self.local_fqdn = robot_part.local_fqdn
|
|
194
210
|
self.created_on = robot_part.created_on.ToDatetime() if robot_part.HasField("created_on") else None
|
|
195
211
|
self.secrets = list(robot_part.secrets)
|
|
212
|
+
self.last_updated = robot_part.last_updated.ToDatetime() if robot_part.HasField("last_updated") else None
|
|
196
213
|
return self
|
|
197
214
|
|
|
198
215
|
id: str
|
|
@@ -209,6 +226,7 @@ class RobotPart:
|
|
|
209
226
|
local_fqdn: str
|
|
210
227
|
created_on: Optional[datetime]
|
|
211
228
|
secrets: Optional[List[SharedSecret]]
|
|
229
|
+
last_updated: Optional[datetime]
|
|
212
230
|
|
|
213
231
|
@property
|
|
214
232
|
def proto(self) -> RobotPartPB:
|
|
@@ -227,6 +245,7 @@ class RobotPart:
|
|
|
227
245
|
local_fqdn=self.local_fqdn,
|
|
228
246
|
created_on=datetime_to_timestamp(self.created_on) if self.created_on else None,
|
|
229
247
|
secrets=self.secrets,
|
|
248
|
+
last_updated=datetime_to_timestamp(self.last_updated) if self.last_updated else None,
|
|
230
249
|
)
|
|
231
250
|
|
|
232
251
|
|
|
@@ -352,6 +371,7 @@ class Fragment:
|
|
|
352
371
|
self.organization_count = fragment.organization_count
|
|
353
372
|
self.only_used_by_owner = fragment.only_used_by_owner
|
|
354
373
|
self.visibility = Fragment.Visibility.from_proto(fragment.visibility)
|
|
374
|
+
self.last_updated = fragment.last_updated.ToDatetime() if fragment.HasField("last_updated") else None
|
|
355
375
|
return self
|
|
356
376
|
|
|
357
377
|
id: str
|
|
@@ -365,6 +385,7 @@ class Fragment:
|
|
|
365
385
|
organization_count: int
|
|
366
386
|
only_used_by_owner: bool
|
|
367
387
|
visibility: Visibility
|
|
388
|
+
last_updated: Optional[datetime]
|
|
368
389
|
|
|
369
390
|
@property
|
|
370
391
|
def proto(self) -> FragmentPB:
|
|
@@ -380,6 +401,7 @@ class Fragment:
|
|
|
380
401
|
organization_count=self.organization_count,
|
|
381
402
|
only_used_by_owner=self.only_used_by_owner,
|
|
382
403
|
visibility=self.visibility.to_proto(),
|
|
404
|
+
last_updated=datetime_to_timestamp(self.last_updated) if self.last_updated else None,
|
|
383
405
|
)
|
|
384
406
|
|
|
385
407
|
|
|
@@ -1262,6 +1284,8 @@ class AppClient:
|
|
|
1262
1284
|
my_robot_part = await cloud.get_robot_part(
|
|
1263
1285
|
robot_part_id="abc12345-1a23-1234-ab12-a22a22a2aa22"
|
|
1264
1286
|
)
|
|
1287
|
+
# Get the part's address
|
|
1288
|
+
address = my_robot_part.fqdn
|
|
1265
1289
|
# Check if machine is live (last access time less than 10 sec ago)
|
|
1266
1290
|
if (time.time() - my_robot_part.last_access.timestamp()) <= 10000:
|
|
1267
1291
|
print("Machine is live.")
|
|
@@ -1429,7 +1453,9 @@ class AppClient:
|
|
|
1429
1453
|
response: GetRobotPartHistoryResponse = await self._app_client.GetRobotPartHistory(request, metadata=self._metadata)
|
|
1430
1454
|
return [RobotPartHistoryEntry.from_proto(part_history) for part_history in response.history]
|
|
1431
1455
|
|
|
1432
|
-
async def update_robot_part(
|
|
1456
|
+
async def update_robot_part(
|
|
1457
|
+
self, robot_part_id: str, name: str, robot_config: Optional[Mapping[str, Any]] = None, last_known_update: Optional[datetime] = None
|
|
1458
|
+
) -> RobotPart:
|
|
1433
1459
|
"""Change the name and assign an optional new configuration to a machine part.
|
|
1434
1460
|
|
|
1435
1461
|
::
|
|
@@ -1443,16 +1469,23 @@ class AppClient:
|
|
|
1443
1469
|
name (str): New name to be updated on the robot part.
|
|
1444
1470
|
robot_config (Mapping[str, Any]): Optional new config represented as a dictionary to be updated on the machine part. The machine
|
|
1445
1471
|
part's config will remain as is (no change) if one isn't passed.
|
|
1446
|
-
|
|
1472
|
+
last_known_update (datetime): Optional time of the last known update to this part's config. If provided, this will result in a
|
|
1473
|
+
GRPCError if the upstream config has changed since this time, indicating that the local config is out of date. Omitting this
|
|
1474
|
+
parameter will result in an overwrite of the upstream config.
|
|
1447
1475
|
Raises:
|
|
1448
|
-
GRPCError: If either an invalid machine part ID, name, or config is passed
|
|
1449
|
-
|
|
1476
|
+
GRPCError: If either an invalid machine part ID, name, or config is passed, or if the upstream config has changed since
|
|
1477
|
+
last_known_update.
|
|
1450
1478
|
Returns:
|
|
1451
1479
|
viam.app.app_client.RobotPart: The newly updated robot part.
|
|
1452
1480
|
|
|
1453
1481
|
For more information, see `Fleet Management API <https://docs.viam.com/dev/reference/apis/fleet/#updaterobotpart>`_.
|
|
1454
1482
|
"""
|
|
1455
|
-
request = UpdateRobotPartRequest(
|
|
1483
|
+
request = UpdateRobotPartRequest(
|
|
1484
|
+
id=robot_part_id,
|
|
1485
|
+
name=name,
|
|
1486
|
+
robot_config=dict_to_struct(robot_config) if robot_config else None,
|
|
1487
|
+
last_known_update=datetime_to_timestamp(last_known_update),
|
|
1488
|
+
)
|
|
1456
1489
|
response: UpdateRobotPartResponse = await self._app_client.UpdateRobotPart(request, metadata=self._metadata)
|
|
1457
1490
|
return RobotPart.from_proto(robot_part=response.part)
|
|
1458
1491
|
|
|
@@ -1791,6 +1824,7 @@ class AppClient:
|
|
|
1791
1824
|
config: Optional[Mapping[str, Any]] = None,
|
|
1792
1825
|
public: Optional[bool] = None,
|
|
1793
1826
|
visibility: Optional[Fragment.Visibility] = None,
|
|
1827
|
+
last_known_update: Optional[datetime] = None,
|
|
1794
1828
|
) -> Fragment:
|
|
1795
1829
|
"""Update a fragment name AND its config and/or visibility.
|
|
1796
1830
|
|
|
@@ -1813,9 +1847,11 @@ class AppClient:
|
|
|
1813
1847
|
visibility (Optional[FragmentVisibility]): Optional FragmentVisibility list specifying who should be allowed
|
|
1814
1848
|
to view the fragment. Not passing this parameter will leave the fragment's visibility unchanged.
|
|
1815
1849
|
A fragment is private by default when created.
|
|
1816
|
-
|
|
1850
|
+
last_known_update (datetime): Optional time of the last known update to this fragment's config. If provided, this will result in
|
|
1851
|
+
a GRPCError if the upstream config has changed since this time, indicating that the local config is out of date. Omitting
|
|
1852
|
+
this parameter will result in an overwrite of the upstream config.
|
|
1817
1853
|
Raises:
|
|
1818
|
-
GRPCError: if an invalid ID, name, or config is passed.
|
|
1854
|
+
GRPCError: if an invalid ID, name, or config is passed, or if the upstream fragment config has changed since last_known_update.
|
|
1819
1855
|
|
|
1820
1856
|
Returns:
|
|
1821
1857
|
viam.app.app_client.Fragment: The newly updated fragment.
|
|
@@ -1828,6 +1864,7 @@ class AppClient:
|
|
|
1828
1864
|
config=dict_to_struct(config) if config else None,
|
|
1829
1865
|
public=public,
|
|
1830
1866
|
visibility=visibility.to_proto() if visibility else None,
|
|
1867
|
+
last_known_update=datetime_to_timestamp(last_known_update),
|
|
1831
1868
|
)
|
|
1832
1869
|
response: UpdateFragmentResponse = await self._app_client.UpdateFragment(request, metadata=self._metadata)
|
|
1833
1870
|
return Fragment.from_proto(response.fragment)
|
|
@@ -2095,7 +2132,7 @@ class AppClient:
|
|
|
2095
2132
|
response: CheckPermissionsResponse = await self._app_client.CheckPermissions(request, metadata=self._metadata)
|
|
2096
2133
|
return list(response.authorized_permissions)
|
|
2097
2134
|
|
|
2098
|
-
async def get_registry_item(self, item_id: str) -> RegistryItem:
|
|
2135
|
+
async def get_registry_item(self, item_id: str, include_markdown_documentation: bool = False) -> RegistryItem:
|
|
2099
2136
|
"""Get registry item by ID.
|
|
2100
2137
|
|
|
2101
2138
|
::
|
|
@@ -2113,7 +2150,7 @@ class AppClient:
|
|
|
2113
2150
|
|
|
2114
2151
|
For more information, see `Fleet Management API <https://docs.viam.com/dev/reference/apis/fleet/#getregistryitem>`_.
|
|
2115
2152
|
"""
|
|
2116
|
-
request = GetRegistryItemRequest(item_id=item_id)
|
|
2153
|
+
request = GetRegistryItemRequest(item_id=item_id, include_markdown_documentation=include_markdown_documentation)
|
|
2117
2154
|
response: GetRegistryItemResponse = await self._app_client.GetRegistryItem(request, metadata=self._metadata)
|
|
2118
2155
|
return response.item
|
|
2119
2156
|
|
|
@@ -2523,3 +2560,135 @@ class AppClient:
|
|
|
2523
2560
|
request = RotateKeyRequest(id=id)
|
|
2524
2561
|
response: RotateKeyResponse = await self._app_client.RotateKey(request, metadata=self._metadata)
|
|
2525
2562
|
return response.key, response.id
|
|
2563
|
+
|
|
2564
|
+
async def get_organization_metadata(self, org_id: str) -> Mapping[str, Any]:
|
|
2565
|
+
"""Get an organization's user-defined metadata.
|
|
2566
|
+
|
|
2567
|
+
::
|
|
2568
|
+
|
|
2569
|
+
metadata = await cloud.get_organization_metadata(org_id="<YOUR-ORG-ID>")
|
|
2570
|
+
|
|
2571
|
+
Args:
|
|
2572
|
+
org_id (str): The ID of the organization with which the user-defined metadata is associated.
|
|
2573
|
+
You can obtain your organization ID from the Viam app's organization settings page.
|
|
2574
|
+
|
|
2575
|
+
Returns:
|
|
2576
|
+
Mapping[str, Any]: The user-defined metadata converted from JSON to a Python dictionary
|
|
2577
|
+
"""
|
|
2578
|
+
request = GetOrganizationMetadataRequest(organization_id=org_id)
|
|
2579
|
+
response: GetOrganizationMetadataResponse = await self._app_client.GetOrganizationMetadata(request)
|
|
2580
|
+
return struct_to_dict(response.data)
|
|
2581
|
+
|
|
2582
|
+
async def update_organization_metadata(self, org_id: str, metadata: Mapping[str, Any]) -> None:
|
|
2583
|
+
"""Update an organization's user-defined metadata.
|
|
2584
|
+
|
|
2585
|
+
::
|
|
2586
|
+
|
|
2587
|
+
await cloud.update_organization_metadata(org_id="<YOUR-ORG-ID>", metadata=)
|
|
2588
|
+
|
|
2589
|
+
Args:
|
|
2590
|
+
organization_id (str): The ID of the organization with which to associate the user-defined metadata.
|
|
2591
|
+
You can obtain your organization ID from the Viam app's organization settings page.
|
|
2592
|
+
metadata (Mapping[str, Any]): The user-defined metadata to upload as a Python dictionary.
|
|
2593
|
+
"""
|
|
2594
|
+
request = UpdateOrganizationMetadataRequest(organization_id=org_id, data=dict_to_struct(metadata))
|
|
2595
|
+
_: UpdateOrganizationMetadataResponse = await self._app_client.UpdateOrganizationMetadata(request)
|
|
2596
|
+
|
|
2597
|
+
async def get_location_metadata(self, location_id: str) -> Mapping[str, Any]:
|
|
2598
|
+
"""Get a location's user-defined metadata.
|
|
2599
|
+
|
|
2600
|
+
::
|
|
2601
|
+
|
|
2602
|
+
metadata = await cloud.get_location_metadata(location_id="<YOUR-LOCATION-ID>")
|
|
2603
|
+
|
|
2604
|
+
Args:
|
|
2605
|
+
location_id (str): The ID of the location with which the user-defined metadata is associated.
|
|
2606
|
+
You can obtain your location ID from the Viam app's locations page.
|
|
2607
|
+
|
|
2608
|
+
Returns:
|
|
2609
|
+
Mapping[str, Any]: The user-defined metadata converted from JSON to a Python dictionary.
|
|
2610
|
+
"""
|
|
2611
|
+
request = GetLocationMetadataRequest(location_id=location_id)
|
|
2612
|
+
response: GetLocationMetadataResponse = await self._app_client.GetLocationMetadata(request)
|
|
2613
|
+
return struct_to_dict(response.data)
|
|
2614
|
+
|
|
2615
|
+
async def update_location_metadata(self, location_id: str, metadata: Mapping[str, Any]) -> None:
|
|
2616
|
+
"""Update a location's user-defined metadata.
|
|
2617
|
+
|
|
2618
|
+
::
|
|
2619
|
+
|
|
2620
|
+
await cloud.update_location_metadata(location_id="<YOUR-LOCATION-ID>", metadata=)
|
|
2621
|
+
|
|
2622
|
+
Args:
|
|
2623
|
+
location_id (str): The ID of the location with which to associate the user-defined metadata.
|
|
2624
|
+
You can obtain your location ID from the Viam app's locations page.
|
|
2625
|
+
metadata (Mapping[str, Any]): The user-defined metadata converted from JSON to a Python dictionary.
|
|
2626
|
+
"""
|
|
2627
|
+
request = UpdateLocationMetadataRequest(location_id=location_id, data=dict_to_struct(metadata))
|
|
2628
|
+
_: UpdateLocationMetadataResponse = await self._app_client.UpdateLocationMetadata(request)
|
|
2629
|
+
|
|
2630
|
+
async def get_robot_metadata(self, robot_id: str) -> Mapping[str, Any]:
|
|
2631
|
+
"""Get a robot's user-defined metadata.
|
|
2632
|
+
|
|
2633
|
+
::
|
|
2634
|
+
|
|
2635
|
+
metadata = await cloud.get_robot_metadata(robot_id="<YOUR-ROBOT-ID>")
|
|
2636
|
+
|
|
2637
|
+
Args:
|
|
2638
|
+
robot_id (str): The ID of the robot with which the user-defined metadata is associated.
|
|
2639
|
+
You can obtain your robot ID from the Viam app's machine page.
|
|
2640
|
+
|
|
2641
|
+
Returns:
|
|
2642
|
+
Mapping[str, Any]: The user-defined metadata converted from JSON to a Python dictionary.
|
|
2643
|
+
"""
|
|
2644
|
+
request = GetRobotMetadataRequest(id=robot_id)
|
|
2645
|
+
response: GetRobotMetadataResponse = await self._app_client.GetRobotMetadata(request)
|
|
2646
|
+
return struct_to_dict(response.data)
|
|
2647
|
+
|
|
2648
|
+
async def update_robot_metadata(self, robot_id: str, metadata: Mapping[str, Any]) -> None:
|
|
2649
|
+
"""Update a robot's user-defined metadata.
|
|
2650
|
+
|
|
2651
|
+
::
|
|
2652
|
+
|
|
2653
|
+
await cloud.update_robot_metadata(robot_id="<YOUR-ROBOT-ID>", metadata=)
|
|
2654
|
+
|
|
2655
|
+
Args:
|
|
2656
|
+
robot_id (str): The ID of the robot with which to associate the user-defined metadata.
|
|
2657
|
+
You can obtain your robot ID from the Viam app's machine page.
|
|
2658
|
+
metadata (Mapping[str, Any]): The user-defined metadata converted from JSON to a Python dictionary.
|
|
2659
|
+
"""
|
|
2660
|
+
request = UpdateRobotMetadataRequest(id=robot_id, data=dict_to_struct(metadata))
|
|
2661
|
+
_: UpdateRobotMetadataResponse = await self._app_client.UpdateRobotMetadata(request)
|
|
2662
|
+
|
|
2663
|
+
async def get_robot_part_metadata(self, robot_part_id: str) -> Mapping[str, Any]:
|
|
2664
|
+
"""Get a robot part's user-defined metadata.
|
|
2665
|
+
|
|
2666
|
+
::
|
|
2667
|
+
|
|
2668
|
+
metadata = await cloud.get_robot_part_metadata(robot_part_id="<YOUR-ROBOT-PART-ID>")
|
|
2669
|
+
|
|
2670
|
+
Args:
|
|
2671
|
+
robot_part_id (str): The ID of the robot part with which the user-defined metadata is associated.
|
|
2672
|
+
You can obtain your robot part ID from the Viam app's machine page.
|
|
2673
|
+
|
|
2674
|
+
Returns:
|
|
2675
|
+
Mapping[str, Any]: The user-defined metadata converted from JSON to a Python dictionary.
|
|
2676
|
+
"""
|
|
2677
|
+
request = GetRobotPartMetadataRequest(id=robot_part_id)
|
|
2678
|
+
response: GetRobotPartMetadataResponse = await self._app_client.GetRobotPartMetadata(request)
|
|
2679
|
+
return struct_to_dict(response.data)
|
|
2680
|
+
|
|
2681
|
+
async def update_robot_part_metadata(self, robot_part_id: str, metadata: Mapping[str, Any]) -> None:
|
|
2682
|
+
"""Update a robot part's user-defined metadata.
|
|
2683
|
+
|
|
2684
|
+
::
|
|
2685
|
+
|
|
2686
|
+
await cloud.update_robot_part_metadata(robot_part_id="<YOUR-ROBOT-PART-ID>", metadata=)
|
|
2687
|
+
|
|
2688
|
+
Args:
|
|
2689
|
+
robot_id (str): The ID of the robot part with which to associate the user-defined metadata.
|
|
2690
|
+
You can obtain your robot part ID from the Viam app's machine page.
|
|
2691
|
+
metadata (Mapping[str, Any]): The user-defined metadata converted from JSON to a Python dictionary.
|
|
2692
|
+
"""
|
|
2693
|
+
request = UpdateRobotPartMetadataRequest(id=robot_part_id, data=dict_to_struct(metadata))
|
|
2694
|
+
_: UpdateRobotPartMetadataResponse = await self._app_client.UpdateRobotPartMetadata(request)
|