mongocli iam organization apikey assign
The iam organization apikey assign
command updates the description
or roles of the specified organization API key.
Syntax
mongocli iam organization|organizations|org|orgs apiKey|apiKeys|apikeys assign|update <api-key-id> [ --desc "<description-of-key>" ] [ --orgId <organization-id> ] [ --output|-o <output-format> ] [ --profile|-P <profile-name> ] [ --role <list-of-roles> ]
Note
Use -h
or --help
to view the command-line help for
this command.
Arguments
Argument | Type | Description | Required? |
---|---|---|---|
<api-key-id> | string | Unique identifier for this organization API key. | yes |
Options
Option | Type | Description | Required? |
---|---|---|---|
--desc | string | Description of the API key to update. | no |
--orgId | string | Unique identifier of the organization of the API key you want to update. If specified, this value overrides any organization ID stored in your profile or environment variable. If omitted, your profile must contain the organization ID. | no |
--output , -o | string | Command output format. Valid values are:
If omitted, the command returns output in the default format. | no |
--profile , -P | string | Name of the profile where your credentials are saved. If omitted, uses the default profile. To learn more about creating a profile, see Configure the MongoDB CLI. | no |
--role | string | Role or roles to assign to the API key. To assign more than
one role, you can specify each role with a --role flag or
specify the roles in a comma-separated list with one --role
flag. | no |
Output
If the command succeeds, it returns the following output in the default format. If the command returns errors, see Troubleshooting for recommended solutions.
API Key '<api-key-id>' successfully updated.
The default output is a subset of the fields returned by this command. For the complete list of JSON fields returned by the command, see the Public API reference for your MongoDB service:
Examples
The following command updates the description and role of an organization API key using the default profile, which contains credentials and the organization ID. The output is returned in the default format.
mongocli iam org apikey assign 5f3d8790c9022019903c1234 --role ORG_MEMBER --desc "User1 Member Key"
The previous command prints the following to the terminal.
API Key '5f3d8790c9022019903c1234' successfully updated.
The following command updates the role and description of an
API key using the myOM
profile, which contains credentials.
The output is returned in JSON format.
mongocli iam organization apikey assign 5f3d8790c9022019903c1234 --role ORG_MEMBER --desc "User1 Member Key" --orgId 5a1b39eec902201990f12345 -P myOM --output json
The previous command updates the API key and prints the following to the terminal in JSON format.
[ { "id": "5f3d8790c9022019903c1234", "desc": "User1 Member Key", "roles": [ { "orgId": "5e429f2e12345c6eac4d59c9", "roleName": "ORG_MEMBER" } ], "privateKey": "********-****-****-123468e0b5be", "publicKey": "abcdefgh" } ]