Data management service API
The data management service API allows you to sync data stored on the machine it is deployed on to the cloud.
The data management service supports the following methods:
| Method Name | Description | viam-micro-server Support |
|---|---|---|
Sync | Sync data stored on the machine to the cloud. | |
UploadBinaryDataToDatasets | Upload Binary data to the specified datasets. | |
Reconfigure | Reconfigure this resource. | |
DoCommand | Execute model-specific commands that are not otherwise defined by the service API. | |
GetResourceName | Get the ResourceName for this instance of the service. | |
Close | Safely shut down the resource and prevent further use. |
The data client API supports a separate set of methods that allow you to upload and export data to and from Viam. For information about that API, see Data Client API.
API
Sync
Important
This method is not yet available in the Viam Python SDK.
Sync data stored on the machine to the cloud.
Parameters:
ctx(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.extra(map[string]interface{}): Extra options to pass to the underlying RPC call.
Returns:
- (error): An error, if one occurred.
Example:
data, err := datamanager.FromProvider(machine, "my_data_manager")
// Sync data stored on the machine to the cloud.
err := data.Sync(context.Background(), nil)
For more information, see the Go SDK Docs.
Parameters:
extra(None) (optional): Extra arguments to pass to the sync request.callOptions(CallOptions) (optional): Call options for the sync request.
Returns:
- (Promise
)
Example:
const dataManager = new VIAM.DataManagerClient(
machine,
'my_data_manager'
);
await dataManager.sync();
For more information, see the TypeScript SDK Docs.
UploadBinaryDataToDatasets
Upload Binary data to the specified datasets.
Parameters:
ctx(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.binaryData([]byte)datasetIDstags([]string)mimeType(datasyncpb.MimeType)extra(map[string]interface{}): Extra options to pass to the underlying RPC call.
Returns:
- (error): An error, if one occurred.
For more information, see the Go SDK Docs.
Parameters:
binaryData(Uint8Array) (required): The binary data to upload.tags(string) (required): Tags to associate with the binary data.datasetIds(string) (required): IDs of the datasets to associate the binary data with.mimeType(MimeType) (required): The MIME type of the binary data.extra(None) (optional): Extra arguments to pass to the upload request.callOptions(CallOptions) (optional): Call options for the upload request.
Returns:
- (Promise
)
Example:
const dataManager = new VIAM.DataManagerClient(
machine,
'my_data_manager'
);
await dataManager.uploadBinaryDataToDatasets(
new Uint8Array([1, 2, 3]),
['tag1', 'tag2'],
['datasetId1', 'datasetId2'],
MimeType.MIME_TYPE_JPEG
);
For more information, see the TypeScript SDK Docs.
Reconfigure
Reconfigure this resource. Reconfigure must reconfigure the resource atomically and in place.
Parameters:
ctx(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.deps(Dependencies): The resource dependencies.conf(Config): The resource configuration.
Returns:
- (error): An error, if one occurred.
For more information, see the Go SDK Docs.
DoCommand
Execute model-specific commands that are not otherwise defined by the service API.
Most models do not implement DoCommand.
Any available model-specific commands should be covered in the model’s documentation.
If you are implementing your own data manager service and want to add features that have no corresponding built-in API method, you can implement them with DoCommand.
Parameters:
ctx(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.cmd(map[string]interface{}): The command to execute.
Returns:
- (map[string]interface{}): The command response.
- (error): An error, if one occurred.
Example:
myDataManagerSvc, err := datamanager.FromProvider(machine, "my_data_manager_svc")
command := map[string]interface{}{"cmd": "test", "data1": 500}
result, err := myDataManagerSvc.DoCommand(context.Background(), command)
For more information, see the Go SDK Docs.
Parameters:
command(Struct) (required): The command to execute. Accepts either a Struct or a plain object, which will be converted automatically.callOptions(CallOptions) (optional)
Returns:
- (Promise<JsonValue>)
Example:
// Plain object (recommended)
const result = await resource.doCommand({
myCommand: { key: 'value' },
});
// Struct (still supported)
import { Struct } from '@viamrobotics/sdk';
const result = await resource.doCommand(
Struct.fromJson({ myCommand: { key: 'value' } })
);
For more information, see the TypeScript SDK Docs.
GetResourceName
Get the ResourceName for this instance of the service.
Parameters:
- None.
Returns:
Example:
data, err := datamanager.FromProvider(machine, "my_data_manager")
err := data.Name()
For more information, see the Go SDK Docs.
Parameters:
- None.
Returns:
- (string): The name of the resource.
Example:
data_manager.name
For more information, see the TypeScript SDK Docs.
Close
Safely shut down the resource and prevent further use.
Parameters:
ctx(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.
Returns:
- (error): An error, if one occurred.
Example:
data, err := datamanager.FromProvider(machine, "my_data_manager")
err := data.Close(context.Background())
For more information, see the Go SDK Docs.
Was this page helpful?
Glad to hear it! If you have any other feedback please let us know:
We're sorry about that. To help us improve, please tell us what we can do better:
Thank you!