HEX
Server: LiteSpeed
System: Linux s1299.sgp1.mysecurecloudhost.com 4.18.0-553.52.1.lve.el8.x86_64 #1 SMP Wed May 21 15:31:29 UTC 2025 x86_64
User: everest2 (1878)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: //lib/python3.6/site-packages/botocore/__pycache__/model.cpython-36.pyc
3

�T_�n�@sRdZddlmZddlmZmZmZddlmZddl	m
Z
ddl	mZe�Z
Gdd�de�ZGd	d
�d
e�ZGdd�de�ZGd
d�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd �d e�ZGd!d"�d"e�ZGd#d$�d$e�ZGd%d&�d&e�Zd'S)(z-Abstractions to interact with service models.�)�defaultdict)�CachedProperty�instance_cache�hyphenize_service_id)�OrderedDict)�MissingServiceIdError)�UndefinedModelAttributeErrorc@seZdZdS)�NoShapeFoundErrorN)�__name__�
__module__�__qualname__�r
r
�/usr/lib/python3.6/model.pyr	sr	c@seZdZdS)�InvalidShapeErrorN)r
rrr
r
r
rrsrc@seZdZdS)�OperationNotFoundErrorN)r
rrr
r
r
rr src@seZdZdS)�InvalidShapeReferenceErrorN)r
rrr
r
r
rr$src@seZdZdd�ZdS)�	ServiceIdcCst|�S)N)r)�selfr
r
r�	hyphenize)szServiceId.hyphenizeN)r
rrrr
r
r
rr(src@s�eZdZdZdddddddd	d
ddd
dddddgZddddddddddg
ZeZd+dd�Ze	dd ��Z
e	d!d"��Ze	d#d$��Zd%d&�Z
d'd(�Zed)d*��ZdS),�Shapez3Object representing a shape from the service model.�locationNameZ	queryNameZ	flattened�location�payloadZ	streamingZtimestampFormatZxmlNamespaceZ
resultWrapperZxmlAttribute�eventstreamZeventZeventheaderZeventpayloadZ	jsonvalueZ	hostLabel�required�min�maxZ	sensitive�enum�idempotencyToken�error�	exceptionZendpointdiscoveryidZ	retryableNcCsB||_|d|_|jdd�|_||_|dkr2t�}||_i|_dS)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
zShape.__init__cCsJ|j}i}x$|jD]}||jkr||||<qWd|krF|jd�|d<|S)aSerialization 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.

        rr$)r'�SERIALIZED_ATTRS�pop)r�model�
serialization�attrr
r
rr2_s
zShape.serializationcCs4|j}i}x$|jD]}||jkr||||<qW|S)a2Metadata about the shape.

        This requires optional information about the shape, including:

            * min
            * max
            * enum
            * sensitive
            * required
            * idempotencyToken

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

        )r'�METADATA_ATTRS)rr1�metadatar3r
r
rr5�s
zShape.metadatacCs|jjdg�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)r5r&)rr
r
r�required_members�s	zShape.required_memberscCs|jj|�S)N)r)�resolve_shape_ref)r�	shape_refr
r
r�_resolve_shape_ref�szShape._resolve_shape_refcCsd|jj|jfS)Nz<%s(%s)>)�	__class__r
r$)rr
r
r�__repr__�szShape.__repr__cCsdS)Nr
)rr
r
r�event_stream_name�szShape.event_stream_name)N)r
rr�__doc__r/r4r�MAP_TYPEr.rr2r5r6r9r;�propertyr<r
r
r
rr-s"


"!rc@s0eZdZedd��Zedd��Zedd��ZdS)�StructureShapecCs:|jd}|j�}x"|j�D]\}}|j|�||<qW|S)N�members)r'r>�itemsr9)rrAZ
shape_membersr$r8r
r
rrA�s

