Skip to content

Commit

Permalink
Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
npentrel committed Oct 31, 2023
1 parent 3f5a636 commit 7e00a45
Show file tree
Hide file tree
Showing 16 changed files with 42 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,4 @@ jobs:
run: python3 .github/workflows/get_modular_resources.py
env:
TYPESENSE_API_KEY_MR: ${{ secrets.TYPESENSE_API_KEY_MR }}
VIAM_LOCATION_SECRET: ${{ secrets.VIAM_LOCATION_SECRET }}
VIAM_API_KEY: ${{ secrets.VIAM_API_KEY }}
8 changes: 3 additions & 5 deletions .github/workflows/get_modular_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@

async def connect() -> ViamClient:
dial_options = DialOptions(
# The URL of any robot in the location.
auth_entity='divine-voice-main.b5luvepsyg.viam.cloud',
auth_entity='744b0c18-f6fd-4c8d-a707-d3f261b353cc'
credentials=Credentials(
type='robot-location-secret',
# The location secret
payload=os.environ['VIAM_LOCATION_SECRET']
type='api-key',
payload=os.environ['VIAM_API_KEY']
)
)
return await ViamClient.create_from_dial_options(dial_options)
Expand Down
7 changes: 2 additions & 5 deletions docs/components/input-controller/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -838,11 +838,8 @@ cmd = {}

async def connect_robot(host, api_key, api_key_id):
opts = RobotClient.Options.with_api_key(
# Replace "<API-KEY>" (including brackets) with your robot's api key
api_key='<API-KEY>',
# Replace "<API-KEY-ID>" (including brackets) with your robot's api key id
api_key_id='<API-KEY-ID>',
refresh_interval=0,
api_key=api_key,
api_key_id=api_key_id
)
return await RobotClient.at_address(host, opts)

Expand Down
19 changes: 8 additions & 11 deletions docs/program/apis/cloud.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ Cloud app API methods are only available in the Python SDK.

