
    I%                         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SKJr   " S S\5      rg)zYAllows you to write surfaces in terms of logical Cloud Run V2 WorkerPools API operations.    )absolute_import)division)print_function)unicode_literals)
exceptions)metric_names)base)stages)deployer)config_changes)metrics)progress_trackerworker_poolc            
           \ rS rSrSrS rS rS rS r\	R                  R                  SSSSSSSSS4
S	 jrS
 rS rS rS rSrg)WorkerPoolsOperations"   zHClient used to communicate with the actual Cloud Run V2 WorkerPools API.c                     Xl         g )N_client)selfclients     @lib/googlecloudsdk/command_lib/run/v2/worker_pools_operations.py__init__WorkerPoolsOperations.__init__%   s    L    c                 f   U R                   R                  nU R                   R                  R                  UR	                  5       S9n [
        R                  " [        R                  5         UR                  U5      sSSS5        $ ! , (       d  f       g= f! [        R                   a     gf = f)zlGet the WorkerPool.

Args:
  worker_pool_ref: Resource, WorkerPool to get.

Returns:
  A WorkerPool object.
nameN)r   workertypesGetWorkerPoolRequestRelativeNamer   RecordDurationr   GET_WORKER_POOLget_worker_poolr   NotFound)r   worker_pool_refworker_poolsget_requests       r   GetWorkerPool#WorkerPoolsOperations.GetWorkerPool(   s     <<&&L,,$$99))+ : K!!,">">?++K8 @?? 0   	$B -B>	B 
BB B B0/B0c                 f   U R                   R                  nU R                   R                  R                  UR	                  5       S9n [
        R                  " [        R                  5         UR                  U5      sSSS5        $ ! , (       d  f       g= f! [        R                   a     gf = f)zyDelete the WorkerPool.

Args:
  worker_pool_ref: Resource, WorkerPool to delete.

Returns:
  A LRO for delete operation.
r   N)r   r    r!   DeleteWorkerPoolRequestr#   r   r$   r   DELETE_WORKER_POOLdelete_worker_poolr   r'   )r   r(   r)   delete_requests       r   DeleteWorkerPool&WorkerPoolsOperations.DeleteWorkerPool;   s     <<&&L\\''??))+ @ N!!,"A"AB..~> CBB r-   c                 0   U R                   R                  nU R                   R                  R                  UR	                  5       S9n[
        R                  " [        R                  5         UR                  U5      sSSS5        $ ! , (       d  f       g= f)zList the WorkerPools in a region.

Args:
  region_ref: Resource, Region to get the list of WorkerPools from.

Returns:
  A list of WorkerPool objects.
