创建一个在线存档
创建一个在线归档。此归档将来自一个集群的数据存储在一个项目中。要使用此资源,请求的服务账户或 API 密钥必须具有项目数据访问管理员角色。
路径参数
-
用于标识项目的唯一 24-十六进制数字字符串。 使用 /groups 端点检索身份验证的用户有权访问权限的所有项目。
注意:群组和项目是同义词。您的群组 ID 与项目 ID 相同。对于现有群组,群组/项目 ID 保持不变。资源和相应的端点使用“群组”一词。
格式应符合以下模式:
^([a-f0-9]{24})$
。 -
用户可读标签,用于标识包含要创建一个在线存档的集合的集群。
格式应符合以下模式:
^[a-zA-Z0-9][a-zA-Z0-9-]*$
。
查询参数
-
指示应用程序是否将响应包装在
envelope
JSON 对象中的标志。某些 API 客户端无法访问 HTTP 响应标头或状态代码。要修复此问题,请在查询中设置 Envelope=true。返回结果列表的端点将结果对象用作 envelope。应用程序将状态参数添加到响应正文中。默认值为
false
。 -
指示响应正文是否应采用 prettyprint 格式的标记。
默认值为
false
。Prettyprint
body
必需
创建一个在线归档。
-
用户可读标签,用于标识您为其创建在线存档的集合。
-
要返回的 MongoDB 数据库集合的分类。
如果将该参数设置为
TIMESERIES
,则设置"criteria.type" : "date"
和"criteria.dateFormat" : "ISODATE"
。值为
TIMESERIES
或STANDARD
。默认值为STANDARD
。 -
用于指定何时从存档中删除数据的规则。
-
包含在线存档的集合的数据库的可读标签。
-
包含用于在集合中以逻辑方式划分数据的文档参数的列表。分区提供对基础集合数据的粗略过滤。若要划分数据,请指定经常查询的参数。如果您“指定 :criteria.type”:在 CREATE ONE ONLINE ARCHIVE 端点中输入“DATE”,然后您可以指定最多三个用于查询的参数。其中一个参数必须是 DATE 值,这是本例中是必需值。如果您“指定 :criteria.type”:在 CREATE ONE ONLINE ARCHIVE 端点中输入“CUSTOM”,然后您可以指定最多两个用于查询的参数。不使用“:criteria.type”的查询:“DATE”或“:criteria.type”:“CUSTOM”参数会使 MongoDB 扫描所有存档文档的完整集合。这需要更多时间,同时增加了您的成本。
用于对此在线存档分区的元数据。
至少
1
个元素。 -
标志,表示该在线存档是否处于暂停状态。如果该集合有另一个活动的在线存档,则恢复请求将失败。如需暂停活动在线存档或恢复已暂停的在线存档,必须包含此参数。如需暂停活动存档,请将此设置为 true。如需恢复暂停的存档,请将此设置为 false。
atlas api onlineArchive createGroupClusterOnlineArchive --help
import (
"os"
"context"
"log"
sdk "go.mongodb.org/atlas-sdk/v20241113001/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.CreateGroupClusterOnlineArchiveApiParams{}
sdkResp, httpResp, err := client.OnlineArchiveApi.
CreateGroupClusterOnlineArchiveWithParams(ctx, params).
Execute()
}
curl --include --header "Authorization: Bearer ${ACCESS_TOKEN}" \
--header "Accept: application/vnd.atlas.2024-11-13+json" \
--header "Content-Type: application/json" \
-X POST "https://cloud.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/onlineArchives" \
-d '{ <Payload> }'
curl --user "${PUBLIC_KEY}:${PRIVATE_KEY}" \
--digest --include \
--header "Accept: application/vnd.atlas.2024-11-13+json" \
--header "Content-Type: application/json" \
-X POST "https://cloud.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/onlineArchives" \
-d '{ <Payload> }'
{
"collName": "string",
"collectionType": "STANDARD",
"criteria": {
"type": "CUSTOM",
"query": "string"
},
"dataExpirationRule": {
"expireAfterDays": 42
},
"dataProcessRegion": {
"cloudProvider": "AWS",
"region": "US_EAST_1"
},
"dbName": "string",
"partitionFields": [
{
"fieldName": "string",
"order": 0
}
],
"paused": true,
"schedule": {
"type": "DEFAULT"
}
}
{
"_id": "32b6e34b3d91647abb20e7b8",
"clusterName": "string",
"collName": "string",
"collectionType": "STANDARD",
"criteria": {
"type": "CUSTOM",
"query": "string"
},
"dataExpirationRule": {
"expireAfterDays": 42
},
"dataProcessRegion": {
"cloudProvider": "AWS",
"region": "US_EAST_1"
},
"dataSetName": "string",
"dbName": "string",
"groupId": "32b6e34b3d91647abb20e7b8",
"partitionFields": [
{
"fieldName": "string",
"fieldType": "date",
"order": 0
}
],
"paused": true,
"schedule": {
"type": "DEFAULT"
},
"state": "PENDING"
}
{
"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": 409,
"detail": "(This is just an example, the exception may not be related to this endpoint) Cannot delete organization link while there is active migration in following project ids: 60c4fd418ebe251047c50554",
"reason": "Conflict",
"errorCode": "CANNOT_DELETE_ORG_ACTIVE_LIVE_MIGRATION_ATLAS_ORG_LINK"
}
{
"error": 500,
"detail": "(This is just an example, the exception may not be related to this endpoint)",
"reason": "Internal Server Error",
"errorCode": "UNEXPECTED_ERROR"
}