o
    "`^h.y                     @   s  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	 d	eZG d
d deZG dd deZG dd deZG dd deZG dd dZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZ G d d! d!eZ!G d"d# d#Z"G d$d% d%Z#G d&d' d'Z$G d(d) d)Z%G d*d+ d+Z&G d,d- d-Z'd.S )/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dS )NoShapeFoundErrorN__name__
__module____qualname__ r   r   L/home/air/shanriGPT/back/venv/lib/python3.10/site-packages/botocore/model.pyr          r   c                   @   r   )InvalidShapeErrorNr   r   r   r   r   r   !   r   r   c                   @   r   )OperationNotFoundErrorNr   r   r   r   r   r   %   r   r   c                   @   r   )InvalidShapeReferenceErrorNr   r   r   r   r   r   )   r   r   c                   @   s   e Zd Zdd ZdS )	ServiceIdc                 C   s   t | S N)r
   selfr   r   r   	hyphenize.   s   zServiceId.hyphenizeN)r   r   r   r   r   r   r   r   r   -   s    r   c                   @   sn   e Zd ZdZg dZg dZeZdddZe	dd Z
e	d	d
 Ze	dd Zdd Zdd Zedd ZdS )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                 C   sB   || _ |d | _|dd| _|| _|du rt }|| _i | _dS )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getr?   _shape_modelUnresolvableShapeMap_shape_resolver_cache)r   
shape_nameshape_modelshape_resolverr   r   r   __init__`   s   

zShape.__init__c                 C   sF   | j }i }| jD ]}|| j v r|| ||< qd|v r!|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   rA   )rD   SERIALIZED_ATTRSpop)r   modelserializationattrr   r   r   rO      s   

zShape.serializationc                 C   s0   | j }i }| jD ]}|| j v r|| ||< q|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.

        )rD   METADATA_ATTRS)r   rN   metadatarP   r   r   r   rR      s   

zShape.metadatac                 C      | 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.

        r.   rR   rC   r   r   r   r   required_members   s   	zShape.required_membersc                 C      | j |S r   rF   resolve_shape_refr   	shape_refr   r   r   _resolve_shape_ref      zShape._resolve_shape_refc                 C   s   d| j j d| j dS )N<(z)>	__class__r   rA   r   r   r   r   __repr__   s   zShape.__repr__c                 C   s   d S r   r   r   r   r   r   event_stream_name   s   zShape.event_stream_namer   )r   r   r   __doc__rL   rQ   r   MAP_TYPErK   r	   rO   rR   rU   r[   ra   propertyrb   r   r   r   r   r   2   s     
"
 


r   c                   @   sH   e Zd Zedd Zedd Zedd Zedd Zed	d
 ZdS )StructureShapec                 C   s>   | j d|  }|  }| D ]\}}| |||< q|S )Nmembers)rD   rC   rd   itemsr[   )r   rg   shape_membersrA   rZ   r   r   r   rg      s
   zStructureShape.membersc                 C   s,   | j  D ]\}}|jdr|  S qd S )Nr(   )rg   rh   rO   rC   )r   member_namememberr   r   r   rb      s
   z StructureShape.event_stream_namec                 C   s8   | j dds	d S | j di }|d}|r|S | jS )Nr6   Fr5   code)rR   rC   rA   )r   error_metadatarl   r   r   r   
error_code   s   
zStructureShape.error_codec                 C      | j ddS )Nr9   FrT   r   r   r   r   is_document_type      zStructureShape.is_document_typec                 C   ro   )Nr:   FrT   r   r   r   r   is_tagged_union   rq   zStructureShape.is_tagged_unionN)	r   r   r   r	   rg   rb   rn   rp   rr   r   r   r   r   rf      s    




rf   c                   @      e Zd Zedd ZdS )	ListShapec                 C      |  | jd S )Nrk   r[   rD   r   r   r   r   rk        zListShape.memberN)r   r   r   r	   rk   r   r   r   r   rt         rt   c                   @   s$   e Zd Zedd Zedd ZdS )MapShapec                 C   ru   )Nkeyrv   r   r   r   r   rz     rw   zMapShape.keyc                 C   ru   )Nvaluerv   r   r   r   r   r{     rw   zMapShape.valueN)r   r   r   r	   rz   r{   r   r   r   r   ry     s
    
ry   c                   @   rs   )StringShapec                 C   rS   )Nr3   rT   r   r   r   r   r3     rq   zStringShape.enumN)r   r   r   r	   r3   r   r   r   r   r|     rx   r|   c                   @   s&   e Zd ZU eed< eeef ed< dS )StaticContextParameterrA   r{   N)r   r   r   str__annotations__r   boolr   r   r   r   r}     s   
 r}   c                   @   s   e Zd ZU eed< eed< dS )ContextParameterrA   rj   Nr   r   r   r~   r   r   r   r   r   r     s   
 r   c                   @   s&   e Zd ZU eed< eed< eed< dS )ClientContextParameterrA   r>   r?   Nr   r   r   r   r   r   !  s   
 r   c                   @   s  e Zd ZdZd0ddZd0ddZdd Zed	d
 Zdd Z	edd Z
edd Zedd Zedd Zedd Zedd Zedd Zedd Zedd Zedd  Zed!d" Zed#d$ Zed%d& Zed'd( Zd)d* Zed+d, Zejd-d, Zd.d/ ZdS )1ServiceModelzQ

    :ivar service_description: The parsed service description dictionary.

    Nc                 C   s<   || _ |di | _t|di | _t| _|| _i | _dS )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.

        rR   shapesN)	_service_descriptionrC   rR   ShapeResolverrF   NOT_SET_signature_version_service_name_instance_cache)r   service_descriptionservice_namer   r   r   rK   .  s   

zServiceModel.__init__c                 C   s   | j ||S r   )rF   get_shape_by_namer   rH   member_traitsr   r   r   	shape_forM  s   zServiceModel.shape_forc                 C   s   | j |d S r   )_error_code_cacherC   )r   rn   r   r   r   shape_for_error_codeR     z!ServiceModel.shape_for_error_codec                 C   s"   i }| j D ]	}|j}|||< q|S r   )error_shapesrn   )r   error_code_cacheerror_shaperl   r   r   r   r   U  s
   

zServiceModel._error_code_cachec                 C   rV   r   rW   rY   r   r   r   rX   ]  r\   zServiceModel.resolve_shape_refc                 C   s   t | jdi S )Nr   listr   rC   r   r   r   r   shape_names`     zServiceModel.shape_namesc                 C   s6   g }| j D ]}| |}|jddr|| q|S )Nr6   F)r   r   rR   rC   append)r   r   rH   r   r   r   r   r   d  s   


