Skip to content

start_import async

start_import(
    import_id: Id,
    resource_specification: ImportResourceSpecification,
    merge_strategy: MergeStrategy,
    *,
    config_overrides: Optional[AsyncLexModelsV2ClientConfig] = None,
    file_password: Optional[ImportExportFilePassword] = None,
) -> StartImportResponse

Starts importing a bot, bot locale, or custom vocabulary from a zip archive that you uploaded to an S3 bucket.

Parameters:

  • import_id (Id) –

    The unique identifier for the import. It is included in the response from the CreateUploadUrl operation.

  • resource_specification (ImportResourceSpecification) –

    Parameters for creating the bot, bot locale or custom vocabulary.

  • merge_strategy (MergeStrategy) –

    The strategy to use when there is a name conflict between the imported resource and an existing resource. When the merge strategy is FailOnConflict existing resources are not overwritten and the import fails.

  • file_password (Optional[ImportExportFilePassword], default: None ) –

    The password used to encrypt the zip archive that contains the resource definition. You should always encrypt the zip archive to protect it during transit between your site and Amazon Lex.

Raises:

  • ConflictException –

    The action that you tried to perform couldn't be completed because the resource is in a conflicting state. For example, deleting a bot that is in the CREATING state. Try your request again.

  • InternalServerException –

    The service encountered an unexpected condition. Try your request again.

  • ResourceNotFoundException –

    You asked to describe a resource that doesn't exist. Check the resource that you are requesting and try again.

  • ServiceQuotaExceededException –

    You have reached a quota for your bot.

  • ThrottlingException –

    Your request rate is too high. Reduce the frequency of requests.

  • ValidationException –

    One of the input parameters in your request isn't valid. Check the parameters and try your request again.

  • UnknownServiceError –

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

Source code in docs_src/capo_lex_models_v2/_services/async_lex_models_v2.py
async def start_import(
    self,
    import_id: "capo_lex_models_v2.types.id.Id",
    resource_specification: "capo_lex_models_v2.types.import_resource_specification.ImportResourceSpecification",
    merge_strategy: "capo_lex_models_v2.types.merge_strategy.MergeStrategy",
    *,
    config_overrides: Optional[AsyncLexModelsV2ClientConfig] = None,
    file_password: Optional[
        "capo_lex_models_v2.types.import_export_file_password.ImportExportFilePassword"
    ] = None,
) -> "capo_lex_models_v2.types.start_import_response.StartImportResponse":
    """<p>Starts importing a bot, bot locale, or custom vocabulary from a zip archive that you uploaded to an S3 bucket.</p>

    Args:
        import_id: <p>The unique identifier for the import. It is included in the response from the <a href="https://docs.aws.amazon.com/lexv2/latest/APIReference/API_CreateUploadUrl.html">CreateUploadUrl</a> operation.</p>
        resource_specification: <p>Parameters for creating the bot, bot locale or custom vocabulary.</p>
        merge_strategy: <p>The strategy to use when there is a name conflict between the imported resource and an existing resource. When the merge strategy is <code>FailOnConflict</code> existing resources are not overwritten and the import fails.</p>
        file_password: <p>The password used to encrypt the zip archive that contains the resource definition. You should always encrypt the zip archive to protect it during transit between your site and Amazon Lex.</p>

    Raises:
        capo_lex_models_v2.errors.conflict_exception.ConflictException: <p>The action that you tried to perform couldn't be completed because the resource is in a conflicting state. For example, deleting a bot that is in the CREATING state. Try your request again. </p>
        capo_lex_models_v2.errors.internal_server_exception.InternalServerException: <p>The service encountered an unexpected condition. Try your request again.</p>
        capo_lex_models_v2.errors.resource_not_found_exception.ResourceNotFoundException: <p>You asked to describe a resource that doesn't exist. Check the resource that you are requesting and try again.</p>
        capo_lex_models_v2.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>You have reached a quota for your bot. </p>
        capo_lex_models_v2.errors.throttling_exception.ThrottlingException: <p>Your request rate is too high. Reduce the frequency of requests.</p>
        capo_lex_models_v2.errors.validation_exception.ValidationException: <p>One of the input parameters in your request isn't valid. Check the parameters and try your request again.</p>
        capo_lex_models_v2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_lex_models_v2.types.start_import_request.StartImportRequest]",
    ) -> AsyncOperationResponse[
        "capo_lex_models_v2.types.start_import_response.StartImportResponse"
    ]:
        import capo_lex_models_v2._operations.lex_model_building_service_v2.start_import

        (
            output,
            http_response,
        ) = await capo_lex_models_v2._operations.lex_model_building_service_v2.start_import.async_start_import(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_lex_models_v2.types.start_import_request.StartImportRequest",
    ) -> dict[str, Any]:
        import capo_lex_models_v2.types.start_import_request

        return capo_lex_models_v2.types.start_import_request.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("StartImport", redact_input=_redact_input),
    )
    input_: capo_lex_models_v2.types.start_import_request.StartImportRequest = {
        "import_id": import_id,
        "resource_specification": resource_specification,
        "merge_strategy": merge_strategy,
    }
    if file_password is not None:
        input_["file_password"] = file_password

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output