parentN)
r   r    r!   ListWorkerPoolsRequestr#   r   r$   r   LIST_WORKER_POOLSlist_worker_pools)r   
region_refr)   list_requests       r   ListWorkerPools%WorkerPoolsOperations.ListWorkerPoolsN   so     <<&&L<<%%<<&&( = L 
		 > >	?++L9 
@	?	?   ,B
BNFc                 8   Uc-  [         R                  " [        R                  " USLU
SLS9SSS9nUbW  [        R
                  " UUUUU
UUUR                  U5	      u  nnnnnUc  gUR                  [        R                  " U	SUS95        Uc  SnO3U(       a  U R                  U5      nOU=(       d    U R                  U5      n[        R                  nUc2  [        R                  " UR                  5       S9n[        R                   n[        R"                  " X5      nU R$                  R&                  nU R$                  R(                  R+                  USUS9n[,        R.                  " U5         UR1                  U5      sSSS5        $ ! , (       d  f       g= f)	a  Stubbed method for worker pool deploy surface.

Update the WorkerPool if it exists, otherwise create it (Upsert).

Args:
  worker_pool_ref: WorkerPool reference containing project, location,
    workerpool IDs.
  config_changes: list, objects that implement Adjust().
  release_track: ReleaseTrack, the release track of a command calling this.
  tracker: StagedProgressTracker, used to track progress.
  prefetch: the worker pool, pre-fetched for ReleaseWorkerPool. `False`
    indicates the caller did not perform a prefetch; `None` indicates a
    nonexistent worker pool.
  build_image: The build image reference to the build.
  build_pack: The build pack reference to the build.
  build_source: The build source reference to the build.
  build_from_source_container_name: The name of the container to be deployed
    from source.
  repo_to_create: Optional
    googlecloudsdk.command_lib.artifacts.docker_util.DockerRepo defining a
    repository to be created.
  already_activated_services: bool. If true, skip activation prompts for
    services
  force_new_revision: bool to force a new revision to be created.

Returns:
  A WorkerPool object.
N)include_buildinclude_create_repoTaborted)interruptableaborted_message)container_namenon_ingress_typeimage_digestr   )r   allow_missingforce_new_revision)r   NoOpStagedProgressTrackerr
   WorkerPoolStagesr   CreateImagelocationsIdappendconfig_changes_modAddDigestToImageChanger+   r   UPDATE_WORKER_POOLworker_pool_objects
WorkerPoolr#   CREATE_WORKER_POOLWithChangesr   r    r!   UpdateWorkerPoolRequestr   r$   update_worker_pool)r   r(   r   release_tracktrackerprefetchbuild_image
build_packbuild_source build_from_source_container_namerepo_to_createalready_activated_servicesrJ   rH   _r   metric_namer)   upsert_requests                      r   ReleaseWorkerPool'WorkerPoolsOperations.ReleaseWorkerPool_   s   V  ::

!
!(4"0"< #g  








$

%
%






 
	

3
3=#' k	 &&7kC 2 2? Ck11K'22++-k !33k$00MK<<&&L\\''??- @ N
 
			,,,^< 
-	,	,s   0F
Fc                    U R                  U5      nUc/  [        R                  " SR                  UR                  5      5      e[
        R                  " X25      nU R                  R                  nU R                  R                  R                  US9n[        R                  " [        R                  5         UR                  U5      sSSS5        $ ! , (       d  f       g= f)z*Update the instance split of a WorkerPool.Nz#WorkerPool [{}] could not be found.r   )r+   r   r'   formatworkerPoolsIdrP   rV   r   r    r!   rW   r   r$   r   rR   rX   )r   r(   r   r   r)   update_requests         r   UpdateInstanceSplit)WorkerPoolsOperations.UpdateInstanceSplit   s     $$_5K
/
6
6++ 
 %00MK<<&&L\\''?? @ N 
		 ? ?	@,,^< 
A	@	@s   7C
C c                 f   U R                   R                  nU R                   R                  R                  UR	                  5       S9n [
        R                  " [        R                  5         UR                  U5      sSSS5        $ ! , (       d  f       g= f! [        R                   a     gf = f)zoGet the Revision.

Args:
  worker_pool_revision_ref: Resource, Revision to get.

Returns:
  A Revision object.
r   N)r   	revisionsr!   GetRevisionRequestr#   r   r$   r   GET_WORKER_POOL_REVISIONget_revisionr   r'   )r   worker_pool_revision_refworker_pool_revisionsr*   s       r   GetRevision!WorkerPoolsOperations.GetRevision   s     !LL22,,$$77%224 8 K!!,"G"GH$11+> IHH r-   c                 f   U R                   R                  nU R                   R                  R                  UR	                  5       S9n [
        R                  " [        R                  5         UR                  U5      sSSS5        $ ! , (       d  f       g= f! [        R                   a     gf = f)z~Delete the Revision.

Args:
  worker_pool_revision_ref: Resource, Revision to delete.

Returns:
  A LRO for delete operation.
r   N)r   rn   r!   DeleteRevisionRequestr#   r   r$   r   DELETE_WORKER_POOL_REVISIONdelete_revisionr   r'   )r   rr   rs   r2   s       r   DeleteRevision$WorkerPoolsOperations.DeleteRevision   s     !LL22\\''==%224 > N!!,"J"JK$44^D LKK r-   c                 0   U R                   R                  nU R                   R                  R                  UR	                  5       S9n[
        R                  " [        R                  5         UR                  U5      sSSS5        $ ! , (       d  f       g= f)zList the Revisions in a region under the given WorkerPool.

Args:
  worker_pool_ref: Resource, WorkerPool to get the list of Revisions from.

Returns:
  A list of Revision objects.
r6   N)
r   rn   r!   ListRevisionsRequestr#   r   r$   r   LIST_WORKER_POOL_REVISIONSlist_revisions)r   r(   rs   r<   s       r   ListRevisions#WorkerPoolsOperations.ListRevisions  sp     !LL22<<%%::++- ; L 
		 G G	H"11,? 
I	H	Hr?   r   )__name__
__module____qualname____firstlineno____doc__r   r+   r3   r=   r	   ReleaseTrackALPHAre   rk   rt   rz   r   __static_attributes__ r   r   r   r   "   sa    P&&:* %%++'+!&k=Z=*&&@r   r   N)r   
__future__r   r   r   r   google.api_corer   googlecloudsdk.api_lib.runr   googlecloudsdk.callioper	   googlecloudsdk.command_lib.runr
   ,googlecloudsdk.command_lib.run.sourcedeploysr   !googlecloudsdk.command_lib.run.v2r   rP   googlecloudsdk.corer   googlecloudsdk.core.consoler   ;googlecloudsdk.generated_clients.gapic_clients.run_v2.typesr   rS   objectr   r   r   r   <module>r      sD    ` '  % ' & 3 ( 1 A R ' 8 jt@F t@r   