在一个全局集群中创建一个托管命名空间
创建指定的 Atlas 全球集群中的一个托管命名空间。托管命名空间使用数据库名称、点分隔符和集合名称来标识集合。要使用此资源,请求的服务帐户或 API 密钥必须具有“项目数据访问管理员”角色。已弃用的版本:v2-{2023-02-01}、v2-{2023-01-01}
路径参数
- 
    
  用于标识项目的唯一 24-十六进制数字字符串。 使用 /groups 端点检索身份验证的用户有权访问权限的所有项目。 注意:群组和项目是同义词。您的群组 ID 与项目 ID 相同。对于现有群组,群组/项目 ID 保持不变。资源和相应的端点使用“群组”一词。 格式应符合以下模式: ^([a-f0-9]{24})$。
- 
    
  用于标识此集群的人类可读标签。 格式应符合以下模式: ^[a-zA-Z0-9][a-zA-Z0-9-]*$。
查询参数
- 
    
  指示应用程序是否将响应包装在 envelopeJSON 对象中的标志。某些 API 客户端无法访问 HTTP 响应标头或状态代码。要修复此问题,请在查询中设置 Envelope=true。返回结果列表的端点将结果对象用作 envelope。应用程序将状态参数添加到响应正文中。默认值为 false。
- 
    
  指示响应正文是否应采用 prettyprint 格式的标记。 默认值为 false。Prettyprint 
      
  
    
  
        body
      
    必需
 
    
    在指定全局集群中创建的托管命名空间。
- 
    
  用于管理此全局集群中的集合的人工可读标签。 
- 
    
  用于将集合划分为分片的数据库参数。全局集群需要复合分片键。此复合分片键将位置参数和用户选择的自定义键组合在一起。 
- 
    
  用于管理此全局集群的数据库的人工可读标签。 
- 
    
  指示是否有人对指定collection的自定义分片键进行哈希处理的标志。如果将此值设置为 false,MongoDB Cloud 将使用范围分片。默认值为 false。哈希分片键 
- 
    
  
  默认值为 false。
- 
    
  
  最大值为 8192。全球集群分片 
- 
    
  该标志指示 MongoDB Cloud 是否应为空或不存在的集合创建和分配初始数据段。MongoDB Cloud 根据集合的定义区域和区域范围来分发数据。 默认值为 false。哈希片键 
atlas api globalClusters createManagedNamespace --helpimport (
	"os"
	"context"
	"log"
	sdk "go.mongodb.org/atlas-sdk/v20250312001/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.CreateGroupClusterGlobalWriteManagedNamespaceApiParams{}
	sdkResp, httpResp, err := client.GlobalClustersApi.
		CreateGroupClusterGlobalWriteManagedNamespaceWithParams(ctx, params).
		Execute()
}
curl --include --header "Authorization: Bearer ${ACCESS_TOKEN}" \
  --header "Accept: application/vnd.atlas.2025-03-12+json" \
  --header "Content-Type: application/json" \
  -X POST "https://cloud.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/globalWrites/managedNamespaces" \
  -d '{ <Payload> }'curl --user "${PUBLIC_KEY}:${PRIVATE_KEY}" \
  --digest --include \
  --header "Accept: application/vnd.atlas.2025-03-12+json" \
  --header "Content-Type: application/json" \
  -X POST "https://cloud.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/globalWrites/managedNamespaces" \
  -d '{ <Payload> }'{
  "collection": "string",
  "customShardKey": "string",
  "db": "string",
  "isCustomShardKeyHashed": false,
  "isShardKeyUnique": false,
  "numInitialChunks": 42,
  "presplitHashedZones": false
}{
  "customZoneMapping": {
    "additionalProperty1": "32b6e34b3d91647abb20e7b8",
    "additionalProperty2": "32b6e34b3d91647abb20e7b8"
  },
  "managedNamespaces": [
    {
      "collection": "string",
      "customShardKey": "string",
      "db": "string",
      "isCustomShardKeyHashed": false,
      "isShardKeyUnique": false,
      "numInitialChunks": 42,
      "presplitHashedZones": false
    }
  ],
  "selfManagedSharding": true
}{
  "error": 400,
  "detail": "(This is just an example, the exception may not be related to this endpoint) No provider AWS exists.",
  "reason": "Bad Request",
  "errorCode": "VALIDATION_ERROR"
}{
  "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": 405,
  "detail": "(This is just an example, the exception may not be related to this endpoint)",
  "reason": "Method Not Allowed",
  "errorCode": "ATLAS_BACKUP_CANCEL_SHARD_RESTORE_JOB_NOT_ALLOWED"
}{
  "error": 500,
  "detail": "(This is just an example, the exception may not be related to this endpoint)",
  "reason": "Internal Server Error",
  "errorCode": "UNEXPECTED_ERROR"
}