o
    ~j@cv                     @   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	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)OrderedDict)MissingServiceIdErrorUndefinedModelAttributeError)CachedPropertyhyphenize_service_idinstance_cachec                   @      e Zd ZdS )NoShapeFoundErrorN__name__
__module____qualname__ r   r   2usr/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.)locationNameZ	queryNameZ	flattenedlocationpayloadZ	streamingtimestampFormatZxmlNamespaceZresultWrapperZxmlAttributeeventstreameventZeventheaderZeventpayloadZ	jsonvaluer    Z	hostLabel)requiredminmaxpatternZ	sensitiveenumidempotencyTokenerror	exceptionZendpointdiscoveryidZ	retryabledocumentunioncontextParamclientContextParamsNc                 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getr0   _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   r2   )r5   SERIALIZED_ATTRSpop)r   modelserializationattrr   r   r   r@      s   

zShape.serializationc                 C   s0   | j }i }| jD ]}|| j v r|| ||< q|S )as  Metadata about the shape.

        This requires optional information about the shape, including:

            * min
            * max
            * pattern
            * enum
            * sensitive
            * required
            * idempotencyToken
            * document
            * union

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

        )r5   METADATA_ATTRS)r   r?   metadatarA   r   r   r   rC      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#   rC   r4   r   r   r   r   required_members   s   	zShape.required_membersc                 C      | j |S r   r7   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   r2   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__r=   rB   r   MAP_TYPEr<   r   r@   rC   rF   rL   rR   propertyrS   r   r   r   r   r   0   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)r5   r4   rU   itemsrL   )r   rX   Zshape_membersr2   rK   r   r   r   rX      s
   zStructureShape.membersc                 C   s,   | j  D ]\}}|jdr|  S qd S )Nr!   )rX   rY   r@   r4   )r   member_namememberr   r   r   rS      s
   z StructureShape.event_stream_namec                 C   s8   | j dds	d S | j di }|d}|r|S | jS )Nr*   Fr)   code)rC   r4   r2   )r   Zerror_metadatar\   r   r   r   
error_code   s   
zStructureShape.error_codec                 C      | j ddS )Nr+   FrE   r   r   r   r   is_document_type      zStructureShape.is_document_typec                 C   r^   )Nr,   FrE   r   r   r   r   is_tagged_union   r`   zStructureShape.is_tagged_unionN)	r   r   r   r   rX   rS   r]   r_   ra   r   r   r   r   rW      s    




rW   c                   @      e Zd Zedd ZdS )	ListShapec                 C      |  | jd S )Nr[   rL   r5   r   r   r   r   r[         zListShape.memberN)r   r   r   r   r[   r   r   r   r   rc          rc   c                   @   s$   e Zd Zedd Zedd ZdS )MapShapec                 C   rd   )Nkeyre   r   r   r   r   ri     rf   zMapShape.keyc                 C   rd   )Nvaluere   r   r   r   r   rj     rf   zMapShape.valueN)r   r   r   r   ri   rj   r   r   r   r   rh     s
    
rh   c                   @   rb   )StringShapec                 C   rD   )Nr'   rE   r   r   r   r   r'     r`   zStringShape.enumN)r   r   r   r   r'   r   r   r   r   rk     rg   rk   c                   @   s&   e Zd ZU eed< eeef ed< dS )StaticContextParameterr2   rj   N)r   r   r   str__annotations__r   boolr   r   r   r   rl     s   
 rl   c                   @   s   e Zd ZU eed< eed< dS )ContextParameterr2   rZ   Nr   r   r   rm   rn   r   r   r   r   rp     s   
 rp   c                   @   s&   e Zd ZU eed< eed< eed< dS )ClientContextParameterr2   r/   r0   Nrq   r   r   r   r   rr     s   
 rr   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.

        rC   shapesN)	_service_descriptionr4   rC   ShapeResolverr7   NOT_SET_signature_version_service_nameZ_instance_cache)r   Zservice_descriptionservice_namer   r   r   r<   (  s   

zServiceModel.__init__c                 C   s   | j ||S r   )r7   get_shape_by_namer   r9   member_traitsr   r   r   	shape_forG  s   zServiceModel.shape_forc                 C   s   | j |d S r   )_error_code_cacher4   )r   r]   r   r   r   shape_for_error_codeL     z!ServiceModel.shape_for_error_codec                 C   s"   i }| j D ]	}|j}|||< q|S r   )error_shapesr]   )r   Zerror_code_cacheerror_shaper\   r   r   r   r   O  s
   

