
    ]gD                        S r SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKJ	r	  SSK
Jr  SSKJr  SSKJr  SSKJrJrJrJr  SrS	rS
r\R0                  " S5      rS"S jr " S S5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r  " S S\5      r! " S S\ \5      r" " S S\ 5      r# " S S \!\5      r$\\\\"\#\$S!.r%g)#a  Protocol input serializes.

This module contains classes that implement input serialization
for the various AWS protocol types.

These classes essentially take user input, a model object that
represents what the expected input should look like, and it returns
a dictionary that contains the various parts of a request.  A few
high level design decisions:


* Each protocol type maps to a separate class, all inherit from
  ``Serializer``.
* The return value for ``serialize_to_request`` (the main entry
  point) returns a dictionary that represents a request.  This
  will have keys like ``url_path``, ``query_string``, etc.  This
  is done so that it's a) easy to test and b) not tied to a
  particular HTTP library.  See the ``serialize_to_request`` docstring
  for more details.

Unicode
-------

The input to the serializers should be text (str/unicode), not bytes,
with the exception of blob types.  Those are assumed to be binary,
and if a str/unicode type is passed in, it will be encoded as utf-8.
    N)ElementTree)validate)
formatdate)ParamValidationError)
has_headeris_json_value_headerparse_to_aware_datetimepercent_encodeiso8601z%Y-%m-%dT%H:%M:%SZz%Y-%m-%dT%H:%M:%S.%fZz^[A-Za-z0-9\.\-]+$c                     [         U    " 5       nU(       a+  [        R                  " 5       n[        R                  " X25      nU$ N)SERIALIZERSr   ParamValidatorParamValidationDecorator)protocol_nameinclude_validation
serializer	validators       4/usr/lib/python3/dist-packages/botocore/serialize.pycreate_serializerr   D   s6    ]+-J++-	66yM
    c                   Z    \ rS rSrSr\rSrS rS r	S r
S rS rSS
 jrS rS rS rSrg	)
SerializerM   POSTutf-8c                     [        S5      e)a  Serialize parameters into an HTTP request.

This method takes user provided parameters and a shape
model and serializes the parameters to an HTTP request.
More specifically, this method returns information about
parts of the HTTP request, it does not enforce a particular
interface or standard for an HTTP request.  It instead returns
a dictionary of:

    * 'url_path'
    * 'host_prefix'
    * 'query_string'
    * 'headers'
    * 'body'
    * 'method'

It is then up to consumers to decide how to map this to a Request
object of their HTTP library of choice.  Below is an example
return value::

    {'body': {'Action': 'OperationName',
              'Bar': 'val2',
              'Foo': 'val1',
              'Version': '2014-01-01'},
     'headers': {},
     'method': 'POST',
     'query_string': '',
     'host_prefix': 'value.',
     'url_path': '/'}

:param parameters: The dictionary input parameters for the
    operation (i.e the user input).
:param operation_model: The OperationModel object that describes
    the operation.
serialize_to_requestNotImplementedError)self
parametersoperation_models      r   r   Serializer.serialize_to_requestV   s    H ""899r   c                 *    SSU R                   0 SS.nU$ )N/ r   )url_pathquery_stringmethodheadersbody)DEFAULT_METHOD)r!   
serializeds     r   _create_default_request"Serializer._create_default_request|   s(     ))

 r   c                 ^    UR                   S:  a  [        nO[        nUR                  U5      $ )Nr   )microsecondISO8601_MICROISO8601strftime)r!   valuetimestamp_formats      r   _timestamp_iso8601Serializer._timestamp_iso8601   s,    q ,&~~.//r   c                 \    [        [        R                  " UR                  5       5      5      $ r   )intcalendartimegm	timetupler!   r6   s     r   _timestamp_unixtimestamp#Serializer._timestamp_unixtimestamp   s    8??5??#4566r   c                 v    [        U[        R                  5      (       a  U R                  U5      n[        USS9$ )NT)usegmt)
isinstancedatetimer@   r   r?   s     r   _timestamp_rfc822Serializer._timestamp_rfc822   s2    eX..//11%8E%--r   Nc                     Uc  U R                   nUR                  5       n[        U5      n[        U SU 35      nU" U5      nU$ )N_timestamp_)TIMESTAMP_FORMATlowerr	   getattr)r!   r6   r7   datetime_obj	converterfinal_values         r   _convert_timestamp_to_str$Serializer._convert_timestamp_to_str   sR    ##44+113.u5DK0@/A"BC	-r   c                 :    UR                   R                  SU5      $ Nnameserializationget)r!   shapedefault_names      r   _get_serialized_nameSerializer._get_serialized_name   s     ""&&v|<<r   c                     [        U[        5      (       a  UR                  U R                  5      n[        R
                  " U5      R                  5       R                  U R                  5      $ r   )rD   strencodeDEFAULT_ENCODINGbase64	b64encodestripdecoder?   s     r   _get_base64Serializer._get_base64   sP     eS!!LL!6!67E&,,.55d6K6KLLr   c                    UR                   nUb  SU;  a  g US   nUR                  R                  nUR                  5        VVs/ s H)  u  pgUR                  R                  S5      (       d  M'  UPM+     nnn0 n	/ n
