
                 	       H   S r SSKrSSKrSSKrSSKJr  SSKJr  SSK	J
r
  SSK	Jr  S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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/J0r0  SS K/J1r1  \Rd                  " S!S"S#9r3\Rd                  " S$S%S&S'9r4\Rd                  " S(S)\Rj                  S&S*9r6\Rd                  " S+S,\Rn                  \8S-S./S&S/9r9\:" / S0Q5      r;\:" S1/5      r<\:" S2/5      r=S3S4S5.r>S6S7S8S9.r?S:S;S<.r@S=S>S?.rAS@rBSASBSC.rC\R                  " SDSE5      rESFrFSGrGSH rHSI rI " SJ SK\R                  5      rK " SL SM\R                  5      rM  GS)SO jrN   GS*SP jrOGS+SQ jrPSR rQSS rRGS,ST jrSSU rTSV rUSW rVSX rWSY rXSZ rYS[ rZS\ r[S] r\S^ r]S_ r^S` r_Sa r`Sb raSc rbSdrc\c4Se jrdSf reSg rfSh rgSi rhSj riSk rjSl rkSm rlSn rmSo rn       GS-Sp jro      GS.Sq jrpSr rq\R                  R                  4Ss jrtSt ruSu rvSv rwSw rxSx rySy rzSz r{S{ r|S| r}S} r~S~ rS rSrSrSrS rS rS rS rS rS rS rS rGS+S jrS rS rGS,S jrS rS rS rS rS rS rS r\o" SSS&S9rS rGS/S jrS rS r " S S5      r " S S5      r " S S5      rS	S jrS rS rS rS	S jr\R                  R                  S4S jrS rS rGS,S jrGS,S jrS rS rS rGS,S jrS rS rS rGS0S jrGS0S jrGS0S jrS rSr\4S jr\4S jrS rS rS rS rGS,S jrS rGS,S jrGS,S jrGS0S jrS rS	S jrS	S jrS	S jrS	S jrS	S jrGS1S jrS	S jrS	S jrS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rGS2S jrS rS rS rS rS rSrSrS rS rS rS rS rS rS r\R                  R                  4S jrS rS rGS2S jrS r\R                  R                  4S jrGS2S jr\R                  R                  4S jrS rS rGS  rGS rGS rGS3GS jrGS r GS4GS jGr GS2GS jGrGS GrGS GrGS	 GrGS
 GrGS GrGS GrGS GrGS Gr	GS Gr
GS GrSNS&\R                  R                  4GS jGrGS GrGS GrGS GrGS2GS jGrGS GrGS GrGS GrGS GrGS GrGS GrGS GrGS GrGS GrGS GrGS  GrGS!\84GS" jGrGS# GrGS$ GrGS% GrGS& Gr GS' Gr!GS( Gr"g(5  z6Provides common arguments for the Run command surface.    N)
exceptions)
kubeconfig)container_resource)global_methods)
k8s_object)revision)service)traffic)
enable_api)actions)arg_parsers)base)env_vars_util)config_changes)	platforms)
preset_arg)pretty_print)resource_args)secrets_mapping)volumes)labels_util)map_util)repeated)concept_parsers)config)log)
properties)
console_io)encoding)filesz--meshzEnables Cloud Service Mesh using the specified mesh resource name. Mesh resource name must be in the format of projects/PROJECT/locations/global/meshes/MESH_NAME or MESH_NAME. Will default to the current project if only MESH_NAME is provided.helpz
--identityzyConfigures a managed workload identity to be used by the service. Must have the form //TRUST_DOMAIN/ns/NAMESPACE/sa/NAME.T)r"   hiddenz--enable-workload-certificatez>Enables workload certificates using managed workload identity.)r"   actionr#   z--mesh-dataplanez7Configures the mesh dataplane mode used by the Service.sidecarzproxyless-grpc)r"   r$   typechoicesr#   )ollamazstatic-website
tagmanagerzprivate-servicezpublic-servicez Visible only within the cluster.z!Visible from outside the cluster.)internalexternalz.Inbound requests from all sources are allowed.a          For Cloud Run, only inbound requests from VPC networks
        in the same project or VPC Service Controls perimeter, as well as
        Pub/Sub subscriptions and Eventarc events in the same project or VPC
        Service Controls perimeter are allowed. All other requests are rejected.
        See https://cloud.google.com/run/docs/securing/ingress for full details
        on the definition of internal traffic for Cloud Run.
        z        Only inbound requests from Google Cloud Load Balancing or a traffic
        source allowed by the internal option are allowed.
        )allr*   z!internal-and-cloud-load-balancingz@Run the application in a first generation execution environment.zARun the application in a second generation execution environment.)gen1gen2z2The system will start the job as soon as possible.zWThe system will start the job within the next 6 hours depending on available capacity.")standardflexz~/.kube/configz        No new instances will be started and the existing instances will be shut
        down after CMEK key revocation.
        z;No new instances will be started after CMEK key revocation.)z	shut-downzprevent-newz#[a-z0-9]([a-z0-9-.]{0,61}[a-z0-9])?zmust conform to RFC 1123: only lowercase, digits, hyphens, and periods are allowed, must begin and end with letter or digit, and less than 64 characters.	automaticmanualc                 v    U R                  5        VVs0 s H  u  pUR                  5       U_M     snn$ s  snnf N)itemsstrip)dkvs      +lib/googlecloudsdk/command_lib/run/flags.py	StripKeysr;      s,    #$779	-941!'')Q,9	--	-s   5c                 L    U  Vs/ s H  oR                  5       PM     sn$ s  snf r4   )lstrip)seqelems     r:   	MapLStripr@      s    $'	(CD++-C	((	(s   !c                       \ rS rSrSrg)KubeconfigError    N)__name__
