o
    è’OjN~  ã                   @   sŒ  d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
mZmZ ddlmZ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)Úresolve_auth_type)ÚOrderedDict)ÚMissingServiceIdErrorÚUndefinedModelAttributeErrorÚ UnsupportedServiceProtocolsError)Ú$PRIORITY_ORDERED_SUPPORTED_PROTOCOLSÚCachedPropertyÚhyphenize_service_idÚinstance_cachec                   @   ó   e Zd ZdS )ÚNoShapeFoundErrorN©Ú__name__Ú
__module__Ú__qualname__© r   r   úT/var/www/html/pharmsmart-cdr-gen/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   Ú	hyphenize4   s   zServiceId.hyphenizeN)r   r   r   r   r   r   r   r   r   3   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__f   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   rB   )rE   ÚSERIALIZED_ATTRSÚpop)r   ÚmodelÚserializationÚattrr   r   r   rP   ˆ   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.

        )rE   ÚMETADATA_ATTRS)r   rO   ÚmetadatarQ   r   r   r   rS   ©   s   

€zShape.metadatac                 C   ó   | 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/   ©rS   rD   r   r   r   r   Úrequired_membersÇ   s   	zShape.required_membersc                 C   ó   | j  |¡S r   ©rG   Ú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   rB   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__rM   rR   r   ÚMAP_TYPErL   r
   rP   rS   rV   r\   rb   Úpropertyrc   r   r   r   r   r   8   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)rE   rD   re   Úitemsr\   )r   rh   Úshape_membersrB   r[   r   r   r   rh   Þ   s
   zStructureShape.membersc                 C   s,   | j  ¡ D ]\}}|j d¡r|  S qd S )Nr)   )rh   ri   rP   rD   )r   Úmember_nameÚmemberr   r   r   rc   ì   s
   ÿz StructureShape.event_stream_namec                 C   s8   | j  dd¡s	d S | j  di ¡}| d¡}|r|S | jS )Nr7   Fr6   Úcode)rS   rD   rB   )r   Úerror_metadatarm   r   r   r   Ú
error_codeó   s   
zStructureShape.error_codec                 C   ó   | j  dd¡S )Nr:   FrU   r   r   r   r   Úis_document_typeþ   ó   zStructureShape.is_document_typec                 C   rp   )Nr;   FrU   r   r   r   r   Úis_tagged_union  rr   zStructureShape.is_tagged_unionN)	r   r   r   r
   rh   rc   ro   rq   rs   r   r   r   r   rg   Ý   s    




rg   c                   @   ó   e Zd Zedd„ ƒZdS )Ú	ListShapec                 C   ó   |   | jd ¡S )Nrl   ©r\   rE   r   r   r   r   rl     ó   zListShape.memberN)r   r   r   r
   rl   r   r   r   r   ru     ó    ru   c                   @   s$   e Zd Zedd„ ƒZedd„ ƒZdS )ÚMapShapec                 C   rv   )NÚkeyrw   r   r   r   r   r{     rx   zMapShape.keyc                 C   rv   )NÚvaluerw   r   r   r   r   r|     rx   zMapShape.valueN)r   r   r   r
   r{   r|   r   r   r   r   rz     s
    
rz   c                   @   rt   )ÚStringShapec                 C   rT   )Nr4   rU   r   r   r   r   r4     rr   zStringShape.enumN)r   r   r   r
   r4   r   r   r   r   r}     ry   r}   c                   @   s"   e Zd ZU eed< eeB ed< dS )ÚStaticContextParameterrB   r|   N)r   r   r   ÚstrÚ__annotations__Úboolr   r   r   r   r~     s   
 r~   c                   @   s   e Zd ZU eed< eed< dS )ÚContextParameterrB   rk   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 )ÚClientContextParameterrB   r?   r@   Nrƒ   r   r   r   r   r„   '  s   
 r„   c                   @   s6  e Zd ZdZd6dd„Zd6d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ed)d*„ ƒZed+d,„ ƒZd-d.„ Zed/d0„ ƒZejd1d0„ ƒZed2d3„ ƒZd4d5„ Z dS )7Ú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.

        rS   ÚshapesN)	Ú_service_descriptionrD   rS   ÚShapeResolverrG   ÚNOT_SETÚ_signature_versionÚ_service_nameÚ_instance_cache)r   Úservice_descriptionÚservice_namer   r   r   rL   4  s   
ÿ
zServiceModel.__init__c                 C   s   | j  ||¡S r   )rG   Úget_shape_by_name©r   rI   Úmember_traitsr   r   r   Ú	shape_forS  s   ÿzServiceModel.shape_forc                 C   s   | j  |d ¡S r   )Ú_error_code_cacherD   )r   ro   r   r   r   Úshape_for_error_codeX  ó   z!ServiceModel.shape_for_error_codec                 C   s"   i }| j D ]	}|j}|||< q|S r   )Úerror_shapesro   )r   Úerror_code_cacheÚerror_shaperm   r   r   r   r“   [  s
   

