
    
                     z    S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  SSKJr  SS	KJr  S
 rS rS rg)z-Utils for common agent pool API interactions.    )absolute_import)division)unicode_literals)apis)	name_util)
properties)progress_tracker)retryc                     A[         R                  " SS5      nU R                  UR                  R                  R
                  :H  $ )a;  Takes AgentPool Apitools object and returns if it's state is "creating".

When an AgentPool create request is sent to the backend, it takes a few
moments for the pool's state to go from CREATING to CREATED. This check
is useful to see if we can start acting like the pool exists yet.

Args:
  result (messages.AgentPool): Object representing current state of AgentPool
    on the backend.
  retryer_state (retry.RetryerState): Unused. Contains info about trials and
    time passed.

Returns:
  Boolean representing if AgentPool's state is "CREATING." False = "CREATED".
transferv1)r   GetMessagesModulestate	AgentPoolStateValueValuesEnumCREATING)resultretryer_statemessagess      7lib/googlecloudsdk/api_lib/transfer/agent_pools_util.py_is_agent_pool_still_creatingr      s:      ##J5(	++@@II	II    c                     [         R                  " SS5      n[         R                  " SS5      n[        R                  " U 5      nUR
                  R                  UR                  US95      $ )z7Returns agent pool details from API as Apitools object.r   r   )name)r   GetClientInstancer   r   add_agent_pool_prefixprojects_agentPoolsGet+StoragetransferProjectsAgentPoolsGetRequest)r   clientr   formatted_agent_pool_names       r   api_getr"   1   sf    !!*d3&##J5('==dC		#	#	'	'::( ; *
+ +r   c                     [         R                  " SS9   [        R                  " 5       R	                  [
        U /[        [        R                  R                  R                  R                  5       S9nSSS5        U$ ! , (       d  f       W$ = f)z9Blocks until agent pool is created. Useful for scripting.z(Waiting for backend to create agent pool)message)argsshould_retry_ifsleep_msN)r	   ProgressTrackerr
   RetryerRetryOnResultr"   r   r   VALUESr   no_async_polling_interval_msGetInt)r   r   s     r   block_until_createdr.   ;   su    ''8:]]_**V5&&CCJJL + F: 
-: : 
-s   AA>>
BN)__doc__
__future__r   r   r   googlecloudsdk.api_lib.utilr   #googlecloudsdk.command_lib.transferr   googlecloudsdk.corer   googlecloudsdk.core.consoler	   googlecloudsdk.core.utilr
   r   r"   r.    r   r   <module>r7      s2    4 &  ' , 9 * 8 *J*+r   