
    Pew                        d Z ddlmZ ddlmZ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)OrderedDict)MissingServiceIdErrorUndefinedModelAttributeError)CachedPropertyhyphenize_service_idinstance_cachec                       e Zd Zy)NoShapeFoundErrorN__name__
__module____qualname__     0/usr/lib/python3/dist-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getrG   _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%   rI   )rL   SERIALIZED_ATTRSpop)r!   modelserializationattrs       r   rX   zShape.serialization   sj    . !!)) 	2Dt(((&+Dkd#	2 ]*$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.

        )rL   METADATA_ATTRS)r!   rW   metadatarY   s       r   r\   zShape.metadata   sK    . !!'' 	-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.

        r5   r\   rK   r    s    r   required_memberszShape.required_members   s     }}  R00r   c                 8    | j                   j                  |      S r   rN   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   rI   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__rU   r[   r   MAP_TYPErS   r	   rX   r\   r_   re   rl   propertyrn   r   r   r   r$   r$   0   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)rL   rK   rp   itemsre   )r!   ru   shape_membersrI   rd   s        r   ru   zStructureShape.members   sc    ##''	4==?C &}} 	EOD)"&"9"9)"DM$	Er   c                     | j                   j                         D ]$  \  }}|j                  j                  d      s"|c S  y )Nr/   )ru   rv   rX   rK   )r!   member_namemembers      r   rn   z StructureShape.event_stream_name   sB    #'<<#5#5#7 	#K##''6""	# r   c                     | j                   j                  dd      sy | j                   j                  di       }|j                  d      }|r|S | j                  S )Nr=   Fr<   code)r\   rK   rI   )r!   error_metadatar|   s      r   
error_codezStructureShape.error_code   sQ    }}  e4**7B7!!&)Kyyr   c                 :    | j                   j                  dd      S )Nr@   Fr^   r    s    r   is_document_typezStructureShape.is_document_type   s    }}  U33r   c                 :    | j                   j                  dd      S )NrA   Fr^   r    s    r   is_tagged_unionzStructureShape.is_tagged_union   s    }}  %00r   N)	r   r   r   r	   ru   rn   r~   r   r   r   r   r   rs   rs      sd          4 4 1 1r   rs   c                       e Zd Zed        Zy)	ListShapec                 >    | j                  | j                  d         S )Nrz   re   rL   r    s    r   rz   zListShape.member   s    &&t'8'8'BCCr   N)r   r   r   r	   rz   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)StaticContextParameterrI   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)ContextParameterrI   ry   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)ClientContextParameterrI   rF   rG   Nr   r   r   r   r   r     s    
I
Ir   r   c                   \   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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_descriptionrK   r\   ShapeResolverrN   NOT_SET_signature_version_service_name_instance_cache)r!   service_descriptionservice_names      r   rS   zServiceModel.__init__,  sW    * %8!+//
B?,##Hb1 
 #*)!r   c                 :    | j                   j                  ||      S r   )rN   get_shape_by_namer!   rP   member_traitss      r   	shape_forzServiceModel.shape_forK  s     ##55
 	
r   c                 :    | j                   j                  |d       S r   )_error_code_cacherK   )r!   r~   s     r   shape_for_error_codez!ServiceModel.shape_for_error_codeP  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_cacheS  s;    ,, 	1K))D%0T"	1  r   c                 8    | j                   j                  |      S r   ra   rc   s     r   rb   zServiceModel.resolve_shape_ref[  rf   r   c                 L    t        | j                  j                  di             S )Nr   listr   rK   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\   rK   append)r!   r   rP   r   s       r   r   zServiceModel.error_shapesb  sV    ** 	1J..4K##''U;##K0	1 r   c                 r    	 | j                   d   |   }t        || |      S # t        $ r t        |      w xY wN
operations)r   KeyErrorr   OperationModel)r!   operation_namerW   s      r   operation_modelzServiceModel.operation_modelk  sI    	9--l;NKE eT>::  	9(88	9s   ! 6c                 :    | j                   j                  dd      S NrG   rH   )r   rK   r    s    r   rG   zServiceModel.documentations  s    ((,,_bAAr   c                 L    t        | j                  j                  dg             S r   r   r    s    r   operation_nameszServiceModel.operation_namesw  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\   rK   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!   	operationrW   s      r   endpoint_discovery_operationz)ServiceModel.endpoint_discovery_operation  s5    -- 	I((3E44	r   c                     | j                   D ]=  }| j                  |      }|j                  !|j                  j                  d      s= y y)Nr5   TF)r   r   endpoint_discoveryrK   r   s      r   endpoint_discovery_requiredz(ServiceModel.endpoint_discovery_required  sO    -- 	I((3E((4,,00<	 r   c           
          | j                   j                  di       }|j                         D cg c]  \  }}t        ||d   |d          c}}S c c}}w )NrC   rF   rG   )rI   rF   rG   )r   rK   rv   r   )r!   params
