U
    ÒZj°v  ã                   @   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                   @   s   e Zd ZdS )ÚNoShapeFoundErrorN©Ú__name__Ú
__module__Ú__qualname__© r   r   úQ/var/www/html/TRUCKING_PROJECT/venv/lib/python3.8/site-packages/botocore/model.pyr      s   r   c                   @   s   e Zd ZdS )ÚInvalidShapeErrorNr   r   r   r   r   r      s   r   c                   @   s   e Zd ZdS )ÚOperationNotFoundErrorNr   r   r   r   r   r   #   s   r   c                   @   s   e Zd ZdS )ÚInvalidShapeReferenceErrorNr   r   r   r   r   r   '   s   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                   @   s¦   e Zd ZdZdddddddd	d
ddddddddgZddddddddddddddd gZeZd0d"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 )1ÚShapez3Object representing a shape from the service model.ÚlocationNameZ	queryNameZ	flattenedÚlocationÚpayloadZ	streamingZtimestampFormatZxmlNamespaceZresultWrapperZxmlAttributeÚeventstreamÚeventZeventheaderZeventpayloadZ	jsonvalueZ	hostLabelÚrequiredÚminÚmaxÚpatternZ	sensitiveÚenumÚidempotencyTokenÚerrorÚ	exceptionZendpointdiscoveryidZ	retryableÚdocumentÚunionÚcontextParamÚclientContextParamsNc                 C   sB   || _ |d | _| dd¡| _|| _|dkr2tƒ }|| _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 kr|| ||< qd|krB| 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   r/   )r2   ÚSERIALIZED_ATTRSÚpop)r   ÚmodelÚserializationÚattrr   r   r   r=      s    

zShape.serializationc                 C   s0   | j }i }| jD ]}|| j k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.

        )r2   ÚMETADATA_ATTRS)r   r<   Úmetadatar>   r   r   r   r@       s    

zShape.metadatac                 C   s   | j  dg ¡S )zïA 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    ©r@   r1   r   r   r   r   Úrequired_members»   s    	zShape.required_membersc                 C   s   | j  |¡S r   ©r4   Úresolve_shape_ref©r   Ú	shape_refr   r   r   Ú_resolve_shape_refÆ   s    zShape._resolve_shape_refc                 C   s   d| j j› d| j› d�S )Nú<ú(z)>©Ú	__class__r   r/   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_name)N)r   r   r   Ú__doc__r:   r?   r   ÚMAP_TYPEr9   r   r=   r@   rB   rG   rL   ÚpropertyrM   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)r2   r1   rO   ÚitemsrG   )r   rR   Zshape_membersr/   rF   r   r   r   rR   Ò   s
    zStructureShape.membersc                 C   s,   | j  ¡ D ]\}}|j d¡r
|  S q
d S )Nr   )rR   rS   r=   r1   )r   Úmember_nameÚmemberr   r   r   rM   à   s    
z StructureShape.event_stream_namec                 C   s8   | j  dd¡sd S | j  di ¡}| d¡}|r2|S | jS )Nr'   Fr&   Úcode)r@   r1   r/   )r   Zerror_metadatarV   r   r   r   Ú
error_codeç   s    
zStructureShape.error_codec                 C   s   | j  dd¡S )Nr(   FrA   r   r   r   r   Úis_document_typeò   s    zStructureShape.is_document_typec                 C   s   | j  dd¡S )Nr)   FrA   r   r   r   r   Úis_tagged_unionö   s    zStructureShape.is_tagged_unionN)	r   r   r   r   rR   rM   rW   rX   rY   r   r   r   r   rQ   Ñ   s   




