HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/botocore/__pycache__/model.cpython-310.pyc
o

*we�w�@s|dZddlmZddlmZmZddlmZddlm	Z	m
Z
ddlmZm
Z
mZe�ZGdd�de�ZGd	d
�d
e�ZGdd�de�ZGd
d�de�ZGdd�de�ZGdd�d�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd �d e�ZGd!d"�d"�Z Gd#d$�d$�Z!Gd%d&�d&�Z"Gd'd(�d(�Z#Gd)d*�d*�Z$Gd+d,�d,�Z%d-S).z-Abstractions to interact with service models.�)�defaultdict)�
NamedTuple�Union)�OrderedDict)�MissingServiceIdError�UndefinedModelAttributeError)�CachedProperty�hyphenize_service_id�instance_cachec@�eZdZdS)�NoShapeFoundErrorN��__name__�
__module__�__qualname__�rr�G/home/arjun/projects/env/lib/python3.10/site-packages/botocore/model.pyr�rc@r)�InvalidShapeErrorNr
rrrrrrrc@r)�OperationNotFoundErrorNr
rrrrr#rrc@r)�InvalidShapeReferenceErrorNr
rrrrr'rrc@seZdZdd�ZdS)�	ServiceIdcCst|�S�N)r	��selfrrr�	hyphenize,szServiceId.hyphenizeN)rrrrrrrrr+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�pattern�	sensitive�enum�idempotencyToken�error�	exception�endpointdiscoveryid�	retryable�document�union�contextParam�clientContextParams�requiresLengthNcCsB||_|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�getr>�_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@)rC�SERIALIZED_ATTRS�pop)r�model�
serialization�attrrrrrN�s

