
    L                     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 jobs API interactions.    )absolute_import)division)unicode_literals)apis)	name_util)
properties)progress_tracker)retryc                     ~| j                    S )zGTakes TransferJob Apitools object and returns if it lacks an operation.)latestOperationName)resultretryer_states     0lib/googlecloudsdk/api_lib/transfer/jobs_util.py_has_not_created_operationr      s    ''	''    c                 <   t        j                  dd      }t        j                  dd      }t        j                  |       }|j
                  j                  |j                  |t        j                  j                  j                  j                                     S )z0Returns job details from API as Apitools object.transferv1)jobName	projectId)r   GetClientInstanceGetMessagesModuler   add_job_prefixtransferJobsGet%StoragetransferTransferJobsGetRequestr   VALUEScoreproject)nameclientmessagesformatted_job_names       r   api_getr$   "   s    !!*d3&##J5( //5				 	 44$%%**22668 5 :
; ;r   c                 .   t        j                  d      5  t        j                         j	                  t
        | gt        t        j                  j                  j                  j                               j                  cddd       S # 1 sw Y   yxY w)zABlocks until job creates an operation and returns operation name.z!Polling for latest operation name)message)argsshould_retry_ifsleep_msN)r	   ProgressTrackerr
   RetryerRetryOnResultr$   r   r   r   r   no_async_polling_interval_msGetIntr   )r    s    r   block_until_operation_createdr/   .   sm    ''13==?((V2&&CCJJL )  3 3 3s   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>r8      s1    . &  ' , 9 * 8 *(	;
r   