
    Mgy                        d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	 ddl
mZmZ ddlmZmZmZ  e       Z G d d	e      Z G d
 de      Z G d de      Z G d de      Z G d de      Z G d d      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z  G d  d!e      Z! G d" d#      Z" G d$ d%      Z# G d& d'      Z$ G d( d)      Z% G d* d+      Z& G d, d-      Z'y.)/z-Abstractions to interact with service models.    )defaultdict)
NamedTupleUnion)resolve_auth_type)OrderedDict)MissingServiceIdErrorUndefinedModelAttributeError)CachedPropertyhyphenize_service_idinstance_cachec                       e Zd Zy)NoShapeFoundErrorN__name__
__module____qualname__     \E:\wamp.anq\www\apps\calme\nutritwin\resources\nutritwin\Lib\site-packages\botocore/model.pyr   r          r   r   c                       e Zd Zy)InvalidShapeErrorNr   r   r   r   r   r   !   r   r   r   c                       e Zd Zy)OperationNotFoundErrorNr   r   r   r   r   r   %   r   r   r   c                       e Zd Zy)InvalidShapeReferenceErrorNr   r   r   r   r   r   )   r   r   r   c                       e Zd Zd Zy)	ServiceIdc                     t        |       S N)r   selfs    r   	hyphenizezServiceId.hyphenize.   s    #D))r   N)r   r   r   r#   r   r   r   r   r   -   s    *r   r   c                   x    e Zd ZdZg dZg dZeZddZe	d        Z
e	d        Ze	d        Zd	 Zd
 Zed        Zy)Shapez3Object representing a shape from the service model.)locationName	queryName	flattenedlocationpayload	streamingtimestampFormatxmlNamespaceresultWrapperxmlAttributeeventstreameventeventheadereventpayload	jsonvaluer,   	hostLabel)requiredminmaxpattern	sensitiveenumidempotencyTokenerror	exceptionendpointdiscoveryid	retryabledocumentunioncontextParamclientContextParamsrequiresLengthNc                     || _         |d   | _        |j                  dd      | _        || _        |
t               }|| _        i | _        y)a  

        :type shape_name: string
        :param shape_name: The name of the shape.

        :type shape_model: dict
        :param shape_model: The shape model.  This would be the value
            associated with the key in the "shapes" dict of the
            service model (i.e ``model['shapes'][shape_name]``)

        :type shape_resolver: botocore.model.ShapeResolver
        :param shape_resolver: A shape resolver object.  This is used to
            resolve references to other shapes.  For scalar shape types
            (string, integer, boolean, etc.), this argument is not
            required.  If a shape_resolver is not provided for a complex
            type, then a ``ValueError`` will be raised when an attempt
            to resolve a shape is made.

        typedocumentation N)name	type_namegetrH   _shape_modelUnresolvableShapeMap_shape_resolver_cache)r"   
