1개의 조직 API 키 만들기
지정된 조직에 대해 API 키 한 개를 생성합니다. 조직 API 키는 조직에 프로그래밍 방식의 액세스 권한을 부여합니다. API 키를 사용하여 콘솔에 로그인할 수 없습니다. 이 리소스를 사용하려면, 요청하는 서비스 계정 또는 API 키에 조직 소유자 역할이 있어야 합니다.
경로 매개변수
-
24프로젝트가 포함된 조직 식별하는 고유한 -16진수 문자열입니다. 인증된 사용자가 액세스 할 수 있는 모든 조직을 조회 하려면 /orgs 엔드포인트를 사용합니다.
형식은
^([a-f0-9]{24})$
패턴 과 일치해야 합니다.
쿼리 매개변수
-
애플리케이션이 응답을
envelope
JSON 객체로 래핑할지 여부를 나타내는 플래그입니다. 일부 API 클라이언트는 HTTP 응답 헤더 또는 상태 코드에 액세스할 수 없습니다. 이 문제를 해결하려면 쿼리에서 envelope=true를 설정합니다. 결과 목록을 반환하는 엔드포인트는 결과 객체를 엔벨로프로 사용합니다. 애플리케이션은 응답 본문에 상태 매개변수를 추가합니다.기본값은
false
입니다. -
응답 본문이 프리티프린트 형식이어야 하는지 여부를 나타내는 플래그입니다.
기본값은
false
입니다.Prettyprint
body
필수 사항
생성할 조직 API 키입니다.
-
누군가가 이 조직 API 키를 생성했을 때 제공한 목적 또는 설명입니다.
최소 길이는
1
, 최대 길이는250
입니다. -
이 API 키를 부여할 역할 목록입니다. 이 목록을 제공하는 경우 역할을 최소 한 개 제공하고 각 역할이 이 조직에 적용되는지 확인합니다.
요소가
1
개 이상이어야 합니다. 값은ORG_OWNER
,ORG_MEMBER
,ORG_GROUP_CREATOR
,ORG_BILLING_ADMIN
,ORG_BILLING_READ_ONLY
,ORG_STREAM_PROCESSING_ADMIN
또는ORG_READ_ONLY
입니다.
atlas api programmaticApiKeys createOrgApiKey --help
import (
"os"
"context"
"log"
sdk "go.mongodb.org/atlas-sdk/v20240530001/admin"
)
func main() {
ctx := context.Background()
clientID := os.Getenv("MONGODB_ATLAS_CLIENT_ID")
clientSecret := os.Getenv("MONGODB_ATLAS_CLIENT_SECRET")
// See https://dochub.mongodb.org/core/atlas-go-sdk-oauth
client, err := sdk.NewClient(sdk.UseOAuthAuth(clientID, clientSecret))
if err != nil {
log.Fatalf("Error: %v", err)
}
params = &sdk.CreateOrgApiKeyApiParams{}
sdkResp, httpResp, err := client.ProgrammaticAPIKeysApi.
CreateOrgApiKeyWithParams(ctx, params).
Execute()
}
curl --include --header "Authorization: Bearer ${ACCESS_TOKEN}" \
--header "Accept: application/vnd.atlas.2024-05-30+json" \
--header "Content-Type: application/json" \
-X POST "https://cloud.mongodb.com/api/atlas/v2/orgs/{orgId}/apiKeys" \
-d '{ <Payload> }'
curl --user "${PUBLIC_KEY}:${PRIVATE_KEY}" \
--digest --include \
--header "Accept: application/vnd.atlas.2024-05-30+json" \
--header "Content-Type: application/json" \
-X POST "https://cloud.mongodb.com/api/atlas/v2/orgs/{orgId}/apiKeys" \
-d '{ <Payload> }'
{
"desc": "string",
"roles": [
"ORG_OWNER"
]
}
{
"desc": "string",
"id": "32b6e34b3d91647abb20e7b8",
"links": [
{
"href": "https://cloud.mongodb.com/api/atlas",
"rel": "self"
}
],
"privateKey": "55c3bbb6-b4bb-0be1-e66d20841f3e",
"publicKey": "zmmrboas",
"roles": [
{
"groupId": "32b6e34b3d91647abb20e7b8",
"orgId": "32b6e34b3d91647abb20e7b8",
"roleName": "ORG_MEMBER"
}
]
}
{
"error": 401,
"detail": "(This is just an example, the exception may not be related to this endpoint)",
"reason": "Unauthorized",
"errorCode": "NOT_ORG_GROUP_CREATOR"
}
{
"error": 403,
"detail": "(This is just an example, the exception may not be related to this endpoint)",
"reason": "Forbidden",
"errorCode": "CANNOT_CHANGE_GROUP_NAME"
}
{
"error": 404,
"detail": "(This is just an example, the exception may not be related to this endpoint) Cannot find resource AWS",
"reason": "Not Found",
"errorCode": "RESOURCE_NOT_FOUND"
}
{
"error": 500,
"detail": "(This is just an example, the exception may not be related to this endpoint)",
"reason": "Internal Server Error",
"errorCode": "UNEXPECTED_ERROR"
}