mongocli iam organization apikey whitelist create
The iam organization apikey whitelist create
command creates one or
more new whitelist entries for the specified API key.
Syntax
mongocli iam organization|organizations|org|orgs apiKey|apiKeys|apikeys whitelist|whitelists create --apiKey <api-key-id> [ --cidr <cidr-entry> ] [ --ip <id-entry> ] [ --orgId <organization-id> ] [ --output|-o <output-format> ] [ --profile|-P <profile-name> ]
Note
Use -h
or --help
to view the command-line help for
this command.
Options
Option | Type | Description | Required? |
---|---|---|---|
--apikey | string | Unique identifier of the API key. | yes |
--cidr | string | Whitelist entry in CIDR notation to be added for the API key.
To add more than one entry in CIDR notation, you can specify
each entry with a --cidr flag or specify the entries in a
comma-separated list with one --cidr flag. | no |
--ip | string | IP address to be added to the whitelist for the API key.
To add more than one IP address, you can specify
each address with an --ip flag or specify the addresses in a
comma-separated list with one --ip flag. | no |
--orgId | string | Unique identifier of the organization to which the target API key belongs. 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. You must have credentials with the If omitted, uses the default profile. To learn more about creating a profile, see Configure the MongoDB CLI. | no |
Output
If the command succeeds, it prints the following output to the terminal. If the command returns errors, see Troubleshooting for recommended solutions.
Created new whitelist entry(s).
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 creates a whitelist entry for an API key using the default profile, which contains credentials, the organization ID, and specifies the Atlas service. The output is returned in the default format.
mongocli iam orgs apikey whitelist create --apiKey 5f24084d8dbffa3ad3f21234 --ip 192.0.2.0
The previous command creates the whitelist entry and prints the following to the terminal.
Created new whitelist entry(s).
The following command creates two whitelist entries for an API key using the myOM
profile, which contains credentials and
specifies the Ops Manager service. The output is returned in JSON
format.
mongocli iam orgs apikey whitelist create --apiKey 5f24084d8dbffa3ad3f21234 --cidr 192.0.2.0/24,198.51.100.0/24 --orgId 5a1b39eec902201990f12345 --output json
The previous command creates the whitelist entries and prints the following to the terminal in JSON format.
{ "results": [ { "cidrBlock": "198.51.100.0/24", "created": "2020-08-04T10:16:51Z", "ipAddress": "198.51.100.0", "links": [ { "rel": "self", "href": "https://example.mongodb.com/api/atlas/v1.0/orgs/5a1b39eec902201990f12345/apiKeys/5f24084d8dbffa3ad3f21234/whitelist/198.51.100.0" } ] }, { "cidrBlock": "192.0.2.0/24", "created": "2020-08-04T10:16:51Z", "ipAddress": "192.0.2.0", "links": [ { "rel": "self", "href": "https://example.mongodb.com/api/atlas/v1.0/orgs/5a1b39eec902201990f12345/apiKeys/5f24084d8dbffa3ad3f21234/whitelist/192.0.2.0" } ] } ], "links": [ { "rel": "self", "href": "https://example.mongodb.com/api/atlas/v1.0/orgs/5a1b39eec902201990f12345/apiKeys/5f24084d8dbffa3ad3f21234/whitelist?pageNum=1\u0026itemsPerPage=100" } ], "totalCount": 2 }