viam.app.viam_client
Attributes
Classes
gRPC client for all communication and interaction with app. |
Module Contents
- viam.app.viam_client.LOGGER
- class viam.app.viam_client.ViamClient[source]
gRPC client for all communication and interaction with app.
ViamClient class for creating and managing specialized client instances. There is currently 1 way to instantiate a ViamClient object:
ViamClient.create_from_dial_options(...)
- classmethod create_from_dial_options(dial_options: viam.rpc.dial.DialOptions, app_url: str | None = None) typing_extensions.Self [source]
- Async:
Create ViamClient that establishes a connection to the Viam app.
dial_options = DialOptions.with_api_key("<API-KEY>", "<API-KEY-ID>") ViamClient.create_from_dial_options(dial_options)
- Parameters:
dial_options (viam.rpc.dial.DialOptions) – Required information for authorization and connection to app. creds and auth_entity fields are required.
app_url – (Optional[str]): URL of app. Uses app.viam.com if not specified.
- Raises:
ValueError – If the input parameters are missing a required field or simply invalid.
- Returns:
The ViamClient.
- Return type:
Self
- property data_client: viam.app.data_client.DataClient
Instantiate and return a DataClient object used to make data and data_sync method calls. To use the DataClient, you must first instantiate a ViamClient.
async def connect() -> ViamClient: # Replace "<API-KEY>" (including brackets) with your API key and "<API-KEY-ID>" with your API key ID dial_options = DialOptions.with_api_key("<API-KEY>", "<API-KEY-ID>") return await ViamClient.create_from_dial_options(dial_options) async def main(): viam_client = await connect() # Instantiate a DataClient to run data client API methods on data_client = viam_client.data_client
- property app_client: viam.app.app_client.AppClient
Instantiate and return an AppClient used to make app method calls. To use the AppClient, you must first instantiate a ViamClient.
async def connect() -> ViamClient: # Replace "<API-KEY>" (including brackets) with your API key and "<API-KEY-ID>" with your API key ID dial_options = DialOptions.with_api_key("<API-KEY>", "<API-KEY-ID>") return await ViamClient.create_from_dial_options(dial_options) async def main(): viam_client = await connect() # Instantiate an AppClient called "fleet" to run fleet management API methods on fleet = viam_client.app_client
- property ml_training_client: viam.app.ml_training_client.MLTrainingClient
Instantiate and return a MLTrainingClient used to make ml_training method calls. To use the MLTrainingClient, you must first instantiate a ViamClient.
async def connect() -> ViamClient: # Replace "<API-KEY>" (including brackets) with your API key and "<API-KEY-ID>" with your API key ID dial_options = DialOptions.with_api_key("<API-KEY>", "<API-KEY-ID>") return await ViamClient.create_from_dial_options(dial_options) async def main(): viam_client = await connect() # Instantiate an MLTrainingClient to run ML training client API methods on ml_training_client = viam_client.ml_training_client
- property billing_client: viam.app.billing_client.BillingClient
- Instantiate and return a BillingClient used to make billing method calls.
To use the BillingClient, you must first instantiate a ViamClient.
async def connect() -> ViamClient: # Replace "<API-KEY>" (including brackets) with your API key and "<API-KEY-ID>" with your API key ID dial_options = DialOptions.with_api_key("<API-KEY>", "<API-KEY-ID>") return await ViamClient.create_from_dial_options(dial_options) async def main(): viam_client = await connect() # Instantiate a BillingClient to run billing client API methods on billing_client = viam_client.billing_client
- property provisioning_client: viam.app.provisioning_client.ProvisioningClient
Instantiate and return a ProvisioningClient used to make provisioning method calls. To use the ProvisioningClient, you must first instantiate a ViamClient.
async def connect() -> ViamClient: # Replace "<API-KEY>" (including brackets) with your API key and "<API-KEY-ID>" with your API key ID dial_options = DialOptions.with_api_key("<API-KEY>", "<API-KEY-ID>") return await ViamClient.create_from_dial_options(dial_options) async def main(): viam_client = await connect() # Instantiate a ProvisioningClient to run provisioning API methods on provisioning_client = viam_client.provisioning_client
- async connect_to_machine(*, address: str | None = None, id: str | None = None) viam.robot.client.RobotClient [source]
Connect to a machine using existing credentials.
A connection can be attempted using either the machine’s address or its ID. If both an address and ID are provided, the address will take precedence and the ID will be ignored.
async def connect() -> ViamClient: # Replace "<API-KEY>" (including brackets) with your API key and "<API-KEY-ID>" with your API key ID dial_options = DialOptions.with_api_key("<API-KEY>", "<API-KEY-ID>") return await ViamClient.create_from_dial_options(dial_options) async def main(): viam_client = await connect() # Connect to a machine and obtain a RobotClient # Replace "<MACHINE_ADDRESS>" (including brackets) with your machine's connection address machine = await viam_client.connect_to_machine(address="<MACHINE_ADDRESS>")
- Parameters:
address (Optional[str]) – The address (FQDN) of the machine. Defaults to None.
id (Optional[str]) – The ID (as a UUID) of the machine. Defaults to None.
- Raises:
ValueError – If neither an address nor ID is provided.
- Returns:
The active connection to the machine.
- Return type: