Skip to content

Commit 4383246

Browse files
(DOCSP-11567, -11605, -11606): mongocli iam organization apikey whitelist commands (#215)
* (DOCSP-11567): mongocli iam org apikey whitelist create * (DOCSP-11605): mongocli iam org apikey whitelist list * (DOCSP-11606): mongocli iam org apikey whitelist delete * cleanup
1 parent a6bf73f commit 4383246

File tree

4 files changed

+567
-0
lines changed

4 files changed

+567
-0
lines changed
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
.. _mcli-iam-organization-apikey-whitelist-create:
2+
3+
=================================================
4+
mongocli iam organization apikey whitelist create
5+
=================================================
6+
7+
.. default-domain:: mongodb
8+
9+
.. contents:: On this page
10+
:local:
11+
:backlinks: none
12+
:depth: 1
13+
:class: singlecol
14+
15+
The ``iam organization apikey whitelist create`` command creates one or
16+
more new whitelist entries for the specified |api| key.
17+
18+
.. _mcli-iam-organization-apikey-whitelist-create-syntax:
19+
20+
Syntax
21+
------
22+
23+
.. code-block:: sh
24+
25+
mongocli iam organization|organizations|org|orgs apiKey|apiKeys|apikeys whitelist|whitelists create
26+
--apiKey <api-key-id>
27+
[ --cidr <cidr-entry> ]
28+
[ --ip <id-entry> ]
29+
[ --orgId <organization-id> ]
30+
[ --output|-o <output-format> ]
31+
[ --profile|-P <profile-name> ]
32+
33+
.. include:: /includes/fact-command-line-help.rst
34+
35+
.. _mcli-iam-organization-apikey-whitelist-create-options:
36+
37+
Options
38+
-------
39+
40+
.. list-table::
41+
:header-rows: 1
42+
:widths: 20 10 60 10
43+
44+
* - Option
45+
- Type
46+
- Description
47+
- Required?
48+
49+
* - ``--apikey``
50+
- string
51+
- Unique identifier of the |api| key.
52+
- yes
53+
54+
* - ``--cidr``
55+
- string
56+
- Whitelist entry in |cidr| notation to be added for the API key.
57+
To add more than one entry in |cidr| notation, you can specify
58+
each entry with a ``--cidr`` flag or specify the entries in a
59+
comma-separated list with one ``--cidr`` flag.
60+
- no
61+
62+
* - ``--ip``
63+
- string
64+
- IP address to be added to the whitelist for the |api| key.
65+
To add more than one IP address, you can specify
66+
each address with an ``--ip`` flag or specify the addresses in a
67+
comma-separated list with one ``--ip`` flag.
68+
- no
69+
70+
* - ``--orgId``
71+
- string
72+
- Unique identifier of the organization to which the target |api|
73+
key belongs.
74+
75+
If specified, this value overrides any organization ID
76+
stored in your :ref:`profile <mcli-profiles>` or
77+
:ref:`environment variable <mcli-env-var>`.
78+
79+
If omitted, your profile must contain the
80+
organization ID.
81+
- no
82+
83+
* - ``--output``, ``-o``
84+
- string
85+
- .. include:: /includes/extracts/fact-basic-options-output.rst
86+
- no
87+
88+
* - ``--profile``, ``-P``
89+
- string
90+
- Name of the profile where your credentials are saved.
91+
92+
You must have credentials with the ``Organization Owner`` role to
93+
create an |api| key for the organization.
94+
95+
If omitted, uses the {+default-profile+}. To learn more about
96+
creating a profile, see :ref:`mcli-configure`.
97+
- no
98+
99+
.. _mcli-iam-organization-apikey-whitelist-create-output:
100+
101+
Output
102+
------
103+
104+
If the command succeeds, it prints the following output to the terminal.
105+
If the command returns errors, see :ref:`Troubleshooting
106+
<troubleshooting>` for recommended solutions.
107+
108+
.. code-block:: sh
109+
:copyable: false
110+
111+
Created new whitelist entry(s).
112+
113+
.. include:: /includes/fact-default-output.rst
114+
115+
- :atlas:`Atlas </reference/api/apiKeys-org-whitelist-create/#response>`
116+
- :cloudmgr:`Cloud Manager </reference/api/api-keys/org/create-org-api-key-whitelist/#response>`
117+
- :opsmgr:`Ops Manager </reference/api/api-keys/org/create-org-api-key-whitelist/#response>`
118+
119+
.. _mcli-iam-organization-apikey-whitelist-create-examples:
120+
121+
Examples
122+
--------
123+
124+
.. tabs::
125+
126+
.. tab:: Default Output
127+
:tabid: default-output
128+
129+
The following command creates a whitelist entry for an |api| key
130+
using the {+default-profile+}, which contains credentials, the
131+
organization ID, and specifies the |service| service. The output
132+
is returned in the default format.
133+
134+
.. code-block:: sh
135+
136+
mongocli iam orgs apikey whitelist create --apiKey 5f24084d8dbffa3ad3f21234 --ip 192.0.2.0
137+
138+
The previous command creates the whitelist entry and
139+
prints the following to the terminal.
140+
141+
.. code-block:: json
142+
:copyable: false
143+
144+
Created new whitelist entry(s).
145+
146+
.. tab:: JSON Output
147+
:tabid: json-output
148+
149+
The following command creates two whitelist entries for an |api| key using the ``myOM`` profile, which contains credentials and
150+
specifies the |onprem| service. The output is returned in |json|
151+
format.
152+
153+
.. code-block:: sh
154+
155+
mongocli iam orgs apikey whitelist create --apiKey 5f24084d8dbffa3ad3f21234 --cidr 192.0.2.0/24,198.51.100.0/24 --orgId 5a1b39eec902201990f12345 --output json
156+
157+
The previous command creates the whitelist entries and
158+
prints the following to the terminal in |json| format.
159+
160+
.. code-block:: json
161+
:copyable: false
162+
163+
{
164+
"results": [
165+
{
166+
"cidrBlock": "198.51.100.0/24",
167+
"created": "2020-08-04T10:16:51Z",
168+
"ipAddress": "198.51.100.0",
169+
"links": [
170+
{
171+
"rel": "self",
172+
"href": "https://example.mongodb.com/api/atlas/v1.0/orgs/5a1b39eec902201990f12345/apiKeys/5f24084d8dbffa3ad3f21234/whitelist/198.51.100.0"
173+
}
174+
]
175+
},
176+
{
177+
"cidrBlock": "192.0.2.0/24",
178+
"created": "2020-08-04T10:16:51Z",
179+
"ipAddress": "192.0.2.0",
180+
"links": [
181+
{
182+
"rel": "self",
183+
"href": "https://example.mongodb.com/api/atlas/v1.0/orgs/5a1b39eec902201990f12345/apiKeys/5f24084d8dbffa3ad3f21234/whitelist/192.0.2.0"
184+
}
185+
]
186+
}
187+
],
188+
"links": [
189+
{
190+
"rel": "self",
191+
"href": "https://example.mongodb.com/api/atlas/v1.0/orgs/5a1b39eec902201990f12345/apiKeys/5f24084d8dbffa3ad3f21234/whitelist?pageNum=1\u0026itemsPerPage=100"
192+
}
193+
],
194+
"totalCount": 2
195+
}
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
.. _mcli-iam-organization-apikey-whitelist-delete:
2+
3+
=================================================
4+
mongocli iam organization apikey whitelist delete
5+
=================================================
6+
7+
.. default-domain:: mongodb
8+
9+
.. contents:: On this page
10+
:local:
11+
:backlinks: none
12+
:depth: 1
13+
:class: singlecol
14+
15+
The ``iam organization apikey whitelist delete`` command deletes a
16+
whitelist entry for the specified |api| key. You must confirm the
17+
operation when you run this command without the ``--force`` option.
18+
19+
.. _mcli-iam-organization-apikey-whitelist-delete-syntax:
20+
21+
Syntax
22+
------
23+
24+
.. code-block:: sh
25+
26+
mongocli iam organization|organizations|org|orgs apiKey|apiKeys|apikeys whitelist|whitelists delete|rm <whitelist-entry>
27+
[ --apiKey <api-key-id> ]
28+
[ --force ]
29+
[ --orgId <organization-id> ]
30+
[ --output|-o <output-format> ]
31+
[ --profile|-P <profile-name> ]
32+
33+
.. include:: /includes/fact-command-line-help.rst
34+
35+
.. _mcli-iam-organization-apikey-whitelist-delete-arguments:
36+
37+
Arguments
38+
---------
39+
40+
.. list-table::
41+
:header-rows: 1
42+
:widths: 20 10 60 10
43+
44+
* - Argument
45+
- Type
46+
- Description
47+
- Required?
48+
49+
* - ``<whitelist-entry>``
50+
- string
51+
- The IP or |cidr| address. If the entry includes a subnet
52+
mask, such as ``192.0.2.0/24``, use the URL-encoded value
53+
``%2F`` for the forward slash ``/``.
54+
- yes
55+
56+
.. _mcli-iam-organization-apikey-whitelist-delete-options:
57+
58+
Options
59+
-------
60+
61+
.. list-table::
62+
:header-rows: 1
63+
:widths: 20 10 60 10
64+
65+
* - Option
66+
- Type
67+
- Description
68+
- Required?
69+
70+
* - ``--apikey``
71+
- string
72+
- Unique identifier of the |api| key.
73+
- yes
74+
75+
* - ``--force``
76+
-
77+
- Flag that indicates that the |api| key can
78+
be deleted without requiring confirmation.
79+
- no
80+
81+
* - ``--orgId``
82+
- string
83+
- Unique identifier of the organization to which the target |api|
84+
key belongs.
85+
86+
If specified, this value overrides any organization ID
87+
stored in your :ref:`profile <mcli-profiles>` or
88+
:ref:`environment variable <mcli-env-var>`.
89+
90+
If omitted, your profile must contain the
91+
organization ID.
92+
- no
93+
94+
* - ``--output``, ``-o``
95+
- string
96+
- .. include:: /includes/extracts/fact-basic-options-output.rst
97+
- no
98+
99+
* - ``--profile``, ``-P``
100+
- string
101+
- Name of the profile where your credentials are saved.
102+
103+
You must have credentials with the ``Organization Owner`` role to
104+
list an |api| key for the organization.
105+
106+
If omitted, uses the {+default-profile+}. To learn more about
107+
creating a profile, see :ref:`mcli-configure`.
108+
- no
109+
110+
.. _mcli-iam-organization-apikey-whitelist-delete-output:
111+
112+
Output
113+
------
114+
115+
If the command succeeds, it prints the following output to the terminal.
116+
If the command returns errors, see :ref:`Troubleshooting
117+
<troubleshooting>` for recommended solutions.
118+
119+
.. code-block:: sh
120+
:copyable: false
121+
122+
Whitelist entry '<whitelist-entry>' deleted
123+
124+
.. include:: /includes/fact-default-output.rst
125+
126+
- :atlas:`Atlas </reference/api/apiKeys-org-whitelist-delete-one/#response>`
127+
- :cloudmgr:`Cloud Manager </reference/api/api-keys/org/get-all-org-api-key-whitelist/#response>`
128+
- :opsmgr:`Ops Manager </reference/api/api-keys/org/get-all-org-api-key-whitelist/#response>`
129+
130+
.. _mcli-iam-organization-apikey-whitelist-delete-examples:
131+
132+
Examples
133+
--------
134+
135+
.. tabs::
136+
137+
.. tab:: Default Output
138+
:tabid: default-output
139+
140+
The following command lists the whitelist entries for an |api| key
141+
using the {+default-profile+}, which contains credentials, the
142+
organization ID, and specifies the |service| service. The output
143+
is returned in the default format.
144+
145+
.. code-block:: sh
146+
147+
mongocli iam org apikey whitelist rm 192.0.2.0 --apiKey 5f4ed27ec90220199065b4bb
148+
149+
The previous command prints the following output to the terminal.
150+
151+
.. code-block:: json
152+
:copyable: false
153+
154+
? Are you sure you want to delete: 192.0.2.0 Yes
155+
Whitelist entry '192.0.2.0' deleted
156+
157+
.. tab:: JSON Output
158+
:tabid: json-output
159+
160+
The following command deletes a whitelist entry for an |api| key
161+
without confirmation. The command uses the ``myOM`` profile, which contains credentials and specifies the |onprem| service. The output is returned in |json| format.
162+
163+
.. code-block:: sh
164+
165+
mongocli iam org apikey whitelist rm 192.0.2.0 --apiKey 5f4ed27ec90220199065b4bb --orgId 5a1b39eec902201990f12345 -P myOM --output json
166+
167+
The previous command prints the following output to the terminal
168+
in |json| format.
169+
170+
.. code-block:: json
171+
:copyable: false
172+
173+
Whitelist entry '192.0.2.0' deleted

0 commit comments

Comments
 (0)