B 劇c-@sZddlZddlmZddlmZddZdddZd d ZGd d d ZGd ddZ dS)N) xform_name)get_data_membercCsx|D]}|dkrdSqWdS)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. NFT)iterableelementrrs/private/var/folders/8c/hx9_v10d5x38qmnzt13b7b8j1k3n5b/T/pip-target-x6xd5gna/lib/python/boto3/resources/response.py all_not_nones r c Csg}x|D]}|j}|j}|dkr2t|j|}nb|dkrJt|j|}nJ|dkrdt|t|j}n0|dkrzt||j}n|dkrq nt d|| t||fq W|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. responseZrequestParameter identifierdatainputzUnsupported source type: ) sourcetargetjmespathsearchpathgetattrrnamerNotImplementedErrorappend) identifiersparentparams raw_responseresultsr rrvaluerrrbuild_identifiers s" rcCsd}||}|j}|rpxV|dD]H}|d}|jdkrH|j|}q$|jdkrZ|j}q$td|j|q$W|jdkri}n|jdkrg}n|jdkri}|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]$Z structurelistz&Search path hits shape type {} from {}map) operation_modelZ output_shapesplitstripZ type_namemembersmemberrformat) search_pathoperation_name service_modelr r!shapeitemrrrbuild_empty_responseNs(        r,c@s eZdZdZddZddZdS) 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 cCs ||_dS)N)r')selfr'rrr__init__szRawHandler.__init__cCs"|jr|jdkrt|j|}|S)a, :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'rr)r.rrr rrr__call__s zRawHandler.__call__N)__name__ __module__ __qualname____doc__r/r1rrrrr-s r-c@s*eZdZdZd ddZddZddZdS) 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). NcCs"||_||_||_||_||_dS)N)r'factoryresource_modelr(service_context)r.r'r7r8r9r(rrrr/s zResourceHandler.__init__c Cs|jj}|jj|}|jj|||jd}|}d}|jrFt |j|}t t |jj |||} dd| D} | rg}xtt| dD]*} d} |r|| } ||||| | qWn@t| r|||| |}n"d}|jdk rt|j|j|jj}|S)a, :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. ) resource_nameZsingle_resource_json_definitionr9NcSsg|]}t|tr|qSr) isinstancer).0vrrr sz,ResourceHandler.__call__..r)r8typer9Zresource_json_definitionsgetr7Zload_from_definitionr'rrdictrrvaluesrangelenrhandle_response_itemr r(r,r)) r.rrr r:Zjson_definition resource_clsrZsearch_responserpluraliZ response_itemrrrr1sD     zResourceHandler.__call__c Cs\d|jji}x0|D]$\}}t|tr2|d}|||<qW|f|}|dk rX||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. clientrN)metarIitemsr;rpopr ) r.rFrrZ resource_datakwargsrrresourcerrrrEs     z$ResourceHandler.handle_response_item)N)r2r3r4r5r/r1rErrrrr6s Tr6)NN) rZbotocorerrrr rr,r-r6rrrrs   .3