
    
                         d 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
 ddl	mZ dd	l	mZ  ej                  ej                  j                         G d
 dej                                Zy)z`gcloud tasks lease` command.    )absolute_import)division)unicode_literals)GetApiAdapter)base)flags)list_formats)parsersc                   &    e Zd ZdZed        Zd Zy)Leasea  Leases a list of tasks and displays them.

  Each task returned from this command will have its schedule time changed
  based on the lease duration specified. A task that has been returned by
  calling this command will not be returned in a different call before its
  schedule time. After the work associated with a task is finished, the lease
  holder should call `gcloud tasks acknowledge` on the task.
  c                    t         j                  j                  |        t         j                  j                  |        t	        j
                  | dd       t	        j                  |        t	        j                  | d       t	        j                  |        t	        j                  |        t        j                  | d       y )NT)requiredplural_tasksz        The number of seconds for the desired new lease duration for all tasks
        leased, starting from now. The maximum lease duration is 1 week.
        )helptext)is_alpha)r   PAGE_SIZE_FLAGRemoveFromParser
LIMIT_FLAGr   AddQueueResourceFlagAddLocationFlagAddTaskLeaseDurationFlagAddFilterLeasedTasksFlagAddMaxTasksToLeaseFlagr	   AddListTasksFormats)parsers    lib/surface/tasks/lease.pyArgsz
Lease.Args'   s    ((0OO$$V,	v4H	&!	""6 5  
""6*	  ($$Vd;    c                 V   t        | j                               j                  }t        j                  |j
                  |j                        }t        j                  |j                        }t        j                  |      }|j                  ||||j                        j                  S )N)filter_string	max_tasks)r   ReleaseTracktasksr
   
ParseQueuequeuelocationFormatLeaseDurationlease_durationParseTasksLeaseFilterFlagsr   limit)selfargstasks_client	queue_refdurationr    s         r   Runz	Lease.Run7   s     !2!2!45;;L""4::t}}=I**4+>+>?H66t<Mi(,

  449E:r   N)__name__
__module____qualname____doc__staticmethodr   r0    r   r   r   r      s      < <:r   r   N)r4   
__future__r   r   r   googlecloudsdk.api_lib.tasksr   googlecloudsdk.callioper    googlecloudsdk.command_lib.tasksr   r	   r
   ReleaseTracksr"   ALPHAListCommandr   r6   r   r   <module>r>      s\    $ &  ' 6 ( 2 9 4 D%%++, :D  : - :r   