
                         6   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  \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\R0                  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S\4S jr g)z!Util for Design Center Cloud SDK.    )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"   .   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+   8   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   r-   r   r   r   r   )r    	space_refs     r   GetSpaceRefr/   @   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>._GetUriM   sI    //-0K!33*+ 4 F ??r   r*   )r$   r   r9   s   `` r   MakeGetUriFuncr;   J   s     
.r   c                   8   ^  \ rS rSrSrU 4S jrS rS rSrU =r	$ )EmbeddedResultOperationPollerW   zAPoller for operations with result embedded in operation.response.c                 .   > [         [        U ]  S U5        g )N)superr=   __init__)selfoperation_service	__class__s     r   rA   &EmbeddedResultOperationPoller.__init__Z   s    	
'7>OPr   c                 8    U R                   R                  U5      $ )
Overrides.)rC   GetRequestType)rB   request_names     r   rH   ,EmbeddedResultOperationPoller.GetRequestType]   s    !!00>>r   c                 f    UR                   (       a   [        R                  " UR                   5      $ g)rG   N)responseapitools_encodingMessageToPyValue)rB   	operations     r   	GetResult'EmbeddedResultOperationPoller.GetResulta   s%    //	0B0BCCr   r*   )
__name__
__module____qualname____firstlineno____doc__rA   rH   rP   __static_attributes____classcell__)rD   s   @r   r=   r=   W   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.r2     polleroperation_refrY   max_wait_ms)r	   r%   r4   r5   OPERATIONS_COLLECTIONr   r   r   WaitForCloudOperationPollerprojects_locations_operations)clientrO   rY   rZ   r   r_   s         r   WaitForOperationrf   h   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_overriderl   s     r   GetGoogleCatalogProjectIdrn      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.r2   r\   r]   )r	   r%   r4   r5   ra   r   r   r=   rd   r   rb   )re   rO   rY   rZ   r   r_   r^   s          r   "WaitForOperationWithEmbeddedResultrp      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.r5   z+Each file in IaC module must have a "name".content )r5   rs   )rr   )
isinstancedict
ValueErrormessagesIaCFiler   append	IaCModule)re   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   c                      [         R                  R                  R                  R	                  5       n U (       a  SU ;   a  gU (       a  SU ;   a  gg)z0Returns the P4SA host based on the API endpoint.stagingz3gcp-sa-staging-designcenter.iam.gserviceaccount.comautopushz4gcp-sa-autopush-designcenter.iam.gserviceaccount.comz+gcp-sa-designcenter.iam.gserviceaccount.com)r   r&   rj   r   rk   )endpoints    r   GetP4saHostr      s?    55BBFFH()x'@J(*A8r   N)!rV   apitools.base.pyr   rM   googlecloudsdk.api_lib.utilr   r   googlecloudsdk.callioper   r   googlecloudsdk.corer   r	   ReleaseTrackALPHAGAr   ra   r   r   r"   r+   r/   r;   rc   r=   strintrf   rn   rp   r   r   r*   r   r   <module>r      s)   ( ; , . ( . * ) 	Y$
 E  %)$5$5$;$; =
 %)$5$5$;$; =
 .2->->-D-D 
F$?$? , ##))  	23 6 ##))  	46$9C 9r   