�zShape.serializationcCs0|j}i}|jD]
}||jvr||||<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.

        )rC�METADATA_ATTRS)rrM�metadatarOrrrrQ�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-�rQrBrrrr�required_members�s	zShape.required_memberscC�|j�|�Sr�rE�resolve_shape_ref�r�	shape_refrrr�_resolve_shape_ref��zShape._resolve_shape_refcCsd|jj�d|j�d�S)N�<�(z)>��	__class__rr@rrrr�__repr__�szShape.__repr__cCsdSrrrrrr�event_stream_name�szShape.event_stream_namer)rrr�__doc__rKrPr�MAP_TYPErJrrNrQrTrZr`�propertyrarrrrr0s 
"
 


rc@sHeZdZedd��Zedd��Zedd��Zedd��Zed	d
��ZdS)�StructureShapecCs>|j�d|���}|��}|��D]\}}|�|�||<q|S)N�members)rCrBrc�itemsrZ)rrf�
shape_membersr@rYrrrrf�s
zStructureShape.memberscCs,|j��D]\}}|j�d�r|SqdS)Nr')rfrgrNrB)r�member_name�memberrrrra�s
�z StructureShape.event_stream_namecCs8|j�dd�s	dS|j�di�}|�d�}|r|S|jS)Nr5Fr4�code)rQrBr@)r�error_metadatarkrrr�
error_code�s
zStructureShape.error_codecC�|j�dd�S)Nr8FrSrrrr�is_document_type��zStructureShape.is_document_typecCrn)Nr9FrSrrrr�is_tagged_union�rpzStructureShape.is_tagged_unionN)	rrrrrfrarmrorqrrrrre�s




rec@�eZdZedd��ZdS)�	ListShapecC�|�|jd�S)Nrj�rZrCrrrrrj�zListShape.memberN)rrrrrjrrrrrs��rsc@s$eZdZedd��Zedd��ZdS)�MapShapecCrt)N�keyrurrrrryrvzMapShape.keycCrt)N�valuerurrrrrz
rvzMapShape.valueN)rrrrryrzrrrrrxs

rxc@rr)�StringShapecCrR)Nr2rSrrrrr2rpzStringShape.enumN)rrrrr2rrrrr{rwr{c@s&eZdZUeed<eeefed<dS)�StaticContextParameterr@rzN)rrr�str�__annotations__r�boolrrrrr|s
r|c@seZdZUeed<eed<dS)�ContextParameterr@riN�rrrr}r~rrrrr�s
r�c@s&eZdZUeed<eed<eed<dS)�ClientContextParameterr@r=r>Nr�rrrrr�s
r�c@seZdZdZd0dd�Zd0dd�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&��Zed'd(��Zd)d*�Zed+d,��Zejd-d,��Zd.d/�ZdS)1�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.

        rQ�shapesN)	�_service_descriptionrBrQ�
ShapeResolverrE�NOT_SET�_signature_version�
_service_name�_instance_cache)r�service_description�service_namerrrrJ,s
�
zServiceModel.__init__cCs|j�||�Sr)rE�get_shape_by_name�rrG�
member_traitsrrr�	shape_forKs�zServiceModel.shape_forcCs|j�|d�Sr)�_error_code_cacherB)rrmrrr�shape_for_error_codeP�z!ServiceModel.shape_for_error_codecCs"i}|jD]	}|j}|||<q|Sr)�error_shapesrm)r�error_code_cache�error_shaperkrrrr�Ss


zServiceModel._error_code_cachecCrUrrVrXrrrrW[r[zServiceModel.resolve_shape_refcCst|j�di��S)Nr���listr�rBrrrr�shape_names^�zServiceModel.shape_namescCs6g}|jD]}|�|�}|j�dd�r|�|�q|S)Nr5F)r�r�rQrB�append)rr�rGr�rrrr�bs


�zServiceModel.error_shapescCs6z	|jd|}Wntyt|��wt|||�S�N�
operations)r��KeyErrorr�OperationModel)r�operation_namerMrrr�operation_modelks�zServiceModel.operation_modelcCrn�Nr>r?)r�rBrrrrr>srpzServiceModel.documentationcCst|j�dg��Sr�r�rrrr�operation_nameswr�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_prefixrrrrr�{s
zServiceModel.service_namecCs,zt|�d��WStyt|jd��w)N�	serviceId)r�)r�_get_metadata_propertyrrr�rrrr�
service_id�s
�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)rQrBr�)r�signing_namerrrr��szServiceModel.signing_namecC�
|�d�S)N�
apiVersion�r�rrrr�api_version��
zServiceModel.api_versioncCr�)N�protocolr�rrrrr��r�zServiceModel.protocolcCr�)N�endpointPrefixr�rrrrr��r�zServiceModel.endpoint_prefixcCs(|jD]}|�|�}|jr|SqdSr)r�r��is_endpoint_discovery_operation�r�	operationrMrrr�endpoint_discovery_operation�s

��z)ServiceModel.endpoint_discovery_operationcCs6|jD]}|�|�}|jdur|j�d�rdSqdS)Nr-TF)r�r��endpoint_discoveryrBr�rrr�endpoint_discovery_required�s



��z(ServiceModel.endpoint_discovery_requiredcC� |j�di�}dd�|��D�S)Nr;cSs&g|]\}}t||d|dd��qS)r=r>)r@r=r>)r�)�.0�
param_name�	param_valrrr�
<listcomp>�s���z:ServiceModel.client_context_parameters.<locals>.<listcomp>)r�rBrg�r�paramsrrr�client_context_parameters�s�z&ServiceModel.client_context_parameterscCs0z|j|WStytd|�d|����w)N�"z," not defined in the metadata of the model: )rQr�r�rr@rrrr��s��z#ServiceModel._get_metadata_propertycCs"|jtur|j�d�}||_|jS)N�signatureVersion)r�r�rQrB)r�signature_versionrrrr��s
zServiceModel.signature_versioncCs
||_dSr)r�)rrzrrrr��r�cC�|jj�d|j�d�S)Nr]�))r_rr�rrrrr`��zServiceModel.__repr__r)rrrrbrJr�r�rr�rWr�r�r
r�r>r�r�r�r�r�r�r�r�r�r�r�rdr��setterr`rrrrr�%sT



















r�c@sVeZdZd>dd�Zedd��Zedd��Zedd	��Zed
d��Z	edd
��Z
edd��Zedd��Zedd��Z
edd��Zedd��Zedd��Zedd��Zedd��Zedd��Zed d!��Zed"d#��Zed$d%��Zed&d'��Zed(d)��Zed*d+��Zd,d-�Zd.d/�Zd0d1�Zed2d3��Zed4d5��Zd6d7�Zd8d9�Z d:d;�Z!d<d=�Z"dS)?r�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_namerB�
_wire_namerQr�)rr��
service_modelr@rrrrJ�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 operation name
        we send across the wire (e.g cloudfront).

        Any serialization code should use ``wire_name``.

        r@�r�rBrrrrr�szOperationModel.wire_namecCs|jSr)r�rrrrr�szOperationModel.service_modelcCrnr�r�rrrrr>"rpzOperationModel.documentationcCrn)N�
deprecatedFr�rrrrr�&rpzOperationModel.deprecatedcCs|j�dd�S)N�endpointdiscoveryr�rrrrr�*sz!OperationModel.endpoint_discoverycCrn)N�endpointoperationFr�rrrrr�0rpz.OperationModel.is_endpoint_discovery_operationcC� d|jvrdS|j�|jd�S)N�input�r�r�rWrrrr�input_shape4s

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

�zOperationModel.output_shapecCs"|j}|sgSdd�|j��D�S)NcSs(g|]\}}d|jvr|jdr|�qS)r3)rQ�r�r@�shaperrrr�Os
��z5OperationModel.idempotent_members.<locals>.<listcomp>�r�rfrg)rr�rrr�idempotent_membersIs�z!OperationModel.idempotent_memberscCr�)N�staticContextParamscSs"g|]
\}}t||�d�d��qS)rz)r@rz)r|rB)r�r@�propsrrrr�Ys��z<OperationModel.static_context_parameters.<locals>.<listcomp>)r�rBrgr�rrr�static_context_parametersVs�z(OperationModel.static_context_parameterscCs |jsgSdd�|jj��D�S)NcSs>g|]\}}d|jvrd|jdvrt|jdd|d��qS)r:r@)r@ri)rQr�r�rrrr�cs
��z5OperationModel.context_parameters.<locals>.<listcomp>r�rrrr�context_parameters^s

�z!OperationModel.context_parameterscCr�)N�requestcompressionr�rrrr�request_compressionm�z"OperationModel.request_compressioncCr�)N�authtyper�rrrr�	auth_typeqr�zOperationModel.auth_typecs$�j�dg�}t�fdd�|D��S)N�errorsc3s�|]	}�j�|�VqdSr)r�rW)r��srrr�	<genexpr>xs�z.OperationModel.error_shapes.<locals>.<genexpr>)r�rBr�)rr�rrrr�uszOperationModel.error_shapescCr�)N�endpointr�rrrrr�zr�zOperationModel.endpointcCrn)N�httpChecksumRequiredFr�rrrr�http_checksum_required~rpz%OperationModel.http_checksum_requiredcCs|j�di�S)N�httpChecksumr�rrrr�
http_checksum�rpzOperationModel.http_checksumcC�|��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��r[z%OperationModel.get_event_stream_inputcCr�r)r�r�rrrrr��r[z&OperationModel.get_event_stream_outputcCs$|durdS|j}|r|j|SdS)zAReturns the event stream member's shape if any or None otherwise.N)rarf)rr��
event_namerrrr��s
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��r[z"OperationModel.get_streaming_inputcCr�r)r�r�rrrrr��r[z#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)rNrBrfrA)rr�r!�
payload_shaperrrr��s

z"OperationModel._get_streaming_bodycCr�)Nz(name=r�r^rrrrr`�r�zOperationModel.__repr__r)#rrrrJrr@rdr�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`rrrrr��sj
%







	












	

