:doc:`B2BI <../../b2bi>` / Client / generate_mapping

****************
generate_mapping
****************



.. py:method:: B2BI.Client.generate_mapping(**kwargs)

  

  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.

   

  .. note::

    

    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 <https://docs.aws.amazon.com/b2bi/latest/userguide/ai-assisted-mapping.html#ai-assist-prereq>`__ in the *Amazon Web Services B2B Data Interchange User guide*.

    

   

  To generate a mapping, perform the following steps:

   

   
  * Start with an X12 EDI document to use as the input.
   
  * Call ``TestMapping`` using your EDI document.
   
  * Use the output from the ``TestMapping`` operation as either input or output for your GenerateMapping call, along with your sample file.
  

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/b2bi-2022-06-23/GenerateMapping>`_  


  **Request Syntax**
  ::

    response = client.generate_mapping(
        inputFileContent='string',
        outputFileContent='string',
        mappingType='JSONATA'|'XSLT'
    )
    
  :type inputFileContent: string
  :param inputFileContent: **[REQUIRED]** 

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

    

  
  :type outputFileContent: string
  :param outputFileContent: **[REQUIRED]** 

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

    

  
  :type mappingType: string
  :param mappingType: **[REQUIRED]** 

    Specify the mapping type: either ``JSONATA`` or ``XSLT.``

    

  
  
  :rtype: dict
  :returns: 
    
    **Response Syntax**

    
    ::

      {
          'mappingTemplate': 'string',
          'mappingAccuracy': ...
      }
      
    **Response Structure**

    

    - *(dict) --* 
      

      - **mappingTemplate** *(string) --* 

        Returns a mapping template based on your inputs.

        
      

      - **mappingAccuracy** *(float) --* 

        Returns a percentage that estimates the accuracy of the generated mapping.

        
  
  **Exceptions**
  
  *   :py:class:`B2BI.Client.exceptions.AccessDeniedException`

  
  *   :py:class:`B2BI.Client.exceptions.ValidationException`

  
  *   :py:class:`B2BI.Client.exceptions.ThrottlingException`

  
  *   :py:class:`B2BI.Client.exceptions.InternalServerException`

  