U
    ³.¬bóp  ã                   @   s<  d 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ƒ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)ÚOrderedDict)ÚMissingServiceIdErrorÚUndefinedModelAttributeError)ÚCachedPropertyÚhyphenize_service_idÚinstance_cachec                   @   s   e Zd ZdS )ÚNoShapeFoundErrorN©Ú__name__Ú
__module__Ú__qualname__© r   r   ú2/tmp/pip-unpacked-wheel-7df6wvge/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g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	streamingZtimestampFormatZxmlNamespaceZresultWrapperZxmlAttributeÚeventstreamÚeventZeventheaderZeventpayloadZ	jsonvalueZ	hostLabelÚrequiredÚminÚmaxÚpatternZ	sensitiveÚenumÚidempotencyTokenÚerrorÚ	exceptionZendpointdiscoveryidZ	retryableÚdocumentÚunionNc                 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__Z   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+   )r.   ÚSERIALIZED_ATTRSÚpop)r   ÚmodelÚserializationÚattrr   r   r   r9   |   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.

        )r.   ÚMETADATA_ATTRS)r   r8   Ú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<   r-   r   r   r   r   Úrequired_members¸   s    	zShape.required_membersc                 C   s   | j  |¡S r   ©r0   Ú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__r6   r;   r   ÚMAP_TYPEr5   r   r9   r<   r>   rC   rH   ÚpropertyrI   r   r   r   r   r   /   sZ   ïó
"
 


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)r.   r-   rK   ÚitemsrC   )r   rN   Zshape_membersr+   rB   r   r   r   rN   Ï   s
    zStructureShape.membersc                 C   s,   | j  ¡ D ]\}}|j d¡r
|  S q
d S )Nr   )rN   rO   r9   r-   )r   Úmember_nameÚmemberr   r   r   rI   Ý   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<   r-   r+   )r   Zerror_metadatarR   r   r   r   Ú
error_codeä   s    
zStructureShape.error_codec                 C   s   | j  dd¡S )Nr&   Fr=   r   r   r   r   Úis_document_typeï   s    zStructureShape.is_document_typec                 C   s   | j  dd¡S )Nr'   Fr=   r   r   r   r   Úis_tagged_unionó   s    zStructureShape.is_tagged_unionN)	r   r   r   r   rN   rI   rS   rT   rU   r   r   r   r   rM   Î   s   




rM   c                   @   s   e Zd Zedd„ ƒZdS )Ú	ListShapec                 C   s   |   | jd ¡S )NrQ   ©rC   r.   r   r   r   r   rQ   ù   s    zListShape.memberN)r   r   r   r   rQ   r   r   r   r   rV   ø   s   rV   c                   @   s$   e Zd Zedd„ ƒZedd„ ƒZdS )ÚMapShapec                 C   s   |   | jd ¡S )NÚkeyrW   r   r   r   r   rY   ÿ   s    zMapShape.keyc                 C   s   |   | jd ¡S )NÚvaluerW   r   r   r   r   rZ     s    zMapShape.valueN)r   r   r   r   rY   rZ   r   r   r   r   rX   þ   s   
rX   c                   @   s   e Zd Zedd„ ƒZdS )ÚStringShapec                 C   s   | j  dg ¡S )Nr"   r=   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dZd.dd„Zd/d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d'd(„ Zed)d*„ ƒZejd+d*„ ƒZd,d-„ ZdS )0Ú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_descriptionr-   r<   ÚShapeResolverr0   ÚNOT_SETÚ_signature_versionÚ_service_nameZ_instance_cache)r   Zservice_descriptionÚservice_namer   r   r   r5     s    
ÿzServiceModel.__init__c                 C   s   | j  ||¡S r   )r0   Úget_shape_by_name©r   r2   Úmember_traitsr   r   r   Ú	shape_for4  s     ÿzServiceModel.shape_forc                 C   s   | j  |d ¡S r   )Ú_error_code_cacher-   )r   rS   r   r   r   Úshape_for_error_code9  s    z!ServiceModel.shape_for_error_codec                 C   s"   i }| j D ]}|j}|||< q
|S r   )Úerror_shapesrS   )r   Zerror_code_cacheÚerror_shaperR   r   r   r   rh   <  s
    

zServiceModel._error_code_cachec                 C   s   | j  |¡S r   r?   rA   r   r   r   r@   D  s    zServiceModel.resolve_shape_refc                 C   s   t | j di ¡ƒS )Nr]   ©Úlistr^   r-   r   r   r   r   Úshape_namesG  s    zServiceModel.shape_namesc                 C   s6   g }| j D ]&}|  |¡}|j dd¡r
| |¡ q
|S )Nr%   F)rn   rg   r<   r-   Úappend)r   rj   r2   rk   r   r   r   rj   K  s    