shape_nameshape_modelshape_resolvers       r   __init__zShape.__init__`   sQ    ( 	$V,(___bA'! 23N-r   c                     | j                   }i }| j                  D ]  }|| j                   v s||   ||<    d|v r|j                  d      |d<   |S )a  Serialization information about the shape.

        This contains information that may be needed for input serialization
        or response parsing.  This can include:

            * name
            * queryName
            * flattened
            * location
            * payload
            * streaming
            * xmlNamespace
            * resultWrapper
            * xmlAttribute
            * jsonvalue
            * timestampFormat

        :rtype: dict
        :return: Serialization information about the shape.

        r&   rJ   )rM   SERIALIZED_ATTRSpop)r"   modelserializationattrs       r   rY   zShape.serialization   se    . !!))Dt(((&+Dkd# * ]*$1$5$5n$EM&!r   c                 r    | j                   }i }| j                  D ]  }|| j                   v s||   ||<    |S )a  Metadata about the shape.

        This requires optional information about the shape, including:

            * min
            * max
            * pattern
            * enum
            * sensitive
            * required
            * idempotencyToken
            * document
            * union
            * contextParam
            * clientContextParams
            * requiresLength

        :rtype: dict
        :return: Metadata about the shape.

        )rM   METADATA_ATTRS)r"   rX   metadatarZ   s       r   r]   zShape.metadata   sF    . !!''Dt(((!&t ( r   c                 :    | j                   j                  dg       S )zA list of members that are required.

        A structure shape can define members that are required.
        This value will return a list of required members.  If there
        are no required members an empty list is returned.

        r6   r]   rL   r!   s    r   required_memberszShape.required_members   s     }}  R00r   c                 8    | j                   j                  |      S r    rO   resolve_shape_refr"   	shape_refs     r   _resolve_shape_refzShape._resolve_shape_ref       ##55i@@r   c                 P    d| j                   j                   d| j                   dS )N<(z)>	__class__r   rJ   r!   s    r   __repr__zShape.__repr__   s&    4>>**+1TYYKr::r   c                      y r    r   r!   s    r   event_stream_namezShape.event_stream_name   s    r   r    )r   r   r   __doc__rV   r\   r   MAP_TYPErT   r
   rY   r]   r`   rf   rm   propertyro   r   r   r   r%   r%   2   s}    =&N$ H D  @  : 1 1A;  r   r%   c                   \    e Zd Zed        Zed        Zed        Zed        Zed        Zy)StructureShapec                     | j                   j                  d| j                               }| j                         }|j                         D ]  \  }}| j	                  |      ||<    |S )Nmembers)rM   rL   rq   itemsrf   )r"   rv   shape_membersrJ   re   s        r   rv   zStructureShape.members   s\    ##''	4==?C &}}OD)"&"9"9)"DM$  /r   c                     | j                   j                         D ]$  \  }}|j                  j                  d      s"|c S  y )Nr0   )rv   rw   rY   rL   )r"   member_namemembers      r   ro   z StructureShape.event_stream_name   s=    #'<<#5#5#7K##''6"" $8 r   c                     | j                   j                  dd      sy | j                   j                  di       }|j                  d      }|r|S | j                  S )Nr>   Fr=   code)r]   rL   rJ   )r"   error_metadatar}   s      r   
error_codezStructureShape.error_code   sQ    }}  e4**7B7!!&)Kyyr   c                 :    | j                   j                  dd      S )NrA   Fr_   r!   s    r   is_document_typezStructureShape.is_document_type   s    }}  U33r   c                 :    | j                   j                  dd      S )NrB   Fr_   r!   s    r   is_tagged_unionzStructureShape.is_tagged_union   s    }}  %00r   N)	r   r   r   r
   rv   ro   r   r   r   r   r   r   rt   rt      sd          4 4 1 1r   rt   c                       e Zd Zed        Zy)	ListShapec                 >    | j                  | j                  d         S )Nr{   rf   rM   r!   s    r   r{   zListShape.member  s    &&t'8'8'BCCr   N)r   r   r   r
   r{   r   r   r   r   r     s    D Dr   r   c                   ,    e Zd Zed        Zed        Zy)MapShapec                 >    | j                  | j                  d         S )Nkeyr   r!   s    r   r   zMapShape.key  s    &&t'8'8'?@@r   c                 >    | j                  | j                  d         S )Nvaluer   r!   s    r   r   zMapShape.value  s    &&t'8'8'ABBr   N)r   r   r   r
   r   r   r   r   r   r   r     s,    A A C Cr   r   c                       e Zd Zed        Zy)StringShapec                 :    | j                   j                  dg       S )Nr;   r_   r!   s    r   r;   zStringShape.enum  s    }}  ,,r   N)r   r   r   r
   r;   r   r   r   r   r     s    - -r   r   c                   ,    e Zd ZU eed<   eeef   ed<   y)StaticContextParameterrJ   r   N)r   r   r   str__annotations__r   boolr   r   r   r   r     s    
