
                       X   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rSSKrSSK	r	SSK
JrJrJrJrJr  SSKrSSKrSSKrSSKrSSKrSS	KJr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K'J(r(  SSK'J)r)  SSK*J+r+  SSK,r, " S S\,RZ                  " \R\                  \/5      5      r0 " S S\05      r1 " S S\05      r2\Rf                  " SS 9 " S! S"\25      5       r4S# r5S$ r6\Rf                  " SS 9 " S% S&\05      5       r7 " S' S(\25      r8\Rf                  " SS 9 " S) S*\15      5       r9\Rf                  " SS 9 " S+ S,\15      5       r:\Rf                  " SS 9 " S- S.\15      5       r;\Rf                  " SS/S09 " S1 S2\75      5       r<\Rf                  " SS 9 " S3 S4\15      5       r=\Rf                  " SS 9 " S5 S6\15      5       r>\Rf                  " SS 9 " S7 S8\25      5       r?\Rf                  " SS 9 " S9 S:\25      5       r@\Rf                  " SS 9 " S; S<\25      5       rA\Rf                  " SS 9 " S= S>\25      5       rB\Rf                  " SS 9 " S? S@\A5      5       rC\Rf                  " SS 9 " SA SB\15      5       rD\Rf                  " SS 9 " SC SD\15      5       rE\Rf                  " SS 9 " SE SF\15      5       rF\Rf                  " SS 9 " SG SH\15      5       rG\Rf                  " SS 9 " SI SJ\05      5       rH\Rf                  " SS 9 " SK SL\25      5       rI\Rf                  " SS 9 " SM SN\25      5       rJ " SO SP\25      rK\Rf                  " S/SSQ9 " SR SS\45      5       rL      SST jrM        SSU jrNSV rO\Rf                  " SS 9 " SW SX\45      5       rP\Rf                  " SS 9 " SY SZ\25      5       rQ " S[ S\\25      rR\Rf                  " SS 9 " S] S^\45      5       rS      SS_ jrT\Rf                  " SS 9 " S` Sa\45      5       rU\Rf                  " SS 9 " Sb Sc\45      5       rV\Rf                  " SS 9 " Sd Se\45      5       rW\Rf                  " SS 9 " Sf Sg\25      5       rX\Rf                  " SS 9 " Sh Si\25      5       rY\Rf                  " SS 9 " Sj Sk\25      5       rZ\Rf                  " SS 9 " Sl Sm\25      5       r[Snr\\Rf                  " SS 9 " So Sp\25      5       r]Sq r^Sr r_Ss r`\Rf                  " SS 9 " St Su\25      5       ra " Sv Sw\25      rb " Sx Sy\15      rc\Rf                  " SS 9 " Sz S{\15      5       rd\Rf                  " SS 9 " S| S}\15      5       re\Rf                  " S/SSQ9 " S~ S\45      5       rf\Rf                  " S/SSQ9 " S S\45      5       rgSrhSri\Rf                  " SS 9 " S S\45      5       rj\Rf                  " SS 9 " S S\25      5       rk\Rf                  " SS 9 " S S\25      5       rl\Rf                  " SS 9 " S S\25      5       rm\Rf                  " SS 9 " S S\25      5       rn\Rf                  " SS 9 " S S\25      5       ro\Rf                  " SS 9 " S S\25      5       rp\Rf                  " SS 9 " S S\25      5       rq\Rf                  " SS 9 " S S\15      5       rr\Rf                  " SS 9 " S S\15      5       rs\Rf                  " SS 9 " S S\25      5       rt\Rf                  " SS 9 " S S\25      5       ru\Rf                  " SS 9 " S S\25      5       rv\Rf                  " SS 9 " S S\25      5       rw\Rf                  " SS 9 " S S\25      5       rx\Rf                  " SS 9 " S S\25      5       ry\Rf                  " SS 9 " S S\25      5       rz\Rf                  " SS 9 " S S\25      5       r{\Rf                  " SS 9 " S S\25      5       r|\Rf                  " SS 9 " S S\25      5       r}\Rf                  " SS 9 " S S\45      5       r~\Rf                  " SS 9 " S S\45      5       r\Rf                  " SS 9 " S S\25      5       r\Rf                  " SS 9 " S S\25      5       r\Rf                  " SS 9 " S S\25      5       rg)z:Class for representing various changes to a Configuration.    )absolute_import)annotations)division)print_function)unicode_literalsN)
Collection	ContainerIterableMappingMutableMapping)AnyClassVar)container_resource)job)
k8s_object)revision)service)worker_pool)base)
exceptions)name_generator)	platforms)secrets_mapping)volumes)labels_util)repeated)run_v1_messagesc                  j    \ rS rSrSr\\R                  S 5       5       r\R                  S 5       r	Sr
g)ConfigChanger4   z5An abstract class representing configuration changes.c                    g)z:Returns True if any template-level changes should be made.N selfs    4lib/googlecloudsdk/command_lib/run/config_changes.pyadjusts_templateConfigChanger.adjusts_template7           c                    g)zAdjust the given Service configuration.

Args:
  resource: the k8s_object to adjust.

Returns:
  A k8s_object that reflects applying the requested update.
  May be resource after a mutation or a different object.
Nr"   r$   resources     r%   AdjustConfigChanger.Adjust<   r(   r)   r"   N)__name__
__module____qualname____firstlineno____doc__propertyabcabstractmethodr&   r-   __static_attributes__r"   r)   r%   r   r   4   sA    =E  E 	 	r)   r   c                  (    \ rS rSrSr\S 5       rSrg)NonTemplateConfigChangerI   zBAn abstract class representing non-template configuration changes.c                    g)NFr"   r#   s    r%   r&   )NonTemplateConfigChanger.adjusts_templateL   s    r)   r"   Nr/   r0   r1   r2   r3   r4   r&   r7   r"   r)   r%   r9   r9   I   s    J r)   r9   c                  (    \ rS rSrSr\S 5       rSrg)TemplateConfigChangerQ   z>An abstract class representing template configuration changes.c                    g)NTr"   r#   s    r%   r&   &TemplateConfigChanger.adjusts_templateT   s    r)   r"   Nr=   r"   r)   r%   r?   r?   Q   s    F r)   r?   T)frozenc                  b    \ rS rSr% SrSrS\S'   \R                      S	S j5       r	S
S jr
Srg)ContainerConfigChangerY   zAn abstract class representing container configuration changes.

Attributes:
  container_name: Name of the container to modify. If None the primary
    container is modified.
N
str | Nonecontainer_namec                    g)zMutate the given container.

This method is called by this class's Adjust method and should apply the
desired changes directly to container.

Args:
  container: the container to adjust.
  messages_mod: Run v1 messages module.
Nr"   r$   	containermessages_mods      r%   AdjustContainer&ContainerConfigChanger.AdjustContainerd   r(   r)   c                    U R                   b$  UR                  R                  U R                      nOUR                  R                  nU R	                  X!R                  5       5        U$ )a  Returns a modified resource.

Adjusts resource by applying changes to the container specified by
self.container_name if present or the primary container otherwise. Calls
AdjustContainer to apply changes to the selected container.

Args:
  resource: The resoure to modify.
)rH   template
containersrK   rM   MessagesModuler$   r,   rK   s      r%   r-   ContainerConfigChanger.Adjustt   sY     &##..t/B/BCi##--i$;$;$=>Or)   r"   )rK   zcontainer_resource.ContainerrL   types.ModuleType)r,   z$container_resource.ContainerResource)r/   r0   r1   r2   r3   rH   __annotations__r5   r6   rM   r-   r7   r"   r)   r%   rE   rE   Y   sB      $.*#- % r)   rE   c                :    U H  nUR                  U 5      n M     U $ )zApply ConfigChangers to resource.

It's undefined whether the input resource is modified.

Args:
  resource: KubernetesObject, probably a Service.
  changes: List of ConfigChangers.

Returns:
  Changed resource.
)r-   )r,   changesconfig_changes      r%   WithChangesrZ      s#     m##H-H 	/r)   c                V    [        U  Vs/ s H  oR                  PM     sn5      $ s  snf )z3Returns True if there's any template-level changes.)anyr&   )rX   cs     r%   AdjustsTemplater^      s#    	'2'Q  '2	332s   &c                  x    \ rS rSr% Sr\" \R                  /5      rS\	S'   S\	S'   Sr
S\	S	'   \S
 5       rS rSrg)LabelChanges   zRepresents the user intent to modify metadata labels.

Attributes:
  diff: Label diff to apply.
  copy_to_revision: A boolean indicating that label changes should be copied
    to the resource's template.
zClassVar[frozenset[str]]_LABELS_NOT_ALLOWED_IN_REVISIONzlabels_util.DiffdiffTboolcopy_to_revisionc                    U R                   $ N)re   r#   s    r%   r&   LabelChanges.adjusts_template   s       r)   c                   U R                   R                  [        R                  " UR	                  5       5      R
                  UR                  R                  5      nUR                  5       nU(       a  X1R                  l        [        US5      (       a  UR                  OUR                  nU R                  (       a  [        US5      (       a  UR                  R                  [        R                  5      n[         R"                  " U5      UR                  l        U R$                   H!  nXdR                  ;   d  M  UR                  U	 M#     U(       a  XTR                  [        R                  '   U$ )Nexecution_templatelabels)rc   Applyr   MetarR   LabelsValuemetadatark   	GetOrNonehasattrrj   rP   re   getr   NONCE_LABELcopydeepcopyrb   )r$   r,   update_resultmaybe_new_labelsrP   noncelabel_to_removes          r%   r-   LabelChanges.Adjust   s    IIOO//12>>  M %..0!1
 X344 
%
%   
 
		78X#>#> ##H$8$89#'==1A#B #CCO/0  D 27//(..
/Or)   r"   N)r/   r0   r1   r2   r3   	frozensetr   ENDPOINT_VISIBILITYrb   rV   re   r4   r&   r-   r7   r"   r)   r%   r`   r`      sS     ?H""#?!#;  	D! !r)   r`   c                      \ rS rSrSrS rSrg)JobNonceChange   z@Adds a new nonce to the job template, for forcing an image pull.c                z    [         R                  " SSS9UR                  R                  [        R
                  '   U$ )N   _)	separator)r   GenerateNamerj   rk   r   rs   r+   s     r%   r-   JobNonceChange.Adjust   s3    ##A5 &&s7 Or)   r"   Nr/   r0   r1   r2   r3   r-   r7   r"   r)   r%   r~   r~      s
    Hr)   r~   c                  *    \ rS rSr% SrS\S'   S rSrg)ReplaceJobChange   zsRepresents the user intent to replace the job.

Attributes:
  new_job: New job that will replace the existing job.
zjob.Jobnew_jobc                    UR                   R                  (       a/  UR                   R                  U R                  R                   l        U R                  $ )a   Returns a replacement for resource.

The returned job is the job provided to the constructor. If
resource.metadata.resourceVersion is not empty, has metadata.resourceVersion
of returned job set to this value.

Args:
  resource: job.Job, The job to adjust.
)ro   resourceVersionr   r+   s     r%   r-   ReplaceJobChange.Adjust   s;     ((.6.?.?.O.Odll+<<r)   r"   Nr/   r0   r1   r2   r3   rV   r-   r7   r"   r)   r%   r   r      s     r)   r   c                  *    \ rS rSr% SrS\S'   S rSrg)ReplaceServiceChange   zRepresents the user intent to replace the service.

Attributes:
  new_service: New service that will replace the existing service.
zservice.Servicenew_servicec                p   UR                   R                  (       a  UR                   R                  U R                  R                   l        UR                  R	                  5        HC  u  p#UR                  [        R                  5      (       d  M+  X0R                  R                  U'   ME     U R                  $ )a  Returns a replacement for resource.

The returned service is the service provided to the constructor. If
resource.metadata.resourceVersion is not empty, has metadata.resourceVersion
of returned service set to this value.

Args:
  resource: service.Service, The service to adjust.
)ro   r   r   r   items
startswithr   SERVING_GROUP)r$   r,   kvs       r%   r-   ReplaceServiceChange.Adjust   s     ((



+
+ /
 &&,,.$!<<
0011,-


&
&q
) / r)   r"   Nr   r"   r)   r%   r   r      s     r)   r   c                  *    \ rS rSr% SrS\S'   S rSrg)ReplaceWorkerPoolChangei  zRepresents the user intent to replace the worker pool.

