
    Vhu                         d Z dZdZ	 ddlZddlmZ ddlmZ ddl	m
Z
 ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ  G d de      Zd Zedk(  r e        yy# e$ r Y _w xY w)a  
module: waf_condition
short_description: Create and delete WAF Conditions
version_added: 1.0.0
description:
  - Read the AWS documentation for WAF
    U(https://aws.amazon.com/documentation/waf/)
  - Prior to release 5.0.0 this module was called C(community.aws.aws_waf_condition).
    The usage did not change.

author:
  - Will Thames (@willthames)
  - Mike Mochan (@mmochan)

options:
  name:
    description: Name of the Web Application Firewall condition to manage.
    required: true
    type: str
  type:
    description: The type of matching to perform.
    choices:
      - byte
      - geo
      - ip
      - regex
      - size
      - sql
      - xss
    type: str
    required: true
  filters:
    description:
      - A list of the filters against which to match.
      - For I(type=byte), valid keys are I(field_to_match), I(position), I(header), I(transformation) and I(target_string).
      - For I(type=geo), the only valid key is I(country).
      - For I(type=ip), the only valid key is I(ip_address).
      - For I(type=regex), valid keys are I(field_to_match), I(transformation) and I(regex_pattern).
      - For I(type=size), valid keys are I(field_to_match), I(transformation), I(comparison) and I(size).
      - For I(type=sql), valid keys are I(field_to_match) and I(transformation).
      - For I(type=xss), valid keys are I(field_to_match) and I(transformation).
      - Required when I(state=present).
    type: list
    elements: dict
    suboptions:
        field_to_match:
          description:
            - The field upon which to perform the match.
            - Valid when I(type=byte), I(type=regex), I(type=sql) or I(type=xss).
          type: str
          choices: ['uri', 'query_string', 'header', 'method', 'body']
        position:
          description:
            - Where in the field the match needs to occur.
            - Only valid when I(type=byte).
          type: str
          choices: ['exactly', 'starts_with', 'ends_with', 'contains', 'contains_word']
        header:
          description:
            - Which specific header should be matched.
            - Required when I(field_to_match=header).
            - Valid when I(type=byte).
          type: str
        transformation:
          description:
            - A transform to apply on the field prior to performing the match.
            - Valid when I(type=byte), I(type=regex), I(type=sql) or I(type=xss).
          type: str
          choices: ['none', 'compress_white_space', 'html_entity_decode', 'lowercase', 'cmd_line', 'url_decode']
        country:
          description:
            - Value of geo constraint (typically a two letter country code).
            - The only valid key when I(type=geo).
          type: str
        ip_address:
          description:
            - An IP Address or CIDR to match.
            - The only valid key when I(type=ip).
          type: str
        regex_pattern:
          description:
            - A dict describing the regular expressions used to perform the match.
            - Only valid when I(type=regex).
          type: dict
          suboptions:
            name:
              description: A name to describe the set of patterns.
              type: str
            regex_strings:
              description: A list of regular expressions to match.
              type: list
              elements: str
        comparison:
          description:
            - What type of comparison to perform.
            - Only valid key when I(type=size).
          type: str
          choices: ['EQ', 'NE', 'LE', 'LT', 'GE', 'GT']
        size:
          description:
            - The size of the field (in bytes).
            - Only valid key when I(type=size).
          type: int
        target_string:
          description:
            - The string to search for.
            - May be up to 50 bytes.
            - Valid when I(type=byte).
          type: str
  purge_filters:
    description:
      - Whether to remove existing filters from a condition if not passed in I(filters).
    default: false
    type: bool
  waf_regional:
    description: Whether to use C(waf-regional) module.
    default: false
    required: false
    type: bool
  state:
    description: Whether the condition should be C(present) or C(absent).
    choices:
      - present
      - absent
    default: present
    type: str

extends_documentation_fragment:
  - amazon.aws.common.modules
  - amazon.aws.region.modules
  - amazon.aws.boto3
a  
- name: create WAF byte condition
  community.aws.waf_condition:
    name: my_byte_condition
    filters:
      - field_to_match: header
        position: STARTS_WITH
        target_string: Hello
        header: Content-type
    type: byte

- name: create WAF geo condition
  community.aws.waf_condition:
    name: my_geo_condition
    filters:
      - country: US
      - country: AU
      - country: AT
    type: geo

- name: create IP address condition
  community.aws.waf_condition:
    name: "{{ resource_prefix }}_ip_condition"
    filters:
      - ip_address: "10.0.0.0/8"
      - ip_address: "192.168.0.0/24"
    type: ip

- name: create WAF regex condition
  community.aws.waf_condition:
    name: my_regex_condition
    filters:
      - field_to_match: query_string
        regex_pattern:
          name: greetings
          regex_strings:
            - '[hH]ello'
            - '^Hi there'
            - '.*Good Day to You'
    type: regex

- name: create WAF size condition
  community.aws.waf_condition:
    name: my_size_condition
    filters:
      - field_to_match: query_string
        size: 300
        comparison: GT
    type: size

- name: create WAF sql injection condition
  community.aws.waf_condition:
    name: my_sql_condition
    filters:
      - field_to_match: query_string
        transformation: url_decode
    type: sql

- name: create WAF xss condition
  community.aws.waf_condition:
    name: my_xss_condition
    filters:
      - field_to_match: query_string
        transformation: url_decode
    type: xss
a.  
condition:
  description: Condition returned by operation.
  returned: always
  type: complex
  contains:
    condition_id:
      description: Type-agnostic ID for the condition.
      returned: when state is present
      type: str
      sample: dd74b1ff-8c06-4a4f-897a-6b23605de413
    byte_match_set_id:
      description: ID for byte match set.
      returned: always
      type: str
      sample: c4882c96-837b-44a2-a762-4ea87dbf812b
    byte_match_tuples:
      description: List of byte match tuples.
      returned: always
      type: complex
      contains:
        field_to_match:
          description: Field to match.
          returned: always
          type: complex
          contains:
            data:
              description: Which specific header (if type is header).
              type: str
              sample: content-type
            type:
              description: Type of field
              type: str
              sample: HEADER
        positional_constraint:
          description: Position in the field to match.
          type: str
          sample: STARTS_WITH
        target_string:
          description: String to look for.
          type: str
          sample: Hello
        text_transformation:
          description: Transformation to apply to the field before matching.
          type: str
          sample: NONE
    geo_match_constraints:
      description: List of geographical constraints.
      returned: when type is geo and state is present
      type: complex
      contains:
        type:
          description: Type of geo constraint.
          type: str
          sample: Country
        value:
          description: Value of geo constraint (typically a country code).
          type: str
          sample: AT
    geo_match_set_id:
      description: ID of the geo match set.
      returned: when type is geo and state is present
      type: str
      sample: dd74b1ff-8c06-4a4f-897a-6b23605de413
    ip_set_descriptors:
      description: list of IP address filters
      returned: when type is ip and state is present
      type: complex
      contains:
        type:
          description: Type of IP address (IPV4 or IPV6).
          returned: always
          type: str
          sample: IPV4
        value:
          description: IP address.
          returned: always
          type: str
          sample: 10.0.0.0/8
    ip_set_id:
      description: ID of condition.
      returned: when type is ip and state is present
      type: str
      sample: 78ad334a-3535-4036-85e6-8e11e745217b
    name:
      description: Name of condition.
      returned: when state is present
      type: str
      sample: my_waf_condition
    regex_match_set_id:
      description: ID of the regex match set.
      returned: when type is regex and state is present
      type: str
      sample: 5ea3f6a8-3cd3-488b-b637-17b79ce7089c
    regex_match_tuples:
      description: List of regex matches.
      returned: when type is regex and state is present
      type: complex
      contains:
        field_to_match:
          description: Field on which the regex match is applied.
          type: complex
          contains:
            type:
              description: The field name.
              returned: when type is regex and state is present
              type: str
              sample: QUERY_STRING
        regex_pattern_set_id:
          description: ID of the regex pattern.
          type: str
          sample: 6fdf7f2d-9091-445c-aef2-98f3c051ac9e
        text_transformation:
          description: transformation applied to the text before matching
          type: str
          sample: NONE
    size_constraint_set_id:
      description: ID of the size constraint set.
      returned: when type is size and state is present
      type: str
      sample: de84b4b3-578b-447e-a9a0-0db35c995656
    size_constraints:
      description: List of size constraints to apply.
      returned: when type is size and state is present
      type: complex
      contains:
        comparison_operator:
          description: Comparison operator to apply.
          type: str
          sample: GT
        field_to_match:
          description: Field on which the size constraint is applied.
          type: complex
          contains:
            type:
              description: Field name.
              type: str
              sample: QUERY_STRING
        size:
          description: Size to compare against the field.
          type: int
          sample: 300
        text_transformation:
          description: Transformation applied to the text before matching.
          type: str
          sample: NONE
    sql_injection_match_set_id:
      description: ID of the SQL injection match set.
      returned: when type is sql and state is present
      type: str
      sample: de84b4b3-578b-447e-a9a0-0db35c995656
    sql_injection_match_tuples:
      description: List of SQL injection match sets.
      returned: when type is sql and state is present
      type: complex
      contains:
        field_to_match:
          description: Field on which the SQL injection match is applied.
          type: complex
          contains:
            type:
              description: Field name.
              type: str
              sample: QUERY_STRING
        text_transformation:
          description: Transformation applied to the text before matching.
          type: str
          sample: URL_DECODE
    xss_match_set_id:
      description: ID of the XSS match set.
      returned: when type is xss and state is present
      type: str
      sample: de84b4b3-578b-447e-a9a0-0db35c995656
    xss_match_tuples:
      description: List of XSS match sets.
      returned: when type is xss and state is present
      type: complex
      contains:
        field_to_match:
          description: Field on which the XSS match is applied.
          type: complex
          contains:
            type:
              description: Field name
              type: str
              sample: QUERY_STRING
        text_transformation:
          description: transformation applied to the text before matching.
          type: str
          sample: URL_DECODE
    N)camel_dict_to_snake_dict)is_boto3_error_code)compare_policies)AWSRetry)MATCH_LOOKUP)get_rule_with_backoff) list_regional_rules_with_backoff)list_rules_with_backoff)"run_func_with_change_token_backoff)AnsibleCommunityAWSModulec                       e Zd Zd Zd Zd Z ej                         d        Z ej                         d        Z	d Z