rQ   c                   @   s   e Zd Zedd„ ƒZdS )Ú	ListShapec                 C   s   |   | jd ¡S )NrU   ©rG   r2   r   r   r   r   rU   ü   s    zListShape.memberN)r   r   r   r   rU   r   r   r   r   rZ   û   s   rZ   c                   @   s$   e Zd Zedd„ ƒZedd„ ƒZdS )ÚMapShapec                 C   s   |   | jd ¡S )NÚkeyr[   r   r   r   r   r]     s    zMapShape.keyc                 C   s   |   | jd ¡S )NÚvaluer[   r   r   r   r   r^     s    zMapShape.valueN)r   r   r   r   r]   r^   r   r   r   r   r\     s   
r\   c                   @   s   e Zd Zedd„ ƒZdS )ÚStringShapec                 C   s   | j  dg ¡S )Nr$   rA   r   r   r   r   r$     s    zStringShape.enumN)r   r   r   r   r$   r   r   r   r   r_     s   r_   c                   @   s&   e Zd ZU eed< eeef ed< dS )ÚStaticContextParameterr/   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 )ÚContextParameterr/   rT   N©r   r   r   ra   rb   r   r   r   r   rd     s   
rd   c                   @   s&   e Zd ZU eed< eed< eed< dS )ÚClientContextParameterr/   r,   r-   Nre   r   r   r   r   rf     s   
rf   c                   @   s  e Zd ZdZd0dd„Zd1d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 )2Ú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.

        r@   ÚshapesN)	Ú_service_descriptionr1   r@   ÚShapeResolverr4   ÚNOT_SETÚ_signature_versionÚ_service_nameZ_instance_cache)r   Zservice_descriptionÚservice_namer   r   r   r9   (  s    
ÿzServiceModel.__init__c                 C   s   | j  ||¡S r   )r4   Úget_shape_by_name©r   r6   Úmember_traitsr   r   r   Ú	shape_forG  s     ÿzServiceModel.shape_forc                 C   s   | j  |d ¡S r   )Ú_error_code_cacher1   )r   rW   r   r   r   Úshape_for_error_codeL  s    z!ServiceModel.shape_for_error_codec                 C   s"   i }| j D ]}|j}|||< q
|S r   )Úerror_shapesrW   )r   Zerror_code_cacheÚerror_shaperV   r   r   r   rs   O  s
    

zServiceModel._error_code_cachec                 C   s   | j  |¡S r   rC   rE   r   r   r   rD   W  s    zServiceModel.resolve_shape_refc                 C   s   t | j di ¡ƒS )Nrh   ©Úlistri   r1   r   r   r   r   Úshape_namesZ  s    zServiceModel.shape_namesc                 C   s6   g }| j D ]&}|  |¡}|j dd¡r
| |¡ q
|S )Nr'   F)ry   rr   r@   r1   Úappend)r   ru   r6   rv   r   r   r   ru   ^  s    

zServiceModel.error_shapesc                 C   s<   z| j d | }W n tk
r.   t|ƒ‚Y nX t|| |ƒS ©NÚ
operations)ri   ÚKeyErrorr   ÚOperationModel)r   Zoperation_namer<   r   r   r   Úoperation_modelg  s
    zServiceModel.operation_modelc                 C   s   | j  dd¡S ©Nr-   r.   )ri   r1   r   r   r   r   r-   o  s    zServiceModel.documentationc                 C   s   t | j dg ¡ƒS r{   rw   r   r   r   r   Úoperation_namess  s    zServiceModel.operation_namesc                 C   s   | j dk	r| j S | jS d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)rm   Úendpoint_prefixr   r   r   r   rn   w  s    
zServiceModel.service_namec                 C   s6   zt |  d¡ƒW S  tk
r0   t| jd�‚Y nX d S )NZ	serviceId)rn   )r   Ú_get_metadata_propertyr   r   rm   r   r   r   r   Ú
service_idˆ  s    zServiceModel.service_idc                 C   s   | j  d¡}|dkr| j}|S )z®The 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)r@   r1   r‚   )r   Úsigning_namer   r   r   r…   �  s    zServiceModel.signing_namec                 C   s
   |   d¡S )NZ
apiVersion©rƒ   r   r   r   r   Úapi_version›  s    zServiceModel.api_versionc                 C   s
   |   d¡S )NÚprotocolr†   r   r   r   r   rˆ   Ÿ  s    zServiceModel.protocolc                 C   s
   |   d¡S )NZendpointPrefixr†   r   r   r   r   r‚   £  s    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 k	r|j d¡r dS qdS )Nr    TF)r�   r   Úendpoint_discoveryr1   rŠ   r   r   r   Úendpoint_discovery_required®  s    

