Skip to content

generate_mapping async

generate_mapping(
    input_file_content: GenerateMappingInputFileContent,
    output_file_content: GenerateMappingOutputFileContent,
    mapping_type: MappingType,
    *,
    config_overrides: Optional[Asyncb2biClientConfig] = None,
) -> GenerateMappingResponse

Takes sample input and output documents and uses Amazon Bedrock to generate a mapping automatically. Depending on the accuracy and other factors, you can then edit the mapping for your needs.

Before you can use the AI-assisted feature for Amazon Web Services B2B Data Interchange you must enable models in Amazon Bedrock. For details, see AI-assisted template mapping prerequisites in the Amazon Web Services B2B Data Interchange User guide.

To generate a mapping, perform the following steps:

  1. Start with an X12 EDI document to use as the input.

  2. Call TestMapping using your EDI document.

  3. Use the output from the TestMapping operation as either input or output for your GenerateMapping call, along with your sample file.

Parameters:

  • input_file_content (GenerateMappingInputFileContent) –

    Provide the contents of a sample X12 EDI file, either in JSON or XML format, to use as a starting point for the mapping.

  • output_file_content (GenerateMappingOutputFileContent) –

    Provide the contents of a sample X12 EDI file, either in JSON or XML format, to use as a target for the mapping.

  • mapping_type (MappingType) –

    Specify the mapping type: either JSONATA or XSLT.

Raises:

  • AccessDeniedException –

    You do not have sufficient access to perform this action.

  • InternalServerException –

    This exception is thrown when an error occurs in the Amazon Web Services B2B Data Interchange service.

  • ThrottlingException –

    The request was denied due to throttling: the data speed and rendering may be limited depending on various parameters and conditions.

  • ValidationException –

    Occurs when a B2BI object cannot be validated against a request from another object. This exception can be thrown during standard EDI validation or when custom validation rules fail, such as when element length constraints are violated, invalid codes are used in code list validations, or required elements are missing based on configured element requirement rules.

  • UnknownServiceError –

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

Examples:

Sample GenerateMapping call

>>> await client.generate_mapping(input_file_content='Sample input file content', output_file_content='Sample output file content', mapping_type='JSONATA')
Source code in docs_src/capo_b2bi/_services/async_b2bi.py
async def generate_mapping(
    self,
    input_file_content: "capo_b2bi.types.generate_mapping_input_file_content.GenerateMappingInputFileContent",
    output_file_content: "capo_b2bi.types.generate_mapping_output_file_content.GenerateMappingOutputFileContent",
    mapping_type: "capo_b2bi.types.mapping_type.MappingType",
    *,
    config_overrides: Optional[Asyncb2biClientConfig] = None,
) -> "capo_b2bi.types.generate_mapping_response.GenerateMappingResponse":
    """<p>Takes sample input and output documents and uses Amazon Bedrock to generate a mapping automatically. Depending on the accuracy and other factors, you can then edit the mapping for your needs.</p> <note> <p>Before you can use the AI-assisted feature for Amazon Web Services B2B Data Interchange you must enable models in Amazon Bedrock. For details, see <a href="https://docs.aws.amazon.com/b2bi/latest/userguide/ai-assisted-mapping.html#ai-assist-prereq">AI-assisted template mapping prerequisites</a> in the <i>Amazon Web Services B2B Data Interchange User guide</i>.</p> </note> <p>To generate a mapping, perform the following steps:</p> <ol> <li> <p>Start with an X12 EDI document to use as the input.</p> </li> <li> <p>Call <code>TestMapping</code> using your EDI document.</p> </li> <li> <p>Use the output from the <code>TestMapping</code> operation as either input or output for your GenerateMapping call, along with your sample file.</p> </li> </ol>

    Args:
        input_file_content: <p>Provide the contents of a sample X12 EDI file, either in JSON or XML format, to use as a starting point for the mapping.</p>
        output_file_content: <p>Provide the contents of a sample X12 EDI file, either in JSON or XML format, to use as a target for the mapping.</p>
        mapping_type: <p>Specify the mapping type: either <code>JSONATA</code> or <code>XSLT.</code> </p>

    Raises:
        capo_b2bi.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p>
        capo_b2bi.errors.internal_server_exception.InternalServerException: <p>This exception is thrown when an error occurs in the Amazon Web Services B2B Data Interchange service.</p>
        capo_b2bi.errors.throttling_exception.ThrottlingException: <p>The request was denied due to throttling: the data speed and rendering may be limited depending on various parameters and conditions.</p>
        capo_b2bi.errors.validation_exception.ValidationException: <p>Occurs when a B2BI object cannot be validated against a request from another object. This exception can be thrown during standard EDI validation or when custom validation rules fail, such as when element length constraints are violated, invalid codes are used in code list validations, or required elements are missing based on configured element requirement rules.</p>
        capo_b2bi.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Sample GenerateMapping call

        >>> await client.generate_mapping(input_file_content='Sample input file content', output_file_content='Sample output file content', mapping_type='JSONATA')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_b2bi.types.generate_mapping_request.GenerateMappingRequest]",
    ) -> AsyncOperationResponse[
        "capo_b2bi.types.generate_mapping_response.GenerateMappingResponse"
    ]:
        import capo_b2bi._operations.b2_bi.generate_mapping

        (
            output,
            http_response,
        ) = await capo_b2bi._operations.b2_bi.generate_mapping.async_generate_mapping(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GenerateMapping")
    )
    input_: capo_b2bi.types.generate_mapping_request.GenerateMappingRequest = {
        "input_file_content": input_file_content,
        "output_file_content": output_file_content,
        "mapping_type": mapping_type,
    }

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