d Zd Zd	 Zd
 Z ej                         d        Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)	Conditionc                    || _         || _        |j                  d   | _        t        | j                     d   | _        t        | j                     d   | _        t        | j                     d   dz   | _        t        | j                     d   dz   | _        t        | j                     d   | _	        t        | j                     d   dz   | _
        t        | j                     d   | _        y )NtypemethodconditionsetsIdconditiontuple)clientmoduleparamsr   r   method_suffixr   conditionsetsconditionsetidr   conditiontuplesconditiontype)selfr   r   s      o/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/aws/plugins/modules/waf_condition.py__init__zCondition.__init__  s    MM&)	)$))4X>(3NC)$))4^DsJ*4995nEL*49956FG+DII67GH3N)$))4V<    c                    t               }t               |d<   | j                  j                  j	                  d      D ]  }| j
                  dk(  r,d|j	                  d      v rd}nd}||j	                  d      d}| j
                  d	k(  rt        d
|j	                  d            }| j
                  dvrt        t        |j	                  d      j                               |j	                  dd      j                               }|j	                  d      j                         dk(  r\|j	                  d      r&|j	                  d      j                         |d   d<   n%| j                  j                  t        d             | j
                  dk(  r(|j	                  d      d<   |j	                  d      |d<   | j
                  dk(  r(|j	                  d      d<   |j	                  d      |d <   | j
                  d!k(  r&| j                  |j	                  d"            d#   d#<   |d   j                  d$d%| j                  i        ||| j                  <   |S )&NUpdatesfiltersip:
ip_addressIPV6IPV4)TypeValuegeoCountrycountry)r%   r,   field_to_match)r*   transformationnone)FieldToMatchTextTransformationHEADERheaderr2   Dataz#DATA required when HEADER requestedmsgbytetarget_stringTargetStringpositionPositionalConstraintsize
comparisonComparisonOperatorSizeregexregex_patternRegexPatternSetIdActionINSERT)dictlistr   r   getr   upperlower	fail_jsonstrensure_regex_pattern_presentappendr   r   )r   condition_set_idkwargsfiltrip_typecondition_inserts         r   format_for_updatezCondition.format_for_update  s2    Fy[[''++I6 +	bEyyD %))L11$G$G,3eii>U#V  yyE!#'Yeii	>R#S  yy-#'!%5995E+F+L+L+N!O',yy1A6'J'P'P'R$ 
 99-.446(Byy*CH99XCVC\C\C^(8@--#6[2\-] yyF"3899_3M 0;@99Z;P !78 yyF"9><9P !56+099V+< ( yyG#8<8Y8YZ_ZcZcdsZt8u'9 !45 9$$h$:M:MO_%`aW+	bZ '7t""#r!   c                     d|| j                      D cg c]  }dd| j                  |i c}| j                  || j                     iS c c}w )Nr#   rE   DELETE)r   r   r   )r   	conditioncurrent_condition_tuples      r   format_for_deletionzCondition.format_for_deletion  s]    /89M9M/N+ 8T%8%8:QR 4+>+>!?
 	
s   Ac                 :     | j                   j                  di |S )N )r   list_regex_pattern_sets)r   r   s     r    list_regex_patterns_with_backoffz*Condition.list_regex_patterns_with_backoff  s    2t{{22<V<<r!   c                 :    | j                   j                  |      S )NrD   )r   get_regex_pattern_set)r   regex_pattern_set_ids     r   "get_regex_pattern_set_with_backoffz,Condition.get_regex_pattern_set_with_backoff  s    {{00CW0XXr!   c                 >   g }i }	 	  | j                   di |}|j                  d          d|v r	|d   |d<   n	 |S 8# t        j                  j                  t        j                  j                  f$ r'}| j
                  j                  |d       Y d }~~d }~ww xY w)NzCould not list regex patternsr7   RegexPatternSets
