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 | 字符串 | 否 | 配置文件中要使用的配置文件名。有关MongoCLI配置文件中配置文件的信息,请参阅https://dochub.mongodb.org/core/atlas-cli-configuration-file. |
输出
如果命令执行成功,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