zServiceModel._error_code_cachec                 C   rG   r   rH   rJ   r   r   r   rI   W  rM   zServiceModel.resolve_shape_refc                 C   s   t | jdi S )Nrt   listru   r4   r   r   r   r   shape_namesZ     zServiceModel.shape_namesc                 C   s6   g }| j D ]}| |}|jddr|| q|S )Nr*   F)r   r~   rC   r4   append)r   r   r9   r   r   r   r   r   ^  s   


zServiceModel.error_shapesc                 C   s6   z	| j d | }W n ty   t|w t|| |S NZ
operations)ru   KeyErrorr   OperationModel)r   Zoperation_namer?   r   r   r   operation_modelg  s   zServiceModel.operation_modelc                 C   r^   Nr0   r1   )ru   r4   r   r   r   r   r0   o  r`   zServiceModel.documentationc                 C   s   t | jdg S r   r   r   r   r   r   operation_namess  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)ry   endpoint_prefixr   r   r   r   rz   w  s   
zServiceModel.service_namec                 C   s,   zt | dW S  ty   t| jdw )NZ	serviceId)rz   )r   _get_metadata_propertyr   r   ry   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.
        ZsigningNameN)rC   r4   r   )r   signing_namer   r   r   r     s   zServiceModel.signing_namec                 C   
   |  dS )NZ
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   )NZ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   Z	operationr?   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_discoveryr4   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/   r0   )r2   r/   r0   )rr   ).0
param_nameZ	param_valr   r   r   
<listcomp>  s    z:ServiceModel.client_context_parameters.<locals>.<listcomp>)ru   r4   rY   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: )rC   r   r   r   r2   r   r   r   r     s   z#ServiceModel._get_metadata_propertyc                 C   s"   | j tu r| jd}|| _ | j S )NZsignatureVersion)rx   rw   rC   r4   )r   signature_versionr   r   r   r     s   
zServiceModel.signature_versionc                 C   s
   || _ d S r   )rx   )r   rj   r   r   r   r     r   c                 C      | j j d| j dS )NrO   ))rQ   r   rz   r   r   r   r   rR        zServiceModel.__repr__r   )r   r   r   rT   r<   r~   r   r   r   rI   r   r   r
   r   r0   r   rz   r   r   r   r   r   r   r   r   r   rV   r   setterrR   r   r   r   r   rs   !  sT    



















rs   c                   @   sJ  e Zd Zd<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d*d+ Zd,d- Zd.d/ Zed0d1 Zed2d3 Zd4d5 Zd6d7 Zd8d9 Z d:d; Z!dS )=r   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.

        r2   httpN)_operation_model_service_model	_api_namer4   Z
_wire_namerC   r   )r   r   service_modelr2   r   r   r   r<     s   zOperationModel.__init__c                 C   s   | j d ur| j S | jS r   )r   	wire_namer   r   r   r   r2     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 operaiton name
        we send across the wire (e.g cloudfront).

        Any serialization code should use ``wire_name``.

        r2   r   r4   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   r^   r   r   r   r   r   r   r0     r`   zOperationModel.documentationc                 C   r^   )N
deprecatedFr   r   r   r   r   r   "  r`   zOperationModel.deprecatedc                 C   s   | j dd S )NZendpointdiscoveryr   r   r   r   r   r   &  s   z!OperationModel.endpoint_discoveryc                 C   r^   )NZendpointoperationFr   r   r   r   r   r   ,  r`   z.OperationModel.is_endpoint_discovery_operationc                 C       d| j vrd S | j| j d S )Ninputr   r   rI   r   r   r   r   input_shape0  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 )r(   )rC   r   r2   shaper   r   r   r   K  s    
z5OperationModel.idempotent_members.<locals>.<listcomp>r   rX   rY   )r   r   r   r   r   idempotent_membersE  s   z!OperationModel.idempotent_membersc                 C   r   )NZstaticContextParamsc                 S   s"   g | ]\}}t ||d dqS )rj   )r2   rj   )rl   r4   )r   r2   propsr   r   r   r   U  s    z<OperationModel.static_context_parameters.<locals>.<listcomp>)r   r4   rY   r   r   r   r   static_context_parametersR  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-   r2   )r2   rZ   )rC   rp   r   r   r   r   r   _  s    
z5OperationModel.context_parameters.<locals>.<listcomp>r   r   r   r   r   context_parametersZ  s
   
