Skip to content

delete_workforce

delete_workforce(
    *,
    config_overrides: Optional[SageMakerClientConfig] = None,
    workforce_name: Optional[WorkforceName] = None,
) -> DeleteWorkforceResponse

Use this operation to delete a workforce.

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

If a private workforce contains one or more work teams, you must use the DeleteWorkteam operation to delete all work teams before you delete the workforce. If you try to delete a workforce that contains one or more work teams, you will receive a ResourceInUse error.

Parameters:

Raises:

Source code in docs_src/capo_sagemaker/_services/sage_maker.py
def delete_workforce(
    self,
    *,
    config_overrides: Optional[SageMakerClientConfig] = None,
    workforce_name: Optional[
        "capo_sagemaker.types.workforce_name.WorkforceName"
    ] = None,
) -> "capo_sagemaker.types.delete_workforce_response.DeleteWorkforceResponse":
    """<p>Use this operation to delete a workforce.</p> <p>If you want to create a new workforce in an Amazon Web Services Region where a workforce already exists, use this operation to delete the existing workforce and then use <a href="https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateWorkforce.html">CreateWorkforce</a> to create a new workforce.</p> <important> <p>If a private workforce contains one or more work teams, you must use the <a href="https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DeleteWorkteam.html">DeleteWorkteam</a> operation to delete all work teams before you delete the workforce. If you try to delete a workforce that contains one or more work teams, you will receive a <code>ResourceInUse</code> error.</p> </important>

    Args:
        workforce_name: <p>The name of the 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.delete_workforce_request.DeleteWorkforceRequest]",
    ) -> OperationResponse[
        "capo_sagemaker.types.delete_workforce_response.DeleteWorkforceResponse"
    ]:
        import capo_sagemaker._operations.sage_maker.delete_workforce

        output, http_response = (
            capo_sagemaker._operations.sage_maker.delete_workforce.delete_workforce(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeleteWorkforce")
    )
    input_: capo_sagemaker.types.delete_workforce_request.DeleteWorkforceRequest = {}
    if workforce_name is not None:
        input_["workforce_name"] = workforce_name

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output