NextMarkerr\   )r^   botocore
exceptionsClientErrorBotoCoreErrorr   fail_json_awsextend)r   regex_patternsr   responsees        r   list_regex_patternszCondition.list_regex_patterns  s    R@4@@J6J !!(+=">?x''/'=|$  ''33X5H5H5V5VW R))!1P)QQRs   > 7B5BBc                 ~    | j                         }t        d |D              }||v r| j                  ||         d   S y )Nc              3   0   K   | ]  }|d    |d   f  yw)NamerD   Nr\   ).0items     r   	<genexpr>z6Condition.get_regex_pattern_by_name.<locals>.<genexpr>  s     j$T&\40C+DEjs   RegexPatternSet)rp   rG   rc   )r   nameexisting_regex_patternsregex_lookups       r   get_regex_pattern_by_namez#Condition.get_regex_pattern_by_name  sI    "&":":"<jRijj<::<;MNO`aar!   c                 N   |d   }| j                  |      }|s;t        | j                  | j                  d|i| j                  j                        d   }t        |d         t        |d         z
  }t        |d         t        |d         z
  }|s|s|S |D cg c]  }d|d	 }}|j                  |D cg c]  }d|d	 c}       t        | j                  | j                  |d	   |d
| j                  j                  d       | j                  |d	         d   S c c}w c c}w )Nrx   rs   rw   regex_stringsRegexPatternStringsrF   rE   RegexPatternStringrW   rD   rD   r#   Twait)	r{   r   r   r   create_regex_pattern_setsetrl   update_regex_pattern_setrc   )r   rC   rx   pattern_setmissingextrapatternupdatess           r   rN   z&Condition.ensure_regex_pattern_present  s-   V$44T:<T[[64.$++:^:^!K mO45KH]<^8__K 567#mO>\:]]uV]^7hgF^^[`aPW87Kab*KKKK"-.A"BwWKK00	
 66{CV7WXYjkk _as   D5D"c                 Z   	 | j                   j                  |      d   }t               }|d   D ]  }|j                  d|d        t	        | j                   | j
                  ||d| j                   j                         t	        | j                   | j
                  d|i| j                   j                  d	       y # t        d
      $ r Y y t        j                  j                  t        j                  j                  f$ r'}| j
                  j                  |d       Y d }~y d }~ww xY w)Nr`   rw   r~   rW   r   r   rD   Tr   WAFNonexistentItemExceptionzCould not delete regex patternr7   )r   ra   rH   rO   r   r   r   delete_regex_pattern_setr   rg   rh   ri   rj   rk   )r   rb   regex_pattern_setr   regex_pattern_stringro   s         r   delete_unused_regex_patternz%Condition.delete_unused_regex_pattern%  s   	O $ A ATh A i!! fG(9:O(P a$(J^_`a.&:wO44	 /$&:;44 ##@A 	++--
 	O KK%%a-M%NN		Os   B:B= =D*6D*D%%D*c                     | j                         D cg c]  }|d   |k(  s| }}|r|d   | j                     S y c c}w )Nrs   r   )list_conditionsr   )r   rx   dall_conditionss       r   get_condition_by_namezCondition.get_condition_by_nameC  sM    %)%9%9%;QqyD?P!QQ!!$T%8%899  Rs   <<c                     t               }||| j                  <   t        | j                  d| j                  z         } |di || j
                     S )Nget_r\   )rG   r   getattrr   r   r   )r   rP   r   funcs       r    get_condition_by_id_with_backoffz*Condition.get_condition_by_id_with_backoffH  sK    &6t""#t{{FT-?-?$?@~f~d//00r!   c                     	 | j                  |      S # t        j                  j                  t        j                  j                  f$ r'}| j
                  j                  |d       Y d }~y d }~ww xY w)NzCould not get conditionr7   )r   rg   rh   ri   rj   r   rk   )r   rP   ro   s      r   get_condition_by_idzCondition.get_condition_by_idO  sd    	H889IJJ##//1D1D1R1RS 	HKK%%a-F%GG	Hs    7A1