__module____qualname____firstlineno____static_attributes__rD       r:   rB   rB      s    rJ   rB   c                        \ rS rSrSrSrSrSrg)Product   RunEventsStacksrD   N)rE   rF   rG   rH   RUNEVENTSSTACKSrI   rD   rJ   r:   rL   rL      s    #&&rJ   rL   1us-docker.pkg.dev/cloudrun/container/hello:latestc                 @    U R                  SUSR                  US9S9  g)zAdd an image resource arg.--image7Name of the container image to deploy (e.g. `{image}`).imagerequiredr"   Nadd_argumentformat)parserr[   rY   s      r:   AddImageArgr`      s4     	DKK L   rJ   c                 d    SR                  US9nU(       d  US-  n[        R                  " SU US9$ )zImage resource arg.rW   rX   a   When used with --source, the image must be the URI of an Artifact Registry Docker repository in the Docker format ($REGION-docker.pkg.dev/$PROJECT/$REPOSITORY") or ($REGION-docker.pkg.dev/$PROJECT/$REPOSITORY/$IMAGE_NAME"). The image name must be the same as the name of the service.rV   rZ   )r^   r   Argument)r[   rY   mutex	help_texts       r:   ImageArgre      sO     HNN O ) 
	FI 

 rJ   c                    U(       a	  U(       a   e[        XU5        U(       a  [        U 5        gU(       d  [        U 5        [        R                  " [        R
                  /5      R                  U 5        [        U 5        g)zGAdds flags used to determine the platform and the location of resource.N)AddPlatformArgAddRegionArgr   ConceptParserr   CLUSTER_PRESENTATIONAddToParserAddKubeconfigFlags)r_   managed_onlyanthos_onlys      r:   AddPlatformAndLocationFlagsro      s`    {+	+{3	 ))*K VrJ   c                 B    U R                  S[        R                  SS9  g)z%Add the --allow-unauthenticated flag.z--allow-unauthenticatedzmWhether to enable allowing unauthenticated access to the service. This may take a few moments to take effect.r$   r"   Nr]   r   StoreTrueFalseActionr_   s    r:   AddAllowUnauthenticatedFlagru      s&    --8	  rJ   c           
      n    U R                  S[        R                  " SSS[        R                  S9SSS9  g)	z'Add the --allow-unencrypted-build flag.z--allow-unencrypted-buildFzThe flag {flag_name} is deprecated. The CMEK compliance is now available for the build process of source-based deployments. For more details, see https://cloud.google.com/run/docs/securing/using-cmek#source-deploy)removedwarnr$   zWhether to allow customer-managed encryption key (CMEK) deployments without encrypting the build process. This means that only the deployed container will be encrypted.T)r$   r"   r#   N)r]   r   DeprecationActionr   rs   rt   s    r:   AddAllowUnencryptedBuildFlagrz      sG    !&&
%U
 11
3 %  rJ   c                     SnU(       a7  [         R                  " S[        R                  SUS9nUR	                  U 5        g[         R
                  R	                  U 5        g)zAdd an async flag.zn    Return immediately, without waiting for the operation in progress to
    complete. Defaults to --no-async.z--asyncasync_)r$   destr"   N)r   rb   r   rs   rk   
ASYNC_FLAG)r_   default_async_for_clusterrd   modified_async_flags       r:   AddAsyncFlagr     sQ    )) --//	 ##F+OO'rJ   c                 X    U R                  SS[        S[        R                  " SSS9S9  g)z0Add the --connectivity=[external|internal] flag.z--connectivityTzDefaults to 'external'. If 'external', the service can be invoked through the internet, in addition to through the cluster network.zoThe {flag_name} flag is deprecated but will continue to be supported. Prefer to use the --ingress flag instead.)rx   )r#   r'   r"   r$   N)r]   _VISIBILITY_MODESr   ry   rt   s    r:   AddEndpointVisibilityEnumr   (  s<     &&
E  rJ   c                 D    U R                  S[        R                  SSS9  g)zAdds the --iap flag.--iapFz&Whether to enable IAP for the Service.)r$   r[   r"   Nrr   rt   s    r:   
AddIapFlagr   =  s'    --3	  rJ   c                 0    U R                  S[        SSS9  g)zAdds the --ingress flag.z	--ingresszSet the ingress traffic sources allowed to call the service. For Cloud Run the `--[no-]allow-unauthenticated` flag separately controls the identities allowed to call the service.r,   )r'   r"   defaultN)r]   _INGRESS_MODESrt   s    r:   AddIngressFlagr   G  s&    L   	rJ   c                 &    U R                  SSSS9  g)zAdd a service resource flag.z	--serviceFz-Limit matched revisions to the given service.rZ   Nr]   rt   s    r:   AddServiceFlagr   U  s    :  rJ   c                 &    U R                  SSSS9  g)zAdd a job resource flag.z--jobFz)Limit matched resources to the given job.rZ   Nr   rt   s    r:   
AddJobFlagr   ^  s    $O  rJ   c                 (    U R                  SSSSS9  g)zAdd a worker resource flag.z--workerFT,Limit matched revisions to the given worker.)r[   r#   r"   Nr   rt   s    r:   AddWorkerFlagr   e  s!    9	  rJ   c                 &    U R                  SSSS9  g)z Add a worker pool resource flag.z--worker-poolFr   rZ   Nr   rt   s    r:   AddWorkerPoolFlagr   o  s    9  rJ   c                 $    U R                  SSS9  g)zAdd a region arg.--regionzXRegion in which the resource can be found. Alternatively, set the property [run/region].r!   Nr   rt   s    r:   rh   rh   x  s    :  rJ   c                 &    U R                  SSSS9  g)zAdd an instance arg for SSH.z
--instanceFz&ID of a specific instance to SSH into.rZ   Nr   rt   s    r:   AddInstanceArgr     s    3  rJ   c                 &    U R                  SSSS9  g)zAdd a container arg for SSH.--containerFz)name of a specific container to SSH into.rZ   Nr   rt   s    r:   AddContainerArgr     s    6  rJ   c                 (    U R                  SSSSS9  g)z.Add flag to deploy a revision with no traffic.z--no-trafficF
store_truea  True to avoid sending traffic to the revision being deployed. Setting this flag assigns any traffic assigned to the LATEST revision to the specific revision bound to LATEST before the deployment. The effect is that the revision being deployed will not receive traffic.

After a deployment with this flag the LATEST revision will not receive traffic on future deployments. To restore sending traffic to the LATEST revision by default, run the `gcloud run services update-traffic` command with `--to-latest`.r   r$   r"   Nr   rt   s    r:   AddNoTrafficFlagr     s$    F  rJ   c                 (    U R                  SSSSS9  g)zGAdds flag to deploy a worker revision with/without instance assignment.z--no-promoteFr   a  True to avoid assign instances to the worker revision being deployed. Setting this flag assigns any instances assigned to the LATEST revision to the specific revision bound to LATEST before the deployment. The effect is that the revision being deployed will not receive instance split.

After a deployment with this flag the LATEST revision will not receive instances on future deployments. To restore assinging instances to the LATEST revision by default, run the `gcloud run workers update-instance-split` command with `--to-latest`.r   Nr   rt   s    r:   AddNoPromoteFlagr     s#      rJ   c                 B    U R                  S[        R                  SS9  g)z@Adds flag for deploying a Cloud Run service with CPU throttling.z--cpu-throttlingzPWhether to throttle the CPU when the container is not actively serving requests.rq   Nrr   rt   s    r:   AddCpuThrottlingFlagr     s&    --	  rJ   c                 B    U R                  S[        R                  SS9  g)zCAdds flag for deploying a Cloud Run service with startup CPU boost.z--cpu-boostzWhether to allocate extra CPU to containers on startup to reduce the perceived latency of a cold start request. Enabled by default when unspecified on new services.rq   Nrr   rt   s    r:   AddStartupCpuBoostFlagr     s&    --*	  rJ   c                 $    U R                  SSS9  g )Nz--tokenzThe specific identity token to add to all requests of the proxied service. If not specified, the identity token of the currently active authenticated account will be used (e.g. gcloud auth print-identity-token).r!   r   rt   s    r:   AddTokenFlagr     s    5  rJ   z4Traffic tag to assign to the newly
created revision.c                 $    U R                  SUS9  g)z/Add flag to specify a tag for the new revision.z--tagr!   Nr   r_   rd   s     r:   AddDeployTagFlagr     s    gI.rJ   c                 2    U R                  S[        SSSS9  g)zTAdd argument to specify the compose yaml file to be used for deploying to Cloud Run.compose_file?NzFThe compose yaml file to deploy from a Compose directory to Cloud Run.)r&   nargsr   r"   )r]   strrt   s    r:   AddDeployFromComposeArgumentr     s&    $  	rJ   c                     [        U SSSSS9  g)z2Add flags for updating traffic tags for a service.a#  Specify traffic tags. Traffic tags can be assigned to a revision by name or to the latest ready revision. Assigning a tag to a revision generates a URL prefixed with the tag that allows addressing that revision directly, regardless of the percent traffic specified. Keys are tags. Values are revision names or "LATEST" for the latest ready revision. For example, --set-tags=candidate=LATEST,current=myservice-v1 assigns the tag "candidate" to the latest ready revision and the tag "current" to the revision with name "myservice-v1" and clears any existing tags. Changing tags does not affect the traffic percentage assigned to revisions. When using a tags flag and one or more of --to-latest and --to-revisions in the same command, the tags change occurs first then the traffic percentage change occurs.tagsTAGREVISION)
group_help	flag_namekey_metavarvalue_metavarN)AddMapFlagsNoFilert   s    r:   AddTrafficTagsFlagsr     s    &( 3rJ   c           
         [         S 5       n[         S 5       nU R                  5       nUR                  SS[        R                  [        R
                  " UR                  UR                  S9SS9  UR                  SS	[        R                  [        R
                  " UR                  UR                  S9S
S9  UR                  SSSSS9  g)z9Add flags for updating traffic assignments for a service.c                     U $ r4   rD   keys    r:   TrafficTargetKey/AddUpdateTrafficFlags.<locals>.TrafficTargetKey      JrJ   c                      [        U 5      nUS:  d  US:  a  [        R                  " SU -  5      eU$ ! [        [        4 a    [        R                  " SU -  5      ef = f)z3Type validation for traffic percentage flag values.z.Traffic percentage value %s is not an integer.r   d   z5Traffic percentage value %s is not between 0 and 100.int	TypeError
ValueErrorserverless_exceptionsArgumentErrorvalueresults     r:   TrafficPercentageValue5AddUpdateTrafficFlags.<locals>.TrafficPercentageValue  sr    5zf zVc\!//
AE
I  M z" !//
:U
B 	   4 *A--to-revisionsREVISION-NAME=PERCENTAGEkey_type
value_typeaf  Comma separated list of traffic assignments in the form REVISION-NAME=PERCENTAGE. REVISION-NAME must be the name for a revision for the service as returned by 'gcloud beta run list revisions'. PERCENTAGE must be an integer percentage between 0 and 100 inclusive.  Ex service-nw9hs=10,service-nw9hs=20 Up to 100 percent of traffic may be assigned. If 100 percent of traffic is assigned,  the Service traffic is updated as specified. If under 100 percent of traffic is assigned, the Service traffic is updated as specified for revisions with assignments and traffic is scaled up or down down proportionally as needed for revision that are currently serving traffic but that do not have new assignments. For example assume revision-1 is serving 40 percent of traffic and revision-2 is serving 60 percent. If revision-1 is assigned 45 percent of traffic and no assignment is made for revision-2, the service is updated with revsion-1 assigned 45 percent of traffic and revision-2 scaled down to 55 percent. You can use "LATEST" as a special revision name to always put the given percentage of traffic on the latest ready revision.metavarr$   r&   r"   z	--to-tagszTAG=PERCENTAGEa  Comma separated list of traffic assignments in the form TAG=PERCENTAGE. TAG must match a traffic tag on a revision of the service. It may match a previously-set tag, or one assigned using the `--set-tags` or `--update-tags` flags on this command. PERCENTAGE must be an integer percentage between 0 and 100 inclusive. Up to 100 percent of traffic may be assigned. If 100 percent of traffic is assigned, the service traffic is updated as specified. If under 100 percent of traffic is assigned, the service traffic is updated as specified to the given tags, and other traffic is scaled up or down proportionally. For example, assume the revision tagged `next` is serving 40 percent of traffic and the revision tagged `current` is serving 60 percent. If `next` is assigned 45 percent of traffic and no assignment is made for `current`, the service is updated with `next` assigned 45 percent of traffic and `current` scaled down to 55 percent. --to-latestFr   zTrue to assign 100 percent of traffic to the 'latest' revision of this service. Note that when a new revision is created, it will become the 'latest' and traffic will be directed to it. Defaults to False. Synonymous with '--to-revisions=LATEST=100'.r   Nstaticmethodadd_mutually_exclusive_groupr]   r   UpdateActionArgDict__func__)r_   r   r   groups       r:   AddUpdateTrafficFlagsr     s         
-
-
/%(%%#,,+44
+  < %%#,,+44
B  6 )  rJ   c           
         [         S 5       n[         S 5       nU R                  5       nUR                  SS[        R                  [        R
                  " UR                  UR                  S9SS9  UR                  SS	S
SS9  g)z9Add flags for updating instance assignments for a worker.c                     U $ r4   rD   r   s    r:   InstanceSplitTargetKey;AddUpdateInstanceSplitFlags.<locals>.InstanceSplitTargetKeyz  r   rJ   c                      [        U 5      nUS:  d  US:  a  [        R                  " SU -  5      eU$ ! [        [        4 a    [        R                  " SU -  5      ef = f)z9Type validation for intance split percentage flag values.z5Instance split percentage value %s is not an integer.r   r   z<Instance split percentage value %s is not between 0 and 100.r   r   s     r:   InstanceSplitPercentageValueAAddUpdateInstanceSplitFlags.<locals>.InstanceSplitPercentageValue~  sr    5zf zVc\!//
H5
P  M z" !//
AE
I r   r   r   r   a  Comma separated list of instance assignments in the form REVISION-NAME=PERCENTAGE. REVISION-NAME must be the name for a revision for the worker as returned by 'gcloud run workers revisions list --worker=WORKER' . PERCENTAGE must be an integer percentage between 0 and 100 inclusive.  Ex worker-nw9hs=10,worker-nw9hs=20 Up to 100 percent of instances may be assigned. If the total of 100 percent of instances is assigned, the Worker instance split is updated as specified. If under 100 percent of instance split is assigned, the Worker instance split is updated as specified for revisions with assignments and instance split is scaled up or down proportionally as needed for revision that are currently serving workload but that do not have new assignments. For example assume revision-1 is serving 40 percent of workload and revision-2 is serving 60 percent. If revision-1 is assigned 45 percent of instances and no assignment is made for revision-2, the worker is updated with revsion-1 assigned 45 percent of instances and revision-2 scaled down to 55 percent. You can use "LATEST" as a special revision name to always put the given percentage of instance split on the latest ready revision.r   r   Fr   a;  True to assign 100 percent of instances to the 'latest' revision of this service. Note that when a new revision is created, it will become the 'latest' and instances will be fully assigned to it unless configured otherwise using `--[no-]promote` flag. Defaults to False. Synonymous with '--to-revisions=LATEST=100'.r   Nr   )r_   r   r   r   s       r:   AddUpdateInstanceSplitFlagsr   w  s         
-
-
/%(%%)221::
H  > D  rJ   c                 N    U R                  S[        R                  " 5       SSS9  g)z+Add only the --set-cloudsql-instances flag.z--set-cloudsql-instanceszCLOUDSQL-INSTANCESzYou can specify a name of a Cloud SQL instance if it's in the same
      project and region as your Cloud Run resource; otherwise specify
      <project>:<region>:<instance> for the instance.)r&   r   r"   N)r]   r   ArgListrt   s    r:   AddSetCloudSQLFlagr     s,      "9	  rJ   c           	      6    [         R                  " U SSSSSS9  g)z%Add flags for setting CloudSQL stuff.Servicezcloudsql-instanceszCloud SQL instancesFa        These flags modify the Cloud SQL instances this Service connects to.
      You can specify a name of a Cloud SQL instance if it's in the same
      project and region as your Cloud Run service; otherwise specify
      <project>:<region>:<instance> for the instance.auto_group_helpadditional_helpNr   AddPrimitiveArgsrt   s    r:   AddCloudSQLFlagsr     s$    
9rJ   c           
         U R                  5       nU[        R                  R                  :X  a>  UR	                  S[
        R                  " S/S9SSS[        R                  " U5      -   S9  O>UR	                  S[
        R                  " SS/S9SSS	[        R                  " U5      -   S9  UR	                  S
[
        R                  " 5       [
        R                  SSS9  UR	                  SSSS9  g)z*Add flags for adding and removing volumes.--add-volumer&   )required_keysappend	KEY=VALUEa  Adds a volume to the Cloud Run resource. To add more than one volume, specify this flag multiple times. Volumes must have a `type` key. Volumes must have a `name` key if `mount-path` is not specified. A `name` key is optional if `mount-path` is specified.Only certain values are supported for `type`. Depending on the provided type, other keys will be required. The following types are supported with the specified additional keys:

)r&   r$   r   r"   nameaE  Adds a volume to the Cloud Run resource. To add more than one volume, specify this flag multiple times. Volumes must have a `name` and `type` key. Only certain values are supported for `type`. Depending on the provided type, other keys will be required. The following types are supported with the specified additional keys:

z--remove-volumeVOLUMEz,Removes volumes from the Cloud Run resource.z--clear-volumesr   z]Remove all existing volumes from the Cloud Run resource, including volumes mounted as secretsrq   N)	add_groupr   ReleaseTrackALPHAr]   r   r   r   volume_helpr   r   )r_   release_trackr   s      r:   AddVolumesFlagsr     s
   



%d''---	  x8D !!-01  $ 
  /?@D !!-01    %%9   (	  rJ   c            	      b    S n [         R                  " SS[        R                  " SS/U S9SSS	9$ )
z1Returns container flag for adding a volume mount.c                 \    U S;  a%  [         R                  " SR                  U 5      5      eU $ )N>   volume
mount-pathz[Key [{}] not recognized for volume mount. Only keys "volume" and "mount-path" are supportedr   r   r^   r   s    r:   _LimitMountKeys+AddVolumeMountFlag.<locals>._LimitMountKeys  s3    
**!//((.s  JrJ   z--add-volume-mountr   r  r  )r   r   z!volume=NAME,mount-path=MOUNT_PATHzAdds a mount to the current container. Must contain the keys `volume=NAME` and `mount-path=/PATH` where NAME is the name of a volume on this resource and PATH is the path within the container's filesystem to mount this volume.r$   r&   r   r"   )r   rb   r   r   )r  s    r:   AddVolumeMountFlagr	    sB     
!<0? 2:
 rJ   c                  t    [         R                  " S[        R                  [        R                  " 5       SSS9$ )z3Returns container flag for removing a volume mount.z--remove-volume-mount
MOUNT_PATHzLRemoves the volume mounted at the specified path from the current container.r  )r   rb   r   r   r   rD   rJ   r:   RemoveVolumeMountFlagr  *  s3    	%% 	
 	rJ   c                  .    [         R                  " SSSS9$ )z2Returns container flag for clearing volume mounts.z--clear-volume-mountsr   z6Remove all existing mounts from the current container.rq   r   rb   rD   rJ   r:   ClearVolumeMountsFlagr  8  s    	C
 rJ   c                    U(       d  U n[         R                  " SXS9n[         R                  " SR                  U 5      S9n	U	R                  [        R
                  " U UUUUUS95        U	R                  [        R                  " U UUUS95        UR                  U	5        UR                  [        R                  " X5      5        UR                  [        R                  " U UUUUUS95        U$ )a4  Create an argument group like map_util.AddUpdateMapFlags but without the file one.

Args:
  flag_name: The name for the property to be used in flag names
  group_help: Help text for the group of flags
  long_name: The name for the property to be used in help text
  key_type: A function to apply to map keys.
  value_type: A function to apply to map values.
  key_metavar: Metavariable to list for the key.
  value_metavar: Metavariable to list for the value.
  hidden: Whether the group should be hidden.

Returns:
  A mutually exclusive group for the map flags.
T)rc   r"   r#   zsOnly --update-{0} and --remove-{0} can be used together. If both are specified, --remove-{0} will be applied first.r!   )r   r   r   r   )r   r   )	r   ArgumentGroupr^   AddArgumentr   MapUpdateFlagMapRemoveFlagMapClearFlag
MapSetFlag)
r   r   	long_namer   r   r   r   r#   r   update_remove_groups
             r:   MapFlagsNoFiler  A  s    2 
I


4j
H%**?y	 !!

!%	 !!

!	 '(H)))?@

!%	 
,rJ   c           
      >    [        UUUUUUUS9R                  U 5      $ )a  Add flags like map_util.AddUpdateMapFlags but without the file one.

Args:
  parser: The argument parser
  flag_name: The name for the property to be used in flag names
  group_help: Help text for the group of flags
  long_name: The name for the property to be used in help text
  key_type: A function to apply to map keys.
  value_type: A function to apply to map values.
  key_metavar: Metavariable to list for the key.
  value_metavar: Metavariable to list for the value.

Returns:
  A mutually exclusive group for the map flags.
)r   r   )r  rk   )r_   r   r   r  r   r   r   r   s           r:   r   r     s2    2 
!
 KrJ   c           
          U R                  SS[        R                  [        R                  " [        R
                  [        R                  S9SS9  g)z!Add only the --set-env-vars flag.z--set-env-varsr   r   z8List of key-value pairs to set as environment variables.r   N)r]   r   r   r   r   EnvVarKeyTypeEnvVarValueTypert   s    r:   AddSetEnvVarsFlagr    sJ    %% .."22 F  	rJ   c                    A [        SS[        R                  [        R                  S9nUR	                  [
        R                  " SS[        R                  " [        R                  [        R                  S9SS95        U$ )	zBReturn argument group for setting, updating and deleting env vars.zenv-varszenvironment variablesr  r   r   --env-vars-file	FILE_PATHr   a  Path to a local YAML or ENV file with definitions for all environment
            variables. All existing environment variables will be removed before
            the new environment variables are added. Example YAML content:

              ```
              KEY_1: "value1"
              KEY_2: "value 2"
              ```
              Example ENV content:

              ```
              KEY_1="value1"
              KEY_2="value 2"
              ```
            r   r&   r"   )	r  r   r  r  r  r   rb   r   ArgDictWithYAMLOrEnv)r   r   s     r:   MutexEnvVarsFlagsr%    su    
'**..	% 
mm
,,$22&662 
,rJ   c                      [        SS[        R                  [        R                  S9n U R	                  [
        R                  " SS[        R                  " [        R                  [        R                  S9SS95        U $ )	zHReturn argument group for setting, updating and deleting build env vars.zbuild-env-varszbuild environment variablesr   z--build-env-vars-filer"  r   ag  Path to a local YAML file with definitions for all build
            environment variables. All existing build environment variables will
            be removed before the new build environment variables are added.
            Example YAML content:

              ```
              KEY_1: "value1"
              KEY_2: "value 2"
              ```
            r#  )	r  r   r  r  r  r   rb   r   ArgDictFiler   s    r:   MutexBuildEnvVarsFlagsr)    sr    
-**..	% 
mm
!##$22&66	( 
,rJ   c                 4    [        5       R                  U 5      $ )z6Add flags for setting, updating and deleting env vars.)r%  rk   rt   s    r:   AddMutexEnvVarsFlagsr+    s    			(	(	00rJ   c           	          U R                  5       n[        U5        UR                  SS[        R                  " [
        R                  [
        R                  S9SS9  g)zAdd flags for setting env vars.r!  r"  r   zPath to a local YAML file with definitions for all environment
            variables. Example YAML content:

              ```
              KEY_1: "value1"
              KEY_2: "value 2"
              ```
            r#  N)r   r  r]   r   r'  r   r  r  r_   r   s     r:   AddMutexEnvVarsFlagsForCreater.     sV    

-
-
/%E .."22  rJ   c            
          [         R                  " SS[        R                  [        R                  " [
        R                  [
        R                  S9SS9$ )z7Creates a flag for overrding container's evn vars args.z--update-env-varsr   r   aP  List of key-value pairs to set as environment variables overrides for an execution of a job. If provided, an execution will be created with the merge result of the input values and the existing environment variables. New value overrides existing value if they have the same key. If not provided, existing environment variables are used.r   )r   rb   r   r   r   r   r  r  rD   rJ   r:   OverrideEnvVarsFlagr0    sG    	%% .."22

 rJ   c                 6    [        5       R                  U 5        g)zAdd the --update-env-vars flag.N)r0  rk   rt   s    r:   AddOverrideEnvVarsFlagr2  +  s    ##F+rJ   c                  ,    [         R                  " SSS9$ )Nz--memoryz$Set a memory limit. Ex: 1024Mi, 4Gi.r!   r  rD   rJ   r:   
MemoryFlagr4  0  s    	z(N	OOrJ   c                 6    [        5       R                  U 5        g r4   )r4  rk   rt   s    r:   AddMemoryFlagr6  4  s    ,6"rJ   c                  0    Sn [         R                  " SU S9$ )zCreate the --cpu flag.zSet a CPU limit in Kubernetes cpu units.

Cloud Run supports values fractional values below 1, 1, 2, 4, and 8.  Some CPU values requires a minimum Memory `--memory` value.z--cpur!   r  )help_msgs    r:   CpuFlagr9  8  s     F 
 
wX	..rJ   c                 6    [        5       R                  U 5        g)zAdd the --cpu flag.N)r9  rk   rt   s    r:   
AddCpuFlagr;  B  s    	)rJ   c                 &    U R                  SSSS9  g)zAdd the --gpu-type flag.z
--gpu-typeGPU_TYPEzThe GPU type to use.r   r"   Nr   rt   s    r:   AddGpuTypeFlagr?  G  s    !  rJ   c                  .    [         R                  " SSSS9$ )zAdd the --gpu flag.z--gpuGPUzvCloud Run supports values 0 or 1.  1 gpu also requires a minimum 4 `--cpu` value and  a minimum 16Gi `--memory` value.r>  r  rD   rJ   r:   GpuFlagrB  P  s    	/	
 rJ   c                 @    U R                  S[        R                  SS9$ )z$Add the --gpu-zonal-redundancy flag.z--gpu-zonal-redundancyzSet GPU zonal redundancy.rq   rr   rt   s    r:   GpuZonalRedundancyFlagrD  ]  s)    			--& 
 
 rJ   )initialDelaySecondstimeoutSecondsperiodSecondsfailureThresholdhttpGet.porthttpGet.path	grpc.portgrpc.service)	rE  rF  rG  rH  rI  rJ  rK  rL  ztcpSocket.port)rF  rG  rH  successThresholdrI  rJ  rK  rL  c                    ^ ^ U U4S jnSR                  T5      n[        R                  " SR                  T 5      S[        R
                  " US9ST  SU ST  S	T  S
3	R                  T US9S9$ )zCreate a flag for the given probe type.

Args:
  probe_type: Probe type, either 'startup' or 'liveness'
  supported_keys: supported keys for the given probe type

Returns:
  A flag.
c                 `   > U T;  a&  [         R                  " SR                  U T5      5      eU $ )Nz%Key [{}] not recognized for {} probe.r  )r   
probe_typesupported_keyss    r:   
_LimitKeys_ProbeFlag.<locals>._LimitKeys  s5    
. !//
1
8
8j
I  JrJ   z, z
--{}-prober   )r   z'          Comma separated settings for z probe in the form KEY=VALUE.
          Each key stands for a field of the probe described in
          https://cloud.google.com/run/docs/reference/rest/v1/Container#Probe.
          Currently supported keys are: z.

          For example, to set a probe with 10s timeout and HTTP probe requests
          sent to 8080 port of the container:

              $ --zc-probe=timeoutSeconds=10,httpGet.port=8080

          To remove existing probe:

              $ --z-probe=""
          )rP  rQ  r#  )joinr   rb   r^   r   r   )rP  rQ  rR  supported_keys_strs   ``  r:   
_ProbeFlagrV    s     yy0	*%((2| 4) *<(< =
 ,  ,  f
;MfN)
 rJ   c                  "    [        S[        5      $ )z Create the --startup-probe flag.startup)rV  _SUPPORTED_STARTUP_PROBE_KEYSrD   rJ   r:   StartupProbeFlagrZ    s    	I<	==rJ   c                  "    [        S[        5      $ )z!Create the --liveness-probe flag.liveness)rV  _SUPPORTED_LIVENESS_PROBE_KEYSrD   rJ   r:   LivenessProbeFlagr^    s    	J >	??rJ   c                  "    [        S[        5      $ )z"Create the --readiness-probe flag.	readiness)rV  _SUPPORTED_READINESS_PROBE_KEYSrD   rJ   r:   ReadinessProbeFlagrb    s    	K!@	AArJ   c                 X     U S:H  =(       d    [        U 5      S:  $ ! [         a     gf = f)z1Returns True if value is an int > 0 or 'default'.r   r   Fr   r   r   s    r:   _ConcurrencyValuerf    s1    I/Ua/	 s    
))c                 X    U R                  S[        R                  " [        S5      SS9  g )Nz--concurrencyz/must be an integer greater than 0 or "default".zSet the maximum number of concurrent requests allowed per container instance. Leave concurrency unspecified or provide the special value 'default' to receive the server default value.r&   r"   )r]   r   CustomFunctionValidatorrf  rt   s    r:   AddConcurrencyFlagrj    s2    ..
NI  
rJ   c                 J    U R                  S[        R                  " SS9SS9  g )Nz	--timeout1slower_boundzSet the maximum request execution time (timeout). It is specified as a duration; for example, "10m5s" is ten minutes, and five seconds. If you don't specify a unit, seconds is assumed. For example, "10" is 10 seconds.rh  r]   r   Durationrt   s    r:   AddTimeoutFlagrq    s+    D1	  	rJ   c                 (    SnU R                  SUS9  g)zAdd the --service-account flag.zthe email address of an IAM service account associated with the revision of the service. The service account represents the identity of the running revision, and determines what permissions the revision has. z--service-accountr!   Nr   r   s     r:   AddServiceAccountFlagrs    s#    N 
 	)	:rJ   c           	      P   U(       a	  U(       a   e[         R                  nU(       a  [         R                  nU(       a  [         R                  nU R	                  SU[
        R                  " [        R                  R                  R                  5      [         R                  SSS9  g)zAdd a platform arg.z
--platformTzVTarget platform for running commands. Alternatively, set the property [run/platform]. )r'   r$   r   r#   r"   N)r   	PLATFORMSPLATFORMS_MANAGED_ONLYPLATFORMS_ANTHOS_ONLYr]   r   StorePropertyr   VALUESrunplatformPLATFORM_MANAGED)r_   rm   rn   r'   s       r:   rg   rg     s~    {+	+'..G--G"":#4#4#8#8#A#AB((=  
rJ   c                 n    U R                  SSSR                  [        5      S9  U R                  SSSS9  g )N--kubeconfigTzThe absolute path to your kubectl config file. If not specified, the colon- or semicolon-delimited list of paths specified by $KUBECONFIG will be used. If $KUBECONFIG is unset, this defaults to `{}`.r#   r"   	--contextzJThe name of the context in your kubectl config file to use for connecting.)r]   r^   _DEFAULT_KUBECONFIG_PATHrt   s    r:   rl   rl     sM     &12  	 		  rJ   c                 $    U R                  SSS9  g )Nz--revision-suffixa2  Specify the suffix of the revision name. Revision names always start with the service name automatically. For example, specifying [--revision-suffix=v1] for a service named 'helloworld', would lead to a revision named 'helloworld-v1'. Set empty string to clear the suffix and resume server-assigned naming.r!   r   rt   s    r:   AddRevisionSuffixArgr    s    @  	rJ   c                 0    U R                  S[        USS9  g )N--execution-environmentzASelects the execution environment where the application will run.r'   r#   r"   )r]   _SANDBOX_CHOICESr_   r#   s     r:   AddSandboxArgr  &  s!    N	  rJ   c                 $    U R                  SSS9  g )N--vpc-connectorz&Set a VPC connector for this resource.r!   r   rt   s    r:   AddVpcConnectorArgr  /  s    3  rJ   c                 <    [        U 5        U R                  SSSS9  g )N--clear-vpc-connectorr   z+Remove the VPC connector for this resource.rq   )r  r]   rt   s    r:   AddVpcConnectorArgsr  6  s&    V8  rJ   c                     U R                  SS[        R                  S[        R                  S[        R                  SR                  [        R                  S90S9  g)	z9Adds a flag for configuring VPC egress for fully-managed.--vpc-egresszSpecify which of the outbound traffic to send through Direct VPC egress or the VPC connector for this resource. This resource must have Direct VPC egress enabled or a VPC connector to set this flag.ai  Default option. Sends outbound traffic to private IP addresses (RFC 1918 and Private Google Access IPs) through Direct VPC egress or the VPC connector.

Traffic to other Cloud Run services might require additional configuration. See https://cloud.google.com/run/docs/securing/private-networking#send_requests_to_other_services_and_services for more information.zJSends all outbound traffic through Direct VPC egress or the VPC connector.z(DEPRECATED) Sends all outbound traffic through Direct VPC egress or the VPC connector. Provides the same functionality as '{all_traffic}'. Prefer to use '{all_traffic}' instead.)all_traffic)r"   r'   N)r]   r   #EGRESS_SETTINGS_PRIVATE_RANGES_ONLYEGRESS_SETTINGS_ALL_TRAFFICEGRESS_SETTINGS_ALLr^   rt   s    r:   AddEgressSettingsFlagr  ?  sm    Q
 
@
@' 
8
8 
0
0 !&0LL ! #  rJ   c                  t    [         R                  " SS[        R                  [        R                  " 5       SS9$ )Nz--set-secretszKEY=SECRET_NAME:SECRET_VERSIONa=  Specify secrets to provide as environment variables. For example: '--set-secrets=ENV=mysecret:latest,OTHER_ENV=othersecret:1' will create an environment variable named ENV whose value is the latest version of secret 'mysecret' and an environment variable OTHER_ENV whose value is version of 1 of secret 'othersecret'.r   )r   rb   r   r   r   rD   rJ   r:   SetSecretsFlagr  a  s4    	.%% K
 rJ   c                 6    [        5       R                  U 5        g r4   )r  rk   rt   s    r:   AddSetSecretsFlagr  r  s    v&rJ   c                      [        SSS9$ )z;Creates flags for creating, updating, and deleting secrets.a
  Specify secrets to mount or provide as environment variables. Keys starting with a forward slash '/' are mount paths. All other keys correspond to environment variables. Values should be in the form SECRET_NAME:SECRET_VERSION. For example: '--update-secrets=/secrets/api/key=mysecret:latest,ENV=othersecret:1' will mount a volume at '/secrets/api' containing a file 'key' with the latest version of secret 'mysecret'. An environment variable named ENV will also be created whose value is version 1 of secret 'othersecret'.secrets)r   r   )r  rD   rJ   r:   SecretsFlagsr  v  s    	
> 
 rJ   c                 6    [        5       R                  U 5        g)z8Adds flags for creating, updating, and deleting secrets.N)r  rk   rt   s    r:   AddSecretsFlagsr    s    .V$rJ   a  Specify config map to mount or provide as environment variables. Keys starting with a forward slash '/' are mount paths. All other keys correspond to environment variables. The values associated with each of these should be in the form CONFIG_MAP_NAME:KEY_IN_CONFIG_MAP; you may omit the key within the config map to specify a mount of all keys within the config map. For example: '--update-config-maps=/my/path=myconfig,ENV=otherconfig:key.json' will create a volume with config map 'myconfig' and mount that volume at '/my/path'. Because no config map key was specified, all keys in 'myconfig' will be included. An environment variable named ENV will also be created whose value is the value of 'key.json' in 'otherconfig. Not supported on the fully managed version of Cloud Run.zconfig-maps)r   r   r#   c                 $    U R                  SSS9  g )Nz--descriptionz@Provides an optional, human-readable description of the service.r!   r   rt   s    r:   AddDescriptionFlagr    s    M  rJ   c                 N    [         R                  " USSS9R                  U 5        g)zAdd only the --labels flag.F)extra_messagevalidate_keysvalidate_valuesN)r   GetCreateLabelsFlagrk   )r_   r  s     r:   AddLabelsFlagr    s!    !!!KrJ   c                 X   U R                  5       nUR                  5       n[        US5        [        R                  " SSSS9R                  U5        UR                  5       n[        R                  " 5       R                  U5        [        R                  " S5      R                  U5        g)zrAdds update command labels flags to an argparse parser.

Args:
  parser: The argparse parser to add the flags to.
zAn alias to --update-labels. F)r  r  N)r   r   r  r   GetUpdateLabelsFlagrk   GetClearLabelsFlagGetRemoveLabelsFlag)r_   r   r   remove_groups       r:   AddLabelsFlagsr    s     


%002)	9:!!uK	335,  "..|<!!"%11,?rJ   c           	      n    U R                  SS[        R                  " 5       [        R                  SSS9  g)zyAdds the update command annotation flag to an argparse parser.

Args:
  parser: The argparse parser to add the flags to.
z--update-annotationsr   TzList of annotation KEY=VALUE pairs to update. If an annotation exists, its value is modified. Otherwise, a new annotation is created.)r   r&   r$   r#   r"   N)r]   r   r   r   rt   s    r:   AddGeneralAnnotationFlagsr    s:     	 %%  rJ   c                       \ rS rSrSrS rSrg)
ScaleValuei  z'Type for min/max-instances flag values.c                 
   US:H  U l         U R                   (       d;   [        U5      U l        U R                  S:  a  [
        R                  " SU-  5      eg g ! [        [        4 a    [
        R                  " SU-  5      ef = f)Nr   z7Instance count value %s is not an integer or 'default'.r   z$Instance count value %s is negative.)restore_defaultr   instance_countr   r   r   r   selfr   s     r:   __init__ScaleValue.__init__  s     I-D
!%j 
		q	 #112U:
 	
 
!   $ 
#11EM
 	

   A *B)r  r  NrE   rF   rG   rH   __doc__r  rI   rD   rJ   r:   r  r    s
    /
rJ   r  c                       \ rS rSrSrS rSrg)UtilizationValuei  z+Type for scaling utilization target values.c                    US:H  U l         US:X  a  [        S5      U l        g U R                   (       dt   [        U5      U l        U R                  S:w  a)  U R                  S:  a  [
        R                  " SU-  5      eU R                  S:  a  [
        R                  " SU-  5      eg g ! [        [        4 a    [
        R                  " SU-  5      ef = f)	Nr   disabledg        z4Utilization value %s is not an decimal or 'default'.g      ?z&Utilization value %s is less than 0.5.gffffff?z*Utilization value %s is greater than 0.95.)r  floatutilizationr   r   r   r   r  s     r:   r  UtilizationValue.__init__  s     I-D
sd
 < 
		S	 T%5%5%;#114u<
 	
 
		D	 #1185@
 	
 
!   $ 
#11BUJ
 	

s   B( (*C)r  r  Nr  rD   rJ   r:   r  r    s
    3
rJ   r  c                       \ rS rSrSrS rSrg)ScalingValuei  zType for --scaling flag values.

Input values could be either 'auto' for automatic scaling or integer to
support manual scaling mode with the integer value as instance count.
c                 
   US:H  U l         U R                   (       d;   [        U5      U l        U R                  S:  a  [
        R                  " SU-  5      eg g ! [        [        4 a    [
        R                  " SU-  5      ef = f)NautozAInput value '%s' for --scaling flag is not an integer nor 'auto'.r   zKInput value '%s' for --scaling flag should be a positive integer or 'auto'.)auto_scalingr   r  r   r   r   r   r  s     r:   r  ScalingValue.__init__  s    D
!%j 
		q	 #11!"
 	
 
!  $ 
#11O
 	

r  )r  r  Nr  rD   rJ   r:   r  r    s    
rJ   r  r	   c                 J    US:X  a  SOSnU R                  S[        SU S3S9  g)	zAdd min scaling flag.r	   r   Workerz--min-instancesa   The minimum number of container instances to run for this Revision  or 'default' to remove. This setting is immutably set on each new  Revision and modifying its value will deploy a another Revision. Consider using --min to set the minimum number of instances across all revisions of the z# which may be modified dynamically.rh  Nr]   r  )r_   resource_kindresources      r:   AddMinInstancesFlagr    s>    '94Y((# $,*,O	Q	  
rJ   c                     U R                  S[        SS9  U R                  S[        SSS9  U R                  S[        SS9  U R                  S	[        SS
S9  g)z#Add service-level min scaling flag.--minzThe minimum number of container instances to run for this Service or 'default' to remove. These instances will be divided among all Revisions receiving a percentage of traffic and can be modified without deploying a new Revision.rh  z--service-min-instancesT)r&   r#   r"   --maxzThe maximum number of container instances to run for this Service. This instance limit will be divided among all Revisions receiving a percentage of traffic and can be modified without deploying a new Revision.z--service-max-instanceszThe maximum number of container instances for this Service to run. This instance limit will be divided among all Revisions receiving a percentage of traffic.Nr  rt   s    r:   AddServiceMinMaxInstancesFlagr  /  s    .	  	 	.  
 		  	 	#  	rJ   c                 .    U R                  S[        SS9  g)z(Add min instances flag for worker pools.r  a  The minimum number of container instances to run for this WorkerPool or 'default' to use system default of 1. These instances will be divided among all Revisions receiving a percentage of instance assignments and can be modified without deploying a new Revision.rh  Nr  rt   s    r:   AddWorkerPoolMinInstancesFlagr  _  s!    O	  	rJ   c                 .    U R                  S[        SS9  g)z(Add max instances flag for worker pools.r  a  The maximum number of container instances to run for this WorkerPool or 'default' to use system default of 100. This instance limit will be divided among all Revisions receiving a percentage of instance assignments and can be modified without deploying a new Revision. rh  Nr  rt   s    r:   AddWorkerPoolMaxInstancesFlagr  m  s!    P	  	rJ   c                 B    SnUS:X  a  SnU R                  S[        US9  g)zAdd max scaling flag.zThe maximum number of container instances for this Revision to run or 'default' to remove. This setting is immutably set on each new Revision and modifying its value will deploy another Revision. workeraE  The maximum number of container instances for this Revision to run or 'default' to remove. This setting is immutably set on each new Revision and modifying its value will deploy another Revision. Consider using --max to set the maximum number of instances across all revisions of the Worker which may be modified dynamically.z--max-instancesrh  Nr  )r_   r  rd   s      r:   AddMaxInstancesFlagr  {  s@    L 
 h	I  	  rJ   c                 ~    SnUS:X  d  U[         R                  R                  :X  a  SnU R                  S[        US9  g)zAdd scaling flag.zThe scaling mode to use for this resource. Flag value should be a positive integer to configure manual scaling with the given integer as a fixed instance count.r	   zThe scaling mode to use for this resource. Flag value could be either "auto" for automatic scaling, or a positive integer to configure manual scaling with the given integer as a fixed instance count.z	--scalingrh  N)r   r   r   r]   r  )r_   r   r  rd   s       r:   AddScalingFlagr    sQ    !  i=D4E4E4K4K#K	  	  rJ   c                  t    [         R                  " SS[        R                  " 5       [        R                  SS9$ )z9Create a flag for specifying container's startup command.z	--commandCOMMANDzEntrypoint for the container image. If not specified, the container image's default Entrypoint is run. To reset this field to its default, pass an empty string.r   r&   r$   r"   r   rb   r   r   r   rD   rJ   r:   CommandFlagr    s4    	 %%F

 
rJ   c                 6    [        5       R                  U 5        g)z5Add flags for specifying container's startup command.N)r  rk   rt   s    r:   AddCommandFlagr    s    -F#rJ   c                     SnU (       a  US-  nOUS-  n[         R                  " SS[        R                  " 5       [        R                  US9$ )z7Creates a flag for specifying container's startup args.zKComma-separated arguments passed to the command run by the container image.zx If provided, an execution will be created with the input values. Otherwise, the existing arguments of the job are used.z If not specified and no '--command' is provided, the container image's default Cmd is used. Otherwise, if not specified, no arguments are passed. To reset this field to its default, pass an empty string.z--argsARGr  r  )for_execution_overridesrd   s     r:   ArgsFlagr    sc      	BI
 	I 
 %%
 rJ   c                 4    [        US9R                  U 5        g)z2Add flags for specifying container's startup args.)r  N)r  rk   )r_   r  s     r:   AddArgsFlagr    s    
#:;GGOrJ   c                 B    U R                  S[        R                  SS9  g)z0Add flag enable and disable deploy health check.z--deploy-health-checka   Schedules a single instance of the Revision and waits for it to pass its startup probe for the deployment to succeed. If disabled, the startup probe runs only when the revision is first started via invocation or by setting min-instances. This check is enabled by default when unspecified.rq   Nrr   rt   s    r:   AddDeployHealthCheckFlagr    s&    --'	  
rJ   c                 B    U R                  S[        R                  SS9  g)z(Add flag enable and disable default url.z--default-urlzWToggles the default url for a run service. This is enabled by default if not specified.rq   Nrr   rt   s    r:   AddDefaultUrlFlagr    s&    --'	  rJ   c                 B    U R                  S[        R                  SS9  g)z.Add flag enable and disable invoker iam check.z--invoker-iam-checkzOptionally disable invoker IAM checks. This feature is available by invitation only. More info at https://cloud.google.com/run/docs/securing/managing-access#invoker_check.rq   Nrr   rt   s    r:   AddInvokerIamCheckFlagr    s'    --V	  rJ   c                 &    U R                  SUSS9  g)z#Add a multi-regional 'regions' arg.	--regionszOComma-separated list of regions in which the multi-region Service can be found.r  Nr   r  s     r:   AddRegionsArgr    s     	  rJ   c                 &    U R                  SSSS9  g )Nz--add-regionsTz5Additional regions to deploy the multi-region Servicer  r   rt   s    r:   AddAddRegionsArgr    s    B  rJ   c                 &    U R                  SSSS9  g )Nz--remove-regionsTz7Existing egions to remove the multi-region Service fromr  r   rt   s    r:   AddRemoveRegionsArgr    s    D  rJ   c                 H    U R                  SSSS9  U R                  SSSS9  g)zAAdd flags for specifying the client name and version annotations.z--client-nameTzuName of the client handling the deployment. Defaults to ``global'' if this and --client-version are both unspecified.r  z--client-versionzVersion of the client handling the deployment. Defaults to the current gcloud version if this and --client-name are both unspecified.Nr   rt   s    r:   AddClientNameAndVersionFlagsr  $  s@    ?	   		  rJ   c                 z    U nU(       a"  U R                  5       nUR                  SSSSS9  UR                  SSS9  g	)
zAdd CMEK key flag.--clear-keyFr   z-Remove any previously set CMEK key reference.r   --keyz1CMEK key reference to encrypt the container with.r!   Nr   r]   r_   
with_clearpolicy_groups      r:   AddCmekKeyFlagr   9  sR    ,668L<	   G  rJ   c                     U nU(       a"  U R                  5       nUR                  SSSSS9  UR                  S[        SS9  g	)
z.Add post CMEK key revocation action type flag.'--clear-post-key-revocation-action-typeFr   z?Remove any previously set post CMEK key revocation action type.r   !--post-key-revocation-action-typez&Action type after CMEK key revocation.)r'   r"   N)r   r]   -_POST_CMEK_KEY_REVOCATION_ACTION_TYPE_CHOICESr  s      r:   "AddCmekKeyRevocationActionTypeFlagr  I  sU    ,668L1N	   );3  rJ   c                 z    U nU(       a"  U R                  5       nUR                  SSSSS9  UR                  SSS9  g	)
z!Add Cmek key shutdown hours flag.%--clear-encryption-key-shutdown-hoursFr   z:Remove any previously set CMEK key shutdown hours setting.r   --encryption-key-shutdown-hourszfThe number of hours to wait before an automatic shutdown server after CMEK key revocation is detected.r!   Nr  r  s      r:   !AddEncryptionKeyShutdownHoursFlagr	  [  sT    ,668L/I	   '4  rJ   c                 x     U S:H  =(       d    S[        U 5      s=:*  =(       a    S:*  $ s  $ ! [         a     gf = f)z?Returns True if port value is an int within range or 'default'.r      i  Frd  re  s    r:   
_PortValuer  o  s@    I;!s5z":":U":;":;	 s   &, , 
99aA  Container port to receive requests at. Also sets
the $PORT environment variable. Must be a number between 1 and 65535, inclusive.
To unset this field, pass the special value "default".
If updating an existing service with a TCP startup probe pointing to the
previous container port, this will also update the probe port.
c                 `    [         R                  " S[        R                  " [        S5      U S9$ )z#Port argument for overriding $PORT.--port@must be an integer between 1 and 65535, inclusive, or "default".rh  )r   rb   r   ri  r  rd   s    r:   PortArgr    s/    	..

L 
 rJ   c                 X    U R                  S[        R                  " [        S5      US9  g)z Add port flag to override $PORT.r  r  rh  N)r]   r   ri  r  r   s     r:   AddPortFlagr    s1    ..

L   rJ   c                  J    [         R                  " S[        R                  SS9$ )z(Create http/2 flag to set the port name.z--use-http2z5Whether to use HTTP/2 for connections to the service.rq   r   rb   r   rs   rD   rJ   r:   	Http2Flagr    s"    	--B
 rJ   c                 6    [        5       R                  U 5        g)z%Add http/2 flag to set the port name.N)r  rk   rt   s    r:   AddHttp2Flagr    s    +&!rJ   c                 J    U R                  S[        R                  " SS9SS9  g)z%Add job parallelism/concurrency flag.z--parallelismr   rm  zpNumber of tasks that may run concurrently. Must be less than or equal to the number of tasks. Set to 0 to unset.rh  Nr]   r   
BoundedIntrt   s    r:   AddParallelismFlagr    s+    !!a0>	  rJ   c                 0    U R                  S[        SSS9  g)zAdd job priority flag.z--priority-tierTzPriority of the job.r  N)r]   _PRIORITY_CHOICESrt   s    r:   AddPriorityFlagr    s!    !	  rJ   c                     SnU(       a)  US-  nU R                  S[        R                  " SS9US9  gU R                  S[        R                  " SS9SUS9  g)	zMAdd job number of tasks flag which maps to job.spec.template.spec.task_count.zTNumber of tasks that must run to completion for the execution to be considered done.zq If provided, an execution will be created with this value. Otherwise the existing task count of the job is used.z--tasksr  rm  rh  )r&   r   r"   Nr  r_   r  rd   s      r:   AddTasksFlagr"    su      	7I ##2   ##2	  rJ   c                 J    U R                  S[        R                  " SS9SS9  g)z<Add job max retries flag to specify number of task restarts.z--max-retriesr   rm  zNumber of times a task is allowed to restart in case of failure before being failed permanently. This applies per-task, not per-job. If set to 0, tasks will only run once and never be retried on failure.rh  Nr  rt   s    r:   AddMaxRetriesFlagr$    s+    !!a0 	  	rJ   c                 D    SnU(       a  US-  nU R                  SSSUS9  g)z0Add job flag to poll until completion on create.zWait until the execution has completed running before exiting. If not set, gcloud exits successfully when the execution has started.z  Implies --execute-now.z--waitFr   r   Nr   )r_   implies_execute_nowrd   s      r:   AddWaitForCompletionFlagr'    s9    N  ++Il  rJ   c                 r    SnU(       a  SU-   nOSU-   nU R                  S[        R                  " SS9US9  g)	z(Add job flags for job and task deadline.a<   In the case of retries, this deadline applies to each attempt of a task. If the task attempt does not complete within this time, it will be killed. It is specified as a duration; for example, "10m5s" is ten minutes, and five seconds. If you don't specify a unit, seconds is assumed. For example, "10" is 10 seconds.zThe existing maximum time (deadline) a job task attempt can run for. If provided, an execution will be created with this value. Otherwise existing maximum time of the job is used.z?Set the maximum time (deadline) a job task attempt can run for.z--task-timeoutrl  rm  rh  Nro  r!  s      r:   AddTaskTimeoutFlagsr)    sa    3  	5 	  	J
	  	D1  rJ   c                 |    U nU(       a"  U R                  5       nUR                  SSSSS9  UR                  SSSS	9  g
)zAdd flags for BinAuthz.--clear-binary-authorizationFr   z6Remove any previously set Binary Authorization policy.r   --binary-authorizationPOLICYzLBinary Authorization policy to check against. This must be set to "default".r>  Nr  r  s      r:   AddBinAuthzPolicyFlagsr.    sW    ,668L&E	   
  
rJ   c                 &    U R                  SSSS9  g )N--breakglassJUSTIFICATIONa  Justification to bypass Binary Authorization policy constraints and allow the operation. See https://cloud.google.com/binary-authorization/docs/using-breakglass for more information. Next update or deploy command will automatically clear existing breakglass justification.r>  r   rt   s    r:   AddBinAuthzBreakglassFlagr2  #  s     &	  rJ   c                 @    U R                  SSSR                  US9S9  g)z"Add flags for setting VPC network.	--networkNETWORKzThe VPC network that the Cloud Run {kind} will be able to send traffic to. If --subnet is also specified, subnet must be a subnetwork of the network specified by this --network flag. To clear existing VPC network settings, use --clear-network.kindr>  Nr\   r_   r  s     r:   AddVpcNetworkFlagsr9  2  s:    G HNv  HN H  rJ   c                 @    U R                  SSSR                  US9S9  g)z%Add flags for setting VPC subnetwork.--subnetSUBNETa_  The VPC subnetwork that the Cloud Run {kind} will get IPs from. The subnetwork must be `/26` or larger. If --network is also specified, subnet must be a subnetwork of the network specified by the --network flag. If --network is not specified, network will be looked up from this subnetwork. To clear existing VPC network settings, use --clear-network.r6  r>  Nr\   r8  s     r:   AddVpcSubnetFlagsr=  B  s.    ,
 -3FF,F  rJ   c           
          U R                  SS[        R                  " 5       [        R                  SR	                  US9S9  g)z'Add flags for setting VPC network tags.--network-tagsr   z{Applies the given network tags (comma separated) to the Cloud Run {kind}. To clear existing tags, use --clear-network-tags.r6  r  N)r]   r   r   r   r^   r8  s     r:   AddVpcNetworkTagsFlagsr@  R  sH     %%>>Df  ?E ?  rJ   c                 @    U R                  SSSR                  US9S9  g)z#Add flags for clearing VPC network.z--clear-networkr   zIDisconnect this Cloud Run {kind} from the VPC network it is connected to.r6  rq   Nr\   r8  s     r:   AddClearVpcNetworkFlagsrB  c  s,    !6}65  rJ   c                 @    U R                  SSSR                  US9S9  g)z(Add flags for clearing VPC network tags.z--clear-network-tagsr   z<Clears all existing network tags from the Cloud Run {kind}. r6  rq   Nr\   r8  s     r:   AddClearVpcNetworkTagsFlagsrD  o  s*    
H6}6%  rJ   c                     U R                  S5      n[        X15        [        X15        U(       d  [        X15        gUR	                  5       n[        XA5        [        XA5        g)z'Add flags for all VPC network settings.z&Direct VPC egress setting flags group.N)add_argument_groupr9  r=  r@  r   rD  )r_   r  	is_updater   
tags_groups        r:   AddVpcNetworkGroupFlagsrI  {  sO    

#
#$L
M%U*E)	50
113*3j8rJ   c                     [        XSS9  g)z@Add flags for all VPC network settings when creating a resource.FrG  N)rI  r8  s     r:    AddVpcNetworkGroupFlagsForCreaterL    s    &5ArJ   c                 N    U R                  5       n[        X!SS9  [        X!5        g)z@Add flags for all VPC network settings when updating a resource.TrK  N)r   rI  rB  )r_   r  r   s      r:    AddVpcNetworkGroupFlagsForUpdaterN    s"    

-
-
/%%$?%/rJ   c           	      6    [         R                  " U SSSSSS9  g)z'Add flags for setting custom audiences.r   zcustom-audienceszcustom audiencesFzvThese flags modify the custom audiences that can be used in the audience field of ID token for authenticated requests.r   Nr   rt   s    r:   AddCustomAudiencesFlagrP    s$    
$rJ   c                 B    U R                  S[        R                  SS9  g)z5Add session affinity flag to enable session affinity.--session-affinityzBWhether to enable session affinity for connections to the service.rq   Nrr   rt   s    r:   AddSessionAffinityFlagrS    s$    --O  rJ   c                 (    U R                  SSSSS9  g)zAdd flags for Wasm runtime.z	--runtimeRUNTIMETz\The runtime to use. "wasm" for WebAssembly runtime, "default" for the default Linux runtime.)r   r#   r"   Nr   rt   s    r:   AddRuntimeFlagrV    s#    5  rJ   c                 D    U R                  SS[        R                  SS9  g)z$Add flag to enable overflow scaling.z--overflow-scalingTa  Whether to start instances for new requests when no capacity is available on existing instances. This behavior is enabled by default i.e. Overflow instances will be started if a request cannot be handled by the existing instances. Enables rapid scaling in response to traffic spikes. When disabled, only Scheduled instances will be started, based on the configured scaling factors and targets. Use --overflow-scaling to enable and --no-overflow-scaling to disable.)r#   r$   r"   Nrr   rt   s    r:   AddOverflowScalingFlagrX    s)    --  rJ   c                 .    U R                  S[        SS9  g)z2Add flag to modify cpu utilization scaling target.z--scaling-cpu-targetzA value between 0.5 and 0.95 that indicates the target CPU utilization where a new instance should be started.  Also accepts "default" to restore the default value or "disabled" to disable CPU utilization scaling. If not set, the default value is 0.6.rh  Nr]   r  rt   s    r:   AddCpuUtilizationFlagr[    s!    K	  	rJ   c                 .    U R                  S[        SS9  g)z3Add flag to modify scaling concurrency utilization.z--scaling-concurrency-targeta
  A value between 0.5 and 0.95 that indicates the target concurrency utilization where a new instance should be started. Also accepts "default" to restore the default value or "disabled" to disable concurrency utilization scaling. If not set, the default value is 0.6.rh  NrZ  rt   s    r:   AddConcurrencyUtilizationFlagr]    s     $	  
rJ   c                 .   ^  [        U 4S jU 5       5      $ )z)True iff any of the passed flags are set.c              3   <   >#    U  H  n[        TU5      v   M     g 7fr4   )FlagIsExplicitlySet).0flagargss     r:   	<genexpr>HasChanges.<locals>.<genexpr>  s     ? t,,s   )any)rc  flagss   ` r:   
HasChangesrh    s    	??	??rJ   c                      / SQn[        X5      $ )z*True iff any of the env var flags are set.)update_env_varsset_env_varsremove_env_varsclear_env_varsenv_vars_filerh  )rc  	env_flagss     r:   HasEnvChangesrq    s    ) 
D	$$rJ   c                      / SQn[        X5      $ )z+True iff any of the cloudsql flags are set.)add_cloudsql_instancesset_cloudsql_instancesremove_cloudsql_instancesclear_cloudsql_instancesro  rc  instances_flagss     r:   HasCloudSQLChangesry        / 
D	**rJ   c                     Sn[        X5      $ )z;True iff flags that add or set cloud sql instances are set.)rs  rt  ro  rw  s     r:   EnabledCloudSqlApiRequiredr|  	  s    / 
D	**rJ   c                      / SQn[        X5      $ )z(True iff any of the label flags are set.)labelsupdate_labelsclear_labelsremove_labelsro  )rc  label_flagss     r:   HasLabelChangesr  	  s    L+	D	&&rJ   c                      / SQn[        X5      $ )z)True iff any of the secret flags are set.)update_secretsset_secretsremove_secretsclear_secretsro  )rc  secret_flagss     r:   HasSecretsChangesr  	  s    , 
D	''rJ   c                      / SQn[        X5      $ )z.True iff any of the config maps flags are set.)update_config_mapsset_config_mapsremove_config_mapsclear_config_mapsro  )rc  config_maps_flagss     r:   _HasConfigMapsChangesr   	  s     
D	,,rJ   c                      / SQn[        X5      $ )z/True iff any of the traffic tags flags are set.)update_tagsset_tagsremove_tags
clear_tagsro  )rc  
tags_flagss     r:   _HasTrafficTagsChangesr  +	  s    G*	D	%%rJ   c                 D    / SQn[        X5      =(       d    [        U 5      $ )z*True iff any of the traffic flags are set.)to_revisionsto_tags	to_latest)rh  r  rc  traffic_flagss     r:   _HasTrafficChangesr  1	  s    :-	D	(	H,B4,HHrJ   c                      SS/n[        X5      $ )z1True iff any of the instance split flags are set.r  r  ro  r  s     r:   HasInstanceSplitChangesr  7	  s    !;/-	D	((rJ   c                      / SQn[        X5      $ )z3True iff any of the custom audiences flags are set.)add_custom_audiencesset_custom_audiencesremove_custom_audiencesclear_custom_audiencesro  rw  s     r:   _HasCustomAudiencesChangesr  =	  rz  rJ   c                 F    / SQn[        X5      =(       d    [        U S5      $ )N)rc  rj  task_timeouttaskspriority_tier
containers)rh  r`  rc  overrides_flagss     r:   HasExecutionOverridesr  H	  s*    / 
D	* 
.A
L/ rJ   c                 >    [        U 5      =(       d    [        U S5      $ )Nr  )HasTopLevelContainerOverrider`  rc  s    r:   HasContainerOverridesr  U	  s!    	%d	+ 
/B
L0 rJ   c                      SS/n[        X5      $ )Nrc  rj  ro  r  s     r:   r  r  [	  s    / 
D	**rJ   c                 h   [         R                  " S[        [        U SS5      =(       d(    U R                  =(       d    U R
                  =(       d    0 5      [        [        U SS5      =(       d    / 5      [        U R                  =(       d    U R
                  =(       d    U R                  5      S.UD6$ )z:Return config_changes.EnvVarLiteralChanges for given args.rj  Nrl  )updatesremovesclear_othersrD   )	r   EnvVarLiteralChangesr;   getattrrk  rn  r@   boolrm  )rc  kwargss     r:   _GetEnvChangesr  c	  s    		,	, 

$)4
0  	 &7>D"E



Ht11
HT5H5H
 	
 rJ   c                    / nSU ;   a  U R                   b  U R                   nUR                  (       d  UR                  S:X  a4  UR                  [        R
                  " [        R                  5      5        OGUR                  [        R                  " [        R                  [        UR                  5      5      5        SU ;   a  U R                  b  U R                  nUR                  (       a5  UR                  [        R
                  " [        R                  5      5        U$ UR                  [        R                  " [        R                  [        UR                  5      5      5        U$ )z7Returns the list of changes for scaling for given args.min_instancesr   max_instances)r  r  r  r   r   DeleteTemplateAnnotationChanger   MIN_SCALE_ANNOTATIONSetTemplateAnnotationChanger   r  MAX_SCALE_ANNOTATION)rc  r   scale_values      r:   _GetScalingChangesr  t	  s   &!3!3!?$$K""k&@&@A&Emm

7
7++ mm

4
4++S1K1K-L
 !3!3!?$$K""mm

7
7++ 
- mm

4
4++S1K1K-L
 
-rJ   c                    / n[        U SS5      =(       d    [        U SS5      nUb  UR                  (       d  UR                  S:X  a4  UR                  [        R
                  " [        R                  5      5        OGUR                  [        R                  " [        R                  [        UR                  5      5      5        [        U SS5      =(       d    [        U SS5      nUb  [        U SS5      (       a1  U R                  R                  (       d  [        R                  " S5      eUR                  [        R                  " [        R                  [        UR                  5      5      5        SU ;   Ga}  U R                  Gbo  U R                  nUR                  (       am  UR                  [        R
                  " [        R                  5      5        UR                  [        R                  " [        R                   ["        5      5        U$ UR                  [        R
                  " [        R                  5      5        UR                  [        R
                  " [        R                  5      5        UR                  [        R                  " [        R                   [$        5      5        UR                  [        R                  " [        R                  [        UR                  5      5      5        U$ )	z@Return the changes for service-level scaling for the given args.service_min_instancesNminr   service_max_instancesmaxscalingz=Cannot set service max instances when scaling mode is manual.)r  r  r  r   r   DeleteAnnotationChanger	   SERVICE_MIN_SCALE_ANNOTATIONSetAnnotationChanger   r  r  r   ConfigurationErrorSERVICE_MAX_SCALE_ANNOTATION MANUAL_INSTANCE_COUNT_ANNOTATIONSERVICE_SCALING_MODE_ANNOTATION_SCALING_MODE_AUTOMATIC_SCALING_MODE_MANUAL)rc  r   min_scale_valuemax_scale_valuescaling_vals        r:   _GetServiceScalingChangesr  	  sU   &D"94@ G
E4E/  &&/*H*HA*Mmm

/
/22 mm

,
,22/001 D"94@ G
E4E/  tY%%dll.G.G "44
I  MM**00../	
 $4<<3,,Kmm

/
/66
 mm

,
,55%B 
-1 mm

/
/22 mm

/
/22 mm

,
,55" mm

,
,66+,,- 
-rJ   c                 $    U R                  S5      $ )z1Returns True if the key refers to a volume mount./)
startswithr   s    r:   _IsVolumeMountKeyr  	  s    		rJ   c                   ^ [        U 5      (       aK  U R                  S5      n[        U5      S:  nU(       d%  1 Skm[        U4S jUSS   5       5      nU(       a  U $ [        R
                  " SR                  U 5      5      e)Nr     >   r  ...c              3   ,   >#    U  H	  oT;  v   M     g 7fr4   rD   )ra  seg
disalloweds     r:   rd  '_ValidatedMountPoint.<locals>.<genexpr>	  s     M*4s   r  z7Mount path [{}] must be in the form /<mountPath>/<path>)r  splitlenr,   r   r  r^   )r   segments	too_shortall_legal_segmentsr  s       @r:   _ValidatedMountPointr  	  sq    syy~HH!I"jMMM	
00?FFsK	 rJ   c                 D   0 n0 n[        [        U SS5      =(       d    U R                  =(       d    0 5      nUR                  5        VVs0 s H8  u  pV[	        U5      (       d  M  U[
        R                  " U[        U5      5      _M:     snnUS'   UR                  5        VVs0 s H.  u  pV[	        U5      (       a  M  U[
        R                  " Xe5      _M0     snnUS'   [        [        U SS5      =(       d    / 5      nU Vs/ s H  n[	        U5      (       d  M  UPM     snUS'   U Vs/ s H  n[	        U5      (       a  M  UPM     snUS'   [        U R                  =(       d    U R                  5      nXS'   XS'   / n	[        UR                  5       5      (       a'  U	R                  [        R                  " SSU0UD65        [        UR                  5       5      (       a'  U	R                  [        R                   " SSU0UD65        U	$ s  snnf s  snnf s  snf s  snf )	z8Return secret env var and volume changes for given args.r  Nr  r  r  r  container_namerD   )r;   r  r  r5   r  r   ReachableSecretr  r@   r  r  rf  valuesr   r   SecretEnvVarChangesSecretVolumeChanges)
rc  r  volume_kwargs
env_kwargsr  r8   r9   r  r  secret_changess
             r:   _GetSecretsChangesr  	  s   -*d$d+Et/?/?E2'
 --/!$!	1	 Ea	(	(,@,C	DD!-	 --/!$!q! /a	(	(	..!*Y gd$4d;ArB')0IA4Ea4HaI-	&-Jg5Fq5I1gJ*Yd&&<$*<*<=,+^"..			** 	
)	
-7	

 				  ** 	
)	
-:	

 
A
 JJs0   
H$%H#H=HHH*HHc                    0 n0 n[        [        U SS5      =(       d    U R                  =(       d    0 5      nUR                  5        VVs0 s H  u  pE[	        U5      (       d  M  XE_M     snnUS'   UR                  5        VVs0 s H  u  pE[	        U5      (       a  M  XE_M     snnUS'   [        [        U SS5      =(       d    / 5      nU Vs/ s H  n[	        U5      (       d  M  UPM     snUS'   U Vs/ s H  n[	        U5      (       a  M  UPM     snUS'   [        U R                  =(       d    U R                  5      nXrS'   XqS'   / n[        UR                  5       5      (       a%  UR                  [        R                  " S0 UD65        [        UR                  5       5      (       a%  UR                  [        R                  " S0 UD65        U$ s  snnf s  snnf s  snf s  snf )z<Return config map env var and volume changes for given args.r  Nr  r  r  r  rD   )r;   r  r  r5   r  r@   r  r  rf  r  r   r   ConfigMapEnvVarChangesConfigMapVolumeChanges)	rc  r  r  r  r8   r9   r  r  config_maps_changess	            r:   _GetConfigMapsChangesr  '
  s   -*d($/M43G3GM2' }}&tq*;A*>dad-	 }}&tq.?.Bdad*Y gd$8$?E2F')0IA4Ea4HaI-	&-Jg5Fq5I1gJ*Yd**Dd.D.DE,+^".			--;
; 				  -->> 
1
 JJs0   
G$GGGG &G 6G%G%c                     / n[        U S5      (       aU  UR                  [        R                  " [        R
                  [        U R                  5      R                  5       5      5        U$ )z/Return overflow scaling changes for given args.overflow_scaling)	r`  r   r   r  r   OVERFLOW_SCALING_ANNOTATIONr   r  lowerrc  r  s     r:   _GetOverFlowScalingChangesr   J
  sZ    1222200%%&,,.	
 
rJ   c                 n   / n[        U S5      (       a  U R                  R                  (       a5  UR                  [        R
                  " [        R                  5      5        U$ UR                  [        R                  " [        R                  [        U R                  R                  5      5      5        U$ )z6Return cpu utilization scaling changes for given args.scaling_cpu_target)r`  r  r  r   r   r  r   CPU_UTILIZATION_ANNOTATIONr  r   r  r  s     r:   _GetCpuUtilizationChangesr  W
  s    344..  

7
711 
   

4
411$))556 
rJ   c                 n   / n[        U S5      (       a  U R                  R                  (       a5  UR                  [        R
                  " [        R                  5      5        U$ UR                  [        R                  " [        R                  [        U R                  R                  5      5      5        U$ )z>Return concurrency utilization scaling changes for given args.scaling_concurrency_target)r`  r  r  r   r   r  r   "CONCURRENCY_UTILIZATION_ANNOTATIONr  r   r  r  s     r:   !_GetConcurrencyUtilizationChangesr  k
  s    ;<<&&66  

7
799 
   

4
499$11==> 
rJ   c                    [         R                  R                  R                  R	                  5       (       d  g[         R                  R                  R
                  R                  SS9n[        R                  " X5      (       dB  [        R                  " SSSR                  X5      S9(       a  [        R                  " X5        ggg)zPrompts to enable the API and throws if the answer is no.

Args:
  service_name: str, The service token of the API to prompt for.
NTr[   FzhAPI [{}] not enabled on project [{}]. Would you like to enable and retry (this will take a few minutes)?)r   cancel_on_noprompt_string)r   ry  coreshould_prompt_to_enable_apiGetBoolprojectGetr   IsServiceEnabledr   PromptContinuer^   EnableService)service_namer  s     r:   PromptToEnableApir  
  s     
					;	;	C	C	E	E
""**...='		$	$W	;	;   &
' w5 
<rJ   zsql-component.googleapis.comzsqladmin.googleapis.comc                  D   [         R                  R                  R                  R	                  5       (       d  g  [        [        5        [        [        5        g ! [        R                  [        R                  4 a"    [        R                  R                  S5         g f = f)NzSkipped validating Cloud SQL API and Cloud SQL Admin API enablement due to an issue contacting the Service Usage  API. Please ensure the Cloud SQL API and Cloud SQL Admin API are activated (see https://console.cloud.google.com/apis/dashboard).)r   ry  r  r  r  r  _CLOUD_SQL_API_SERVICE_TOKEN"_CLOUD_SQL_ADMIN_API_SERVICE_TOKENservices_exceptions#GetServicePermissionDeniedExceptionapitools_exceptions	HttpErrorr   statusPrintrD   rJ   r:   CheckCloudSQLApiEnablementr   
  sy    						;	;	C	C	E	E
2389==##
 
 JJ	<	
s   A ABBc                    U R                   =(       d    U R                  =(       d    0 nU R                  =(       d    / n[        U R                  5      =(       d    U R                  nSnU R
                  (       a  [        R                  S0nO@U R                  (       a  U R                  nO"[        U S5      (       a  U R                  nSnO0 n[        R                  " UUUUU5      $ )z<Returns a changes for traffic assignment based on the flags.Fr   r  T)r  r  r  r  r  r  r
   LATEST_REVISION_KEYr  r`  r  r   TrafficChanges)rc  r  r  clear_other_tagsby_tagnew_percentagess         r:   _GetTrafficChangesr'  
  s      7DMM7R+  &B+$--(;DOO&	^^22C8O''O4++llOFO		&	&
 rJ   c                    [         R                  " 5       nU[         R                  :X  a/  [        R                  " [
        R                  U R                  5      $ U R                  [
        R                  :X  a  [        R                  " S5      $ U R                  [
        R                  :X  a  [        R                  " S5      $ [        R                  " SR                  U R                  U5      5      e)z>Returns changes to ingress traffic allowed based on the flags.TFz5Ingress value `{}` is not supported on platform `{}`.)r   GetPlatformr|  r   r  r	   INGRESS_ANNOTATIONingressINGRESS_INTERNALEndpointVisibilityChangeINGRESS_ALLr   r  r^   )rc  r{  s     r:   _GetIngressChangesr/  
  s    ""$(+++--""DLL  ||w///22488||w***22599

2
2?FFLL(	
 rJ   c                     U R                  5        VVs0 s H7  u  p[        US5      (       d  M  UR                  (       d  M+  XR                  _M9     snn$ s  snnf )z%Returns a dict of base images to set.
base_image)r5   hasattrr1  container_argsr   rc  s      r:   _GetBaseImagesToSetr5  
  sS    
 )..0
0,4	|	$ )- dOO0
  
s   AAAc                     U R                  5        VVs/ s H-  u  p[        US5      (       d  M  UR                  (       d  M+  UPM/     snn$ s  snnf )z7Returns a list of containers to clear base images from.clear_base_image)r5   r2  r7  r3  s      r:   _GetBaseImagesToClearr8  
  sM    
 ',,.
.*$	)	* /3/D/D .
  
s   AAAc                     [        U R                  5      n[        U R                  5      nU(       d  U(       a  [        R                  " XS9/$ / $ )z1Returns changes to base image based on the flags.)r  deletes)r5  r  r8  r   BaseImagesAnnotationChange)rc  base_images_to_setbase_images_to_clears      r:   _GetBaseImageChangesr>  
  sH    *4??;.t?/11&	
 
 
)rJ   c           
      @   SU ;   a  U R                  S5      =(       d    U R                  S5      nUR                  S[        R                  " U(       a  U R                  OSU(       a  U R
                  O[        R                  [        R                  " U5      S95        gg)zJSet client name and version regardless of whether or not it was specified.client_nameclient_versionr   gcloud)set_on_templateN)	IsSpecifiedinsertr   'SetClientNameAndVersionAnnotationChanger@  rA  r   CLOUD_SDK_VERSIONAdjustsTemplate)rc  changesis_either_specifieds      r:   "_PrependClientNameAndVersionChangerK  
  s    d**=9 T=M=M> NN	>> 3D" ))*::7C	
		 rJ   c           
      h!   / n[        U S5      (       a<  U R                  b/  UR                  [        R                  " U R                  5      5        [        U 5      (       a  UR                  [        U 5      5        [        U 5      (       a  [        U 5      n[        U SS5      =(       d1    [        R                  R                  R                  R                  SS9n[        U 5      (       a
  [!        5         UR                  [        R"                  R%                  XCU S95        ['        U S5      (       a  U R(                  (       d"  ['        U S5      (       aI  U R*                  (       a8  UR                  [        R,                  " U R(                  U R*                  S	95        ['        U S
5      (       a  U R.                  (       d"  ['        U S5      (       aK  U R0                  (       a:  UR                  [        R2                  " U R.                  U R0                  5      5        [5        U 5      (       a  UR7                  [9        U 5      5        ['        U S5      (       aX  U R:                  (       aG  [=        X5        UR                  [        R>                  " U R:                  U5      5        [A        XU5        ['        U S5      (       a>  U RB                  (       a-  UR                  [        RD                  " U RB                  S95        [G        U 5      (       a  UR7                  [I        U 5      5        SU ;   a>  U RJ                  (       a-  UR                  [        RL                  " U RJ                  S95        SU ;   a>  U RN                  (       a-  UR                  [        RL                  " U RN                  S95        SU ;   aq  U RP                  (       a`  UR                  [        RL                  " U RP                  S95        U RP                  S:X  a#  UR                  [        RR                  " SS95        ['        U S5      (       a-  UR                  [        RT                  " U RV                  S95        ['        U S5      (       ab  U RX                  (       a.  UR                  [        RZ                  " U RX                  S95        O#UR                  [        RZ                  " SS95        ['        U S5      (       ab  U R\                  (       a.  UR                  [        R^                  " U R\                  S95        O#UR                  [        R^                  " SS95        ['        U S5      (       ab  U R`                  (       a.  UR                  [        Rb                  " U R`                  S95        O#UR                  [        Rb                  " SS95        SU ;   a>  U Rd                  (       a-  UR                  [        Rf                  " U Rd                  S 95        [i        U 5      (       a  ['        U S!5      (       a  U Rj                  OU Rl                  n[n        Rp                  " US"U ;   a  U Rr                  O/ S#U ;   a  U Rt                  OS$S%9nURw                  5       (       a%  UR                  [        Rx                  " U5      5        S&U ;   a@  U Rz                  (       a/  UR                  [        R|                  " U Rz                  5      5        ['        U S'5      (       a>  UR                  [        R~                  " [        R                  U R                  5      5        S(U ;   a5  U R                  (       a$  UR                  [        R                  " 5       5        S)U ;   a<  U R                  b/  UR                  [        R                  " U R                  5      5        S*U ;   a<  U R                  b/  UR                  [        R                  " U R                  5      5        ['        U S+5      (       a>  UR                  [        R                  " [        R                  U R                  5      5        ['        U S,5      (       a3  UR                  [        R                  " [        R                  5      5        ['        U S-5      (       a>  UR                  [        R                  " [        R                  U R                  5      5        ['        U S.5      (       a>  UR                  [        R~                  " [        R                  U R                  5      5        ['        U S/5      (       a>  UR                  [        R~                  " [        R                  U R                  5      5        ['        U S05      (       a>  UR                  [        R~                  " [        R                  U R                  5      5        ['        U S15      (       a  UR                  [        R                  " [        R                  5      5        UR                  [        R                  " [        R                  5      5        UR                  [        R                  " [        R                  5      5        ['        U S25      (       af  UR                  [        R                  " [        R                  5      5        UR                  [        R                  " [        R                  5      5        ['        U S35      (       a3  UR                  [        R                  " [        R                  5      5        ['        U S45      (       a>  UR                  [        R                  " [        R                  U R                  5      5        S5U ;   a@  U R                  (       a/  UR                  [        R                  " U R                  5      5        ['        U S65      (       d3  ['        U S75      (       d"  ['        U S85      (       d  ['        U S95      (       a  ['        U S95      nSn['        U S85      (       a  SnU R                  nUR                  [        R                  " ['        U S65      U R                  ['        U S75      U R                  UU5      5        S:U ;   a5  U R                  (       a$  UR                  [        R                  " 5       5        [        U 5      (       a%  UR                  [        R                  " U 5      5        ['        U S;5      (       a\  UR                  [        R                  R                  U R                  5      5        UR                  [        R                  " 5       5        ['        U S<5      (       a;  U R                  R                  5        H  u  pUR7                  [        XS=95        M     ['        U S>5      (       a  U R                  (       a^  UR                  [        R                  " [        R                  R                  R                  R                  SS9U R                  S?95        O3UR                  [        R                  " [        R                  5      5        ['        U S@5      (       a  U R                  (       a?  UR                  [        R~                  " [        R                  U R                  5      5        O3UR                  [        R                  " [        R                  5      5        ['        U SA5      (       aU  UR                  [        R~                  " [        R                  [        U R                  5      R                  5       5      5        ['        U SB5      (       a>  UR                  [        R~                  " [        R                  U R                  5      5        ['        U SC5      (       a-  UR                  [        R                  " U R                  SD95        ['        U SE5      (       a#  UR                  [        R                  " SSD95        ['        U SF5      (       a>  UR                  [        R                  " U R                  SG   U R                  SH   SI95        ['        U SJ5      (       a-  UR                  [        R                  " U R                  SK95        U$ )LzOReturns a list of changes shared by multiple resources, based on the flags set.rY   Nr  Tr
  )r  regionrc  remove_volume_mountclear_volume_mounts)removed_mountsclear_mountsremove_volumeclear_volumes
add_volumeadd_volume_mount
new_mountscpu)rX  memory)rY  gpu)rZ  0r  gpu_typegpu_zonal_redundancy)r^  startup_probe)settings)clearliveness_probereadiness_probeservice_account)rd  r~  r  r  F)	additionssubtractionsra  vpc_connector
vpc_egressclear_vpc_connectorcommandrc  binary_authorizationclear_binary_authorization
breakglassr   post_key_revocation_action_typeencryption_key_shutdown_hours	clear_key%clear_post_key_revocation_action_type#clear_encryption_key_shutdown_hoursdescriptionexecution_environmentnetworksubnetnetwork_tagsclear_network_tagsclear_networkremove_containersr  r  mesh)r  	mesh_nameidentityenable_workload_certificatemesh_dataplaner1  )r1  r7  presetr   params)r&   r   clear_presets)r  )|r2  rY   r   r   ImageChangerq  r  ry  	GetRegionr  r   ry  r  r  r  r|  r   CloudSQLChangesFromArgsr`  rN  rO  RemoveVolumeMountChangerR  rS  RemoveVolumeChanger  extendr  rT  $_ValidateAndMaybeGenerateVolumeNamesAddVolumeChange_MaybeAddVolumeMountChangerU  AddVolumeMountChanger  r  rX  ResourceChangesrY  rZ  GpuTypeChangeGpuZonalRedundancyChanger^  r_  StartupProbeChangesrb  LivenessProbeChangesrc  ReadinessProbeChangesrd  ServiceAccountChangesr  r~  r  r   Diffr  r  MayHaveUpdatesLabelChangesrg  VpcConnectorChanger  r   EGRESS_SETTINGS_ANNOTATIONrh  ri  ClearVpcConnectorChangerj  ContainerCommandChangerc  ContainerArgsChanger  r   BINAUTHZ_POLICY_ANNOTATIONrk  r  BINAUTHZ_BREAKGLASS_ANNOTATIONrm  CMEK_KEY_ANNOTATIONr   /POST_CMEK_KEY_REVOCATION_ACTION_TYPE_ANNOTATIONrn  (ENCRYPTION_KEY_SHUTDOWN_HOURS_ANNOTATIONro  r  DESCRIPTION_ANNOTATIONrs  rt  SandboxChangerw  NetworkInterfacesChangeru  rv  ry  ClearNetworkInterfacesChanger  CustomAudiencesChangesRemoveContainersChangeFromContainerNamesrz  ContainerDependenciesChanger  r5   !_GetContainerConfigurationChangesr|  SetServiceMeshChanger   MESH_ANNOTATIONr~  IDENTITY_ANNOTATION&ENABLE_WORKLOAD_CERTIFICATE_ANNOTATIONr   r  r  MESH_DATAPLANE_ANNOTATIONr  *IngressContainerBaseImagesAnnotationChanger1  PresetChanger  RemovePresetsChanger  )rc  r   rI  rM  r  re  diffnetwork_tags_is_setrw  r  r4  s              r:   _GetConfigurationChangesr    s7   ' T7

 6NN>--djj9:4NN>$'(t_Fi ;						'	'	+	+T	+	:  "$'' "NN&&// 	0 	
 $ 566

"
"$ 566

"
"NN..3311	
 $00T5G5G$00T5G5GNN)) 2 2	

 tNN%d+,|,,(=NN&&tF tm<122t7L7LNN++t7L7LM 4  NN(./
d]txxNN>11dhh?@$++NN>11EF
d]txxNN>11dhh?@xx3nn^112>?566NN//!%!:!:	

 //nn

,
,d6H6H
I nn^77dCD/00nn

-
-t7J7J
K nn^88tDE011nn

.
.8L8L
M nn^99EF$4#7#7NN,, 00	

 T tX.. 	 
 +:d+BT''#1T#9duD
 nn^0067!3!3NN>44T5G5GHI|,,NN22994??	

 d"t'?'?NN>99;<$4<<3NN>88FGt^		-NN>55dii@A566NN**1143L3L	

 ;<<NN--11	

 |,,NN**55t	

 u%%NN2222DHH	

 @AANN22NN00	
 >??NN22GG..	
 {++NN5522	

 NN55NN	

 NN55GG	

 FGGNN55NN	

 NN55GG	

 DEENN55GG	

 }--NN**--t/?/?	

 $)C)CNN>//0J0JKL$	**	T8	,	,	T>	2	2	T#7	8	8-d4HIL400 &&lNN..i0LLh/KK	
	 !3!3NN>>>@A%%NN>88>?233NN--@@""	
 NN>==?@|,,*.//*?*?*A&nn
+ +B v&&yynn

-
- '',,4488$8G		 nn

7
7&&
 z**}}nn

4
4**DMM nn

7
7**
 <==NN22;;001779	
 /00NN22..	
 |,,NNAA	

 122NNAA	

 x((NN##V$T[[-B	
 //NN**,,	

 
.rJ   c                    [        U S5      nU[        R                  R                  :X  a]  U R                   HL  nSU;   d  M  U(       a  [
        R                  " S5      eSU;  d  M0  [        R                  " US   5      US'   MN     gg)a  Validates used of the volumes shortcut and generates volume names when needed.

Specifically, it checks that the 'mount-path' parameter is not being used
with the --containers flag and that the volume type is an allowed type. If
validation succeeds and the volume also needs a name, one is generated.

Args:
  args: The argparse namespace containing the parsed command line arguments.
  release_track: The current release track (e.g., base.ReleaseTrack.ALPHA).
r  r  zWhen using the --containers flag, "mount-path" cannot be specified under the --add-volume flag. Instead, specify "mount-path" using the --add-volume-mount flag after the --container flag of the container the volume should be mounted to.r   r&   N)	r`  r   r   r   rT  r   r  r   GenerateVolumeName)rc  r   uses_containers_flagr  s       r:   r  r  W  s     -T<@d''---// 
	%88  )<<VF^L&. " .rJ   c                    U[         R                  R                  :X  am  / nU R                   H/  nSU;   d  M  SU;   d  M  US   US   S.nUR	                  U5        M1     U(       a$  UR	                  [
        R                  " US95        ggg)a	  Adds a VolumeMountChange to the list of changes if applicable.

This function checks if new volume mounts should be added based on the
`--add-volume` flag in ALPHA release track. If a volume in `args.add_volume`
has a 'mount-path', a corresponding AddVolumeMountChange
is appended to the `changes` list.

Args:
  args: The argparse namespace containing the parsed command line arguments.
  changes: A list of configuration changes to append to.
  release_track: The current release track (e.g., base.ReleaseTrack.ALPHA).
r  r   )r  r  rV  N)r   r   r   rT  r   r   r  )rc  rI  r   new_volume_mountsr  volume_mount_argss         r:   r  r  v  s     d''---//		Ff$4Vn .
 	  !23 " nn

-
-*  .rJ   c                    / n[        U S5      (       a;  U R                  b.  UR                  [        R                  " U R                  US95        [        U 5      (       a  UR                  [        XS95        U R                  S5      (       a.  UR                  [        R                  " U R                  US95        U R                  S5      (       a.  UR                  [        R                  " U R                  US95        [        U S5      (       ad  U R                  (       a/  UR                  [        R                  " U R                  US95        O$UR                  [        R                  " S	US
95        [        U S5      (       ad  U R                  (       a/  UR                  [        R                  " U R                  US95        O$UR                  [        R                  " S	US
95        [        U S5      (       ad  U R                   (       a/  UR                  [        R"                  " U R                  US95        O$UR                  [        R"                  " S	US
95        U R%                  S5      (       a.  UR                  [        R                  " U R&                  US95        U R                  S5      (       a.  UR                  [        R(                  " U R*                  US95        U R                  S5      (       a.  UR                  [        R,                  " U R.                  US95        [        U S5      (       d  [        U S5      (       a9  UR                  [        R0                  " U R2                  U R4                  US95        [7        U 5      (       a  UR9                  [;        XS95        [        U S5      (       a.  UR                  [        R<                  " U R>                  US95        U$ )z,Returns per-container configuration changes.rY   r{  rX  )rX  r  rY  )rY  r  r_  )r`  r  T)ra  r  rb  rc  rZ  )rZ  r  rj  rc  rN  rO  )rP  rQ  r  rU  )rW  r  ) r2  rY   r   r   r  rq  r  rD  r  rX  rY  r`  r_  r  rb  r  rc  r  IsKnownAndSpecifiedrZ  r  rj  r  rc  r  rN  rO  r  r  r  r  rU  r4  r  rI  s      r:   r  r    sN   ' ^W%%.*>*>*JNN""  	

 >""NN~E &&NN&&"">	

 ))NN&&!((	

 99##nn

,
,%33+ nn

,
,
 )9::$$nn

-
-%44+ nn

-
-
 ):;;%%nn

.
.%44+ nn

.
. ''..NN&&"">	

 	**NN--"">	

 ''NN**	

 + >+@AANN..)==';;)	
 ~&&NN>I );<<NN++%66)	
 
.rJ   c                     [        U SS5      c  / $ U R                  (       a&  [        R                  " [        R
                  S5      /$ [        R                  " [        R
                  5      /$ )z3Returns the list of changes for IAP for given args.iapNtrue)r  r  r   r  r	   IAP_ANNOTATIONr  r  s    r:   _GetIapChangesr    sU    T5$' I	XX..w/E/EvNOO11'2H2HIJJrJ   c                 4   [        XS9nUR                  [        U 5      5        UR                  [        U 5      5        [	        U 5      (       a  UR                  [        U 5      5        SU ;   a5  U R                  (       a$  UR                  [        R                  " 5       5        SU ;   aI  U R                  (       a8  UR                  [        R                  R                  U R                  5      5        SU ;   a>  U R                  (       a-  UR                  [        R                  " U R                  S95        SU ;   aY  U R                  (       aH  U R                  R!                  5        H*  u  p4UR                  [        R"                  " X45      5        M,     [%        U S5      (       a/  UR                  [        R&                  " U R(                  5      5        SU ;   a|  U R*                  (       ak  U R*                  S	:X  a&  UR                  [        R,                  " S
5      5        O5U R*                  S:X  a%  UR                  [        R,                  " S5      5        [%        U S5      (       a  UR                  [/        U 5      5        [%        U S5      (       a-  UR                  [        R0                  " U R2                  S95        [%        U S5      (       a-  UR                  [        R0                  " U R4                  S95        [%        U S5      (       a@  U R6                  (       a/  UR                  [        R8                  " U R6                  5      5        [%        U S5      (       a-  UR                  [        R:                  " U R<                  S95        [%        U S5      (       a-  UR                  [        R>                  " U R@                  S95        [%        U S5      (       a-  UR                  [        RB                  " U RD                  S95        [%        U S5      (       a-  UR                  [        RF                  " U RH                  S95        [%        U S5      (       a-  UR                  [        RJ                  " U RL                  S95        [%        U S5      (       a  U RN                  (       aV  UR                  [        RP                  " [R        RT                  [W        U RN                  5      RY                  5       5      5        O3UR                  [        RZ                  " [R        RT                  5      5        [%        U S5      (       a-  UR                  [        R\                  " U R^                  S95        S U ;   a>  U R`                  (       a-  UR                  [        Rb                  " U R`                  S!95        [e        X5        [%        U S"5      (       a1  UR                  [        Rf                  " S#U Rh                  05      5        [%        U S$5      (       a  U Rj                  R!                  5        H  u  pVUR                  [m        Xe5      5        M!     U Rj                  R!                  5        VVs0 s H)  u  pVURo                  S"5      (       d  M  XVRh                  _M+     nnnU(       a%  UR                  [        Rf                  " U5      5        [q        U 5      nU(       a  UR                  U5        [%        U S%5      (       a-  UR                  [        Rr                  " U Rt                  S&95        UR                  [w        U 5      5        UR                  [y        U 5      5        UR                  [{        U 5      5        UR                  [}        U 5      5        U$ s  snnf )'zHReturns a list of changes to the service config, based on the flags set.r   
no_trafficconcurrencytimeout)r  update_annotationsrevision_suffixconnectivityr*   Tr+   Fr+  port)r  	use_http2)r  tagcpu_throttling)
throttling	cpu_boost)r  deploy_health_check)health_checkdefault_url)r  invoker_iam_check)r  session_affinityruntime)r  r]  r\  
depends_onr  r  domain)domain_name)?r  r  r  r  r  r   r'  r  r   NoTrafficChanger  ConcurrencyChangesFromFlagr  TimeoutChangesr  r5   r  r`  RevisionNameChangesr  r  r-  r/  ContainerPortChanger  r  r  TagOnDeployChangeCpuThrottlingChanger  StartupCpuBoostChanger  HealthCheckChanger  DefaultUrlChanger  InvokerIamChanger  r  r  r   SESSION_AFFINITY_ANNOTATIONr   r  r  RuntimeChanger  r]  r  rK  r  r  r  _GetServiceContainerChangesrD  r>  MultiRegionDomainNameChanger  r  r   r  r  )	rc  r   rI  r   r   r  r4  dependency_changesbase_image_changess	            r:   GetServiceConfigurationChangesr    sd   $TG'	..#D)*	..*401NN%d+,TdooNN>1134dt//NN>44==d>N>NOP$4<<NN>00FGT!d&=&=--335
nn^77CD 6011NN>55d6J6JKLt 1 1J&nn^<<TBC			j	(nn^<<UCDy))NN%d+,v&&NN>55499EF{++NN>55OPu%%$((NN>33DHH=>/00NN**d6I6IJ {++NN,,t~~F 455NN((d6N6NO }--NN''D4D4DE 233NN''"44	

 122nn

4
422$''(..0 nn

7
722
 y))NN>//EF4DMMNN>//GH$T3|,,NN22B3HI |,,*.//*?*?*A&nn
%n
E +B /3oo.C.C.E.E*N%%l3 	2111.E  
 nn

4
45G
H .d3nn'(x((NN22t{{K 
..%&	..+D12	..*401	..2489	.+s   *^
^c                    / nU R                  S5      (       a-  UR                  [        R                  " XR                  S95        U R                  S5      (       a.  UR                  [        R                  " U R
                  US95        U$ )z&Returns per-container Service changes.r  )r  r  r  )r  r  )rD  r   r   r  r  r  r  s      r:   r  r    sz    '''NN**)0C0C	

 ,,NN**$..~	

 
.rJ   c                 .   [        XS9nUR                  S[        R                  " [        R
                  5      5        [        U S5      (       a0  UR                  [        R                  " SU R                  5      5        [        U S5      (       a-  UR                  [        R                  " U R                  S95        [        U S5      (       a0  UR                  [        R                  " SU R                  5      5        [        U S5      (       a$  UR                  [        R                  " 5       5        [        U S	5      (       a/  UR                  [        R                  " U R                  5      5        [        U S
5      (       a/  UR                  [        R                   " U R"                  5      5        SU ;   a>  U R$                  (       a-  UR                  [        R&                  " U R$                  S95        [)        X5        [        U S5      (       a|  U R*                  R-                  5        VVs0 s H)  u  p4UR/                  S5      (       d  M  X4R0                  _M+     nnnU(       a%  UR                  [        R2                  " U5      5        U$ s  snnf )zDReturns a list of changes to the job config, based on the flags set.r  r   parallelismr  )r  r  	taskCountrY   max_retriesr  r]  r\  r  r  )r  rE  r   r  r   r  r`  r   ExecutionTemplateSpecChanger  JobPriorityTierChanger  r  JobNonceChangeJobMaxRetriesChanger  JobTaskTimeoutChanger  r]  r  rK  r  r5   rD  r  r  )rc  r   rI  r  r4  r  s         r:   GetJobConfigurationChangesr    s   $TG'	..++

3
3 }--NN224++	

 //NN,,,,	

 w''NN22;

K w''NN>0023}--NN>55d6F6FGH~..NN>66t7H7HIJ4DMMNN>//GH$T3|,, /3oo.C.C.E.E*N%%l3 	2111.E  
 nn

4
45G
H 
.s   0JJc                    / n[        U S5      (       a@  UR                  [        R                  " [	        [        U SS5      =(       d    0 5      S95        [        U S5      (       av  U R                  R                  5        HX  u  p#[        U5      (       d  M  UR                  [        R                  " [	        [        USS5      =(       d    0 5      US95        MZ     U$ )zDReturns a list of config changes caused by overrides for validation.rj  N)r  r  )r  r  )	r`  r   r   r  r;   r  r  r5   rq  )rc  rI  r  r4  s       r:   )GetExecutionOverridesChangesForValidationr    s    ' 011NN++gd,=tDJK	

 |,,*.//*?*?*A&	~	&	&//!N,=tDJ  .		
 +B 
.rJ   c                     [         R                  " S5      nUR                  U R                  5       5      (       d3  [        R
                  " SR                  U R                  5       5      5      eg)zValidate resource name.z'(?=^[a-z0-9-]{1,63}$)(?!^\-.*)(?!.*\-$)zInvalid resource name [{}]. The name must use only lowercase alphanumeric characters and dashes, cannot begin or end with a dash, and cannot be longer than 63 characters.N)recompilematchNamer   r   r^   )resource_refk8s_resource_name_regexs     r:   ValidateResourcer    sb    
 JJ0 
!	&	&|'8'8':	;	;

-
-	3396,:K:K:M3N  
<rJ   c                  $   [         R                  " 5       (       av  [        R                  " 5       n [        R                  " U 5      n[         R
                  " USSSS9nX   n[        R                  R                  SR                  U5      5        U$ g)zPrompt for region from list of available regions.

This method is referenced by the declaritive iam commands as a fallthrough
for getting the region.

Returns:
  The region specified by the user, str
zPlease specify a region:
T)messagecancel_optionallow_freeformzHTo make this the default region, run `gcloud config set run/region {}`.
N)
r   	CanPromptr   GetServerlessClientInstanceListRegionsPromptChoicer   r  r  r^   )clientall_regionsidxrM  s       r:   PromptForRegionr    s     779F ,,V4K

!
!,	C FJJ	//5vf~ M rJ   c                     [        U S5      (       a  [        U SS5      OSn[        U SS5      nU(       a  U(       a  [        R                  " SSS9eU(       a   [	        UR                  S5      5      S:  a  U$ U$ )	zReturns a list of regions if regions is defined, or region is a multi-region, empty otherwise.

Args:
  args: Namespace, The args namespace.
regionsNrM  r  z.--region and --regions are mutually exclusive.)parameter_namer  ,r  )r`  r  c_exceptionsInvalidArgumentExceptionr  r  )rc  r  rM  s      r:   GetMultiRegionr    sy     
T9	-	- dIt$ 

 44(&

/
/"@  FLL%&*M	.rJ   c                 d    [        U 5      nU(       d  gUR                  S5      nU(       a  US   $ g)zEReturns the first region if multi-region is defined. Empty otherwise.Nr  r   )r  r  )rc  multi_regionr  s      r:   GetFirstRegionr  !  s2    %,	s#'1:	rJ   c                 ^   [        U SS5      (       a  U R                  $ Ub  U$ [        R                  R                  R                  R                  5       (       a2  [        R                  R                  R                  R                  5       $ U(       a  [        5       nU(       a  X0l        U$ gg)aI  Prompt for region if not provided.

Region is decided in the following order:
- region argument;
- region label
- run/region gcloud config;
- prompt user.

Args:
  args: Namespace, The args namespace.
  prompt: bool, whether to attempt to prompt.
  region_label: a k8s label for the region

Returns:
  A str representing region.
rM  N)r  rM  r   ry  rz  IsExplicitlySetr  r  )rc  promptregion_labelrM  s       r:   r  r  ,  s    " T8T"";;!!1133  ''++--F km	  rJ   c                    [        U SS5      U l        [        R                  " U 5        U R                  (       a  U R                  $ [        R
                  R                  R                  R                  5       (       a2  [        R
                  R                  R                  R                  5       $ [        R                  " S5      e)aZ  Get Project ID if provided, or raise error.

Project ID is decided in the following order:
- project argument;
- core/project gcloud config;

Also validate that the project ID is not a project number.

Args:
  args: Namespace, The args namespace.

Returns:
  A str representing project ID.
Raises:
  ArgumentError: if project ID is not provided.
r  NzqMissing required argument [project]. Set --project flag to PROJECT ID or set core/project property to PROJECT ID.)r  r  r   RequireProjectIDr   ry  r  r  r  r   r   r  s    r:   GetProjectIDr   L  s    " y$/$,	\\<<##3355!!))--//++2	 rJ   c                 L   [        U SS5      b  U R                  $ [        U S5      (       a  U R                  (       d  gU(       a`  Ub  Uc   eUR	                  X$S9(       a.  [
        R                  " SR                  UR                  5      SS9$ [        R                  " S5        g)	a  Return bool for the explicit intent to allow unauth invocations or None.

If --[no-]allow-unauthenticated is set, return that value. If not set,
prompt for value if desired. If prompting not necessary or doable,
return None, indicating that no action needs to be taken.

Args:
  args: Namespace, The args namespace
  client: from googlecloudsdk.command_lib.run import serverless_operations
    serverless_operations.ServerlessOperations object
  service_ref: service resource reference (e.g. args.CONCEPTS.service.Parse())
  prompt: bool, whether to attempt to prompt.
  region_override: If present, will use instead of currently selected region.

Returns:
  bool indicating whether to allow/unallow unauthenticated or None if N/A
allow_unauthenticatedNr  )region_overridez)Allow unauthenticated invocations to [{}]F)r  r   z7This service will require authentication to be invoked.)r  r"  r`  r  CanSetIamPolicyBindingr   r  r^   
servicesIdr   Info)rc  r  service_refr  r#  s        r:   GetAllowUnauthenticatedr(  i  s    ( T*D1=%%% $ 344$$+"999$$ %  &&CJJ$$ 	  
C 
rJ   c                    U (       a3  [         R                  R                  [        R                  " U 5      5      $ [
        R                  " [        R                  S5      (       a  [
        R                  " [        R                  S5      R                  [        R                  5      nSnU HS  n [         R                  R                  [        R                  " U5      5      nU(       d  UnMB  UR                  U5        MU     U(       d  [        S5      eU$ [         R                  R                  [        R                  " [        5      5      $ ! [         R                   a     M  f = f)a  Get config from kubeconfig file.

Get config from potentially 3 different places, falling back to the next
option as necessary:
1. file_path specified as argument by the user
2. List of file paths specified in $KUBECONFIG
3. Default config path (~/.kube/config)

Args:
  file_path: str, the path to the kubeconfig if provided by the user

Returns:
  dict: config object

Raises:
  KubeconfigError: if $KUBECONFIG is set but contains no valid paths

KUBECONFIGNz(No valid file paths found in $KUBECONFIG)r   
KubeconfigLoadFromFiler    ExpandHomeDirr   GetEncodedValueosenvironr  pathsepMergeErrorrB   r  )	file_pathconfig_pathskube_configpathother_configs        r:   GetKubeconfigr9    s   $   --e.A.A).LMMbjj,77++BJJEKK


L K	!,,99%
 $+


L
)  FGG				+	+23
   s   /<E-EE%$E%c                 H    [        X5      =(       a    U R                  U5      $ )z7Return True if --flag is explicitly passed by the user.)r2  rD  )rc  rb  s     r:   r`  r`    s     
		7!1!1$!77rJ   c                 x   U[         R                  :X  a3  [        R                  " SR	                  [
        R                  5      5      eSn[        U S5      (       aR  [        R                  " UR	                  S[
        R                  [
        R                  [
        R                     S95      e[        U S5      (       aR  [        R                  " UR	                  S[
        R                  [
        R                  [
        R                     S95      e[        U S5      (       aR  [        R                  " UR	                  S	[
        R                  [
        R                  [
        R                     S95      e[        U S
5      (       aR  [        R                  " UR	                  S[
        R                  [
        R                  [
        R                     S95      e[        U 5      (       aR  [        R                  " UR	                  S[
        R                  [
        R                  [
        R                     S95      e[        U S5      (       aR  [        R                  " UR	                  S[
        R                  [
        R                  [
        R                     S95      e[        U S5      (       af  U[         R                  :X  aR  [        R                  " UR	                  S[
        R                  [
        R                  [
        R                     S95      e[        U S5      (       aR  [        R                  " UR	                  S[
        R                  [
        R                  [
        R                     S95      e[        U S5      (       aR  [        R                  " UR	                  S[
        R                  [
        R                  [
        R                     S95      e[        U S5      (       aR  [        R                  " UR	                  S[
        R                  [
        R                  [
        R                     S95      eg)zDRaise ConfigurationError if args aren't valid for managed Cloud Run.z}The flag --platform={0} is not supported. Instead of using the flag --platform={0} in "gcloud events", run "gcloud eventarc".zThe `{flag}` flag is not supported on the fully managed version of Cloud Run. Specify `--platform {platform}` or run `gcloud config set run/platform {platform}` to work with {platform_desc}.r  z"--connectivity=[internal|external]rb  r{  platform_desc	namespacez--namespacecluster	--clustercluster_location--cluster-locationz'--[update|set|remove|clear]-config-mapsbrokerz--brokercustom_typez--custom-typer   r~  contextr  trigger_filtersz--trigger-filtersN)rL   rR   r   r  r^   r   r|  r`  PLATFORM_GKEPLATFORM_SHORT_DESCRIPTIONSr  PLATFORM_KUBERNETESrc  r   product	error_msgs       r:   VerifyManagedFlagsrM    s    

2
2	!!'	(B(B!C   ~..

2
25++#??&& 	 	
  {++

2
2++#??&& 	 	
  y))

2
2++#??&& 	 	
  122

2
2%++#??&& 	 	
  4  

2
2:++#??&& 	 	
  x((

2
2++#??&& 	 	
  }--'W^^2K

2
2 ++#??&& 	 	
  |,,

2
222#??-- 	 	
  y))

2
222#??-- 	 	
  011

2
2$++#??&& 	 	
  2rJ   c                    Sn[        U S5      (       a  [        R                  " S5      e[        U S5      (       a'  [        U S5      (       a  [        R                  " S5      e[        U S5      (       aR  [        R                  " UR                  S[        R
                  [        R                  [        R
                     S	95      e[        U S
5      (       aR  [        R                  " UR                  S[        R
                  [        R                  [        R
                     S	95      e[        U S5      (       aR  [        R                  " UR                  S[        R
                  [        R                  [        R
                     S	95      e[        U S5      (       aR  [        R                  " UR                  S[        R
                  [        R                  [        R
                     S	95      e[        U S5      (       aR  [        R                  " UR                  S[        R
                  [        R                  [        R
                     S	95      e[        U S5      (       aR  [        R                  " UR                  S[        R
                  [        R                  [        R
                     S	95      e[        U S5      (       aR  [        R                  " UR                  S[        R
                  [        R                  [        R
                     S	95      e[        U S5      (       aR  [        R                  " UR                  S[        R
                  [        R                  [        R
                     S	95      e[        U S5      (       aR  [        R                  " UR                  S[        R
                  [        R                  [        R
                     S	95      e[        U S5      (       aR  [        R                  " UR                  S[        R
                  [        R                  [        R
                     S	95      e[        U S5      (       aR  [        R                  " UR                  S[        R
                  [        R                  [        R
                     S	95      e[        U S5      (       aR  [        R                  " UR                  S[        R
                  [        R                  [        R
                     S	95      e[        U S 5      (       aR  [        R                  " UR                  S![        R
                  [        R                  [        R
                     S	95      e[        U S"5      (       aR  [        R                  " UR                  S#[        R
                  [        R                  [        R
                     S	95      e[        U S$5      (       aR  [        R                  " UR                  S%[        R
                  [        R                  [        R
                     S	95      e[        U S&5      (       aR  [        R                  " UR                  S'[        R
                  [        R                  [        R
                     S	95      e[        U S(5      (       aR  [        R                  " UR                  S)[        R
                  [        R                  [        R
                     S	95      e[        U S*5      (       aR  [        R                  " UR                  S+[        R
                  [        R                  [        R
                     S	95      e[        U S,5      (       aR  [        R                  " UR                  S-[        R
                  [        R                  [        R
                     S	95      e[        U S.5      (       aR  [        R                  " UR                  S/[        R
                  [        R                  [        R
                     S	95      e[        U S05      (       aR  [        R                  " UR                  S1[        R
                  [        R                  [        R
                     S	95      e[        U S25      (       aR  [        R                  " UR                  S3[        R
                  [        R                  [        R
                     S	95      e[        U S45      (       aR  [        R                  " UR                  S5[        R                  [        R                  [        R                     S	95      e[        U S65      (       aR  [        R                  " UR                  S7[        R                  [        R                  [        R                     S	95      e[        U S85      (       aR  [        R                  " UR                  S9[        R
                  [        R                  [        R
                     S	95      e[        U S:5      (       aR  [        R                  " UR                  S;[        R
                  [        R                  [        R
                     S	95      eg<)=zERaise ConfigurationError if args includes OnePlatform only arguments.zThe `{flag}` flag is not supported with Cloud Run for Anthos deployed on Google Cloud. Specify `--platform {platform}` or run `gcloud config set run/platform {platform}` to work with {platform_desc}.r"  a   The `--[no-]allow-unauthenticated` flag is not supported with Cloud Run for Anthos deployed on Google Cloud. All deployed services allow unauthenticated requests. The `--connectivity` flag can limit which network a service is available on to reduce access.r  r+  wCannot specify both the `--connectivity` and `--ingress` flags. `--connectivity` is deprecated in favor of `--ingress`.rM  r   r<  rt  r  rg  r  ri  r  rh  r  rk  r,  rl  r+  rm  r0  ru  r4  rv  r;  znetwork-tagsr?  r   r  rn  r  ro  r  rp  r  rq  r  rr  r  r  --set-custom-audiencesr  --add-custom-audiencesr  --remove-custom-audiencesr  --clear-custom-audiencesr  rR  r   r~  rE  r  rT  r   r  r   N)r`  r   r  r^   r   r|  rH  rI  rJ  s       r:   VerifyGKEFlagsrT  L  sr	     677

2
2	  ~..3F
I4 4  
2
2	C 
 x((

2
2//#??** 	 	
  677

2
2*//#??** 	 	
  //

2
2"//#??** 	 	
  455

2
2(//#??** 	 	
  |,,

2
2//#??** 	 	
  566

2
2)//#??** 	 	
  ;<<

2
2///#??** 	 	
  |,,

2
2//#??** 	 	
  y))

2
2//#??** 	 	
  x((

2
2//#??** 	 	
  ~..

2
2!//#??** 	 	
  u%%

2
2//#??** 	 	
  @AA

2
24//#??** 	 	
  >??

2
22//#??** 	 	
  {++

2
2//#??** 	 	
  FGG

2
2://#??** 	 	
  DEE

2
28//#??** 	 	
  566

2
2)//#??** 	 	
  566

2
2)//#??** 	 	
  899

2
2,//#??** 	 	
  788

2
2+//#??** 	 	
  122

2
2%//#??** 	 	
  |,,

2
222#??-- 	 	
  y))

2
222#??-- 	 	
  |,,

2
2//#??** 	 	
  u%%

2
2//#??** 	 	
  &rJ   c                 X   Sn[        U S5      (       a  [        R                  " S5      e[        U S5      (       a'  [        U S5      (       a  [        R                  " S5      e[        U S5      (       aR  [        R                  " UR                  S[        R
                  [        R                  [        R
                     S	95      e[        U S
5      (       aR  [        R                  " UR                  S[        R
                  [        R                  [        R
                     S	95      e[        U S5      (       a6  [        R                  " UR                  SS[        R                  S   S	95      e[        U S5      (       aR  [        R                  " UR                  S[        R
                  [        R                  [        R
                     S	95      e[        U S5      (       aR  [        R                  " UR                  S[        R
                  [        R                  [        R
                     S	95      e[        U S5      (       aR  [        R                  " UR                  S[        R
                  [        R                  [        R
                     S	95      e[        U S5      (       aR  [        R                  " UR                  S[        R
                  [        R                  [        R
                     S	95      e[        U S5      (       aR  [        R                  " UR                  S[        R
                  [        R                  [        R
                     S	95      e[        U S5      (       aR  [        R                  " UR                  S[        R
                  [        R                  [        R
                     S	95      e[        U S5      (       aR  [        R                  " UR                  S[        R
                  [        R                  [        R
                     S	95      e[        U S5      (       aR  [        R                  " UR                  S[        R
                  [        R                  [        R
                     S	95      e[        U S5      (       aR  [        R                  " UR                  S [        R
                  [        R                  [        R
                     S	95      e[        U S!5      (       aR  [        R                  " UR                  S"[        R
                  [        R                  [        R
                     S	95      e[        U S#5      (       aR  [        R                  " UR                  S$[        R
                  [        R                  [        R
                     S	95      e[        U S%5      (       aR  [        R                  " UR                  S&[        R
                  [        R                  [        R
                     S	95      e[        U S'5      (       aR  [        R                  " UR                  S([        R
                  [        R                  [        R
                     S	95      e[        U S)5      (       aR  [        R                  " UR                  S*[        R
                  [        R                  [        R
                     S	95      e[        U S+5      (       aR  [        R                  " UR                  S,[        R
                  [        R                  [        R
                     S	95      e[        U S-5      (       aR  [        R                  " UR                  S.[        R
                  [        R                  [        R
                     S	95      e[        U S/5      (       aR  [        R                  " UR                  S0[        R                  [        R                  [        R                     S	95      e[        U S15      (       aR  [        R                  " UR                  S2[        R                  [        R                  [        R                     S	95      e[        U S35      (       aR  [        R                  " UR                  S4[        R
                  [        R                  [        R
                     S	95      e[        U S55      (       aR  [        R                  " UR                  S6[        R
                  [        R                  [        R
                     S	95      eg7)8zLRaise ConfigurationError if args includes OnePlatform or GKE only arguments.zThe `{flag}` flag is not supported with Cloud Run for Anthos deployed on VMware. Specify `--platform {platform}` or run `gcloud config set run/platform {platform}` to work with {platform_desc}.r"  zThe `--[no-]allow-unauthenticated` flag is not supported with Cloud Run for Anthos deployed on VMware. All deployed services allow unauthenticated requests. The `--connectivity` flag can limit which network a service is available on to reduce access.r  r+  rO  rM  r   r<  rt  r  rg  r  managedri  r  rh  r  rk  r,  rl  r+  rm  r0  r   r  rn  r  ro  r  rp  r  rq  r  rr  r  r  rP  r  rQ  r  rR  r  rS  r  rR  r?  r@  rA  rB  rT  r   r  r   N)r`  r   r  r^   r   r|  rH  rG  rJ  s       r:   VerifyKubernetesFlagsrW    s\     677

2
2	  ~..3F
I4 4  
2
2	C 
 x((

2
2//#??** 	 	
  677

2
2*//#??** 	 	
  //

2
2"#??	J 	 	
  455

2
2(//#??** 	 	
  |,,

2
2//#??** 	 	
  566

2
2)//#??** 	 	
  ;<<

2
2///#??** 	 	
  |,,

2
2//#??** 	 	
  u%%

2
2//#??** 	 	
  @AA

2
24//#??** 	 	
  >??

2
22//#??** 	 	
  {++

2
2//#??** 	 	
  FGG

2
2://#??** 	 	
  DEE

2
28//#??** 	 	
  566

2
2)//#??** 	 	
  566

2
2)//#??** 	 	
  899

2
2,//#??** 	 	
  788

2
2+//#??** 	 	
  122

2
2%//#??** 	 	
  y))

2
2++#??&& 	 	
  122

2
2%++#??&& 	 	
  |,,

2
2//#??** 	 	
  u%%

2
2//#??** 	 	
  &rJ   c                    [         R                  " 5       nU[         R                  :X  a  [        XU5        OAU[         R                  :X  a  [        XU5        O U[         R                  :X  a  [        XU5        U[         R                  ;  au  [        R                  " SR                  USR                  [         R                  R                  5        VVs/ s H  u  pESR                  XE5      PM     snn5      5      5      eU$ s  snnf )a  Returns the platform to run on and validates specified flags.

A given command may support multiple platforms, but not every flag is
supported by every platform. This method validates that all specified flags
are supported by the specified platform.

Args:
  args: Namespace, The args namespace.
  release_track: base.ReleaseTrack, calliope release track.
  product: Product, which product the command was executed for (e.g. Run or
    Events).

Raises:
  ArgumentError if an unknown platform type is found.
z@Invalid target platform specified: [{}].
Available platforms:
{}
z- {}: {})r   r)  r|  rM  rG  rT  rI  rW  ru  r   r   r^   rT  r5   )rc  r   rK  r{  r8   r9   s         r:   GetAndValidatePlatformrZ    s      ""$(+++tG49)))409000$w7Y(((

-
-	##)6II4=4G4G4M4M4O4ODA
!!!'4O $
  
/s   Dc                     [         R                  " 5       nU[         R                  :w  a%  [        R                  " SR                  U5      5      e[        XU5        g)a6  Validates the platform being 'managed' only and specified flags.

A given command only supports 'managed' platform, but not every flag is
supported by every platform. This method validates that platform set for the
given command is 'managed' and all specified flags
are supported by the 'managed' platform.

Args:
  args: Namespace, The args namespace.
  release_track: base.ReleaseTrack, calliope release track.
  product: Product, which product the command was executed for (e.g. Run or
    Events).

Raises:
  ArgumentError if the platform type is not 'managed'.
z`Invalid target platform specified: [{}].
This command is only supported for platform "managed".
N)r   r)  r|  r   r   r^   rM  )rc  r   rK  r{  s       r:   ValidateManagedPlatformr\    sS    " ""$(+++

-
-	CCI6D
  T'2rJ   c                     U R                  SSSSSS9  U R                  SSSSS	S9  U R                  S
SSSSS9  U R                  SSSSSS9  U R                  SSSSSS9  U R                  SSSSSS9  U R                  S[        R                  S/ SQSS9  U R                  S[        R                  SSS/SS9  U R                  S[        R                  S/ SQSS9  U R                  S[        R                  SSS/SS9  g )!zAdd filter flags for task list.z--succeededappend_constfilter_flags	SucceededzInclude succeeded tasks.)r$   r}   constr"   z--failedFailedzInclude failed tasks.z--cancelled	CancelledzInclude cancelled tasks.z	--runningRunningzInclude running tasks.z--abandoned	AbandonedzInclude abandoned tasks.z	--pendingPendingzInclude pending tasks.z--completed)r`  rb  rc  z/Include succeeded, failed, and cancelled tasks.z--no-completedz"Include running and pending tasks.z	--started)r`  rb  rc  rd  z8Include running, succeeded, failed, and cancelled tasks.z--no-startedz$Include pending and abandoned tasks.N)r]   r   ExtendConstActionrt   s    r:   AddTaskFilterFlagsrh    s   %   	"   	%   	#   	%   	#   	**0<   	**	"/   	**;E   	**$1  rJ   c                 &    U R                  SSSS9  g)z2Add --execute-now flag for Job creation or update.z--execute-nowr   zExecute the job immediately after the creation or update  completes. gcloud exits once the job has started unless the `--wait` flag is set.rq   Nr   rt   s    r:   AddExecuteNowFlagrj  %  s        rJ   c                  ,    [         R                  " SSS9$ )Nz--sourceaQ  The location of the source to build. If a Dockerfile is present in the source code directory, it will be built using that Dockerfile, otherwise it will use Google Cloud buildpacks. See https://cloud.google.com/run/docs/deploying-source-code for more details. The location can be a directory on a local disk or a gzipped archive file (.tar.gz) in Google Cloud Storage. If the source is a local directory, this command skips the files specified in the `--ignore-file`. If `--ignore-file` is not specified, use `.gcloudignore` file. If a `.gcloudignore` file is absent and a `.gitignore` file is present in the local source directory, gcloud will use a generated Git-compatible `.gcloudignore` file that respects your .gitignored files. The global `.gitignore` is not respected. For more information on `.gcloudignore`, see `gcloud topic gcloudignore`.r!   r  rD   rJ   r:   	SourceArgrl  0  s    	"
 rJ   c                  2    [         R                  " SSSSSS9$ )Nz
--no-buildr   FTzmWhen set, the cloud build step will be skipped and the provided will be extracted directly on the base image.r$   r   r#   r"   r  rD   rJ   r:   
NoBuildArgro  F  s$    	;	
 	rJ   c                     [         R                  " US9nUR                  [        SXS95        UR                  [	        5       5        U[         R
                  R                  :w  a  UR                  [        5       5        U$ )zDReturns a group of flags for deploy source, an image or source code.rc   F)r[   rY   rc   )r   r  r  re   rl  r   GAro  )rY   rc   r   r   s       r:   SourceAndImageFlagsrs  S  sb     

5
)%He5FGIK d''***	jl#	,rJ   c                  4    Sn [         R                  " SSSU S9$ )z*Create a dummy --container flag for usage.z
  Specifies a container by name. Flags following --container will apply to the specified container.

  Flags that are not container-specific must be specified before --container.
  r   	CONTAINERr  )r   r}   r"   r  r  s    r:   ContainerFlagrv  a  s(    )
 
	
 rJ   c            	      |    [         R                  " S[        R                  [        R                  " [
        SS9SSS9$ )Nz--remove-containers	   element_type
max_lengthru  zList of containers to remove.r  r   rb   r   r   r   _CONTAINER_NAME_TYPErD   rJ   r:   RemoveContainersFlagr~  q  s6    	%%,@QO*
 rJ   c            	      |    [         R                  " S[        R                  [        R                  " [
        SS9SSS9$ )Nz--depends-onrx  ry  ru  z?List of container dependencies to add to the current container.r  r|  rD   rJ   r:   DependsOnFlagr  {  s6    	%%,@QOL
 rJ   c                 *   [         R                  " 5       (       ay  [        R                  " S5        [        R
                  " 5       nU (       a  SR                  U S9nOSn[         R                  " X!S9n[        R                  R                  S5        U$ g)zPrompt for source code location when image flag is not set.

Returns:
  The source code location
Args:
  container_name: The name of the container to prompt for.
zDeploying from source. To deploy a container use [--image]. See https://cloud.google.com/run/docs/deploying-source-code for more details.z$Source code location for {container})	containerzSource code locationr  r   zNNext time, you can use `--source .` argument to deploy the current directory.
N)r   r  r   r&  r    GetCWDr^   PromptWithDefaultr   r  r  )r  cwdr  sources       r:   PromptForDefaultSourcer    s     	
 ,,.C6==" > g 'g))'GFJJ	 M' rJ   c                  f    [         R                  " 5       (       a  Sn [         R                  " U SS9$ g)zGPrompt for clearing --command when user tries to deploy function to CR.zzDeploying a function to Cloud Run has the effect of removing any value previously set for --command in the same container.Fr  )r   r  r  )r  s    r:   PromptForClearCommandr    s;    	?  $$  
rJ   c                 (    U R                  SSSSS9  g)zAdd --dry-run flag.z	--dry-runr   FzXIf set to true, only validates the configuration. The configuration will not be applied.r$   r   r"   Nr   rt   s    r:   AddDryRunFlagr    s#    "  rJ   c                 *    U R                  SSSSSS9  g)zAdd --dev flag.z--devr   FTz=If set to true, will execute the command in development mode.rn  Nr   rt   s    r:   
AddDevFlagr    s$    J  rJ   c                 *    U R                  SSSSSS9  g)zAdd --debug or -d flag.z-dz--debugr   Fz"If set to true, enables debug moder  Nr   rt   s    r:   AddDebugFlagr    s$    
/  rJ   c                  ,    [         R                  " SSS9$ )z1Specify that the deployed resource is a function.z
--functionzoSpecifies that the deployed object is a function. If a value is provided, that value is used as the entrypoint.r!   r  rD   rJ   r:   FunctionArgr    s    	@
 rJ   c                      [         R                  " SS9n U R                  [         R                  " SSS95        U R                  [         R                  " SSSS	95        U $ )
/Adds automatic base image update related flags.Trq  z--base-imagea9  Specifies the base image to be used for automatic base image updates. When deploying from source using the Google Cloud buildpacks, this flag will also override the base image used for the application image. See https://cloud.google.com/run/docs/configuring/services/automatic-base-image-updates for more details.r!   z--clear-base-imager   z)Opts out of automatic base image updates.rq   r   r  r  rb   r(  s    r:   BaseImageArgr    s`    


4
(%
mm
#
 
mm
: 
,rJ   c                  J    [         R                  " S[        R                  SS9$ )r  z--automatic-updatesz`Indicates whether automatic base image updates should be enabled for an image built from source.rq   r  rD   rJ   r:   AutomaticUpdatesFlagr    s$    	--)	
 rJ   c                      [         R                  " SS9n U R                  [         R                  " SSS95        U R                  [         R                  " SSSS	95        U $ )
z>Add flags for specifying Cloud Build Custom Build Worker Pool.Trq  z--build-worker-poola  
          Name of the Cloud Build Custom Worker Pool that should be used to build
          the function. The format of this field is
          `projects/${PROJECT}/locations/${LOCATION}/workerPools/${WORKERPOOL}`
          where ${PROJECT} is the project id and ${LOCATION} is the location where
          the worker pool is defined and ${WORKERPOOL} is the short name of the
          worker pool.
        r!   z--clear-build-worker-poolr   zD
          Clears the Cloud Build Custom Worker Pool field.
        rq   r  r(  s    r:   BuildWorkerPoolMutexGroupr    sb    


4
(%
mm

 
mm
% 
,rJ   c                      [         R                  " SS9n U R                  [        5       5        U R                  [	        5       5        U $ )z@Add --function and --command flag, which are mutually exclusive.Trq  )r   r  r  r  r  r(  s    r:   AddCommandAndFunctionFlagr  "  s7    


4
(%KM"KM"	,rJ   c                 &    U R                  SSSS9  g)z?Adds flag to indicate using Build API for source deploy builds.z--delegate-buildsr   zg      Specifies that the source deploy for run will use the Build API
      to submit the build.
      rq   Nr   rt   s    r:   AddDelegateBuildsFlagr  *  s     
  rJ   c                      [         R                  " SS9n U R                  [        5       5        U R                  [	        5       5        U $ )zHAdds flags for configuring the build service account for Cloud Function.Trq  )r   r  r  BuildServiceAccountFlagClearBuildServiceAccountFlagr(  s    r:   BuildServiceAccountMutexGroupr  6  s;    


4
(%+-.023	,rJ   r   c                     [         R                  " S5      nU (       a;  UR                  U 5      (       d%  [        R                  " SR                  U 5      5      eU $ )a  Define a Service acccount type which needs to follow the pattern projects/<projectId>/serviceAccounts/<serviceAccount>.

Args:
  value: The service account provided by the user. Empty string is allowed
    which means build service account will be cleared.

Returns:
  The service account provided by the user after validation.
Raises:
  ArgumentError if the service account value does not follow the pattern
  projects/<projectId>/serviceAccounts/<serviceAccount>.
z)^projects\/[^/]+\/serviceAccounts\/[^/]+$zInvalid service account value [{}]. The service account value must follow the pattern projects/<projectId>/serviceAccounts/<serviceAccount>.)r  r  r  r   r   r^   )r   service_account_regexs     r:   ServiceAccountr  >  sU     **2 (..u55

-
-	AAG 
 
,rJ   c                  6    [         R                  " S[        SS9$ )zUAdds flag to specify a service account to use for the build for source deploy builds.z--build-service-accountz      Specifies the service account to use to execute the build. Applies only
      to source deploy builds using the Build API.
      rh  )r   rb   r  rD   rJ   r:   r  r  W  s    	

 rJ   c                  .    [         R                  " SSSS9$ )z)Adds flag to clear build service account.z--clear-build-service-accountr   z-Clears the Cloud Build service account field.rq   r  rD   rJ   r:   r  r  c  s    	%:
 rJ   c                     [         R                  U;  d"  [        U S5      (       d  [        U S5      (       a  g[        R                  " UR                  [         R                  S5      SSS9$ )Nr^  quietFz:Would you like to deploy with no zonal redundancy instead?T)r  r   r  )r   REDEPLOY_GPU_WITH_FLAG_MESSAGEr`  r   r  replace)rc  error_messages     r:   ShouldRetryNoZonalRedundancyr  l  sc    ::-O	T#9	:	:	T7	+	+		"	"!))

>
>
F 
 rJ   c                 j    U R                  SS9n[        5       R                  U5        [        U5        g)z5Add the --preset flag and other preset related flags.T)r#   N)r   
PresetFlagrk   AddClearPresetFlagr-  s     r:   AddPresetFlagsr  }  s-    

-
-T
-
:%,5!UrJ   c                  X    [         R                  " S[        R                  " 5       SSSS9$ )zCreate a --preset flag.z--presetPRESETz1Specifies a preset to be used for the deployment.T)r&   r   r"   r#   )r   rb   r   	PresetArgrD   rJ   r:   r  r    s+    	!>
 rJ   c                 *    U R                  SSSSSS9  g)zAdd the --clear-presets flag.z--clear-presetsz'Clears all presets from the deployment.r   FT)r"   r$   r   r#   Nr   rt   s    r:   r  r    s$    4  rJ   )TrT   )TrT   T)FF)F)r  NNNKEYVALUEF)r  NNNr  r  )r  )T)r	   Fr4   )FN)NNFN(#  r  enumr/  r  apitools.base.pyr   r   googlecloudsdk.api_lib.containerr   googlecloudsdk.api_lib.runr   r   r   r   r	   r
   googlecloudsdk.api_lib.servicesr   r  googlecloudsdk.callioper   r   r   r  .googlecloudsdk.command_lib.functions.v2.deployr   googlecloudsdk.command_lib.runr   r   r   r   r   r   r   r   $googlecloudsdk.command_lib.util.argsr   r   r   (googlecloudsdk.command_lib.util.conceptsr   googlecloudsdk.corer   r   r   googlecloudsdk.core.consoler   googlecloudsdk.core.utilr   r    rb   SERVICE_MESH_FLAGIDENTITY_FLAGrs    ENABLE_WORKLOAD_CERTIFICATE_FLAGStoreOnceActionr   MESH_DATAPLANE_FLAG	frozensetINGRESS_CONTAINER_PRESETSPRIVATE_ACCESS_PRESETSPUBLIC_ACCESS_PRESETSr   r   r  r  r  r  RegexpValidatorr}  r  r  r;   r@   r3  rB   EnumrL   r`   re   ro   ru   rz   r   r   r   r   r   r   r   r   rh   r   r   r   r   r   r   r   _DEFAULT_DEPLOY_TAG_HELPr   r   r   r   r   r   r   r   r	  r  r  r  r   r  r   rr  r%  r)  r+  r.  r0  r2  r4  r6  r9  r;  r?  rB  rD  r]  rY  ra  rV  rZ  r^  rb  rf  rj  rq  rs  rg   rl   r  r  r  r  r  r  r  r  r  CONFIG_MAP_FLAGSr  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r	  r  _DEFAULT_PORT_HELPr  r  r  r  r  r  r"  r$  r'  r)  r.  r2  r9  r=  r@  rB  rD  rI  rL  rN  rP  rS  rV  rX  r[  r]  rh  rq  ry  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r  r   r'  r/  r5  r8  r>  rK  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r(  r9  r`  rM  rT  rW  rZ  r\  rh  rj  rl  ro  rs  rv  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rD   rJ   r:   <module>r     sE   =  	 	 > 7 9 5 1 / . . 6 M + / ( > H 9 N 4 5 7 8 : 2 < 9 9 D & * # * 2 - *MM	I  	C  $(==#	I++	$   mm	B&&	()  & '   #$   "#  
 33  <*" OO  E	   , 
 	F1 - #22)   &  .)j&& dii  
=  
=
0,	0("*&(	
	  (@ /
>]@CL	 3l6 AN !H %)$5$5$8$8 "J>1
,*,
P#/ 

	" 
! 	# (V>
@
B

;**
D"'(%
 "	?  ' .@"(
 
&
 
4
 
2 -`. ++..i6$
6P
	
	* $(  ) 	 #5 	"
	2
80  "		
9B
0 
&@
	%++'(-&I)+
+"DPf
(V F
((60  > %> "&4&
$ 261B1B1E1E FR
M><od
K 8<7H7H7K7K l^$ 483D3D3G3G 1h2 4,@< HL,^*Z8}@vr	Sl!H38GT,
 >
##&& <
4	8	# 2	"rJ   