Current File : //usr/lib/python3/dist-packages/boto3/resources/__pycache__/model.cpython-312.pyc
�

��e�O���dZddlZddlmZeje�ZGd�d�ZGd�d�ZGd�d	�Z	Gd
�d�Z
Gd�d
e	�ZGd�de	�ZGd�d�Z
Gd�de�ZGd�d�Zy)a�
The models defined in this file represent the resource JSON description
format and provide a layer of abstraction from the raw JSON. The advantages
of this are:

* Pythonic interface (e.g. ``action.request.operation``)
* Consumers need not change for minor JSON changes (e.g. renamed field)

These models are used both by the resource factory to generate resource
classes as well as by the documentation generator.
�N)�
xform_namec��eZdZdZdd�Zy)�
Identifierzw
    A resource identifier, given by its name.

    :type name: string
    :param name: The name of the identifier
    Nc� �||_||_y�N)�name�member_name)�selfrr	s   �7/usr/lib/python3/dist-packages/boto3/resources/model.py�__init__zIdentifier.__init__)s����	�&���r��__name__�
__module__�__qualname__�__doc__r�r
rrr!s���'r
rc��eZdZdZd�Zy)�Actiona
    A service operation action.

    :type name: string
    :param name: The name of the action
    :type definition: dict
    :param definition: The JSON definition
    :type resource_defs: dict
    :param resource_defs: All resources defined in the service
    c��||_||_d|_d|vr t|j	di��|_d|_d|vr!t
|j	di�|�|_|j	d�|_y)N�request�resource�path)�_definitionrr�Request�getr�ResponseResourcer�r
r�
definition�
resource_defss    rrzAction.__init__;sv��%�����	�����
�"�"�:�>�>�)�R�#@�A�D�L���
���#�,����z�2�.�
��D�M��N�N�6�*��	r
Nrrr
rrr/s��	�+r
rc�&�eZdZdZd�Zed��Zy)�DefinitionWithParamsa
    An item which has parameters exposed via the ``params`` property.
    A request has an operation and parameters, while a waiter has
    a name, a low-level waiter name and parameters.

    :type definition: dict
    :param definition: The JSON definition
    c��||_yr)r)r
rs  rrzDefinitionWithParams.__init__Xs
��%��r
c��g}|jjdg�D]}|jtdi|����|S)zt
        Get a list of auto-filled parameters for this request.

        :type: list(:py:class:`Parameter`)
        �paramsr�rr�append�	Parameter)r
r%�items   rr%zDefinitionWithParams.params[sF�����$�$�(�(��2�6�	-�D��M�M�)�+�d�+�,�	-��
r
N)rrrrr�propertyr%rr
rr"r"Ns ���&����r
r"c��eZdZdZ	dd�Zy)r(a�
    An auto-filled parameter which has a source and target. For example,
    the ``QueueUrl`` may be auto-filled from a resource's ``url`` identifier
    when making calls to ``queue.receive_messages``.

    :type target: string
    :param target: The destination parameter name, e.g. ``QueueUrl``
    :type source_type: string
    :param source_type: Where the source is defined.
    :type source: string
    :param source: The source name, e.g. ``Url``
    Nc�|�||_||_||_||_||_|rt
j
d|�yy)Nz#Unknown parameter options found: %s)�target�sourcerr�value�logger�warning)r
r-r.rrr/�kwargss       rrzParameter.__init__xs@����������	���	���
���N�N�@�&�I�r
)NNNrrr
rr(r(js���;?�Jr
r(c�"��eZdZdZ�fd�Z�xZS)rzt
    A service operation action request.

    :type definition: dict
    :param definition: The JSON definition
    c�P��t�|�|�|jd�|_y)N�	operation)�superrrr5)r
r�	__class__s  �rrzRequest.__init__�s"���
����$�$����4��r
)rrrrr�
__classcell__�r7s@rrr�s����5�5r
rc�&��eZdZdZdZ�fd�Z�xZS)�Waiterz�
    An event waiter specification.

    :type name: string
    :param name: Name of the waiter
    :type definition: dict
    :param definition: The JSON definition
    �	WaitUntilc�^��t�|�|�||_|jd�|_y)N�
waiterName)r6rrr�waiter_name)r
rrr7s   �rrzWaiter.__init__�s,���
����$���	�&�>�>�,�7��r
)rrrr�PREFIXrr8r9s@rr;r;�s�����F�8�8r
r;c�6�eZdZdZd�Zed��Zed��Zy)rz�
    A resource response to create after performing an action.

    :type definition: dict
    :param definition: The JSON definition
    :type resource_defs: dict
    :param resource_defs: All resources defined in the service
    c�x�||_||_|jd�|_|jd�|_y)N�typer)r�_resource_defsrrCr)r