r�c@s8eZdZdZeeeed�Zdd�Z	d
dd�Z
dd	�ZdS)r�zResolves shape references.)�	structurer��map�stringcCs||_i|_dSr)�
_shape_map�_shape_cache)r�	shape_maprrrrJ�s
zShapeResolver.__init__NcCs�z|j|}Wntyt|��wz|j�|dt�}Wnty,td|����w|r8|��}|�|�||||�}|S)Nr=z&Shape is missing required key 'type': )	rr�r�
SHAPE_CLASSESrBrr�copy�update)rrGr�rH�	shape_cls�resultrrrr��s"���
zShapeResolver.get_shape_by_namecCsbt|�dkrd|vr|�|d�S|��}z|�d�}Wnty*td|����w|�||�S)N�r�z(Invalid model, missing shape reference: )�lenr�rrLr�r)rrYr�rGrrrrW�s��zShapeResolver.resolve_shape_refr)rrrrbrersrxr{rrJr�rWrrrrr��s�
r�c@s"eZdZdZddd�Zdd�ZdS)rDzEA ShapeResolver that will throw ValueErrors when shapes are resolved.NcC�td|�d���)NzAttempted to lookup shape '�!', but no shape map was provided.��
ValueErrorr�rrrr���
�z&UnresolvableShapeMap.get_shape_by_namecCr
)NzAttempted to resolve shape 'rrrXrrrrW�rz&UnresolvableShapeMap.resolve_shape_refr)rrrrbr�rWrrrrrD�s
rDc@sfeZdZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�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�charNcCs.t�|_t�|_|dur|j�d�|_dSdS)Nr�)rrf�ShapeNameGenerator�_name_generator�new_shape_namer@r�rrrrJ0s
�z%DenormalizedStructureBuilder.__init__cCs
||_|S)zp

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

        :return: self

        )�_members)rrfrrr�with_members6s	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�)r=rf)r)rGrHrI)rr�_build_modelr@r�re)rr��denormalized�resolverrrr�build_modelBs�
�z(DenormalizedStructureBuilder.build_modelcCs�|ddkr|�||�||<dS|ddkr |�||�||<dS|ddkr0|�||�||<dS|d|jvr@|�|�||<dStd|d����)Nr=r�r�r�zUnknown shape type: )�_build_structure�_build_list�
_build_map�SCALAR_TYPES�
_build_scalarr)rrMr�rGrrrrVsz)DenormalizedStructureBuilder._build_modelcCs\t�}|�|�}||d<|�dt����D]\}}|�|�}d|i||<|�|||�q|S)Nrfr�)r�_build_initial_shaperBrg�_get_shape_namer)rrMr�rfr�r@�member_model�member_shape_namerrrr bs

z-DenormalizedStructureBuilder._build_structurecCs6|�|�}|�|�}d|i|d<|�|d||�|S)Nr�rj�r&r%r)rrMr�r(r�rrrr!ms


z(DenormalizedStructureBuilder._build_listcCsf|�|d�}|�|d�}|�|�}d|i|d<d|i|d<|�|d||�|�|d||�|S)Nryrzr�r))rrMr��key_shape_name�value_shape_namer�rrrr"ts
z'DenormalizedStructureBuilder._build_mapcCsDd|di}d|vr|d|d<tjD]}||vr||||<q|S)Nr=r>)rrP)rrMr�rOrrrr%~s�
�z1DenormalizedStructureBuilder._build_initial_shapecCs
|�|�Sr)r%�rrMrrrr$�s
z*DenormalizedStructureBuilder._build_scalarcCs d|vr|dS|j�|d�S)NrGr=)rrr,rrrr&�sz,DenormalizedStructureBuilder._get_shape_namer)rrrrbr#rJrrrr r!r"r%r$r&rrrrr�s$

rc@s eZdZdZdd�Zdd�ZdS)rz�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_cacherrrrrJ�r�zShapeNameGenerator.__init__cCs.|j|d7<|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)rrA�
current_indexrrrr�s
z!ShapeNameGenerator.new_shape_nameN)rrrrbrJrrrrrr�srN)&rb�collectionsr�typingrr�botocore.compatr�botocore.exceptionsrr�botocore.utilsrr	r
�objectr��	Exceptionrrrrr}rrrersrxr{r|r�r�r�r�r�rDrrrrrr�<module>s<&*
?X6