Attributes:
  new_worker_pool: New worker pool that will replace the existing worker pool.
zworker_pool.WorkerPoolnew_worker_poolc                    UR                   R                  (       a/  UR                   R                  U R                  R                   l        U R                  $ )a/  Returns a replacement for resource.

The returned worker pool is the worker pool provided to the constructor. If
resource.metadata.resourceVersion is not empty, has metadata.resourceVersion
of returned worker pool set to this value.

Args:
  resource: worker_pool.WorkerPool, The worker pool to adjust.
)ro   r   r   r+   s     r%   r-   ReplaceWorkerPoolChange.Adjust  sD     ((



+
+ ##3 r)   r"   Nr   r"   r)   r%   r   r     s     *) r)   r   F)rC   initc                  8   ^  \ rS rSr% SrS\S'   U 4S jrSrU =r$ )EndpointVisibilityChangei0  zeRepresents the user intent to modify the endpoint visibility.

Only applies to Cloud Run for Anthos.
zdataclasses.InitVar[bool]endpoint_visibilityc                   > U(       a3  [         R                  " [        R                  [        R                  0S9nO#[         R                  " [        R                  /S9n[
        TU ]  US5        g)zDetermine label changes for modifying endpoint visibility.

Args:
  endpoint_visibility: bool, True if Cloud Run on GKE service should only be
    addressable from within the cluster. False if it should be publicly
    addressable.
)	additions)subtractionsFN)r   Diffr   r|   CLUSTER_LOCALsuper__init__)r$   r   rc   	__class__s      r%   r   !EndpointVisibilityChange.__init__9  sX     00'2G2GHd G,G,G+HId 
GT5!r)   r"   )	r/   r0   r1   r2   r3   rV   r   r7   __classcell__r   s   @r%   r   r   0  s    
 10" "r)   r   c                  4    \ rS rSr% SrS\S'   S\S'   S rSrg)	SetAnnotationChangeiL  zzRepresents the user intent to set an annotation.

Attributes:
  key: Annotation to set.
  value: Annotation value to set.
strkeyvaluec                L    U R                   UR                  U R                  '   U$ rg   )r   r   r   r+   s     r%   r-   SetAnnotationChange.AdjustX  s    %)ZZH"Or)   r"   Nr   r"   r)   r%   r   r   L       (	*r)   r   c                  *    \ rS rSr% SrS\S'   S rSrg)DeleteAnnotationChangei]  z^Represents the user intent to delete an annotation.

Attributes:
  key: Annotation to delete.
r   r   c                V    UR                   nU R                  U;   a  X R                  	 U$ rg   )r   r   r$   r,   r   s      r%   r-   DeleteAnnotationChange.Adjustg  s(    &&Kxx;
hh
Or)   r"   Nr   r"   r)   r%   r   r   ]       (r)   r   c                  4    \ rS rSr% SrS\S'   S\S'   S rSrg)	SetTemplateAnnotationChangein  zRepresents the user intent to set a template annotation.

Attributes:
  key: Template annotation to set.
  value: Annotation value to set.
