updateWorkforce method

Future<UpdateWorkforceResponse> updateWorkforce({
  1. required String workforceName,
  2. WorkforceIpAddressType? ipAddressType,
  3. OidcConfig? oidcConfig,
  4. SourceIpConfig? sourceIpConfig,
  5. WorkforceVpcConfigRequest? workforceVpcConfig,
})

Use this operation to update your workforce. You can use this operation to require that workers use specific IP addresses to work on tasks and to update your OpenID Connect (OIDC) Identity Provider (IdP) workforce configuration.

The worker portal is now supported in VPC and public internet.

Use SourceIpConfig to restrict worker access to tasks to a specific range of IP addresses. You specify allowed IP addresses by creating a list of up to ten CIDRs. By default, a workforce isn't restricted to specific IP addresses. If you specify a range of IP addresses, workers who attempt to access tasks using any IP address outside the specified range are denied and get a Not Found error message on the worker portal.

To restrict public internet access for all workers, configure the SourceIpConfig CIDR value. For example, when using SourceIpConfig with an IpAddressType of IPv4, you can restrict access to the IPv4 CIDR block "10.0.0.0/16". When using an IpAddressType of dualstack, you can specify both the IPv4 and IPv6 CIDR blocks, such as "10.0.0.0/16" for IPv4 only, "2001:db8:1234:1a00::/56" for IPv6 only, or "10.0.0.0/16" and "2001:db8:1234:1a00::/56" for dual stack. Use OidcConfig to update the configuration of a workforce created using your own OIDC IdP. After restricting access to a range of IP addresses or updating your OIDC IdP configuration with this operation, you can view details about your update workforce using the DescribeWorkforce operation.

May throw ConflictException.

Parameter workforceName : The name of the private workforce that you want to update. You can find your workforce name by using the ListWorkforces operation.

Parameter ipAddressType : Use this parameter to specify whether you want IPv4 only or dualstack (IPv4 and IPv6) to support your labeling workforce.

Parameter oidcConfig : Use this parameter to update your OIDC Identity Provider (IdP) configuration for a workforce made using your own IdP.

Parameter sourceIpConfig : A list of one to ten worker IP address ranges (CIDRs) that can be used to access tasks assigned to this workforce.

Maximum: Ten CIDR values

Parameter workforceVpcConfig : Use this parameter to update your VPC configuration for a workforce.

Implementation

Future<UpdateWorkforceResponse> updateWorkforce({
  required String workforceName,
  WorkforceIpAddressType? ipAddressType,
  OidcConfig? oidcConfig,
  SourceIpConfig? sourceIpConfig,
  WorkforceVpcConfigRequest? workforceVpcConfig,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'SageMaker.UpdateWorkforce'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'WorkforceName': workforceName,
      if (ipAddressType != null) 'IpAddressType': ipAddressType.value,
      if (oidcConfig != null) 'OidcConfig': oidcConfig,
      if (sourceIpConfig != null) 'SourceIpConfig': sourceIpConfig,
      if (workforceVpcConfig != null)
        'WorkforceVpcConfig': workforceVpcConfig,
    },
  );

  return UpdateWorkforceResponse.fromJson(jsonResponse.body);
}