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. | |
Reconfigure | Reconfigure this resource. | |
DoCommand | Execute model-specific commands that are not otherwise defined by the service API. | |
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 the Viam app. For information about that API, see Data Client API.
Establish a connection
To get started using Viam’s SDKs to connect to and control your machine, go to your machine’s page on the Viam app, navigate to the CONNECT tab’s Code sample page, select your preferred programming language, and copy the sample code.
API key and API key ID
By default, the sample code does not include your machine API key and API key ID. We strongly recommend that you add your API key and API key ID as an environment variable and import this variable into your development environment as needed.
To show your machine’s API key and API key ID in the sample code, toggle Include API key on the CONNECT tab’s Code sample page.
Caution
Do not share your API key or machine address publicly. Sharing this information could compromise your system security by allowing unauthorized access to your machine, or to the computer running your machine.
When executed, this sample code creates a connection to your machine as a client.
The following examples assume that you have a machine configured with an data_manager
service.
import (
"go.viam.com/rdk/services/datamanager"
)
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:
// Sync data stored on the machine to the cloud.
err := data.Sync(context.Background(), nil)
For more information, see the Go 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.
For built-in service models, any model-specific commands available are covered with each model’s documentation.
If you are implementing your own data manager service and add features that have no built-in API method, you can access 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:
myDataManager, err := data_manager.FromRobot(machine, "my_data_manager")
command := map[string]interface{}{"cmd": "test", "data1": 500}
result, err := myDataManager.DoCommand(context.Background(), command)
For more information, see the Go 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.FromRobot(machine, "my_data_manager")
err := data.Close(context.Background())
For more information, see the Go SDK Docs.
Have questions, or want to meet other people working on robots? Join our Community Discord.
If you notice any issues with the documentation, feel free to file an issue or edit this file.
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!