Skip to content

create_model_copy_job

create_model_copy_job(
    source_model_arn: ModelArn,
    target_model_name: CustomModelName,
    *,
    config_overrides: Optional[BedrockClientConfig] = None,
    model_kms_key_id: Optional[KmsKeyId] = None,
    target_model_tags: Optional[TagList] = None,
    client_request_token: Optional[IdempotencyToken] = None,
) -> CreateModelCopyJobResponse

Copies a model to another region so that it can be used there. For more information, see Copy models to be used in other regions in the Amazon Bedrock User Guide.

Parameters:

  • source_model_arn (ModelArn) –

    The Amazon Resource Name (ARN) of the model to be copied.

  • target_model_name (CustomModelName) –

    A name for the copied model.

  • model_kms_key_id (Optional[KmsKeyId], default: None ) –

    The ARN of the KMS key that you use to encrypt the model copy.

  • target_model_tags (Optional[TagList], default: None ) –

    Tags to associate with the target model. For more information, see Tag resources in the Amazon Bedrock User Guide.

  • client_request_token (Optional[IdempotencyToken], default: None ) –

    A unique, case-sensitive identifier to ensure that the API request completes no more than one time. If this token matches a previous request, Amazon Bedrock ignores the request, but does not return an error. For more information, see Ensuring idempotency.

Raises:

  • AccessDeniedException –

    The request is denied because of missing access permissions.

  • InternalServerException –

    An internal server error occurred. Retry your request.

  • ResourceNotFoundException –

    The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and try your request again.

  • TooManyTagsException –

    The request contains more tags than can be associated with a resource (50 tags per resource). The maximum number of tags includes both existing tags and those included in your current request.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_bedrock/_services/bedrock.py
def create_model_copy_job(
    self,
    source_model_arn: "capo_bedrock.types.model_arn.ModelArn",
    target_model_name: "capo_bedrock.types.custom_model_name.CustomModelName",
    *,
    config_overrides: Optional[BedrockClientConfig] = None,
    model_kms_key_id: Optional["capo_bedrock.types.kms_key_id.KmsKeyId"] = None,
    target_model_tags: Optional["capo_bedrock.types.tag_list.TagList"] = None,
    client_request_token: Optional[
        "capo_bedrock.types.idempotency_token.IdempotencyToken"
    ] = None,
) -> "capo_bedrock.types.create_model_copy_job_response.CreateModelCopyJobResponse":
    """<p>Copies a model to another region so that it can be used there. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/copy-model.html">Copy models to be used in other regions</a> in the <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/what-is-service.html">Amazon Bedrock User Guide</a>.</p>

    Args:
        source_model_arn: <p>The Amazon Resource Name (ARN) of the model to be copied.</p>
        target_model_name: <p>A name for the copied model.</p>
        model_kms_key_id: <p>The ARN of the KMS key that you use to encrypt the model copy.</p>
        target_model_tags: <p>Tags to associate with the target model. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/tagging.html">Tag resources</a> in the <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/what-is-service.html">Amazon Bedrock User Guide</a>.</p>
        client_request_token: <p>A unique, case-sensitive identifier to ensure that the API request completes no more than one time. If this token matches a previous request, Amazon Bedrock ignores the request, but does not return an error. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html">Ensuring idempotency</a>.</p>

    Raises:
        capo_bedrock.errors.access_denied_exception.AccessDeniedException: <p>The request is denied because of missing access permissions.</p>
        capo_bedrock.errors.internal_server_exception.InternalServerException: <p>An internal server error occurred. Retry your request.</p>
        capo_bedrock.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and try your request again.</p>
        capo_bedrock.errors.too_many_tags_exception.TooManyTagsException: <p>The request contains more tags than can be associated with a resource (50 tags per resource). The maximum number of tags includes both existing tags and those included in your current request. </p>
        capo_bedrock.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_bedrock.types.create_model_copy_job_request.CreateModelCopyJobRequest]",
    ) -> OperationResponse[
        "capo_bedrock.types.create_model_copy_job_response.CreateModelCopyJobResponse"
    ]:
        import capo_bedrock._operations.amazon_bedrock_control_plane_service.create_model_copy_job

        output, http_response = (
            capo_bedrock._operations.amazon_bedrock_control_plane_service.create_model_copy_job.create_model_copy_job(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateModelCopyJob")
    )
    input_: capo_bedrock.types.create_model_copy_job_request.CreateModelCopyJobRequest = {
        "source_model_arn": source_model_arn,
        "target_model_name": target_model_name,
    }
    if model_kms_key_id is not None:
        input_["model_kms_key_id"] = model_kms_key_id
    if target_model_tags is not None:
        input_["target_model_tags"] = target_model_tags
    if client_request_token is None:
        client_request_token = str(uuid.uuid4())
    input_["client_request_token"] = client_request_token

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