HEX
Server: Apache
System: Linux vps35971 6.8.0-79-generic #79~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug 15 16:54:53 UTC 2 x86_64
User: haitiopendh (6209306)
PHP: 8.1.32
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/botocore/__pycache__/model.cpython-310.pyc
o

.&�a;p�@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@�eZdZdS)�NoShapeFoundErrorN��__name__�
__module__�__qualname__�rr�0/usr/lib/python3/dist-packages/botocore/model.pyr
�r
c@r	)�InvalidShapeErrorNrrrrrrrrc@r	)�OperationNotFoundErrorNrrrrrr!rrc@r	)�InvalidShapeReferenceErrorNrrrrrr%rrc@seZdZdd�ZdS)�	ServiceIdcCst|�S�N)r��selfrrr�	hyphenize*�zServiceId.hyphenizeN)rr
rrrrrrr)src@sneZdZdZgd�Zgd�ZeZddd�Ze	dd��Z
e	d	d
��Ze	dd��Zd
d�Z
dd�Zedd��ZdS)�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�	sensitive�enum�idempotencyToken�error�	exception�endpointdiscoveryid�	retryable�document�unionNcCsB||_|d|_|�dd�|_||_|durt�}||_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�getr9�_shape_model�UnresolvableShapeMap�_shape_resolver�_cache)r�
shape_name�shape_model�shape_resolverrrr�__init__>s

zShape.__init__cCsF|j}i}|jD]
}||jvr||||<qd|vr!|�d�|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�attrrrrrI`s

�zShape.serializationcCs0|j}i}|jD]
}||jvr||||<q|S)a]Metadata about the shape.

        This requires optional information about the shape, including:

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

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

        )r>�METADATA_ATTRS)rrH�metadatarJrrrrL�s

�zShape.metadatacC�|j�dg�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,�rLr=rrrr�required_members�s	zShape.required_memberscC�|j�|�Sr�r@�resolve_shape_ref�r�	shape_refrrr�_resolve_shape_ref��zShape._resolve_shape_refcC�d|jj|jfS)Nz<%s(%s)>��	__class__rr;rrrr�__repr__�s�zShape.__repr__cCsdSrrrrrr�event_stream_name�szShape.event_stream_namer)rr
r�__doc__rFrKr�MAP_TYPErErrIrLrOrUrZ�propertyr[rrrrr.s 
"
 


rc@sHeZdZedd��Zedd��Zedd��Zedd��Zed	d
��ZdS)�StructureShapecCs>|j�d|���}|��}|��D]\}}|�|�||<q|S)N�members)r>r=r]�itemsrU)rr`�
shape_membersr;rTrrrr`�s
zStructureShape.memberscCs,|j��D]\}}|j�d�r|SqdS)Nr&)r`rarIr=)r�member_name�memberrrrr[�s
�z StructureShape.event_stream_namecCs8|j�dd�s	dS|j�di�}|�d�}|r|S|jS)Nr3Fr2�code)rLr=r;)r�error_metadatarerrr�
error_code�s
zStructureShape.error_codecC�|j�dd�S)Nr6FrNrrrr�is_document_type��zStructureShape.is_document_typecCrh)Nr7FrNrrrr�is_tagged_union�rjzStructureShape.is_tagged_unionN)	rr
rrr`r[rgrirkrrrrr_�s




r_c@�eZdZedd��ZdS)�	ListShapecC�|�|jd�S)Nrd�rUr>rrrrrd��zListShape.memberN)rr
rrrdrrrrrm��rmc@s$eZdZedd��Zedd��ZdS)�MapShapecCrn)N�keyrorrrrrs�rpzMapShape.keycCrn)N�valuerorrrrrt�rpzMapShape.valueN)rr
rrrsrtrrrrrr�s

rrc@rl)�StringShapecCrM)Nr0rNrrrrr0�rjzStringShape.enumN)rr
rrr0rrrrru�rqruc@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)/�ServiceModelzQ

    :ivar service_description: The parsed service description dictionary.

    NcCs<||_|�di�|_t|�di��|_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.

        rL�shapesN)	�_service_descriptionr=rL�
ShapeResolverr@�NOT_SET�_signature_version�
_service_name�_instance_cache)r�service_description�service_namerrrrE�s
�
zServiceModel.__init__cCs|j�||�Sr)r@�get_shape_by_name�rrB�
member_traitsrrr�	shape_fors�zServiceModel.shape_forcCs|j�|d�Sr)�_error_code_cacher=)rrgrrr�shape_for_error_code�z!ServiceModel.shape_for_error_codecCs"i}|jD]	}|j}|||<q|Sr)�error_shapesrg)r�error_code_cache�error_shapererrrr�s


zServiceModel._error_code_cachecCrPrrQrSrrrrR&rVzServiceModel.resolve_shape_refcCst|j�di��S)Nrw��listrxr=rrrr�shape_names)�zServiceModel.shape_namescCs6g}|jD]}|�|�}|j�dd�r|�|�q|S)Nr3F)r�r�rLr=�append)rr�rBr�rrrr�-s


�zServiceModel.error_shapescCs6z	|jd|}Wntyt|��wt|||�S�N�
operations)rx�KeyErrorr�OperationModel)r�operation_namerHrrr�operation_model6s�zServiceModel.operation_modelcCrh�Nr9r:)rxr=rrrrr9>rjzServiceModel.documentationcCst|j�dg��Sr�r�rrrr�operation_namesBr�zServiceModel.operation_namescCs|jdur|jS|jS)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_prefixrrrrrFs
zServiceModel.service_namecCs,zt|�d��WStyt|jd��w)N�	serviceId)r)r�_get_metadata_propertyrrr|rrrr�
service_idWs��zServiceModel.service_idcCs|j�d�}|dur
|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)rLr=r�)r�signing_namerrrr�`szServiceModel.signing_namecC�
|�d�S)N�
apiVersion�r�rrrr�api_versionl�
zServiceModel.api_versioncCr�)N�protocolr�rrrrr�pr�zServiceModel.protocolcCr�)N�endpointPrefixr�rrrrr�tr�zServiceModel.endpoint_prefixcCs(|jD]}|�|�}|jr|SqdSr)r�r��is_endpoint_discovery_operation�r�	operationrHrrr�endpoint_discovery_operationxs