r   r   r   c                `    U R                   UR                  R                  U R                  '   U$ rg   )r   rP   r   r   r+   s     r%   r-   "SetTemplateAnnotationChange.Adjustz  s%    .2jjH!!$((+Or)   r"   Nr   r"   r)   r%   r   r   n  r   r)   r   c                  *    \ rS rSr% SrS\S'   S rSrg)DeleteTemplateAnnotationChangei  zoRepresents the user intent to delete a template annotation.

Attributes:
  key: Template annotation to delete.
r   r   c                j    UR                   R                  nU R                  U;   a  X R                  	 U$ rg   )rP   r   r   r   s      r%   r-   %DeleteTemplateAnnotationChange.Adjust  s.    ##//Kxx;
hh
Or)   r"   Nr   r"   r)   r%   r   r     r   r)   r   c                      \ rS rSr% Sr\R                  " \S9rS\	S'   \R                  " \
S9rS\	S'           SS jr    SS	 jrSS
 jrSrg)BaseImagesAnnotationChangei  a  Represents the user intent to update the 'base-images' template annotation.

The value of the annotation is a string representation of a json map of
container_name -> base_image_url. E.g.: '{"mycontainer":"my_base_image_url"}'.

Attributes:
  updates: {container:url} map of values that need to be added/updated
  deletes: List of containers whose base image url needs to be deleted.
default_factorydict[str, str]updates	list[str]deletesc                    U(       a  U H  nXR;   d  M
  X%	 M     U(       a  UR                  5        H	  u  pVXbU'   M     U R                  X5      $ rg   )r   _constructBaseImageUrls)r$   r,   existing_base_image_urlsr   r   rK   urls          r%   _mergeBaseImageUrls.BaseImagesAnnotationChange._mergeBaseImageUrls  sM     )0&1  #MMO.).1+ ,''KKr)   c                  ^ [        UR                  R                  R                  5        Vs/ s H  o3=(       d    SPM     sn5      mSR	                  U4S jUR                  5        5       5      nU(       a  SU-   S-   $ S$ s  snf )N z, c              3  J   >#    U  H  u  pUT;   d  M  S U SU S 3v   M     g7f)"z":"Nr"   ).0r   r   rQ   s      r%   	<genexpr>EBaseImagesAnnotationChange._constructBaseImageUrls.<locals>.<genexpr>  s/       /;sj?P!C5E7!|s   ##{})r{   rP   rQ   keysjoinr   )r$   r,   urlsxbase_images_strrQ   s        @r%   r   2BaseImagesAnnotationChange._constructBaseImageUrls  s}     "++66;;=>=Qb=>J ii  /3zz|  O +:3 3&ArA 	?s   Bc                   UR                   R                  nUR                  " [        R                  S5      nU(       a>  [
        R                  " U5      nU R                  XU R                  U R                  5      nOU R                  XR                  5      nU(       aQ  XQR                   R                  [        R                  '   [        R                  UR                   R                  l        U$ [        R                  U;   ar  UR                   R                  [        R                  	 UR                   R                  R                  [        R                  :X  a  SUR                   R                  l        U$ z9Updates the revision to use automatic base image updates.r   )rP   r   rr   r   BASE_IMAGES_ANNOTATIONjsonloadsr   r   r   r   $BASE_IMAGE_UPDATE_RUNTIME_CLASS_NAMEspecruntimeClassName)r$   r,   r   existing_valuer   	new_values         r%   r-   !BaseImagesAnnotationChange.Adjust  s    ##//K __X%D%DbIN!%N!;**
dllDLLi ..xFiGP##H$C$CD

7
7 - O 
	(	(K	7



'
'(G(G
H



 
 
1
1::; 35/Or)   r"   N)r,   revision.Revisionr   r   r   r   r   r   r,   r   r   r   r,   r   )r/   r0   r1   r2   r3   dataclassesfielddictr   rV   listr   r   r   r-   r7   r"   r)   r%   r   r     s     (--dC'>C"((>'9>L!L !/L 	L
 L"	B'	B/=	Br)   r   c                      \ rS rSr% Sr\R                  " \S9rS\	S'   \R                  " \
S9rS\	S'           SS jr    SS	 jrSS
 jrSrg)SourcesAnnotationChangei  ap  Represents the user intent to update the 'sources' template annotation.

The value of the annotation is a string representation of a json map of
container_name -> GCS objects. E.g.: '{"foo":"gs://my-bucket/my-object"}'.

Attributes:
  updates: {container:url} map of values that need to be added/updated
  deletes: List of containers whose source needs to be deleted.
r   r   r   r   r   c                    U(       a  U H  nXR;   d  M
  X%	 M     U(       a  UR                  5        H	  u  pVXbU'   M     U R                  X5      $ rg   )r   _constructSources)r$   r,   existing_sourcesr   r   rK   r   s          r%   _mergeSources%SourcesAnnotationChange._mergeSources  sM     )()  #MMO.)&)# ,!!(==r)   c                "   [        UR                  R                  R                  5        Vs/ s H  o3=(       d    SPM     sn5      n[        R
                  " UR                  5        VVs0 s H  u  p5X4;   d  M  X5_M     snnSS9$ s  snf s  snnf )Nr   ),:)
separators)r{   rP   rQ   r   r   dumpsr   )r$   r,   r   r   rQ   ys         r%   r   )SourcesAnnotationChange._constructSources  s}     "++66;;=>=Qb=>J ::**,:,$!!/,:  	? 	;s   B*B
9B
c                   UR                   R                  nUR                  " [        R                  S5      nU(       a>  [
        R                  " U5      nU R                  XU R                  U R                  5      nOU R                  XR                  5      nU(       a.  US:w  a(  XQR                   R                  [        R                  '   U$ [        R                  U;   a%  UR                   R                  [        R                  	 U$ )z(Updates the revision to use zip deploys.r   z{})rP   r   rr   r   SOURCES_ANNOTATIONr   r   r   r   r   r   )r$   r,   r   r   r   r   s         r%   r-   SourcesAnnotationChange.Adjust  s     ##//K __X%@%@"ENN3$$
dllDLLi ((<<@iY$&CL##H$?$?@ O 
	$	$	3



'
'(C(C
DOr)   r"   N)r,   r   r   r   r   r   r   r   r   r   )r/   r0   r1   r2   r3   r   r   r   r   rV   r   r   r   r   r-   r7   r"   r)   r%   r   r     sx     (--dC'>C"((>'9>>!> '> 	>
 > 	'	/=	r)   r   c                  @   ^  \ rS rSr% SrSrS\S'   SU 4S jjrSrU =r	$ )	*IngressContainerBaseImagesAnnotationChangei  a   Represents the user intent to update the 'base-images' template annotation.

The value of the annotation is a string representation of a json map of
container_name -> base_image_url. E.g.: '{"mycontainer":"my_base_image_url"}'.

This class changes the base image annotation for the default container, which
is either the container in a service with one container or the one with a port
set in a service with multiple containers.

Attributes:
  base_image: url of the base image for the default container or None
NrG   
base_imagec                J  > U R                   (       aA  U R                   U R                  UR                  R                  R                  =(       d    S'   OBU R
                  R                  UR                  R                  R                  =(       d    S5        [        TU ]!  U5      $ r   )	r  r   rP   rK   namer   appendr   r-   )r$   r,   r   s     r%   r-   1IngressContainerBaseImagesAnnotationChange.Adjust(  sm     =A__dll8$$..339r:
ll(++55::@bA7>(##r)   r"   r   )
r/   r0   r1   r2   r3   r  rV   r-   r7   r   r   s   @r%   r  r    s      *j$ $r)   r  c                  *    \ rS rSr% SrS\S'   S rSrg)SetLaunchStageAnnotationChangei3  zbSets launch stage annotation on a resource.

Attributes:
  launch_stage: The launch stage to set.
base.ReleaseTracklaunch_stagec                    U R                   [        R                  R                  :X  a  U$ U R                   R                  UR
                  [        R                  '   U$ rg   )r  r   ReleaseTrackGAidr   r   LAUNCH_STAGE_ANNOTATIONr+   s     r%   r-   %SetLaunchStageAnnotationChange.Adjust=  sO    D--000o 



 :==> or)   r"   Nr   r"   r)   r%   r  r  3  s     "!r)   r  c                  *    \ rS rSr% SrS\S'   S rSrg)SetRegionsAnnotationChangeiG  zbSets regions annotation on a resource.

Attributes:
  regions: A comma-separated list of regions.
r   regionsc                T    U R                   UR                  [        R                  '   U$ rg   )r  r   r   MULTI_REGION_REGIONS_ANNOTATIONr+   s     r%   r-   !SetRegionsAnnotationChange.AdjustQ  s&     CCD Or)   r"   Nr   r"   r)   r%   r  r  G       ,r)   r  c                  :    \ rS rSr% SrS\S'   S\S'   S rS rSrg	)
RegionsChangeAnnotationChangeiX  zAdds or removes regions annotation on an existing service.

Attributes:
  existing: the existing Service.
  to_add: A comma-separated list of regions to add to existing.
  to_remove: A comma-separated list of regions to remove from existing.
r   to_add	to_removec                    U R                  U5      nSR                  U5      UR                  [        R                  '   U$ Nr   )GetFinalListr   r   r   r  )r$   r,   
final_lists      r%   r-   $RegionsChangeAnnotationChange.Adjuste  s<    ""8,JGJxxHHCCD Or)   c                   UR                   R                  [        R                  5      =(       d    SnU(       a  UR	                  S5      O/ nU R
                  (       a  U R
                  R	                  S5      O/ nU R                  (       a  U R                  R	                  S5      O/ nU Vs/ s H  ofU;  d  M
  UPM     nnUR                  U Vs/ s H  ofU;  d  M
  UPM     sn5        U$ s  snf s  snf )z=Returns the final list of regions after applying the changes.Nr   )r   rr   r   r  splitr  r  extend)r$   r,   
annotationexistingr  r  r   r#  s           r%   r"  *RegionsChangeAnnotationChange.GetFinalListl  s     	  !K!KL 	  )3z$H'+{{T[[s#F-1^^$$S)I%<X));!XJ<&>&QX,=q&>? =>s   -	C-:C-	C2C2r"   N)	r/   r0   r1   r2   r3   rV   r-   r"  r7   r"   r)   r%   r  r  X  s     +.r)   r  c                  *    \ rS rSr% SrS\S'   S rSrg)MultiRegionDomainNameChangeiz  z|Sets a multi-region domain name annotation on the service.

Attributes:
  domain_name: The sandbox annotation value to set.
r   domain_namec                T    U R                   UR                  [        R                  '   U$ rg   )r-  r   r   GCLB_DOMAIN_NAME_ANNOTATIONr+   s     r%   r-   "MultiRegionDomainNameChange.Adjust  s(     ??@ Or)   r"   Nr   r"   r)   r%   r,  r,  z  s     r)   r,  c                  R    \ rS rSr% SrS\S'   S\S'   SrS\S'   \S	 5       rS
 r	Sr
g)'SetClientNameAndVersionAnnotationChangei  a  Sets the client name and version annotations.

Attributes:
  client_name: Client name to set.
  client_version: Client version to set.
  set_on_template: A boolean indicating whether the client name and version
    annotations should be set on the resource template as well.
r   client_nameclient_versionTrd   set_on_templatec                    U R                   $ rg   )r5  r#   s    r%   r&   8SetClientNameAndVersionAnnotationChange.adjusts_template  s    r)   c                J   U R                   b  U R                   UR                  [        R                  '   U R                  (       aL  [        UR                  S5      (       a1  U R                   UR                  R                  [        R                  '   U R                  b  U R                  UR                  [        R                  '   U R                  (       aL  [        UR                  S5      (       a1  U R                  UR                  R                  [        R                  '   U$ )Nr   )	r3  r   r   CLIENT_NAME_ANNOTATIONr5  rq   rP   r4  CLIENT_VERSION_ANNOTATIONr+   s     r%   r-   .SetClientNameAndVersionAnnotationChange.Adjust  s    #@D@P@Ph:<<=			'(*;*;]"K"K 	%%j&G&GH &


 :??@ 
		'(*;*;]"K"K 	%%j&J&JK Or)   r"   N)r/   r0   r1   r2   r3   rV   r5  r4   r&   r-   r7   r"   r)   r%   r2  r2    s6     /4   r)   r2  c                  *    \ rS rSr% SrS\S'   S rSrg)SandboxChangei  zgSets a sandbox annotation on the service.

Attributes:
  sandbox: The sandbox annotation value to set.
r   sandboxc                h    U R                   UR                  R                  [        R                  '   U$ rg   )r>  rP   r   r   SANDBOX_ANNOTATIONr+   s     r%   r-   SandboxChange.Adjust  s-     !!"4"G"GH Or)   r"   Nr   r"   r)   r%   r=  r=    r  r)   r=  c                  *    \ rS rSr% SrS\S'   S rSrg)VpcConnectorChangei  zSets a VPC connector annotation on the service.

Attributes:
  connector_name: The VPC connector name to set in the annotation.
r   connector_namec                h    U R                   UR                  R                  [        R                  '   U$ rg   )rD  rP   r   r   VPC_ACCESS_ANNOTATIONr+   s     r%   r-   VpcConnectorChange.Adjust  s/     !!"4"J"JK Or)   r"   Nr   r"   r)   r%   rC  rC    s     r)   rC  c                      \ rS rSrSrS rSrg)ClearVpcConnectorChangei  z1Clears a VPC connector annotation on the service.c                    UR                   R                  n[        R                  U;   a  U[        R                  	 [        R                  U;   a  U[        R                  	 U$ rg   )rP   r   r   rF  EGRESS_SETTINGS_ANNOTATIONr   s      r%   r-   ClearVpcConnectorChange.Adjust  sR    ##//K//;>
(>>
?44C
(CC
DOr)   r"   Nr   r"   r)   r%   rI  rI    s
    9r)   rI  )r   rC   c                  >   ^  \ rS rSr% SrS\S'   U 4S jrS rSrU =r	$ )ImageChangei  zdA Cloud Run container deployment.

Attributes:
  image: The image to set in the adjusted container.
r   imagec                T   > [         TU ]  " S0 UD6  [        R                  U SU5        g )NrO  r"   r   r   object__setattr__)r$   rO  kwargsr   s      r%   r   ImageChange.__init__  s%    	Gv
tWe,r)   c                &    U R                   Ul         g rg   )rO  rJ   s      r%   rM   ImageChange.AdjustContainer  s    jjIOr)   r"   
r/   r0   r1   r2   r3   rV   r   rM   r7   r   r   s   @r%   rN  rN    s     
*-! !r)   rN  c                X    U(       a  U R                  5         g U H  nX0;   d  M
  X	 M     g rg   )clear)mappingkeys_to_removeclear_othersvar_or_paths       r%   _PruneMappingr_    s&    
 MMO%		  &r)   c           
     t   U(       a  UR                  5         gU H  nUR                  SS5      u  pxXr;   d  M  X'   n	X;   a&  [        U U	U[        R                  " X   5      UU5      n	/ n
X   R
                   H%  nXR                  :w  d  M  U
R                  U5        M'     U
(       d  X'	 M  XU	   l        M     g)z5Remove the specified volume mappings from the config./   N)rZ  rsplit_CopyToNewVolumert   ru   r   pathr	  )r,   res_volumesvolume_mountsremovesr]  external_mountsremovemountre  volume_name	new_pathskey_to_paths               r%   _PruneManagedVolumeMappingro    s     MM#q)ke		#*)(mmK45+ 	&399K%%%[) : "+4k
"
(+ r)   c                   [        UR                  U R                  R                  5      n XeU'   UR                   Vs1 s H  owR                  iM     nnXA   n	U	R                   H0  nUR                  U;  d  M  UR                  R                  U5        M2     X4U'   U$ ! [         a&    [
        R                  " SR                  U5      5      ef = fs  snf )z1Copies existing volume to volume with a new name.RCannot update mount [{}] because its mounted volume is of a different source type.)_UniqueVolumeName
secretNamerP   r   KeyErrorr   ConfigurationErrorformatr   re  r	  )
r,   rl  mount_pointvolume_sourcerf  rg  new_volume_nameitemrm  
old_volumes
             r%   rd  rd  !  s     & 1 1 9 9/!0+ &3%8%89%8Tyy%8)9'*dyy	!  &  "/o	 
 

'
'	))/)<  :s   B C0Cc                      \ rS rSr% Sr\R                  " \S9rS\	S'   \R                  " \
S9rS\	S'   SrS	\	S
'   S rSrg)EnvVarLiteralChangesi>  zRepresents the user intent to modify environment variables string literals.

Attributes:
  updates: Updated env var names and values to set.
  removes: Env vars to remove.
  clear_others: If true clear all non-updated env vars.
r   Mapping[str, str]r   Collection[str]rh  Frd   r]  c                V   [        UR                  R                  U R                  U R                  5         UR                  R                  R                  U R                  5        g! [         a7  n[        R                  " SR                  UR                  S   5      5      eSnAff = f)a  Mutates the given config's env vars to match the desired changes.

Args:
  container: container to adjust
  messages_mod: messages module

Returns:
  The adjusted container

Raises:
  ConfigurationError if there's an attempt to replace the source of an
    existing environment variable whose source is of a different type
    (e.g. env var's secret source can't be replaced with a config map
    source).
zpCannot update environment variable [{}] to string literal because it has already been set with a different type.r   N)r_  env_varsliteralsrh  r]  updater   rt  r   ru  rv  args)r$   rK   rL   es       r%   rM   $EnvVarLiteralChanges.AdjustContainerL  s      )$$--t||T=N=NO!!((6 ))CCI6ffQiD s   /A' '
B(12B##B(r"   N)r/   r0   r1   r2   r3   r   r   r   r   rV   r   rh  r]  rM   r7   r"   r)   r%   r}  r}  >  sC      +00F'F(..tD'?D,r)   r}  c                  L    \ rS rSr% SrS\S'   S\S'   S\S'   S	rS
\S'   S rSrg	)SecretEnvVarChangesii  aJ  Represents the user intent to modify environment variable secrets.

Attributes:
  updates: Env var names and values to update.
  removes: List of env vars to remove.
  clear_others: If true clear all non-updated env vars.
  container_name: Name of the container to update. If None, the resource's
    primary container is update.
-Mapping[str, secrets_mapping.ReachableSecret]r   r  rh  rd   r]  NrG   rH   c                   U R                   (       a8  UR                  R                  U R                      R                  R                  nO UR                  R                  R                  n[        X R                  U R                  5        U R                  R                  5        H  u  p4 UR                  U5      X#'   M     [        R                   " U5        U$ ! [         a&    [        R                  " SR                  U5      5      ef = fau  Mutates the given config's env vars to match the desired changes.

Args:
  resource: k8s_object to adjust

Returns:
  The adjusted resource

Raises:
  ConfigurationError if there's an attempt to replace the source of an
    existing environment variable whose source is of a different type
    (e.g. env var's secret source can't be replaced with a config map
    source).
zpCannot update environment variable [{}] to the given type because it has already been set with a different type.)rH   rP   rQ   r  secretsr_  rh  r]  r   r   AsEnvVarSourcert  r   ru  rv  r   PruneAnnotation)r$   r,   r  r  reachable_secrets        r%   r-   SecretEnvVarChanges.Adjustz  s     ""--


  ""++33h(LL$*;*;<"&,,"4"4"6
)88B #7 ##H-O  
++EEKVF
 	

s   *C0D	r"   )	r/   r0   r1   r2   r3   rV   rH   r-   r7   r"   r)   r%   r  r  i  s*     98#.*#"r)   r  c                  >   ^  \ rS rSrSrU 4S jrS rS rS rSr	U =r
$ )ConfigMapEnvVarChangesi  zFRepresents the user intent to modify environment variable config maps.c                  > [         TU ]  5         0 U l        UR                  5        HT  u  pEUR	                  SS5      n[        U5      S:  a   UR                  U R                  U5      5        X`R                  U'   MV     X l        X0l	        g)a&  Initialize a new ConfigMapEnvVarChanges object.