Isr   r   c                   "    e Zd ZU eed<   eed<   y)ContextParameterrJ   rz   Nr   r   r   r   r   r   r   r   r   r     s    
Ir   r   c                   ,    e Zd ZU eed<   eed<   eed<   y)ClientContextParameterrJ   rG   rH   Nr   r   r   r   r   r   !  s    
I
Ir   r   c                   l   e Zd ZdZddZddZd Zed        Zd Z	ed        Z
ed	        Zed
        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zd Zed        Zej8                  d        Zed        Zd Zy)ServiceModelzQ

    :ivar service_description: The parsed service description dictionary.

    Nc                     || _         |j                  di       | _        t        |j                  di             | _        t
        | _        || _        i | _        y)a  

        :type service_description: dict
        :param service_description: The service description model.  This value
            is obtained from a botocore.loader.Loader, or from directly loading
            the file yourself::

                service_description = json.load(
                    open('/path/to/service-description-model.json'))
                model = ServiceModel(service_description)

        :type service_name: str
        :param service_name: The name of the service.  Normally this is
            the endpoint prefix defined in the service_description.  However,
            you can override this value to provide a more convenient name.
            This is done in a few places in botocore (ses instead of email,
            emr instead of elasticmapreduce).  If this value is not provided,
            it will default to the endpointPrefix defined in the model.

        r]   shapesN)	_service_descriptionrL   r]   ShapeResolverrO   NOT_SET_signature_version_service_name_instance_cache)r"   service_descriptionservice_names      r   rT   zServiceModel.__init__.  sW    * %8!+//
B?,##Hb1 
 #*)!r   c                 :    | j                   j                  ||      S r    )rO   get_shape_by_namer"   rQ   member_traitss      r   	shape_forzServiceModel.shape_forM  s     ##55
 	