zStructureShape.memberscCs,x&|jj�D]\}}|jjd�r|SqWdS)Nr)rArBr2r&)r�member_name�memberr
r
rr<�sz StructureShape.event_stream_namecCs8|jjdd�sdS|jjdi�}|jd�}|r2|S|jS)Nr Fr�code)r5r&r$)rZerror_metadatarEr
r
r�
error_code�s
zStructureShape.error_codeN)r
rrrrAr<rFr
r
r
rr@�sr@c@seZdZedd��ZdS)�	ListShapecCs|j|jd�S)NrD)r9r')rr
r
rrD�szListShape.memberN)r
rrrrDr
r
r
rrG�srGc@s$eZdZedd��Zedd��ZdS)�MapShapecCs|j|jd�S)N�key)r9r')rr
r
rrI�szMapShape.keycCs|j|jd�S)N�value)r9r')rr
r
rrJ�szMapShape.valueN)r
rrrrIrJr
r
r
rrH�srHc@seZdZedd��ZdS)�StringShapecCs|jjdg�S)Nr)r5r&)rr
r
rr�szStringShape.enumN)r
rrrrr
r
r
rrK�srKc@seZdZdZd.dd�Zd/dd�Zdd�Zed	d
��Zdd�Z	ed
d��Z
edd��Zedd��Z
edd��Zedd��Zedd��Zedd��Zedd��Zedd��Zedd ��Zed!d"��Zed#d$��Zed%d&��Zd'd(�Zed)d*��Zejd+d*��Zd,d-�ZdS)0�ServiceModelzQ

    :ivar service_description: The parsed service description dictionary.

    NcCs<||_|jdi�|_t|jdi��|_t|_||_i|_dS)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.

        r5�shapesN)	�_service_descriptionr&r5�
ShapeResolverr)�NOT_SET�_signature_version�
_service_nameZ_instance_cache)rZservice_description�service_namer
r
rr.�szServiceModel.__init__cCs|jj||�S)N)r)�get_shape_by_name)rr+�
member_traitsr
r
r�	shape_forszServiceModel.shape_forcCs|jj|d�S)N)�_error_code_cacher&)rrFr
r
r�shape_for_error_codesz!ServiceModel.shape_for_error_codecCs&i}x|jD]}|j}|||<qW|S)N)�error_shapesrF)rZerror_code_cache�error_shaperEr
r
rrWs
zServiceModel._error_code_cachecCs|jj|�S)N)r)r7)rr8r
r
rr7szServiceModel.resolve_shape_refcCst|jjdi��S)NrM)�listrNr&)rr
r
r�shape_namesszServiceModel.shape_namescCs:g}x0|jD]&}|j|�}|jjdd�r|j|�qW|S)Nr F)r\rVr5r&�append)rrYr+rZr
r
rrY"s
zServiceModel.error_shapescCs<y|jd|}Wntk
r.t|��YnXt|||�S)N�
operations)rN�KeyErrorr�OperationModel)rZoperation_namer1r
r
r�operation_model+s
zServiceModel.operation_modelcCs|jjdd�S)Nr"r#)rNr&)rr
r
rr"3szServiceModel.documentationcCst|jjdg��S)Nr^)r[rNr&)rr
r
r�operation_names7szServiceModel.operation_namescCs|jdk	r|jS|jSdS)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)rR�endpoint_prefix)rr
r
rrS;s
zServiceModel.service_namecCs4yt|jd��Stk
r.t|jd��YnXdS)NZ	serviceId)rS)r�_get_metadata_propertyrrrR)rr
r
r�
service_idLs
zServiceModel.service_idcCs|jjd�}|dkr|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.
        ZsigningNameN)r5r&rc)r�signing_namer
r
rrfUszServiceModel.signing_namecCs
|jd�S)NZ
apiVersion)rd)rr
r
r�api_versionaszServiceModel.api_versioncCs
|jd�S)N�protocol)rd)rr
r
rrheszServiceModel.protocolcCs
|jd�S)NZendpointPrefix)rd)rr
r
rrciszServiceModel.endpoint_prefixcCs(x"|jD]}|j|�}|jr|SqWdS)N)rbra�is_endpoint_discovery_operation)r�	operationr1r
r
r�endpoint_discovery_operationms
z)ServiceModel.endpoint_discovery_operationcCs8x2|jD](}|j|�}|jdk	r|jjd�rdSqWdS)NrTF)rbra�endpoint_discoveryr&)rrjr1r
r
r�endpoint_discovery_requiredts

z(ServiceModel.endpoint_discovery_requiredcCs4y
|j|Stk
r.td||f��YnXdS)Nz1"%s" not defined in the metadata of the model: %s)r5r_r)rr$r
r
rrd}s
z#ServiceModel._get_metadata_propertycCs"|jtkr|jjd�}||_|jS)NZsignatureVersion)rQrPr5r&)r�signature_versionr
r
rrn�s
zServiceModel.signature_versioncCs
||_dS)N)rQ)rrJr
r
rrn�scCsd|jj|jfS)Nz%s(%s))r:r
rS)rr
r
rr;�szServiceModel.__repr__)N)N)r
rrr=r.rVrXrrWr7r\rYrrar"rbrSrerfrgrhrcrkrmrdr?rn�setterr;r
r
r
rrL�s.

			rLc@s&eZdZd6dd�Zedd��Zedd��Zedd	��Zed
