Skip to content

Commit b26c748

Browse files
authored
DOCS-4403: Add new methods (#4656)
1 parent 4c8be14 commit b26c748

15 files changed

+357
-25
lines changed

.github/workflows/sdk_protos_map.csv

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ base_remote_control,Close,,,Close,,
235235

236236
## Data Manager
237237
data_manager,Sync,No,,Sync,,sync
238+
data_manager,UploadImageToDatasets,No,,UploadImageToDatasets,,,
239+
data_manager,UploadBinaryDataToDatasets,No,,UploadBinaryDataToDatasets,,uploadBinaryDataToDatasets
238240
## HACK: No proto for these (and/or inherited in Go SDK), manually mapping:
239241
data_manager,Reconfigure,No,,Reconfigure,,
240242
data_manager,DoCommand,No,,DoCommand,,doCommand
@@ -255,7 +257,7 @@ mlmodel,Metadata,,metadata,Metadata,,
255257
## HACK: proto for DoCommand or Close (and/or inherited in Go SDK), manually mapping:
256258
mlmodel,Reconfigure,,,Reconfigure,,
257259
mlmodel,DoCommand,,,DoCommand,,
258-
mlmodel,GetResourceName,,get_resource_name,,,
260+
mlmodel,GetResourceName,,get_resource_name,Name,,
259261
mlmodel,Close,,close,Close,,
260262

261263
## Motion
@@ -471,6 +473,9 @@ data_sync,StreamingDataCaptureUpload,,streaming_data_capture_upload,,streamingDa
471473

472474
## Discovery
473475
discovery,DiscoverResources,,discover_resources,DiscoverResources,discoverResources,discoverResources
476+
discovery,GetResourceName,,get_resource_name,Name,getResourceName,name
477+
discovery,DoCommand,,do_command,DoCommand,doCommand,doCommand
478+
discovery,Close,,close,Close,,
474479

475480
## MLTraining
476481
mltraining,SubmitTrainingJob,,submit_training_job,SubmitTrainingJob,,submitTrainingJob

.github/workflows/update_sdk_methods.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ def check_for_unused_methods(methods, type):
766766
if not "used" in methods[lang][type][resource][method].keys():
767767
if resource in ["data_sync", "dataset", "data"]:
768768
continue
769-
if lang == "python" and method not in ["from_robot", "close", "get_resource_name", "get_geometries", "do_command", "proto"] or \
769+
if lang == "python" and method not in ["from_robot", "close", "get_resource_name", "get_geometries", "do_command", "proto", "transform", "updated_fields", "ListUUIDs", "GetTransform", "StreamTransformChanges", "DoCommand"] or \
770770
lang == "go" and method not in ["Reconfigure", "Stream", "ListTunnels", "Close", "DoCommand", "CurrentPosition", "AddTagsToBinaryDataByFilter", "RemoveTagsFromBinaryDataByFilter"] or \
771771
lang == "flutter" and method not in ["getResources", "getStream", "getStreamOptions", "resetStreamOptions", "setStreamOptions", "Discovery.fromProto", "addCallbacks", "getResource"] or \
772772
lang == "typescript" and method not in ["connect", "disconnect", "dial", "isConnected", "discoverComponents", "createServiceClient", "getRoverRentalRobots", "doCommand"]:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Uploads the contents and metadata for an image, adds it to a dataset, and returns the file id of the uploaded data.

static/include/services/apis/generated/data_manager-table.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
| Method Name | Description | `viam-micro-server` Support |
33
| ----------- | ----------- | --------------------------- |
44
| [`Sync`](/dev/reference/apis/services/data/#sync) | Sync data stored on the machine to the cloud. | |
5+
| [`UploadImageToDatasets`](/dev/reference/apis/services/data/#uploadimagetodatasets) | Upload an image data to the specified datasets. | |
6+
| [`UploadBinaryDataToDatasets`](/dev/reference/apis/services/data/#uploadbinarydatatodatasets) | Upload Binary data to the specified datasets. | |
57
| [`Reconfigure`](/dev/reference/apis/services/data/#reconfigure) | Reconfigure this resource. | |
68
| [`DoCommand`](/dev/reference/apis/services/data/#docommand) | Execute model-specific commands that are not otherwise defined by the service API. | |
79
| [`GetResourceName`](/dev/reference/apis/services/data/#getresourcename) | Get the `ResourceName` for this instance of the service. | |

static/include/services/apis/generated/data_manager.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,89 @@ For more information, see the [TypeScript SDK Docs](https://ts.viam.dev/classes/
5757
{{% /tab %}}
5858
{{< /tabs >}}
5959

60+
### UploadImageToDatasets
61+
62+
Upload an image data to the specified datasets.
63+
64+
{{< tabs >}}
65+
{{% tab name="Go" %}}
66+
67+
**Parameters:**
68+
69+
- `ctx` [(Context)](https://pkg.go.dev/context#Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.
70+
- `image` [(image.Image)](https://pkg.go.dev/image#Image)
71+
- `datasetIDs`
72+
- `tags` [([]string)](https://pkg.go.dev/builtin#string)
73+
- `mimeType` [(datasyncpb.MimeType)](https://pkg.go.dev/go.viam.com/api/app/datasync/v1#MimeType)
74+
- `extra` [(map[string]interface{})](https://go.dev/blog/maps): Extra options to pass to the underlying RPC call.
75+
76+
**Returns:**
77+
78+
- [(error)](https://pkg.go.dev/builtin#error): An error, if one occurred.
79+
80+
For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/services/datamanager#Service).
81+
82+
{{% /tab %}}
83+
{{< /tabs >}}
84+
85+
### UploadBinaryDataToDatasets
86+
87+
Upload Binary data to the specified datasets.
88+
89+
{{< tabs >}}
90+
{{% tab name="Go" %}}
91+
92+
**Parameters:**
93+
94+
- `ctx` [(Context)](https://pkg.go.dev/context#Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.
95+
- `binaryData` [([]byte)](https://pkg.go.dev/builtin#byte)
96+
- `datasetIDs`
97+
- `tags` [([]string)](https://pkg.go.dev/builtin#string)
98+
- `mimeType` [(datasyncpb.MimeType)](https://pkg.go.dev/go.viam.com/api/app/datasync/v1#MimeType)
99+
- `extra` [(map[string]interface{})](https://go.dev/blog/maps): Extra options to pass to the underlying RPC call.
100+
101+
**Returns:**
102+
103+
- [(error)](https://pkg.go.dev/builtin#error): An error, if one occurred.
104+
105+
For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/services/datamanager#Service).
106+
107+
{{% /tab %}}
108+
{{% tab name="TypeScript" %}}
109+
110+
**Parameters:**
111+
112+
- `binaryData` (Uint8Array) (required): The binary data to upload.
113+
- `tags` (string) (required): Tags to associate with the binary data.
114+
- `datasetIds` (string) (required): IDs of the datasets to associate the binary data with.
115+
- `mimeType` (MimeType) (required): The MIME type of the binary data.
116+
- `extra` (None) (optional): Extra arguments to pass to the upload request.
117+
- `callOptions` (CallOptions) (optional): Call options for the upload request.
118+
119+
**Returns:**
120+
121+
- (Promise<void>)
122+
123+
**Example:**
124+
125+
```ts {class="line-numbers linkable-line-numbers"}
126+
const dataManager = new VIAM.DataManagerClient(
127+
machine,
128+
'my_data_manager'
129+
);
130+
await dataManager.uploadBinaryDataToDatasets(
131+
new Uint8Array([1, 2, 3]),
132+
['tag1', 'tag2'],
133+
['datasetId1', 'datasetId2'],
134+
MimeType.MIME_TYPE_JPEG
135+
);
136+
```
137+
138+
For more information, see the [TypeScript SDK Docs](https://ts.viam.dev/classes/DataManagerClient.html#uploadbinarydatatodatasets).
139+
140+
{{% /tab %}}
141+
{{< /tabs >}}
142+
60143
### Reconfigure
61144

62145
Reconfigure this resource.

static/include/services/apis/generated/discovery-table.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
| Method Name | Description |
33
| ----------- | ----------- |
44
| [`DiscoverResources`](/dev/reference/apis/services/discovery/#discoverresources) | Get a list of component configs of all resources available to configure on a machine based on the hardware that is connected to or part of the machine. |
5+
| [`GetResourceName`](/dev/reference/apis/services/discovery/#getresourcename) | Get the `ResourceName` for this instance of the service. |
6+
| [`DoCommand`](/dev/reference/apis/services/discovery/#docommand) | Execute model-specific commands. |
7+
| [`Close`](/dev/reference/apis/services/discovery/#close) | Safely shut down the resource and prevent further use. |

static/include/services/apis/generated/discovery.md

Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,236 @@ For more information, see the [Flutter SDK Docs](https://flutter.viam.dev/viam_s
9595

9696
{{% /tab %}}
9797
{{< /tabs >}}
98+
99+
### GetResourceName
100+
101+
Get the `ResourceName` for this instance of the service.
102+
103+
{{< tabs >}}
104+
{{% tab name="Python" %}}
105+
106+
**Parameters:**
107+
108+
- `name` ([str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)) (required): The name of the Resource.
109+
110+
**Returns:**
111+
112+
- ([viam.proto.common.ResourceName](https://python.viam.dev/autoapi/viam/proto/common/index.html#viam.proto.common.ResourceName)): The ResourceName of this Resource.
113+
114+
**Example:**
115+
116+
```python {class="line-numbers linkable-line-numbers"}
117+
my_discovery_svc_name = DiscoveryClient.get_resource_name("my_discovery_svc")
118+
```
119+
120+
For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/services/discovery/client/index.html#viam.services.discovery.client.DiscoveryClient.get_resource_name).
121+
122+
{{% /tab %}}
123+
{{% tab name="Go" %}}
124+
125+
**Parameters:**
126+
127+
- None.
128+
129+
**Returns:**
130+
131+
- [(Name)](https://pkg.go.dev/go.viam.com/[email protected]/resource#Name)
132+
133+
**Example:**
134+
135+
```go {class="line-numbers linkable-line-numbers"}
136+
myDiscoverySvc, err := discovery.FromRobot(machine, "my_discovery_svc")
137+
138+
err = myDiscoverySvc.Name()
139+
```
140+
141+
For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/resource#Resource).
142+
143+
{{% /tab %}}
144+
{{% tab name="TypeScript" %}}
145+
146+
**Parameters:**
147+
148+
- None.
149+
150+
**Returns:**
151+
152+
- (string): The name of the resource.
153+
154+
**Example:**
155+
156+
```ts {class="line-numbers linkable-line-numbers"}
157+
discovery.name
158+
```
159+
160+
For more information, see the [TypeScript SDK Docs](https://ts.viam.dev/classes/DiscoveryClient.html#name).
161+
162+
{{% /tab %}}
163+
{{% tab name="Flutter" %}}
164+
165+
**Parameters:**
166+
167+
- `name` [String](https://api.flutter.dev/flutter/dart-core/String-class.html) (required)
168+
169+
**Returns:**
170+
171+
- [ResourceName](https://flutter.viam.dev/viam_sdk/ResourceName-class.html)
172+
173+
For more information, see the [Flutter SDK Docs](https://flutter.viam.dev/viam_sdk/DiscoveryClient/getResourceName.html).
174+
175+
{{% /tab %}}
176+
{{< /tabs >}}
177+
178+
### DoCommand
179+
180+
Execute model-specific commands.
181+
If you are implementing your own generic service and want to add features that have no corresponding built-in API method, you can implement them with [`DoCommand`](/dev/reference/sdks/docommand/).
182+
183+
{{< tabs >}}
184+
{{% tab name="Python" %}}
185+
186+
**Parameters:**
187+
188+
- `command` (Mapping[[str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str), ValueTypes]) (required): The command to execute.
189+
- `timeout` ([float](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.
190+
191+
**Returns:**
192+
193+
- (Mapping[[str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str), viam.utils.ValueTypes]): Result of the executed command.
194+
195+
**Example:**
196+
197+
```python {class="line-numbers linkable-line-numbers"}
198+
my_discovery_svc = DiscoveryClient.from_robot(robot=machine, "my_discovery_svc")
199+
200+
my_command = {
201+
"cmnd": "dosomething",
202+
"someparameter": 52
203+
}
204+
205+
await my_discovery_svc.do_command(command=my_command)
206+
```
207+
208+
For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/services/discovery/client/index.html#viam.services.discovery.client.DiscoveryClient.do_command).
209+
210+
{{% /tab %}}
211+
{{% tab name="Go" %}}
212+
213+
**Parameters:**
214+
215+
- `ctx` [(Context)](https://pkg.go.dev/context#Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.
216+
- `cmd` [(map[string]interface{})](https://go.dev/blog/maps): The command to execute.
217+
218+
**Returns:**
219+
220+
- [(map[string]interface{})](https://pkg.go.dev/builtin#string): The command response.
221+
- [(error)](https://pkg.go.dev/builtin#error): An error, if one occurred.
222+
223+
**Example:**
224+
225+
```go {class="line-numbers linkable-line-numbers"}
226+
myDiscoverySvc, err := discovery.FromRobot(machine, "my_discovery_svc")
227+
228+
command := map[string]interface{}{"cmd": "test", "data1": 500}
229+
result, err := myDiscoverySvc.DoCommand(context.Background(), command)
230+
```
231+
232+
For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/resource#Resource).
233+
234+
{{% /tab %}}
235+
{{% tab name="TypeScript" %}}
236+
237+
**Parameters:**
238+
239+
- `command` ([Struct](https://ts.viam.dev/classes/Struct.html)) (required): The command to execute.
240+
- `callOptions` (CallOptions) (optional)
241+
242+
**Returns:**
243+
244+
- (Promise<[JsonValue](https://ts.viam.dev/types/JsonValue.html)>)
245+
246+
**Example:**
247+
248+
```ts {class="line-numbers linkable-line-numbers"}
249+
import { Struct } from '@viamrobotics/sdk';
250+
251+
const result = await resource.doCommand(
252+
Struct.fromJson({
253+
myCommand: { key: 'value' },
254+
})
255+
);
256+
```
257+
258+
For more information, see the [TypeScript SDK Docs](https://ts.viam.dev/classes/DiscoveryClient.html#docommand).
259+
260+
{{% /tab %}}
261+
{{% tab name="Flutter" %}}
262+
263+
**Parameters:**
264+
265+
- `command` [Map](https://api.flutter.dev/flutter/dart-core/Map-class.html)\<[String](https://api.flutter.dev/flutter/dart-core/String-class.html), dynamic\> (required)
266+
267+
**Returns:**
268+
269+
- [Future](https://api.flutter.dev/flutter/dart-async/Future-class.html)\<[Map](https://api.flutter.dev/flutter/dart-core/Map-class.html)\<[String](https://api.flutter.dev/flutter/dart-core/String-class.html), dynamic\>\>
270+
271+
**Example:**
272+
273+
```dart {class="line-numbers linkable-line-numbers"}
274+
// Example using doCommand with an arm component
275+
const command = {'cmd': 'test', 'data1': 500};
276+
var result = myArm.doCommand(command);
277+
```
278+
279+
For more information, see the [Flutter SDK Docs](https://flutter.viam.dev/viam_sdk/DiscoveryClient/doCommand.html).
280+
281+
{{% /tab %}}
282+
{{< /tabs >}}
283+
284+
### Close
285+
286+
Safely shut down the resource and prevent further use.
287+
288+
{{< tabs >}}
289+
{{% tab name="Python" %}}
290+
291+
**Parameters:**
292+
293+
- None.
294+
295+
**Returns:**
296+
297+
- None.
298+
299+
**Example:**
300+
301+
```python {class="line-numbers linkable-line-numbers"}
302+
my_discovery_svc = DiscoveryClient.from_robot(robot=machine, name="my_discovery_svc")
303+
await my_discovery_svc.close()
304+
```
305+
306+
For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/services/discovery/client/index.html#viam.services.discovery.client.DiscoveryClient.close).
307+
308+
{{% /tab %}}
309+
{{% tab name="Go" %}}
310+
311+
**Parameters:**
312+
313+
- `ctx` [(Context)](https://pkg.go.dev/context#Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.
314+
315+
**Returns:**
316+
317+
- [(error)](https://pkg.go.dev/builtin#error): An error, if one occurred.
318+
319+
**Example:**
320+
321+
```go {class="line-numbers linkable-line-numbers"}
322+
myDiscoverySvc, err := discovery.FromRobot(machine, "my_discovery_svc")
323+
324+
err = myDiscoverySvc.Close(context.Background())
325+
```
326+
327+
For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/resource#Resource).
328+
329+
{{% /tab %}}
330+
{{< /tabs >}}

0 commit comments

Comments
 (0)