
                             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 ej                   G d	 d
ej                               Zy)zGImplementation of resume command for resuming Anywhere Cache instances.    )base)progress_callbacks)storage_url)task_executor)task_graph_executor)task_status)resume_anywhere_cache_taskc                   6    e Zd ZdZdddZed        Zd Zd Zy)	Resumez Resume Anywhere Cache instances.a  

      Resume operation could be used to revert the Paused and Disabled state.
      Once a paused/disabled cache is resumed, the cache will be set to
      RUNNING/CREATING state:
        1. RUNNING if the cache is active.
        2. CREATING if the cache is pending creation.
      z

      The following command resume the anywhere cache instance of bucket
      ``my-bucket'' having anywhere_cache_id ``my-cache-id'':

        $ {command} my-bucket/my-cache-id
      )DESCRIPTIONEXAMPLESc                 6    |j                  dt        dd       y )Nid+zIdentifiers for a Anywhere Cache instance. They are combination of bucket_name/anywhere_cache_id. For example : test-bucket/my-cache-id.)typenargshelp)add_argumentstr)clsparsers     5lib/surface/storage/buckets/anywhere_caches/resume.pyArgszResume.Args0   s#    
(  	    c              #      K   t        j                  |t        |j                               |j                  D ]=  }|j	                  t
        j                        \  }}}t        j                  ||       ? y w)N)	r   workload_estimator_callbacklenr   
rpartitionr   CLOUD_URL_DELIMITERr	   ResumeAnywhereCacheTask)selfargstask_status_queueid_strbucket_name_anywhere_cache_ids          r   _get_task_iteratorzResume._get_task_iterator=   sm     223tww< ''*0*;*;

)
)+'k1' '>>
( 	 s   A7A9c           	          t         j                  j                         }| j                  ||      }t	        j
                  |d|t        j                  t        j                  j                  d             | _
        y )NT)increment_typemanifest_path)parallelizabler#   progress_manager_args)r   multiprocessing_contextQueuer(   r   execute_tasksr   ProgressManagerArgsIncrementTypeINTEGER	exit_code)r!   r"   r#   task_iterators       r   Runz
Resume.RunJ   sd    +CCIIK++D2CDM"00+)==&44<<D
	DNr   N)	__name__
__module____qualname____doc__detailed_helpclassmethodr   r(   r6    r   r   r   r      s4    (

-$ 
 
r   r   N)r:   googlecloudsdk.callioper   "googlecloudsdk.command_lib.storager   r   (googlecloudsdk.command_lib.storage.tasksr   r   r   @googlecloudsdk.command_lib.storage.tasks.buckets.anywhere_cachesr	   DefaultUniverseOnlyCommandr   r=   r   r   <module>rD      sE    N ( A : B H @ g :T\\ : :r   