
                         L   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S
KJr  SSKJr  \R"                  R$                  S\R"                  R&                  S0rSr\R"                  R$                  4S jr\R"                  R$                  4S jrS rS rS r\R"                  R$                  4S jr " S S\
R8                  5      r\R"                  R$                  4S\S\4S jjr S\4S jr!\R"                  R$                  4S\S\4S jjr"S r#g)z!Util for Design Center Cloud SDK.    )absolute_import)division)unicode_literals)encoding)apis)waiter)base)
exceptions)
properties)	resourcesv1alphav1z*designcenter.projects.locations.operationsc                 Z    [         R                  U 5      n[        R                  " SU5      $ Ndesigncenter)VERSION_MAPgetr   GetMessagesModulerelease_trackapi_versions     1lib/googlecloudsdk/api_lib/design_center/utils.pyr   r   '   #    .+				<<    c                 Z    [         R                  U 5      n[        R                  " SU5      $ r   )r   r   r   GetClientInstancer   s     r   r   r   ,   r   r   c                     U R                   R                  R                  5       nUR                  5       (       d  [        R
                  " SS5      eU$ )zReturns a location reference.locationzlocation id must be non-empty.)CONCEPTSr   ParseNamer
   InvalidArgumentException)argslocation_refs     r   GetLocationRefr%   1   sJ    ''--/,					

-
-4  
r   c                      [         R                  R                  [        R                  R
                  R                  R                  5       SS9$ )zReturns a project reference.zdesigncenter.projects)
collection)r   REGISTRYr    r   VALUEScoreproject	GetOrFail r   r   GetProjectRefr.   ;   sA    				!	!$$..0( 
" 
 r   c                     U R                   R                  R                  5       nUR                  5       (       d  [        R
                  " SS5      eU$ )zReturns a space reference.spacezspace id must be non-empty.)r   r0   r    r!   r
   r"   )r#   	space_refs     r   GetSpaceRefr2   C   sH    mm!!''))			

-
-.  
r   c                    ^ ^ U U4S jnU$ )z5Returns a function which turns a resource into a uri.c                    > [         R                  T5      n[        R                  " 5       R	                  U R
                  TUS9nUR                  5       $ )Nr'   r   )r   r   r   RegistryParseRelativeNamenameSelfLink)resourcer   resultr'   r   s      r   _GetUriMakeGetUriFunc.<locals>._GetUriP   sI    //-0K!33*+ 4 F ??r   r-   )r'   r   r<   s   `` r   MakeGetUriFuncr>   M   s     
.r   c                   8   ^  \ rS rSrSrU 4S jrS rS rSrU =r	$ )EmbeddedResultOperationPollerZ   zAPoller for operations with result embedded in operation.response.c                 .   > [         [        U ]  S U5        g )N)superr@   __init__)selfoperation_service	__class__s     r   rD   &EmbeddedResultOperationPoller.__init__]   s    	
'7>OPr   c                 8    U R                   R                  U5      $ )
Overrides.)rF   GetRequestType)rE   request_names     r   rK   ,EmbeddedResultOperationPoller.GetRequestType`   s    !!00>>r   c                 f    UR                   (       a   [        R                  " UR                   5      $ g)rJ   N)responseapitools_encodingMessageToPyValue)rE   	operations     r   	GetResult'EmbeddedResultOperationPoller.GetResultd   s%    //	0B0BCCr   r-   )
__name__
__module____qualname____firstlineno____doc__rD   rK   rS   __static_attributes____classcell__)rG   s   @r   r@   r@   Z   s    IQ? r   r@   messagemax_wait_secc                    [         R                  R                  UR                  [        [
        R                  U5      S9n[        R                  " [        R                  " U R                  U R                  5      UUUS-  S9$ )z*Waits for the given operation to complete.r5     polleroperation_refr\   max_wait_ms)r   r(   r7   r8   OPERATIONS_COLLECTIONr   r   r   WaitForCloudOperationPollerprojects_locations_operations)clientrR   r\   r]   r   rb   s         r   WaitForOperationri   k   sx     $$66nn&//-0 7 - 
((

.
.

.
. "%
 r   returnc                     [         R                  R                  R                  R	                  5       n [         R                  R
                  R                  R	                  5       nU (       a
  SU 3U ;   a  gU (       a
  SU 3U ;   a  gg)z@Returns the project ID for Google Catalog based on API endpoint.zautopush-designcenter.sandbox.zgcpdesigncenter-autopushzstaging-designcenter.sandbox.zgcpdesigncenter-staginggcpdesigncenter)r   r)   api_endpoint_overridesr   Getr*   universe_domain)endpoint_overridero   s     r   GetGoogleCatalogProjectIdrq      s     ..;;??A  %%**::>>@/*?*;
<	 &)/):
;	 %	r   c                     [         R                  R                  UR                  [        [
        R                  U5      S9n[        U R                  5      n[        R                  " UUUUS-  S9$ )z[Waits for an operation to complete, where the result is embedded in the operation response.r5   r_   r`   )r   r(   r7   r8   rd   r   r   r@   rg   r   re   )rh   rR   r\   r]   r   rb   ra   s          r   "WaitForOperationWithEmbeddedResultrs      sn     $$66nn&//-0 7 - )**& 
!%	
 r   c                 t   [        U[        5      (       a  SU;  a  [        S5      e/ nUS    Ho  n[        U[        5      (       a  SU;  a  [        S5      eU R                  R	                  US   UR                  S5      =(       d    SS9nUR                  U5        Mq     U R                  R                  US9$ )	z+Parses dict data into an IaCModule message.fileszDInvalid IaC module format. Expected a dictionary with a "files" key.r8   z+Each file in IaC module must have a "name".content )r8   rv   )ru   )
isinstancedict
ValueErrormessagesIaCFiler   append	IaCModule)rh   iac_module_data	iac_files	file_dataiac_files        r   ParseIaCModuleDatar      s    ot,,0N]^^I$W-		4((F),CFGG(( --	*0b ) h x  . ??$$9$55r   N)$rY   
__future__r   r   r   apitools.base.pyr   rP   googlecloudsdk.api_lib.utilr   r   googlecloudsdk.callioper	   r
   googlecloudsdk.corer   r   ReleaseTrackALPHAGAr   rd   r   r   r%   r.   r2   r>   rf   r@   strintri   rq   rs   r   r-   r   r   <module>r      s$   ( &  ' : , . ( . * ) 	Y$
 E  %)$5$5$;$; =
 %)$5$5$;$; =
 .2->->-D-D 
F$?$? , ##))  	23 6 ##))  	46r   