diff --git a/docs/dev/tools/cli.md b/docs/dev/tools/cli.md index a3bee992fe..173d9e1587 100644 --- a/docs/dev/tools/cli.md +++ b/docs/dev/tools/cli.md @@ -598,7 +598,7 @@ See [Authenticate](#authenticate). | -------------- | ----------- | -------------------- | | `api-key` | Authenticate to Viam using an organization, location, or machine part API key. | - | | `print-access-token` | Prints the access token used to authenticate the current CLI session. | - | -| `--disable-browser-open` | Authenticate in a headless environment by preventing the opening of the default browser during login (default: `false`). | - | +| `--no-browser` | Authenticate in a headless environment by preventing the opening of the default browser during login (default: `false`). | - | | `--help` | Return help. | - | ##### Named arguments @@ -1091,7 +1091,7 @@ See [create an organization API key](#create-an-organization-api-key) for more i | Command option | Description | Positional arguments | | -------------- | ----------- | -------------------- | -| `list` | List all organizations (name, id, and [namespace](/operate/reference/naming-modules/#create-a-namespace-for-your-organization)) that the authenticated session has access to. | - | +| `list` | List all organizations (name, ID, and [namespace](/operate/reference/naming-modules/#create-a-namespace-for-your-organization)) that the authenticated session has access to. | - | | `api-key create` | Create a new organization API key. | - | | `support-email get` | Get the support email for an organization. | - | | `support-email set` | Set the support email for an organization. | - | @@ -1159,6 +1159,59 @@ viam packages export --org-id=123 --name=MyMLModel --version=latest --type=ml_mo | `--path` | The path to the package for upload. The package should be zipped with tar and have the `.tar.gz` extension. | `upload` | **Required** | | `--destination` | The output directory for downloaded package. | `export` | **Required** | +### `profiles` + +The `profiles` command allows you to manage different CLI authentication profiles, so you can easily switch between API key authentications (for example authentication to one organization versus another). + +```sh {class="command-line" data-prompt="$"} +viam profiles add --profile-name= --key-id= --key= +viam profiles update --profile-name= --key-id= --key= +viam profiles list +viam profiles remove --profile-name= +``` + +Examples: + +```sh {id="terminal-prompt" class="command-line" data-prompt="$"} +# Add a new profile for authentication (throws error if profile already exists) +viam profiles add --profile-name=mycompany --key-id=54321zyx --key=123abcd1234 + +# Update an existing profile for authentication, or add it if it doesn't exist +viam profiles update --key=123abcd1234 --key-id=54321zyx --profile-name=mycompany + +# List all existing profiles by name +viam profiles list + +# Remove a profile +viam profiles remove --profile-name=mycompany +``` + +See [create an organization API key](#create-an-organization-api-key) for more information. + +{{% alert title="Tip" color="tip" %}} +You can set a default profile by using the `VIAM_CLI_PROFILE_NAME` environment variable. +{{% /alert %}} + +#### Command options + + +| Command option | Description | Positional arguments | +| -------------- | ----------- | -------------------- | +| `add` | List all existing profiles by name. | - | +| `update` | Update an existing profile for authentication, or add it if it doesn't exist. | - | +| `list` | List all existing profiles by name. | - | +| `remove` | Remove a profile. | - | +| `--help` | Return help | - | + +##### Named arguments + + +| Argument | Description | Applicable commands | Required? | +| -------- | ----------- | ------------------- | --------- | +| `--profile-name` | Name of the profile to add, update, or remove. | `add`, `update`, `remove` | **Required** | +| `--key-id` | The `key id` (UUID) of the API key. | `add`, `update` | **Required** | +| `--key` | The `key value` of the API key. | `api-key`, `update` | **Required** | + ### `machines` (alias `robots`) The `machines` command allows you to manage your machine fleet. @@ -1179,7 +1232,7 @@ viam machines api-key create --machine-id= [...named args] viam machines part logs --machine= --part= [...named args] viam machines part status --organization= --location= --machine= viam machines part run --organization= --location= --machine= [--stream] --data -viam machines part shell --organization= --location= --machine= +viam machines part shell --organization= --location= --machine= --part= viam machines part restart --machine= --part= viam machines part cp --organization= --location= --machine= --part= machine:/path/to/file ``` @@ -1191,45 +1244,42 @@ Examples: viam machines list # get machine status -viam machines status --machine=123 --organization="Robot's Org" --location=myLoc +viam machines status --machine=123 --location=myLoc # create an api key for a machine viam machines api-key create --machine-id=123 --name=MyKey # stream logs from a machine -viam machines logs --machine=123 \ ---organization="Robot's Org" --location=myLoc +viam machines logs --machine=123 # stream logs from a machine part -viam machines part logs --machine=123 \ ---organization="Robot's Org" --location=myLoc --part=myrover-main --tail=true +viam machines part logs --part=myrover-main --tail=true # stream classifications from a machine part every 500 milliseconds from the Viam Vision Service with classifier "stuff_detector" -viam machines part run --machine=123 \ ---organization="Robot's Org" --location=myLoc --part=myrover-main --stream=500ms \ +viam machines part run --part=myrover-main --stream=500ms \ --data='{"name": "vision", "camera_name": "cam", "classifier_name": "stuff_classifier", "n":1}' \ viam.service.vision.v1.VisionService.GetClassificationsFromCamera # restart a part of a specified machine -viam machines part restart --machine=123 --part=456 +viam machines part restart --part=123 # Copy and a single file to a machine and change the file's name: -viam machine part cp --organization=my_org --location=my_location --machine=my_machine --part=m1-main my_file machine:/home/user/ +viam machine part cp --part=m1-main my_file machine:/home/user/ # Recursively copy a directory to a machine: -viam machine part cp --machine=123 --part=123 -r my_dir machine:/home/user/ +viam machine part cp --part=123 -r my_dir machine:/home/user/ # Copy multiple files to a machine with recursion and keep original permissions and metadata for the files: -viam machine part cp --machine=123 --part=123 -r -p my_dir my_file machine:/home/user/some/existing/dir/ +viam machine part cp --part=123 -r -p my_dir my_file machine:/home/user/some/existing/dir/ # Copy a single file from a machine to a local destination: -viam machine part cp --machine=123 --part=123 machine:my_file ~/Downloads/ +viam machine part cp --part=123 machine:my_file ~/Downloads/ # Recursively copy a directory from a machine to a local destination: -viam machine part cp --machine=123 --part=123 -r machine:my_dir ~/Downloads/ +viam machine part cp --part=123 -r machine:my_dir ~/Downloads/ # Copy multiple files from the machine to a local destination with recursion and keep original permissions and metadata for the files: -viam machine part cp --machine=123 --part=123 -r -p machine:my_dir machine:my_file ~/some/existing/dir/ +viam machine part cp --part=123 -r -p machine:my_dir machine:my_file ~/some/existing/dir/ ``` #### Command options @@ -1270,8 +1320,8 @@ viam machine part cp --machine=123 --part=123 -r -p machine:my_dir machine:my_fi | Argument | Description | Applicable commands | Required? | | -------- | ----------- | ------------------- | --------- | -| `--organization` | Organization name or ID that the machine belongs to | `list`, `status`, `logs`, `part` | **Required** | -| `--location` | Location name or ID that the machine belongs to or to list machines in | `list`, `status`, `logs`, `part` | **Required** | +| `--organization` | Organization name or ID that the machine belongs to | `list`, `status`, `logs`, `part` | Optional | +| `--location` | Location name or ID that the machine belongs to or to list machines in | `list`, `status`, `logs`, `part` | Optional | | `--machine` | Machine name or ID for which the command is being issued. If machine name is used instead of ID, `--organization` and `--location` are required. | `status`, `logs`, `part` | **Required** | | `--errors` | Boolean, return only errors (default: false) | `logs` | Optional | | `--levels` | Filter logs by levels (debug, info, warn, error). Accepts multiple inputs in comma-separated list. | `logs` | Optional | @@ -1470,4 +1520,8 @@ You can pass global options after the `viam` CLI keyword with any command. | Global option | Description | | ------------- | ----------- | -| `--debug` | Enable debug logging (default: false) | +| `--debug` | Enable debug logging (default: false). | +| `--disable-profiles`, `disable-profile` | Disable usage of [profiles](#profiles), falling back to default (false) behavior. | +| `--help`, `-h` | Show help (default: false). | +| `--profile` | Specify a particular [profile](#profiles) for the current command. | +| `--quiet`, `-q` | Suppress warnings (default: false). |