

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 使用 Amazon SageMaker API 进行私人劳动力管理
<a name="sms-workforce-management-private-api"></a>

您可以使用 Amazon SageMaker API 操作来管理、更新和删除您的私人员工。对于以下主题中列出的每个 API 操作，您可以在 API 文档的 “**另请参阅**” 部分中找到支持的特定语言 SDKs 及其文档的列表。

**Topics**
+ [查找人力名称](sms-workforce-management-private-api-name.md)
+ [将工作人员访问任务的权限限制在允许的 IP 地址范围内](sms-workforce-management-private-api-cidr.md)
+ [启用双堆栈人力](sms-workforce-management-private-api-dualstack.md)
+ [更新 OIDC 身份提供者人力配置](sms-workforce-management-private-api-update.md)
+ [删除私有人力](sms-workforce-management-private-api-delete.md)

# 查找人力名称
<a name="sms-workforce-management-private-api-name"></a>

某些与 SageMaker AI 劳动力相关的 API 操作需要您的员工姓名作为输入。您可以使用 API 操作在 AWS 某个地区查看您的 Amazon Cognito 或 OIDC IdP 个人和供应商员工姓名。[]() AWS 如果您使用自己的 OIDC IdP 创建了员工，则可以在人工智能控制台的 Ground Truth 区域找到您的员工姓名。 SageMaker 

**在 SageMaker AI 控制台中查找您的员工姓名**