d��Z	edd
��Z
edd��Zedd��Zedd��Z
edd��Zedd��Zedd��Zedd��Zedd��Zedd��Zed d!��Zed"d#��Zd$d%�Zd&d'�Zd(d)�Zed*d+��Zed,d-��Zd.d/�Zd0d1�Zd2d3�Zd4d5�ZdS)7r`NcCs8||_||_||_|jd�|_|j|_|jdi�|_dS)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_namer5rp)rra�
service_modelr$r
r
rr.�szOperationModel.__init__cCs|jdk	r|jS|jSdS)N)rs�	wire_name)rr
r
rr$�s
zOperationModel.namecCs|jjd�S)aRThe 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$)rqr&)rr
r
rru�szOperationModel.wire_namecCs|jS)N)rr)rr
r
rrt�szOperationModel.service_modelcCs|jjdd�S)Nr"r#)rqr&)rr
r
rr"�szOperationModel.documentationcCs|jjdd�S)N�
deprecatedF)rqr&)rr
r
rrv�szOperationModel.deprecatedcCs|jjdd�S)NZendpointdiscovery)rqr&)rr
r
rrl�sz!OperationModel.endpoint_discoverycCs|jjdd�S)NZendpointoperationF)rqr&)rr
r
rri�sz.OperationModel.is_endpoint_discovery_operationcCs d|jkrdS|jj|jd�S)N�input)rqrrr7)rr
r
r�input_shape�s
zOperationModel.input_shapecCs d|jkrdS|jj|jd�S)N�output)rqrrr7)rr
r
r�output_shape�s
zOperationModel.output_shapecCs"|j}|sgSdd�|jj�D�S)NcSs(g|] \}}d|jkr|jdr|�qS)r)r5)�.0r$�shaper
r
r�
<listcomp>s
z5OperationModel.idempotent_members.<locals>.<listcomp>)rxrArB)rrxr
r
r�idempotent_members�sz!OperationModel.idempotent_memberscCs|jjd�S)NZauthtype)rqr&)rr
r
r�	auth_typeszOperationModel.auth_typecs$�jjdg�}t�fdd�|D��S)N�errorsc3s|]}�jj|�VqdS)N)rrr7)r{�s)rr
r�	<genexpr>
sz.OperationModel.error_shapes.<locals>.<genexpr>)rqr&r[)rrMr
)rrrY
szOperationModel.error_shapescCs|jjd�S)N�endpoint)rqr&)rr
r
rr�szOperationModel.endpointcCs|jjdd�S)NZhttpChecksumRequiredF)rqr&)rr
r
r�http_checksum_requiredsz%OperationModel.http_checksum_requiredcCs|j�dk	S)N)�get_event_stream_input)rr
r
r�has_event_stream_inputsz%OperationModel.has_event_stream_inputcCs|j�dk	S)N)�get_event_stream_output)rr
r
r�has_event_stream_outputsz&OperationModel.has_event_stream_outputcCs|j|j�S)N)�_get_event_streamrx)rr
r
rr�sz%OperationModel.get_event_stream_inputcCs|j|j�S)N)r�rz)rr
r
rr�"sz&OperationModel.get_event_stream_outputcCs$|dkrdS|j}|r |j|SdS)zAReturns the event stream member's shape if any or None otherwise.N)r<rA)rr|Z
event_namer
r
rr�%s
z OperationModel._get_event_streamcCs|j�dk	S)N)�get_streaming_input)rr
r
r�has_streaming_input.sz"OperationModel.has_streaming_inputcCs|j�dk	S)N)�get_streaming_output)rr
r
r�has_streaming_output2sz#OperationModel.has_streaming_outputcCs|j|j�S)N)�_get_streaming_bodyrx)rr
r
rr�6sz"OperationModel.get_streaming_inputcCs|j|j�S)N)r�rz)rr
r
rr�9sz#OperationModel.get_streaming_outputcCs<|dkrdS|jjd�}|dk	r8|j|}|jdkr8|SdS)z?Returns the streaming member's shape if any; or None otherwise.Nr�blob)r2r&rAr%)rr|rZ
payload_shaper
r
rr�<s

z"OperationModel._get_streaming_bodycCsd|jj|jfS)Nz%s(name=%s))r:r
r$)rr
r
rr;GszOperationModel.__repr__)N)r
rrr.rr$r?rurtr"rvrlrirxrzr~rrYr�r�r�r�r�r�r�r�r�r�r�r�r;r
r
r
rr`�s4
%	

	r`c@s8eZdZdZeeeed�Zdd�Z	d