Args:
  updates: {str, str}, Update env var names and values.
  removes: [str], List of env vars to remove.
  clear_others: bool, If true, clear all non-updated env vars.

Raises:
  ConfigurationError if a key hasn't been provided for a source.
r   rb     N)
r   r   _updatesr   r&  lenr	  _OmittedSecretKeyDefault_removes_clear_others)r$   r   rh  r]  r  r   r   r   s          r%   r   ConfigMapEnvVarChanges.__init__  su     
GDM==? ggc1oe	UaT22489!mmD # M%r)   c                    [         R                  " 5       (       a  g[        R                  " SR	                  U5      5      e)Nlatestz8Missing required item key for environment variable [{}].)r   	IsManagedr   ru  rv  )r$   r  s     r%   r  /ConfigMapEnvVarChanges._OmittedSecretKeyDefault  s5    

'
'BII$O r)   c                ~   UR                   R                  R                  n[        X R                  U R
                  5        U R                  R                  5        H+  u  nu  pE U R                  UR                  5       XE5      X#'   M-     U$ ! [         a&    [        R                  " SR                  U5      5      ef = fr  )rP   r  config_mapsr_  r  r  r  r   _MakeEnvVarSourcerR   rt  r   ru  rv  )r$   r,   r  r  source_name
source_keys         r%   r-   ConfigMapEnvVarChanges.Adjust  s       ))55H(MM4+=+=>+/==+>+>+@''{

//##%{
 ,A O  
++EEKVF
 	

s   $"B0B<c                :    UR                  UR                  X#S9S9$ )N)r  r   )configMapKeyRef)EnvVarSourceConfigMapKeySelector)r$   messagesr  r   s       r%   r  (ConfigMapEnvVarChanges._MakeEnvVarSource  s+       5545I !  r)   r  r  r  )r/   r0   r1   r2   r3   r   r  r-   r  r7   r   r   s   @r%   r  r    s     N&.@ r)   r  c                  J    \ rS rSr% SrSrS\S'   SrS\S'   SrS\S'   S r	S	r
g)
ResourceChangesi  aP  Represents the user intent to update resource limits.

Attributes:
  memory: Updated memory limit to set in the container. Specified as string
    ending in 'Mi' or 'Gi'. If None the memory limit is not changed.
  cpu: Updated cpu limit to set in the container if not None.
  gpu: Updated gpu limit to set in the container if not None.
NrG   memorycpugpuc                D   U R                   b  U R                   UR                  S'   U R                  b  U R                  UR                  S'   U R                  bG  U R                  S:X  a  UR                  R	                  SS5        gU R                  UR                  S'   gg)CMutates the given config's resource limits to match what's desired.Nr  r  0znvidia.com/gpu)r  resource_limitsr  r  poprJ   s      r%   rM   ResourceChanges.AdjustContainer  s    {{,0KKi)xx)-i&xx	S!!%%&6=6:hh	!!"23	 r)   r"   )r/   r0   r1   r2   r3   r  rV   r  r  rM   r7   r"   r)   r%   r  r    s,     &*#z#z
?r)   r  c           	        S nU R                  5       nU H  nUR                  S5      (       a  U R                  5       Ul        M0  UR                  S5      (       a  U R	                  5       Ul        M]  UR                  S5      (       a  U R                  5       Ul        M  [        X4U" X5      5        M     SU;   a  U" US5      UR                  l	        SU;   a  U" US5      UR
                  l	        SU;   a  US   UR
                  l
        SU;   a  U" US5      UR                  l	        S	U;   a  US	   UR                  l        U$ )
zCreates a probe from the given settings.

Args:
  messages: Run v1 messages module.
  settings: a dict of settings for the probe.

Returns:
  A new Run v1 probe.
c                    X   (       d  g  [        X   5      $ ! [         a&    [        R                  " SR	                  U5      5      ef = f)Nz&Value for key [{}] must be an integer.)int
ValueErrorr   ArgumentErrorrv  )settingsr   s     r%   	_ParseInt_MakeProbe.<locals>._ParseInt  sL    = $$
2
9
9#
> s	    0A		tcpSockethttpGetgrpcztcpSocket.portzhttpGet.portzhttpGet.pathz	grpc.portzgrpc.service)Prober   TCPSocketActionr  HTTPGetActionr  
GRPCActionr  setattrportre  r   )r  r  r  prober   s        r%   
_MakeProber    s    ..
%c
~~k"" 002eo			"	",,.em			&&(ej e)H23  !$X/?@EOOx"8^<EMMx!.1EMMH+6EJJOx!.1EJJ	,r)   c                  X    \ rS rSr% Sr\R                  " \S9rS\	S'   Sr
S\	S'   S	 rS
rg)StartupProbeChangesi4  zRepresents the user intent to update startup probe settings.

Attributes:
  settings: Values to set in the probe.
  clear: If true, clear the startup probe.
r   r   r  Frd   rZ  c                j    U R                   (       a  S Ul        g [        X R                  5      Ul        g rg   )rZ  startupProber  r  rJ   s      r%   rM   #StartupProbeChanges.AdjustContainer@  s%    zz#i'mmDIr)   r"   Nr/   r0   r1   r2   r3   r   r   r   r  rV   rZ  rM   r7   r"   r)   r%   r  r  4  s.     )..tD(ND%Er)   r  c                  X    \ rS rSr% Sr\R                  " \S9rS\	S'   Sr
S\	S'   S	 rS
rg)LivenessProbeChangesiG  zRepresents the user intent to update liveness probe settings.

Attributes:
  settings: values to set in the probe.
  clear: If true, clear the liveness probe.
r   r   r  Frd   rZ  c                j    U R                   (       a  S Ul        g [        X R                  5      Ul        g rg   )rZ  livenessProber  r  rJ   s      r%   rM   $LivenessProbeChanges.AdjustContainerS  s%    zz $i(}}EIr)   r"   Nr  r"   r)   r%   r  r  G  s.     )..tD(ND%Fr)   r  c                  X    \ rS rSr% Sr\R                  " \S9rS\	S'   Sr
S\	S'   S	 rS
rg)ReadinessProbeChangesiZ  zRepresents the user intent to update readiness probe settings.

Attributes:
  settings: values to set in the probe.
  clear: If true, clear the readiness probe.
r   r   r  Frd   rZ  c                j    U R                   (       a  S Ul        g [        X R                  5      Ul        g rg   )rZ  readinessProber  r  rJ   s      r%   rM   %ReadinessProbeChanges.AdjustContainerf  s%    zz!%i),FIr)   r"   Nr  r"   r)   r%   r  r  Z  s.     )..tD(ND%Gr)   r  c                  r    \ rS rSr% SrS\S'   S\S'   S\S'   SrS\S	'   \  S     SS
 jj5       rS r	Sr
g)CloudSQLChangesim  zRepresents the intent to update the Cloug SQL instances.

Attributes:
  project: Project to use as the default project for Cloud SQL instances.
  region: Region to use as the default region for Cloud SQL instances
  args: Args to the command.
r   add_cloudsql_instancesremove_cloudsql_instancesset_cloudsql_instancesNbool | Noneclear_cloudsql_instancesc          
     r   ^^^^ UU4S jnUU4S jmU " U" S5      U" S5      U" S5      [        TSS5      S9$ )	a4  Returns a CloudSQLChanges object from the given args.