zServiceModel.error_shapesc                 C   s<   z| j d | }W n tk
r.   t|ƒ‚Y nX t|| |ƒS ©NÚ
operations)r^   ÚKeyErrorr   ÚOperationModel)r   Zoperation_namer8   r   r   r   Úoperation_modelT  s
    zServiceModel.operation_modelc                 C   s   | j  dd¡S ©Nr)   r*   )r^   r-   r   r   r   r   r)   \  s    zServiceModel.documentationc                 C   s   t | j dg ¡ƒS rp   rl   r   r   r   r   Úoperation_names`  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)rb   Úendpoint_prefixr   r   r   r   rc   d  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)rc   )r   Ú_get_metadata_propertyr   r   rb   r   r   r   r   Ú
service_idu  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<   r-   rw   )r   Úsigning_namer   r   r   rz   |  s    zServiceModel.signing_namec                 C   s
   |   d¡S )NZ
apiVersion©rx   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   rw   �  s    zServiceModel.endpoint_prefixc                 C   s(   | j D ]}|  |¡}|jr|  S qd S r   )rv   rt   Úis_endpoint_discovery_operation©r   Z	operationr8   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)rv   rt   Úendpoint_discoveryr-   r   r   r   r   Úendpoint_discovery_required›  s    

ÿ
þz(ServiceModel.endpoint_discovery_requiredc                 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<   rr   r   ©r   r+   r   r   r   rx   ¦  s    ÿz#ServiceModel._get_metadata_propertyc                 C   s"   | j tkr| j d¡}|| _ | j S )NZsignatureVersion)ra   r`   r<   r-   )r   Úsignature_versionr   r   r   r…   ±  s    
zServiceModel.signature_versionc                 C   s
   || _ d S r   )ra   )r   rZ   r   r   r   r…   ¸  s    c                 C   s   | j j› d| j› d�S )NrE   ú))rG   r   rc   r   r   r   r   rH   ¼  s    zServiceModel.__repr__)N)N)r   r   r   rJ   r5   rg   ri   r   rh   r@   rn   rj   r   rt   r)   rv   rc   ry   rz   r|   r}   rw   r€   r‚   rx   rL   r…   ÚsetterrH   r   r   r   r   r\     sN   


















r\   c                   @   s2  e Zd Zd8d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d,d-„ ƒZed.d/„ ƒZd0d1„ Zd2d3„ Zd4d5„ Zd6d7„ ZdS )9rs   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_namer-   Z
_wire_namer<   rˆ   )r   rt   Úservice_modelr+   r   r   r   r5   Á  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‰   r-   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 ru   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Š   r@   r   r   r   r   Úinput_shape  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<   )Ú.0r+   Úshaper   r   r   Ú
<listcomp>,  s   

ýz5OperationModel.idempotent_members.<locals>.<listcomp>)r’   rN   rO   )r   r’   r   r   r   Úidempotent_members&  s    þz!OperationModel.idempotent_membersc                 C   s   | j  d¡S )NZauthtyperŽ   r   r   r   r   Ú	auth_type3  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Š   r@   )r•   Úsr   r   r   Ú	<genexpr>:  s     z.OperationModel.error_shapes.<locals>.<genexpr>)r‰   r-   rm   )r   r]   r   r   r   rj   7  s    zOperationModel.error_shapesc                 C   s   | j  d¡S )NÚendpointrŽ   r   r   r   r   r�   <  s    zOperationModel.endpointc                 C   s   | j  dd¡S )NZhttpChecksumRequiredFrŽ   r   r   r   r   Úhttp_checksum_required@  s    z%OperationModel.http_checksum_requiredc                 C   s   | j  di ¡S )NZhttpChecksumrŽ   r   r   r   r   Úhttp_checksumD  s    zOperationModel.http_checksumc                 C   s   |   ¡ d k	S r   )Úget_event_stream_inputr   r   r   r   Úhas_event_stream_inputH  s    z%OperationModel.has_event_stream_inputc                 C   s   |   ¡ d k	S r   )Úget_event_stream_outputr   r   r   r   Úhas_event_stream_outputL  s    z&OperationModel.has_event_stream_outputc                 C   s   |   | j¡S r   )Ú_get_event_streamr’   r   r   r   r   r    P  s    z%OperationModel.get_event_stream_inputc                 C   s   |   | j¡S r   )r¤   r”   r   r   r   r   r¢   S  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)rI   rN   )r   r–   Z
event_namer   r   r   r¤   V  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_outputc  s    z#OperationModel.has_streaming_outputc                 C   s   |   | j¡S r   )Ú_get_streaming_bodyr’   r   r   r   r   r¥   g  s    z"OperationModel.get_streaming_inputc                 C   s   |   | j¡S r   )r©   r”   r   r   r   r   r§   j  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)r9   r-   rN   r,   )r   r–   r   Zpayload_shaper   r   r   r©   m  s    