A,,A1c                    d| j                   z   dz   }	 | j                  j                  |      }|j                         j                  }	  |       | j                     S # t
        j                  j                  $ r t        | j                  |      }Y Jw xY w# t
        j                  j                  t
        j                  j                  f$ r5}| j                  j                  |d| j                   d       Y d }~y d }~ww xY w)Nlist_r   zCould not list z conditionsr7   )r   r   get_paginatorpaginatebuild_full_resultrg   rh   OperationNotPageableErrorr   r   ri   rj   r   rk   r   )r   r   	paginatorr   ro   s        r   r   zCondition.list_conditionsU  s    4---3	011&9I%%'99D	W6$,,--	 ""<< 	04;;/D	0
 ##//1D1D1R1RS 	WKK%%atyyk-U%VV	Ws)   5A 
B 3BB7D+C>>Dc                 (   | j                         }t               }|D ]C  }|j                  d | j                  || j                           | j
                     D               E || j
                     D ]  }|d   |vs| j                  |d            y )Nc              3   &   K   | ]	  }|d      yw)rD   Nr\   )rt   r   s     r   rv   z3Condition.tidy_up_regex_patterns.<locals>.<genexpr>f  s      *" 23*s   rD   )r   rH   rl   r   r   r   r   )r   regex_match_setall_regex_match_setsall_match_set_patternsrmsrR   s         r   tidy_up_regex_patternsz Condition.tidy_up_regex_patternsb  s    #335!%' 	C")) *&*&>&>s4CVCV?W&XY]YmYm&n* 	
 %T%9%9: 	ME()1GG007J1KL	Mr!   c                    g }	 | j                   j                  j                  dk(  rt        | j                         }n8| j                   j                  j                  dk(  rt	        | j                         }D ]I  }	 t        | j                   |d         }|d   D cg c]  }|d   	 c}v s6|j                  |d	          K |S # t
        j                  j                  t
        j                  j                  f$ r'}| j                  j                  |d       Y d }~d }~ww xY w# t
        j                  j                  t
        j                  j                  f$ r'}| j                  j                  |d       Y d }~d }~ww xY wc c}w )