r   c                 :    | j                   j                  |d       S r    )_error_code_cacherL   )r"   r   s     r   shape_for_error_codez!ServiceModel.shape_for_error_codeR  s    %%))*d;;r   c                 N    i }| j                   D ]  }|j                  }|||<    |S r    )error_shapesr   )r"   error_code_cacheerror_shaper}   s       r   r   zServiceModel._error_code_cacheU  s6    ,,K))D%0T" -  r   c                 8    | j                   j                  |      S r    rb   rd   s     r   rc   zServiceModel.resolve_shape_ref]  rg   r   c                 L    t        | j                  j                  di             S )Nr   listr   rL   r!   s    r   shape_nameszServiceModel.shape_names`  s     D--11(B?@@r   c                     g }| j                   D ]A  }| j                  |      }|j                  j                  dd      s1|j	                  |       C |S )Nr>   F)r   r   r]   rL   append)r"   r   rQ   r   s       r   r   zServiceModel.error_shapesd  sQ    **J..4K##''U;##K0 + r   c                 r    	 | j                   d   |   }t        || |      S # t        $ r t        |      w xY wN
operations)r   KeyErrorr   OperationModel)r"   operation_namerX   s      r   operation_modelzServiceModel.operation_modelm  sI    	9--l;NKE eT>::  	9(88	9s   ! 6c                 :    | j                   j                  dd      S NrH   rI   )r   rL   r!   s    r   rH   zServiceModel.documentationu  s    ((,,_bAAr   c                 L    t        | j                  j                  dg             S r   r   r!   s    r   operation_nameszServiceModel.operation_namesy  s     D--11,CDDr   c                 J    | j                   | j                   S | j                  S )a  The name of the service.

        This defaults to the endpointPrefix defined in the service model.
        However, this value can be overriden when a ``ServiceModel`` is
        created.  If a service_name was not provided when the ``ServiceModel``
        was created and if there is no endpointPrefix defined in the
        service model, then an ``UndefinedModelAttributeError`` exception
        will be raised.

        )r   endpoint_prefixr!   s    r   r   zServiceModel.service_name}  s(     )%%%'''r   c                 ~    	 t        | j                  d            S # t        $ r t        | j                        w xY w)N	serviceId)r   )r   _get_metadata_propertyr	   r   r   r!   s    r   
service_idzServiceModel.service_id  s@    	IT88EFF+ 	I'T5G5GHH	Is     <c                 X    | j                   j                  d      }|| j                  }|S )zThe name to use when computing signatures.

        If the model does not define a signing name, this
        value will be the endpoint prefix defined in the model.
        signingName)r]   rL   r   )r"   signing_names     r   r   zServiceModel.signing_name  s/     }}((7//Lr   c                 $    | j                  d      S )N
apiVersionr   r!   s    r   api_versionzServiceModel.api_version  s    **<88r   c                 $    | j                  d      S )Nprotocolr   r!   s    r   r   zServiceModel.protocol  s    **:66r   c                 $    | j                  d      S )NendpointPrefixr   r!   s    r   r   zServiceModel.endpoint_prefix  s    **+;<<r   c                 h    | j                   D ]#  }| j                  |      }|j                  s!|c S  y r    )r   r   is_endpoint_discovery_operationr"   	operationrX   s      r   endpoint_discovery_operationz)ServiceModel.endpoint_discovery_operation  s0    --I((3E44 .r   c                     | j                   D ]=  }| j                  |      }|j                  !|j                  j                  d      s= y y)Nr6   TF)r   r   endpoint_discoveryrL   r   s      r   endpoint_discovery_requiredz(ServiceModel.endpoint_discovery_required  sJ    --I((3E((4,,00< . r   c           
          | j                   j                  di       }|j                         D cg c]  \  }}t        ||d   |d          c}}S c c}}w )NrD   rG   rH   )rJ   rG   rH   )r   rL   rw   r   )r"   params
param_name	param_vals       r   client_context_parametersz&ServiceModel.client_context_parameters  si    **../DbI *0
 *8%
I #v&'8
 *8
 	
 
s   Ac                 ^    	 | j                   |   S # t        $ r t        d| d|        w xY w)N"z," not defined in the metadata of the model: )r]   r   r	   r"   rJ   s     r   r   z#ServiceModel._get_metadata_property  sC    	==&& 	.D6EdVL 	s    ,c                     | j                   t        u r"| j                  j                  d      }|| _         | j                   S )NsignatureVersion)r   r   r]   rL   )r"   signature_versions     r   r   zServiceModel.signature_version  s:    ""g- $ 1 12D E&7D#&&&r   c                     || _         y r    )r   )r"   r   s     r   r   zServiceModel.signature_version  s
    "'r   c                     d| j                   v S )NawsQueryCompatible)r]   r!   s    r   is_query_compatiblez ServiceModel.is_query_compatible  s    #t}}44r   c                 N    | j                   j                   d| j                   dS )Nrj   ))rl   r   r   r!   s    r   rm   zServiceModel.__repr__  s'    ..))*!D,=,=+>a@@r   r    )r   r   r   rp   rT   r   r   r
   r   rc   r   r   r   r   rH   r   r   r   r   r   r   r   r   r   r   r   rr   r   setterr   rm   r   r   r   r   r   '  s   ">

<    A A A   ; ; B B E E ( (  I I 	 	 9 9 7 7 = =     	
 	
 ' ' ( ( 5 5Ar   r   c                      e Zd Zd#dZed        Zed        Zed        Zed        Z	ed        Z
ed        Zed	        Zed
        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zd Zd Zd Zed        Z ed        Z!d Z"d  Z#d! Z$d" Z%y)$r   Nc                     || _         || _        || _        |j                  d      | _        |j
                  | _        |j                  di       | _        y)a  

        :type operation_model: dict
        :param operation_model: The operation model.  This comes from the
            service model, and is the value associated with the operation
            name in the service model (i.e ``model['operations'][op_name]``).

        :type service_model: botocore.model.ServiceModel
        :param service_model: The service model associated with the operation.

        :type name: string
        :param name: The operation name.  This is the operation name exposed to
            the users of this model.  This can potentially be different from
            the "wire_name", which is the operation name that *must* by
            provided over the wire.  For example, given::

               "CreateCloudFrontOriginAccessIdentity":{
                 "name":"CreateCloudFrontOriginAccessIdentity2014_11_06",
                  ...
              }

           The ``name`` would be ``CreateCloudFrontOriginAccessIdentity``,
           but the ``self.wire_name`` would be
           ``CreateCloudFrontOriginAccessIdentity2014_11_06``, which is the
           value we must send in the corresponding HTTP request.

        rJ   httpN)_operation_model_service_model	_api_namerL   
_wire_namer]   r   )r"   r   service_modelrJ   s       r   rT   zOperationModel.__init__  sP    8 !0+ *--f5%..#''3	r   c                 J    | j                   | j                   S | j                  S r    )r   	wire_namer!   s    r   rJ   zOperationModel.name  s     >>%>>!>>!r   c                 8    | j                   j                  d      S )aR  The wire name of the operation.

        In many situations this is the same value as the
        ``name``, value, but in some services, the operation name
        exposed to the user is different from the operation name
        we send across the wire (e.g cloudfront).

        Any serialization code should use ``wire_name``.

        rJ   r   rL   r!   s    r   r   zOperationModel.wire_name  s     $$((00r   c                     | j                   S r    )r   r!   s    r   r   zOperationModel.service_model$  s    """r   c                 :    | j                   j                  dd      S r   r   r!   s    r   rH   zOperationModel.documentation(  s    $$(("==r   c                 :    | j                   j                  dd      S )N
deprecatedFr   r!   s    r   r   zOperationModel.deprecated,  s    $$((u==r   c                 :    | j                   j                  dd       S )Nendpointdiscoveryr   r!   s    r   r   z!OperationModel.endpoint_discovery0  s     $$(()<dCCr   c                 :    | j                   j                  dd      S )NendpointoperationFr   r!   s    r   r   z.OperationModel.is_endpoint_discovery_operation6  s    $$(()<eDDr   c                 p    d| j                   vry | j                  j                  | j                   d         S )Ninputr   r   rc   r!   s    r   input_shapezOperationModel.input_shape:  s<    $/// ""44!!'*
 	
r   c                 p    d| j                   vry | j                  j                  | j                   d         S )Noutputr  r!   s    r   output_shapezOperationModel.output_shapeD  s<    4000 ""44!!(+
 	
r   c                     | j                   }|sg S |j                  j                         D cg c]$  \  }}d|j                  v r|j                  d   r|& c}}S c c}}w )Nr<   )r  rv   rw   r]   )r"   r  rJ   shapes       r   idempotent_membersz!OperationModel.idempotent_membersO  sh    &&I "-!4!4!:!:!<
!<u!U^^312 !<
 	
 
s   )Ac           
          | j                   j                  di       }|j                         D cg c]!  \  }}t        ||j                  d            # c}}S c c}}w )NstaticContextParamsr   )rJ   r   )r   rL   rw   r   )r"   r   rJ   propss       r   static_context_parametersz(OperationModel.static_context_parameters\  s\    &&**+@"E  &||~
-e #EIIg4FG-
 	
 
s   &Ac                    | j                   sg S | j                   j                  j                         D cg c]A  \  }}d|j                  v r.d|j                  d   v rt	        |j                  d   d   |      C c}}S c c}}w )NrC   rJ   )rJ   rz   )r  rv   rw   r]   r   )r"   rJ   r  s      r   context_parametersz!OperationModel.context_parametersd  s    I  $//77==?

  @e/%..88 ^^N3F;   @
 	
 
s   AB c                 8    | j                   j                  d      S )Nrequestcompressionr   r!   s    r   request_compressionz"OperationModel.request_compressions  s    $$(()=>>r   c                 8    | j                   j                  d      S )Nauthr   r!   s    r   r  zOperationModel.authw  s    $$((00r   c                 8    | j                   j                  d      S )Nauthtyper   r!   s    r   	auth_typezOperationModel.auth_type{      $$((44r   c                 \    | j                   rt        | j                         S | j                  S r    )r  r   r  r!   s    r   resolved_auth_typez!OperationModel.resolved_auth_type  s"    99$TYY//~~r   c                 8    | j                   j                  d      S )NunsignedPayloadr   r!   s    r   unsigned_payloadzOperationModel.unsigned_payload  s    $$(():;;r   c                 d      j                   j                  dg       }t         fd|D              S )Nerrorsc              3   T   K   | ]  }j                   j                  |       ! y wr    )r   rc   ).0sr"   s     r   	<genexpr>z.OperationModel.error_shapes.<locals>.<genexpr>  s#     MfD''99!<fs   %()r   rL   r   )r"   r   s   ` r   r   zOperationModel.error_shapes  s,    &&**8R8MfMMMr   c                 8    | j                   j                  d      S )Nendpointr   r!   s    r   r)  zOperationModel.endpoint  r  r   c                 :    | j                   j                  dd      S )NhttpChecksumRequiredFr   r!   s    r   http_checksum_requiredz%OperationModel.http_checksum_required  s    $$(()?GGr   c                 :    | j                   j                  di       S )NhttpChecksumr   r!   s    r   http_checksumzOperationModel.http_checksum  s    $$((<<r   c                 &    | j                         d uS r    )get_event_stream_inputr!   s    r   has_event_stream_inputz%OperationModel.has_event_stream_input  s    **,D88r   c                 &    | j                         d uS r    )get_event_stream_outputr!   s    r   has_event_stream_outputz&OperationModel.has_event_stream_output  s    ++-T99r   c                 8    | j                  | j                        S r    )_get_event_streamr  r!   s    r   r1  z%OperationModel.get_event_stream_input  s    %%d&6&677r   c                 8    | j                  | j                        S r    )r7  r
  r!   s    r   r4  z&OperationModel.get_event_stream_output  s    %%d&7&788r   c                 D    |y|j                   }|r|j                  |   S y)zAReturns the event stream member's shape if any or None otherwise.N)ro   rv   )r"   r  
event_names      r   r7  z OperationModel._get_event_stream  s*    =,,
==,,r   c                 &    | j                         d uS r    )get_streaming_inputr!   s    r   has_streaming_inputz"OperationModel.has_streaming_input  s    '')55r   c                 &    | j                         d uS r    )get_streaming_outputr!   s    r   has_streaming_outputz#OperationModel.has_streaming_output  s    ((*$66r   c                 8    | j                  | j                        S r    )_get_streaming_bodyr  r!   s    r   r<  z"OperationModel.get_streaming_input  s    ''(8(899r   c                 8    | j                  | j                        S r    )rB  r
  r!   s    r   r?  z#OperationModel.get_streaming_output  s    ''(9(9::r   c                     |y|j                   j                  d      }| |j                  |   }|j                  dk(  r|S y)z?Returns the streaming member's shape if any; or None otherwise.Nr*   blob)rY   rL   rv   rK   )r"   r  r*   payload_shapes       r   rB  z"OperationModel._get_streaming_body  sK    =%%)))4!MM'2M&&&0$$r   c                 N    | j                   j                   d| j                   dS )Nz(name=r   rk   r!   s    r   rm   zOperationModel.__repr__  s$    ..))*&1==r   r    )&r   r   r   rT   r
   rJ   rr   r   r   rH   r   r   r   r  r
  r  r  r  r  r  r  r  r!  r   r)  r,  r/  r2  r5  r1  r4  r7  r=  r@  r<  r?  rB  rm   r   r   r   r   r     s'   #4J " " 1 1 # # > > > > D D
 E E 
 
 
 
 

 

 
 
 
 
 ? ? 1 1 5 5  
 < < N N 5 5 H H = = 9 9 : :89 6 6 7 7:;	>r   r   c                   2    e Zd ZdZeeeedZd Z	ddZ
d Zy)r   zResolves shape references.)	structurer   mapstringc                      || _         i | _        y r    )
_shape_map_shape_cache)r"   	shape_maps     r   rT   zShapeResolver.__init__  s    #r   Nc                 .   	 | j                   |   }	 | j                  j	                  |d   t
              }|r!|j                         }|j                  |        ||||       }|S # t        $ r t        |      w xY w# t        $ r t        d|       w xY w)NrG   z&Shape is missing required key 'type': )	rM  r   r   SHAPE_CLASSESrL   r%   r   copyupdate)r"   rQ   r   rR   	shape_clsresults         r   r   zShapeResolver.get_shape_by_name  s    	0//*5K	**..{6/BEJI
 %**,K}-:{D9  	0#J//	0  	#8F 	s   A$ #A< $A9<Bc                     t        |      dk(  rd|v r| j                  |d         S |j                         }	 |j                  d      }| j                  ||      S # t        $ r t        d|       w xY w)N   r  z(Invalid model, missing shape reference: )lenr   rR  rW   r   r   )r"   re   r   rQ   s       r   rc   zShapeResolver.resolve_shape_ref  s     y>Q7i#7 )))G*<==%NN,M*..w7

 ))*mDD	  0>ykJ s   A A3r    )r   r   r   rp   rt   r   r   r   rQ  rT   r   rc   r   r   r   r   r     s*    $ $	M"Er   r   c                       e Zd ZdZddZd Zy)rN   zEA ShapeResolver that will throw ValueErrors when shapes are resolved.Nc                      t        d| d      )NzAttempted to lookup shape '!', but no shape map was provided.
ValueErrorr   s      r   r   z&UnresolvableShapeMap.get_shape_by_name  s    )*5VW
 	
r   c                      t        d| d      )NzAttempted to resolve shape 'r[  r\  rd   s     r   rc   z&UnresolvableShapeMap.resolve_shape_ref  s     *9+ 6  !
 	
r   r    )r   r   r   rp   r   rc   r   r   r   rN   rN     s    O


r   rN   c                   R    e Zd ZdZdZddZd Zd Zd Zd Z	d	 Z
d
 Zd Zd Zd Zy)DenormalizedStructureBuildera  Build a StructureShape from a denormalized model.

    This is a convenience builder class that makes it easy to construct
    ``StructureShape``s based on a denormalized model.

    It will handle the details of creating unique shape names and creating
    the appropriate shape map needed by the ``StructureShape`` class.

    Example usage::

        builder = DenormalizedStructureBuilder()
        shape = builder.with_members({
            'A': {
                'type': 'structure',
                'members': {
                    'B': {
                        'type': 'structure',
                        'members': {
                            'C': {
                                'type': 'string',
                            }
                        }
                    }
                }
            }
        }).build_model()
        # ``shape`` is now an instance of botocore.model.StructureShape

    :type dict_type: class
    :param dict_type: The dictionary type to use, allowing you to opt-in
                      to using OrderedDict or another dict type. This can
                      be particularly useful for testing when order
                      matters, such as for documentation.

    )	rK  integerbooleanrE  float	timestamplongdoublecharNc                     t               | _        t               | _        |!| j                  j	                  d      | _        y y )NrI  )r   rv   ShapeNameGenerator_name_generatornew_shape_namerJ   r   s     r   rT   z%DenormalizedStructureBuilder.__init__D  s8    "}13<,,;;KHDI r   c                     || _         | S )zp

        :type members: dict
        :param members: The denormalized members.

        :return: self

        )_members)r"   rv   s     r   with_membersz)DenormalizedStructureBuilder.with_membersJ  s      r   c                     t               }d| j                  d}| j                  ||| j                         t	        |      }t        | j                  || j                     |      S )zBuild the model based on the provided members.

        :rtype: botocore.model.StructureShape
        :return: The built StructureShape object.

        rI  )rG   rv   )rO  )rQ   rR   rS   )r   rm  _build_modelrJ   r   rt   )r"   r   denormalizedresolvers       r   build_modelz(DenormalizedStructureBuilder.build_modelV  sa     }}
 	,		: 62yytyy)#
 	
r   c                 $   |d   dk(  r| j                  ||      ||<   y |d   dk(  r| j                  ||      ||<   y |d   dk(  r| j                  ||      ||<   y |d   | j                  v r| j	                  |      ||<   y t        d|d          )NrG   rI  r   rJ  zUnknown shape type: )_build_structure_build_list
_build_mapSCALAR_TYPES_build_scalarr   )r"   rX   r   rQ   s       r   rp  z)DenormalizedStructureBuilder._build_modelj  s    =K'!%!6!6uf!EF:6]f$!%!1!1%!@F:6]e#!%!?F:6]d///!%!3!3E!:F:#&:5=/$JKKr   c                     t               }| j                  |      }||d<   |j                  dt                     j                         D ]0  \  }}| j	                  |      }d|i||<   | j                  |||       2 |S )Nrv   r  )r   _build_initial_shaperL   rw   _get_shape_namerp  )r"   rX   r   rv   r  rJ   member_modelmember_shape_names           r   ru  z-DenormalizedStructureBuilder._build_structurev  s    -))%0"i"'))I{}"E"K"K"MD, $ 4 4\ B$&78GDMlF4EF #N r   c                     | j                  |      }| j                  |      }d|i|d<   | j                  |d   ||       |S )Nr  r{   r|  r{  rp  )r"   rX   r   r~  r  s        r   rv  z(DenormalizedStructureBuilder._build_list  sN     007))%0"$56h%/63DEr   c                     | j                  |d         }| j                  |d         }| j                  |      }d|i|d<   d|i|d<   | j                  |d   ||       | j                  |d   ||       |S )Nr   r   r  r  )r"   rX   r   key_shape_namevalue_shape_namer  s         r   rw  z'DenormalizedStructureBuilder._build_map  s    --eEl;//g?))%00e!#34g%,?%.&2BCr   c                 p    d|d   i}d|v r|d   |d<   t         j                  D ]  }||v s||   ||<    |S )NrG   rH   )r%   r\   )r"   rX   r  rZ   s       r   r{  z1DenormalizedStructureBuilder._build_initial_shape  sV    E&M
 e#%*?%;E/"((Du}#Dkd ) r   c                 $    | j                  |      S r    )r{  r"   rX   s     r   ry  z*DenormalizedStructureBuilder._build_scalar  s    ((//r   c                 P    d|v r|d   S | j                   j                  |d         S )NrQ   rG   )rj  rk  r  s     r   r|  z,DenormalizedStructureBuilder._get_shape_name  s0    5 &&''66uV}EEr   r    )r   r   r   rp   rx  rT   rn  rs  rp  ru  rv  rw  r{  ry  r|  r   r   r   r`  r`    sD    "H
LI

(
L		0Fr   r`  c                       e Zd ZdZd Zd Zy)ri  zGenerate unique shape names for a type.

    This class can be used in conjunction with the DenormalizedStructureBuilder
    to generate unique shape names for a given type.

    c                 ,    t        t              | _        y r    )r   int_name_cacher!   s    r   rT   zShapeNameGenerator.__init__  s    &s+r   c                 x    | j                   |xx   dz  cc<   | j                   |   }|j                          d| S )a  Generate a unique shape name.

        This method will guarantee a unique shape name each time it is
        called with the same type.

        ::

            >>> s = ShapeNameGenerator()
            >>> s.new_shape_name('structure')
            'StructureType1'
            >>> s.new_shape_name('structure')
            'StructureType2'
            >>> s.new_shape_name('list')
            'ListType1'
            >>> s.new_shape_name('list')
            'ListType2'


        :type type_name: string
        :param type_name: The type name (structure, list, map, string, etc.)

        :rtype: string
        :return: A unique shape name for the given type

        rW  Type)r  
capitalize)r"   rK   current_indexs      r   rk  z!ShapeNameGenerator.new_shape_name  sE    4 	#q(#((3&&()m_==r   N)r   r   r   rp   rT   rk  r   r   r   ri  ri    s    ,>r   ri  N)(rp   collectionsr   typingr   r   botocore.authr   botocore.compatr   botocore.exceptionsr   r	   botocore.utilsr
   r   r   objectr   	Exceptionr   r   r   r   r   r   r%   rt   r   r   r   r   r   r   r   r   r   rN   r`  ri  r   r   r   <module>r     s   4 # $ + ' P O
(		 			 		Y 		 	* *
b bJ'1U '1TD DCu C-% -Z 
z 
Z A ADb> b>J3E 3El
 
QF QFh'> '>r   