
    &                        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  SSKJr  SSKJr  SrSrSrSrSr\4S jrS rS r\S4S jrS r S r!S r"S!S jr#S r$S"S jr%S r&S r'S r(S  r)g)#z(Methods and constants for global access.    )
exceptions)api_adapterclient)util)job)service)worker_pool)apis)log)
properties)	resourcesv1beta1runv1-appdevexperiencec                 8    [         R                  " [        U 5      $ N)r   GetClientInstanceSERVERLESS_API_NAME)api_versions    0lib/googlecloudsdk/api_lib/run/global_methods.pyGetServerlessClientInstancer   )   s    			 3[	AA    c                 h    [        [        U 5       Vs/ s H  oR                  PM     sn5      $ s  snf )zGet the list of all available regions from control plane.

Args:
  client: (base_api.BaseApiClient), instance of a client to use for the list
    request.

Returns:
  A list of str, which are regions.
)sortedListLocations
locationId)r   ls     r   ListRegionsr!   -   s*     
}V'<='<!'<=	>>=s   /c                    [         R                  " [        R                  R                  R
                  R                  SS95      nU R                  R                  U R                  R                  USS95      R                  $ )zGet the list of all available regions from control plane.

Args:
  client: (base_api.BaseApiClient), instance of a client to use for the list
    request.

Returns:
  A list of location resources.
Trequiredd   )namepageSize)r   ProjectPathr   VALUEScoreprojectGetprojects_locationsListMESSAGES_MODULERunProjectsLocationsListRequest	locations)r   project_resource_relnames     r   r   r   :   sx     "--$$(($(7 
	"	"	'	'<<'# = 
 I	r   Nc           	      \   [         R                  R                  R                  R	                  SS9n[
        R                  R                  USU0SS9nU R                  R                  UR                  5       US9nU R                  R                  U5      nUR                  (       aG  [        R                  " SR!                  SR#                  [%        UR                  5      5      5      5        UR&                   Vs/ s H#  n[(        R*                  " XpR                  5      PM%     sn$ s  snf )	a  Get the global services for a OnePlatform project.

Args:
  client: (base_api.BaseApiClient), instance of a client to use for the list
    request.
  region: (str) optional name of location to search for services in. If not
    passed, this defaults to the global value for all locations.
  field_selector: (str) optional parameter to pass in request.field_selector.

Returns:
  List of googlecloudsdk.api_lib.run import service.Service objects.
Tr#   
projectsIdzrun.projects.locationsparams
collection)parentfieldSelectorTThe following Cloud Run regions did not respond: {}. List results may be incomplete., )r   r)   r*   r+   r,   r   REGISTRYParser/   'RunProjectsLocationsServicesListRequestRelativeNameprojects_locations_servicesr.   unreachabler   warningformatjoinr   itemsr	   Service)r   regionfield_selectorr+   r1   requestresponseitems           r   ListServicesrL   N   s    ""**...='  &&G$) ' )
 ""JJ##%^ K ' //44W=( KK	**0&IIfX1123+
 AI
@Ngood223
  
s   <*D)c                     [        U 5      $ r   )rL   r   s    r   ListWorkersrN   u   s    	f	r   c           	         U R                   R                  UR                  5       S9nU R                  R	                  U5      nUR
                  (       aG  [        R                  " SR                  SR                  [        UR
                  5      5      5      5        UR                   Vs/ s H#  n[        R                  " X@R                   5      PM%     sn$ s  snf )a
  Get the global services for a OnePlatform project.

Args:
  client: (base_api.BaseApiClient), instance of a client to use for the list
    request.
  namespace: namespace/project to list jobs in

Returns:
  List of googlecloudsdk.api_lib.run import job.Job objects.
r8   r:   r;   )r/   RunNamespacesJobsListRequestr?   namespaces_jobsr.   rA   r   rB   rC   rD   r   rE   r   Job)r   	namespacerI   rJ   rK   s        r   ListJobsrU   y   s     ""??##% @ ' ##((1( KK	**0&IIfX1123+
 =ENN	KND#''$..