U H6  nX   n[        R                  U5      (       d  U
R                  U5        XU'   M8     U
(       a  [        SSR                  U
5       S3S9eUR                  " S0 U	D6$ s  snnf )N
hostPrefix	hostLabelz Invalid value for parameter(s): z, z?. Must contain only alphanumeric characters, hyphen, or period.)report )endpointinput_shapemembersitemsrV   rW   HOST_PREFIX_REmatchappendr   joinformat)r!   r"   r#   operation_endpointhost_prefix_expressioninput_membersmemberrX   host_labelsformat_kwargs
bad_labelsrT   params                r   _expand_host_prefixSerializer._expand_host_prefix   s   ,55&#55!3L!A'33;; "/!4!4!6
!6""&&{3 !6 	 

 
D$E!''..!!$'"'$	  
 &6tyy7L6M N! !  &,,=}==)
s   &C-/C-rj   r   )__name__
__module____qualname____firstlineno__r-   dictMAP_TYPEr_   r   r/   r8   r@   rF   rP   rZ   rd   r|   __static_attributes__rj   r   r   r   r   M   sC    N
 H$:L07.
=
M>r   r   c                   t    \ rS rSrSrS rSS jrSS jrSS jrSS jr	SS jr
SS	 jrSS
 jrSS jrS rSrg)QuerySerializer   r   c                 b   UR                   nU R                  5       nUR                  R                  SU R                  5      US'   SS0US'   U R                  5       nUR                  US'   UR                  S   US'   Ub  U R                  XQU5        XTS'   U R                  X5      nUb  XdS	'   U$ )
Nr*   Content-Typez0application/x-www-form-urlencoded; charset=utf-8r+   Action
apiVersionVersionr,   host_prefix)
rl   r/   httprW   r-   r   rT   metadata
_serializer|   )r!   r"   r#   rX   r.   body_paramsr   s          r   r   $QuerySerializer.serialize_to_request   s    ++113
.3377d)) 

8 N!

9
 mmo / 4 4H!0!9!9,!GIOOKU;(6..zK"(3}%r   c                 Z    [        U SUR                   3U R                  5      nU" XX4S9  g )N_serialize_type_)prefixrL   	type_name_default_serialize)r!   r.   r6   rX   r   r*   s         r   r   QuerySerializer._serialize   s5     u/0##

 	z%7r   c                     UR                   nUR                  5        H:  u  pbXV   nU R                  Xv5      nU(       a  U SU 3nU R                  XXx5        M<     g )N.)rm   rn   rZ   r   )	r!   r.   r6   rX   r   rm   keymember_shapemember_prefixs	            r   _serialize_type_structure)QuerySerializer._serialize_type_structure   sU    --++-JC"<L 55lHM#)(!M? ;OOJ|K (r   c                    U(       d  SX'   g U R                  U5      (       an  UnUR                  R                  R                  S5      (       aA  U R	                  UR                  SS9nSR                  UR                  S5      S S U/-   5      nO-UR                  R                  R                  SS5      nU SU 3n[        US5       H*  u  pU SU 3n
UR                  nU R                  XX5        M,     g )Nr'   rT   rY   r   rw      )	_is_shape_flattenedrw   rV   rW   rZ   rr   split	enumerater   )r!   r.   r6   rX   r   list_prefixrT   	list_nameielementelement_prefixelement_shapes               r   _serialize_type_list$QuerySerializer._serialize_type_list  s    !#J##E** K||))--f5500B0O!hhv||C'8"'='FG2266vxHI#HAi[1K#E1-JA +}AaS1N!LLMOOJO .r   c                 r   U R                  U5      (       a  UnOU S3nUS-   nUR                  nUR                  nU R                  USS9n	U R                  US5      n
[	        US5       HJ  u  pUR                  XS9nUR                  XS9nU R                  XX}5        U R                  XU   X5        ML     g )Nz.entryz.{i}.{suffix}r   r   r6   r   )r   suffix)r   r   r6   rZ   r   rs   r   )r!   r.   r6   rX   r   full_prefixtemplate	key_shapevalue_shape
key_suffixvalue_suffixr   r   
key_prefixvalue_prefixs                  r   _serialize_type_map#QuerySerializer._serialize_type_map  s    ##E** K#HF+K0II	kk..yu.M
00gFq)FA!1@J#??Q?DLOOJYCOOJc
KN	 *r   c                 *    U R                  U5      X'   g r   rd   r!   r.   r6   rX   r   s        r   _serialize_type_blob$QuerySerializer._serialize_type_blob'  s    !--e4
r   c                 \    U R                  X#R                  R                  S5      5      X'   g NtimestampFormatrP   rV   rW   r   s        r   _serialize_type_timestamp)QuerySerializer._serialize_type_timestamp+  s*    !;;&&**+<=

