createTransformer

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

Samples

import aws.sdk.kotlin.services.b2bi.model.AdvancedOptions
import aws.sdk.kotlin.services.b2bi.model.ElementRequirement
import aws.sdk.kotlin.services.b2bi.model.FormatOptions
import aws.sdk.kotlin.services.b2bi.model.FromFormat
import aws.sdk.kotlin.services.b2bi.model.InputConversion
import aws.sdk.kotlin.services.b2bi.model.Mapping
import aws.sdk.kotlin.services.b2bi.model.MappingTemplateLanguage
import aws.sdk.kotlin.services.b2bi.model.SampleDocumentKeys
import aws.sdk.kotlin.services.b2bi.model.SampleDocuments
import aws.sdk.kotlin.services.b2bi.model.Tag
import aws.sdk.kotlin.services.b2bi.model.X12AdvancedOptions
import aws.sdk.kotlin.services.b2bi.model.X12CodeListValidationRule
import aws.sdk.kotlin.services.b2bi.model.X12Details
import aws.sdk.kotlin.services.b2bi.model.X12ElementLengthValidationRule
import aws.sdk.kotlin.services.b2bi.model.X12ElementRequirementValidationRule
import aws.sdk.kotlin.services.b2bi.model.X12SplitBy
import aws.sdk.kotlin.services.b2bi.model.X12SplitOptions
import aws.sdk.kotlin.services.b2bi.model.X12TransactionSet
import aws.sdk.kotlin.services.b2bi.model.X12ValidationOptions
import aws.sdk.kotlin.services.b2bi.model.X12ValidationRule
import aws.sdk.kotlin.services.b2bi.model.X12Version

fun main() { 
   //sampleStart 
   // Sample CreateTransformer call
val resp = b2BiClient.createTransformer {
    clientToken = "foo"
    name = "transformX12"
    inputConversion = InputConversion {
        fromFormat = FromFormat.fromValue("X12")
        formatOptions = FormatOptions.X12(X12Details {
            transactionSet = X12TransactionSet.fromValue("X12_110")
            version = X12Version.fromValue("VERSION_4010")
        }
        )
        advancedOptions = AdvancedOptions {
            x12 = X12AdvancedOptions {
                splitOptions = X12SplitOptions {
                    splitBy = X12SplitBy.fromValue("NONE")
                }
                validationOptions = X12ValidationOptions {
                    validationRules = listOf<X12ValidationRule>(
                        X12ValidationRule.CodeListValidationRule(X12CodeListValidationRule {
                            elementId = "1234"
                            codesToAdd = listOf<String>(
                                "A",
                                "B",
                                "C"
                            )
                            codesToRemove = listOf<String>(
                                "X",
                                "Y",
                                "Z"
                            )
                        }
                        ),
                        X12ValidationRule.ElementRequirementValidationRule(X12ElementRequirementValidationRule {
                            elementPosition = "NM1-01"
                            requirement = ElementRequirement.fromValue("MANDATORY")
                        }
                        ),
                        X12ValidationRule.ElementLengthValidationRule(X12ElementLengthValidationRule {
                            elementId = "5678"
                            maxLength = 10
                            minLength = 2
                        }
                        )
                    )
                }
            }
        }
    }
    mapping = Mapping {
        templateLanguage = MappingTemplateLanguage.fromValue("JSONATA")
        template = "{}"
    }
    sampleDocuments = SampleDocuments {
        bucketName = "test-bucket"
        keys = listOf<SampleDocumentKeys>(
            SampleDocumentKeys {
                input = "sampleDoc.txt"
            }                
        )
    }
    tags = listOf<Tag>(
        Tag {
            key = "sampleKey"
            value = "sampleValue"
        }            
    )
} 
   //sampleEnd
}