Current File : //proc/self/root/lib/python3/dist-packages/boto3/resources/__pycache__/response.cpython-312.pyc
�

��e�-��`�ddlZddlmZddlmZd�Zdd�Zd�ZGd�d	�ZGd
�d�Z	y)
�N)�
xform_name�)�get_data_memberc��|D]}|��yy)z�
    Return True if all elements of the iterable are not None (or if the
    iterable is empty). This is like the built-in ``all``, except checks
    against None, so 0 and False are allowable values.
    FT�)�iterable�elements  �:/usr/lib/python3/dist-packages/boto3/resources/response.py�all_not_noners ������?����c���g}|D]�}|j}|j}|dk(r!tj|j|�}n{|dk(r!tj|j|�}nU|dk(r t|t
|j��}n0|dk(rt||j�}n|dk(r��td|����|jt
|�|f���|S)a�
    Builds a mapping of identifier names to values based on the
    identifier source location, type, and target. Identifier
    values may be scalars or lists depending on the source type
    and location.

    :type identifiers: list
    :param identifiers: List of :py:class:`~boto3.resources.model.Parameter`
                        definitions
    :type parent: ServiceResource
    :param parent: The resource instance to which this action is attached.
    :type params: dict
    :param params: Request parameters sent to the service.
    :type raw_response: dict
    :param raw_response: Low-level operation response.
    :rtype: list
    :return: An ordered list of ``(name, value)`` identifier tuples.
    �response�requestParameter�
identifier�data�inputzUnsupported source type: )�source�target�jmespath�search�path�getattrr�namer�NotImplementedError�append)	�identifiers�parent�params�raw_response�resultsrrr�values	         r
�build_identifiersr" s���&�G�!�4�
��"�"���"�"���Z���O�O�J�O�O�\�B�E�
�)�
)��O�O�J�O�O�V�<�E�
�|�
#��F�J�z���$?�@�E�
�v�
�$�F�J�O�O�<�E�
�w�
��%�(A�&��&J�K�K����
�6�*�E�2�3�)4�,�Nrc���d}|j|�}|j}|r�|jd�D]r}|jd�}|jdk(r|j
|}�3|jdk(r
|j}�Otdj|j|���|jdk(ri}|S|jdk(rg}|S|jdk(ri}|S)a�
    Creates an appropriate empty response for the type that is expected,
    based on the service model's shape type. For example, a value that
    is normally a list would then return an empty list. A structure would
    return an empty dict, and a number would return None.

    :type search_path: string
    :param search_path: JMESPath expression to search in the response
    :type operation_name: string
    :param operation_name: Name of the underlying service operation.
    :type service_model: :ref:`botocore.model.ServiceModel`
    :param service_model: The Botocore service model
    :rtype: dict, list, or None
    :return: An appropriate empty value
    N�.z
[0123456789]$�	structure�listz&Search path hits shape type {} from {}�map)	�operation_model�output_shape�split�strip�	type_name�members�memberr�format)�search_path�operation_name�
service_modelrr(�shape�items       r
�build_empty_responser5Ns��� �H�#�3�3�N�C�O��(�(�E��
 �%�%�c�*�	�D��:�:�o�.�D����+�-��
�
�d�+�����F�*�����)�<�C�C��������	�
���+�%����O�
���F�	"����O�
���E�	!����Orc��eZdZdZd�Zd�Zy)�
RawHandleraG
    A raw action response handler. This passed through the response
    dictionary, optionally after performing a JMESPath search if one
    has been defined for the action.

    :type search_path: string
    :param search_path: JMESPath expression to search in the response
    :rtype: dict
    :return: Service response
    c��||_y�N)r0)�selfr0s  r
�__init__zRawHandler.__init__�s
��&��rc�|�|jr/|jdk7r tj|j|�}|S)�,
        :type parent: ServiceResource
        :param parent: The resource instance to which this action is attached.
        :type params: dict
        :param params: Request parameters sent to the service.
        :type response: dict
        :param response: Low-level operation response.
        �$)r0rr)r:rrrs    r
�__call__zRawHandler.__call__�s5������ 0� 0�C� 7����t�'7�'7��B�H��rN)�__name__�
__module__�__qualname__�__doc__r;r?rrr
r7r7�s��	�'�
rr7c�&�eZdZdZ	dd�Zd�Zd�Zy)�ResourceHandleraf
    Creates a new resource or list of new resources from the low-level
    response based on the given response resource definition.

    :type search_path: string
    :param search_path: JMESPath expression to search in the response

    :type factory: ResourceFactory
    :param factory: The factory that created the resource class to which
                    this action is attached.

    :type resource_model: :py:class:`~boto3.resources.model.ResponseResource`
    :param resource_model: Response resource model.

    :type service_context: :py:class:`~boto3.utils.ServiceContext`
    :param service_context: Context about the AWS service

    :type operation_name: string
    :param operation_name: Name of the underlying service operation, if it
                           exists.

    :rtype: ServiceResource or list
    :return: New resource instance(s).
    Nc�J�||_||_||_||_||_yr9)r0�factory�resource_modelr1�service_context)r:r0rGrHrIr1s      r
r;zResourceHandler.__init__�s+��'������,���,���.��rc	�h�|jj}|jjj	|�}|j
j
|||j��}|}d}|jr tj|j|�}tt|jj|||��}	|	j�D�
cgc]}
t|
t�s�|
��}}
|rLg}t!t#|d��D].}d}
|r||}
|j%|j'|||	|
���0|St)|	j��r|j'|||	|�}|Sd}|j*�5t-|j|j*|jj.�}|Scc}
w)r=)�
resource_name�single_resource_json_definitionrINr)rH�typerI�resource_json_definitions�getrG�load_from_definitionr0rr�dictr"r�values�
isinstancer&�range�lenr�handle_response_itemrr1r5r2)r:rrrrK�json_definition�resource_clsr�search_responser�v�plural�i�
response_items              r
r?zResourceHandler.__call__�s����+�+�0�0�
��.�.�H�H�L�L��
��
�|�|�8�8�'�,;� �0�0�9�
��
 �������&�o�o�d�.>�.>��M�O����#�#�/�/����
�
��)�/�/�1�I��Z��4�5H�!�I��I���H��3�v�a�y�>�*�
��!%�
�"�$3�A�$6�M�����-�-�$�f�k�=���
�B��+�+�,�,�.�
/��0�0��f�k�?��H�$���H��"�"�.�0��$�$��'�'��(�(�6�6������QJs�F/�'F/c���d|jji}|j�D]+\}}t|t�r|jd�}|||<�-|di|��}|�||j_|S)a�
        Handles the creation of a single response item by setting
        parameters and creating the appropriate resource instance.

        :type resource_cls: ServiceResource subclass
        :param resource_cls: The resource class to instantiate.
        :type parent: ServiceResource
        :param parent: The resource instance to which this action is attached.
        :type identifiers: dict
        :param identifiers: Map of identifier names to value or values.
        :type resource_data: dict or None
        :param resource_data: Data for resource attributes.
        :rtype: ServiceResource
        :return: New resource instance.
        �clientrr)�metar_�itemsrSr&�popr)	r:rXrr�
resource_data�kwargsrr!�resources	         r
rVz$ResourceHandler.handle_response_items~��&
�f�k�k�(�(�
��'�,�,�.�	!�K�D�%��%��&��	�	�!��� �F�4�L�	!� �)�&�)���$�!.�H�M�M���rr9)r@rArBrCr;r?rVrrr
rErE�s���>�
/�R�h"rrE)NN)
r�botocorerrrrr"r5r7rErrr
�<module>rgs7����#�	�+�\0�f��>^�^r