对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
See how MongoDB 9.0 delivers up to 2x higher throughput.
MongoDB Branding Shape
Register now >
Docs 菜单

mongocli iam 项目 apiKeys 分配

将指定的组织 API 密钥分配给您的项目,并修改该 API 密钥在项目中的角色。

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

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

命令语法
mongocli iam projects apiKeys assign <ID> [options]
名称
类型
必需
说明

id

字符串

true

标识 API 密钥的唯一的 24 位字符串。

名称
类型
必需
说明

-h,--help

false

分配帮助

-o, --output

字符串

false

输出格式。 有效值为 json、json-path、go-template 或 go-template-file。 要查看完整输出,请使用 -o json 选项。

--projectId

字符串

false

标识要使用的项目的十六进制字符串。 此选项会覆盖配置文件或环境变量中的设置。

--role

字符串

true

要分配给 API 密钥的一个或多个角色。 要分配多个角色,请为每个角色指定单独的角色标志,或使用一个角色标志将所有角色指定为以逗号分隔的列表。 要了解 CLI 接受哪些值,请参阅 Atlas API 规范中角色的枚举项:https: //www.mongodb.com/zh-cn/docs/atlas/reference/api-resources-spec/v 2 /#tag/ Programmatic-API-Keys/operation/createProjectApiKey/。

名称
类型
必需
说明

-P, --profile

字符串

false

要从您的配置文件中使用的配置文件的名称。要学习;了解MongoCLI 的配置文件,请参阅 https://dochub.mongodb.org/core/atlas-cli-configuration-file.

# Assign an organization API key with the ID 5f46ae53d58b421fe3edc115 and grant the GROUP_DATA_ACCESS_READ_WRITE role for the project with ID 5e2211c17a3e5a48f5497de3:
mongocli iam projects apiKeys assign 5f46ae53d58b421fe3edc115 --projectId 5e1234c17a3e5a48f5497de3 --role GROUP_DATA_ACCESS_READ_WRITE --output json
给本页内容打分