z!OperationModel.context_parametersc                 C   r   )NZauthtyper   r   r   r   r   	auth_typei     zOperationModel.auth_typec                    s$    j dg }t fdd|D S )Nerrorsc                 3   s    | ]	} j |V  qd S r   )r   rI   )r   sr   r   r   	<genexpr>p  s    z.OperationModel.error_shapes.<locals>.<genexpr>)r   r4   r   )r   rt   r   r   r   r   m  s   zOperationModel.error_shapesc                 C   r   )Nendpointr   r   r   r   r   r   r  r   zOperationModel.endpointc                 C   r^   )NZhttpChecksumRequiredFr   r   r   r   r   http_checksum_requiredv  r`   z%OperationModel.http_checksum_requiredc                 C   s   | j di S )NZhttpChecksumr   r   r   r   r   http_checksumz  r`   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     rM   z%OperationModel.get_event_stream_inputc                 C   r   r   )r   r   r   r   r   r   r     rM   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)rS   rX   )r   r   Z
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     rM   z"OperationModel.get_streaming_inputc                 C   r   r   )r   r   r   r   r   r   r     rM   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)r@   r4   rX   r3   )r   r   r   Zpayload_shaper   r   r   r     s   

z"OperationModel._get_streaming_bodyc                 C   r   )Nz(name=r   rP   r   r   r   r   rR     r   zOperationModel.__repr__r   )"r   r   r   r<   r   r2   rV   r   r   r0   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rR   r   r   r   r   r     sf    
%







	











	

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 )rv   zResolves shape references.)	structurer   mapstringc                 C   s   || _ i | _d S r   )
_shape_mapZ_shape_cache)r   	shape_mapr   r   r   r<     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_CLASSESr4   r   r   copyupdate)r   r9   r}   r:   Z	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   r>   r   r   )r   rK   r}   r9   r   r   r   rI     s   zShapeResolver.resolve_shape_refr   )r   r   r   rT   rW   rc   rh   rk   r   r<   r{   rI   r   r   r   r   rv     s    
rv   c                   @   s"   e Zd ZdZdddZdd ZdS )r6   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   rJ   r   r   r   rI     r   z&UnresolvableShapeMap.resolve_shape_refr   )r   r   r   rT   r{   rI   r   r   r   r   r6     s    
r6   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   integerZbooleanr   float	timestamplongZdoublecharNc                 C   s.   t  | _t | _|d u r| jd| _d S d S )Nr   )r   rX   ShapeNameGenerator_name_generatornew_shape_namer2   r   r   r   r   r<   (  s
   z%DenormalizedStructureBuilder.__init__c                 C   s
   || _ | S )zp

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

        :return: self

        )_members)r   rX   r   r   r   with_members.  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/   rX   )r   )r9   r:   r;   )r   r   _build_modelr2   rv   rW   )r   rt   Zdenormalizedresolverr   r   r   build_model:  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   r?   rt   r9   r   r   r   r   N  s   z)DenormalizedStructureBuilder._build_modelc                 C   s\   t  }| |}||d< |dt   D ]\}}| |}d|i||< | ||| q|S )NrX   r   )r   _build_initial_shaper4   rY   _get_shape_namer   )r   r?   rt   rX   r   r2   Zmember_modelmember_shape_namer   r   r   r   Z  s   

z-DenormalizedStructureBuilder._build_structurec                 C   s6   |  |}| |}d|i|d< | |d || |S )Nr   r[   r   r   r   )r   r?   rt   r   r   r   r   r   r   e  s
   

z(DenormalizedStructureBuilder._build_listc                 C   sf   |  |d }|  |d }| |}d|i|d< d|i|d< | |d || | |d || |S )Nri   rj   r   r   )r   r?   rt   Zkey_shape_nameZvalue_shape_namer   r   r   r   r   l  s   
z'DenormalizedStructureBuilder._build_mapc                 C   sD   d|d i}d|v r|d |d< t jD ]}||v r|| ||< q|S )Nr/   r0   )r   rB   )r   r?   r   rA   r   r   r   r   v  s   
z1DenormalizedStructureBuilder._build_initial_shapec                 C   s
   |  |S r   )r   r   r?   r   r   r   r     s   
z*DenormalizedStructureBuilder._build_scalarc                 C   s    d|v r|d S | j |d S )Nr9   r/   )r   r   r   r   r   r   r     s   z,DenormalizedStructureBuilder._get_shape_namer   )r   r   r   rT   r   r<   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   r<     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)r   
capitalize)r   r3   Zcurrent_indexr   r   r   r     s   
z!ShapeNameGenerator.new_shape_nameN)r   r   r   rT   r<   r   r   r   r   r   r     s    r   N)&rT   collectionsr   typingr   r   Zbotocore.compatr   Zbotocore.exceptionsr   r   Zbotocore.utilsr   r	   r
   objectrw   	Exceptionr   r   r   r   rm   r   r   rW   rc   rh   rk   rl   rp   rr   rs   r   rv   r6   r   r   r   r   r   r   <module>   s<    "*
 ? T6 