Args:
  project: Optional project. If absent project must be specified in each
    Cloud SQL instance.
  region: Optional region. If absent region must be specified in each Cloud
    SQL instance.
  args: Command line args to parse CloudSQL flags from.
c                b   > [        TU S 5      nUc  g U Vs/ s H  nT" U5      PM     sn$ s  snf rg   getattr)arg_namevaliAugmentr  s      r%   AugmentArgs-CloudSQLChanges.FromArgs.<locals>.AugmentArgs  s5    D(D)c	"%&#Qgaj#&&&s   ,c                  > U R                  S5      n[        U5      S:X  a  SR                  U5      $ [        U5      S:X  ab  T(       d  [        R                  " S5      eT(       d  [        R                  " S5      eSR                  [
        R                  " TT/U5      5      $ [        R                  " SR                  U 5      5      e)Nr   r   rb  zJTo specify a Cloud SQL instance by plain name, you must specify a project.zcTo specify a Cloud SQL instance by plain name, you must be deploying to a managed Cloud Run region.z&Malformed CloudSQL instance string: {})r&  r  r   r   CloudSQLError	itertoolschainrv  )instance_strinstanceprojectregions     r%   r  )CloudSQLChanges.FromArgs.<locals>.Augment  s    ##C(h	X!	xx!!x=A((  ((9  xx	&(98DEE&&4;;LI
 	
r)   r  r  r  r  N)r  r  r  r  r  )clsr  r  r  r  r  s    ``` @r%   FromArgsCloudSQLChanges.FromArgs|  sG    $'
, *+CD"-.I"J*+CD!(,d"
	 r)   c                   ^ U4S jn[         R                  " U SU5      nUb6  SR                  U5      TR                  R                  [
        R                  '   T$ )Nc                    > TR                   R                  R                  [        R                  5      n U (       a  U R                  S5      $ / $ r!  )rP   r   rr   r   CLOUDSQL_ANNOTATIONr&  annotation_valr,   s    r%   GetCurrentInstances3CloudSQLChanges.Adjust.<locals>.GetCurrentInstances  sC    ((4488

0
0n 
##C((ir)   zcloudsql-instancesr   )r   ParsePrimitiveArgsr   rP   r   r   r  )r$   r,   r  	instancess    `  r%   r-   CloudSQLChanges.Adjust  s[     ++"$7I 
((9
 ##$6$J$JK Or)   r"   )NN)r  rG   r  rG   r  zargparse.Namespace)r/   r0   r1   r2   r3   rV   r  classmethodr  r-   r7   r"   r)   r%   r  r  m  sb     $#&&##*.K. !44 4
 4 4lr)   r  c                  >    \ rS rSr% SrSrS\S'   \S 5       rS r	Sr
g)	ConcurrencyChangesi  zRepresents the user intent to update concurrency preference.

Attributes:
  concurrency: The concurrency value to set in the resource template. If None
    concurrency is cleared.
Nz
int | Noneconcurrencyc                <    U " US:X  a  S5      $ [        U5      5      $ )zReturns a ConcurrencyChanges object from the --concurrency flag value.

Args:
  concurrency: The concurrency flag value. If 'default' concurrency is
    cleared, otherwise should be an integer concurrency value to set.
defaultN)r  )r  r  s     r%   FromFlagConcurrencyChanges.FromFlag  s#     {i/tFFS5EFFr)   c                <    U R                   UR                  l         U$ )r  )r  rP   r+   s     r%   r-   ConcurrencyChanges.Adjust  s    $($4$4H!Or)   r"   )r/   r0   r1   r2   r3   r  rV   r  r  r-   r7   r"   r)   r%   r  r    s,     !+z G Gr)   r  c                  *    \ rS rSr% SrS\S'   S rSrg)TimeoutChangesi  z|Represents the user intent to update request duration.

Attributes:
  timeout: The timeout to set in the resource template.
r   timeoutc                <    U R                   UR                  l         U$ )z;Mutates the given config's timeout to match what's desired.)r  rP   r+   s     r%   r-   TimeoutChanges.Adjust  s     $HOr)   r"   Nr   r"   r)   r%   r  r    s     ,r)   r  c                  *    \ rS rSr% SrS\S'   S rSrg)ServiceAccountChangesi  zRepresents the user intent to change service account for the revision.

Attributes:
  service_account: The service account to set.
r   service_accountc                <    U R                   UR                  l         U$ )zCMutates the given config's service account to match what's desired.)r  rP   r+   s     r%   r-   ServiceAccountChanges.Adjust  s    (,(<(<H%Or)   r"   Nr   r"   r)   r%   r  r    s     r)   r  ?   c                  *    \ rS rSr% SrS\S'   S rSrg)RevisionNameChangesi  z{Represents the user intent to change revision name.

Attributes:
  revision_suffix: Suffix to append to the revision name.
r   revision_suffixc                    U R                   (       d  SUR                  l        U$ [        [	        U R                   5      -
  S-
  nSR                  UR                  SU U R                   5      UR                  l        U$ )zAMutates the given config's revision name to match what's desired.r   rb  z{}-{}N)r  rP   r  _MAX_RESOURCE_NAME_LENGTHr  rv  )r$   r,   max_prefix_lengths      r%   r-   RevisionNameChanges.Adjust  su    !ho 	"C(<(<$==A  %^^(()4+?+?H Or)   r"   Nr   r"   r)   r%   r  r    s     r)   r  c                .    [         R                  " SSU S9$ )z.Randomly generated name with the given prefix.r  -)sectionsr   prefix)r   r   )r   s    r%   GenerateVolumeNamer!    s    		$	$a3v	NNr)   c                H    SnUb  X!;   a  [        U 5      nUc  M  X!;   a  M  U$ )zGenerate unique volume name.

The names that connect volumes and mounts must be unique even if their
source volume names match.

Args:
  source_name: (Potentially clashing) name.
  existing_volumes: Names in use.

Returns:
  Unique name.
N)r!  )r  existing_volumesrl  s      r%   rr  rr  "  s1     +{>$[1K 	{>	r)   c                :    [        U5       H  nX ;  d  M
  X	 M     g)zDelete all volumes no longer being mounted.

Args:
  mounted_volumes: set of volumes mounted in any container
  res_volumes: resource.template.volumes
N)r   )mounted_volumesrf  volumes      r%   _PruneVolumesr'  5  s     [!f$

 "r)   c                  R    \ rS rSr% SrS\S'   S\S'   S\S'   S	rS
\S'   S rS rSr	g	)SecretVolumeChangesiA  aF  Represents the user intent to change volumes with secret source types.

Attributes:
  updates: Updates to mount path and volume fields.
  removes: List of mount paths to remove.
  clear_others: If true clear all non-updated volumes and mounts of the given
    [volume_type].
  container_name: Name of the container to update.