1. 前往 SageMaker AI 控制台的 Ground Truth 区域：g [https://console.aws.amazon.com/sagemaker/roundtrut](https://console.aws.amazon.com/sagemaker/groundtruth) h。

1. 选择**标注人力**。

1. 选择**私有**。

1. 在**私有人力摘要**部分中，找到您的人力 ARN。人力名称位于此 ARN 的末尾。例如，如果 ARN 是 `arn:aws:sagemaker:us-east-2:111122223333:workforce/example-workforce`，则人力名称是 `example-workforce`。

# 将工作人员访问任务的权限限制在允许的 IP 地址范围内
<a name="sms-workforce-management-private-api-cidr"></a>

默认情况下，人力不受限于特定的 IP 地址。您可以使用该[https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_UpdateWorkforce.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_UpdateWorkforce.html)操作要求工作人员使用特定的 IP 地址范围 ([CIDRs](https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Subnets.html)) 来访问任务。如果您指定一个或多个 CIDRs，则尝试使用指定范围之外的任何 IP 地址访问任务的工作人员将被拒绝，并将在工作人员门户上收到 HTTP 204 No Content 错误消息。您最多可以使用 `UpdateWorkforce` 指定 10 个 CIDR 值。

将员工限制为一名或多名员工后 CIDRs，`UpdateWorkforce`列表的输出全部允许 CIDRs。您还可以使用该[https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DescribeWorkforce.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DescribeWorkforce.html)操作来查看员工的所有允许 CIDRs 范围。

# 启用双堆栈人力
<a name="sms-workforce-management-private-api-dualstack"></a>

您可以使用[CreateWorkforce](https://docs.aws.amazon.com//sagemaker/latest/APIReference/API_CreateWorkforce.html)和 [UpdateWorkforce](https://docs.aws.amazon.com//sagemaker/latest/APIReference/API_UpdateWorkforce.html)API 操作启用双栈员工。中不支持创建双栈员工、将现有员工队伍更新为双栈员工，以及将员工队伍从双栈改回 IPv4 双栈员工。 AWS 管理控制台

**重要**  
没有定义的 `IpAddressType` 的人力默认为 `IPv4`。

## 创建双堆栈人力
<a name="sms-workforce-management-private-dualstack-create"></a>

创建双层员工队伍的过程与创建 IPv4仅限员工队伍的过程类似，但有以下例外情况。有关更多信息，请参阅 [CreateWorkforce](https://docs.aws.amazon.com//sagemaker/latest/APIReference/API_CreateWorkforce.html)。
+ 要将 VPC 连接到私有员工，请确保 VPC 也是双堆栈的， IPv6 CIDR 块与 VPC 的子网关联。
+ 要使用`SourceIpConfig`参数将流量限制到特定 IP 地址范围，请确保 IPv6 CIDR 块也包含在列表中。
+ 要在任务访问的 S3 存储桶上实施带有 `SourceIp` 条件的策略，请确保将这些策略更新为双堆栈兼容。
+ 身份提供者身份验证端点支持双堆栈。有关更多信息，请参阅 [Authentication flow](https://docs.aws.amazon.com//elasticloadbalancing/latest/application/listener-authenticate-users.html#authentication-flow)。

**使用 boto3 的 `CreateWorkforce` SDK 调用示例**

有关更多信息，请参阅 [create\$1workforce](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/sagemaker/client/create_workforce.html#SageMaker.Client.create_workforce)。

```
import boto3

client = boto3.resource('sagemaker')

# IpAddressType = 'dualstack'|'ipv4'
client.create_workforce(
    WorkforceName='string',
    IpAddressType='dualstack',
    WorkforceConfig={
        'CognitoConfig': {
            'UserPool': 'string',
            'Client': 'string'
        }
    }
)
```

## 更新双堆栈人力
<a name="sms-workforce-management-private-dualstack-update"></a>

将现有人力更新为双堆栈时，请注意以下各项。有关更多信息，请参阅[UpdateWorkforce](https://docs.aws.amazon.com//sagemaker/latest/APIReference/API_UpdateWorkforce.html)和[对您的 VPC 的IPv6 支持](https://docs.aws.amazon.com//vpc/latest/userguide/vpc-migrate-ipv6.html)。
+ 如果 VPC 已附加到人力，则必须将 VPC 更新为双堆栈。还要确保 VPC 的所有安全组都允许 IPv6流量。
+ 如果您使用的是`SourceIpConfig`参数，请将其更新为包含 IPv6 CIDR 块。
+ 要在任务访问的 S3 存储桶上实施带有 `SourceIp` 条件的策略，请确保将这些策略更新为双堆栈兼容。
+ 身份提供者身份验证端点支持双堆栈。有关更多信息，请参阅 [Authentication flow](https://docs.aws.amazon.com//elasticloadbalancing/latest/application/listener-authenticate-users.html#authentication-flow)。

**使用 boto3 的 `UpdateWorkforce` SDK 调用示例**

有关更多信息，请参阅 [update\$1workforce](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/sagemaker/client/update_workforce.html#SageMaker.Client.update_workforce)。

```
import boto3

client = boto3.resource('sagemaker')

# IpAddressType = 'dualstack'|'ipv4'
client.update_workforce(
    WorkforceName='string',
    IpAddressType='dualstack'
)
```

# 更新 OIDC 身份提供者人力配置
<a name="sms-workforce-management-private-api-update"></a>

您可能需要更新使用自己的 OIDC IdP 创建的人力，以指定不同的授权端点、令牌端点或发行者。您可以使用 [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_UpdateWorkforce.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_UpdateWorkforce.html) 操作更新在 `[OidcConfig](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_OidcConfig.html)` 中找到的任何参数。

**重要**  
只有在没有与人力相关联的工作团队时，才能更新 OIDC IdP 配置。您可以使用 `[DeleteWorkteam](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DeleteWorkteam.html)` 操作删除私有工作团队。

# 删除私有人力
<a name="sms-workforce-management-private-api-delete"></a>

每个 AWS 地区只能有一名私人员工。在以下情况下，您可能需要删除某个 AWS 地区的私人员工：
+ 您想使用新的 Amazon Cognito 用户池创建人力。
+ 您已经使用 Amazon Cognito 创建了一个私有人力，并且您想使用自己的 OpenID Connect (OIDC) 身份提供者 (IdP) 创建一个人力。

要删除私有人力，请使用 [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DeleteWorkforce.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DeleteWorkforce.html) API 操作。如果有任何工作团队与人力相关联，则必须在删除人力之前删除这些工作团队。您可以使用 `[DeleteWorkteam](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DeleteWorkteam.html)` 操作删除私有工作团队。