Generic service API | Service APIs
Generic service API
The generic service API allows you to give commands to your generic services for running model-specific commands using DoCommand.
The generic service supports the following methods:
| Method Name | Description |
|---|---|
DoCommand |
Execute model-specific commands. |
GetResourceName |
Get the ResourceName for this instance of the generic service. |
Close |
Safely shut down the resource and prevent further use. |
API
DoCommand
Execute model-specific commands. 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.
Parameters:
command(Mapping[ str, ValueTypes]) (required): The command to execute.timeout( float) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.
Returns:
- (Mapping[ str, Any]): : Result of the executed command.
Example:
For more information, see the Python SDK Docs.
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:
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:
For more information, see the TypeScript SDK Docs.
Parameters:
Returns:
Example:
For more information, see the Flutter SDK Docs.
GetResourceName
Get the ResourceName for this instance of the generic service.
Parameters:
name( str) (required): The name of the Resource.
Returns:
- ( viam.proto.common.ResourceName): : The ResourceName of this Resource.
Example:
For more information, see the Python SDK Docs.
Parameters:
- None.
Returns:
Example:
For more information, see the Go SDK Docs.
Parameters:
- None.
Returns:
- (string): The name of the resource.
Example:
For more information, see the TypeScript SDK Docs.
Parameters:
nameString (required)
Returns:
For more information, see the Flutter SDK Docs.
Close
Safely shut down the resource and prevent further use.
Parameters:
- None.
Returns:
- None.
Example:
For more information, see the Python SDK Docs.