createWorkforce method

Future<CreateWorkforceResponse> createWorkforce({
  1. required String workforceName,
  2. CognitoConfig? cognitoConfig,
  3. WorkforceIpAddressType? ipAddressType,
  4. OidcConfig? oidcConfig,
  5. SourceIpConfig? sourceIpConfig,
  6. List<Tag>? tags,
  7. WorkforceVpcConfigRequest? workforceVpcConfig,
})

Use this operation to create a workforce. This operation will return an error if a workforce already exists in the Amazon Web Services Region that you specify. You can only create one workforce in each Amazon Web Services Region per Amazon Web Services account.

If you want to create a new workforce in an Amazon Web Services Region where a workforce already exists, use the DeleteWorkforce API operation to delete the existing workforce and then use CreateWorkforce to create a new workforce.

To create a private workforce using Amazon Cognito, you must specify a Cognito user pool in CognitoConfig. You can also create an Amazon Cognito workforce using the Amazon SageMaker console. For more information, see Create a Private Workforce (Amazon Cognito).

To create a private workforce using your own OIDC Identity Provider (IdP), specify your IdP configuration in OidcConfig. Your OIDC IdP must support groups because groups are used by Ground Truth and Amazon A2I to create work teams. For more information, see Create a Private Workforce (OIDC IdP).

Parameter workforceName : The name of the private workforce.

Parameter cognitoConfig : Use this parameter to configure an Amazon Cognito private workforce. A single Cognito workforce is created using and corresponds to a single Amazon Cognito user pool.

Do not use OidcConfig if you specify values for CognitoConfig.

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 configure a private workforce using your own OIDC Identity Provider.

Do not use CognitoConfig if you specify values for OidcConfig.

Parameter tags : An array of key-value pairs that contain metadata to help you categorize and organize our workforce. Each tag consists of a key and a value, both of which you define.

Parameter workforceVpcConfig : Use this parameter to configure a workforce using VPC.

Implementation

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

  return CreateWorkforceResponse.fromJson(jsonResponse.body);
}