dd�Z
dd	�ZdS)rOzResolves shape references.)�	structurer[�map�stringcCs||_i|_dS)N)�
_shape_mapZ_shape_cache)r�	shape_mapr
r
rr.VszShapeResolver.__init__NcCs�y|j|}Wntk
r*t|��YnXy|jj|dt�}Wn tk
rbtd|��YnX|rz|j�}|j|�||||�}|S)Nr!z(Shape is missing required key 'type': %s)	r�r_r	�
SHAPE_CLASSESr&rr�copy�update)rr+rUr,Z	shape_cls�resultr
r
rrTZs
zShapeResolver.get_shape_by_namecCsjt|�dkr"d|kr"|j|d�S|j�}y|jd�}Wn tk
rXtd|��YnX|j||�SdS)N�r|z*Invalid model, missing shape reference: %s)�lenrTr�r0r_r)rr8rUr+r
r
rr7jszShapeResolver.resolve_shape_ref)N)r
rrr=r@rGrHrKr�r.rTr7r
r
r
rrOKs
rOc@s"eZdZdZddd�Zdd�ZdS)r(zJA ShapeResolver that will throw ValueErrors when shapes are resolved.
    NcCstd��dS)Nz>Attempted to lookup shape '%s', but no shape map was provided.)�
ValueError)rr+rUr
r
rrT�sz&UnresolvableShapeMap.get_shape_by_namecCstd��dS)Nz?Attempted to resolve shape '%s', but no shape map was provided.)r�)rr8r
r
rr7�sz&UnresolvableShapeMap.resolve_shape_ref)N)r
rrr=rTr7r
r
r
rr(s
r(c@sbeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�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.

    NcCs*t�|_t�|_|dkr&|jjd�|_dS)Nr�)rrA�ShapeNameGenerator�_name_generator�new_shape_namer$)rr$r
r
rr.�sz%DenormalizedStructureBuilder.__init__cCs
||_|S)zp

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

        :return: self

        )�_members)rrAr
r
r�with_members�s	z)DenormalizedStructureBuilder.with_memberscCsBt�}d|jd�}|j|||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!rA)r�)r+r,r-)rr��_build_modelr$rOr@)rrMZdenormalizedZresolverr
r
r�build_model�s

z(DenormalizedStructureBuilder.build_modelc
Cs�|ddkr|j||�||<nh|ddkr<|j||�||<nJ|ddkrZ|j||�||<n,|ddkrv|j|�||<ntd|d��dS)Nr!r�r[r�r��integer�booleanr��float�	timestamp�long�double�charzUnknown shape type: %s)	r�r�r�r�r�r�r�r�r�)�_build_structure�_build_list�
_build_map�
_build_scalarr)rr1rMr+r
r
rr��sz)DenormalizedStructureBuilder._build_modelcCsZt�}|j|�}||d<x<|dj�D],\}}|j|�}d|i||<|j|||�q&W|S)NrAr|)r�_build_initial_shaperB�_get_shape_namer�)rr1rMrAr|r$Zmember_model�member_shape_namer
r
rr��s

z-DenormalizedStructureBuilder._build_structurecCs6|j|�}|j|�}d|i|d<|j|d||�|S)Nr|rD)r�r�r�)rr1rMr�r|r
r
rr��s


z(DenormalizedStructureBuilder._build_listcCsf|j|d�}|j|d�}|j|�}d|i|d<d|i|d<|j|d||�|j|d||�|S)NrIrJr|)r�r�r�)rr1rMZkey_shape_nameZvalue_shape_namer|r
r
rr��s
z'DenormalizedStructureBuilder._build_mapcCsHd|di}d|kr |d|d<x"tjD]}||kr(||||<q(W|S)Nr!r")rr4)rr1r|r3r
r
rr��sz1DenormalizedStructureBuilder._build_initial_shapecCs
|j|�S)N)r�)rr1r
r
rr�sz*DenormalizedStructureBuilder._build_scalarcCs$d|kr|dS|jj|d�SdS)Nr+r!)r�r�)rr1r
r
rr�
sz,DenormalizedStructureBuilder._get_shape_name)N)r
rrr=r.r�r�r�r�r�r�r�r�r�r
r
r
rr��s#


r�c@s eZdZdZdd�Zdd�ZdS)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.

    cCstt�|_dS)N)r�int�_name_cache)rr
r
rr.szShapeNameGenerator.__init__cCs,|j|d7<|j|}d|j�|fS)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�z%sType%s)r��
capitalize)rr%Z
current_indexr
r
rr�s
z!ShapeNameGenerator.new_shape_nameN)r
rrr=r.r�r
r
r
rr�sr�N) r=�collectionsrZbotocore.utilsrrrZbotocore.compatrZbotocore.exceptionsrr�objectrP�	Exceptionr	rrr�strrrr@rGrHrKrLr`rOr(r�r�r
r
r
r�<module>
s4"
244