r   c                 $    U(       a  SX'   g SX'   g Ntruefalserj   r   s        r   _serialize_type_boolean'QuerySerializer._serialize_type_boolean0  s    !'J!(Jr   c                     X!U'   g r   rj   r   s        r   r   "QuerySerializer._default_serialize6  s
    "6r   c                 8    UR                   R                  S5      $ )N	flattenedrU   r!   rX   s     r   r   #QuerySerializer._is_shape_flattened9  s    ""&&{33r   rj   Nr'   )r~   r   r   r   rJ   r   r   r   r   r   r   r   r   r   r   r   rj   r   r   r   r      s=     08LP&O 5

)#4r   r   c                   (    \ rS rSrSrS rSS jrSrg)EC2Serializeri=  aA  EC2 specific customizations to the query protocol serializers.

The EC2 model is almost, but not exactly, similar to the query protocol
serializer.  This class encapsulates those differences.  The model
will have be marked with a ``protocol`` of ``ec2``, so you don't need
to worry about wiring this class up correctly.

c                     SUR                   ;   a  UR                   S   $ SUR                   ;   a(  UR                   S   nUS   R                  5       USS  -   $ U$ )N	queryNamerT   r   r   )rV   upper)r!   rX   rY   rT   s       r   rZ   "EC2Serializer._get_serialized_nameG  sd     %---&&{33u*** &&v.D7==?T!"X--r   c                 x    [        US5       H*  u  pVU SU 3nUR                  nU R                  XX5        M,     g )Nr   r   )r   rw   r   )	r!   r.   r6   rX   r   r   r   r   r   s	            r   r   "EC2Serializer._serialize_type_listT  s;    #E1-JA &xq_N!LLMOOJO .r   rj   Nr   )r~   r   r   r   __doc__rZ   r   r   rj   r   r   r   r   =  s     Pr   r   c                   L    \ rS rSrSrS rSS jrS rS rS r	S	 r
S
 rS rSrg)JSONSerializeri[  unixtimestampc                    SR                  UR                  S   UR                  5      nUR                  S   nU R                  5       nUR                  R                  SU R                  5      US'   USU 3S.US'   U R                  5       nUR                  nUb  U R                  XaU5        [        R                  " U5      R                  U R                  5      US'   U R                  X5      nUb  XS	'   U$ )
Nz{}.{}targetPrefixjsonVersionr*   zapplication/x-amz-json-)zX-Amz-Targetr   r+   r,   r   )rs   r   rT   r/   r   rW   r-   r   rl   r   jsondumpsr^   r_   r|   )	r!   r"   r#   targetjson_versionr.   r,   rl   r   s	            r   r   #JSONSerializer.serialize_to_request^  s    $$^4  
 '//>113
.3377d)) 

8 #5l^D!

9 }}%11"OODk:!ZZ-44T5J5JK
6..zK"(3}%r   Nc                 ^    [        U SUR                   3U R                  5      nU" XX45        g Nr   r   r!   r.   r6   rX   r   r*   s         r   r   JSONSerializer._serializex  s3    u/0##

 	z%-r   c                    UR                   (       a  X!U'   g Ub  U R                  5       nXQU'   UnUR                  nUR                  5        H:  u  pxXg   n	SU	R                  ;   a  U	R                  S   nU R                  XX5        M<     g rS   )is_document_typer   rm   rn   rV   r   )
