
    l                        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d
lmZ e	j                  j                  diZdZe	j                  j                  fdZe	j                  j                  fdZd Zd Zd Ze	j                  j                  fdZe	j                  j                  fdedefdZy)z!Util for Design Center Cloud SDK.    )absolute_import)division)unicode_literals)apis)waiter)base)
exceptions)
properties)	resourcesv1alphaz*designcenter.projects.locations.operationsc                 X    t         j                  |       }t        j                  d|      S Ndesigncenter)VERSION_MAPgetr   GetMessagesModulerelease_trackapi_versions     1lib/googlecloudsdk/api_lib/design_center/utils.pyr   r   (   #    .+				<<    c                 X    t         j                  |       }t        j                  d|      S r   )r   r   r   GetClientInstancer   s     r   r   r   -   r   r   c                     | j                   j                  j                         }|j                         st	        j
                  dd      |S )zReturns a location reference.locationzlocation id must be non-empty.)CONCEPTSr   ParseNamer	   InvalidArgumentException)argslocation_refs     r   GetLocationRefr#   2   sG    ''--/,				

-
-4  
r   c                      t         j                  j                  t        j                  j
                  j                  j                         d      S )zReturns a project reference.zdesigncenter.projects)
collection)r   REGISTRYr   r
   VALUEScoreproject	GetOrFail r   r   GetProjectRefr,   <   sA    				!	!$$..0( 
" 
 r   c                     | j                   j                  j                         }|j                         st	        j
                  dd      |S )zReturns a space reference.spacezspace id must be non-empty.)r   r.   r   r   r	   r    )r!   	space_refs     r   GetSpaceRefr0   D   sE    mm!!''))		

-
-.  
r   c                       fd}|S )z5Returns a function which turns a resource into a uri.c                     t         j                        }t        j                         j	                  | j
                  |      }|j                         S )Nr%   r   )r   r   r   RegistryParseRelativeNamenameSelfLink)resourcer   resultr%   r   s      r   _GetUrizMakeGetUriFunc.<locals>._GetUriQ   sI    //-0K!33*+ 4 F ??r   r+   )r%   r   r:   s   `` r   MakeGetUriFuncr;   N   s     
.r   messagemax_wait_secc                    t         j                  j                  |j                  t        t
        j                  |            }t        j                  t        j                  | j                  | j                        |||dz        S )z*Waits for the given operation to complete.r3   i  )polleroperation_refr<   max_wait_ms)r   r&   r5   r6   OPERATIONS_COLLECTIONr   r   r   WaitForCloudOperationPollerprojects_locations_operations)client	operationr<   r=   r   r@   s         r   WaitForOperationrH   [   sx     $$66nn&//-0 7 - 
((

.
.

.
. "%
 r   N)__doc__
__future__r   r   r   googlecloudsdk.api_lib.utilr   r   googlecloudsdk.callioper   r	   googlecloudsdk.corer
   r   ReleaseTrackALPHAr   rB   r   r   r#   r,   r0   r;   strintrH   r+   r   r   <module>rR      s    ( &  ' , . ( . * ) 	Y E  %)$5$5$;$; =
 %)$5$5$;$; =
 .2->->-D-D 
$ ##))  	r   