zServiceModel.error_shapesc                 C   s6   z	| j d | }W n ty   t|w t|| |S N
operations)r   KeyErrorr   OperationModel)r   operation_namerN   r   r   r   operation_modelm  s   zServiceModel.operation_modelc                 C   ro   Nr?   r@   )r   rC   r   r   r   r   r?   u  rq   zServiceModel.documentationc                 C   s   t | jdg S r   r   r   r   r   r   operation_namesy  r   zServiceModel.operation_namesc                 C   s   | j dur| 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.

        N)r   endpoint_prefixr   r   r   r   r   }  s   
zServiceModel.service_namec                 C   s,   zt | dW S  ty   t| jdw )N	serviceId)r   )r   _get_metadata_propertyr   r   r   r   r   r   r   
service_id  s
   zServiceModel.service_idc                 C   s   | j d}|du r| 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.
        signingNameN)rR   rC   r   )r   signing_namer   r   r   r     s   zServiceModel.signing_namec                 C   
   |  dS )N
apiVersionr   r   r   r   r   api_version     
zServiceModel.api_versionc                 C   r   )Nprotocolr   r   r   r   r   r     r   zServiceModel.protocolc                 C   r   )NendpointPrefixr   r   r   r   r   r     r   zServiceModel.endpoint_prefixc                 C   s(   | j D ]}| |}|jr|  S qd S r   )r   r   is_endpoint_discovery_operationr   	operationrN   r   r   r   endpoint_discovery_operation  s   

z)ServiceModel.endpoint_discovery_operationc                 C   s6   | j D ]}| |}|jd ur|jdr dS qdS )Nr.   TF)r   r   endpoint_discoveryrC   r   r   r   r   endpoint_discovery_required  s   