ÿ
þz(ServiceModel.endpoint_discovery_requiredc                 C   s    | j  di ¡}dd„ | ¡ D ƒS )Nr+   c                 S   s&   g | ]\}}t ||d  |d d�‘qS )r,   r-   )r/   r,   r-   )rf   )Ú.0Ú
param_nameZ	param_valr   r   r   Ú
<listcomp>¼  s   ûýz:ServiceModel.client_context_parameters.<locals>.<listcomp>)ri   r1   rS   ©r   Úparamsr   r   r   Úclient_context_parameters¹  s    úz&ServiceModel.client_context_parametersc                 C   s:   z| j | W S  tk
r4   td|› d| › �ƒ‚Y nX d S )Nú"z," not defined in the metadata of the model: )r@   r}   r   ©r   r/   r   r   r   rƒ   Å  s    ÿz#ServiceModel._get_metadata_propertyc                 C   s"   | j tkr| j d¡}|| _ | j S )NZsignatureVersion)rl   rk   r@   r1   )r   Úsignature_versionr   r   r   r–   Ð  s    
zServiceModel.signature_versionc                 C   s
   || _ d S r   )rl   )r   r^   r   r   r   r–   ×  s    c                 C   s   | j j› d| j› d�S )NrI   ú))rK   r   rn   r   r   r   r   rL   Û  s    zServiceModel.__repr__)N)N)r   r   r   rN   r9   rr   rt   r   rs   rD   ry   ru   r
   r   r-   r�   rn   r„   r…   r‡   rˆ   r‚   r‹   r�   r“   rƒ   rP   r–   ÚsetterrL   r   r   r   r   rg   !  sR   



















rg   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.

        r/   ÚhttpN)Ú_operation_modelÚ_service_modelÚ	_api_namer1   Z
_wire_namer@   r™   )r   r   Úservice_modelr/   r   r   r   r9   à  s    zOperationModel.__init__c                 C   s   | j d k	r| j S | jS d S r   )rœ   Ú	wire_namer   r   r   r   r/     s    
zOperationModel.namec                 C   s   | 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``.

        r/   ©rš   r1   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   s   | j  dd¡S r€   rŸ   r   r   r   r   r-     s    zOperationModel.documentationc                 C   s   | j  dd¡S )NÚ
deprecatedFrŸ   r   r   r   r   r    "  s    zOperationModel.deprecatedc                 C   s   | j  dd ¡S )NZendpointdiscoveryrŸ   r   r   r   r   rŒ   &  s    z!OperationModel.endpoint_discoveryc                 C   s   | j  dd¡S )NZendpointoperationFrŸ   r   r   r   r   r‰   ,  s    z.OperationModel.is_endpoint_discovery_operationc                 C   s    d| j krd S | j | j d ¡S )NÚinput©rš   r›   rD   r   r   r   r   Úinput_shape0  s
    
ÿzOperationModel.input_shapec                 C   s    d| j krd S | j | j d ¡S )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 kr|j d  r|‘qS )r%   )r@   ©rŽ   r/   Úshaper   r   r   r�   K  s   

ýz5OperationModel.idempotent_members.<locals>.<listcomp>©r£   rR   rS   )r   r£   r   r   r   Úidempotent_membersE  s    þz!OperationModel.idempotent_membersc                 C   s    | j  di ¡}dd„ | ¡ D ƒS )NZstaticContextParamsc                 S   s"   g | ]\}}t || d ¡d�‘qS )r^   )r/   r^   )r`   r1   )rŽ   r/   Úpropsr   r   r   r�   U  s   ÿz<OperationModel.static_context_parameters.<locals>.<listcomp>)rš   r1   rS   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 | ]6\}}d |j krd|j d  krt|j d  d |d�‘qS )r*   r/   )r/   rT   )r@   rd   r¦   r   r   r   r�   _  s   
úþz5OperationModel.context_parameters.<locals>.<listcomp>r¨   r   r   r   r   Úcontext_parametersZ  s
    
