
                             S r SSKJr  SSKJr   " S S\R
                  5      r " S S\5      r " S S	\5      r	 " S
 S\5      r
g)zAPI Library for gcloud tasks.    )
list_pager)
exceptionsc                       \ rS rSrSrSrg)"ModifyingPullAndAppEngineTaskError   zEError for when attempt to create a queue as both pull and App Engine. N)__name__
__module____qualname____firstlineno____doc____static_attributes__r       )lib/googlecloudsdk/api_lib/tasks/tasks.pyr   r      s    Mr   r   c                   >    \ rS rSrSrS rS
S jrSS jrS rS r	S	r
g)	BaseTasks   !API client for Cloud Tasks tasks.c                     Xl         X l        g Nmessagestasks_service)selfr   r   s      r   __init__BaseTasks.__init__   s    M&r   Nc           	          U R                   R                  UR                  5       S9n[        R                  " U R
                  XCUSSS9$ )N)parenttaskspageSize)
batch_sizelimitfieldbatch_size_attribute)r   1CloudtasksProjectsLocationsQueuesTasksListRequestRelativeNamer   YieldFromListr   )r   
parent_refr"   	page_sizerequests        r   ListBaseTasks.List!   sR    GG**, 	H 	.  ##GJ8 8r   c                     U R                   R                  UR                  5       US9nU R                  R	                  U5      $ )N)nameresponseView)r   0CloudtasksProjectsLocationsQueuesTasksGetRequestr&   r   Get)r   task_refresponse_viewr*   s       r   r1   BaseTasks.Get)   sG    FF&&(& 	G 	(  !!'**r   c                     U R                   R                  UR                  5       S9nU R                  R	                  U5      $ N)r.   )r   3CloudtasksProjectsLocationsQueuesTasksDeleteRequestr&   r   Deleter   r2   r*   s      r   r8   BaseTasks.Delete0   sD    II&&( 	J 	*  $$W--r   c                     U R                   R                  UR                  5       S9nU R                  R	                  U5      $ r6   )r   0CloudtasksProjectsLocationsQueuesTasksRunRequestr&   r   Runr9   s      r   r=   BaseTasks.Run6   sD    FF&&( 	G 	*  !!'**r   r   )Nd   r   )r	   r
   r   r   r   r   r+   r1   r8   r=   r   r   r   r   r   r      s    )'8+.+r   r   c                   0    \ rS rSrSr  SS jrSS jrSrg)	Tasks=   r   Nc                 6   U(       a  UR                  5       OSnU R                  R                  XcUS9nU(       a  XWl        U R                  R	                  U R                  R                  US9UR                  5       S9nU R                  R                  U5      $ )8Prepares and sends a Create request for creating a task.N)r.   scheduleTimeappEngineHttpRequesttaskcreateTaskRequestr   )r&   r   TaskhttpRequest3CloudtasksProjectsLocationsQueuesTasksCreateRequestCreateTaskRequestr   Create)	r   r(   r2   schedule_timeapp_engine_http_requesthttp_requestr.   rH   r*   s	            r   rO   Tasks.Create@   s     '/8  "DD==4  6D %II"mm==4=H**, 	J 	.  $$W--r   c                     U R                   R                  UR                  5       US9nU R                  R	                  U5      $ z9Prepares and sends a Create request for buffering a task.)queuetaskIdr   3CloudtasksProjectsLocationsQueuesTasksBufferRequestr&   r   Bufferr   r(   task_idr*   s       r   rZ   Tasks.BufferO   sC    mmOO%%' P G $$W--r   r   NNNN )r	   r
   r   r   r   rO   rZ   r   r   r   r   rA   rA   =   s    )<@8<..r   rA   c                   P    \ rS rSrSrSS jr  SS jrS rS r  SS jr	S	 r