z(ServiceModel.endpoint_discovery_requiredc                 C       | j di }dd | D S )Nr<   c                 S   s&   g | ]\}}t ||d  |d dqS )r>   r?   )rA   r>   r?   )r   ).0
param_name	param_valr   r   r   
<listcomp>  s    z:ServiceModel.client_context_parameters.<locals>.<listcomp>)r   rC   rh   r   paramsr   r   r   client_context_parameters  s   z&ServiceModel.client_context_parametersc                 C   s0   z| j | W S  ty   td| d|  w )N"z," not defined in the metadata of the model: )rR   r   r   r   rA   r   r   r   r     s   z#ServiceModel._get_metadata_propertyc                 C   s"   | j tu r| jd}|| _ | j S )NsignatureVersion)r   r   rR   rC   )r   signature_versionr   r   r   r     s   
zServiceModel.signature_versionc                 C   s
   || _ d S r   )r   )r   r{   r   r   r   r     r   c                 C      | j j d| j dS )Nr^   ))r`   r   r   r   r   r   r   ra        zServiceModel.__repr__r   )r   r   r   rc   rK   r   r   r	   r   rX   r   r   r   r   r?   r   r   r   r   r   r   r   r   r   r   r   re   r   setterra   r   r   r   r   r   '  sT    



















r   c                   @   sz  e Zd ZdDddZedd Zedd Zedd	 Zed
d Z	edd Z
edd Zedd Zedd Zedd Zedd Zedd Zedd Zedd Zedd Zed d! Zed"d# Zed$d% Zed&d' Zed(d) Zed*d+ Zed,d- Zed.d/ Zed0d1 Zd2d3 Zd4d5 Zd6d7 Zed8d9 Z ed:d; Z!d<d= Z"d>d? Z#d@dA Z$dBdC Z%dS )Er   Nc                 C   s8   || _ || _|| _|d| _|j| _|di | _dS )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.

        rA   httpN)_operation_model_service_model	_api_namerC   
_wire_namerR   r   )r   r   service_modelrA   r   r   r   rK     s   zOperationModel.__init__c                 C   s   | j d ur| j S | jS r   )r   	wire_namer   r   r   r   rA     s   
zOperationModel.namec                 C      | 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``.

        rA   r   rC   r   r   r   r   r     s   zOperationModel.wire_namec                 C   s   | j S r   )r   r   r   r   r   r      s   zOperationModel.service_modelc                 C   ro   r   r   r   r   r   r   r?   $  rq   zOperationModel.documentationc                 C   ro   )N
deprecatedFr   r   r   r   r   r   (  rq   zOperationModel.deprecatedc                 C   s   | j dd S )Nendpointdiscoveryr   r   r   r   r   r   ,  s   z!OperationModel.endpoint_discoveryc                 C   ro   )NendpointoperationFr   r   r   r   r   r   2  rq   z.OperationModel.is_endpoint_discovery_operationc                 C       d| j vrd S | j| j d S )Ninputr   r   rX   r   r   r   r   input_shape6  s
   
zOperationModel.input_shapec                 C   r   )Noutputr   r   r   r   r   output_shape@  s
   
zOperationModel.output_shapec                 C   s"   | j }|sg S dd |j D S )Nc                 S   s(   g | ]\}}d |j v r|j d  r|qS )r4   )rR   r   rA   shaper   r   r   r   Q  s    
z5OperationModel.idempotent_members.<locals>.<listcomp>r   rg   rh   )r   r   r   r   r   idempotent_membersK  s   z!OperationModel.idempotent_membersc                 C   r   )NstaticContextParamsc                 S   s"   g | ]\}}t ||d dqS )r{   )rA   r{   )r}   rC   )r   rA   propsr   r   r   r   [  s    z<OperationModel.static_context_parameters.<locals>.<listcomp>)r   rC   rh   r   r   r   r   static_context_parametersX  s   z(OperationModel.static_context_parametersc                 C   s    | j sg S dd | j j D S )Nc                 S   s>   g | ]\}}d |j v rd|j d  v rt|j d  d |dqS )r;   rA   )rA   rj   )rR   r   r   r   r   r   r   e  s    
z5OperationModel.context_parameters.<locals>.<listcomp>r   r   r   r   r   context_parameters`  s
   