ûz!OperationModel.context_parametersc                 C   s   | j  d¡S )NZauthtyperŸ   r   r   r   r   Ú	auth_typei  s    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›   rD   )rŽ   Úsr   r   r   Ú	<genexpr>p  s     z.OperationModel.error_shapes.<locals>.<genexpr>)rš   r1   rx   )r   rh   r   r   r   ru   m  s    zOperationModel.error_shapesc                 C   s   | j  d¡S )NÚendpointrŸ   r   r   r   r   r±   r  s    zOperationModel.endpointc                 C   s   | j  dd¡S )NZhttpChecksumRequiredFrŸ   r   r   r   r   Úhttp_checksum_requiredv  s    z%OperationModel.http_checksum_requiredc                 C   s   | j  di ¡S )NZhttpChecksumrŸ   r   r   r   r   Úhttp_checksumz  s    zOperationModel.http_checksumc                 C   s   |   ¡ d k	S r   )Úget_event_stream_inputr   r   r   r   Úhas_event_stream_input~  s    z%OperationModel.has_event_stream_inputc                 C   s   |   ¡ d k	S r   )Úget_event_stream_outputr   r   r   r   Úhas_event_stream_output‚  s    z&OperationModel.has_event_stream_outputc                 C   s   |   | j¡S r   )Ú_get_event_streamr£   r   r   r   r   r´   †  s    z%OperationModel.get_event_stream_inputc                 C   s   |   | j¡S r   )r¸   r¥   r   r   r   r   r¶   ‰  s    z&OperationModel.get_event_stream_outputc                 C   s$   |dkrdS |j }|r |j| S dS )zAReturns the event stream member's shape if any or None otherwise.N)rM   rR   )r   r§   Z
event_namer   r   r   r¸   Œ  s    
z OperationModel._get_event_streamc                 C   s   |   ¡ d k	S r   )Úget_streaming_inputr   r   r   r   Úhas_streaming_input•  s    z"OperationModel.has_streaming_inputc                 C   s   |   ¡ d k	S r   )Úget_streaming_outputr   r   r   r   Úhas_streaming_output™  s    z#OperationModel.has_streaming_outputc                 C   s   |   | j¡S r   )Ú_get_streaming_bodyr£   r   r   r   r   r¹   �  s    z"OperationModel.get_streaming_inputc                 C   s   |   | j¡S r   )r½   r¥   r   r   r   r   r»      s    z#OperationModel.get_streaming_outputc                 C   s<   |dkrdS |j  d¡}|dk	r8|j| }|jdkr8|S dS )z?Returns the streaming member's shape if any; or None otherwise.Nr   Úblob)r=   r1   rR   r0   )r   r§   r   Zpayload_shaper   r   r   r½   £  s    

z"OperationModel._get_streaming_bodyc                 C   s   | j j› d| j› d�S )Nz(name=r—   rJ   r   r   r   r   rL   ®  s    zOperationModel.__repr__)N)"r   r   r   r9   r   r/   rP   rž   r�   r-   r    rŒ   r‰   r£   r¥   r©   r«   r¬   r­   ru   r±   r²   r³   rµ   r·   r´   r¶   r¸   rº   r¼   r¹   r»   r½   rL   r   r   r   r   r~   ß  sd   
%







	











	

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 )rj   zResolves shape references.)Ú	structurerx   ÚmapÚstringc                 C   s   || _ i | _d S r   )Ú
_shape_mapZ_shape_cache)r   Ú	shape_mapr   r   r   r9   ½  s    zShapeResolver.__init__Nc                 C   sŒ   z| j | }W n tk
r*   t|ƒ‚Y nX z| j |d t¡}W n" tk
rd   td|› �ƒ‚Y nX |r|| ¡ }| |¡ |||| ƒ}|S )Nr,   z&Shape is missing required key 'type': )	rÂ   r}   r   ÚSHAPE_CLASSESr1   r   r   ÚcopyÚupdate)r   r6   rq   r7   Z	shape_clsÚresultr   r   r   ro   Á  s    ÿ