zServiceModel._error_code_cachec                 C   rW   r   rX   rZ   r   r   r   rY   c  r]   zServiceModel.resolve_shape_refc                 C   s   t | j di ¡ƒS )Nr†   ©Úlistr‡   rD   r   r   r   r   Úshape_namesf  ó   zServiceModel.shape_namesc                 C   s6   g }| j D ]}|  |¡}|j dd¡r| |¡ q|S )Nr7   F)r›   r’   rS   rD   Úappend)r   r–   rI   r˜   r   r   r   r–   j  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_namerO   r   r   r   Úoperation_models  s   ÿzServiceModel.operation_modelc                 C   rp   ©Nr@   rA   )r‡   rD   r   r   r   r   r@   {  rr   zServiceModel.documentationc                 C   s   t | j dg ¡ƒS rž   r™   r   r   r   r   Úoperation_names  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 )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.
        ÚsigningNameN)rS   rD   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Ú	protocolsr®   r   r   r   r   r²   ¯  r°   zServiceModel.protocolsc                 C   s@   | j  d¡rtD ]}|| jv r|  S qtt| j| jd�‚| jS )Nr²   )Úbotocore_supported_protocolsÚservice_supported_protocolsÚservice)rS   rD   r	   r²   r   rŽ   r±   )r   r±   r   r   r   Úresolved_protocol³  s   
ÿýzServiceModel.resolved_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   Ú	operationrO   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_discoveryrD   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@   )rB   r?   r@   )r„   )Ú.0Ú
param_nameÚ	param_valr   r   r   Ú
<listcomp>Þ  s    ûýÿz:ServiceModel.client_context_parameters.<locals>.<listcomp>)r‡   rD   ri   ©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: )rS   r    r   ©r   rB   r   r   r   r¨   ç  s   ÿÿz#ServiceModel._get_metadata_propertyc                 C   s"   | j tu r| j d¡}|| _ | j S )NÚsignatureVersion)rŠ   r‰   rS   rD   )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   s
   d| j v S )NÚawsQueryCompatible©rS   r   r   r   r   Úis_query_compatibleý  r°   z ServiceModel.is_query_compatiblec                 C   ó   | j j› d| j› d�S )Nr_   ú))ra   r   rŽ   r   r   r   r   rb     ó   zServiceModel.__repr__r   )!r   r   r   rd   rL   r’   r”   r
   r“   rY   r›   r–   r   r£   r@   r¥   rŽ   r©   r«   r¯   r±   r²   r¶   r¦   r»   r½   rÅ   r¨   rf   rÉ   ÚsetterrÌ   rb   r   r   r   r   r…   -  s`    






















r…   c                   @   s†  e Zd ZdFd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ed2d3„ ƒZd4d5„ Zd6d7„ Zd8d9„ Z ed:d;„ ƒZ!ed<d=„ ƒZ"d>d?„ Z#d@dA„ Z$dBdC„ Z%dDdE„ Z&dS )Gr¡   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.

        rB   ÚhttpN)Ú_operation_modelÚ_service_modelÚ	_api_namerD   Ú
_wire_namerS   rÑ   )r   r£   Úservice_modelrB   r   r   r   rL     s   zOperationModel.__init__c                 C   s   | j d ur| j S | jS r   )rÔ   Ú	wire_namer   r   r   r   rB   +  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``.

        rB   ©rÒ   rD   r   r   r   r   r×   2  s   zOperationModel.wire_namec                 C   s   | j S r   )rÓ   r   r   r   r   rÖ   @  s   zOperationModel.service_modelc                 C   rp   r¤   rÙ   r   r   r   r   r@   D  rr   zOperationModel.documentationc                 C   rp   )NÚ
deprecatedFrÙ   r   r   r   r   rÚ   H  rr   zOperationModel.deprecatedc                 C   s   | j  dd ¡S )NÚendpointdiscoveryrÙ   r   r   r   r   r¼   L  s   z!OperationModel.endpoint_discoveryc                 C   rp   )NÚendpointoperationFrÙ   r   r   r   r   r¸   R  rr   z.OperationModel.is_endpoint_discovery_operationc                 C   ó    d| j vrd S | j | j d ¡S )NÚinput©rÒ   rÓ   rY   r   r   r   r   Úinput_shapeV  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 )r5   rË   ©r¿   rB   Úshaper   r   r   rÂ   q  s    ýüÿz5OperationModel.idempotent_members.<locals>.<listcomp>©rà   rh   ri   )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|   )rB   r|   )r~   rD   )r¿   rB   Úpropsr   r   r   rÂ   {  s    ÿÿz<OperationModel.static_context_parameters.<locals>.<listcomp>)rÒ   rD   ri   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<   rB   )rB   rk   )rS   r‚   rã   r   r   r   rÂ   …  s    úùþÿz5OperationModel.context_parameters.<locals>.<listcomp>rå   r   r   r   r   Úcontext_parameters€  s
   
ûz!OperationModel.context_parametersc                 C   rT   )NÚoperationContextParamsrÙ   r   r   r   r   Úoperation_context_parameters�  rr   z+OperationModel.operation_context_parametersc                 C   rØ   )NÚrequestcompressionrÙ   r   r   r   r   Úrequest_compression“  ó   z"OperationModel.request_compressionc                 C   rØ   )NÚauthrÙ   r   r   r   r   rð   —  rï   zOperationModel.authc                 C   rØ   )NÚauthtyperÙ   r   r   r   r   Ú	auth_type›  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Ó   rY   )r¿   Úsr   r   r   Ú	<genexpr>¬  s   € z.OperationModel.error_shapes.<locals>.<genexpr>)rÒ   rD   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   rp   )NÚhttpChecksumRequiredFrÙ   r   r   r   r   Úhttp_checksum_required²  rr   z%OperationModel.http_checksum_requiredc                 C   s   | j  di ¡S )NÚhttpChecksumrÙ   r   r   r   r   Úhttp_checksum¶  rr   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)rc   rh   )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)rP   rD   rh   rC   )r   rä   r#   Úpayload_shaper   r   r   r
  ß  s   

z"OperationModel._get_streaming_bodyc                 C   rÍ   )Nz(name=rÎ   r`   r   r   r   r   rb   ê  rÏ   zOperationModel.__repr__r   )'r   r   r   rL   r
   rB   rf   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  r
  rb   r   r   r   r   r¡     sz    
