createWorkforce method
- required String workforceName,
- CognitoConfig? cognitoConfig,
- OidcConfig? oidcConfig,
- SourceIpConfig? sourceIpConfig,
- List<
Tag> ? tags,
Use this operation to create a workforce. This operation will return an error if a workforce already exists in the AWS Region that you specify. You can only create one workforce in each AWS Region per AWS account.
If you want to create a new workforce in an AWS Region where a workforce
already exists, use the 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 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.
Implementation
Future<CreateWorkforceResponse> createWorkforce({
required String workforceName,
CognitoConfig? cognitoConfig,
OidcConfig? oidcConfig,
SourceIpConfig? sourceIpConfig,
List<Tag>? tags,
}) async {
ArgumentError.checkNotNull(workforceName, 'workforceName');
_s.validateStringLength(
'workforceName',
workforceName,
1,
63,
isRequired: true,
);
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 (oidcConfig != null) 'OidcConfig': oidcConfig,
if (sourceIpConfig != null) 'SourceIpConfig': sourceIpConfig,
if (tags != null) 'Tags': tags,
},
);
return CreateWorkforceResponse.fromJson(jsonResponse.body);
}