z!OperationModel.context_parametersc                 C   r   )Nrequestcompressionr   r   r   r   r   request_compressiono     z"OperationModel.request_compressionc                 C   r   )Nauthr   r   r   r   r   r   s  r   zOperationModel.authc                 C   r   )Nauthtyper   r   r   r   r   	auth_typew  r   zOperationModel.auth_typec                 C   s   | j rt| j S | jS r   )r   r   r   r   r   r   r   resolved_auth_type{  s   
z!OperationModel.resolved_auth_typec                 C   r   )NunsignedPayloadr   r   r   r   r   unsigned_payload  r   zOperationModel.unsigned_payloadc                    s$    j dg }t fdd|D S )Nerrorsc                 3   s    | ]	} j |V  qd S r   )r   rX   )r   sr   r   r   	<genexpr>  s    z.OperationModel.error_shapes.<locals>.<genexpr>)r   rC   r   )r   r   r   r   r   r     s   zOperationModel.error_shapesc                 C   r   )Nendpointr   r   r   r   r   r     r   zOperationModel.endpointc                 C   ro   )NhttpChecksumRequiredFr   r   r   r   r   http_checksum_required  rq   z%OperationModel.http_checksum_requiredc                 C   s   | j di S )NhttpChecksumr   r   r   r   r   http_checksum  rq   zOperationModel.http_checksumc                 C      |   d uS r   )get_event_stream_inputr   r   r   r   has_event_stream_input  r   z%OperationModel.has_event_stream_inputc                 C   r   r   )get_event_stream_outputr   r   r   r   has_event_stream_output  r   z&OperationModel.has_event_stream_outputc                 C      |  | jS r   )_get_event_streamr   r   r   r   r   r     r\   z%OperationModel.get_event_stream_inputc                 C   r   r   )r   r   r   r   r   r   r     r\   z&OperationModel.get_event_stream_outputc                 C   s$   |du rdS |j }|r|j| S dS )zAReturns the event stream member's shape if any or None otherwise.N)rb   rg   )r   r   
event_namer   r   r   r     s   
z OperationModel._get_event_streamc                 C   r   r   )get_streaming_inputr   r   r   r   has_streaming_input  r   z"OperationModel.has_streaming_inputc                 C   r   r   )get_streaming_outputr   r   r   r   has_streaming_output  r   z#OperationModel.has_streaming_outputc                 C   r   r   )_get_streaming_bodyr   r   r   r   r   r     r\   z"OperationModel.get_streaming_inputc                 C   r   r   )r   r   r   r   r   r   r     r\   z#OperationModel.get_streaming_outputc                 C   s<   |du rdS |j d}|dur|j| }|jdkr|S dS )z?Returns the streaming member's shape if any; or None otherwise.Nr"   blob)rO   rC   rg   rB   )r   r   r"   payload_shaper   r   r   r     s   

z"OperationModel._get_streaming_bodyc                 C   r   )Nz(name=r   r_   r   r   r   r   ra     r   zOperationModel.__repr__r   )&r   r   r   rK   r	   rA   re   r   r   r?   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   ra   r   r   r   r   r     sv    
%







	















	

