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).
Parameters:
-
cognito_config
(Optional[CognitoConfig], default:
None
)
–
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.
-
oidc_config
(Optional[OidcConfig], default:
None
)
–
Use this parameter to configure a private workforce using your own OIDC Identity Provider.
Do not use CognitoConfig if you specify values for OidcConfig.
-
workforce_name
(Optional[WorkforceName], default:
None
)
–
The name of the private workforce.
-
tags
(Optional[TagList], default:
None
)
–
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.
-
workforce_vpc_config
(Optional[WorkforceVpcConfigRequest], default:
None
)
–
Use this parameter to configure a workforce using VPC.
-
ip_address_type
(Optional[WorkforceIpAddressType], default:
None
)
–
Use this parameter to specify whether you want IPv4 only or dualstack (IPv4 and IPv6) to support your labeling workforce.
Raises:
Source code in docs_src/capo_sagemaker/_services/sage_maker.py
| def create_workforce(
self,
*,
config_overrides: Optional[SageMakerClientConfig] = None,
cognito_config: Optional[
"capo_sagemaker.types.cognito_config.CognitoConfig"
] = None,
oidc_config: Optional["capo_sagemaker.types.oidc_config.OidcConfig"] = None,
source_ip_config: Optional[
"capo_sagemaker.types.source_ip_config.SourceIpConfig"
] = None,
workforce_name: Optional[
"capo_sagemaker.types.workforce_name.WorkforceName"
] = None,
tags: Optional["capo_sagemaker.types.tag_list.TagList"] = None,
workforce_vpc_config: Optional[
"capo_sagemaker.types.workforce_vpc_config_request.WorkforceVpcConfigRequest"
] = None,
ip_address_type: Optional[
"capo_sagemaker.types.workforce_ip_address_type.WorkforceIpAddressType"
] = None,
) -> "capo_sagemaker.types.create_workforce_response.CreateWorkforceResponse":
"""<p>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.</p> <p>If you want to create a new workforce in an Amazon Web Services Region where a workforce already exists, use the <a href="https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DeleteWorkforce.html">DeleteWorkforce</a> API operation to delete the existing workforce and then use <code>CreateWorkforce</code> to create a new workforce.</p> <p>To create a private workforce using Amazon Cognito, you must specify a Cognito user pool in <code>CognitoConfig</code>. You can also create an Amazon Cognito workforce using the Amazon SageMaker console. For more information, see <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/sms-workforce-create-private.html"> Create a Private Workforce (Amazon Cognito)</a>.</p> <p>To create a private workforce using your own OIDC Identity Provider (IdP), specify your IdP configuration in <code>OidcConfig</code>. Your OIDC IdP must support <i>groups</i> because groups are used by Ground Truth and Amazon A2I to create work teams. For more information, see <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/sms-workforce-create-private-oidc.html"> Create a Private Workforce (OIDC IdP)</a>.</p>
Args:
cognito_config: <p>Use this parameter to configure an Amazon Cognito private workforce. A single Cognito workforce is created using and corresponds to a single <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools.html"> Amazon Cognito user pool</a>.</p> <p>Do not use <code>OidcConfig</code> if you specify values for <code>CognitoConfig</code>.</p>
oidc_config: <p>Use this parameter to configure a private workforce using your own OIDC Identity Provider.</p> <p>Do not use <code>CognitoConfig</code> if you specify values for <code>OidcConfig</code>.</p>
workforce_name: <p>The name of the private workforce.</p>
tags: <p>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.</p>
workforce_vpc_config: <p>Use this parameter to configure a workforce using VPC.</p>
ip_address_type: <p>Use this parameter to specify whether you want <code>IPv4</code> only or <code>dualstack</code> (<code>IPv4</code> and <code>IPv6</code>) to support your labeling workforce.</p>
Raises:
capo_sagemaker.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
def _handler(
req: "OperationRequest[capo_sagemaker.types.create_workforce_request.CreateWorkforceRequest]",
) -> OperationResponse[
"capo_sagemaker.types.create_workforce_response.CreateWorkforceResponse"
]:
import capo_sagemaker._operations.sage_maker.create_workforce
output, http_response = (
capo_sagemaker._operations.sage_maker.create_workforce.create_workforce(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
def _redact_input(
input_: "capo_sagemaker.types.create_workforce_request.CreateWorkforceRequest",
) -> dict[str, Any]:
import capo_sagemaker.types.create_workforce_request
return capo_sagemaker.types.create_workforce_request.redact_sensitive(
input_
)
interceptors_, options_ = self.operation_options(
config_overrides,
OperationLogging("CreateWorkforce", redact_input=_redact_input),
)
input_: capo_sagemaker.types.create_workforce_request.CreateWorkforceRequest = {}
if cognito_config is not None:
input_["cognito_config"] = cognito_config
if oidc_config is not None:
input_["oidc_config"] = oidc_config
if source_ip_config is not None:
input_["source_ip_config"] = source_ip_config
if workforce_name is not None:
input_["workforce_name"] = workforce_name
if tags is not None:
input_["tags"] = tags
if workforce_vpc_config is not None:
input_["workforce_vpc_config"] = workforce_vpc_config
if ip_address_type is not None:
input_["ip_address_type"] = ip_address_type
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|