/N	KK	K   )*Cc           	         U R                   R                  UR                  5       S9nU R                  R	                  U5      nUR
                  (       aG  [        R                  " SR                  SR                  [        UR
                  5      5      5      5        UR                   Vs/ s H#  n[        R                  " X@R                   5      PM%     sn$ s  snf )a!  Get the global list of worker pools for a OnePlatform project.

Args:
  client: (base_api.BaseApiClient), instance of a client to use for the list
    request.
  project: project to list worker pools in

Returns:
  List of googlecloudsdk.api_lib.run import worker_pool.WorkerPool objects.
rP   r:   r;   )r/   #RunNamespacesWorkerpoolsListRequestr?   namespaces_workerpoolsr.   rA   r   rB   rC   rD   r   rE   r
   
WorkerPool)r   r+   rI   rJ   rK   s        r   ListWorkerPoolsr[      s     ""FF!!# G ' **//8( KK	**0&IIfX1123+
 ..
 $ T#9#9: 
  
rV   c                    [         R                  " [        5      nU(       d1  [        R                  R
                  R                  R                  SS9nUR                  X5      nUR                  (       a>  [        R                  " SR                  SR                  UR                  5      5      5        S n[        UR                  US9n[!        U5      nU Vs/ s HY  nUR"                  U;   dD  UR$                  R&                  (       d  M0  UR$                  R&                  R(                  (       a  MW  UPM[     sn$ s  snf )a  Get all clusters with Cloud Run enabled.

Args:
  location: str optional name of location to search for clusters in. Leaving
    this field blank will search in all locations.
  project: str optional name of project to search for clusters in. Leaving
    this field blank will use the project defined by the corresponding
    property.

Returns:
  List of
  googlecloudsdk.generated_clients.apis.container.CONTAINER_API_VERSION
  import container_CONTAINER_API_VERSION_messages.Cluster objects
Tr#   zTThe following cluster locations did not respond: {}. List results may be incomplete.r;   c                 2    U R                   U R                  4$ r   )zoner&   )clusters    r   _SortKeyListClusters.<locals>._SortKey   s    LL',,''r   )key)container_api_adapterNewAPIAdapterCONTAINER_API_VERSIONr   r)   r*   r+   r,   ListClustersmissingZonesr   rB   rC   rD   r   clustersListCloudRunForAnthosClustersr&   addonsConfigcloudRunConfigdisabled)locationr+   container_apirJ   r`   rh   crfa_cluster_namescs           r   rf   rf      s    (556KL-	$$,,00$0?G'':(KK	**0&IIh++,+
( H%%84(4W= 

!
&&&
&nn++  nn33<< 

 
 

s   /D<#D<3D<c                    [         R                  " [        R                  R                  R
                  R                  SS95      nU R                  R                  US9nU R                  R                  U5      nUR                  $ )zGet all verified domains.

Args:
  client: (base_api.BaseApiClient), instance of a client to use for the list
    request.

Returns:
  List of client.MESSAGES_MODULE.AuthorizedDomain objects
Tr#   rP   )r   r(   r   r)   r*   r+   r,   r/   'RunProjectsAuthorizeddomainsListRequestprojects_authorizeddomainsr.   domains)r   r2   rI   rJ   s       r   ListVerifiedDomainsru      s}     "--$$(($(7 ""JJ% K ' ..33G<(			r   c                     U(       d1  [         R                  R                  R                  R	                  SS9n[
        R                  R                  U R                  XR                  S.SS9$ )zReturns a ref for the specified cluster.

Args:
  cluster: container_CONTAINER_API_VERSION_messages.Cluster object
  project: str optional project which overrides the default

Returns:
  A Resource object
Tr#   )	projectIdr^   z!container.projects.zones.clustersr5   )
r   r)   r*   r+   r,   r   r<   r=   r&   r^   )r_   r+   s     r   GetClusterRefrx      s^     
$$,,00$0?G				!	!ll"LL94 
" 
 r   c                 @    / nUR                  SU 5        [        X!5      $ )a]  Returns a list of clusters accounting for multi-tenant projects.

This function can also be used for non-multitenant projects and will
operate on the single passed-in project_id.

Args:
  project_id: The id of the project, which may or may not be multi-tenant
  cluster_location: The zone or region of the cluster

Returns:
  A list of cluster refs
r   )insert_ClustersForProjectIds)
project_idcluster_locationproject_idss      r   MultiTenantClustersForProjectr     s$     +Q
#		>>r   c                 x    / nU  H1  n[        X5      nU H  nUR                  [        XS5      5        M     M3     U$ r   )rf   appendrx   )r~   r}   rJ   r|   rh   r_   s         r   r{   r{     s>    (j,9HoomG89    
/r   c                    SU < S[         < 3n [        R                  " 5       R                  U5      n[        U5      nUR                  5        VVs/ s H  u  pEUS:X  d  M  UPM     snn$ ! [        R
                   a    / s $ f = fs  snnf )zGet all clusters with Cloud Run for Anthos enabled.

Args:
 project: str optional of project to search for clusters in. Leaving this
   field blank will use the project defined by the corresponding property.

Returns:
  List of Cluster string names
z	projects/z/locations/global/features/OK)CLOUDRUN_FEATURE
hub_client	HubClient
GetFeatureapi_exceptions	HttpError_ListAnthosClusterStatesrE   )r+   	crfa_specfcluster_state_objr&   states         r   ri   ri   &  s     ))))4A /q1"3"9"9";	M";;4u}$";	MM	 
	!	! I 
Ns   $A, B"B,BBc                 4    [         R                  R                  U R                  5      R	                  5        VVs0 s H:  u  p[
        R                  " U5      UR                  R                  R                  _M<     nnnU$ s  snnf ! [         a    0 s $ f = fr   )r   r   ToPyDictmembershipStatesrE   hub_utilMembershipShortnamer   coder&   AttributeError)r   msr   s       r   r   r   >  s     ((11!2D2DEKKMMDA 	$$Q'):)::M   
 
 Is#   :B AB=B B BB)NNr   )*__doc__apitools.base.pyr   r    googlecloudsdk.api_lib.containerr   rc   &googlecloudsdk.api_lib.container.fleetr   r   r   r   googlecloudsdk.api_lib.runr   r	   r
   %googlecloudsdk.api_lib.runtime_configgooglecloudsdk.api_lib.utilr   googlecloudsdk.corer   r   r   re   r   SERVERLESS_API_VERSION_ALL_REGIONSr   r   r!   r   rL   rN   rU   r[   rf   ru   rx   r   r{   ri   r    r   r   <module>r      s    / : Q G C * . 2 6 , # * )!   %  -C B
?( !-T #NL8>-`(&?$N0r   