Skip to content

create_transformer

create_transformer(
    name: TransformerName,
    *,
    config_overrides: Optional[b2biClientConfig] = None,
    client_token: Optional[str] = None,
    tags: Optional[TagList] = None,
    file_format: Optional[FileFormat] = None,
    mapping_template: Optional[MappingTemplate] = None,
    edi_type: Optional[EdiType] = None,
    sample_document: Optional[FileLocation] = None,
    input_conversion: Optional[InputConversion] = None,
    mapping: Optional[Mapping] = None,
    output_conversion: Optional[OutputConversion] = None,
    sample_documents: Optional[SampleDocuments] = None,
) -> CreateTransformerResponse

Creates a transformer. Amazon Web Services B2B Data Interchange currently supports two scenarios:

  • Inbound EDI: the Amazon Web Services customer receives an EDI file from their trading partner. Amazon Web Services B2B Data Interchange converts this EDI file into a JSON or XML file with a service-defined structure. A mapping template provided by the customer, in JSONata or XSLT format, is optionally applied to this file to produce a JSON or XML file with the structure the customer requires.

  • Outbound EDI: the Amazon Web Services customer has a JSON or XML file containing data that they wish to use in an EDI file. A mapping template, provided by the customer (in either JSONata or XSLT format) is applied to this file to generate a JSON or XML file in the service-defined structure. This file is then converted to an EDI file.

The following fields are provided for backwards compatibility only: fileFormat, mappingTemplate, ediType, and sampleDocument.

  • Use the mapping data type in place of mappingTemplate and fileFormat

  • Use the sampleDocuments data type in place of sampleDocument

  • Use either the inputConversion or outputConversion in place of ediType

Parameters:

  • name (TransformerName) –

    Specifies the name of the transformer, used to identify it.

  • client_token (Optional[str], default: None ) –

    Reserved for future use.

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

    Specifies the key-value pairs assigned to ARNs that you can use to group and search for resources by type. You can attach this metadata to resources (capabilities, partnerships, and so on) for any purpose.

  • file_format (Optional[FileFormat], default: None ) –

    Specifies that the currently supported file formats for EDI transformations are JSON and XML.

  • mapping_template (Optional[MappingTemplate], default: None ) –

    Specifies the mapping template for the transformer. This template is used to map the parsed EDI file using JSONata or XSLT.

    This parameter is available for backwards compatibility. Use the Mapping data type instead.

  • edi_type (Optional[EdiType], default: None ) –

    Specifies the details for the EDI standard that is being used for the transformer. Currently, only X12 is supported. X12 is a set of standards and corresponding messages that define specific business documents.

  • sample_document (Optional[FileLocation], default: None ) –

    Specifies a sample EDI document that is used by a transformer as a guide for processing the EDI data.

  • input_conversion (Optional[InputConversion], default: None ) –

    Specify the InputConversion object, which contains the format options for the inbound transformation.

  • mapping (Optional[Mapping], default: None ) –

    Specify the structure that contains the mapping template and its language (either XSLT or JSONATA).

  • output_conversion (Optional[OutputConversion], default: None ) –

    A structure that contains the OutputConversion object, which contains the format options for the outbound transformation.

  • sample_documents (Optional[SampleDocuments], default: None ) –

    Specify a structure that contains the Amazon S3 bucket and an array of the corresponding keys used to identify the location for your sample documents.

Raises:

  • AccessDeniedException –

    You do not have sufficient access to perform this action.

  • ConflictException –

    A conflict exception is thrown when you attempt to delete a resource (such as a profile or a capability) that is being used by other resources.

  • InternalServerException –

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

  • ResourceNotFoundException –

    Occurs when the requested resource does not exist, or cannot be found. In some cases, the resource exists in a region other than the region specified in the API call.

  • ServiceQuotaExceededException –

    Occurs when the calling command attempts to exceed one of the service quotas, for example trying to create a capability when you already have the maximum number of capabilities allowed.

  • 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 CreateTransformer call

