文档菜单
文档首页
/ /
MongoDB CLI
/ / / /

mongocli iam organizations apiKeys assign

本页内容

  • 语法
  • 参数
  • 选项
  • 继承选项
  • 输出
  • 示例

修改指定组织API密钥的角色或描述。

使用此命令修改组织API密钥的角色时,您指定的值将覆盖API密钥现有的角色分配。

要查看apiKeyId参数的可能值,请运行mongocli iam organizations apiKeys list。

要使用此命令,您必须使用具有组织用户管理员角色的用户帐户或API密钥进行认证。

命令语法
mongocli iam organizations apiKeys assign <apiKeyId> [options]
名称
类型
必需
描述
apiKeyId
字符串
一个唯一的24位数字字符串,用于标识您的API密钥。
名称
类型
必需
描述
--desc
字符串
API密钥的描述。
-h, --help
assign的帮助信息
--orgId
字符串
要使用的组织ID。此选项会覆盖配置文件或环境变量中的设置。
-o, --output
字符串
输出格式。有效值有json、json-path、go-template或go-template-file。要查看完整输出,请使用-o json选项。
--role
字符串
您想要分配给API密钥的角色或角色列表。要分配多个角色,请使用单独的角色标志指定每个角色,或者使用一个角色标志指定所有角色,以逗号分隔。要了解CLI接受的哪些值,请参阅Atlas API规范中关于角色的项目枚举https://mongodb.ac.cn/docs/atlas/reference/api-resources-spec/v2/#tag/Programmatic-API-Keys/operation/createApiKey/. 通过设置此标志替换现有数据。
名称
类型
必需
描述
-P, --profile
字符串

如果命令执行成功,CLI将返回类似以下示例的输出。括号中的值代表您的值。

API Key '<ID>' successfully updated.
# Modify the role and description for the API key with the ID 5f24084d8dbffa3ad3f21234 for the organization with the ID 5a1b39eec902201990f12345:
mongocli iam organizations apiKeys assign 5f24084d8dbffa3ad3f21234 --role ORG_MEMBER --desc "User1 Member Key" --orgId 5a1b39eec902201990f12345 --output json

返回

列表