��z)ServiceModel.endpoint_discovery_operationcCs6|jD]}|�|�}|jdur|j�d�rdSqdS)Nr,TF)r�r��endpoint_discoveryr=r�rrr�endpoint_discovery_requireds



��z(ServiceModel.endpoint_discovery_requiredcCs,z|j|WStytd||f��w)Nz1"%s" not defined in the metadata of the model: %s)rLr�r�rr;rrrr��s���z#ServiceModel._get_metadata_propertycCs"|jtur|j�d�}||_|jS)N�signatureVersion)r{rzrLr=)r�signature_versionrrrr��s
zServiceModel.signature_versioncCs
||_dSr)r{)rrtrrrr��r�cCrW)Nz%s(%s))rYrrrrrrrZ��zServiceModel.__repr__r)rr
rr\rEr�r�rr�rRr�r�rr�r9r�rr�r�r�r�r�r�r�r�r^r��setterrZrrrrrv�sP


















rvc@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||_||_||_|�d�|_|j|_|�di�|_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=�
_wire_namerLr�)rr��
service_modelr;rrrrE�szOperationModel.__init__cCs|jdur|jS|jSr)r��	wire_namerrrrr;�s
zOperationModel.namecC�|j�d�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;�r�r=rrrrr��szOperationModel.wire_namecCs|jSr)r�rrrrr��szOperationModel.service_modelcCrhr�r�rrrrr9�rjzOperationModel.documentationcCrh)N�
deprecatedFr�rrrrr��rjzOperationModel.deprecatedcCs|j�dd�S)N�endpointdiscoveryr�rrrrr��sz!OperationModel.endpoint_discoverycCrh)N�endpointoperationFr�rrrrr��rjz.OperationModel.is_endpoint_discovery_operationcC� d|jvrdS|j�|jd�S)N�input�r�r�rRrrrr�input_shape�s

�zOperationModel.input_shapecCr�)N�outputr�rrrr�output_shape�s

�zOperationModel.output_shapecCs"|j}|sgSdd�|j��D�S)NcSs(g|]\}}d|jvr|jdr|�qS)r1)rL)�.0r;�shaperrr�
<listcomp>s
��z5OperationModel.idempotent_members.<locals>.<listcomp>)r�r`ra)rr�rrr�idempotent_memberss�z!OperationModel.idempotent_memberscCr�)N�authtyper�rrrr�	auth_type�zOperationModel.auth_typecs$�j�dg�}t�fdd�|D��S)N�errorsc3s�|]	}�j�|�VqdSr)r�rR)r��srrr�	<genexpr>s�z.OperationModel.error_shapes.<locals>.<genexpr>)r�r=r�)rrwrrrr�szOperationModel.error_shapescCr�)N�endpointr�rrrrr�r�zOperationModel.endpointcCrh)N�httpChecksumRequiredFr�rrrr�http_checksum_required!rjz%OperationModel.http_checksum_requiredcC�|��duSr)�get_event_stream_inputrrrr�has_event_stream_input%r�z%OperationModel.has_event_stream_inputcCr�r)�get_event_stream_outputrrrr�has_event_stream_output)r�z&OperationModel.has_event_stream_outputcC�|�|j�Sr)�_get_event_streamr�rrrrr�-rVz%OperationModel.get_event_stream_inputcCr�r)r�r�rrrrr�0rVz&OperationModel.get_event_stream_outputcCs$|durdS|j}|r|j|SdS)zAReturns the event stream member's shape if any or None otherwise.N)r[r`)rr��
event_namerrrr�3s
z OperationModel._get_event_streamcCr�r)�get_streaming_inputrrrr�has_streaming_input<r�z"OperationModel.has_streaming_inputcCr�r)�get_streaming_outputrrrr�has_streaming_output@r�z#OperationModel.has_streaming_outputcCr�r)�_get_streaming_bodyr�rrrrr�DrVz"OperationModel.get_streaming_inputcCr�r)r�r�rrrrr�GrVz#OperationModel.get_streaming_outputcCs<|durdS|j�d�}|dur|j|}|jdkr|SdS)z?Returns the streaming member's shape if any; or None otherwise.Nr �blob)rIr=r`r<)rr�r �
payload_shaperrrr�Js