NWAFWAFRegionalzCould not list rulesr7   RuleIdzCould not get rule details
PredicatesDataIdrs   )r   	__class____name__r
   r	   rg   rh   ri   rj   r   rk   r   rO   )r   rP   rules_in_use	all_rulesro   rulerule_details	predicates           r   find_condition_in_rulesz!Condition.find_condition_in_rulesn  sX   	E{{$$--63DKK@	&&//=@<T[[I	  	:DO4T[[$x.Q  VbIc#dIIh$7#dd##L$89	:  ##//1D1D1R1RS 	EKK%%a-C%DD	E
 ''33X5H5H5V5VW O))!1M)NNO#ds6   A1C ;D&F7D#<DD#&7FE??Fc                    | j                  |      }| j                  |      }|r6dj                  |      }| j                  j	                  d|d    d|        || j
                     rWt        | j                  d| j                  z         }| j                  |      }	 t        | j                  | j                  ||       t        | j                  d| j                  z         }t!               }||| j"                  <   	 t        | j                  | j                  ||d	
       | j$                  dk(  r| j'                  |       d	i fS # t        j                  j                  t        j                  j                  f$ r'}| j                  j                  |d       Y d }~d }~ww xY w# t        j                  j                  t        j                  j                  f$ r'}| j                  j                  |d       Y d }~d }~ww xY w)Nz, z