rr s   rrzResponseResource.__init__�s6��%���+����N�N�6�*��	��N�N�6�*��	r
c��g}|jjdg�D]}|jtdi|����|S)z^
        A list of resource identifiers.

        :type: list(:py:class:`Identifier`)
        �identifiersrr&)r
rFr)s   rrFzResponseResource.identifiers�sI�����$�$�(�(���;�	2�D����y�0�4�0�1�	2��r
c�r�t|j|j|j|j�S)zm
        Get the resource model for the response resource.

        :type: :py:class:`ResourceModel`
        )�
ResourceModelrCrD�r
s r�modelzResponseResource.model�s1����I�I�t�*�*�4�9�9�5�t�7J�7J�
�	
r
N)rrrrrr*rFrJrr
rrr�s4���+������
��
r
rc� �eZdZdZed��Zy)�
Collectiona
    A group of resources. See :py:class:`Action`.

    :type name: string
    :param name: The name of the collection
    :type definition: dict
    :param definition: The JSON definition
    :type resource_defs: dict
    :param resource_defs: All resources defined in the service
    c�B�|jjjS)z�
        Get a list of batch actions supported by the resource type
        contained in this action. This is a shortcut for accessing
        the same information through the resource model.

        :rtype: list(:py:class:`Action`)
        )rrJ�
batch_actionsrIs rrNzCollection.batch_actions�s���}�}�"�"�0�0�0r
N)rrrrr*rNrr
rrLrL�s��	��1��1r
rLc��eZdZdZd�Zdd�Zdd�Zdd�Zd�Ze	d��Z
e	d	��Ze	d
��Ze	d��Z
d�Zd
�Ze	d��Ze	d��Ze	d��Ze	d��Zy)rHa�
    A model representing a resource, defined via a JSON description
    format. A resource has identifiers, attributes, actions,
    sub-resources, references and collections. For more information
    on resources, see :ref:`guide_resources`.

    :type name: string
    :param name: The name of this resource, e.g. ``sqs`` or ``Queue``
    :type definition: dict
    :param definition: The JSON definition
    :type resource_defs: dict
    :param resource_defs: All resources defined in the service
    c�h�||_||_i|_||_|j	d�|_y)N�shape)rrD�_renamedrrrQrs    rrzResourceModel.__init__s2��%���+�����
���	��^�^�G�,��
r
Nc�z�dh}i|_|jjd�r|jd�|jjdg�D]}|j	||dd��|jjdi�D]}|j	||d��|j�j
�D]K\}}d}|d	dD]}|d
dk(s�d}n|s|j	||d
d���9|j	||d��M|jjdi�D]}|j	||d��|jjdi�D]&}|j	|tj|zd��(|�3|jj�D]}|j	||d��yy)a�
        Load a name translation map given a shape. This will set
        up renamed values for any collisions, e.g. if the shape,
        an action, and a subresource all are all named ``foo``
        then the resource will have an action ``foo``, a subresource
        named ``Foo`` and a property named ``foo_attribute``.
        This is the order of precedence, from most important to
        least important:

        * Load action (resource.load)
        * Identifiers
        * Actions
        * Subresources
        * References
        * Collections
        * Waiters
        * Attributes (shape members)

        Batch actions are only exposed on collections, so do not
        get modified here. Subresources use upper camel casing, so
        are unlikely to collide with anything but other subresources.

        Creates a structure like this::

            renames = {
                ('action', 'id'): 'id_action',
                ('collection', 'id'): 'id_collection',
                ('attribute', 'id'): 'id_attribute'
            }

            # Get the final name for an action named 'id'
            name = renames.get(('action', 'id'), 'id')

        :type shape: botocore.model.Shape
        :param shape: The underlying shape for this resource.
        �meta�loadrFr�
identifier�actions�actionFrr.�dataT�subresource��
snake_case�	reference�hasMany�
collection�waiters�waiterN�	attribute)rRrr�add�_load_name_with_category�_get_has_definition�itemsr;r@�members�keys)r
rQ�namesr)r�ref�
data_requiredrVs        r�load_rename_mapzResourceModel.load_rename_maps���L�����
�������'��I�I�f���$�$�(�(���;�	M�D��)�)�%��f��|�L�	M��$�$�(�(��B�7�	A�D��)�)�%��x�@�	A��1�1�3�9�9�;�	H�I�D�#�"�M�!�*�o�m�<�
�
��h�'�6�1�$(�M��
�
!��-�-��4��5�.���-�-�e�T�;�G�	H� �$�$�(�(��B�7�	E�D��)�)�%��|�D�	E��$�$�(�(��B�7�	�D��)�)��v�}�}�t�+�X�
�	�
���
�
�*�*�,�
H���-�-�e�T�;�G�
H�r
c�*�|rt|�}||vrqtjd|j�d|�d|���|dz|z|j||f<|d|zz
}||vr&tdj
|j||���|j|�y)a�
        Load a name with a given category, possibly renaming it
        if that name is already in use. The name will be stored
        in ``names`` and possibly be set up in ``self._renamed``.

        :type names: set
        :param names: Existing names (Python attributes, properties, or
                      methods) on the resource.
        :type name: string
        :param name: The original name of the value.
        :type category: string
        :param category: The value type, such as 'identifier' or 'action'
        :type snake_case: bool
        :param snake_case: True (default) if the name should be snake cased.
        z	Renaming � �_zProblem renaming {} {} to {}!N)rr0�debugrrR�
ValueError�formatrc)r
rir�categoryr\s     rrdz&ResourceModel._load_name_with_category]s��� ��d�#�D��5�=��L�L�9�T�Y�Y�K�q��
�!�D�6�B�C�.2�S�j�8�.C�D�M�M�8�T�*�+��C�(�N�"�D��u�}�!�3�:�:��	�	�8�T����	�	�	�$�r
c�X�|rt|�}|jj||f|�S)a]
        Get a possibly renamed value given a category and name. This
        uses the rename map set up in ``load_rename_map``, so that
        method must be called once first.

        :type category: string
        :param category: The value type, such as 'identifier' or 'action'
        :type name: string
        :param name: The original name of the value
        :type snake_case: bool
        :param snake_case: True (default) if the name should be snake cased.
        :rtype: string
        :return: Either the renamed value if it is set, otherwise the
                 original name.
        )rrRr)r
rsrr\s    r�	_get_namezResourceModel._get_name�s-�� ��d�#�D��}�}� � �(�D�!1�4�8�8r
c���i}|jD�cgc]}|j��}}|jj�D]0\}}t	|�}||vr�|jd|d��}||f||<�2|Scc}w)a�
        Get a dictionary of attribute names to original name and shape
        models that represent the attributes of this resource. Looks
        like the following:

            {
                'some_name': ('SomeName', <Shape...>)
            }

        :type shape: botocore.model.Shape
        :param shape: The underlying shape for this resource.
        :rtype: dict
        :return: Mapping of resource attributes.
        rbFr[)rFrrgrfrru)r
rQ�
attributes�i�identifier_namesr�member�snake_caseds        r�get_attributeszResourceModel.get_attributes�s����
�,0�,<�,<�=�q�A�F�F�=��=�!�M�M�/�/�1�	5�L�D�&�$�T�*�K��.�.���.�.��[�U�)��K�(,�V�n�J�{�#�	5����>s�A5c��g}|jjdg�D]X}|jd|d�}|jdd�}|r|jd|�}|jt	||���Z|S)zb
        Get a list of resource identifiers.

        :type: list(:py:class:`Identifier`)
        rFrVr�
memberNameNrb)rrrur'r)r
rFr)rr	s     rrFzResourceModel.identifiers�s�����$�$�(�(���;�	>�D��>�>�,��V��=�D��(�(�<��6�K��"�n�n�[�+�F�����z�$��<�=�	>��r
c�n�|jjd�}|�td||j�}|S)zy
        Get the load action for this resource, if it is defined.

        :type: :py:class:`Action` or ``None``
        rU)rrrrD)r
rXs  rrUzResourceModel.load�s9���!�!�%�%�f�-�����F�F�D�,?�,?�@�F��
r
c���g}|jjdi�j�D]=\}}|jd|�}|j	t|||j���?|S)zc
        Get a list of actions for this resource.

        :type: list(:py:class:`Action`)
        rWrX�rrrfrur'rrD�r
