|
| 1 | +.. _mcli-iam-global-apikey-create: |
| 2 | + |
| 3 | +================================ |
| 4 | +mongocli iam globalApiKey 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 globalApiKey create`` command creates a new Global |
| 16 | +|api| Key for the specified |mms| instance. You must have the |
| 17 | +:opsmgr:`Global Owner </reference/user-roles/#Global-Owner>` role |
| 18 | +to create a Global |api| key. You can also create the key through |
| 19 | +the |mms| :opsmgr:`UI |
| 20 | +</admin/general/api-keys-page/#add-a-global-api-key>` and |
| 21 | +:opsmgr:`API </reference/api/api-keys/global/create-one-global-api-key/>`. |
| 22 | + |
| 23 | +.. _mcli-iam-global-apikey-create-syntax: |
| 24 | + |
| 25 | +Syntax |
| 26 | +------ |
| 27 | + |
| 28 | +.. code-block:: text |
| 29 | + |
| 30 | + mongocli iam globalApiKey|globalApiKeys create |
| 31 | + --desc "<description-of-key>" |
| 32 | + [ --output|-o <output-format> ] |
| 33 | + [ --profile|-P <profile-name> ] |
| 34 | + --role <list-of-roles> |
| 35 | + |
| 36 | +.. include:: /includes/fact-command-line-help.rst |
| 37 | + |
| 38 | +.. _mcli-iam-global-apikey-create-options: |
| 39 | + |
| 40 | +Options |
| 41 | +------- |
| 42 | + |
| 43 | +.. list-table:: |
| 44 | + :header-rows: 1 |
| 45 | + :widths: 20 10 60 10 |
| 46 | + |
| 47 | + * - Option |
| 48 | + - Type |
| 49 | + - Description |
| 50 | + - Required? |
| 51 | + |
| 52 | + * - ``--desc`` |
| 53 | + - string |
| 54 | + - Description of the |api| key. This description can’t be longer |
| 55 | + than 250 characters. |
| 56 | + - yes |
| 57 | + |
| 58 | + * - ``--output``, ``-o`` |
| 59 | + - string |
| 60 | + - .. include:: /includes/extracts/fact-basic-options-output.rst |
| 61 | + - no |
| 62 | + |
| 63 | + * - ``--profile``, ``-P`` |
| 64 | + - string |
| 65 | + - Name of the profile where your credentials are saved. If omitted, |
| 66 | + uses the {+default-profile+}. To learn more about |
| 67 | + creating a profile, see :ref:`mcli-configure`. |
| 68 | + |
| 69 | + You must have credentials with the :authrole:`Global Owner` role to |
| 70 | + create a Global |api| Key. |
| 71 | + - no |
| 72 | + |
| 73 | + * - ``--role`` |
| 74 | + - string |
| 75 | + - Role or roles to assign to the |api| key. To assign more than |
| 76 | + one role, you can specify each role with a ``--role`` flag or |
| 77 | + specify the roles in a comma-separated list with one ``--role`` |
| 78 | + flag. Global roles accepted by default include: |
| 79 | + |
| 80 | + .. include:: /includes/list-table-global-roles.rst |
| 81 | + |
| 82 | + - yes |
| 83 | + |
| 84 | +.. _mcli-iam-global-apikey-create-output: |
| 85 | + |
| 86 | +Output |
| 87 | +------ |
| 88 | + |
| 89 | +If the command succeeds, it prints the following output to the terminal. |
| 90 | +If the command returns errors, see :ref:`Troubleshooting |
| 91 | +<troubleshooting>` for recommended solutions. |
| 92 | + |
| 93 | +.. code-block:: sh |
| 94 | + :copyable: false |
| 95 | + |
| 96 | + API Key '<api-key-id>' created. |
| 97 | + Public API Key <public-key> |
| 98 | + Private API Key <private-key> |
| 99 | + |
| 100 | +.. warning:: Copy and Save Public and Private Keys |
| 101 | + |
| 102 | + {+mcli+} returns the Private |api| Key only once. After running this |
| 103 | + command, immediately copy, save, and secure both the Public and |
| 104 | + Private |api| Keys. |
| 105 | + |
| 106 | +For the complete list of |json| fields returned by the command, see the |
| 107 | +public API :opsmgr:`reference |
| 108 | +</reference/api/api-keys/global/create-one-global-api-key/#response>`. |
| 109 | +The default output contains only a subset of the fields returned by this |
| 110 | +command. |
| 111 | + |
| 112 | +.. _mcli-iam-global-apikey-create-examples: |
| 113 | + |
| 114 | +Examples |
| 115 | +-------- |
| 116 | + |
| 117 | +.. tabs:: |
| 118 | + |
| 119 | + .. tab:: Default Output |
| 120 | + :tabid: default-output |
| 121 | + |
| 122 | + The following command creates a Global |api| Key using a profile |
| 123 | + named ``om-admin``, which contains the ``Organization Owner`` |
| 124 | + credentials, the organization ID, and specifies the |onprem| |
| 125 | + service. The output is returned in the default format. |
| 126 | + |
| 127 | + .. code-block:: sh |
| 128 | + |
| 129 | + mongocli iam globalApiKey create --desc "My Global API key" --role "GLOBAL_READ_ONLY","GLOBAL_USER_ADMIN" --profile om-admin |
| 130 | + |
| 131 | + The previous command creates the |api| key and |
| 132 | + prints the following to the terminal. |
| 133 | + |
| 134 | + .. code-block:: json |
| 135 | + :copyable: false |
| 136 | + |
| 137 | + API Key '5f3d8790c12345678903c8d66' created. |
| 138 | + Public API Key abcdefgh |
| 139 | + Private API Key b4d12345-b4a3-1234-b24e-729b3f35642d |
| 140 | + |
| 141 | + .. tab:: JSON Output |
| 142 | + :tabid: json-output |
| 143 | + |
| 144 | + The following command creates a Global |api| Key using a profile |
| 145 | + named ``om-admin``, which contains the ``Organization Owner`` |
| 146 | + credentials, the organization ID, and specifies the |onprem| |
| 147 | + service. The output is returned in |json| format. |
| 148 | + |
| 149 | + .. code-block:: sh |
| 150 | + |
| 151 | + mongocli iam globalApiKey create --desc "My Global API key" --role "GLOBAL_READ_ONLY","GLOBAL_USER_ADMIN" --profile om-admin --output json |
| 152 | + |
| 153 | + The previous command creates the |api| key and |
| 154 | + prints the following to the terminal in |json| format. |
| 155 | + |
| 156 | + .. code-block:: json |
| 157 | + :copyable: false |
| 158 | + |
| 159 | + { |
| 160 | + "id": "5f3d8ea3c9022019903c9fce", |
| 161 | + "desc": "My Global API key", |
| 162 | + "roles": [ |
| 163 | + { |
| 164 | + "roleName": "GLOBAL_READ_ONLY" |
| 165 | + }, |
| 166 | + { |
| 167 | + "roleName": "GLOBAL_USER_ADMIN" |
| 168 | + } |
| 169 | + ], |
| 170 | + "privateKey": "b4d12345-b4a3-1234-b24e-729b3f35642d", |
| 171 | + "publicKey": "abcdefgh" |
| 172 | + } |
0 commit comments