r  r   r  rh  rd   r]  NrG   rH   c           	        0 n[         R                  " [        5      nUR                  5        H  u  pxXh   R	                  U5        M     U R
                  R                  5        H  u  pU	R                  SS5      S   nX;   aW  X[   R                  U
R                  :w  a%  [        R                  " SR                  U	5      5      eU
R                  XU   5        Mv  U
R                  U5      X['   M     UR                  5        GH  u  pX;   Ga_  X+   n[        Xm   5      S:  d  X;   a8  Xm   R                  U5        [!        UUUUUU5      nXn   R	                  U5        M^  X=   nUR                  UR                  :w  a  UR                   Vs1 s H  nUR"                  iM     nnUR                   Vs1 s H  nUR"                  iM     nnUR%                  U5      (       d%  [        R                  " SR                  U5      5      eOUR                   Vs1 s H  nUR"                  iM     nnUR                   H0  nUR"                  U;  d  M  UR                  R	                  U5        M2     O/['        UR                  UR(                  R*                  5      n XU'   XU'   GM     gs  snf s  snf s  snf ! [,         a&    [        R                  " SR                  U5      5      ef = f)zCUpdate volumes for Cloud Run. Ensure only one secret per directory.ra  rb  r   zaCannot update secret at [{}] because a different secret is already mounted in the same directory.zcMultiple secrets are specified for directory [{}]. Cloud Run only supports one secret per directoryrq  N)collectionsdefaultdictr   r   r	  r   rc  rs  secret_namer   ru  rv  AppendToSecretVolumeSourceAsSecretVolumeSourcer  rj  rd  re  issubsetrr  rP   r   rt  )r$   r,   rg  rf  ri  new_volumesvolumes_to_mountsre  vol	file_pathr  rw  rx  rl  new_namer&  rz  existing_pathsrm  s                      r%   _UpdateManagedVolumes)SecretVolumeChanges._UpdateManagedVolumesR  s    K#//5"((*	##D) + (,||'9'9';#	$$S!,Q/k		##..2B2N2NN --77=vi7H  	33+.	
 $4#H#H$
  (<$ '2&7&7&9"		%#0!./!3- 
(
/
/
<%( 
%
,
,[
9
+&-":"::4:LLALDdiiLNA/</B/BC/Bt/BIC!**95511<<BF;<O  6 0=/B/BC/Bt/BIC)+##**40 %
 ($$h&7&7&?&?
	'2
$ "/+e ':0 BC D  	--//5vk/B 	s   
J$0J)J.J330K#c                  ^
 U R                   (       a$  UR                  R                  U R                      m
OUR                  R                  m
T
R                  R
                  nUR                  R                  R
                  n[        [        R                  R                  U
4S jUR                  R                  R                  5        5       5      5      n[        R                  " 5       (       a%  [        UUUU R                  U R                   U5        O"U R                  n[#        X%U R                   5        [        R                  " 5       (       a  U R%                  XX45        OgU R&                  R                  5        HI  u  pg[)        UR*                  UR                  R                  5      n Un	XU	'   UR5                  U5      X8'   MK     [7        UR9                  UR;                  5       5      U5        [<        R>                  " U5        U$ ! [,         a&    [.        R0                  " SR3                  U5      5      ef = f)  Mutates the given config's volumes to match the desired changes.

Args:
  resource: k8s_object to adjust

Returns:
  The adjusted resource

Raises:
  ConfigurationError if there's an attempt to replace the volume a mount
    points to whose existing volume has a source of a different type than
    the new volume (e.g. mount that points to a volume with a secret source
    can't be replaced with a volume that has a config map source).
c              3     >#    U  H=  u  pUTR                   :w  d  M  UR                  R                  R                  5       v   M?     g 7frg   )r  rg  r  values)r   r  external_containerrK   s      r%   r   -SecretVolumeChanges.Adjust.<locals>.<genexpr>  sB      &
,P(y~~% >,,44;;==,Ps
   A+Arq  ) rH   rP   rQ   rK   rg  r  r   r{   r  r  from_iterabler   r   r  ro  rh  r]  r_  r7  r   rr  r-  rt  r   ru  rv  r/  r'  unionr<  r   r  )r$   r,   rg  rf  ri  rh  r4  r  rl  rw  rK   s             @r%   r-   SecretVolumeChanges.Adjust  s    ##..t/B/BCi##--i++33M##++33K%% &
,4,=,=,H,H,N,N,P&
 	
O  



,,



 gMD,=,=>
  
; *.););)=
%)'(((*;*;*C*C
	!+'2
$ $4#H#H$
  *>& /''(<(<(>?M##H-O  	--//5vi/@ 	s   /H0H=r"   )
r/   r0   r1   r2   r3   rV   rH   r7  r-   r7   r"   r)   r%   r)  r)  A  s2     98#.*#M/^Dr)   r)  c                  <   ^  \ rS rSrSrU 4S jrS rSS jrSrU =r	$ )ConfigMapVolumeChangesi  zJRepresents the user intent to change volumes with config map source types.c                   > [         TU ]  5         0 U l        UR                  5        HE  u  pEUR	                  SS5      n[        U5      S:  a  UR                  S5        X`R                  U'   MG     X l        X0l        g)a  Initialize a new ConfigMapVolumeChanges object.

Args:
  updates: {str, [str, str]}, Update mount path and volume fields.
  removes: [str], List of mount paths to remove.
  clear_others: bool, If true, clear all non-updated volumes and mounts of
    the given [volume_type].
r   rb  r  N)	r   r   r  r   r&  r  r	  r  r  )r$   r   rh  r]  r   r   update_valuer   s          r%   r   ConfigMapVolumeChanges.__init__  sn     
GDM WWS!_l	\	Q	D!%mmA   M%r)   c                   UR                   R                  R                  R                  nUR                   R                  R                  n[        X R                  U R                  5        U R                  R                  5        HN  u  nu  pV[        XQR                   R                  5      n XrU'   U R                  UR!                  5       XV5      X7'   MP     [#        [$        R&                  R)                  S UR                   R*                  R-                  5        5       5      5      n[/        X5        U$ ! [         a&    [        R                  " SR                  U5      5      ef = f)r:  rq  c              3  j   #    U  H)  nUR                   R                  R                  5       v   M+     g 7frg   )rg  r  r<  )r   rK   s     r%   r   0ConfigMapVolumeChanges.Adjust.<locals>.<genexpr>&  s/      &
B	 ##//6688Bs   13)rP   rK   rg  r  r   r_  r  r  r  r   rr  rt  r   ru  rv  _MakeVolumeSourcerR   r{   r  r  r?  rQ   r<  r'  )	r$   r,   rg  rf  re  r  r  rl  r%  s	            r%   r-   ConfigMapVolumeChanges.Adjust  s3    %%//==IIM##++77K-0B0BC+/==+>+>+@''{%k3D3D3L3LMk
)d "&!7!7

!
!
#["k ,A   %% &
%..99@@B&
 	
O //O#  
++--3VD\
 	

s   -D550E%c                z    UR                  US9nUb(  UR                  R                  UR                  X3S95        U$ )N)r  )r   re  )ConfigMapVolumeSourcer   r	  	KeyToPath)r$   r  r  r   sources        r%   rJ  (ConfigMapVolumeChanges._MakeVolumeSource/  s?    +++6F
ll(,,,?@Mr)   r  rg   )
r/   r0   r1   r2   r3   r   r-   rJ  r7   r   r   s   @r%   rC  rC    s    R&,,\ r)   rC  c                      \ rS rSrSrS rSrg)NoTrafficChangei6  z?Represents the user intent to block traffic for a new revision.c                    UR                   (       d  [        R                  " S5      eUR                  R	                  UR
                  R                  5        U$ )z5Removes LATEST from the services traffic assignments.z7--no-traffic not supported when creating a new service.)
generationr   ru  spec_trafficZeroLatestTrafficstatuslatestReadyRevisionNamer+   s     r%   r-   NoTrafficChange.Adjust9  sK    ))
C  ++// Or)   r"   Nr   r"   r)   r%   rR  rR  6  s
    G
r)   rR  c                      \ rS rSr% SrS\S'   SrS\S'   \R                  " \	S9r
S	\S
'   \R                  " \S9rS\S'   SrS\S'   S rSrg)TrafficChangesiF  as  Represents the user intent to change a service's traffic assignments.

Attributes:
  new_percentages: New traffic percentages to set.
  by_tag: Boolean indicating that new traffic percentages are specified by
    tag.
  tags_to_update: Traffic tag values to update.
  tags_to_remove: Traffic tags to remove.
  clear_other_tags: Whether nonupdated tags should be cleared.
zMapping[str, int]new_percentagesFrd   by_tagr   r~  tags_to_updateContainer[str]tags_to_removeclear_other_tagsc                x   U R                   (       d"  U R                  (       d  U R                  (       a;  UR                  R	                  U R                   U R                  U R                  5        U R
                  (       a}  U R                  (       aE  UR                  R                  5       n0 nU R
                   H  n U R
                  U   X2U   '   M     OU R
                  nUR                  R                  U5        U$ ! [         a0    [        R                  " SR                  XAR                  5      5      ef = f)z0Mutates the given service's traffic assignments.zIThere is no revision tagged with [{}] in the traffic allocation for [{}].)r^  r`  ra  rU  
UpdateTagsr\  r]  TagToKeyrt  r   ru  rv  r  UpdateTraffic)r$   r,   
tag_to_keypercentagestags        r%   r-   TrafficChanges.AdjustY  s    d11T5J5J&&









 	**335
''C+/+?+?+DK3( ( **))+6O  //((.sMM(B s   =C??:D9r"   N)r/   r0   r1   r2   r3   rV   r]  r   r   r   r^  r   r`  ra  r-   r7   r"   r)   r%   r[  r[  F  sT    	 %$&$&1&7&7&M.#M#.#4#4T#J..J D r)   r[  c                  *    \ rS rSr% SrS\S'   S rSrg)TagOnDeployChangeis  zThe intent to provide a tag for the revision you're currently deploying.

Attributes:
  tag: The tag to apply to the new revision.
r   rh  c                    U R                   UR                  R                  0nUR                  R	                  U/ S5        U$ )z6Gives the revision that's being created the given tag.F)rh  rP   r  rU  rc  )r$   r,   r^  s      r%   r-   TagOnDeployChange.Adjust}  s9    hh 1 1 6 67N$$^R?Or)   r"   Nr   r"   r)   r%   rk  rk  s  r   r)   rk  c                  >   ^  \ rS rSr% SrS\S'   U 4S jrS rSrU =r	$ )ContainerCommandChangei  zRepresents the user intent to change the 'command' for the container.

Attributes:
  command: The command to set in the adjusted container.
r   commandc                T   > [         TU ]  " S0 UD6  [        R                  U SU5        g )Nrp  r"   rQ  )r$   rp  rT  r   s      r%   r   ContainerCommandChange.__init__  s%    	Gv
tY0r)   c                &    U R                   Ul         g rg   )rp  rJ   s      r%   rM   &ContainerCommandChange.AdjustContainer  s    Ir)   r"   rX  r   s   @r%   ro  ro    s     ,1% %r)   ro  c                  >   ^  \ rS rSr% SrS\S'   U 4S jrS rSrU =r	$ )ContainerArgsChangei  zRepresents the user intent to change the 'args' for the container.

Attributes:
  args: The args to set in the adjusted container.
r   r  c                T   > [         TU ]  " S0 UD6  [        R                  U SU5        g )Nr  r"   rQ  )r$   r  rT  r   s      r%   r   ContainerArgsChange.__init__  s%    	Gv
tVT*r)   c                &    U R                   Ul         g rg   )r  rJ   s      r%   rM   #ContainerArgsChange.AdjustContainer  s    YYINr)   r"   rX  r   s   @r%   rv  rv    s     	/+ r)   rv  h2c  c                  <    \ rS rSr% SrSrS\S'   SrS\S'   S rS	r	g)
ContainerPortChangei  aW  Represents the user intent to change the port name and/or number.

Attributes:
  port: The port to set, "default" to unset the containerPort field, or None
    to not modify the port number.
  use_http2: True to set the port name for http/2, False to unset it, or None
    to not modify the port name.
  **kwargs: ContainerConfigChanger args.
NrG   r  r  	use_http2c                   UR                   (       a  UR                   S   OUR                  5       nUR                  =(       d    SnU R                  S:X  a  UR	                  S5        O'U R                  b  [        U R                  5      Ul        U R                  (       a  [        Ul        OU R                  b  UR	                  S5        UR                  (       a  UR                  (       d  [        Ul        UR                  (       a	  U/Ul         OUR	                  S5        UR                  (       a  UR                  R                  (       a  UR                  R                  R                  U:X  a]  UR                  (       a&  UR                  UR                  R                  l        gUR                  R                  R	                  S5        gggg)	z5Modify an existing ContainerPort or create a new one.r   r|  r  containerPortNr  portsr  )r  ContainerPortr  r  resetr  r  _HTTP2_NAMEr  _DEFAULT_PORTr  r  )r$   rK   rL   port_msgold_ports        r%   rM   #ContainerPortChange.AdjustContainer  sC    (oo	<3M3M3O  %%-HyyInn_%		"499~h~~!hm		#nnV}}X33,h !
iooog )"8"8"B"B				)	)	.	.(	:!!2:2H2H)
 
 
*
*
/

 
 
*
*
0
0
8	 
; #Cr)   r"   )
r/   r0   r1   r2   r3   r  rV   r  rM   r7   r"   r)   r%   r~  r~    s"     $
)[ 9r)   r~  c                  4    \ rS rSr% SrS\S'   S\S'   S rSrg	)
ExecutionTemplateSpecChangei  zRepresents the intent to update field in an execution template's spec.

Attributes:
  field: The field to update in the execution template spec.
  value: The value to set in the updated field.
r   r   r   r   c                p    [        UR                  R                  U R                  U R                  5        U$ rg   )r  rj   r   r   r   r+   s     r%   r-   "ExecutionTemplateSpecChange.Adjust  s'    H'',,djj$**EOr)   r"   Nr   r"   r)   r%   r  r    s     
*	*r)   r  c                  *    \ rS rSr% SrS\S'   S rSrg)JobMaxRetriesChangei  zRepresents the user intent to update a job's restart policy.

Attributes:
  max_retries: The max retry number to set in the job's restart policy.
r  max_retriesc                P    U R                   UR                  R                  l        U$ rg   )r  task_templater   
maxRetriesr+   s     r%   r-   JobMaxRetriesChange.Adjust  s!    -1-=-=H*Or)   r"   Nr   r"   r)   r%   r  r    s     r)   r  c                  *    \ rS rSr% SrS\S'   S rSrg)JobPriorityTierChangei  zqRepresents the intent to update the job's priority tier.