S
rg)
AlphaTasksW   r   c                     U R                   R                  UR                  5       US9nU R                  R	                  U5      $ rU   rX   r[   s       r   rZ   AlphaTasks.BufferZ   sC    mmOO%%' P 9G $$W--r   Nc                 P   U(       a  U(       a  [        S5      eU(       a  UR                  5       OSnU R                  R                  XcUUS9nU R                  R	                  U R                  R                  US9UR                  5       S9nU R                  R                  U5      $ )rD   zFAttempting to send PullMessage and AppEngineHttpRequest simultaneouslyN)r.   rE   pullMessagerF   rG   rI   )r   r&   r   rK   rM   rN   r   rO   )	r   r(   r2   rP   pull_messagerQ   r.   rH   r*   s	            r   rO   AlphaTasks.Createa   s     /.  '/8  "DD==<4  6D 	II"mm==4=H**, 	J 	.  $$W--r   c                     U R                   R                  X#S9nU R                   R                  nU" UUR                  5       S9nU R                  R                  U5      $ )a  Constructs and sends a tasks RenewLease request to the Cloud Tasks API.

Args:
  task_ref: A cloudtasks.projects.locations.queues.tasks resource reference
  schedule_time: string formatted as an ISO 8601 datetime with timezone
  lease_duration: string of an integer followed by 's', (e.g. '10s') for
                  the number of seconds for the new lease
Returns:
  The response of the tasks RenewLease request
)rE   leaseDuration)renewLeaseRequestr.   )r   RenewLeaseRequest7CloudtasksProjectsLocationsQueuesTasksRenewLeaseRequestr&   r   
RenewLease)r   r2   rP   lease_durationrenew_lease_requestrequest_clsr*   s          r   ro   AlphaTasks.RenewLeaser   sd     --99" : B==JJ ,?'4468G((11r   c                     U R                   R                  US9nU R                   R                  nU" UUR                  5       S9nU R                  R                  U5      $ )a  Constructs and sends a tasks CancelLease request to the Cloud Tasks API.

Args:
  task_ref: A cloudtasks.projects.locations.queues.tasks resource reference
  schedule_time: string formatted as an ISO 8601 datetime with timezone

Returns:
  The response of the tasks CancelLease request
rE   )cancelLeaseRequestr.   )r   CancelLeaseRequest8CloudtasksProjectsLocationsQueuesTasksCancelLeaseRequestr&   r   CancelLease)r   r2   rP   cancel_lease_requestrr   r*   s         r   ry   AlphaTasks.CancelLease   sc      ==;;" < $==KK -A'4468G))'22r   c                     U R                   R                  X2US9nU R                   R                  UUR                  5       S9nU R                  R                  U5      $ )a  Constructs and sends a LeaseTasks request to the Cloud Tasks API.

Args:
  queue_ref: A cloudtasks.projects.locations.queues resource reference
  lease_duration: string of an integer followed by 's', (e.g. '10s') for the
                  number of seconds for the new leases
  filter_string: string with an expression to filter which tasks are leased
  max_tasks: the maximum number of tasks to lease

Returns:
  The response of the LeaseTasks request
)filterrk   maxTasks)leaseTasksRequestr   )r   LeaseTasksRequest2CloudtasksProjectsLocationsQueuesTasksLeaseRequestr&   r   Lease)r   	queue_refrp   filter_string	max_taskslease_tasks_requestr*   s          r   r   AlphaTasks.Lease   sk     --99Y : P 	HH1))+ 	I 	-  ##G,,r   c                     U R                   R                  US9nU R                   R                  nU" UUR                  5       S9nU R                  R                  U5      $ )a  Constructs and sends a tasks Acknowledge request to the Cloud Tasks API.

Args:
  task_ref: A cloudtasks.projects.locations.queues.tasks resource reference
  schedule_time: string formatted as an ISO 8601 datetime with timezone

Returns:
  The response of the tasks Acknowledge request
ru   )acknowledgeTaskRequestr.   )r   AcknowledgeTaskRequest8CloudtasksProjectsLocationsQueuesTasksAcknowledgeRequestr&   r   Acknowledge)r   r2   rP   acknowledge_task_requestrr   r*   s         r   r   AlphaTasks.Acknowledge   sd      $}}CC"  D  $==KK 1I'4468G))'22r   r   r_   r^   )NN)r	   r
   r   r   r   rZ   rO   ro   ry   r   r   r   r   r   r   rb   rb   W   s5    ). =A8<."2&3$ <@-,3r   rb   N)r   apitools.base.pyr   googlecloudsdk.corer   InternalErrorr   objectr   rA   rb   r   r   r   <module>r      sM    $ ( *N)A)A N +  +F.I .4f3 f3r   