r   c                   @   s8   e Zd ZdZeeeedZdd Z	d
ddZ
dd	 ZdS )r   zResolves shape references.)	structurer   mapstringc                 C   s   || _ i | _d S r   )
_shape_map_shape_cache)r   	shape_mapr   r   r   rK     s   
zShapeResolver.__init__Nc                 C   s   z| j | }W n ty   t|w z| j|d t}W n ty,   td| w |r8| }|| |||| }|S )Nr>   z&Shape is missing required key 'type': )	r  r   r   SHAPE_CLASSESrC   r   r   copyupdate)r   rH   r   rI   	shape_clsresultr   r   r   r     s"   
zShapeResolver.get_shape_by_namec                 C   sb   t |dkrd|v r| |d S | }z|d}W n ty*   td| w | ||S )N   r   z(Invalid model, missing shape reference: )lenr   r	  rM   r   r   )r   rZ   r   rH   r   r   r   rX     s   zShapeResolver.resolve_shape_refr   )r   r   r   rc   rf   rt   ry   r|   r  rK   r   rX   r   r   r   r   r     s    
r   c                   @   s"   e Zd ZdZdddZdd ZdS )rE   zEA ShapeResolver that will throw ValueErrors when shapes are resolved.Nc                 C      t d| d)NzAttempted to lookup shape '!', but no shape map was provided.
ValueErrorr   r   r   r   r        
z&UnresolvableShapeMap.get_shape_by_namec                 C   r  )NzAttempted to resolve shape 'r  r  rY   r   r   r   rX     r  z&UnresolvableShapeMap.resolve_shape_refr   )r   r   r   rc   r   rX   r   r   r   r   rE      s    
rE   c                   @   sf   e Zd ZdZdZdddZdd Zdd	 Zd
d Zdd Z	dd Z
dd Zdd Zdd Zdd ZdS )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                 C   s.   t  | _t | _|d u r| jd| _d S d S )Nr  )r   rg   ShapeNameGenerator_name_generatornew_shape_namerA   r   r   r   r   rK   @  s
   z%DenormalizedStructureBuilder.__init__c                 C   s
   || _ | S )zp

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

        :return: self

        )_members)r   rg   r   r   r   with_membersF  s   	z)DenormalizedStructureBuilder.with_membersc                 C   sB   t  }d| jd}| ||| j t|d}t| j|| j |dS )zBuild the model based on the provided members.

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

        r  )r>   rg   )r  )rH   rI   rJ   )r   r  _build_modelrA   r   rf   )r   r   denormalizedresolverr   r   r   build_modelR  s   
z(DenormalizedStructureBuilder.build_modelc                 C   s   |d dkr|  ||||< d S |d dkr | ||||< d S |d dkr0| ||||< d S |d | jv r@| |||< d S td|d  )Nr>   r  r   r  zUnknown shape type: )_build_structure_build_list
_build_mapSCALAR_TYPES_build_scalarr   )r   rN   r   rH   r   r   r   r!  f  s   z)DenormalizedStructureBuilder._build_modelc                 C   s\   t  }| |}||d< |dt   D ]\}}| |}d|i||< | ||| q|S )Nrg   r   )r   _build_initial_shaperC   rh   _get_shape_namer!  )r   rN   r   rg   r   rA   member_modelmember_shape_namer   r   r   r%  r  s   

z-DenormalizedStructureBuilder._build_structurec                 C   s6   |  |}| |}d|i|d< | |d || |S )Nr   rk   r+  r*  r!  )r   rN   r   r-  r   r   r   r   r&  }  s
   

z(DenormalizedStructureBuilder._build_listc                 C   sf   |  |d }|  |d }| |}d|i|d< d|i|d< | |d || | |d || |S )Nrz   r{   r   r.  )r   rN   r   key_shape_namevalue_shape_namer   r   r   r   r'    s   
z'DenormalizedStructureBuilder._build_mapc                 C   sD   d|d i}d|v r|d |d< t jD ]}||v r|| ||< q|S )Nr>   r?   )r   rQ   )r   rN   r   rP   r   r   r   r*    s   
z1DenormalizedStructureBuilder._build_initial_shapec                 C   s
   |  |S r   )r*  r   rN   r   r   r   r)    s   
z*DenormalizedStructureBuilder._build_scalarc                 C   s    d|v r|d S | j |d S )NrH   r>   )r  r  r1  r   r   r   r+    s   z,DenormalizedStructureBuilder._get_shape_namer   )r   r   r   rc   r(  rK   r   r$  r!  r%  r&  r'  r*  r)  r+  r   r   r   r   r    s    $

r  c                   @   s    e Zd ZdZdd Zdd ZdS )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                 C   s   t t| _d S r   )r   int_name_cacher   r   r   r   rK     r   zShapeNameGenerator.__init__c                 C   s.   | j |  d7  < | 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

        r  Type)r3  
capitalize)r   rB   current_indexr   r   r   r    s   
z!ShapeNameGenerator.new_shape_nameN)r   r   r   rc   rK   r  r   r   r   r   r    s    r  N)(rc   collectionsr   typingr   r   botocore.authr   botocore.compatr   botocore.exceptionsr   r   botocore.utilsr	   r
   r   objectr   	Exceptionr   r   r   r   r~   r   r   rf   rt   ry   r|   r}   r   r   r   r   r   rE   r  r  r   r   r   r   <module>   s>    &*
 ? f6 