Attributes:
  priority_tier: The priority tier to set.
r   priority_tierc                    [         R                  R                  U R                  R	                  5       5      UR
                  R                  l        U$ rg   )r   ExecutionSpecPriorityTierValueValuesEnumr  upperrj   r   priorityTierr+   s     r%   r-   JobPriorityTierChange.Adjust  sC    %%AA$$&	
 $$1
 Or)   r"   Nr   r"   r)   r%   r  r    s     r)   r  c                  *    \ rS rSr% SrS\S'   S rSrg)JobTaskTimeoutChangei  zRepresents the user intent to update a job's instance deadline.

Attributes:
  timeout_seconds: The timeout in seconds to set in the job's instance
    deadline.
r  timeout_secondsc                P    U R                   UR                  R                  l        U$ rg   )r  r  r   timeoutSecondsr+   s     r%   r-   JobTaskTimeoutChange.Adjust  s!    151E1EH.Or)   r"   Nr   r"   r)   r%   r  r    s     r)   r  c                  *    \ rS rSr% SrS\S'   S rSrg)CpuThrottlingChangei!  zSets the cpu-throttling annotation on the service template.

Attributes:
  throttling: The throttling annotation value to set.
rd   
throttlingc                z    [        U R                  5      UR                  R                  [        R
                  '   U$ rg   )r   r  rP   r   r   CPU_THROTTLE_ANNOTATIONr+   s     r%   r-   CpuThrottlingChange.Adjust+  s6     	DOO !!22 Or)   r"   Nr   r"   r)   r%   r  r  !  s     r)   r  c                  *    \ rS rSr% SrS\S'   S rSrg)StartupCpuBoostChangei2  zSets the startup-cpu-boost annotation on the service template.

Attributes:
  cpu_boost: Boolean indicating whether CPU boost should be enabled.
rd   	cpu_boostc                z    [        U R                  5      UR                  R                  [        R
                  '   U$ rg   )r   r  rP   r   r   COLD_START_BOOST_ANNOTATIONr+   s     r%   r-   StartupCpuBoostChange.Adjust<  s6     	DNN !!66 Or)   r"   Nr   r"   r)   r%   r  r  2  s     /r)   r  c                  *    \ rS rSr% SrS\S'   S rSrg)HealthCheckChangeiC  zSets the health-check-disabled annotation on the revision template.

Attributes:
  health_check: Boolean indicating whether the health check should be enabled.
rd   health_checkc                    [        U R                  (       + 5      UR                  R                  [        R
                  '   U$ rg   )r   r  rP   r   r   DISABLE_HEALTH_CHECK_ANNOTATIONr+   s     r%   r-   HealthCheckChange.AdjustM  s;     	!!!" !!:: Or)   r"   Nr   r"   r)   r%   r  r  C  s     r)   r  c                  *    \ rS rSr% SrS\S'   S rSrg)DefaultUrlChangeiT  zSets the default-url-disabled annotation on the service.

Attributes:
  default_url: Boolean indicating whether the default URL should be enabled.
rd   default_urlc                p    [        U R                  (       + 5      UR                  [        R                  '   U$ rg   )r   r  r   r   DISABLE_URL_ANNOTATIONr+   s     r%   r-   DefaultUrlChange.Adjust^  s2    FIGH+BBC Or)   r"   Nr   r"   r)   r%   r  r  T  s     r)   r  c                  *    \ rS rSr% SrS\S'   S rSrg)InvokerIamChangeie  zSets the invoker-iam-disabled annotation on the service.

Attributes:
  invoker_iam_check: Boolean indicating whether invoker iam should be enabled
rd   invoker_iam_checkc                p    [        U R                  (       + 5      UR                  [        R                  '   U$ rg   )r   r  r   r   DISABLE_IAM_ANNOTATIONr+   s     r%   r-   InvokerIamChange.Adjusto  s2    FI"""GH+BBC Or)   r"   Nr   r"   r)   r%   r  r  e  s     r)   r  c                  b    \ rS rSr% SrS\S'   S\S'   S\S'   S\S'   S\S	'   S
\S'   S rS rSrg)NetworkInterfacesChangeiv  a  Sets or updates the network interfaces annotation on the template.

Attributes:
  network_is_set: Boolean indicating whether network was explicitly set by the
    user.
  network: The network to set.
  subnet_is_set: Boolean indicating whether subnet was explicitly set by the
    user.
  subnet: The subnet to set.
  network_tags_is_set: Boolean indicating whether network_tags was explicitly
    set by the user.
  network_tags: The network tags to set.
rd   network_is_setr   networksubnet_is_setsubnetnetwork_tags_is_setr   network_tagsc                ,    U(       a  X1U'   g X!;   a  X	 g g rg   r"   )r$   mr   r   s       r%   _SetOrClear#NetworkInterfacesChange._SetOrClear  s    f	
& 
r)   c                   UR                   R                  n0 n[        R                  U;   a*  [        R
                  " U[        R                     5      S   nU R                  (       a  U R                  USU R                  5        U R                  (       a  U R                  USU R                  5        U R                  (       a  U R                  USU R                  5        SnU(       a"  SR                  [        R                  " USS9S	9nU R                  U[        R                  U5        U(       d%  [        R                   U;   a  U[        R                   	 U$ )
Nr   r  
subnetworktagsr   z[{interfaces}]T)	sort_keys)
interfaces)rP   r   r   NETWORK_INTERFACES_ANNOTATIONr   r   r  r  r  r  r  r  r  rv  r   r   rK  )r$   r,   r   network_interfacer   s        r%   r-   NetworkInterfacesChange.Adjust  s    ##//K//;>**
j>>
?	 
()T\\B
(,D
(&$2C2CDE%%ZZ 1TB & e 	Z==u
 99[H
(CC
DOr)   r"   N)	r/   r0   r1   r2   r3   rV   r  r-   r7   r"   r)   r%   r  r  v  s5     ,
+r)   r  c                      \ rS rSrSrS rSrg)ClearNetworkInterfacesChangei  z7Clears a network interfaces annotation on the resource.c                    UR                   R                  n[        R                  U;   a  U[        R                  	 [        R
                  U;   a  U[        R
                  	 U$ rg   )rP   r   r   r  r   rK  r   s      r%   r-   #ClearNetworkInterfacesChange.Adjust  sQ    ##//K//;>
j>>
?44C
(CC
DOr)   r"   Nr   r"   r)   r%   r  r    s
    ?r)   r  c                  j    \ rS rSr% SrS\S'   \S 5       r\S 5       r\S 5       r	\S 5       r
S	 rS
rg)CustomAudiencesChangesi  z`Represents the intent to update the custom audiences.

Attributes:
  args: Args to the command.
rR  r  c                0    [        U R                  SS 5      $ )Nadd_custom_audiencesr  r  r#   s    r%   r  +CustomAudiencesChanges.add_custom_audiences      4994d;;r)   c                0    [        U R                  SS 5      $ )Nremove_custom_audiencesr  r#   s    r%   r  .CustomAudiencesChanges.remove_custom_audiences  s    4997>>r)   c                0    [        U R                  SS 5      $ )Nset_custom_audiencesr  r#   s    r%   r  +CustomAudiencesChanges.set_custom_audiences  r  r)   c                0    [        U R                  SS 5      $ )Nclear_custom_audiencesr  r#   s    r%   r  -CustomAudiencesChanges.clear_custom_audiences  s    4996==r)   c                0  ^ U4S jn[         R                  " U SU5      nUbs  U(       a3  [        R                  " U5      TR                  [
        R                  '   T$ [
        R                  TR                  ;   a  TR                  [
        R                  	 T$ )Nc                    > TR                   R                  [        R                  5      n U (       a  [        R
                  " U 5      $ / $ rg   )r   rr   r   CUSTOM_AUDIENCES_ANNOTATIONr   r   r  s    r%   GetCurrentCustomAudiences@CustomAudiencesChanges.Adjust.<locals>.GetCurrentCustomAudiences  s;    ++//

0
0n 
zz.))ir)   zcustom-audiences)r   r  r   r   r   r   r  )r$   r,   r  	audiencess    `  r%   r-   CustomAudiencesChanges.Adjust  s     ++ ";I 	JJy! 	ZCCD
 O 11X5I5II  !G!GHOr)   r"   N)r/   r0   r1   r2   r3   rV   r4   r  r  r  r  r-   r7   r"   r)   r%   r  r    sa     	,< < ? ? < < > >r)   r  c                  *    \ rS rSr% SrS\S'   S rSrg)RuntimeChangei  zrSets the runtime annotation on the service template.

Attributes:
  runtime: The runtime annotation value to set.
r   runtimec                P    U R                   UR                  R                  l        U$ rg   )r  rP   r   r   r+   s     r%   r-   RuntimeChange.Adjust  s    .2llH+Or)   r"   Nr   r"   r)   r%   r  r    s     ,r)   r  c                  *    \ rS rSr% SrS\S'   S rSrg)GpuTypeChangei  zuSets the gpu-type annotation on the service template.

Attributes:
  gpu_type: The gpu_type annotation value to set.
r   gpu_typec                    U R                   (       a3  U R                   UR                  R                  [        R                  '   U$ UR                  R                  R                  [        R                  S 5        U$ rg   )r  rP   node_selectorr   GPU_TYPE_NODE_SELECTORr  r+   s     r%   r-   GpuTypeChange.Adjust	  sa    }}
-- %%j&G&GH O %%))

+
+T Or)   r"   Nr   r"   r)   r%   r  r    s     -	r)   r  c                  *    \ rS rSr% SrS\S'   S rSrg)GpuZonalRedundancyChangei  zSets the gpu zonal redundancy annotation on the revision annotations.

Attributes:
  gpu_zonal_redundancy: The gpu_zonal_redundancy annotation value to set.
rd   gpu_zonal_redundancyc                    [        U R                  (       + 5      UR                  R                  [        R
                  '   U$ rg   )r   r  rP   r   r   (GPU_ZONAL_REDUNDANCY_DISABLED_ANNOTATIONr+   s     r%   r-   GpuZonalRedundancyChange.Adjust  s;     	)))* !!99 Or)   r"   Nr   r"   r)   r%   r  r    s     r)   r  c                  J    \ rS rSr% SrS\S'   \S	S j5       r    S
S jrSr	g)RemoveContainersChangei&  zSRemoves the specified containers.

Attributes:
  containers: Containers to remove.
zfrozenset[str]rQ   c                $    U " [        U5      5      $ )zReturns a RemoveContainersChange that removes the specified containers.

Args:
  containers: The names of containers to remove. Duplicate container names
    are ignored.
)r{   )r  rQ   s     r%   FromContainerNames)RemoveContainersChange.FromContainerNames0  s     y$%%r)   c                ~    U R                    H  n UR                  R                   U	 M     U$ ! [         a     M.  f = frg   )rQ   rP   rt  rS   s      r%   r-   RemoveContainersChange.Adjust:  sF     __	((3 %
 O  s   .
<<r"   N)rQ   Iterable[str]r,   k8s_object.KubernetesObjectreturnr  )
r/   r0   r1   r2   r3   rV   r  r  r-   r7   r"   r)   r%   r  r  &  s6     & &1"r)   r  c                  V    \ rS rSr% Sr\R                  " \S9rS\	S'       S	S jr
Srg)
ContainerDependenciesChangeiE  a5  Sets container dependencies.

