
                            S r SSKJr  SSKJr  SSKJr  SSKrSSKJr  SSKJ	r	  SSK
Jr  SS	KJr  S
rSr\	R                   R"                  \\	R                   R$                  \\	R                   R&                  \0rSrSrSr\	R                   R"                  4S jr\	R                   R"                  S4S jrS rS rS rS rS rg)z$Utilities for the cloudbuild v2 API.    )absolute_import)division)unicode_literalsN)apis)base)	resources)resource_property
cloudbuildv2z)projects/.*/locations/.*/memberships/(.*)z/projects/.*/locations/.*/workerPoolSecondGen/.*z1projects/.*/locations/.*/workerPoolSecondGen/(.*)c                 F    [         R                  " [        [        U    5      $ )zReturns the messages module for Cloud Build.

Args:
  release_track: The desired value of the enum
    googlecloudsdk.calliope.base.ReleaseTrack.

Returns:
  Module containing the definitions of messages for Cloud Build.
)r   GetMessagesModule	_API_NAMERELEASE_TRACK_TO_API_VERSION)release_tracks    7lib/googlecloudsdk/api_lib/cloudbuild/v2/client_util.pyr   r   .   s#     
			 <] K
M M    Tc                 N    [         R                  " [        [        U    U(       + S9$ )a   Returns an instance of the Cloud Build client.

Args:
  release_track: The desired value of the enum
    googlecloudsdk.calliope.base.ReleaseTrack.
  use_http: bool, True to create an http object for this client.

Returns:
  base_api.BaseApiClient, An instance of the Cloud Build client.
)no_http)r   GetClientInstancer   r   )r   use_https     r   r   r   <   s'     
		"=1|
 r   c           	         [        5       n[        5       nUS:X  a\  [        R                  R	                  USSU UUS.S9nUR
                  R                  UR                  UR                  5       S95      nU$ US:X  a\  [        R                  R	                  USSU UUS	.S9nUR                  R                  UR                  UR                  5       S95      n	U	$ g
)zGet a PipelineRun/TaskRun.pipelinerunz*cloudbuild.projects.locations.pipelineRunsr   )
projectsIdlocationsIdpipelineRunsId)
collectionapi_versionparamsnametaskrunz&cloudbuild.projects.locations.taskRuns)r   r   
taskRunsIdN)r   r   r   REGISTRYParseprojects_locations_pipelineRunsGet1CloudbuildProjectsLocationsPipelineRunsGetRequestRelativeNameprojects_locations_taskRuns-CloudbuildProjectsLocationsTaskRunsGetRequest)
projectregionrun_idrun_typeclientmessagespipeline_run_resourcepipeline_runtask_run_resourcetask_runs
             r   GetRunr5   M   s   & (%..44?!!$
	 5  99==BB&335 	C 	89L 9!**00;!! 
	 1  1155>>"//1 	? 	45H O r   c                     [         R                  " [        U 5      nU(       a  UR                  S5      $ [	        S[        < S35      e)a>  Get the name part of a cluster membership's full resource name.

For example, "projects/123/locations/global/memberships/cluster2" returns
"cluster2".

Args:
  resource_name: A cluster's full resource name.

Raises:
  ValueError: If the full resource name was not well-formatted.

Returns:
  The cluster's short name.
   z1The cluster membership resource name must match "")researchCLUSTER_NAME_SELECTORgroup
ValueErrorresource_namematchs     r   ClusterShortNamerA   o   s;     )))=
9%
;;q>), 	- -r   c                     [        5       n[        5       nUR                  R                  UR	                  SR                  U 5      S95      $ )zGet the list of supported Cloud Build locations.

Args:
  project: The project to search.

Returns:
  A CloudbuildProjectsLocationsListRequest object.
zprojects/{}r   )r   r   projects_locationsList&CloudbuildProjectsLocationsListRequestformat)r+   r/   r0   s      r   ListLocationsrG      sN     & (		"	"	'	'55##G, 6 
 r   c                     [         R                  " [        U 5      nU(       a  UR                  S5      $ [	        S[
        < S35      e)aH  Get the name part of a worker pool second gen's full resource name.

E.g. "projects/abc/locations/def/workerPoolSecondGen/ghi" returns "ghi".

Args:
  resource_name: A worker pool second gen's full resource name.

Raises:
  ValueError: If the full resource name was not well-formatted.

Returns:
  The worker pool's short name.
r7   z5The worker pool second gen resource name must match "r8   )r9   r:   #WORKERPOOL_SECOND_GEN_NAME_SELECTORr<   r=   "WORKERPOOL_SECOND_GEN_NAME_MATCHERr>   s     r   WorkerPoolSecondGenShortNamerK      s;     ))7
G%
;;q>69 	: :r   c                    / nU R                  5        H  nU R                  UR                  5      nUR                  (       a	  U(       d  M8  Uc  M=  [        R
                  " UR                  5      n[        US5      (       a4  [        U5       H#  nUR                  SR                  XE5      5        M%     M  UR                  U5        M     U$ )a  Produce field paths from a message object.

The result is used to create a FieldMask proto message that contains all field
paths presented in the object.
https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto

Args:
  msg: A user defined message object that extends the messages.Message class.
  https://github.com/google/apitools/blob/master/apitools/base/protorpclite/messages.py

Returns:
  The list of field paths.

all_fieldsz{}.{})
rM   get_assigned_valuer    repeatedr	   ConvertToSnakeCasehasattrMessageToFieldPathsappendrF   )msgfieldsfieldvr    fs         r   rR   rR      s     &~~euzz*A~~a}11%**=d	L	!	!$Q'A
--t/
0 ( 	d   
-r   )__doc__
__future__r   r   r   r9   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   googlecloudsdk.corer   googlecloudsdk.core.resourcer	   r   GA_API_VERSIONReleaseTrackGABETAALPHAr   r;   rJ   rI   r   r   r5   rA   rG   rK   rR    r   r   <module>re      s    + &  ' 	 , ( ) :	 	.N^   E 6 # 9 $
 %)$5$5$8$8 M %)$5$5$8$84 "D-,&:*r   