To use the Viam cloud app API, you first need to instantiate a [`ViamClient`](https://python.viam.dev/autoapi/viam/app/viam_client/index.html#viam.app.viam_client.ViamClient) and then instantiate an [`AppClient`](https://python.viam.dev/autoapi/viam/app/app_client/index.html#viam.app.app_client.AppClient).
See the following example for reference.
To find the api key and secret, go to [Viam app](https://app.viam.com/), and navigate to the bottom of your location's page.
For the URL, use the address of any of the robots in the location (found on the **Code sample** tab).

TODO
To find your api key and secret, go to [Viam app](https://app.viam.com/), and navigate to one of your robots' **Security** tab the bottom of your location's page.

```python {class="line-numbers linkable-line-numbers"}
import asyncio
Expand All @@ -47,13 +44,13 @@ from viam.app.viam_client import ViamClient

async def connect() -> ViamClient:
dial_options = DialOptions(
# The URL of any robot in the location.
auth_entity='beepboop-main.YOUR LOCATION ID.viam.cloud',
credentials=Credentials(
type='robot-location-secret',
# The location secret
payload='YOUR LOCATION SECRET'
)
credentials=Credentials(
type="api-key",
# Replace "<API-KEY>" (including brackets) with your robot's api key
payload='<API-KEY>',
),
# Replace "<API-KEY-ID>" (including brackets) with your robot's api key id
auth_entity='<API-KEY-ID>'
)
return await ViamClient.create_from_dial_options(dial_options)

Expand Down
16 changes: 7 additions & 9 deletions docs/program/apis/data-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,21 @@ import asyncio
from viam.rpc.dial import DialOptions, Credentials
from viam.app.viam_client import ViamClient

TODO

async def connect() -> ViamClient:
dial_options = DialOptions(
# The URL of any robot in the location.
auth_entity='beepboop-main.YOUR LOCATION ID.viam.cloud',
credentials=Credentials(
type='robot-location-secret',
# The location secret
payload='YOUR LOCATION SECRET'
)
credentials=Credentials(
type="api-key",
# Replace "<API-KEY>" (including brackets) with your robot's api key
payload='<API-KEY>',
),
# Replace "<API-KEY-ID>" (including brackets) with your robot's api key id
auth_entity='<API-KEY-ID>'
)
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
Expand Down
3 changes: 1 addition & 2 deletions docs/tutorials/projects/light-up.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@ You need to tell the code how to access your specific robot (which in this case

{{% snippet "show-secret.md" %}}

2. In the code sample, find the `payload`, a long string of numbers and letters.
Copy it and paste it into line 13 of <file>lightupbot.py</file> in place of `ROBOT_SECRET`. TODO
2. Get the robot address and API key from the code sample and set them as environment variables or add them at the top of <file>lightupbot.py</file>.
3. Find the robot address, of the form `robot-name-main.abc1ab123a1.viam.cloud`, and paste it into line 14 of <file>lightupbot.py</file> in place of `ROBOT_ADDRESS`.

You also need to tell the code how to access your smart plug.
Expand Down
6 changes: 3 additions & 3 deletions docs/tutorials/projects/pet-treat-dispenser.md
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ from viam.services.vision import VisionClient

# these must be set, you can get them from your robot's 'Code sample' tab
robot_api_key = os.getenv('ROBOT_API_KEY') or ''
robot_api_key_secret = os.getenv('ROBOT_API_KEY_SECRET') or ''
robot_api_key_id = os.getenv('ROBOT_API_KEY_ID') or ''
robot_address = os.getenv('ROBOT_ADDRESS') or ''

# change this if you named your camera differently in your robot configuration
Expand All @@ -493,8 +493,8 @@ camera_name = os.getenv('ROBOT_CAMERA') or 'petcam'

async def connect():
opts = RobotClient.Options.with_api_key(
api_key=robot_api_key_secret,
api_key_id=robot_api_key
api_key=robot_api_key,
api_key_id=robot_api_key_id
)
return await RobotClient.at_address(robot_address, opts)

Expand Down
6 changes: 3 additions & 3 deletions docs/tutorials/projects/send-security-photo.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,14 @@ import yagmail

# These must be set. You can get them from your robot's 'Code sample' tab
robot_api_key = os.getenv('ROBOT_API_KEY') or ''
robot_api_key_secret = os.getenv('ROBOT_API_KEY_SECRET') or ''
robot_api_key_id = os.getenv('ROBOT_API_KEY_ID') or ''
robot_address = os.getenv('ROBOT_ADDRESS') or ''


async def connect():
opts = RobotClient.Options.with_api_key(
api_key=robot_api_key_secret,
api_key_id=robot_api_key
api_key=robot_api_key,
api_key_id=robot_api_key_id
)
return await RobotClient.at_address(robot_address, opts)

Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/projects/tipsy.md
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ You can also use a laser cutter to cut them into the sizes you prefer if you wan

## Add the robot logic

Download the [full code](https://raw.githubusercontent.com/viam-labs/devrel-demos/main/tipsy-bot/tipsy.py) onto your computer. TODO
Download the [full code](https://raw.githubusercontent.com/viam-labs/devrel-demos/main/tipsy-bot/tipsy.py) onto your computer.

Let’s take a look at what it does.
First, the code imports the required libraries:
Expand All @@ -629,7 +629,7 @@ Replace these values with your robot’s own location secret and address, which

```python {class="line-numbers linkable-line-numbers"}
robot_api_key = os.getenv('ROBOT_API_KEY') or ''
robot_api_key_secret = os.getenv('ROBOT_API_KEY_SECRET') or ''
robot_api_key_id = os.getenv('ROBOT_API_KEY_ID') or ''
robot_address = os.getenv('ROBOT_ADDRESS') or ''
# change this if you named your base differently in your robot configuration
base_name = os.getenv('ROBOT_BASE') or 'tipsy-base'
Expand Down
3 changes: 1 addition & 2 deletions docs/tutorials/services/accessing-and-moving-robot-arm.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,7 @@ async def connect():
# Replace "<API-KEY>" (including brackets) with your robot's api key
api_key='<API-KEY>',
# Replace "<API-KEY-ID>" (including brackets) with your robot's api key id
api_key_id='<API-KEY-ID>',
refresh_interval=0
api_key_id='<API-KEY-ID>'
)
return await RobotClient.at_address('ADDRESS FROM THE VIAM APP', opts)

Expand Down
6 changes: 2 additions & 4 deletions docs/tutorials/services/color-detection-scuttle.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@ async def connect():
# Replace "<API-KEY>" (including brackets) with your robot's api key
api_key='<API-KEY>',
# Replace "<API-KEY-ID>" (including brackets) with your robot's api key id
api_key_id='<API-KEY-ID>',
refresh_interval=0
api_key_id='<API-KEY-ID>'
)
return await RobotClient.at_address("ADDRESS FROM THE VIAM APP", opts)

Expand Down Expand Up @@ -331,8 +330,7 @@ async def connect():
# Replace "<API-KEY>" (including brackets) with your robot's api key
api_key='<API-KEY>',
# Replace "<API-KEY-ID>" (including brackets) with your robot's api key id
api_key_id='<API-KEY-ID>',
refresh_interval=0,
api_key_id='<API-KEY-ID>'
)
return await RobotClient.at_address("ADDRESS FROM THE VIAM APP", opts)