z"OperationModel._get_streaming_bodycCrW)Nz%s(name=%s)rXrrrrrZUr�zOperationModel.__repr__r)rr
rrErr;r^r�r�r9r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rZrrrrr��sZ
%








	






	

r�c@s8eZdZdZeeeed�Zdd�Z	d
dd�Z
dd	�ZdS)ryzResolves shape references.)�	structurer��map�stringcCs||_i|_dSr)�
_shape_map�_shape_cache)r�	shape_maprrrrEds
zShapeResolver.__init__NcCs~z|j|}Wntyt|��wz|j�|dt�}Wn
ty+td|��w|r7|��}|�|�||||�}|S)Nr8z(Shape is missing required key 'type': %s)	r�r�r
�
SHAPE_CLASSESr=rr�copy�update)rrBr�rC�	shape_cls�resultrrrr�hs"���
zShapeResolver.get_shape_by_namecCs`t|�dkrd|vr|�|d�S|��}z|�d�}Wn
ty)td|��w|�||�S)N�r�z*Invalid model, missing shape reference: %s)�lenr�r�rGr�r)rrTr�rBrrrrRxs��zShapeResolver.resolve_shape_refr)rr
rr\r_rmrrrur�rEr�rRrrrrryYs�
ryc@s"eZdZdZddd�Zdd�ZdS)r?zJA ShapeResolver that will throw ValueErrors when shapes are resolved.
    NcC�td��)Nz>Attempted to lookup shape '%s', but no shape map was provided.��
ValueErrorr�rrrr��rz&UnresolvableShapeMap.get_shape_by_namecCr�)Nz?Attempted to resolve shape '%s', but no shape map was provided.r�rSrrrrR�rz&UnresolvableShapeMap.resolve_shape_refr)rr
rr\r�rRrrrrr?�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�|_|dur|j�d�|_dSdS)Nr�)rr`�ShapeNameGenerator�_name_generator�new_shape_namer;r�rrrrE�s
�z%DenormalizedStructureBuilder.__init__cCs
||_|S)zp

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

        :return: self

        )�_members)rr`rrr�with_members�s	z)DenormalizedStructureBuilder.with_memberscCsBt�}d|jd�}|�|||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�)r8r`)r�)rBrCrD)rr��_build_modelr;ryr_)rrw�denormalized�resolverrrr�build_model�s�
�z(DenormalizedStructureBuilder.build_modelcCs�|ddkr|�||�||<dS|ddkr |�||�||<dS|ddkr0|�||�||<dS|ddvr?|�|�||<dStd|d��)Nr8r�r�r�)	r��integer�booleanr��float�	timestamp�long�double�charzUnknown shape type: %s)�_build_structure�_build_list�
_build_map�
_build_scalarr)rrHrwrBrrrr��sz)DenormalizedStructureBuilder._build_modelcCs\t�}|�|�}||d<|�dt����D]\}}|�|�}d|i||<|�|||�q|S)Nr`r�)r�_build_initial_shaper=ra�_get_shape_namer�)rrHrwr`r�r;�member_model�member_shape_namerrrr��s

z-DenormalizedStructureBuilder._build_structurecCs6|�|�}|�|�}d|i|d<|�|d||�|S)Nr�rd�rrr�)rrHrwrr�rrrr��s


z(DenormalizedStructureBuilder._build_listcCsf|�|d�}|�|d�}|�|�}d|i|d<d|i|d<|�|d||�|�|d||�|S)Nrsrtr�r)rrHrw�key_shape_name�value_shape_namer�rrrrs
z'DenormalizedStructureBuilder._build_mapcCsDd|di}d|vr|d|d<tjD]}||vr||||<q|S)Nr8r9)rrK)rrHr�rJrrrr
s�
�z1DenormalizedStructureBuilder._build_initial_shapecCs
|�|�Sr)r�rrHrrrrs
z*DenormalizedStructureBuilder._build_scalarcCs d|vr|dS|j�|d�S)NrBr8)r�r�r	rrrrsz,DenormalizedStructureBuilder._get_shape_namer)rr
rr\rEr�r�r�r�r�rrrrrrrrr��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�|_dSr)r�int�_name_cacherrrrrE&r�zShapeNameGenerator.__init__cCs,|j|d7<|j|}d|��|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<�
current_indexrrrr�)s

�z!ShapeNameGenerator.new_shape_nameN)rr
rr\rEr�rrrrr�sr�N) r\�collectionsr�botocore.utilsrrr�botocore.compatr�botocore.exceptionsrr�objectrz�	Exceptionr
rrr�strrrr_rmrrrurvr�ryr?r�r�rrrr�<module>s6*
364