param_name	param_vals       r   client_context_parametersz&ServiceModel.client_context_parameters  sa    **../DbI *0
 &
I #v&'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!   rI   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\   rK   )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                 N    | j                   j                   d| j                   dS )Nri   ))rk   r   r   r    s    r   rl   zServiceModel.__repr__  s'    ..))*!D,=,=+>a@@r   r   )r   r   r   ro   rS   r   r   r	   r   rb   r   r   r   r   rG   r   r   r   r   r   r   r   r   r   r   r   rq   r   setterrl   r   r   r   r   r   %  s   ">

<    A A A   ; ; B B E E ( (  I I 	 	 9 9 7 7 = =     	
 	
 ' ' ( (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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.

        rI   httpN)_operation_model_service_model	_api_namerK   
_wire_namer\   r   )r!   r   service_modelrI   s       r   rS   zOperationModel.__init__  sP    8 !0+ *--f5%..#''3	r   c                 J    | j                   | j                   S | j                  S r   )r   	wire_namer    s    r   rI   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``.

        rI   r   rK   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   rG   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_discovery*  s     $$(()<dCCr   c                 :    | j                   j                  dd      S )NendpointoperationFr   r    s    r   r   z.OperationModel.is_endpoint_discovery_operation0  s    $$(()<eDDr   c                 p    d| j                   vry | j                  j                  | j                   d         S )Ninputr   r   rb   r    s    r   input_shapezOperationModel.input_shape4  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_shape>  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  ru   rv   r\   )r!   r  rI   shapes       r   idempotent_membersz!OperationModel.idempotent_membersI  sc    &&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   )rI   r   )r   rK   rv   r   )r!   r   rI   propss       r   static_context_parametersz(OperationModel.static_context_parametersV  sW    &&**+@"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 )NrB   rI   )rI   ry   )r  ru   rv   r\   r   )r!   rI   r  s      r   context_parametersz!OperationModel.context_parameters^  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_compressionm  s    $$(()=>>r   c                 8    | j                   j                  d      S )Nauthtyper   r    s    r   	auth_typezOperationModel.auth_typeq      $$((44r   c                 d      j                   j                  dg       }t         fd|D              S )Nerrorsc              3   T   K   | ]  }j                   j                  |       ! y wr   )r   rb   ).0sr!   s     r   	<genexpr>z.OperationModel.error_shapes.<locals>.<genexpr>x  s"     MD''99!<Ms   %()r   rK   r   )r!   r   s   ` r   r   zOperationModel.error_shapesu  s,    &&**8R8MfMMMr   c                 8    | j                   j                  d      S )Nendpointr   r    s    r   r  zOperationModel.endpointz  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   r&  z%OperationModel.get_event_stream_input  s    %%d&6&677r   c                 8    | j                  | j                        S r   )r,  r  r    s    r   r)  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)rn   ru   )r!   r  
event_names      r   r,  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   r1  z"OperationModel.get_streaming_input  s    ''(8(899r   c                 8    | j                  | j                        S r   )r7  r  r    s    r   r4  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)rX   rK   ru   rJ   )r!   r  r)   payload_shapes       r   r7  z"OperationModel._get_streaming_body  sK    =%%)))4!MM'2M&&&0$$r   c                 N    | j                   j                   d| j                   dS )Nz(name=r   rj   r    s    r   rl   zOperationModel.__repr__  s$    ..))*&1==r   r   )#r   r   r   rS   r	   rI   rq   r   r   rG   r   r   r   r  r  r	  r  r  r  r  r   r  r!  r$  r'  r*  r&  r)  r,  r2  r5  r1  r4  r7  rl   r   r   r   r   r     s   #4J " " 1 1 # # > > > > D D
 E E 
 
 
 
 

 

 
 
 
 
 ? ? 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   rS   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)NrF   z&Shape is missing required key 'type': )	rB  r   r   SHAPE_CLASSESrK   r$   r   copyupdate)r!   rP   r   rQ   	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   rG  rV   r   r   )r!   rd   r   rP   s       r   rb   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   ro   rs   r   r   r   rF  rS   r   rb   r   r   r   r   r     s*    $ $	M"Er   r   c                       e Zd ZdZddZd Zy)rM   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 'rP  rQ  rc   s     r   rb   z&UnresolvableShapeMap.resolve_shape_ref  s     *9+ 6  !
 	
r   r   )r   r   r   ro   r   rb   r   r   r   rM   rM     s    O


r   rM   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.

    )	r@  integerbooleanr:  float	timestamplongdoublecharNc                     t               | _        t               | _        |!| j                  j	                  d      | _        y y )Nr>  )r   ru   ShapeNameGenerator_name_generatornew_shape_namerI   r   s     r   rS   z%DenormalizedStructureBuilder.__init__0  s8    "}13<,,;;KHDI r   c                     || _         | S )zp

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

        :return: self

        )_members)r!   ru   s     r   with_membersz)DenormalizedStructureBuilder.with_members6  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.

        r>  )rF   ru   )rD  )rP   rQ   rR   )r   rb  _build_modelrI   r   rs   )r!   r   denormalizedresolvers       r   build_modelz(DenormalizedStructureBuilder.build_modelB  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          )NrF   r>  r   r?  zUnknown shape type: )_build_structure_build_list
_build_mapSCALAR_TYPES_build_scalarr   )r!   rW   r   rP   s       r   re  z)DenormalizedStructureBuilder._build_modelV  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 )Nru   r  )r   _build_initial_shaperK   rv   _get_shape_namere  )r!   rW   r   ru   r  rI   member_modelmember_shape_names           r   rj  z-DenormalizedStructureBuilder._build_structureb  s    -))%0"i"'))I{}"E"K"K"M 	GD, $ 4 4\ B$&78GDMlF4EF	G r   c                     | j                  |      }| j                  |      }d|i|d<   | j                  |d   ||       |S )Nr  rz   rq  rp  re  )r!   rW   r   rs  r  s        r   rk  z(DenormalizedStructureBuilder._build_listm  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  ru  )r!   rW   r   key_shape_namevalue_shape_namer  s         r   rl  z'DenormalizedStructureBuilder._build_mapt  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 )NrF   rG   )r$   r[   )r!   rW   r  rY   s       r   rp  z1DenormalizedStructureBuilder._build_initial_shape~  s[    E&M
 e#%*?%;E/"(( 	*Du}#Dkd	* r   c                 $    | j                  |      S r   )rp  r!   rW   s     r   rn  z*DenormalizedStructureBuilder._build_scalar  s    ((//r   c                 P    d|v r|d   S | j                   j                  |d         S )NrP   rF   )r_  r`  r{  s     r   rq  z,DenormalizedStructureBuilder._get_shape_name  s0    5 &&''66uV}EEr   r   )r   r   r   ro   rm  rS   rc  rh  re  rj  rk  rl  rp  rn  rq  r   r   r   rU  rU    sD    "H
LI

(
L		0Fr   rU  c                       e Zd ZdZd Zd Zy)r^  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   rS   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

        rL  Type)r  
capitalize)r!   rJ   current_indexs      r   r`  z!ShapeNameGenerator.new_shape_name  sE    4 	#q(#((3&&()m_==r   N)r   r   r   ro   rS   r`  r   r   r   r^  r^    s    ,>r   r^  N)&ro   collectionsr   typingr   r   botocore.compatr   botocore.exceptionsr   r   botocore.utilsr	   r
   r   objectr   	Exceptionr   r   r   r   r   r   r$   rs   r   r   r   r   r   r   r   r   r   rM   rU  r^  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|T> T>n3E 3El
 
QF QFh'> '>r   