Expand Down
3 changes: 1 addition & 2 deletions docs/tutorials/services/navigate-with-rover-base.md
Original file line number Diff line number Diff line change
Expand Up @@ -626,8 +626,7 @@ async def connect():
# Replace "<API-KEY>" (including brackets) with your robot's api key
api_key='<API-KEY>',
# Replace "<API-KEY-ID>" (including brackets) with your robot's api key id
api_key_id='<API-KEY-ID>',
refresh_interval=0
api_key_id='<API-KEY-ID>'
)
return await RobotClient.at_address('<INSERT REMOTE ADDRESS>', opts)

Expand Down
3 changes: 1 addition & 2 deletions docs/tutorials/services/plan-motion-with-arm-gripper.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,7 @@ async def connect():
# Replace "<API-KEY>" (including brackets) with your robot's api key
api_key='<API-KEY>',
# Replace "<API-KEY-ID>" (including brackets) with your robot's api key id
api_key_id='<API-KEY-ID>',
refresh_interval=0,
api_key_id='<API-KEY-ID>'
)
return await RobotClient.at_address('<ROBOT ADDRESS>', opts)

Expand Down
9 changes: 5 additions & 4 deletions static/include/program/authenticate.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ To authenticate yourself to your robot, you need

1. The robot's part api key:

To authenticate, [create an api key [using the UI]() or [using the CLI](/manage/cli/#create-an-organization-api-key).
To authenticate, [create a robot api key using the UI]() or [create an organization-wide api key using the CLI](/manage/cli/#create-an-organization-api-key).
Copy and paste the api key id and the api key into your environment variables or directly into the code:

{{< tabs >}}
Expand Down Expand Up @@ -100,16 +100,17 @@ Future<void> connectToViam() async {
{{< /tabs >}}

{{< alert title="Caution" color="caution" >}}
Do not share your part api key id, org api key, or robot address publicly.
Do not share your part api key or robot address publicly.
Sharing this information could compromise your system security by allowing unauthorized access to your robot, or to the computer running your robot.
{{< /alert >}}

{{< alert title="Location secret (deprecated)" color="note" >}}

Prior to API keys, Viam used Location secrets for authentication.
To avoid future issues, start using API keys.
Location secrets are now deprecated.
To avoid connection issues, start using API keys.

{{< /alert >}}

2. The robot's remote address: Include the address, which resembles `12345.somerobot-main.viam.cloud`. The robot address is as a public address to connect to your robot.
You can find this address at the top of the robot's **Control** tab or in the **Code sample** tab..
You can find this address at the top of the robot's **Control** tab or in the **Code sample** tab.
2 changes: 1 addition & 1 deletion static/include/snippet/secret-share.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{< alert title="Caution" color="caution" >}}
Do not share your part api key id, org api key, or robot address publicly.
Do not share your api key or robot address publicly.
Sharing this information could compromise your system security by allowing unauthorized access to your robot, or to the computer running your robot.
{{< /alert >}}
2 changes: 1 addition & 1 deletion static/include/snippet/show-secret.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ By default, the sample code does not include your robot api key and secret.
We strongly recommend that you add your api key and secret as an environment variable and import this variable into your development environment as needed.

To show your robot's api key and secret in the sample code, toggle **Include secret** on the **Code sample** tab.
You can also see your api key and secret on the [locations page](/manage/fleet/locations/).
You can also see your api key and secret on your robot's **Security** tab.
{{< /alert >}}

{{% snippet "secret-share.md" %}}

0 comments on commit 7e00a45

Please sign in to comment.