
     hv-                     `    d dl Z d dlmZ ddlmZ d ZddZd Z G d d	      Z G d
 d      Z	y)    N)
xform_name   )get_data_memberc                     | D ]  }| y y)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     t/home/developers/rajanand/mypropertyqr-fmb-refixing-v2/venv/lib/python3.12/site-packages/boto3/resources/response.pyall_not_noner      s       ?     c                    g }| D ]  }|j                   }|j                  }|dk(  r!t        j                  |j                  |      }n{|dk(  r!t        j                  |j                  |      }nU|dk(  r t        |t        |j                              }n0|dk(  rt        ||j                        }n|dk(  rt        d|       |j                  t        |      |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inputzUnsupported source type: )sourcetargetjmespathsearchpathgetattrr   namer   NotImplementedErrorappend)	identifiersparentparamsraw_responseresultsr   r   r   values	            r
   build_identifiersr"       s    & G! 4
""""ZOOJOO\BE))OOJOOV<E|#FJz$?@Ev $FJOO<Ew%(A&&JKK
6*E23)4, Nr   c                    d}|j                  |      }|j                  }| r|| j                  d      D ]h  }|j                  d      }|j                  dk(  r|j
                  |   }3|j                  dk(  r|j                  }Ot        d|j                   d|        |j                  dk(  ri }|S |j                  dk(  rg }|S |j                  dk(  ri }|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 z from map)operation_modeloutput_shapesplitstrip	type_namemembersmemberr   )search_pathoperation_nameservice_modelr   r(   shapeitems          r
   build_empty_responser4   N   s      H#33NCO((E
  %%c* 
	D::o.D+-d+F*)25??2C6$P 
	 +% O 
F	" O 
E	!Or   c                       e Zd ZdZd Zd Zy)
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)r/   )selfr/   s     r
   __init__zRawHandler.__init__   s
    &r   c                 |    | j                   r/| j                   dk7  r t        j                  | 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.
        $)r/   r   r   )r9   r   r   r   s       r
   __call__zRawHandler.__call__   s5      0 0C 7t'7'7BHr   N)__name__
__module____qualname____doc__r:   r>   r   r   r
   r6   r6      s    	'r   r6   c                   &    e Zd ZdZ	 ddZd Zd Zy)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    || _         || _        || _        || _        || _        y r8   )r/   factoryresource_modelr0   service_context)r9   r/   rF   rG   rH   r0   s         r
   r:   zResourceHandler.__init__   s+     ',,.r   c           	      h   | j                   j                  }| j                  j                  j	                  |      }| j
                  j                  ||| j                        }|}d}| j                  r t        j                  | j                  |      }t        t        | j                   j                  |||            }	|	j                         D 
cg c]  }
t        |
t              s|
 }}
|rLg }t!        t#        |d               D ].  }d}|r||   }|j%                  | j'                  |||	|             0 |S t)        |	j                               r| j'                  |||	|      }|S d}| j*                  5t-        | j                  | j*                  | j                  j.                        }|S c c}
w )r<   )resource_namesingle_resource_json_definitionrH   Nr   )rG   typerH   resource_json_definitionsgetrF   load_from_definitionr/   r   r   dictr"   r   values
isinstancer&   rangelenr   handle_response_itemr   r0   r4   r1   )r9   r   r   r   rJ   json_definitionresource_clsr   search_responser   vpluraliresponse_items                 r
   r>   zResourceHandler.__call__   s    ++00..HHLL

 ||88',; 00 9 

   &ood.>.>MO ##//
 )//1IZ45H!IIH 3vay>*  !%"$3A$6M--$fk=B + +,,./ 00fk?H$  H"". 0$$''((66 Q Js   F/'F/c                     d|j                   j                  i}|j                         D ]+  \  }}t        |t              r|j                  d      }|||<   -  |di |}|||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.
        clientr   r   )metar^   itemsrR   r&   popr   )	r9   rW   r   r   resource_datakwargsr   r!   resources	            r
   rU   z$ResourceHandler.handle_response_item  s~    & fkk((
 ',,. 	!KD%%&		! F4L	!  )&)$!.HMMr   r8   )r?   r@   rA   rB   r:   r>   rU   r   r   r
   rD   rD      s    > /Rh"r   rD   )NN)
r   botocorer   r   r   r   r"   r4   r6   rD   r   r   r
   <module>rf      s7      #	+\.b >^ ^r   