rWrr)s    rrWzResourceModel.actions�sl�����*�*�.�.�y�"�=�C�C�E�	D�J�D�$��>�>�(�D�1�D��N�N�6�$��d�.A�.A�B�C�	D��r
c���g}|jjdi�j�D]=\}}|jd|�}|j	t|||j���?|S)zi
        Get a list of batch actions for this resource.

        :type: list(:py:class:`Action`)
        �batchActions�batch_actionr�r�s    rrNzResourceModel.batch_actions�sl�����*�*�.�.�~�r�B�H�H�J�	D�J�D�$��>�>�.�$�7�D��N�N�6�$��d�.A�.A�B�C�	D��r
c��|j|jvr�i}|jj�D]�\}}d}|jj	di�j�}|D]1\}}|j	di�j	d�|k(s�+|||<d}�3|r�kd|gd�i}|j	dg�D]}	|ddj|	dd	d
���!|||<��|S|jj	di�}|S)a�
        Get a ``has`` relationship definition from a model, where the
        service resource model is treated special in that it contains
        a relationship to every resource defined for the service. This
        allows things like ``s3.Object('bucket-name', 'key')`` to
        work even though the JSON doesn't define it explicitly.

        :rtype: dict
        :return: Mapping of names to subresource and reference
                 definitions.
        F�hasrrCT)rCrFrFr�input)r-r.)rrDrfrrr')
r
rr�resource_def�found�	has_items�has_name�has_def�fake_hasrVs
          rrez!ResourceModel._get_has_definition�s6���9�9�D�/�/�/��J�&*�&9�&9�&?�&?�&A�#
0�"��l�
�� �,�,�0�0���;�A�A�C�	�)2�%�%�H�g��{�{�:�r�2�6�6�v�>�$�F�/6�
�8�,� $��%�
� !+�T�"�,M�N�H�&2�&6�&6�}�b�&I��
� ��,�]�;�B�B�'1�&�'9�W�M���
(0�J�t�$�G#
0�N���)�)�-�-�e�R�8�J��r
c��g}|j�j�D]�\}}|r|jd|d��}n|jd|�}t|||j�}d}|j
jD]}|jdk(s�d}n|r|s|j|���|r��|s��|j|���|S)z�
        Get a list of sub-resources or references.

        :type subresources: bool
        :param subresources: ``True`` to get sub-resources, ``False`` to
                             get references.
        :rtype: list(:py:class:`Action`)
        rZFr[r]rYT)	rerfrurrDrrFr.r')r
�subresources�	resourcesrrrXrkrVs        r�_get_related_resourcesz$ResourceModel._get_related_resources+s����	� $� 8� 8� :� @� @� B�	)��D�*���~�~�m�T�e�~�L���~�~�k�4�8���D�*�d�.A�.A�B�F�!�M�$�o�o�9�9�
�
��$�$��.�$(�M��
�
�M�� � ��(�!�m�� � ��(�!	)�$�r
c�$�|jd�S)zW
        Get a list of sub-resources.

        :type: list(:py:class:`Action`)
        T�r�rIs rr�zResourceModel.subresourcesJs���*�*�4�0�0r
c�$�|jd�S)z]
        Get a list of reference resources.

        :type: list(:py:class:`Action`)
        Fr�rIs r�
referenceszResourceModel.referencesSs���*�*�5�1�1r
c���g}|jjdi�j�D]=\}}|jd|�}|j	t|||j���?|S)zk
        Get a list of collections for this resource.

        :type: list(:py:class:`Collection`)
        r^r_)rrrfrur'rLrD)r
�collectionsrr)s    rr�zResourceModel.collections\so�����*�*�.�.�y�"�=�C�C�E�	L�J�D�$��>�>�,��5�D����z�$��d�6I�6I�J�K�	L��r
c���g}|jjdi�j�D]C\}}|jdtj
|z�}|j
t	||���E|S)zc
        Get a list of waiters for this resource.

        :type: list(:py:class:`Waiter`)
        r`ra)rrrfrur;r@r')r
r`rr)s    rr`zResourceModel.waitersksk�����*�*�.�.�y�"�=�C�C�E�	/�J�D�$��>�>�(�F�M�M�D�,@�A�D��N�N�6�$��-�.�	/��r
r)T)rrrrrrlrdrur|r*rFrUrWrNrer�r�r�r�r`rr
rrHrH�s����-�LH�\!�F9�*�<����"������������8�t�>�1��1��2��2��������r
rH)r�logging�botocorer�	getLoggerrr0rrr"r(rr;rrLrHrr
r�<module>r�s���
���	��	�	�8�	$��'�'�+�+�>��8J�J�B5�"�5�8�
!�8�,+
�+
�\1��1�0B�Br