|
| 1 | +.. _mcli-iam-project-apikey-assign: |
| 2 | + |
| 3 | +================================== |
| 4 | +mongocli iam project apikey assign |
| 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 project apikey assign`` command assigns an organization |api| |
| 16 | +key to a project and updates the |api| key roles. |
| 17 | + |
| 18 | +You must have ``GROUP_USER_ADMIN`` privileges to assign an |
| 19 | +|api| key to a project. |
| 20 | + |
| 21 | +.. _mcli-iam-project-apikey-assign-syntax: |
| 22 | + |
| 23 | +Syntax |
| 24 | +------ |
| 25 | + |
| 26 | +.. code-block:: text |
| 27 | + |
| 28 | + mongocli iam project|projects apiKey|apiKeys|apikeys assign|update <api-key-id> |
| 29 | + [ --projectId <project-id> ] |
| 30 | + [ --output|-o <output-format> ] |
| 31 | + [ --profile|-P <profile-name> ] |
| 32 | + [ --role <list-of-roles> ] |
| 33 | + |
| 34 | +.. include:: /includes/fact-command-line-help.rst |
| 35 | + |
| 36 | +.. _mcli-iam-project-apikey-assign-arguments: |
| 37 | + |
| 38 | +Arguments |
| 39 | +--------- |
| 40 | + |
| 41 | +.. list-table:: |
| 42 | + :header-rows: 1 |
| 43 | + :widths: 20 10 60 10 |
| 44 | + |
| 45 | + * - Argument |
| 46 | + - Type |
| 47 | + - Description |
| 48 | + - Required? |
| 49 | + |
| 50 | + * - ``<api-key-id>`` |
| 51 | + - string |
| 52 | + - Unique identifier for this API key. |
| 53 | + - yes |
| 54 | + |
| 55 | +.. _mcli-iam-project-apikey-assign-options: |
| 56 | + |
| 57 | +Options |
| 58 | +------- |
| 59 | + |
| 60 | +.. list-table:: |
| 61 | + :header-rows: 1 |
| 62 | + :widths: 20 10 60 10 |
| 63 | + |
| 64 | + * - Option |
| 65 | + - Type |
| 66 | + - Description |
| 67 | + - Required? |
| 68 | + |
| 69 | + * - ``--projectId`` |
| 70 | + - string |
| 71 | + - Unique identifier of the project of the |api| key you want |
| 72 | + to update. |
| 73 | + |
| 74 | + If specified, this value overrides any project ID |
| 75 | + stored in your :ref:`profile <mcli-profiles>` or |
| 76 | + :ref:`environment variable <mcli-env-var>`. |
| 77 | + |
| 78 | + If omitted, your profile must contain the |
| 79 | + project ID. |
| 80 | + - no |
| 81 | + |
| 82 | + * - ``--output``, ``-o`` |
| 83 | + - string |
| 84 | + - .. include:: /includes/extracts/fact-basic-options-output.rst |
| 85 | + - no |
| 86 | + |
| 87 | + * - ``--profile``, ``-P`` |
| 88 | + - string |
| 89 | + - Name of the profile where your credentials are saved. |
| 90 | + |
| 91 | + If omitted, uses the {+default-profile+}. To learn more about |
| 92 | + creating a profile, see :ref:`mcli-configure`. |
| 93 | + - no |
| 94 | + |
| 95 | + * - ``--role`` |
| 96 | + - string |
| 97 | + - Role or roles to assign to the |api| key. To assign more than |
| 98 | + one role, you can specify each role with a ``--role`` flag or |
| 99 | + specify the roles in a comma-separated list with one ``--role`` |
| 100 | + flag. |
| 101 | + - no |
| 102 | + |
| 103 | +.. _mcli-iam-project-apikey-assign-output: |
| 104 | + |
| 105 | +Output |
| 106 | +------ |
| 107 | + |
| 108 | +If the command succeeds, it returns the following output in the default |
| 109 | +format. If the command returns errors, see :ref:`Troubleshooting |
| 110 | +<troubleshooting>` for recommended solutions. |
| 111 | + |
| 112 | +.. code-block:: sh |
| 113 | + :copyable: false |
| 114 | + |
| 115 | + API Key successfully assigned. |
| 116 | + |
| 117 | +.. include:: /includes/fact-default-output.rst |
| 118 | + |
| 119 | +- :atlas:`Atlas API </reference/api/projectApiKeys/assign-one-org-apiKey-to-one-project/#response>` |
| 120 | +- :cloudmgr:`Cloud Manager API </reference/api/api-keys/project/assign-one-org-apiKey-to-one-project/#response>` |
| 121 | +- :opsmgr:`Ops Manager API </reference/api/api-keys/project/assign-one-org-apiKey-to-one-project/#response>` |
| 122 | + |
| 123 | +.. _mcli-iam-project-apikey-assign-examples: |
| 124 | + |
| 125 | +Examples |
| 126 | +-------- |
| 127 | + |
| 128 | +.. tabs:: |
| 129 | + |
| 130 | + .. tab:: Default Output |
| 131 | + :tabid: default-output |
| 132 | + |
| 133 | + The following command assigns an organization |api| key to a |
| 134 | + project and updates its role using the |
| 135 | + {+default-profile+}, which contains credentials and the project |
| 136 | + ID of the project to assign the |api| key to. The output is |
| 137 | + returned in the default format. |
| 138 | + |
| 139 | + .. code-block:: sh |
| 140 | + |
| 141 | + mongocli iam project apikey assign 5f46ae53d58b421fe3edc115 --role GROUP_OWNER |
| 142 | + |
| 143 | + The previous command prints the following to the terminal. |
| 144 | + |
| 145 | + .. code-block:: json |
| 146 | + :copyable: false |
| 147 | + |
| 148 | + API Key successfully assigned. |
| 149 | + |
| 150 | + .. tab:: JSON Output |
| 151 | + :tabid: json-output |
| 152 | + |
| 153 | + The following command assigns an organization |api| key to a |
| 154 | + project and updates its role using the ``myOM`` profile, which |
| 155 | + contains credentials and specifies the the |onprem| service. The |
| 156 | + output is returned in |json| format. |
| 157 | + |
| 158 | + .. code-block:: sh |
| 159 | + |
| 160 | + mongocli iam project apikey assign 5f46ae53d58b421fe3edc115 --role GROUP_DATA_ACCESS_READ_WRITE --output json |
| 161 | + |
| 162 | + The previous command updates the |api| key does not return a |
| 163 | + |json| response. |
0 commit comments