z"OperationModel._get_streaming_bodyc                 C   s   | j j› d| j› d�S )Nz(name=r†   rF   r   r   r   r   rH   x  s    zOperationModel.__repr__)N) r   r   r   r5   r   r+   rL   r�   rŒ   r)   r�   r�   r~   r’   r”   r˜   r™   rj   r�   rž   rŸ   r¡   r£   r    r¢   r¤   r¦   r¨   r¥   r§   r©   rH   r   r   r   r   rs   À  s\   
%







	









	

rs   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.)Ú	structurerm   ÚmapÚstringc                 C   s   || _ i | _d S r   )Ú
_shape_mapZ_shape_cache)r   Ú	shape_mapr   r   r   r5   ‡  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®   rr   r	   ÚSHAPE_CLASSESr-   r   r   ÚcopyÚupdate)r   r2   rf   r3   Z	shape_clsÚresultr   r   r   rd   ‹  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: )Úlenrd   r±   r7   rr   r   )r   rB   rf   r2   r   r   r   r@   œ  s    ÿ
zShapeResolver.resolve_shape_ref)N)r   r   r   rJ   rM   rV   rX   r[   r°   r5   rd   r@   r   r   r   r   r_   |  s   ü
r_   c                   @   s"   e Zd ZdZddd„Zdd„ ZdS )r/   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.©Ú
ValueErrorre   r   r   r   rd   µ  s    
ÿz&UnresolvableShapeMap.get_shape_by_namec                 C   s   t d|› d�ƒ‚d S )NzAttempted to resolve shape 'r¶   r·   rA   r   r   r   r@   º  s    
ÿz&UnresolvableShapeMap.resolve_shape_ref)N)r   r   r   rJ   rd   r@   r   r   r   r   r/   ²  s   
r/   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   rN   ÚShapeNameGeneratorÚ_name_generatorÚnew_shape_namer+   r„   r   r   r   r5   ò  s    z%DenormalizedStructureBuilder.__init__c                 C   s
   || _ | S )zp

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

        :return: self

        )Ú_members)r   rN   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(   rN   )r¯   )r2   r3   r4   )r   rÄ   Ú_build_modelr+   r_   rM   )r   r]   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«   rm   r¬   zUnknown shape type: )Ú_build_structureÚ_build_listÚ
_build_mapÚSCALAR_TYPESÚ_build_scalarr   )r   r8   r]   r2   r   r   r   rÆ     s    z)DenormalizedStructureBuilder._build_modelc                 C   s\   t ƒ }|  |¡}||d< | dt ƒ ¡ ¡ D ],\}}|  |¡}d|i||< |  |||¡ q*|S )NrN   r–   )r   Ú_build_initial_shaper-   rO   Ú_get_shape_namerÆ   )r   r8   r]   rN   r–   r+   Zmember_modelÚmember_shape_namer   r   r   rÉ   $  s    

z-DenormalizedStructureBuilder._build_structurec                 C   s6   |   |¡}|  |¡}d|i|d< |  |d ||¡ |S )Nr–   rQ   ©rÏ   rÎ   rÆ   )r   r8   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 )NrY   rZ   r–   rÑ   )r   r8   r]   Zkey_shape_nameZvalue_shape_namer–   r   r   r   rË   6  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   r8   r–   r:   r   r   r   rÎ   @  s     ÿ
z1DenormalizedStructureBuilder._build_initial_shapec                 C   s
   |   |¡S r   )rÎ   ©r   r8   r   r   r   rÍ   K  s    z*DenormalizedStructureBuilder._build_scalarc                 C   s$   d|kr|d S | j  |d ¡S d S )Nr2   r(   )rÂ   rÃ   rÒ   r   r   r   rÏ   N  s    z,DenormalizedStructureBuilder._get_shape_name)N)r   r   r   rJ   rÌ   r5   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   r5   ]  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   r,   Zcurrent_indexr   r   r   rÃ   `  s    
z!ShapeNameGenerator.new_shape_nameN)r   r   r   rJ   r5   rÃ   r   r   r   r   rÁ   U  s   rÁ   N) rJ   Úcollectionsr   Zbotocore.compatr   Zbotocore.exceptionsr   r   Zbotocore.utilsr   r   r   Úobjectr`   Ú	Exceptionr	   r   r   r   Ústrr   r   rM   rV   rX   r[   r\   rs   r_   r/   r¹   rÁ   r   r   r   r   Ú<module>   s2     *
 3 =6 