>>> client.create_transformer(client_token='foo', name='transformX12', input_conversion={'fromFormat': 'X12', 'formatOptions': {'x12': {'transactionSet': 'X12_110', 'version': 'VERSION_4010'}}, 'advancedOptions': {'x12': {'splitOptions': {'splitBy': 'NONE'}, 'validationOptions': {'validationRules': [{'codeListValidationRule': {'elementId': '1234', 'codesToAdd': ['A', 'B', 'C'], 'codesToRemove': ['X', 'Y', 'Z']}}, {'elementRequirementValidationRule': {'elementPosition': 'NM1-01', 'requirement': 'MANDATORY'}}, {'elementLengthValidationRule': {'elementId': '5678', 'maxLength': 10, 'minLength': 2}}]}}}}, mapping={'templateLanguage': 'JSONATA', 'template': '{}'}, sample_documents={'bucketName': 'test-bucket', 'keys': [{'input': 'sampleDoc.txt'}]}, tags=[{'Key': 'sampleKey', 'Value': 'sampleValue'}])
Source code in docs_src/capo_b2bi/_services/b2bi.py
def create_transformer(
    self,
    name: "capo_b2bi.types.transformer_name.TransformerName",
    *,
    config_overrides: Optional[b2biClientConfig] = None,
    client_token: Optional[str] = None,
    tags: Optional["capo_b2bi.types.tag_list.TagList"] = None,
    file_format: Optional["capo_b2bi.types.file_format.FileFormat"] = None,
    mapping_template: Optional[
        "capo_b2bi.types.mapping_template.MappingTemplate"
    ] = None,
    edi_type: Optional["capo_b2bi.types.edi_type.EdiType"] = None,
    sample_document: Optional["capo_b2bi.types.file_location.FileLocation"] = None,
    input_conversion: Optional[
        "capo_b2bi.types.input_conversion.InputConversion"
    ] = None,
    mapping: Optional["capo_b2bi.types.mapping.Mapping"] = None,
    output_conversion: Optional[
        "capo_b2bi.types.output_conversion.OutputConversion"
    ] = None,
    sample_documents: Optional[
        "capo_b2bi.types.sample_documents.SampleDocuments"
    ] = None,
) -> "capo_b2bi.types.create_transformer_response.CreateTransformerResponse":
    """<p>Creates a transformer. Amazon Web Services B2B Data Interchange currently supports two scenarios:</p> <ul> <li> <p> <i>Inbound EDI</i>: the Amazon Web Services customer receives an EDI file from their trading partner. Amazon Web Services B2B Data Interchange converts this EDI file into a JSON or XML file with a service-defined structure. A mapping template provided by the customer, in JSONata or XSLT format, is optionally applied to this file to produce a JSON or XML file with the structure the customer requires.</p> </li> <li> <p> <i>Outbound EDI</i>: the Amazon Web Services customer has a JSON or XML file containing data that they wish to use in an EDI file. A mapping template, provided by the customer (in either JSONata or XSLT format) is applied to this file to generate a JSON or XML file in the service-defined structure. This file is then converted to an EDI file.</p> </li> </ul> <note> <p>The following fields are provided for backwards compatibility only: <code>fileFormat</code>, <code>mappingTemplate</code>, <code>ediType</code>, and <code>sampleDocument</code>.</p> <ul> <li> <p>Use the <code>mapping</code> data type in place of <code>mappingTemplate</code> and <code>fileFormat</code> </p> </li> <li> <p>Use the <code>sampleDocuments</code> data type in place of <code>sampleDocument</code> </p> </li> <li> <p>Use either the <code>inputConversion</code> or <code>outputConversion</code> in place of <code>ediType</code> </p> </li> </ul> </note>

    Args:
        name: <p>Specifies the name of the transformer, used to identify it.</p>
        client_token: <p>Reserved for future use.</p>
        tags: <p>Specifies the key-value pairs assigned to ARNs that you can use to group and search for resources by type. You can attach this metadata to resources (capabilities, partnerships, and so on) for any purpose.</p>
        file_format: <p>Specifies that the currently supported file formats for EDI transformations are <code>JSON</code> and <code>XML</code>.</p>
        mapping_template: <p>Specifies the mapping template for the transformer. This template is used to map the parsed EDI file using JSONata or XSLT.</p> <note> <p>This parameter is available for backwards compatibility. Use the <a href="https://docs.aws.amazon.com/b2bi/latest/APIReference/API_Mapping.html">Mapping</a> data type instead.</p> </note>
        edi_type: <p>Specifies the details for the EDI standard that is being used for the transformer. Currently, only X12 is supported. X12 is a set of standards and corresponding messages that define specific business documents.</p>
        sample_document: <p>Specifies a sample EDI document that is used by a transformer as a guide for processing the EDI data.</p>
        input_conversion: <p>Specify the <code>InputConversion</code> object, which contains the format options for the inbound transformation.</p>
        mapping: <p>Specify the structure that contains the mapping template and its language (either XSLT or JSONATA).</p>
        output_conversion: <p>A structure that contains the <code>OutputConversion</code> object, which contains the format options for the outbound transformation.</p>
        sample_documents: <p>Specify a structure that contains the Amazon S3 bucket and an array of the corresponding keys used to identify the location for your sample documents.</p>

    Raises:
        capo_b2bi.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p>
        capo_b2bi.errors.conflict_exception.ConflictException: <p>A conflict exception is thrown when you attempt to delete a resource (such as a profile or a capability) that is being used by other resources.</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.resource_not_found_exception.ResourceNotFoundException: <p>Occurs when the requested resource does not exist, or cannot be found. In some cases, the resource exists in a region other than the region specified in the API call.</p>
        capo_b2bi.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>Occurs when the calling command attempts to exceed one of the service quotas, for example trying to create a capability when you already have the maximum number of capabilities allowed.</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 CreateTransformer call

        >>> client.create_transformer(client_token='foo', name='transformX12', input_conversion={'fromFormat': 'X12', 'formatOptions': {'x12': {'transactionSet': 'X12_110', 'version': 'VERSION_4010'}}, 'advancedOptions': {'x12': {'splitOptions': {'splitBy': 'NONE'}, 'validationOptions': {'validationRules': [{'codeListValidationRule': {'elementId': '1234', 'codesToAdd': ['A', 'B', 'C'], 'codesToRemove': ['X', 'Y', 'Z']}}, {'elementRequirementValidationRule': {'elementPosition': 'NM1-01', 'requirement': 'MANDATORY'}}, {'elementLengthValidationRule': {'elementId': '5678', 'maxLength': 10, 'minLength': 2}}]}}}}, mapping={'templateLanguage': 'JSONATA', 'template': '{}'}, sample_documents={'bucketName': 'test-bucket', 'keys': [{'input': 'sampleDoc.txt'}]}, tags=[{'Key': 'sampleKey', 'Value': 'sampleValue'}])
    """

    def _handler(
        req: "OperationRequest[capo_b2bi.types.create_transformer_request.CreateTransformerRequest]",
    ) -> OperationResponse[
        "capo_b2bi.types.create_transformer_response.CreateTransformerResponse"
    ]:
        import capo_b2bi._operations.b2_bi.create_transformer

        output, http_response = (
            capo_b2bi._operations.b2_bi.create_transformer.create_transformer(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateTransformer")
    )
    input_: capo_b2bi.types.create_transformer_request.CreateTransformerRequest = {
        "name": name
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if tags is not None:
        input_["tags"] = tags
    if file_format is not None:
        input_["file_format"] = file_format
    if mapping_template is not None:
        input_["mapping_template"] = mapping_template
    if edi_type is not None:
        input_["edi_type"] = edi_type
    if sample_document is not None:
        input_["sample_document"] = sample_document
    if input_conversion is not None:
        input_["input_conversion"] = input_conversion
    if mapping is not None:
        input_["mapping"] = mapping
    if output_conversion is not None:
        input_["output_conversion"] = output_conversion
    if sample_documents is not None:
        input_["sample_documents"] = sample_documents

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