
    
                     z    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 d
 Zd Zd Zy)z-Utils for common agent pool API interactions.    )absolute_import)division)unicode_literals)apis)	name_util)
properties)progress_tracker)retryc                     ~t        j                  dd      }| j                  |j                  j                  j
                  k(  S )aQ  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                     t        j                  dd      }t        j                  dd      }t        j                  |       }|j
                  j                  |j                  |            S )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                    t        j                  d      5  t        j                         j	                  t
        | gt        t        j                  j                  j                  j                               }ddd       |S # 1 sw Y   S xY w)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.   ;   sp    ''8:]]_**V5&&CCJJL + F: 
-: 
-s   A!B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   