o
    é’Oj€%  ã                   @   sœ   d dl Z d dlmZ d dlmZ d dlmZ ddlmZ ddl	m
Z
 ddlmZmZ e  e¡ZG d	d
„ d
ƒZG dd„ deƒZG dd„ dƒZG dd„ dƒZdS )é    N)Ú
xform_name)ÚActionDocstring)Úinject_attributeé   )ÚAction)Úcreate_request_parameters)Ú
RawHandlerÚResourceHandlerc                   @   s"   e Zd ZdZddd„Zdd„ ZdS )Ú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
    Nc                 C   s>   || _ |j}|rt|j||||jjd�| _d S t|jƒ| _d S )N)Úsearch_pathÚfactoryÚresource_modelÚservice_contextÚoperation_name)Ú_action_modelÚresourcer	   ÚpathÚrequestÚ	operationÚ_response_handlerr   )ÚselfÚaction_modelr   r   Úresource_response_model© r   ú\/var/www/html/pharmsmart-cdr-gen/venv/lib/python3.10/site-packages/boto3/resources/action.pyÚ__init__.   s   ûzServiceAction.__init__c                 O   sl   t | jjjƒ}t|| jjƒ}| |¡ t d|jj	||¡ t
|jj|ƒ|i |¤Ž}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)r   r   r   r   r   ÚupdateÚloggerÚdebugÚmetaÚservice_nameÚgetattrÚclientr   )r   ÚparentÚargsÚkwargsr   ÚparamsÚresponser   r   r   Ú__call__?   s   

üzServiceAction.__call__)NN©Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r*   r   r   r   r   r
      s    
r
   c                   @   s   e Zd ZdZdd„ ZdS )Ú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                 O   sÎ   d}d}g }t | jjjƒ}| ¡ D ]S}i }	t|ƒD ]\}
}|du r%|jj}|du r-|jj}t	|| jj|	|
d� q|	s= |S |	 
|¡ t d|||	¡ t||ƒ|i |	¤Ž}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(   Úindexr   r   )r   r   r   r   ÚpagesÚ	enumerater!   r"   r$   r   r   r   r    r#   Úappendr   )r   r%   r&   r'   r"   r$   Ú	responsesr   Úpager(   r1   r   r)   r   r   r   r*   r   s8   ü
ôÿzBatchAction.__call__N)r,   r-   r.   r/   r*   r   r   r   r   r0   _   s    r0   c                   @   ó    e Zd ZdZdd„ Zdd„ ZdS )Ú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_``
    c                 C   s   || _ || _d S )N)Ú_waiter_modelÚ_waiter_resource_name)r   Úwaiter_modelÚwaiter_resource_namer   r   r   r   º   s   
zWaiterAction.__init__c           	      O   sj   t | jjƒ}t|| jƒ}| |¡ t d|jj| j	|¡ |jj
}| |¡}|jdi |¤Ž}t d|¡ dS )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.
        r   r   Nr   )r   r9   Úwaiter_namer   r   r   r    r!   r"   r:   r$   Ú
get_waiterÚwait)	r   r%   r&   r'   Úclient_waiter_namer(   r$   Úwaiterr)   r   r   r   r*   ¾   s   
ü
zWaiterAction.__call__Nr+   r   r   r   r   r8   «   s    r8   c                   @   r7   )ÚCustomModeledActionz3A custom, modeled action to inject into a resource.c                 C   s   || _ || _|| _|| _dS )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_namer   rE   Úevent_emitterr   r   r   r   ß   s   
zCustomModeledAction.__init__c                 K   sV   |  d¡d }t| j| ji ƒ}| j| j_t|| j||jdd�| j_	t
|| j| jƒ d S )NÚ.éÿÿÿÿF)Úresource_namerH   r   Úservice_modelÚinclude_signature)Úrsplitr   rC   rD   rE   r,   r   rF   rL   r/   r   )r   Úclass_attributesr   Ú
event_namer'   rK   Úactionr   r   r   Úinjectö   s   

ûzCustomModeledAction.injectN)r,   r-   r.   r/   r   rR   r   r   r   r   rB   Ü   s    rB   )ÚloggingÚbotocorer   Úboto3.docs.docstringr   Úboto3.utilsr   rD   r   r(   r   r)   r   r	   Ú	getLoggerr,   r   r
   r0   r8   rB   r   r   r   r   Ú<module>   s   
CL1