zShapeResolver.get_shape_by_namec                 C   sl   t |ƒdkr"d|kr"|  |d ¡S | ¡ }z| d¡}W n" tk
rZ   td|› �ƒ‚Y nX |  ||¡S d S )Né   r§   z(Invalid model, missing shape reference: )Úlenro   rÅ   r;   r}   r   )r   rF   rq   r6   r   r   r   rD   Ò  s    ÿ
zShapeResolver.resolve_shape_ref)N)r   r   r   rN   rQ   rZ   r\   r_   rÄ   r9   ro   rD   r   r   r   r   rj   ²  s   ü
rj   c                   @   s"   e Zd ZdZddd„Zdd„ ZdS )r3   zEA ShapeResolver that will throw ValueErrors when shapes are resolved.Nc                 C   s   t d|› d�ƒ‚d S )NzAttempted to lookup shape 'ú!', but no shape map was provided.©Ú
ValueErrorrp   r   r   r   ro   ë  s    
ÿz&UnresolvableShapeMap.get_shape_by_namec                 C   s   t d|› d�ƒ‚d S )NzAttempted to resolve shape 'rÊ   rË   rE   r   r   r   rD   ð  s    
ÿz&UnresolvableShapeMap.resolve_shape_ref)N)r   r   r   rN   ro   rD   r   r   r   r   r3   è  s   
r3   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 kr&| j d¡| _d S )Nr¿   )r   rR   ÚShapeNameGeneratorÚ_name_generatorÚnew_shape_namer/   r•   r   r   r   r9   (  s    z%DenormalizedStructureBuilder.__init__c                 C   s
   || _ | S )zp

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

        :return: self

        )Ú_members)r   rR   r   r   r   Úwith_members.  s    	z)DenormalizedStructureBuilder.with_membersc                 C   sB   t ƒ }d| jdœ}|  ||| j¡ t|d�}t| j|| j |d�S )z™Build the model based on the provided members.

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

        r¿   )r,   rR   )rÃ   )r6   r7   r8   )r   rØ   Ú_build_modelr/   rj   rQ   )r   rh   ZdenormalizedÚresolverr   r   r   Úbuild_model:  s    þ
ýz(DenormalizedStructureBuilder.build_modelc                 C   sŽ   |d dkr|   ||¡||< nl|d dkr<|  ||¡||< nN|d dkrZ|  ||¡||< n0|d | jkrx|  |¡||< ntd|d › �ƒ‚d S )Nr,   r¿   rx   rÀ   zUnknown shape type: )Ú_build_structureÚ_build_listÚ
_build_mapÚSCALAR_TYPESÚ_build_scalarr   )r   r<   rh   r6   r   r   r   rÚ   N  s    z)DenormalizedStructureBuilder._build_modelc                 C   s\   t ƒ }|  |¡}||d< | dt ƒ ¡ ¡ D ],\}}|  |¡}d|i||< |  |||¡ q*|S )NrR   r§   )r   Ú_build_initial_shaper1   rS   Ú_get_shape_namerÚ   )r   r<   rh   rR   r§   r/   Zmember_modelÚmember_shape_namer   r   r   rÝ   Z  s    

z-DenormalizedStructureBuilder._build_structurec                 C   s6   |   |¡}|  |¡}d|i|d< |  |d ||¡ |S )Nr§   rU   ©rã   râ   rÚ   )r   r<   rh   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 )Nr]   r^   r§   rå   )r   r<   rh   Zkey_shape_nameZvalue_shape_namer§   r   r   r   rß   l  s    
z'DenormalizedStructureBuilder._build_mapc                 C   sD   d|d i}d|kr |d |d< t jD ]}||kr&|| ||< q&|S )Nr,   r-   )r   r?   )r   r<   r§   r>   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|kr|d S | j  |d ¡S d S )Nr6   r,   )rÖ   r×   ræ   r   r   r   rã   „  s    z,DenormalizedStructureBuilder._get_shape_name)N)r   r   r   rN   rà   r9   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Õ   z³Generate 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   r9   “  s    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   r0   Zcurrent_indexr   r   r   r×   –  s    
z!ShapeNameGenerator.new_shape_nameN)r   r   r   rN   r9   r×   r   r   r   r   rÕ   ‹  s   rÕ   N)&rN   Úcollectionsr   Útypingr   r   Zbotocore.compatr   Zbotocore.exceptionsr   r   Zbotocore.utilsr   r	   r
   Úobjectrk   Ú	Exceptionr   r   r   r   ra   r   r   rQ   rZ   r\   r_   r`   rd   rf   rg   r~   rj   r3   rÍ   rÕ   r   r   r   r   Ú<module>   s:    "*
 ? T6 