Updates container dependencies to add the dependencies in new_depencies.
Additionally, dependencies to or from a container which does not exist will be
removed.

Attributes:
    new_dependencies: A map of containers to their updated dependencies.
      Defaults to an empty map.
r   zMapping[str, Iterable[str]]new_dependenciesc                   [        UR                  R                  R                  5       5      nUR                  R                  nUR                  5        VVVs0 s H&  u  pEXB;   d  M  XE Vs/ s H  ofU;   d  M
  UPM     sn_M(     nnnnU R                  R                  5        H  u  puU(       d   UR                  R                  R                  n[        U5      nXR-
  nU(       a5  [        R                  " SR                  USR                  U5      5      5      eU(       a  [        U5      X7'   M  X7	 M     X1R                  l        U$ s  snf s  snnnf )NzD--depends_on for container {} references nonexistent containers: {}.r   )r{   rP   rQ   r   dependenciesr   r  rK   r  r   ru  rv  r   sorted)	r$   r,   rQ   r  rH   
depends_onr]   rK   missings	            r%   r-   "ContainerDependenciesChange.AdjustV  s3    8,,77<<>?J$$11L +7*<*<*>*>&N' 	CJBJqz/JBB*>   "&!6!6!<!<!>	%%//44	Z(j'g	++%vi'1BC
 	

 
"("4# "?  &2"O- Cs$   E'E+	E8E>EEr"   Nr  )r/   r0   r1   r2   r3   r   r   r   r  rV   r-   r7   r"   r)   r%   r  r  E  s:    	 3>2C2C3/ 1"r)   r  c                  4    \ rS rSr% SrS\S'   S\S'   S rSrg	)
RemoveVolumeChangeiv  ziRemoves volumes from the service or job template.

Attributes:
  removed_volumes: The volumes to remove.
r
  removed_volumesrd   clear_volumesc                4   U R                   (       aA  [        UR                  R                  5      nU H  nUR                  R                  U	 M     U$ U R                   H5  nXAR                  R                  ;   d  M  UR                  R                  U	 M7     U$ rg   )r  r   rP   r   r  )r$   r,   volsr3  r  s        r%   r-   RemoveVolumeChange.Adjust  s    (##++,d#%%c*  O ++)))111''	2 , Or)   r"   Nr   r"   r)   r%   r  r  v  s     ! 
r)   r  c                  4    \ rS rSr% SrS\S'   S\S'   S rSrg	)
AddVolumeChangei  zUpdates Volumes set on the service or job template.

Attributes:
  new_volumes: The volumes to add.
  release_track: The resource's release track. Used to verify volume types are
    supported in that release track.
Collection[Mapping[str, str]]r1  r  release_trackc                    U R                    HH  n[        R                  " UUR                  R                  UR	                  5       U R
                  5        MJ     U$ rg   )r1  r   
add_volumerP   rR   r!  )r$   r,   r  s      r%   r-   AddVolumeChange.Adjust  sN    ""




#
#

!
!
#


	 # Or)   r"   Nr   r"   r)   r%   r  r    s     -,""r)   r  c                  X    \ rS rSr% Sr\R                  " \S9rS\	S'   Sr
S\	S'   S	 rS
rg)RemoveVolumeMountChangei  z~Removes Volume Mounts from the container.

Attributes:
  removed_mounts: Volume mounts to remove from the adjusted container.
r   r  removed_mountsFrd   clear_mountsc                    U R                   (       a-  [        UR                  5      nU H  nUR                  U	 M     U$ U R                   H!  nXQR                  ;   d  M  UR                  U	 M#     U$ rg   )r(  r   rg  r'  )r$   rK   rL   r   rk  r  s         r%   rM   'RemoveVolumeMountChange.AdjustContainer  sq     )))*d%##E*   **)///%%i0 + r)   r"   N)r/   r0   r1   r2   r3   r   r   r   r'  rV   r(  rM   r7   r"   r)   r%   r&  r&    s-     %0$5$5d$K./K,r)   r&  c                  J    \ rS rSr% Sr\R                  " \S9rS\	S'   S r
Srg)	AddVolumeMountChangei  zpUpdates Volume Mounts set on the container.

Attributes:
  new_mounts: Mounts to add to the adjusted container.
r   r   
new_mountsc                    U R                    H:  nSU;  d  SU;  a  [        R                  " S5      eUS   UR                  US   '   M<     U$ )Nr&  z
mount-pathz<Added Volume mounts must have a `volume` and a `mount-path`.)r-  r   ru  rg  )r$   rK   rL   rk  s       r%   rM   $AddVolumeMountChange.AdjustContainer  sX    		,e";++J
 	
 6;8_ieL12 ! r)   r"   N)r/   r0   r1   r2   r3   r   r   r   r-  rV   rM   r7   r"   r)   r%   r,  r,    s)     /:.?.?/*+ r)   r,  c                  4    \ rS rSr% SrS\S'   S\S'   S rSrg)	SetServiceMeshChangei  a  Sets the service mesh annotation on the service template.

Attributes:
  project: The project to use for the mesh when not specified in mesh_name.
  mesh: Mesh resource name in the format of MESH_NAME or
    projects/PROJECT/locations/global/meshes/MESH_NAME.
r   r  	mesh_namec                    SU R                   ;   a  U R                   OSU R                   SU R                    3UR                  R                  [        R
                  '   U$ )Nra  z	projects/z/locations/global/meshes/)r2  r  rP   r   r   MESH_ANNOTATIONr+   s     r%   r-   SetServiceMeshChange.Adjust  sV     $..  	&??OP !!(":":;
 Or)   r"   Nr   r"   r)   r%   r1  r1    s     ,.r)   r1  c                  b    \ rS rSr% SrS\S'   \R                  " \S9r	S\S'   Sr
S	\S
'   S rSrg)PresetChangei  zSets the preset annotation on the service template.

Attributes:
  type: The type of preset to use.
  config: The config to use for the preset.
  flatten: Whether to flatten the preset values into the service template.
r   typer   r~  configTrd   flattenc                   / n[         R                  UR                  ;   a1  [        R                  " UR                  [         R                     5      nU(       aJ  US   S   U R
                  :w  a4  UR                  U R
                  U R                  U R                  S.5        O%U R
                  U R                  U R                  S./n[        R                  " U5      UR                  [         R                  '   U$ )Nr   r8  )r8  r9  r:  )
r   PRESETS_ANNOTATIONr   r   r   r8  r	  r9  r:  r   r$   r,   presetss      r%   r-   PresetChange.Adjust  s     G!!X%9%99

8//0J0JKLg71:f%2nn))KK\\ 	 ))KK\\ 	g
 8<zz'7JH334Or)   r"   N)r/   r0   r1   r2   r3   rV   r   r   r   r9  r:  r-   r7   r"   r)   r%   r7  r7    s3     	))//E&
E'4r)   r7  c                  *    \ rS rSr% SrS\S'   S rSrg)RemovePresetsChangei	  zRemoves one or more presets from annotation from the service metadata.

Attributes:
  clear_presets: Whether to clear all presets.
rd   clear_presetsc                    [         R                  " UR                  R                  [        R
                  S5      5      nU(       a/  U R                  (       a  UR                  [        R
                  	 U$ g g )Nz[])r   r   r   rr   r   r<  rB  r=  s      r%   r-   RemovePresetsChange.Adjust	  sY    jj  !;!;TBG 4%%


w99
:o &wr)   r"   Nr   r"   r)   r%   rA  rA  	  s     r)   rA  )r[  MutableMapping[str, str]r\  r  r]  rd   )rg  rE  rh  r  r]  rd   ri  r_  )r  rU   r  r   r  zrun_v1_messages.Probe)r3   
__future__r   r   r   r   r   r5   argparser+  collections.abcr   r	   r
   r   r   rt   r   r  r   typestypingr   r   googlecloudsdk.api_lib.runr   r   r   r   r   r   googlecloudsdk.callioper   googlecloudsdk.command_lib.runr   r   r   r   r   $googlecloudsdk.command_lib.util.argsr   r   ,googlecloudsdk.generated_clients.apis.run.v1r   sixwith_metaclassABCMetarR  r   r9   r?   	dataclassrE   rZ   r^   r`   r~   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r,  r2  r=  rC  rI  rN  r_  ro  rd  r}  r  r  r  r  r  r  r  r  r  r  r  r  r  r!  rr  r'  r)  rC  rR  r[  rk  ro  rv  r  r  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r&  r,  r1  r7  rA  r"   r)   r%   <module>rT     s   A & "  % ' 
   T T        9 * 1 / . 2 ( 5 9 4 : 2 < 9 H 
C&&s{{F; *} M  d#*2 * $*Z"4
 d#0= 0 $0f*  d#/  $0 d#3  $> d# 6   $ 4 d/"| " 0"6 d#2  $  d#5  $  d#"7  $  d#%:  $  d#D!6 D $DN d#;3 ; $;| d#$1K $ $$6 d#%=  $& d#!9  $  d#$<  $B d#":  $  d#!m ! $!H d#)  $  d#.  $ 	3 	 E$/!( ! 0!"
!%
!#
! 
!!5 ,!5 	!5
 !5 $!5H: d#'1 ' $'T d#2/ 2 $2jD2 DN d#?, ? $?6//*8//d d#E0 E $E$ d#F1 F $F$ d#G2 G $G$ d#U+ U $Up d#.  $4 d#*  $ d#1  $   d#/  $0O
&	 d#c/ c $cLK2 K\.   d#)- ) $)X d#0  $  E$/%3 % 0%" E$/0  0"  d#.90 .9 $.9b d#"7  $  d#/  $ d#1  $$ d#0  $ d#/  $  d#1  $  d#-  $  d#/  $  d#/  $  d#93 9 $9x d#	#8 	 $	 d#,2 , $,^ d#)  $ d#)  $* d#4  $  d#2  $< d#-"7 - $-` d#.  $. d#+  $. d#4  $0 d#1  $* d#0  $* d#!( ! $!H d#/  $r)   