返回一个项目 IP 访问列表条目
从指定项目的 IP 访问列表中返回一个访问列表条目。项目 IP 访问列表中的每个条目都包含一个 IP 地址或一个 CIDR 注释的 IP 地址区块。MongoDB Cloud 仅允许客户端从列入项目 IP 访问列表中的 IP 地址连接到集群。要使用此资源,请求的服务账户或 API 密钥必须具有“项目只读”或“项目图表管理员”角色。此资源将替换白名单资源。MongoDB Cloud 于 2021 年 7 月删除了白名单。更新您的应用程序以使用此新资源。此端点 (/groups/{GROUP-ID}/accessList
) 管理项目 IP 访问列表。不管理 MongoDB Cloud 组织的访问列表。编程 API 密钥端点 (/orgs/{ORG-ID}/apiKeys/{API-KEY-ID}/accesslist
) 管理这些访问列表。
路径参数
-
用于标识项目的唯一 24-十六进制数字字符串。 使用 /groups 端点检索身份验证的用户有权访问权限的所有项目。
注意:群组和项目是同义词。您的群组 ID 与项目 ID 相同。对于现有群组,群组/项目 ID 保持不变。资源和相应的端点使用“群组”一词。
格式应符合以下模式:
^([a-f0-9]{24})$
。 -
您要从项目的 IP 访问列表中返回的访问列表条目。该值可以使用以下值之一:一个 AWS 安全组 ID、一个 IP 地址或一个 CIDR 地址区块。对于使用子网掩码的 CIDR 区块,将正斜杠 (
/
) 替换为其 URL 编码值 (%2F
)。格式应符合以下模式:
^([0-9]{1,3}\.){3}[0-9]{1,3}(%2[fF][0-9]{1,3})?|([0-9a-f]{1,4}\:){7}[0-9a-f]{1,4}(%2[fF][0-9]{1,3})?|([0-9a-f]{1,4}\:){1,6}\:(%2[fF][0-9]{1,3})|(sg\-[a-f0-9]{8})?$
。
查询参数
-
指示应用程序是否将响应包装在
envelope
JSON 对象中的标志。某些 API 客户端无法访问 HTTP 响应标头或状态代码。要修复此问题,请在查询中设置 Envelope=true。返回结果列表的端点将结果对象用作 envelope。应用程序将状态参数添加到响应正文中。默认值为
false
。 -
指示响应正文是否应采用 prettyprint 格式的标记。
默认值为
false
。Prettyprint
atlas api projectIpAccessList getGroupAccessListEntry --help
import (
"os"
"context"
"log"
sdk "go.mongodb.org/atlas-sdk/v20230201001/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.GetGroupAccessListEntryApiParams{}
sdkResp, httpResp, err := client.ProjectIPAccessListApi.
GetGroupAccessListEntryWithParams(ctx, params).
Execute()
}
curl --include --header "Authorization: Bearer ${ACCESS_TOKEN}" \
--header "Accept: application/vnd.atlas.2023-02-01+json" \
-X GET "https://cloud.mongodb.com/api/atlas/v2/groups/{groupId}/accessList/{entryValue}?pretty=true"
curl --user "${PUBLIC_KEY}:${PRIVATE_KEY}" \
--digest --include \
--header "Accept: application/vnd.atlas.2023-02-01+json" \
-X GET "https://cloud.mongodb.com/api/atlas/v2/groups/{groupId}/accessList/{entryValue}?pretty=true"
{
"awsSecurityGroup": "string",
"cidrBlock": "string",
"comment": "string",
"deleteAfterDate": "2025-05-04T09:42:00Z",
"groupId": "32b6e34b3d91647abb20e7b8",
"ipAddress": "string",
"links": [
{
"href": "https://cloud.mongodb.com/api/atlas",
"rel": "self"
}
]
}
{
"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"
}