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

mongocli iam organizations apiKeys create

本页内容

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

为您的组织创建一个API密钥。

MongoDB仅返回一次私有API密钥。运行此命令后,请立即复制、保存并安全存储公钥和私钥。

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

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

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

API Key '<ID>' created.
Public API Key <PublicKey>
Private API Key <PrivateKey>
# Create an organization API key with organization owner access in the organization with the ID 5a1b39eec902201990f12345:
mongocli iam organizations apiKeys create --role ORG_OWNER --desc "My API Key" --orgId 5a1b39eec902201990f12345 --output json

返回

分配