U å€C^%ã@s¢ddlZddlmZddlmZddlmZmZddlm Z ddl m Z ddl m Z e e¡ZGd d „d eƒZGd d „d eƒZGd d„deƒZGdd„deƒZdS)éN)Ú xform_nameé)Úcreate_request_parameters)Ú RawHandlerÚResourceHandler)ÚAction)ÚActionDocstring)Úinject_attributec@s"eZdZdZddd„Zdd„ZdS)Ú ServiceActiona¥ A class representing a callable action on a resource, for example ``sqs.get_queue_by_name(...)`` or ``s3.Bucket('foo').delete()``. The action may construct parameters from existing resource identifiers and may return either a raw response or a new resource instance. :type action_model: :py:class`~boto3.resources.model.Action` :param action_model: The action model. :type factory: ResourceFactory :param factory: The factory that created the resource class to which this action is attached. :type service_context: :py:class:`~boto3.utils.ServiceContext` :param service_context: Context about the AWS service NcCs<||_|j}|r,t|j||||jjd�|_n t|jƒ|_dS)N)Ú search_pathÚfactoryZresource_modelÚservice_contextÚoperation_name)Ú _action_modelÚresourcerÚpathÚrequestÚ operationÚ_response_handlerr)ÚselfÚ action_modelr r Zresource_response_model©rú9/tmp/pip-install-6_kvzl1k/boto3/boto3/resources/action.pyÚ__init__.sü zServiceAction.__init__cOsht|jjjƒ}t||jjƒ}| |¡t d|jj ||¡t |jj |ƒf|Ž}t d|¡|  |||¡S)a½ Perform the action's request operation after building operation parameters and build any defined resources from the response. :type parent: :py:class:`~boto3.resources.base.ServiceResource` :param parent: The resource instance to which this action is attached. :rtype: dict or ServiceResource or list(ServiceResource) :return: The response, either as a raw dict or resource instance(s). úCalling %s:%s with %rú Response: %r) rrrrrÚupdateÚloggerÚdebugÚmetaÚ service_nameÚgetattrÚclientr)rÚparentÚargsÚkwargsrÚparamsÚresponserrrÚ__call__>s   ÿ zServiceAction.__call__)NN©Ú__name__Ú __module__Ú __qualname__Ú__doc__rr(rrrrr s r c@seZdZdZdd„ZdS)Ú BatchActionaÆ An action which operates on a batch of items in a collection, typically a single page of results from the collection's underlying service operation call. For example, this allows you to delete up to 999 S3 objects in a single operation rather than calling ``.delete()`` on each one individually. :type action_model: :py:class`~boto3.resources.model.Action` :param action_model: The action model. :type factory: ResourceFactory :param factory: The factory that created the resource class to which this action is attached. :type service_context: :py:class:`~boto3.utils.ServiceContext` :param service_context: Context about the AWS service c OsÈd}d}g}t|jjjƒ}| ¡D] }i} t|ƒD]<\} } |dkrJ| jj}|dkrZ| jj}t | |jj| | d�q2| sxqÄ|   |¡t   d||| ¡t ||ƒf| Ž} t   d| ¡| | || | ¡¡q"|S)a‘ Perform the batch action's operation on every page of results from the collection. :type parent: :py:class:`~boto3.resources.collection.ResourceCollection` :param parent: The collection iterator to which this action is attached. :rtype: list(dict) :return: A list of low-level response dicts from each call. N)r&Úindexrr)rrrrZpagesÚ enumeraterr r"rrrrr!Úappendr) rr#r$r%r r"Ú responsesrÚpager&r/rr'rrrr(ls>  þ ÿ  ÿzBatchAction.__call__N)r*r+r,r-r(rrrrr.Zsr.c@s eZdZdZdd„Zdd„ZdS)Ú WaiterActiona/ A class representing a callable waiter action on a resource, for example ``s3.Bucket('foo').wait_until_bucket_exists()``. The waiter action may construct parameters from existing resource identifiers. :type waiter_model: :py:class`~boto3.resources.model.Waiter` :param waiter_model: The action waiter. :type waiter_resource_name: string :param waiter_resource_name: The name of the waiter action for the resource. It usually begins with a ``wait_until_`` cCs||_||_dS)N)Ú _waiter_modelÚ_waiter_resource_name)rZ waiter_modelZwaiter_resource_namerrrr°szWaiterAction.__init__c Osft|jjƒ}t||jƒ}| |¡t d|jj|j |¡|jj }|  |¡}|j f|Ž}t d|¡dS)zñ Perform the wait operation after building operation parameters. :type parent: :py:class:`~boto3.resources.base.ServiceResource` :param parent: The resource instance to which this action is attached. rrN) rr5Z waiter_namerrrrrr r6r"Z get_waiterÚwait) rr#r$r%Zclient_waiter_namer&r"Úwaiterr'rrrr(´s   þ  zWaiterAction.__call__Nr)rrrrr4¢s r4c@s eZdZdZdd„Zdd„ZdS)ÚCustomModeledActionz3A custom, modeled action to inject into a resource.cCs||_||_||_||_dS)aƒ :type action_name: str :param action_name: The name of the action to inject, e.g. 'delete_tags' :type action_model: dict :param action_model: A JSON definition of the action, as if it were part of the resource model. :type function: function :param function: The function to perform when the action is called. The first argument should be 'self', which will be the resource the function is to be called on. :type event_emitter: :py:class:`botocore.hooks.BaseEventHooks` :param event_emitter: The session event emitter. N)ÚnameÚmodelÚfunctionÚemitter)rÚ action_namerr<Ú event_emitterrrrrÑszCustomModeledAction.__init__cKsV| d¡d}t|j|jiƒ}|j|j_t||j||jdd�|j_ t ||j|jƒdS)NÚ.éÿÿÿÿF)Ú resource_namer?rÚ service_modelZinclude_signature) Úrsplitrr:r;r<r*rr=rCr-r )rZclass_attributesr Z event_namer%rBÚactionrrrÚinjectés û zCustomModeledAction.injectN)r*r+r,r-rrFrrrrr9Ïsr9)ÚloggingZbotocorerr&rr'rrr;rZboto3.docs.docstringrZ boto3.utilsr Ú getLoggerr*rÚobjectr r.r4r9rrrrÚs      =H-