Condition rs   z is in use by r7   update_z'Could not delete filters from conditiondelete_Tr   zCould not delete conditionrB   )r   r   joinr   rL   r   r   r   r   rZ   r   rg   rh   ri   rj   rk   rG   r   r   r   )r   rP   current_conditionin_use_rules	rulenamesr   r   ro   s           r   find_and_delete_conditionz#Condition.find_and_delete_condition  s    445EF334DE		,/IKK!!
3DV3L2M^\e[f&g!hT1124;;	D4F4F(FGD--.?@F\24;;VUYZ t{{I0B0B$BC&6t""#	K.t{{DKKQU\`a 99''(9:Rx ''33X5H5H5V5VW \))!1Z)[[\ ##//1D1D1R1RS 	KKK%%a-I%JJ	Ks0   "E >$F' 7F$=FF$'7HH  Hc                     g }|d   D ]L  }d}|| j                      }|| j                     }|D ]  }t        ||      rd} |r<|j                  |       N |S )Nr#   FT)r   r   r   rO   )	r   updater   r   desiredfounddesired_conditioncurrent_conditionsrX   s	            r   find_missingzCondition.find_missing  sy    i( 	(GE '(;(; <!243G3G!H/ !	'	3DE E! w'	( r!   c           
         | j                  |      }| j                  |      }| j                  ||      }| j                  j                  j                  d      rO|| j                     D cg c]4  }||d   D cg c]  }|| j                      c}vrdd| j                  |i6 }}}ng }t        |xs |      }|rP||z   |d<   t        | j                  d| j                  z         }		 t        | j                  | j                  ||	d       || j                  |      fS c c}w c c}}w # t        j                  j                  t        j                  j                   f$ r'}