r!   r.   r6   rX   r   new_serializedrm   
member_keymember_valuer   s
             r   r   (JSONSerializer._serialize_type_structure  s    !!#sO "&"03+
mmG,1KKM(
&2\777!-!;!;F!CJl	 -:r   c                     U R                  5       nXQU'   UR                  5        H"  u  pgU R                  XWUR                  U5        M$     g r   )r   rn   r   r6   )r!   r.   r6   rX   r   map_objsub_key	sub_values           r   r   "JSONSerializer._serialize_type_map  s;    --/!3"'++-GOOGWE #0r   c                     / nXQU'   U H6  n0 nU R                  XvUR                  S5        UR                  US   5        M8     g )N__current__)r   rw   rq   )r!   r.   r6   rX   r   list_obj	list_itemwrappers           r   r   #JSONSerializer._serialize_type_list  sD    "3IG
 OOGmLOOGM23 r   c                     X!U'   g r   rj   r!   r.   r6   rX   r   s        r   r   !JSONSerializer._default_serialize  s	    3r   c                 \    U R                  X#R                  R                  S5      5      X'   g r   r   r   s        r   r   (JSONSerializer._serialize_type_timestamp  s)    88&&**+<=

r   c                 *    U R                  U5      X'   g r   r   r   s        r   r   #JSONSerializer._serialize_type_blob  s    **51
r   rj   r   )r~   r   r   r   rJ   r   r   r   r   r   r   r   r   r   rj   r   r   r   r   [  s1    &4.,F
4 

2r   r   c                       \ rS rSrSrSrSrSrSrSr	Sr
S	rSS jrS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rSrg
)CBORSerializeri  r   r                     Nc                     [        U SUR                   35      nUc  [        SUR                   S35      eU" XX45        g )Nr   zUnrecognized C2J type: z, unable to serialize request)rL   r   
ValueErrorr   s         r   _serialize_data_item#CBORSerializer._serialize_data_item  sO    !1%//1BCD>)%//): ;$ %  	z%-r   c                 
   US:  a  U R                   nOU R                  nSU-
  nU R                  U5      u  pgU R                  XV5      nUS:X  a  UR	                  U5        g UR	                  XR                  US5      -   5        g )Nr   r   big)UNSIGNED_INT_MAJOR_TYPENEGATIVE_INT_MAJOR_TYPE"_get_additional_info_and_num_bytes_get_initial_byteextendto_bytes)	r!   r.   r6   rX   r   
major_typeadditional_info	num_bytesinitial_bytes	            r   _serialize_type_integer&CBORSerializer._serialize_type_integer  s    A:55J55J JE%)%L%L&
" --jJ>l+l^^Iu-MMNr   c                 (    U R                  XX45        g r   )r  r   s        r   _serialize_type_long#CBORSerializer._serialize_type_long  s    $$ZCr   c                    [        U[        5      (       a  UR                  S5      nO+[        U[        [        45      (       d  UR                  5       n[        U5      nU R                  U5      u  pgU R                  U R                  U5      nUS:X  a  UR                  U5        O#UR                  XR                  US5      -   5        UR                  U5        g Nr   r   r  )rD   r]   r^   bytes	bytearrayreadlenr  r  BLOB_MAJOR_TYPEr  r  )	r!   r.   r6   rX   r   lengthr  r  r  s	            r   r   #CBORSerializer._serialize_type_blob  s    eS!!LL)EEE9#566 JJLEU%)%L%L&
" --  /
 >l+l__Y-NNO% r   c                    UR                  S5      n[        U5      nU R                  U5      u  pxU R                  U R                  U5      n	US:X  a  UR                  X-   5        g UR                  XR                  US5      -   U-   5        g r"  )r^   r&  r  r  STRING_MAJOR_TYPEr  r  )
r!   r.   r6   rX   r   encodedr(  r  r  r  s
             r   _serialize_type_string%CBORSerializer._serialize_type_string  s    ,,w'W%)%L%L&
" --""O
 >l45y%@@7Jr   c                 8   [        U5      nU R                  U5      u  pgU R                  U R                  U5      nUS:X  a  UR	                  U5        O#UR	                  XR                  US5      -   5        U H  n	U R                  XUR                  5        M!     g Nr   r  )r&  r  r  LIST_MAJOR_TYPEr  r  r  rw   )
r!   r.   r6   rX   r   r(  r  r  r  items
             r   r   #CBORSerializer._serialize_type_list   s    U%)%L%L&
" --  /
 >l+l__Y-NNOD%%jE r   c                    [        U5      nU R                  U5      u  pgU R                  U R                  U5      nUS:X  a  UR	                  U5        O#UR	                  XR                  US5      -   5        UR                  5        H=  u  pU R                  XUR                  5        U R                  XUR                  5        M?     g r0  )
r&  r  r  MAP_MAJOR_TYPEr  r  rn   r  r   r6   )r!   r.   r6   rX   r   r(  r  r  r  key_itemr2  s              r   r   "CBORSerializer._serialize_type_map  s    U%)%L%L&
" --
 >l+l__Y-NNO#kkmNH%%jEIIF%%jD ,r   c                 n   Ub  U R                  XUR                  5        UR                  5        VVs0 s H  u  pVUc  M
  XV_M     nnn[        U5      nU R	                  U5      u  pU R                  U R                  U5      n
U	S:X  a  UR                  U
5        O#UR                  XR                  U	S5      -   5        UR                  nUR                  5        HR  u  pX   nSUR                  ;   a  UR                  S   nUc  M-  U R                  XS S 5        U R                  XU5        MT     g s  snnf )Nr   r  rT   )r  r   rn   r&  r  r  r5  r  r  rm   rV   r-  )r!   r.   r6   rX   r   kv
map_lengthr  r  r  rm   r   r   r   s                  r   r   (CBORSerializer._serialize_type_structure  s(   ?%%juG #(++-A-$!1-AZ
%)%L%L&
" --
 >l+229eDD --(-$J".L333)77?
'++JD$O))l )6# Bs   	D1 D1c                    U R                  U5      nSnU R                  U R                  U5      nUR                  U5        U R	                  U5      u  pU	S:X  a.  U R                  U R
                  U5      nUR                  U5        g U R                  U R
                  U5      nUR                  XuR                  U	S5      -   5        g )Nr   r   r  )rP   r  TAG_MAJOR_TYPEr  r  r  r  )
r!   r.   r6   rX   r   	timestamptagr  r  r  s
             r   r   (CBORSerializer._serialize_type_timestamp@  s    2259	--d.A.A3G,'%)%L%L&
" >11,,iL l+11,,oL 11)UCCr   c                     U R                  U5      (       a!  UR                  U R                  U5      5        g U R                  U R                  S5      nUR                  U[
        R                  " SU5      -   5        g )N   z>f_is_special_numberr  _get_bytes_for_special_numbersr  FLOAT_AND_SIMPLE_MAJOR_TYPEstructpackr!   r.   r6   rX   r   r  s         r   _serialize_type_float$CBORSerializer._serialize_type_floatV  l    ""5))33E:  1100"L lV[[u-EEFr   c                     U R                  U5      (       a!  UR                  U R                  U5      5        g U R                  U R                  S5      nUR                  U[
        R                  " SU5      -   5        g )N   z>drD  rJ  s         r   _serialize_type_double%CBORSerializer._serialize_type_doublea  rM  r   c                 p    U(       a  SOSnUR                  U R                  U R                  U5      5        g )N      )r  r  rG  )r!   r.   r6   rX   r   r  s         r   r   &CBORSerializer._serialize_type_booleanl  s2     %"2""00/	
r   c                 B    US:  a  US4$ US:  a  gUS:  a  gUS:  a  gg	)
N   r      )rW  r   i   )   r  l        )rC  r  )rO     rj   r?   s     r   r  1CBORSerializer._get_additional_info_and_num_bytest  s>     2:!8O S[ U] Z r   c                 4    US-  nX2-  R                  SS5      $ )Nr	  r   r  )r  )r!   r  r  major_type_bytess       r   r   CBORSerializer._get_initial_byte  s$     &? 2<<QFFr   c                 v    [        U[        S5      :H  U[        S5      :H  [        R                  " U5      /5      $ )Ninf-inf)anyfloatmathisnanr?   s     r   rE  !CBORSerializer._is_special_number  s8    u%v&

5!
 	
r   c                 N   SnU R                  U R                  U5      nU[        S5      :X  a  U[        R                  " SS5      -   $ U[        S5      :X  a  U[        R                  " SS5      -   $ [
        R                  " U5      (       a  U[        R                  " SS5      -   $ g )NrY  r`  z>Hi |  ra  i   i ~  )r  rG  rc  rH  rI  rd  re  )r!   r6   r  r  s       r   rF  -CBORSerializer._get_bytes_for_special_numbers  s    --,,o
 E%L &++dF";;;eFm#&++dF";;;ZZ&++dF";;; r   rj   r   )r~   r   r   r   r  r  r'  r+  r1  r5  r>  rG  r  r  r  r   r-  r   r   r   r   rK  rP  r   r  r  rE  rF  r   rj   r   r   r  r    s    OONN"#.O$D!( FE B,	G	G
,G

<r   r  c                   p    \ rS rSrSrSrSr/ SQrS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rSrg)BaseRestSerializeri  a)  Base class for rest protocols.

The only variance between the various rest protocols is the
way that the body is serialized.  All other aspects (headers, uri, etc.)
are the same and logic for serializing those aspects lives here.

Subclasses must implement the ``_serialize_body_params`` method.

r   rfc822)uriquerystringheaderr+   c                    U R                  5       nUR                  R                  SU R                  5      US'   UR                  nUc  UR                  S   US'   U$ UR
                  nU R                  5       U R                  5       U R                  5       U R                  5       S.nUR                  5        H  u  pxUc  M
  U R                  XgX5        M     U R                  UR                  S   US   5      US'   SUR                  ;   a%  U R                  UR                  S   US   5      US'   US   US	'   US
   (       a  US
   US
'   U R                  XaX4U5        U R                  X4U5        U R                  X5      n	U	b  XS'   U$ )Nr*   
requestUrir(   )uri_path_kwargsquery_string_kwargsbody_kwargsr+   rq  authPath	auth_pathrr  r)   r+   r   )r/   r   rW   r-   rl   rm   r   rn   _partition_parameters_render_uri_template_serialize_payload_serialize_content_typer|   )
r!   r"   r#   r.   rX   shape_memberspartitioned
param_nameparam_valuer   s
             r   r   'BaseRestSerializer.serialize_to_request  s   113
.3377d)) 

8  ++=%4%9%9,%GJz"  $}}#'==?==?}}	
 (2'7'7'9#J"&&	 (: "&!:!:  .<M0N"

: ---&*&?&?$$Z0-.'J{# &11F%G
>"y!$/	$:Jy!Z	
 	$$ZF..zK"(3}%r   c                     0 n[         R                  " SU5       H;  nUR                  S5      (       a  [        X$S S    SS9X4'   M,  [        X$   5      X4'   M=     UR                  " S0 UD6$ )Nz{(.*?)}+r   z/~)saferj   )refindallendswithr
   rs   )r!   uri_templateparamsencoded_paramstemplate_params        r   rw  'BaseRestSerializer._render_uri_template  sx      jj\BN&&s++1?#2./d2. 2@*2. C ""4^44r   c                    UR                   R                  S5      nU R                  Xe5      (       a(  UR                  US5      nU R                  U5      nXsS'   g Ub@  UR                  U5      nUb  U R	                  XU   5      US'   g U R                  5       US'   g US   (       a  U R	                  US   U5      US'   g U R                  U5      (       a  U R                  5       US'   g g )Npayloadr   r,   rs  )rV   rW   _has_streaming_payload_encode_payload_serialize_body_params_serialize_empty_body_requires_empty_body)	r!   r{  r"   r.   rX   rz  payload_memberbody_payloadr   s	            r   rx  %BaseRestSerializer._serialize_payload  s     ,,00;&&~EE &>>.#>L//=L!-v' %..8K&%)%@%@~!>&
6" &*%?%?%A
6"'!%!<!<M*E"Jv &&u--!%!;!;!=Jv .r   c                     g)Nr   rj   r!   s    r   r  (BaseRestSerializer._serialize_empty_body&  s    r   c                     g)z
Some protocols require varied Content-Type headers
depending on user input. This allows subclasses to apply
this conditionally.
Nrj   )r!   r.   rX   rz  s       r   ry  *BaseRestSerializer._serialize_content_type)  s     	r   c                     g)z{
Some protocols require a specific body to represent an empty
payload. This allows subclasses to apply this conditionally.
Frj   r   s     r   r  'BaseRestSerializer._requires_empty_body1  s    
 r   c                 :    USL=(       a    X!   R                   S;   $ )z5Determine if payload is streaming (a blob or string).N)blobstring)r   )r!   r  rz  s      r   r  )BaseRestSerializer._has_streaming_payload8  s*    d" 
}'='G'G L
 (
 	
r   c                 f    [        U[        5      (       a  UR                  U R                  5      $ U$ r   )rD   r]   r^   r_   )r!   r,   s     r   r  "BaseRestSerializer._encode_payload?  s)    dC  ;;t4455r   c                    XB   nUR                   R                  S5      nUR                   R                  SU5      nUS:X  a  X1S   U'   g US:X  a  [        U[        5      (       a  US   R	                  U5        g [        U[
        5      (       a!  [        U5      R                  5       nXS   U'   g UR                  S:X  a?  UR                   R                  SU R                  5      n	U R                  X95      n
XS   U'   g X1S   U'   g US	:X  a?  XB   nU(       d  UR                  S
:X  a  g U R                  X5      n[        U5      US   U'   g US:X  a  UnU R                  XS   U5        g X1S   U'   g )NlocationrT   rl  rq  rm  rr  r?  r   rn  listr+   rs  )rV   rW   rD   r   updateboolr]   rK   r   QUERY_STRING_TIMESTAMP_FORMATrP   _convert_header_value_do_serialize_header_map)r!   r{  r|  r}  rz  rw   r  key_namebool_strr7   r?  rX   r6   header_prefixs                 r   rv  (BaseRestSerializer._partition_parametersD  s    *''++J7''++FJ?u7B)*84&+t,,1299+FK..{+113?G128<!![0#)#7#7#;#;%t'I'I$  !::	 @I128<?J128<!!-E5??f#<..uBE/25zK	"8," %M
 ))95{ 6A&z2r   c                 F    UR                  5        H  u  pEX-   nXRU'   M     g r   )rn   )r!   r  r+   
user_inputr   valfull_keys          r   r  +BaseRestSerializer._do_serialize_header_mapu  s'    "((*HC$*H #H +r   c                     [        S5      eNr  r   )r!   r  rX   s      r   r  )BaseRestSerializer._serialize_body_paramsz      !":;;r   c                    UR                   S:X  af  [        U5      n[        R                  " UR	                  5       5      nUR
                  R                  SU R                  5      nU R                  XE5      $ UR                   S:X  aB  U Vs/ s H$  nUc  M  U R                  UR                  U5      PM&     nnSR                  U5      $ [        U5      (       a$  U R                  [        R                  " USS95      $ U$ s  snf )Nr?  r   r  ,)r  :)
separators)r   r	   r<   r=   utctimetuplerV   rW   HEADER_TIMESTAMP_FORMATrP   r  rw   rr   r   rd   r   r   )r!   rX   r6   rM   r?  r7   r:  converted_values           r   r  (BaseRestSerializer._convert_header_value}  s    ??k)259L (A(A(CDI$2266!4#?#?  11)NN__& A <**5<<;  
 88O,,!%(( ##DJJu$LMMLs   C? C?rj   N)r~   r   r   r   r   r  r  KNOWN_LOCATIONSr   rw  rx  r  ry  r  r  r  rv  r  r  r  r   rj   r   r   rj  rj    s]     %.!& BO9v5&>@

/Ab$
<r   rj  c                   0    \ rS rSrSrS rS rS rS rSr	g)	BaseRpcV2Serializeri  aH  Base class for RPCv2 protocols.

The only variance between the various RPCv2 protocols is the
way that the body is serialized.  All other aspects (headers, uri, etc.)
are the same and logic for serializing those aspects lives here.

Subclasses must implement the ``_serialize_body_params``  and
``_serialize_headers`` methods.

c                     U R                  5       nUR                  R                  S   nUR                  nSU SU 3US'   UR                  nUb  U R                  XU5        U R                  X25        U$ )Nr   z	/service/z/operation/r(   )r/   service_modelr   rT   rl   rx  _serialize_headers)r!   r"   r#   r.   service_nameoperation_namerl   s          r   r   (BaseRpcV2Serializer.serialize_to_request  s    113
&44==nM(--~[0@A 	: &11"##JKH
<r   c                 .    U R                  X5      nXBS'   g )Nr,   )r  )r!   r"   r.   rX   r  s        r   rx  &BaseRpcV2Serializer._serialize_payload  s    22:E)6r   c                     [        S5      e)Nr  r   )r!   r.   r#   s      r   r  &BaseRpcV2Serializer._serialize_headers  s    !"677r   c                     [        S5      er  r   )r!   r"   rX   s      r   r  *BaseRpcV2Serializer._serialize_body_params  r  r   rj   N)
r~   r   r   r   r   r   rx  r  r  r   rj   r   r   r  r    s    	 *8<r   r  c                   ,    \ rS rSrS rS rS rS rSrg)RestJSONSerializeri  c                     g)Ns   {}rj   r  s    r   r  (RestJSONSerializer._serialize_empty_body  s    r   c                 n    UR                   R                  5        H  u  p#SUR                  ;  d  M    g   g)zY
Serialize an empty JSON object whenever the shape has
members not targeting a location.
r  TF)rm   rn   rV   )r!   rX   rw   r  s       r   r  'RestJSONSerializer._requires_empty_body  s3    
 !==..0KF!2!22 1 r   c                     UR                   R                  S5      nU R                  XC5      (       a  gUS   S:g  n[        SUS   5      nU(       a  U(       d	  SUS   S'   ggg)z?Set Content-Type to application/json for all structured bodies.r  Nr,   r   r   r+   zapplication/json)rV   rW   r  r   )r!   r.   rX   rz  r  has_bodyhas_content_types          r   ry  *RestJSONSerializer._serialize_content_type  si    %%)))4&&w>>f%,%nj6KL,4FJy!.1 -8r   c                     U R                  5       nU R                  X1U5        [        R                  " U5      R	                  U R
                  5      $ r   )r   r   r   r   r^   r_   )r!   r  rX   serialized_bodys       r   r  )RestJSONSerializer._serialize_body_params  s;    --/7zz/*11$2G2GHHr   rj   N)	r~   r   r   r   r  r  ry  r  r   rj   r   r   r  r    s    
GIr   r  c                   N    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rSrg)RestXMLSerializeri  r   c                     UR                   S   n[        R                  " S5      nU R                  X!XC5        [	        U5      S   n[        R
                  " XPR                  S9$ )NrT   r'   r   )encoding)rV   r   Elementr   r  tostringr_   )r!   r  rX   	root_namepseudo_root	real_roots         r   r  (RestXMLSerializer._serialize_body_params  sV    ''/	!))"-{>%a(	##I8M8MNNr   c                 ^    [        U SUR                   3U R                  5      nU" X2X5        g r   r   )r!   rX   r  xmlnoderT   r*   s         r   r   RestXMLSerializer._serialize  s3    u/0##

 	w,r   c                    [         R                  " X5      nSUR                  ;   aD  UR                  S   nSnUR                  S5      (       a  USUS    3-  nUS   UR                  U'   UR                  5        H  u  pUR                  U   n
U
R                  R                  SU5      nU	c    g U
R                  R                  S5      (       a  U
R                  S   nXR                  U'   Mt  U R                  XX[5        M     g )NxmlNamespacexmlnsr   r  rl  rT   xmlAttribute)r   
SubElementrV   rW   attribrn   rm   r   )r!   r  r  rX   rT   structure_nodenamespace_metadataattribute_namer   r6   r   member_namexml_attribute_names                r   r   +RestXMLSerializer._serialize_type_structure  s    $//>U000!&!4!4^!D$N!%%h//A&8&B%C"DD4Fu4MN!!.1 ,,.JC ==-L&4488EK
 }))--n==%1%?%?%G"<A%%&89OOLM )r   c                     UR                   nUR                  R                  S5      (       a  UnUnO2UR                  R                  SS5      n[        R                  " X5      nU H  nU R                  XXXv5        M     g )Nr   rT   rw   )rw   rV   rW   r   r  r   )	r!   r  r  rX   rT   r   element_name	list_noder2  s	            r   r   &RestXMLSerializer._serialize_type_list  sl    ||"";//LI'5599&(KL#..w=IDOOL	H r   c                 l   [         R                  " X5      nUR                  5        H  u  pg[         R                  " US5      nU R                  UR                  SS9n	U R                  UR
                  SS9n
U R                  UR                  XhU	5        U R                  UR
                  XxU
5        M     g )Nentryr   r   r6   )r   r  rn   rZ   r   r6   r   )r!   r  r  rX   rT   noder   r6   
entry_noder  val_names              r   r   %RestXMLSerializer._serialize_type_map  s     %%g4 ,,.JC$//g>J000OH00' 1 H OOEIIsAOOEKKHE )r   c                 T    [         R                  " X5      nU(       a  SnOSnXel        g r   )r   r  text)r!   r  r  rX   rT   r  	str_values          r   r   )RestXMLSerializer._serialize_type_boolean&  s&     %%g4II	r   c                 \    [         R                  " X5      nU R                  U5      Ul        g r   )r   r  rd   r  r!   r  r  rX   rT   r  s         r   r   &RestXMLSerializer._serialize_type_blob1  s$    %%g4$$V,	r   c                     [         R                  " X5      nU R                  X#R                  R	                  S5      5      Ul        g r   )r   r  rP   rV   rW   r  r  s         r   r   +RestXMLSerializer._serialize_type_timestamp5  s9    %%g422''++,=>
	r   c                 P    [         R                  " X5      n[        U5      Ul        g r   )r   r  r]   r  r  s         r   r   $RestXMLSerializer._default_serialize;  s    %%g4K	r   rj   N)r~   r   r   r   rJ   r  r   r   r   r   r   r   r   r   r   rj   r   r   r  r    s9     O-N4	IF(	-
 r   r  c                   $    \ rS rSrSrS rS rSrg)RpcV2CBORSerializeri@  r   c                 P    [        5       nU R                  X1U5        [        U5      $ r   )r$  r  r#  )r!   r"   rl   r,   s       r   r  *RpcV2CBORSerializer._serialize_body_paramsC  s#    {!!$K@T{r   c                     SUS   S'   UR                   (       a  SnOSnUS   S:g  n[        SUS   5      nX1S   S	'   U(       d  U(       a  X1S   S'   g g g )
Nzrpc-v2-cborr+   zsmithy-protocolz"application/vnd.amazon.eventstreamzapplication/cborr,   r   r   Accept)has_event_stream_outputr   )r!   r.   r#   
header_valr  r  s         r   r  &RpcV2CBORSerializer._serialize_headersH  sm    3@
9/022=J+Jf%,%nj6KL*49h'H4>y!.1 %-r   rj   N)r~   r   r   r   rJ   r  r  r   rj   r   r   r	  r	  @  s    &
?r   r	  )ec2queryr   z	rest-jsonzrest-xmlzsmithy-rpc-v2-cbor)T)&r   r`   r<   rE   r   rd  r  rH  	xml.etreer   botocorer   botocore.compatr   botocore.exceptionsr   botocore.utilsr   r   r	   r
   DEFAULT_TIMESTAMP_FORMATr4   r3   compilero   r   r   r   r   r   r  rj  r  r  r  r	  r   rj   r   r   <module>r     s  8      	  !  & 4  % 
'12A> A>Hi4j i4XPO P<V2Z V2ro<Z o<dk k\$<* $<NI+^ I@b * b J?-~ ?2 #!-r   