:doc:`MailManager <../../mailmanager>` / Client / create_traffic_policy

*********************
create_traffic_policy
*********************



.. py:method:: MailManager.Client.create_traffic_policy(**kwargs)

  

  Provision a new traffic policy resource.

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/mailmanager-2023-10-17/CreateTrafficPolicy>`_  


  **Request Syntax**
  ::

    response = client.create_traffic_policy(
        ClientToken='string',
        TrafficPolicyName='string',
        PolicyStatements=[
            {
                'Conditions': [
                    {
                        'StringExpression': {
                            'Evaluate': {
                                'Attribute': 'RECIPIENT',
                                'Analysis': {
                                    'Analyzer': 'string',
                                    'ResultField': 'string'
                                }
                            },
                            'Operator': 'EQUALS'|'NOT_EQUALS'|'STARTS_WITH'|'ENDS_WITH'|'CONTAINS',
                            'Values': [
                                'string',
                            ]
                        },
                        'IpExpression': {
                            'Evaluate': {
                                'Attribute': 'SENDER_IP'
                            },
                            'Operator': 'CIDR_MATCHES'|'NOT_CIDR_MATCHES',
                            'Values': [
                                'string',
                            ]
                        },
                        'Ipv6Expression': {
                            'Evaluate': {
                                'Attribute': 'SENDER_IPV6'
                            },
                            'Operator': 'CIDR_MATCHES'|'NOT_CIDR_MATCHES',
                            'Values': [
                                'string',
                            ]
                        },
                        'TlsExpression': {
                            'Evaluate': {
                                'Attribute': 'TLS_PROTOCOL'
                            },
                            'Operator': 'MINIMUM_TLS_VERSION'|'IS',
                            'Value': 'TLS1_2'|'TLS1_3'
                        },
                        'BooleanExpression': {
                            'Evaluate': {
                                'Analysis': {
                                    'Analyzer': 'string',
                                    'ResultField': 'string'
                                },
                                'IsInAddressList': {
                                    'Attribute': 'RECIPIENT',
                                    'AddressLists': [
                                        'string',
                                    ]
                                }
                            },
                            'Operator': 'IS_TRUE'|'IS_FALSE'
                        }
                    },
                ],
                'Action': 'ALLOW'|'DENY'
            },
        ],
        DefaultAction='ALLOW'|'DENY',
        MaxMessageSizeBytes=123,
        Tags=[
            {
                'Key': 'string',
                'Value': 'string'
            },
        ]
    )
    
  :type ClientToken: string
  :param ClientToken: 

    A unique token that Amazon SES uses to recognize subsequent retries of the same request.

    This field is autopopulated if not provided.

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

    A user-friendly name for the traffic policy resource.

    

  
  :type PolicyStatements: list
  :param PolicyStatements: **[REQUIRED]** 

    Conditional statements for filtering email traffic.

    

  
    - *(dict) --* 

      The structure containing traffic policy conditions and actions.

      

    
      - **Conditions** *(list) --* **[REQUIRED]** 

        The list of conditions to apply to incoming messages for filtering email traffic.

        

      
        - *(dict) --* 

          The email traffic filtering conditions which are contained in a traffic policy resource.

          .. note::    This is a Tagged Union structure. Only one of the     following top level keys can be set: ``StringExpression``, ``IpExpression``, ``Ipv6Expression``, ``TlsExpression``, ``BooleanExpression``. 

        
          - **StringExpression** *(dict) --* 

            This represents a string based condition matching on the incoming mail. It performs the string operation configured in 'Operator' and evaluates the 'Protocol' object against the 'Value'.

            

          
            - **Evaluate** *(dict) --* **[REQUIRED]** 

              The left hand side argument of a string condition expression.

              .. note::    This is a Tagged Union structure. Only one of the     following top level keys can be set: ``Attribute``, ``Analysis``. 

            
              - **Attribute** *(string) --* 

                The enum type representing the allowed attribute types for a string condition.

                

              
              - **Analysis** *(dict) --* 

                The structure type for a string condition stating the Add On ARN and its returned value.

                

              
                - **Analyzer** *(string) --* **[REQUIRED]** 

                  The Amazon Resource Name (ARN) of an Add On.

                  

                
                - **ResultField** *(string) --* **[REQUIRED]** 

                  The returned value from an Add On.

                  

                
              
            
            - **Operator** *(string) --* **[REQUIRED]** 

              The matching operator for a string condition expression.

              

            
            - **Values** *(list) --* **[REQUIRED]** 

              The right hand side argument of a string condition expression.

              

            
              - *(string) --* 

              
          
          
          - **IpExpression** *(dict) --* 

            This represents an IP based condition matching on the incoming mail. It performs the operation configured in 'Operator' and evaluates the 'Protocol' object against the 'Value'.

            

          
            - **Evaluate** *(dict) --* **[REQUIRED]** 

              The left hand side argument of an IP condition expression.

              .. note::    This is a Tagged Union structure. Only one of the     following top level keys can be set: ``Attribute``. 

            
              - **Attribute** *(string) --* 

                An enum type representing the allowed attribute types for an IP condition.

                

              
            
            - **Operator** *(string) --* **[REQUIRED]** 

              The matching operator for an IP condition expression.

              

            
            - **Values** *(list) --* **[REQUIRED]** 

              The right hand side argument of an IP condition expression.

              

            
              - *(string) --* 

              
          
          
          - **Ipv6Expression** *(dict) --* 

            This represents an IPv6 based condition matching on the incoming mail. It performs the operation configured in 'Operator' and evaluates the 'Protocol' object against the 'Value'.

            

          
            - **Evaluate** *(dict) --* **[REQUIRED]** 

              The left hand side argument of an IPv6 condition expression.

              .. note::    This is a Tagged Union structure. Only one of the     following top level keys can be set: ``Attribute``. 

            
              - **Attribute** *(string) --* 

                An enum type representing the allowed attribute types for an IPv6 condition.

                

              
            
            - **Operator** *(string) --* **[REQUIRED]** 

              The matching operator for an IPv6 condition expression.

              

            
            - **Values** *(list) --* **[REQUIRED]** 

              The right hand side argument of an IPv6 condition expression.

              

            
              - *(string) --* 

              
          
          
          - **TlsExpression** *(dict) --* 

            This represents a TLS based condition matching on the incoming mail. It performs the operation configured in 'Operator' and evaluates the 'Protocol' object against the 'Value'.

            

          
            - **Evaluate** *(dict) --* **[REQUIRED]** 

              The left hand side argument of a TLS condition expression.

              .. note::    This is a Tagged Union structure. Only one of the     following top level keys can be set: ``Attribute``. 

            
              - **Attribute** *(string) --* 

                The enum type representing the allowed attribute types for the TLS condition.

                

              
            
            - **Operator** *(string) --* **[REQUIRED]** 

              The matching operator for a TLS condition expression.

              

            
            - **Value** *(string) --* **[REQUIRED]** 

              The right hand side argument of a TLS condition expression.

              

            
          
          - **BooleanExpression** *(dict) --* 

            This represents a boolean type condition matching on the incoming mail. It performs the boolean operation configured in 'Operator' and evaluates the 'Protocol' object against the 'Value'.

            

          
            - **Evaluate** *(dict) --* **[REQUIRED]** 

              The operand on which to perform a boolean condition operation.

              .. note::    This is a Tagged Union structure. Only one of the     following top level keys can be set: ``Analysis``, ``IsInAddressList``. 

            
              - **Analysis** *(dict) --* 

                The structure type for a boolean condition stating the Add On ARN and its returned value.

                

              
                - **Analyzer** *(string) --* **[REQUIRED]** 

                  The Amazon Resource Name (ARN) of an Add On.

                  

                
                - **ResultField** *(string) --* **[REQUIRED]** 

                  The returned value from an Add On.

                  

                
              
              - **IsInAddressList** *(dict) --* 

                The structure type for a boolean condition that provides the address lists to evaluate incoming traffic on.

                

              
                - **Attribute** *(string) --* **[REQUIRED]** 

                  The email attribute that needs to be evaluated against the address list.

                  

                
                - **AddressLists** *(list) --* **[REQUIRED]** 

                  The address lists that will be used for evaluation.

                  

                
                  - *(string) --* 

                  
              
              
            
            - **Operator** *(string) --* **[REQUIRED]** 

              The matching operator for a boolean condition expression.

              

            
          
        
    
      - **Action** *(string) --* **[REQUIRED]** 

        The action that informs a traffic policy resource to either allow or block the email if it matches a condition in the policy statement.

        

      
    

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

    Default action instructs the traﬃc policy to either Allow or Deny (block) messages that fall outside of (or not addressed by) the conditions of your policy statements

    

  
  :type MaxMessageSizeBytes: integer
  :param MaxMessageSizeBytes: 

    The maximum message size in bytes of email which is allowed in by this traffic policy—anything larger will be blocked.

    

  
  :type Tags: list
  :param Tags: 

    The tags used to organize, track, or control access for the resource. For example, { "tags": {"key1":"value1", "key2":"value2"} }.

    

  
    - *(dict) --* 

      A key-value pair (the value is optional), that you can define and assign to Amazon Web Services resources.

      

    
      - **Key** *(string) --* **[REQUIRED]** 

        The key of the key-value tag.

        

      
      - **Value** *(string) --* **[REQUIRED]** 

        The value of the key-value tag.

        

      
    

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

    
    ::

      {
          'TrafficPolicyId': 'string'
      }
      
    **Response Structure**

    

    - *(dict) --* 
      

      - **TrafficPolicyId** *(string) --* 

        The identifier of the traffic policy resource.

        
  
  **Exceptions**
  
  *   :py:class:`MailManager.Client.exceptions.ValidationException`

  
  *   :py:class:`MailManager.Client.exceptions.ServiceQuotaExceededException`

  
  *   :py:class:`MailManager.Client.exceptions.ConflictException`

  