%







	
















	

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   rL   ù  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_CLASSESrD   r   r   ÚcopyÚupdate)r   rI   r‘   rJ   Ú	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  rN   r    r   )r   r[   r‘   rI   r   r   r   rY     s   ÿÿzShapeResolver.resolve_shape_refr   )r   r   r   rd   rg   ru   rz   r}   r  rL   r�   rY   r   r   r   r   rˆ   î  s    ü
rˆ   c                   @   s"   e Zd ZdZddd„Zdd„ ZdS )rF   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  rZ   r   r   r   rY   ,  r  z&UnresolvableShapeMap.resolve_shape_refr   )r   r   r   rd   r�   rY   r   r   r   r   rF   $  s    
rF   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   rh   ÚShapeNameGeneratorÚ_name_generatorÚnew_shape_namerB   rÇ   r   r   r   rL   d  s
   ÿz%DenormalizedStructureBuilder.__init__c                 C   s
   || _ | S )zp

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

        :return: self

        )Ú_members)r   rh   r   r   r   Úwith_membersj  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?   rh   )r  )rI   rJ   rK   )r   r*  Ú_build_modelrB   rˆ   rg   )r   r†   ÚdenormalizedÚresolverr   r   r   Úbuild_modelv  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   rO   r†   rI   r   r   r   r,  Š  s   z)DenormalizedStructureBuilder._build_modelc                 C   s\   t ƒ }|  |¡}||d< | dt ƒ ¡ ¡ D ]\}}|  |¡}d|i||< |  |||¡ q|S )Nrh   rä   )r   Ú_build_initial_shaperD   ri   Ú_get_shape_namer,  )r   rO   r†   rh   rä   rB   Úmember_modelÚmember_shape_namer   r   r   r0  –  s   

z-DenormalizedStructureBuilder._build_structurec                 C   s6   |   |¡}|  |¡}d|i|d< |  |d ||¡ |S )Nrä   rl   ©r6  r5  r,  )r   rO   r†   r8  rä   r   r   r   r1  ¡  s
   

z(DenormalizedStructureBuilder._build_listc                 C   sf   |   |d ¡}|   |d ¡}|  |¡}d|i|d< d|i|d< |  |d ||¡ |  |d ||¡ |S )Nr{   r|   rä   r9  )r   rO   r†   Úkey_shape_nameÚvalue_shape_namerä   r   r   r   r2  ¨  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   rR   )r   rO   rä   rQ   r   r   r   r5  ²  s   ÿ
€z1DenormalizedStructureBuilder._build_initial_shapec                 C   s
   |   |¡S r   )r5  ©r   rO   r   r   r   r4  ½  s   
z*DenormalizedStructureBuilder._build_scalarc                 C   s    d|v r|d S | j  |d ¡S )NrI   r?   )r(  r)  r<  r   r   r   r6  À  s   z,DenormalizedStructureBuilder._get_shape_namer   )r   r   r   rd   r3  rL   r+  r/  r,  r0  r1  r2  r5  r4  r6  r   r   r   r   r  3  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   rL   Ï  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   rC   Úcurrent_indexr   r   r   r)  Ò  s   
z!ShapeNameGenerator.new_shape_nameN)r   r   r   rd   rL   r)  r   r   r   r   r'  Ç  s    r'  N))rd   Úcollectionsr   Útypingr   Úbotocore.authr   Úbotocore.compatr   Úbotocore.exceptionsr   r   r   Úbotocore.utilsr	   r
   r   r   Úobjectr‰   Ú	Exceptionr   r   r   r   r   r   r   rg   ru   rz   r}   r~   r‚   r„   r…   r¡   rˆ   rF   r  r'  r   r   r   r   Ú<module>   s>    &*
 Y j6 