From ff8ac909054c989039e763d780d1d501dadae4ab Mon Sep 17 00:00:00 2001 From: "promptless[bot]" <179508745+promptless[bot]@users.noreply.github.com> Date: Sat, 28 Jun 2025 05:17:39 +0000 Subject: [PATCH 1/3] Documentation updates from Promptless --- docs/dev/reference/apis/billing-client.md | 81 --------- docs/dev/reference/apis/components/arm.md | 42 ----- docs/dev/reference/apis/components/base.md | 32 ---- docs/dev/reference/apis/components/board.md | 34 ---- docs/dev/reference/apis/components/button.md | 32 ---- docs/dev/reference/apis/components/camera.md | 32 ---- docs/dev/reference/apis/components/encoder.md | 32 ---- docs/dev/reference/apis/components/gantry.md | 32 ---- docs/dev/reference/apis/components/generic.md | 40 ----- docs/dev/reference/apis/components/gripper.md | 32 ---- .../apis/components/input-controller.md | 32 ---- docs/dev/reference/apis/components/motor.md | 32 ---- .../apis/components/movement-sensor.md | 32 ---- .../reference/apis/components/power-sensor.md | 32 ---- docs/dev/reference/apis/components/sensor.md | 32 ---- docs/dev/reference/apis/components/servo.md | 32 ---- docs/dev/reference/apis/components/switch.md | 32 ---- docs/dev/reference/apis/data-client.md | 79 --------- docs/dev/reference/apis/fleet.md | 86 ---------- docs/dev/reference/apis/ml-training-client.md | 81 --------- docs/dev/reference/apis/robot.md | 156 ------------------ docs/dev/reference/apis/services/SLAM.md | 29 ---- docs/dev/reference/apis/services/base-rc.md | 20 --- docs/dev/reference/apis/services/data.md | 22 --- docs/dev/reference/apis/services/discovery.md | 29 ---- docs/dev/reference/apis/services/generic.md | 34 ---- docs/dev/reference/apis/services/ml.md | 42 ----- docs/dev/reference/apis/services/motion.md | 32 ---- .../dev/reference/apis/services/navigation.md | 29 ---- docs/dev/reference/apis/services/vision.md | 29 ---- 30 files changed, 1281 deletions(-) diff --git a/docs/dev/reference/apis/billing-client.md b/docs/dev/reference/apis/billing-client.md index 425b311dc4..83bb753868 100644 --- a/docs/dev/reference/apis/billing-client.md +++ b/docs/dev/reference/apis/billing-client.md @@ -25,87 +25,6 @@ The billing client API supports the following methods: {{< readfile "/static/include/app/apis/generated/billing-table.md" >}} -## Establish a connection - -To use the Viam billing client API, you first need to instantiate a `ViamClient` and then instantiate a `BillingClient`. - -You will also need an API key and API key ID to authenticate your session. -Your API key needs to have [Org owner permissions](/manage/manage/rbac/#organization-settings-and-roles) to use the billing client API. -To get an API key (and corresponding ID), you have two options: - -- [Create an API key in the web UI](/operate/control/api-keys/#add-an-api-key) -- [Create an API key using the Viam CLI](/dev/tools/cli/#create-an-organization-api-key) - -The following example instantiates a `ViamClient`, authenticating with an API key, and then instantiates a `BillingClient`: - -{{< tabs >}} -{{% tab name="Python" %}} - -```python {class="line-numbers linkable-line-numbers" data-line="12, 16"} -import asyncio - -from viam.rpc.dial import DialOptions, Credentials -from viam.app.viam_client import ViamClient -from viam.app.billing_client import BillingClient - - -async def connect() -> ViamClient: - dial_options = DialOptions( - credentials=Credentials( - type="api-key", - # Replace "" (including brackets) with your machine's API key - payload='', - ), - # Replace "" (including brackets) with your machine's - # API key ID - auth_entity='' - ) - return await ViamClient.create_from_dial_options(dial_options) - - -async def main(): - # Make a ViamClient - viam_client = await connect() - # Instantiate a BillingClient to run data client API methods on - billing_client = viam_client.billing_client - - viam_client.close() - -if __name__ == '__main__': - asyncio.run(main()) -``` - -{{% /tab %}} -{{% tab name="TypeScript" %}} - -```ts {class="line-numbers linkable-line-numbers" data-line="3, 5"} -async function connect(): Promise { - // Replace "" (including brackets) with your machine's - const API_KEY_ID = ""; - // Replace "" (including brackets) with your machine's API key - const API_KEY = ""; - const opts: VIAM.ViamClientOptions = { - serviceHost: "https://app.viam.com:443", - credentials: { - type: "api-key", - authEntity: API_KEY_ID, - payload: API_KEY, - }, - }; - - const client = await VIAM.createViamClient(opts); - return client; -} - -const viamClient = await connect(); -const billingClient = viamClient.billingClient; -``` - -{{% /tab %}} -{{< /tabs >}} - -Once you have instantiated a `BillingClient`, you can run [API methods](#api) against the `BillingClient` object (named `billing_client` in the examples). - ## API {{< readfile "/static/include/app/apis/generated/billing.md" >}} diff --git a/docs/dev/reference/apis/components/arm.md b/docs/dev/reference/apis/components/arm.md index e6bdc0ae18..6575c7ffdd 100644 --- a/docs/dev/reference/apis/components/arm.md +++ b/docs/dev/reference/apis/components/arm.md @@ -19,48 +19,6 @@ The arm component supports the following methods: {{< readfile "/static/include/components/apis/generated/arm-table.md" >}} -## Establish a connection - -To get started using Viam's SDKs to connect to and control your arm and the rest of your machine, go to your machine's page. -Navigate to the **CONNECT** tab's **Code sample** page, select your preferred programming language, and copy the sample code. - -{{% snippet "show-secret.md" %}} - -When executed, this sample code creates a connection to your machine as a client. - -The following examples assume you have an arm called `"my_arm"` configured as a component of your machine. -If your arm has a different name, change the `name` in the code. - -Import the arm package for the SDK you are using: - -{{< tabs >}} -{{% tab name="Python" %}} - -```python -from viam.components.arm import Arm -# To use move_to_position: -from viam.proto.common import Pose -# To use move_to_joint_positions: -from viam.proto.component.arm import JointPositions -``` - -{{% /tab %}} -{{% tab name="Go" %}} - -```go -import ( - "go.viam.com/rdk/components/arm" - // To use MoveToPosition: - "go.viam.com/rdk/referenceframe" - "go.viam.com/rdk/spatialmath" - // To use MoveToJointPositions ("armapi" name optional, but necessary if importing other packages called "v1"): - armapi "go.viam.com/api/component/arm/v1" -) -``` - -{{% /tab %}} -{{< /tabs >}} - ## API {{< readfile "/static/include/components/apis/generated/arm.md" >}} diff --git a/docs/dev/reference/apis/components/base.md b/docs/dev/reference/apis/components/base.md index 0541287807..1011cb655e 100644 --- a/docs/dev/reference/apis/components/base.md +++ b/docs/dev/reference/apis/components/base.md @@ -18,38 +18,6 @@ The base component supports the following methods: {{< readfile "/static/include/components/apis/generated/base-table.md" >}} -## Establish a connection - -To get started using Viam's SDKs to connect to and control your base and the rest of your machine, go to your machine's page, navigate to the **CONNECT** tab's **Code sample** page, select your preferred programming language, and copy the sample code. - -{{% snippet "show-secret.md" %}} - -When executed, this sample code creates a connection to your machine as a client. - -The following examples assume you have a wheeled base called `"my_base"` configured as a component of your machine. -If your base has a different name, change the `name` in the code. - -Import the base package for the SDK you are using: - -{{< tabs >}} -{{% tab name="Python" %}} - -```python -from viam.components.base import Base -``` - -{{% /tab %}} -{{% tab name="Go" %}} - -```go -import ( - "go.viam.com/rdk/components/base" -) -``` - -{{% /tab %}} -{{< /tabs >}} - ## API {{< readfile "/static/include/components/apis/generated/base.md" >}} diff --git a/docs/dev/reference/apis/components/board.md b/docs/dev/reference/apis/components/board.md index 9d54a69eb4..d0249cb6bf 100644 --- a/docs/dev/reference/apis/components/board.md +++ b/docs/dev/reference/apis/components/board.md @@ -18,40 +18,6 @@ The board component supports the following methods: {{< readfile "/static/include/components/apis/generated/board-table.md" >}} -## Establish a connection - -To get started using Viam's SDKs to connect to and control your board and the rest of your machine, go to your machine's page. -Navigate to the **CONNECT** tab's **Code sample** page, select your preferred programming language, and copy the sample code. - -{{% snippet "show-secret.md" %}} - -When executed, this sample code will create a connection to your machine as a client. -Then control your machine programmatically by getting your `board` component from the machine with `FromRobot` and adding API method calls, as shown in the following examples. - -The following examples assume you have a board called `"my_board"` configured as a component of your machine. -If your board has a different name, change the `name` in the code. - -Import the board package for the SDK you are using: - -{{< tabs >}} -{{% tab name="Python" %}} - -```python -from viam.components.board import Board -``` - -{{% /tab %}} -{{% tab name="Go" %}} - -```go -import ( - "go.viam.com/rdk/components/board" -) -``` - -{{% /tab %}} -{{< /tabs >}} - ## API {{< readfile "/static/include/components/apis/generated/board.md" >}} diff --git a/docs/dev/reference/apis/components/button.md b/docs/dev/reference/apis/components/button.md index 3f3e42931f..f2c5fb9bf3 100644 --- a/docs/dev/reference/apis/components/button.md +++ b/docs/dev/reference/apis/components/button.md @@ -16,38 +16,6 @@ The button component supports the following methods: {{< readfile "/static/include/components/apis/generated/button-table.md" >}} -## Establish a connection - -To get started using Viam's SDKs to connect to and control your button and the rest of your machine, go to your machine's page, navigate to the **CONNECT** tab's **Code sample** page, select your preferred programming language, and copy the sample code. - -{{% snippet "show-secret.md" %}} - -When executed, this sample code creates a connection to your machine as a client. - -The following examples assume you have an button called `"my_button"` configured as a component of your machine. -If your button has a different name, change the `name` in the code. - -Import the button package for the SDK you are using: - -{{< tabs >}} -{{% tab name="Python" %}} - -```python -from viam.components.button import Button -``` - -{{% /tab %}} -{{% tab name="Go" %}} - -```go -import ( - "go.viam.com/rdk/components/button" -) -``` - -{{% /tab %}} -{{< /tabs >}} - ## API {{< readfile "/static/include/components/apis/generated/button.md" >}} diff --git a/docs/dev/reference/apis/components/camera.md b/docs/dev/reference/apis/components/camera.md index 1d0522fb07..b11f3a65e8 100644 --- a/docs/dev/reference/apis/components/camera.md +++ b/docs/dev/reference/apis/components/camera.md @@ -24,38 +24,6 @@ The camera component supports the following methods: {{< readfile "/static/include/components/apis/generated/camera-table.md" >}} -## Establish a connection - -To get started using Viam's SDKs to connect to and control your camera and the rest of your machine, go to your machine's page, navigate to the **CONNECT** tab's **Code sample** page, select your preferred programming language, and copy the sample code. - -{{% snippet "show-secret.md" %}} - -When executed, this sample code creates a connection to your machine as a client. - -The following examples assume you have a camera called `"my_camera"` configured as a component of your machine. -If your camera has a different name, change the `name` in the code. - -Import the camera package for the SDK you are using: - -{{< tabs >}} -{{% tab name="Python" %}} - -```python -from viam.components.camera import Camera -``` - -{{% /tab %}} -{{% tab name="Go" %}} - -```go -import ( - "go.viam.com/rdk/components/camera" -) -``` - -{{% /tab %}} -{{< /tabs >}} - ## API {{< readfile "/static/include/components/apis/generated/camera.md" >}} diff --git a/docs/dev/reference/apis/components/encoder.md b/docs/dev/reference/apis/components/encoder.md index 3a26e2253c..e1e8634cb4 100644 --- a/docs/dev/reference/apis/components/encoder.md +++ b/docs/dev/reference/apis/components/encoder.md @@ -18,38 +18,6 @@ The encoder component supports the following methods: {{< readfile "/static/include/components/apis/generated/encoder-table.md" >}} -## Establish a connection - -To get started using Viam's SDKs to connect to and control your encoder and the rest of your machine, go to your machine's page, navigate to the **CONNECT** tab's **Code sample** page, select your preferred programming language, and copy the sample code. - -{{% snippet "show-secret.md" %}} - -When executed, this sample code creates a connection to your machine as a client. - -The following examples assume you have an encoder called `"my_encoder"` configured as a component of your machine. -If your encoder has a different name, change the `name` in the code. - -Import the encoder package for the SDK you are using: - -{{< tabs >}} -{{% tab name="Python" %}} - -```python -from viam.components.encoder import Encoder -``` - -{{% /tab %}} -{{% tab name="Go" %}} - -```go -import ( - "go.viam.com/rdk/components/encoder" -) -``` - -{{% /tab %}} -{{< /tabs >}} - ## API {{< readfile "/static/include/components/apis/generated/encoder.md" >}} diff --git a/docs/dev/reference/apis/components/gantry.md b/docs/dev/reference/apis/components/gantry.md index 44203a6422..3243fb49e8 100644 --- a/docs/dev/reference/apis/components/gantry.md +++ b/docs/dev/reference/apis/components/gantry.md @@ -18,38 +18,6 @@ The gantry component supports the following methods: {{< readfile "/static/include/components/apis/generated/gantry-table.md" >}} -## Establish a connection - -To get started using Viam's SDKs to connect to and control your gantry and the rest of your machine, go to your machine's page, navigate to the **CONNECT** tab's **Code sample** page, select your preferred programming language, and copy the sample code. - -{{% snippet "show-secret.md" %}} - -When executed, this sample code creates a connection to your machine as a client. - -The following examples assume you have a gantry called `"my_gantry"` configured as a component of your machine. -If your gantry has a different name, change the `name` in the code. - -Import the gantry package for the SDK you are using: - -{{< tabs >}} -{{% tab name="Python" %}} - -```python -from viam.components.gantry import Gantry -``` - -{{% /tab %}} -{{% tab name="Go" %}} - -```go -import ( - "go.viam.com/rdk/components/gantry" -) -``` - -{{% /tab %}} -{{< /tabs >}} - ## API {{< readfile "/static/include/components/apis/generated/gantry.md" >}} diff --git a/docs/dev/reference/apis/components/generic.md b/docs/dev/reference/apis/components/generic.md index c91eb78eeb..e534df4953 100644 --- a/docs/dev/reference/apis/components/generic.md +++ b/docs/dev/reference/apis/components/generic.md @@ -24,46 +24,6 @@ The generic component supports the following method: {{< readfile "/static/include/components/apis/generated/generic_component-table.md" >}} -## Establish a connection - -To get started using Viam's SDKs to connect to and control your generic component and the rest of your machine, go to your machine's page, navigate to the **CONNECT** tab's **Code sample** page, select your preferred programming language, and copy the sample code. - -{{% snippet "show-secret.md" %}} - -When executed, this sample code will create a connection to your machine as a client. -Then control your machine programmatically by getting your `generic` component from the machine with `FromRobot` and adding API method calls, as shown in the following examples. - -The following examples assume you have a board called "my_board" configured as a component of your machine. -If your board has a different name, change the `name` in the code. - -Import the generic component package for the SDK you are using: - -{{< tabs >}} -{{% tab name="Python" %}} - -```python -from viam.components.generic import Generic -``` - -{{% /tab %}} -{{% tab name="Go" %}} - -```go -import ( - "go.viam.com/rdk/components/generic" -) -``` - -{{% /tab %}} -{{% tab name="C++" %}} - -```cpp -#include -``` - -{{% /tab %}} -{{< /tabs >}} - ## API {{< readfile "/static/include/components/apis/generated/generic_component.md" >}} diff --git a/docs/dev/reference/apis/components/gripper.md b/docs/dev/reference/apis/components/gripper.md index d44a710497..5a0d3e4649 100644 --- a/docs/dev/reference/apis/components/gripper.md +++ b/docs/dev/reference/apis/components/gripper.md @@ -18,38 +18,6 @@ The gripper component supports the following methods: {{< readfile "/static/include/components/apis/generated/gripper-table.md" >}} -## Establish a connection - -To get started using Viam's SDKs to connect to and control your gripper and the rest of your machine, go to your machine's page, navigate to the **CONNECT** tab's **Code sample** page, select your preferred programming language, and copy the sample code. - -{{% snippet "show-secret.md" %}} - -When executed, this sample code creates a connection to your machine as a client. - -The following examples assume you have a gripper called `"my_gripper"` configured as a component of your machine. -If your gripper has a different name, change the `name` in the code. - -Import the gripper package for the SDK you are using: - -{{< tabs >}} -{{% tab name="Python" %}} - -```python -from viam.components.gripper import Gripper -``` - -{{% /tab %}} -{{% tab name="Go" %}} - -```go -import ( - "go.viam.com/rdk/components/gripper" -) -``` - -{{% /tab %}} -{{< /tabs >}} - ## API {{< readfile "/static/include/components/apis/generated/gripper.md" >}} diff --git a/docs/dev/reference/apis/components/input-controller.md b/docs/dev/reference/apis/components/input-controller.md index d2f212a88e..90b7bc1f58 100644 --- a/docs/dev/reference/apis/components/input-controller.md +++ b/docs/dev/reference/apis/components/input-controller.md @@ -19,38 +19,6 @@ The input controller component supports the following methods: {{< readfile "/static/include/components/apis/generated/input_controller-table.md" >}} -## Establish a connection - -To get started using Viam's SDKs to connect to and control your controller and the rest of your machine, go to your machine's page, navigate to the **CONNECT** tab's **Code sample** page, select your preferred programming language, and copy the sample code. - -{{% snippet "show-secret.md" %}} - -When executed, this sample code creates a connection to your machine as a client. - -The following examples assume you have an input controller called `"my_controller"` configured as a component of your machine. -If your input controller has a different name, change the `name` in the code. - -Import the input controller package for the SDK you are using: - -{{< tabs >}} -{{% tab name="Python" %}} - -```python -from viam.components.input import Control, Controller, EventType -``` - -{{% /tab %}} -{{% tab name="Go" %}} - -```go -import ( - "go.viam.com/rdk/components/input" -) -``` - -{{% /tab %}} -{{< /tabs >}} - ## API {{< readfile "/static/include/components/apis/generated/input_controller.md" >}} diff --git a/docs/dev/reference/apis/components/motor.md b/docs/dev/reference/apis/components/motor.md index 2629e50a04..7e2d26529b 100644 --- a/docs/dev/reference/apis/components/motor.md +++ b/docs/dev/reference/apis/components/motor.md @@ -18,38 +18,6 @@ The motor component supports the following methods: {{< readfile "/static/include/components/apis/generated/motor-table.md" >}} -## Establish a connection - -To get started using Viam's SDKs to connect to and control your motor and the rest of your machine, go to your machine's page, navigate to the **CONNECT** tab's **Code sample** page, select your preferred programming language, and copy the sample code. - -{{% snippet "show-secret.md" %}} - -When executed, this sample code creates a connection to your machine as a client. - -The following examples assume you have a motor called `"my_motor"` configured as a component of your machine. -If your motor has a different name, change the `name` in the code. - -Import the motor package for the SDK you are using: - -{{< tabs >}} -{{% tab name="Python" %}} - -```python -from viam.components.motor import Motor -``` - -{{% /tab %}} -{{% tab name="Go" %}} - -```go -import ( - "go.viam.com/rdk/components/motor" -) -``` - -{{% /tab %}} -{{< /tabs >}} - ## API {{< readfile "/static/include/components/apis/generated/motor.md" >}} diff --git a/docs/dev/reference/apis/components/movement-sensor.md b/docs/dev/reference/apis/components/movement-sensor.md index 1b52c77563..04fb4fe8f5 100644 --- a/docs/dev/reference/apis/components/movement-sensor.md +++ b/docs/dev/reference/apis/components/movement-sensor.md @@ -25,38 +25,6 @@ You can run `GetProperties` on your sensor for a list of its supported methods. {{< readfile "/static/include/components/apis/movement-sensor.md" >}} -## Establish a connection - -To get started using Viam's SDKs to connect to and control your movement sensor and the rest of your machine, go to your machine's page, navigate to the **CONNECT** tab's **Code sample** page, select your preferred programming language, and copy the sample code. - -{{% snippet "show-secret.md" %}} - -When executed, this sample code creates a connection to your machine as a client. - -The following examples assume you have a movement sensor called `"my_movement_sensor"` configured as a component of your machine. -If your movement sensor has a different name, change the `name` in the code. - -Import the movement sensor package for the SDK you are using: - -{{< tabs >}} -{{% tab name="Python" %}} - -```python -from viam.components.movement_sensor import MovementSensor -``` - -{{% /tab %}} -{{% tab name="Go" %}} - -```go -import ( - "go.viam.com/rdk/components/movementsensor" -) -``` - -{{% /tab %}} -{{< /tabs >}} - ## API {{< readfile "/static/include/components/apis/generated/movement_sensor.md" >}} diff --git a/docs/dev/reference/apis/components/power-sensor.md b/docs/dev/reference/apis/components/power-sensor.md index ac5a48da15..d7a5a06c37 100644 --- a/docs/dev/reference/apis/components/power-sensor.md +++ b/docs/dev/reference/apis/components/power-sensor.md @@ -18,38 +18,6 @@ The power sensor component supports the following methods: {{< readfile "/static/include/components/apis/generated/power_sensor-table.md" >}} -## Establish a connection - -To get started using Viam's SDKs to connect to and control your power sensor and the rest of your machine, go to your machine's page, navigate to the **CONNECT** tab's **Code sample** page, select your preferred programming language, and copy the sample code. - -{{% snippet "show-secret.md" %}} - -When executed, this sample code will create a connection to your machine as a client. -Once connected, you can control your machine programmatically by adding API method calls as shown in the following examples. - -The following examples assume you have a power sensor called `"my_power_sensor"` configured as a component of your machine. -If your power sensor has a different name, change the `name` in the code. - -Import the power sensor package for the SDK you are using: -{{< tabs >}} -{{% tab name="Python" %}} - -```python -from viam.components.power_sensor import PowerSensor -``` - -{{% /tab %}} -{{% tab name="Go" %}} - -```go -import ( - "go.viam.com/rdk/components/powersensor" -) -``` - -{{% /tab %}} -{{< /tabs >}} - ## API {{< readfile "/static/include/components/apis/generated/power_sensor.md" >}} diff --git a/docs/dev/reference/apis/components/sensor.md b/docs/dev/reference/apis/components/sensor.md index db62928a24..8cd129532e 100644 --- a/docs/dev/reference/apis/components/sensor.md +++ b/docs/dev/reference/apis/components/sensor.md @@ -18,38 +18,6 @@ The sensor component supports the following methods: {{< readfile "/static/include/components/apis/generated/sensor-table.md" >}} -## Establish a connection - -To get started using Viam's SDKs to connect to and control your sensor and the rest of your machine, go to your machine's page, navigate to the **CONNECT** tab's **Code sample** page, select your preferred programming language, and copy the sample code. - -{{% snippet "show-secret.md" %}} - -When executed, this sample code creates a connection to your machine as a client. - -The following examples assume you have a sensor called `"my_sensor"` configured as a component of your machine. -If your sensor has a different name, change the `name` in the code. - -Import the sensor package for the SDK you are using: - -{{< tabs >}} -{{% tab name="Python" %}} - -```python -from viam.components.sensor import Sensor -``` - -{{% /tab %}} -{{% tab name="Go" %}} - -```go -import ( - "go.viam.com/rdk/components/sensor" -) -``` - -{{% /tab %}} -{{< /tabs >}} - ## API {{< readfile "/static/include/components/apis/generated/sensor.md" >}} diff --git a/docs/dev/reference/apis/components/servo.md b/docs/dev/reference/apis/components/servo.md index c92287ec26..0d20d7be3c 100644 --- a/docs/dev/reference/apis/components/servo.md +++ b/docs/dev/reference/apis/components/servo.md @@ -20,38 +20,6 @@ The servo component supports the following methods: {{< readfile "/static/include/components/apis/generated/servo-table.md" >}} -## Establish a connection - -To get started using Viam's SDKs to connect to and control your servo and the rest of your machine, go to your machine's page, navigate to the **CONNECT** tab's **Code sample** page, select your preferred programming language, and copy the sample code. - -{{% snippet "show-secret.md" %}} - -When executed, this sample code creates a connection to your machine as a client. - -The following examples assume you have a servo called `"my_servo"` configured as a component of your machine. -If your servo has a different name, change the `name` in the code. - -Import the servo package for the SDK you are using: - -{{< tabs >}} -{{% tab name="Python" %}} - -```python -from viam.components.servo import Servo -``` - -{{% /tab %}} -{{% tab name="Go" %}} - -```go -import ( - "go.viam.com/rdk/components/servo" -) -``` - -{{% /tab %}} -{{< /tabs >}} - ## API {{< readfile "/static/include/components/apis/generated/servo.md" >}} diff --git a/docs/dev/reference/apis/components/switch.md b/docs/dev/reference/apis/components/switch.md index f5409df825..9c1b1b6e2a 100644 --- a/docs/dev/reference/apis/components/switch.md +++ b/docs/dev/reference/apis/components/switch.md @@ -17,38 +17,6 @@ The switch component supports the following methods: {{< readfile "/static/include/components/apis/generated/switch-table.md" >}} -## Establish a connection - -To get started using Viam's SDKs to connect to and control your switch and the rest of your machine, go to your machine's page, navigate to the **CONNECT** tab's **Code sample** page, select your preferred programming language, and copy the sample code. - -{{% snippet "show-secret.md" %}} - -When executed, this sample code creates a connection to your machine as a client. - -The following examples assume you have an switch called `"my_switch"` configured as a component of your machine. -If your switch has a different name, change the `name` in the code. - -Import the switch package for the SDK you are using: - -{{< tabs >}} -{{% tab name="Python" %}} - -```python -from viam.components.switch import Switch -``` - -{{% /tab %}} -{{% tab name="Go" %}} - -```go -import ( - "go.viam.com/rdk/components/switch" -) -``` - -{{% /tab %}} -{{< /tabs >}} - ## API {{< readfile "/static/include/components/apis/generated/switch.md" >}} diff --git a/docs/dev/reference/apis/data-client.md b/docs/dev/reference/apis/data-client.md index 1a47188d98..dc6f6edda5 100644 --- a/docs/dev/reference/apis/data-client.md +++ b/docs/dev/reference/apis/data-client.md @@ -42,85 +42,6 @@ Methods to work with datasets: {{< readfile "/static/include/app/apis/generated/dataset-table.md" >}} -## Establish a connection - -To use the Viam data client API, you first need to instantiate a `ViamClient` and then instantiate a `DataClient`. - -You will also need an API key and API key ID to authenticate your session. -To get an API key (and corresponding ID), you have two options: - -- [Create an API key in the web UI](/operate/control/api-keys/#add-an-api-key) -- [Create an API key using the Viam CLI](/dev/tools/cli/#create-an-organization-api-key) - -The following example instantiates a `ViamClient`, authenticating with an API key, and then instantiates a `DataClient`: - -{{< tabs >}} -{{% tab name="Python" %}} - -```python {class="line-numbers linkable-line-numbers"} -import asyncio - -from viam.rpc.dial import DialOptions, Credentials -from viam.app.viam_client import ViamClient - - -async def connect() -> ViamClient: - dial_options = DialOptions( - credentials=Credentials( - type="api-key", - # Replace "" (including brackets) with your machine's API key - payload='', - ), - # Replace "" (including brackets) with your machine's - # API key ID - auth_entity='' - ) - return await ViamClient.create_from_dial_options(dial_options) - - -async def main(): - # Make a ViamClient - viam_client = await connect() - # Instantiate a DataClient to run data client API methods on - data_client = viam_client.data_client - - viam_client.close() - -if __name__ == '__main__': - asyncio.run(main()) -``` - -{{% /tab %}} -{{% tab name="TypeScript" %}} - -```ts {class="line-numbers linkable-line-numbers" data-line="5"} -async function connect(): Promise { - // Replace "" (including brackets) with your machine's - const API_KEY_ID = ""; - // Replace "" (including brackets) with your machine's API key - const API_KEY = ""; - const opts: VIAM.ViamClientOptions = { - serviceHost: "https://app.viam.com:443", - credentials: { - type: "api-key", - authEntity: API_KEY_ID, - payload: API_KEY, - }, - }; - - const client = await VIAM.createViamClient(opts); - return client; -} - -const viamClient = await connect(); -const dataClient = viamClient.dataClient; -``` - -{{% /tab %}} -{{< /tabs >}} - -Once you have instantiated a `DataClient`, you can run [API methods](#api) against the `DataClient` object (named `data_client` in the examples). - ## API {{< readfile "/static/include/app/apis/generated/data_sync.md" >}} diff --git a/docs/dev/reference/apis/fleet.md b/docs/dev/reference/apis/fleet.md index 624f7dc586..436af76045 100644 --- a/docs/dev/reference/apis/fleet.md +++ b/docs/dev/reference/apis/fleet.md @@ -41,92 +41,6 @@ The fleet management API supports the following methods: {{< readfile "/static/include/app/apis/generated/app-table.md" >}} -## Establish a connection - -To use the Viam fleet management API, you first need to instantiate a `ViamClient` and then instantiate an `AppClient`. - -You will also need an API key and API key ID to authenticate your session. -To get an API key (and corresponding ID), you have two options: - -- [Create an API key in the web UI](/operate/control/api-keys/#add-an-api-key) -- [Create an API key using the Viam CLI](/dev/tools/cli/#create-an-organization-api-key) - -The following example instantiates a `ViamClient`, authenticating with an API key, and then instantiates an `AppClient`: - -{{< tabs >}} -{{% tab name="Python" %}} - -```python {class="line-numbers linkable-line-numbers"} -import asyncio - -from viam.rpc.dial import DialOptions, Credentials -from viam.app.viam_client import ViamClient - - -async def connect() -> ViamClient: - dial_options = DialOptions( - credentials=Credentials( - type="api-key", - # Replace "" (including brackets) with your API key - payload='', - ), - # Replace "" (including brackets) with your API key - # ID - auth_entity='' - ) - return await ViamClient.create_from_dial_options(dial_options) - - -async def main(): - - # Make a ViamClient - viam_client = await connect() - # Instantiate an AppClient called "cloud" - # to run fleet management API methods on - cloud = viam_client.app_client - - viam_client.close() - -if __name__ == '__main__': - asyncio.run(main()) -``` - -{{% /tab %}} -{{% tab name="TypeScript" %}} - -```ts {class="line-numbers linkable-line-numbers" data-line="3,5"} -async function connect(): Promise { - // Replace "" (including brackets) with your machine's - const API_KEY_ID = ""; - // Replace "" (including brackets) with your machine's API key - const API_KEY = ""; - const opts: VIAM.ViamClientOptions = { - serviceHost: "https://app.viam.com:443", - credentials: { - type: "api-key", - authEntity: API_KEY_ID, - payload: API_KEY, - }, - }; - - const client = await VIAM.createViamClient(opts); - return client; -} - -const viamClient = await connect(); -const appClient = appClient.appClient; -``` - -{{% /tab %}} -{{< /tabs >}} - -Once you have instantiated an `AppClient`, you can run the following [API methods](#api) against the `AppClient` object (named `fleet` in the examples). - -{{% hiddencontent %}} -To instantiate an `AppClient` from inside a module, you must authenticate using API keys. -You can use the module environment variables `VIAM_API_KEY` and `VIAM_API_KEY_ID` to access credentials. -{{% /hiddencontent %}} - ## API {{< readfile "/static/include/app/apis/generated/app.md" >}} diff --git a/docs/dev/reference/apis/ml-training-client.md b/docs/dev/reference/apis/ml-training-client.md index 310d5776da..4d1359a847 100644 --- a/docs/dev/reference/apis/ml-training-client.md +++ b/docs/dev/reference/apis/ml-training-client.md @@ -25,87 +25,6 @@ The ML training client API supports the following methods: {{< readfile "/static/include/app/apis/generated/mltraining-table.md" >}} -## Establish a connection - -To use the Viam ML training client API, you first need to instantiate a `ViamClient` and then instantiate an `MLTrainingClient`. - -You will also need an API key and API key ID to authenticate your session. -Your API key needs to have [Org owner permissions](/manage/manage/rbac/#organization-settings-and-roles) to use the MLTraining client API. -To get an API key (and corresponding ID), you have two options: - -- [Create an API key in the web UI](/operate/control/api-keys/#add-an-api-key) -- [Create an API key using the Viam CLI](/dev/tools/cli/#create-an-organization-api-key) - -The following example instantiates a `ViamClient`, authenticating with an API key, and then instantiates an `MLTrainingClient`: - -{{< tabs >}} -{{% tab name="Python" %}} - -```python {class="line-numbers linkable-line-numbers" data-line="12, 16"} -import asyncio - -from viam.rpc.dial import DialOptions, Credentials -from viam.app.viam_client import ViamClient - - -async def connect() -> ViamClient: - dial_options = DialOptions( - credentials=Credentials( - type="api-key", - # Replace "" (including brackets) with your machine's API key - payload='', - ), - # Replace "" (including brackets) with your machine's - # API key ID - auth_entity='' - ) - return await ViamClient.create_from_dial_options(dial_options) - - -async def main(): - - # Make a ViamClient - viam_client = await connect() - # Instantiate an MLTrainingClient to run ML training client API methods on - ml_training_client = viam_client.ml_training_client - - viam_client.close() - -if __name__ == '__main__': - asyncio.run(main()) -``` - -{{% /tab %}} -{{% tab name="TypeScript" %}} - -```ts {class="line-numbers linkable-line-numbers" data-line="3, 5"} -async function connect(): Promise { - // Replace "" (including brackets) with your machine's - const API_KEY_ID = ""; - // Replace "" (including brackets) with your machine's API key - const API_KEY = ""; - const opts: VIAM.ViamClientOptions = { - serviceHost: "https://app.viam.com:443", - credentials: { - type: "api-key", - authEntity: API_KEY_ID, - payload: API_KEY, - }, - }; - - const client = await VIAM.createViamClient(opts); - return client; -} - -const viamClient = await connect(); -const mlTrainingClient = viamClient.mlTrainingClient; -``` - -{{% /tab %}} -{{< /tabs >}} - -Once you have instantiated an `MLTrainingClient`, you can run the following [API methods](#api) against the `MLTrainingClient` object (named `ml_training_client` in the examples). - ## API {{< readfile "/static/include/app/apis/generated/mltraining.md" >}} diff --git a/docs/dev/reference/apis/robot.md b/docs/dev/reference/apis/robot.md index 55f632f279..0ef50d8bd4 100644 --- a/docs/dev/reference/apis/robot.md +++ b/docs/dev/reference/apis/robot.md @@ -21,162 +21,6 @@ The machine API supports the following methods: {{< readfile "/static/include/robot/apis/generated/robot-table.md" >}} -## Establish a connection - -To interact with the machine API with Viam's SDKs, instantiate a `RobotClient` ([gRPC](https://grpc.io/) client) and use that class for all interactions. - -To find the API key, API key ID, and machine address, go to [Viam](https://app.viam.com/), select the machine you wish to connect to, and go to the **CONNECT** tab. -Toggle **Include API key**, and then copy and paste the API key ID and the API key into your environment variables or directly into the code: - -{{< tabs >}} -{{% tab name="Python" %}} - -```python {class="line-numbers linkable-line-numbers"} -import asyncio - -from viam.rpc.dial import DialOptions, Credentials -from viam.robot.client import RobotClient - - -async def connect() -> RobotClient: - opts = RobotClient.Options.with_api_key( - # Replace "" (including brackets) with your API key - api_key='', - # Replace "" (including brackets) with your - # API key ID - api_key_id='' - ) - return await RobotClient.at_address( - address='MACHINE ADDRESS', - options=opts - ) - - -async def main(): - # Make a RobotClient - machine = await connect() - print('Resources:') - print(machine.resource_names) - await machine.close() - -if __name__ == '__main__': - asyncio.run(main()) -``` - -You can use this code to connect to your machine and instantiate a `RobotClient` that you can then use with the [robot API](#api). -As an example, this code uses the instantiated `RobotClient` to return the {{< glossary_tooltip term_id="resource" text="resources" >}} currently configured. -Remember to always close the connection (using `close()`) when done. - -{{% /tab %}} -{{% tab name="Go" %}} - -```go {class="line-numbers linkable-line-numbers"} -package main - -import ( - "context" - - "go.viam.com/rdk/logging" - "go.viam.com/rdk/robot/client" - "go.viam.com/rdk/utils" -) - -func main() { - logger := logging.NewLogger("client") - machine, err := client.New( - context.Background(), - "MACHINE ADDRESS", - logger, - client.WithDialOptions(utils.WithEntityCredentials( - // Replace "" (including brackets) with your machine's - // API Key ID - "", - utils.Credentials{ - Type: utils.CredentialsTypeAPIKey, - // Replace "" (including brackets) with your machine's API key - Payload: "", - })), - ) - if err != nil { - logger.Fatal(err) - } - - defer machine.Close(context.Background()) - logger.Info("Resources:") - logger.Info(machine.ResourceNames()) -} -``` - -You can use this code to connect to your machine and instantiate a `robot` client that you can then use with the [Robot API](#api). -As an example, this code uses the instantiated `robot` client to return the configured {{< glossary_tooltip term_id="resource" text="resources" >}}. -Remember to always close the connection (using `Close()`) when done. - -{{% /tab %}} -{{< /tabs >}} - -Once you have instantiated the robot client, you can run any of the [robot API methods](#api) against the `robot` object to communicate with your machine. - -### Configure a timeout - -Because the robot API needs to be able to reliably connect to a deployed machine even over a weak or intermittent network, it supports a configurable timeout for connection and command execution. - -To configure a timeout when using the robot API: - -{{< tabs >}} -{{% tab name="Python" %}} - -Add a `timeout` to [`DialOptions`](https://python.viam.dev/autoapi/viam/rpc/dial/index.html#viam.rpc.dial.DialOptions) inside of `Options`: - -```python {class="line-numbers linkable-line-numbers"} -# Add the timeout argument to DialOptions: -opts = RobotClient.Options( - dial_options=DialOptions(timeout=10)).with_api_key( - ... - ) -``` - -The example above shows a timeout of 10 seconds configured. - -{{% /tab %}} -{{% tab name="Go" %}} - -Import the `time` package, then add a timeout to your context using `WithTimeout`: - -```go {class="line-numbers linkable-line-numbers"} -// Import the time package in addition to the other imports: -import ( - ... - "time" - ... -) - -// Edit your main() to configure a timeoutContext, then pass this context to the dial invocation: -func main() { - ctx := context.Background() - timeoutContext, cancel := context.WithTimeout(ctx, 10*time.Second) - defer cancel() - machine, err := client.New( - timeoutContext, - "MACHINE ADDRESS", - logger, - client.WithDialOptions(rpc.WithEntityCredentials( - // Replace "" (including brackets) with your machine's - // API key ID - "", - rpc.Credentials{ - Type: rpc.CredentialsTypeAPIKey, - // Replace "" (including brackets) with your machine's API key - Payload: "", - })), - ) -} -``` - -The example above shows a timeout of 10 seconds configured. - -{{% /tab %}} -{{< /tabs >}} - ## API {{< readfile "/static/include/robot/apis/generated/robot.md" >}} diff --git a/docs/dev/reference/apis/services/SLAM.md b/docs/dev/reference/apis/services/SLAM.md index 388b8dd323..2c5b29897e 100644 --- a/docs/dev/reference/apis/services/SLAM.md +++ b/docs/dev/reference/apis/services/SLAM.md @@ -19,35 +19,6 @@ The [SLAM service](/operate/reference/services/slam/) supports the following met {{< readfile "/static/include/services/apis/generated/slam-table.md" >}} -## Establish a connection - -To get started using Viam's SDKs to connect to and control your machine, go to your machine's page, navigate to the **CONNECT** tab's **Code sample** page, select your preferred programming language, and copy the sample code. - -{{% snippet "show-secret.md" %}} - -When executed, this sample code creates a connection to your machine as a client. - -The following code examples assume that you have a machine configured with a SLAM service called `"my_slam_service"`. - -{{< tabs >}} -{{% tab name="Python" %}} - -```python -from viam.services.slam import SLAMClient -``` - -{{% /tab %}} -{{% tab name="Go" %}} - -```go -import ( - "go.viam.com/rdk/services/slam" -) -``` - -{{% /tab %}} -{{< /tabs >}} - ## API {{< readfile "/static/include/services/apis/generated/slam.md" >}} diff --git a/docs/dev/reference/apis/services/base-rc.md b/docs/dev/reference/apis/services/base-rc.md index aa681c847e..c10fab4be0 100644 --- a/docs/dev/reference/apis/services/base-rc.md +++ b/docs/dev/reference/apis/services/base-rc.md @@ -19,26 +19,6 @@ The [SLAM service](/operate/reference/services/slam/) supports the following met {{< readfile "/static/include/services/apis/generated/base_remote_control-table.md" >}} -## Establish a connection - -To get started using Viam's SDKs to connect to and control your machine, go to your machine's page, navigate to the **CONNECT** tab's **Code sample** page, select your preferred programming language, and copy the sample code. - -{{% snippet "show-secret.md" %}} - -When executed, this sample code creates a connection to your machine as a client. - -{{< tabs >}} -{{% tab name="Go" %}} - -```go -import ( - "go.viam.com/rdk/services/baseremotecontrol" -) -``` - -{{% /tab %}} -{{< /tabs >}} - ## API {{< readfile "/static/include/services/apis/generated/base_remote_control.md" >}} diff --git a/docs/dev/reference/apis/services/data.md b/docs/dev/reference/apis/services/data.md index 9feb8a32b2..1c6bc06f2a 100644 --- a/docs/dev/reference/apis/services/data.md +++ b/docs/dev/reference/apis/services/data.md @@ -21,28 +21,6 @@ The [data management service](/data-ai/capture-data/capture-sync/) supports the 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](/dev/reference/apis/data-client/). -## Establish a connection - -To get started using Viam's SDKs to connect to and control your machine, go to your machine's page, navigate to the **CONNECT** tab's **Code sample** page, select your preferred programming language, and copy the sample code. - -{{% snippet "show-secret.md" %}} - -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. - -{{< tabs >}} -{{% tab name="Go" %}} - -```go -import ( - "go.viam.com/rdk/services/datamanager" -) -``` - -{{% /tab %}} -{{< /tabs >}} - ## API {{< readfile "/static/include/services/apis/generated/data_manager.md" >}} diff --git a/docs/dev/reference/apis/services/discovery.md b/docs/dev/reference/apis/services/discovery.md index b4bb12ce7f..595b848e58 100644 --- a/docs/dev/reference/apis/services/discovery.md +++ b/docs/dev/reference/apis/services/discovery.md @@ -16,35 +16,6 @@ The discovery service supports the following methods: {{< readfile "/static/include/services/apis/generated/discovery-table.md" >}} -## Establish a connection - -To get started using Viam's SDKs to connect to and control your machine, go to your machine's page, navigate to the **CONNECT** tab's **Code sample** page, select your preferred programming language, and copy the sample code. - -{{% snippet "show-secret.md" %}} - -When executed, this sample code creates a connection to your machine as a client. - -The following code examples assume that you have a machine configured with a `Discovery` service. - -{{< tabs >}} -{{% tab name="Python" %}} - -```python -from viam.services.discovery import DiscoveryClient -``` - -{{% /tab %}} -{{% tab name="Go" %}} - -```go -import ( - "go.viam.com/rdk/services/discovery" -) -``` - -{{% /tab %}} -{{< /tabs >}} - ## API {{< readfile "/static/include/services/apis/generated/discovery.md" >}} diff --git a/docs/dev/reference/apis/services/generic.md b/docs/dev/reference/apis/services/generic.md index ca40234f7c..9ceb812855 100644 --- a/docs/dev/reference/apis/services/generic.md +++ b/docs/dev/reference/apis/services/generic.md @@ -20,40 +20,6 @@ The generic service supports the following methods: {{< readfile "/static/include/services/apis/generated/generic_service-table.md" >}} -## Establish a connection - -To get started using Viam's SDKs to connect to and control your machine, go to your machine's page, navigate to the **CONNECT** tab's **Code sample** page, select your preferred programming language, and copy the sample code. - -{{% snippet "show-secret.md" %}} - -When executed, this sample code creates a connection to your machine as a client. - -{{< tabs >}} -{{% tab name="Python" %}} - -```python -from viam.services.generic import Generic -``` - -{{% /tab %}} -{{% tab name="Go" %}} - -```go -import ( - "go.viam.com/rdk/services/generic" -) -``` - -{{% /tab %}} -{{% tab name="C++" %}} - -```cpp -#include -``` - -{{% /tab %}} -{{< /tabs >}} - ## API {{< readfile "/static/include/services/apis/generated/generic_service.md" >}} diff --git a/docs/dev/reference/apis/services/ml.md b/docs/dev/reference/apis/services/ml.md index f0c0bd3ddf..ce7e273a71 100644 --- a/docs/dev/reference/apis/services/ml.md +++ b/docs/dev/reference/apis/services/ml.md @@ -19,48 +19,6 @@ The [ML Model service](/data-ai/ai/deploy/) supports the following methods: {{< readfile "/static/include/services/apis/generated/mlmodel-table.md" >}} -## Establish a connection - -{{< alert title="Viam Python SDK Support" color="note" >}} - -To use the ML model service from the [Viam Python SDK](https://python.viam.dev/), install the Python SDK using the `mlmodel` extra: - -```sh {class="command-line" data-prompt="$"} -pip install 'viam-sdk[mlmodel]' -``` - -{{< /alert >}} - -To get started using Viam's SDKs to connect to and control your machine, go to your machine's page, navigate to the **CONNECT** tab's **Code sample** page, select your preferred programming language, and copy the sample code. - -{{% snippet "show-secret.md" %}} - -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 `MLModel` service called `"my_mlmodel_service"`, and that you have installed the `mlmodel` extra for the Python SDK. -If your ML model service has a different name, change the `name` in the code. - -Import the mlmodel package for the SDK you are using: - -{{< tabs >}} -{{% tab name="Python" %}} - -```python -from viam.services.mlmodel import MLModelClient -``` - -{{% /tab %}} -{{% tab name="Go" %}} - -```go -import ( - "go.viam.com/rdk/services/mlmodel" -) -``` - -{{% /tab %}} -{{< /tabs >}} - ## API {{< readfile "/static/include/services/apis/generated/mlmodel.md" >}} diff --git a/docs/dev/reference/apis/services/motion.md b/docs/dev/reference/apis/services/motion.md index d43e3060a5..6fa8bcab64 100644 --- a/docs/dev/reference/apis/services/motion.md +++ b/docs/dev/reference/apis/services/motion.md @@ -18,38 +18,6 @@ The motion service supports the following methods: {{< readfile "/static/include/services/apis/generated/motion-table.md" >}} -## Establish a connection - -To get started using Viam's SDKs to connect to and control your machine, go to your machine's page, navigate to the **CONNECT** tab's **Code sample** page, select your preferred programming language, and copy the sample code. - -{{% snippet "show-secret.md" %}} - -When executed, this sample code creates a connection to your machine as a client. - -Because the motion service is enabled by default, you don't give it a `"name"` while configuring it. -Use the name `"builtin"` to access the built-in motion service in your code with methods like [`FromRobot()`](/dev/reference/apis/services/motion/#fromrobot) that require a `ResourceName`. - -Import the motion package for the SDK you are using: - -{{< tabs >}} -{{% tab name="Python" %}} - -```python -from viam.services.motion import MotionClient -``` - -{{% /tab %}} -{{% tab name="Go" %}} - -```go -import ( - "go.viam.com/rdk/services/motion" -) -``` - -{{% /tab %}} -{{< /tabs >}} - ## API {{< readfile "/static/include/services/apis/generated/motion.md" >}} diff --git a/docs/dev/reference/apis/services/navigation.md b/docs/dev/reference/apis/services/navigation.md index 375bb09313..e65fa5b7f6 100644 --- a/docs/dev/reference/apis/services/navigation.md +++ b/docs/dev/reference/apis/services/navigation.md @@ -19,35 +19,6 @@ The [navigation service](/operate/reference/services/navigation/) supports the f {{< readfile "/static/include/services/apis/generated/navigation-table.md" >}} -## Establish a connection - -To get started using Viam's SDKs to connect to and control your machine, go to your machine's page, navigate to the **CONNECT** tab's **Code sample** page, select your preferred programming language, and copy the sample code. - -{{% snippet "show-secret.md" %}} - -When executed, this sample code creates a connection to your machine as a client. - -The following code examples assume that you have a machine configured with a `Navigation` service. - -{{< tabs >}} -{{% tab name="Python" %}} - -```python -from viam.services.navigation import NavigationClient -``` - -{{% /tab %}} -{{% tab name="Go" %}} - -```go -import ( - "go.viam.com/rdk/services/navigation" -) -``` - -{{% /tab %}} -{{< /tabs >}} - ## API {{< readfile "/static/include/services/apis/generated/navigation.md" >}} diff --git a/docs/dev/reference/apis/services/vision.md b/docs/dev/reference/apis/services/vision.md index 227688f9e2..e58b4d9cad 100644 --- a/docs/dev/reference/apis/services/vision.md +++ b/docs/dev/reference/apis/services/vision.md @@ -94,35 +94,6 @@ The [vision service](/operate/reference/services/vision/) supports the following {{< readfile "/static/include/services/apis/generated/vision-table.md" >}} -## Establish a connection - -To get started using Viam's SDKs to connect to and control your machine, go to your machine's page, navigate to the **CONNECT** tab's **Code sample** page, select your preferred programming language, and copy the sample code. - -{{% snippet "show-secret.md" %}} - -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 a [camera](/operate/reference/components/camera/) and a vision service [detector](/dev/reference/apis/services/vision/#detections), [classifier](/dev/reference/apis/services/vision/#classifications) or [segmenter](/dev/reference/apis/services/vision/#segmentations). - -{{< tabs >}} -{{% tab name="Python" %}} - -```python -from viam.services.vision import VisionClient -``` - -{{% /tab %}} -{{% tab name="Go" %}} - -```go -import ( - "go.viam.com/rdk/services/vision" -) -``` - -{{% /tab %}} -{{< /tabs >}} - ## API {{< readfile "/static/include/services/apis/generated/vision.md" >}} From 92bc99daa1c0dd28b641e02ef2eee68941141e97 Mon Sep 17 00:00:00 2001 From: Jessamy Taylor <75634662+JessamyT@users.noreply.github.com> Date: Mon, 30 Jun 2025 13:39:46 -0700 Subject: [PATCH 2/3] Update connectivity.md --- docs/dev/reference/sdks/connectivity.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/dev/reference/sdks/connectivity.md b/docs/dev/reference/sdks/connectivity.md index d28f8d060b..e331091503 100644 --- a/docs/dev/reference/sdks/connectivity.md +++ b/docs/dev/reference/sdks/connectivity.md @@ -110,7 +110,7 @@ When a machine loses its connection to LAN or WAN, all client sessions will time ### Client session timeout and end -When your client cannot connect to your machine's `viam-server` instance, `viam-server` will end any current client [_sessions_](/dev/reference/apis/sessions/) on this machine and all client operations will [timeout automatically](/dev/reference/apis/sessions/) and halt: any active commands will be cancelled, stopping any moving parts, and no new commands will be able to reach the machine until the connection is restored. +When your client cannot connect to your machine's `viam-server` instance, `viam-server` will end any current client [_sessions_](/dev/reference/apis/sessions/) on this machine and all client operations will [time out automatically](/dev/reference/apis/sessions/) and halt: any active commands will be cancelled, stopping any moving parts, and no new commands will be able to reach the machine until the connection is restored. To disable the default behavior and manage resource timeout and reconfiguration over a networking session yourself, you can [disable the default behavior](/dev/reference/apis/sessions/#disable-default-session-management) of session management, then use [Viam's SDKs](/dev/reference/sdks/) in your code to make calls to [the session management API](https://pkg.go.dev/go.viam.com/rdk/session#hdr-API). @@ -125,4 +125,4 @@ There are a couple of exceptions to the general timeout behavior: ### Configure a connection timeout -When connecting to a machine using the [robot API](/dev/reference/apis/robot/) from a supported [Viam SDK](/dev/reference/apis/), you can configure an [optional timeout](/dev/reference/apis/robot/#configure-a-timeout) to account for intermittent or delayed network connectivity. +When connecting to a machine using the [robot API](/dev/reference/apis/robot/) from a supported [Viam SDK](/dev/reference/apis/), you can configure an [optional timeout](/dev/reference/apis/sessions/#change-the-session-timeout) to account for intermittent or delayed network connectivity. From c8420ed4e915da2f5d696821c555c8bfffa5bf0e Mon Sep 17 00:00:00 2001 From: JessamyT Date: Tue, 1 Jul 2025 12:03:49 -0700 Subject: [PATCH 3/3] Revert certain APIs --- docs/dev/reference/apis/billing-client.md | 81 +++++++++++++++++ docs/dev/reference/apis/data-client.md | 79 +++++++++++++++++ docs/dev/reference/apis/fleet.md | 86 +++++++++++++++++++ docs/dev/reference/apis/ml-training-client.md | 81 +++++++++++++++++ docs/dev/reference/apis/services/data.md | 22 +++++ docs/dev/reference/apis/services/ml.md | 42 +++++++++ 6 files changed, 391 insertions(+) diff --git a/docs/dev/reference/apis/billing-client.md b/docs/dev/reference/apis/billing-client.md index 83bb753868..425b311dc4 100644 --- a/docs/dev/reference/apis/billing-client.md +++ b/docs/dev/reference/apis/billing-client.md @@ -25,6 +25,87 @@ The billing client API supports the following methods: {{< readfile "/static/include/app/apis/generated/billing-table.md" >}} +## Establish a connection + +To use the Viam billing client API, you first need to instantiate a `ViamClient` and then instantiate a `BillingClient`. + +You will also need an API key and API key ID to authenticate your session. +Your API key needs to have [Org owner permissions](/manage/manage/rbac/#organization-settings-and-roles) to use the billing client API. +To get an API key (and corresponding ID), you have two options: + +- [Create an API key in the web UI](/operate/control/api-keys/#add-an-api-key) +- [Create an API key using the Viam CLI](/dev/tools/cli/#create-an-organization-api-key) + +The following example instantiates a `ViamClient`, authenticating with an API key, and then instantiates a `BillingClient`: + +{{< tabs >}} +{{% tab name="Python" %}} + +```python {class="line-numbers linkable-line-numbers" data-line="12, 16"} +import asyncio + +from viam.rpc.dial import DialOptions, Credentials +from viam.app.viam_client import ViamClient +from viam.app.billing_client import BillingClient + + +async def connect() -> ViamClient: + dial_options = DialOptions( + credentials=Credentials( + type="api-key", + # Replace "" (including brackets) with your machine's API key + payload='', + ), + # Replace "" (including brackets) with your machine's + # API key ID + auth_entity='' + ) + return await ViamClient.create_from_dial_options(dial_options) + + +async def main(): + # Make a ViamClient + viam_client = await connect() + # Instantiate a BillingClient to run data client API methods on + billing_client = viam_client.billing_client + + viam_client.close() + +if __name__ == '__main__': + asyncio.run(main()) +``` + +{{% /tab %}} +{{% tab name="TypeScript" %}} + +```ts {class="line-numbers linkable-line-numbers" data-line="3, 5"} +async function connect(): Promise { + // Replace "" (including brackets) with your machine's + const API_KEY_ID = ""; + // Replace "" (including brackets) with your machine's API key + const API_KEY = ""; + const opts: VIAM.ViamClientOptions = { + serviceHost: "https://app.viam.com:443", + credentials: { + type: "api-key", + authEntity: API_KEY_ID, + payload: API_KEY, + }, + }; + + const client = await VIAM.createViamClient(opts); + return client; +} + +const viamClient = await connect(); +const billingClient = viamClient.billingClient; +``` + +{{% /tab %}} +{{< /tabs >}} + +Once you have instantiated a `BillingClient`, you can run [API methods](#api) against the `BillingClient` object (named `billing_client` in the examples). + ## API {{< readfile "/static/include/app/apis/generated/billing.md" >}} diff --git a/docs/dev/reference/apis/data-client.md b/docs/dev/reference/apis/data-client.md index dc6f6edda5..1a47188d98 100644 --- a/docs/dev/reference/apis/data-client.md +++ b/docs/dev/reference/apis/data-client.md @@ -42,6 +42,85 @@ Methods to work with datasets: {{< readfile "/static/include/app/apis/generated/dataset-table.md" >}} +## Establish a connection + +To use the Viam data client API, you first need to instantiate a `ViamClient` and then instantiate a `DataClient`. + +You will also need an API key and API key ID to authenticate your session. +To get an API key (and corresponding ID), you have two options: + +- [Create an API key in the web UI](/operate/control/api-keys/#add-an-api-key) +- [Create an API key using the Viam CLI](/dev/tools/cli/#create-an-organization-api-key) + +The following example instantiates a `ViamClient`, authenticating with an API key, and then instantiates a `DataClient`: + +{{< tabs >}} +{{% tab name="Python" %}} + +```python {class="line-numbers linkable-line-numbers"} +import asyncio + +from viam.rpc.dial import DialOptions, Credentials +from viam.app.viam_client import ViamClient + + +async def connect() -> ViamClient: + dial_options = DialOptions( + credentials=Credentials( + type="api-key", + # Replace "" (including brackets) with your machine's API key + payload='', + ), + # Replace "" (including brackets) with your machine's + # API key ID + auth_entity='' + ) + return await ViamClient.create_from_dial_options(dial_options) + + +async def main(): + # Make a ViamClient + viam_client = await connect() + # Instantiate a DataClient to run data client API methods on + data_client = viam_client.data_client + + viam_client.close() + +if __name__ == '__main__': + asyncio.run(main()) +``` + +{{% /tab %}} +{{% tab name="TypeScript" %}} + +```ts {class="line-numbers linkable-line-numbers" data-line="5"} +async function connect(): Promise { + // Replace "" (including brackets) with your machine's + const API_KEY_ID = ""; + // Replace "" (including brackets) with your machine's API key + const API_KEY = ""; + const opts: VIAM.ViamClientOptions = { + serviceHost: "https://app.viam.com:443", + credentials: { + type: "api-key", + authEntity: API_KEY_ID, + payload: API_KEY, + }, + }; + + const client = await VIAM.createViamClient(opts); + return client; +} + +const viamClient = await connect(); +const dataClient = viamClient.dataClient; +``` + +{{% /tab %}} +{{< /tabs >}} + +Once you have instantiated a `DataClient`, you can run [API methods](#api) against the `DataClient` object (named `data_client` in the examples). + ## API {{< readfile "/static/include/app/apis/generated/data_sync.md" >}} diff --git a/docs/dev/reference/apis/fleet.md b/docs/dev/reference/apis/fleet.md index 436af76045..624f7dc586 100644 --- a/docs/dev/reference/apis/fleet.md +++ b/docs/dev/reference/apis/fleet.md @@ -41,6 +41,92 @@ The fleet management API supports the following methods: {{< readfile "/static/include/app/apis/generated/app-table.md" >}} +## Establish a connection + +To use the Viam fleet management API, you first need to instantiate a `ViamClient` and then instantiate an `AppClient`. + +You will also need an API key and API key ID to authenticate your session. +To get an API key (and corresponding ID), you have two options: + +- [Create an API key in the web UI](/operate/control/api-keys/#add-an-api-key) +- [Create an API key using the Viam CLI](/dev/tools/cli/#create-an-organization-api-key) + +The following example instantiates a `ViamClient`, authenticating with an API key, and then instantiates an `AppClient`: + +{{< tabs >}} +{{% tab name="Python" %}} + +```python {class="line-numbers linkable-line-numbers"} +import asyncio + +from viam.rpc.dial import DialOptions, Credentials +from viam.app.viam_client import ViamClient + + +async def connect() -> ViamClient: + dial_options = DialOptions( + credentials=Credentials( + type="api-key", + # Replace "" (including brackets) with your API key + payload='', + ), + # Replace "" (including brackets) with your API key + # ID + auth_entity='' + ) + return await ViamClient.create_from_dial_options(dial_options) + + +async def main(): + + # Make a ViamClient + viam_client = await connect() + # Instantiate an AppClient called "cloud" + # to run fleet management API methods on + cloud = viam_client.app_client + + viam_client.close() + +if __name__ == '__main__': + asyncio.run(main()) +``` + +{{% /tab %}} +{{% tab name="TypeScript" %}} + +```ts {class="line-numbers linkable-line-numbers" data-line="3,5"} +async function connect(): Promise { + // Replace "" (including brackets) with your machine's + const API_KEY_ID = ""; + // Replace "" (including brackets) with your machine's API key + const API_KEY = ""; + const opts: VIAM.ViamClientOptions = { + serviceHost: "https://app.viam.com:443", + credentials: { + type: "api-key", + authEntity: API_KEY_ID, + payload: API_KEY, + }, + }; + + const client = await VIAM.createViamClient(opts); + return client; +} + +const viamClient = await connect(); +const appClient = appClient.appClient; +``` + +{{% /tab %}} +{{< /tabs >}} + +Once you have instantiated an `AppClient`, you can run the following [API methods](#api) against the `AppClient` object (named `fleet` in the examples). + +{{% hiddencontent %}} +To instantiate an `AppClient` from inside a module, you must authenticate using API keys. +You can use the module environment variables `VIAM_API_KEY` and `VIAM_API_KEY_ID` to access credentials. +{{% /hiddencontent %}} + ## API {{< readfile "/static/include/app/apis/generated/app.md" >}} diff --git a/docs/dev/reference/apis/ml-training-client.md b/docs/dev/reference/apis/ml-training-client.md index 4d1359a847..310d5776da 100644 --- a/docs/dev/reference/apis/ml-training-client.md +++ b/docs/dev/reference/apis/ml-training-client.md @@ -25,6 +25,87 @@ The ML training client API supports the following methods: {{< readfile "/static/include/app/apis/generated/mltraining-table.md" >}} +## Establish a connection + +To use the Viam ML training client API, you first need to instantiate a `ViamClient` and then instantiate an `MLTrainingClient`. + +You will also need an API key and API key ID to authenticate your session. +Your API key needs to have [Org owner permissions](/manage/manage/rbac/#organization-settings-and-roles) to use the MLTraining client API. +To get an API key (and corresponding ID), you have two options: + +- [Create an API key in the web UI](/operate/control/api-keys/#add-an-api-key) +- [Create an API key using the Viam CLI](/dev/tools/cli/#create-an-organization-api-key) + +The following example instantiates a `ViamClient`, authenticating with an API key, and then instantiates an `MLTrainingClient`: + +{{< tabs >}} +{{% tab name="Python" %}} + +```python {class="line-numbers linkable-line-numbers" data-line="12, 16"} +import asyncio + +from viam.rpc.dial import DialOptions, Credentials +from viam.app.viam_client import ViamClient + + +async def connect() -> ViamClient: + dial_options = DialOptions( + credentials=Credentials( + type="api-key", + # Replace "" (including brackets) with your machine's API key + payload='', + ), + # Replace "" (including brackets) with your machine's + # API key ID + auth_entity='' + ) + return await ViamClient.create_from_dial_options(dial_options) + + +async def main(): + + # Make a ViamClient + viam_client = await connect() + # Instantiate an MLTrainingClient to run ML training client API methods on + ml_training_client = viam_client.ml_training_client + + viam_client.close() + +if __name__ == '__main__': + asyncio.run(main()) +``` + +{{% /tab %}} +{{% tab name="TypeScript" %}} + +```ts {class="line-numbers linkable-line-numbers" data-line="3, 5"} +async function connect(): Promise { + // Replace "" (including brackets) with your machine's + const API_KEY_ID = ""; + // Replace "" (including brackets) with your machine's API key + const API_KEY = ""; + const opts: VIAM.ViamClientOptions = { + serviceHost: "https://app.viam.com:443", + credentials: { + type: "api-key", + authEntity: API_KEY_ID, + payload: API_KEY, + }, + }; + + const client = await VIAM.createViamClient(opts); + return client; +} + +const viamClient = await connect(); +const mlTrainingClient = viamClient.mlTrainingClient; +``` + +{{% /tab %}} +{{< /tabs >}} + +Once you have instantiated an `MLTrainingClient`, you can run the following [API methods](#api) against the `MLTrainingClient` object (named `ml_training_client` in the examples). + ## API {{< readfile "/static/include/app/apis/generated/mltraining.md" >}} diff --git a/docs/dev/reference/apis/services/data.md b/docs/dev/reference/apis/services/data.md index 1c6bc06f2a..9feb8a32b2 100644 --- a/docs/dev/reference/apis/services/data.md +++ b/docs/dev/reference/apis/services/data.md @@ -21,6 +21,28 @@ The [data management service](/data-ai/capture-data/capture-sync/) supports the 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](/dev/reference/apis/data-client/). +## Establish a connection + +To get started using Viam's SDKs to connect to and control your machine, go to your machine's page, navigate to the **CONNECT** tab's **Code sample** page, select your preferred programming language, and copy the sample code. + +{{% snippet "show-secret.md" %}} + +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. + +{{< tabs >}} +{{% tab name="Go" %}} + +```go +import ( + "go.viam.com/rdk/services/datamanager" +) +``` + +{{% /tab %}} +{{< /tabs >}} + ## API {{< readfile "/static/include/services/apis/generated/data_manager.md" >}} diff --git a/docs/dev/reference/apis/services/ml.md b/docs/dev/reference/apis/services/ml.md index ce7e273a71..f0c0bd3ddf 100644 --- a/docs/dev/reference/apis/services/ml.md +++ b/docs/dev/reference/apis/services/ml.md @@ -19,6 +19,48 @@ The [ML Model service](/data-ai/ai/deploy/) supports the following methods: {{< readfile "/static/include/services/apis/generated/mlmodel-table.md" >}} +## Establish a connection + +{{< alert title="Viam Python SDK Support" color="note" >}} + +To use the ML model service from the [Viam Python SDK](https://python.viam.dev/), install the Python SDK using the `mlmodel` extra: + +```sh {class="command-line" data-prompt="$"} +pip install 'viam-sdk[mlmodel]' +``` + +{{< /alert >}} + +To get started using Viam's SDKs to connect to and control your machine, go to your machine's page, navigate to the **CONNECT** tab's **Code sample** page, select your preferred programming language, and copy the sample code. + +{{% snippet "show-secret.md" %}} + +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 `MLModel` service called `"my_mlmodel_service"`, and that you have installed the `mlmodel` extra for the Python SDK. +If your ML model service has a different name, change the `name` in the code. + +Import the mlmodel package for the SDK you are using: + +{{< tabs >}} +{{% tab name="Python" %}} + +```python +from viam.services.mlmodel import MLModelClient +``` + +{{% /tab %}} +{{% tab name="Go" %}} + +```go +import ( + "go.viam.com/rdk/services/mlmodel" +) +``` + +{{% /tab %}} +{{< /tabs >}} + ## API {{< readfile "/static/include/services/apis/generated/mlmodel.md" >}}