| j                  j#                  |
d	       Y d }
~
wd }
~
ww xY w)
Npurge_filtersr#   rE   rW   r   Tr   zCould not update conditionr7   )r   rU   r   r   r   rI   r   r   boolr   r   r   r   rg   rh   ri   rj   rk   )r   rP   r   r   r   current_tupler   r   changedr   ro   s              r   find_and_update_conditionz#Condition.find_and_update_condition  s    445EF''(89##F,=>;;!!/2 &7t7K7K%L! U[\eUf(g'1D1D)E(gg 8T%8%8-HE  Ew'%( '%F94;;	D4F4F(FGDO24;;VUY`de 001ABBB )h ''33X5H5H5V5VW O))!1M)NNOs0   ,D$9DD$($D* D$*7F!FFc                 >   | j                   j                  d   }| j                  |      }|r| j                  |      S t	               }||d<   t        | j                  d| j                  z         }	 t        | j                  | j                   ||      }| j                  | j                     | j                           S # t        j                  j                  t        j                  j                  f$ r'}| j                   j                  |d       Y d }~d }~ww xY w)Nrx   rs   create_zCould not create conditionr7   )r   r   r   r   rG   r   r   r   r   rg   rh   ri   rj   rk   r   r   )r   rx   rP   r   r   rX   ro   s          r   ensure_condition_presentz"Condition.ensure_condition_present  s    {{!!&)55d;112BCCVF!F6N4;;	D4F4F(FGDO>t{{DKKY_aef	 11)D<M<M2NtObOb2cdd ''33X5H5H5V5VW O))!1M)NNOs   1"B> >7D5DDc                     | j                  | j                  j                  d         }|r| j                  |      S di fS )Nrx   F)r   r   r   r   )r   rP   s     r   ensure_condition_absentz!Condition.ensure_condition_absent  sA    55dkk6H6H6PQ112BCCbyr!   N)r   
__module____qualname__r    rU   rZ   r   exponential_backoffr^   rc   rp   r{   rN   r   r   r   r   r   r   r   r   r   r   r   r   r\   r!   r   r   r     s    
=3j
 "X!!#= $= "X!!#Y $Y l.O<:
 "X!!#1 $1HW
M$6C,er!   r   c                  P   t        t               t        g d      t               t        g d      t        g d      t        g d      t               t        d      t               t        dt        t               t        d	d
                  
      } t        t        d      t        dg d      t        d	d|       t        dd      t        dd      t        dddg            }t        |dddggg      }|j                  j                  d      }|j                  d   sdnd }|j	                  |      }t        ||      }|dk(  r&|j                         \  }}||j                     |d!<   n|j                         \  }}|j                  |t        |      "       y )#N)uriquery_stringr5   r   body)choices)r1   compress_white_spacehtml_entity_decode	lowercasecmd_line
url_decode)exactlystarts_with	ends_withcontainscontains_word)EQNELELTGEGTint)r   rG   rH   rM   )r   elements)rx   r}   )r   options)
r.   r/   r5   r0   r<   r?   r:   r>   r'   rC   T)required)r9   r,   r%   rB   r>   sqlxss)r   r   )r   r   r   r   F)r   defaultpresentabsent)r   r   )rx   r   r$   r   waf_regionalstater   r$   )argument_specrequired_ifr   wafzwaf-regionalConditionId)r   rX   )rG   AnsibleAWSModuler   rI   r   r   r   r   r   	exit_jsonr   )	filters_subspecr   r   r   resourcer   rX   r   resultss	            r   mainr     s|   $WXvq
 bc DEfu6V"?
O( 4 4)]^&6?K6vu59y(.CDM #y9+67F MMg&E"MM.9u~H]]8$F&&)I	&??A'!()A)A!B&>>@'
W0H0QRr!   __main__)DOCUMENTATIONEXAMPLESRETURNrg   ImportError0ansible.module_utils.common.dict_transformationsr   <ansible_collections.amazon.aws.plugins.module_utils.botocorer   :ansible_collections.amazon.aws.plugins.module_utils.policyr   ;ansible_collections.amazon.aws.plugins.module_utils.retriesr   7ansible_collections.amazon.aws.plugins.module_utils.wafr   r   r	   r
   r   >ansible_collections.community.aws.plugins.module_utils.modulesr   r   objectr   r   r   r\   r!   r   <module>r     s   CJAF~
@	 V \ W P P Y d [ f xn nb	/Sd zF i  		s   A$ $A,+A,