
    7                        S r SSKJr  SSKJr  SSKJr  SSKrSSKJr  SSKJ	r
  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJ r   SSKJ!r!  SSK"J#r#  SSK$r$Sr%Sr&\%S-   r'/ SQr(/ SQr)SS/r*/ SQr+SS /r,S!S"S#S$.r-S%S!S&.r.S%S!S'.r/S(S)S*.r0S+r1S,r2S-r3S.r4S/Rk                  \3\45      r6S0r7S1S2S3.r8S4S5S6.r9S7 r:S8 r;S9 r<S: r=S; r>S< r?S= r@S> rAS? rBS@ rCSA rDSB rESC rF SzSD jrGSE rHSF rISG rJSH rKSI rLSJ rMSK rNSL rOSM rPSN rQSO rRSP rSSQ rTSR rUSS rVST rWSU rXSV rYSW rZSX r[SY r\SZ r]S[ r^ " S\ S]\R                  5      r` " S^ S_\R                  5      rbS` rcSa rdSb reSc rfSd rgSe rh S{Sf jriSg rjSh rkSi rlSj rmSk rnSl roSm rpSn rqSo rrSp rsSq rtSr ruSs rvSt rwSu rxSv rySw rzSx r{Sy r|g)|zBHelpers for flags in commands working with Google Cloud Functions.    )absolute_import)division)unicode_literalsN)DirectoriesCompleter)util)client)actions)arg_parsers)base)
exceptions)concepts)deps)flags)
completers)concept_parsers)presentation_specs)log)
properties)	resources)
console_iocloudfunctionsv1z.projects.locations)httpevent
cloudevent)DEBUGINFOERRORzPRIVATE-RANGES-ONLYALL)r   zINTERNAL-ONLYzINTERNAL-AND-GCLBzSECURE-ALWAYSzSECURE-OPTIONALallzinternal-onlyzinternal-and-gclb)	ALLOW_ALLALLOW_INTERNAL_ONLYALLOW_INTERNAL_AND_GCLBzprivate-ranges-only)PRIVATE_RANGES_ONLYALL_TRAFFIC)VPC_EGRESS_PRIVATE_RANGES_ONLYVPC_EGRESS_ALL_TRAFFICsecure-alwayszsecure-optional)SECURE_ALWAYSSECURE_OPTIONALzR^projects/[^/]+/locations/[^/]+/keyRings/[a-zA-Z0-9_-]+/cryptoKeys/[a-zA-Z0-9_-]+$zKMS key name should match projects/{project}/locations/{location}/keyRings/{keyring}/cryptoKeys/{cryptokey} and only contain characters from the valid character set for a KMS key.zH^projects/[^/]+/locations/[^/]+/repositories/[a-z]([a-z0-9-]*[a-z0-9])?$zG^(?P<location>.*)-docker.pkg.dev\/(?P<project>[^\/]+)\/(?P<repo>[^\/]+)z({}|{})zDocker repository name should match `projects/{project}/locations/{location}/repositories/{repository}` or `{location}-docker.pkg.dev/{project}/{repository}` and only contain characters from the valid character set for a repository.zcontainer-registryzartifact-registry)CONTAINER_REGISTRYARTIFACT_REGISTRY	automaticz	on-deploy)	AUTOMATIC	ON_DEPLOYc                     [         R                  " S[         Vs/ s H  oR                  5       PM     snSS9nUR	                  U 5        g s  snf )Nz--min-log-levelz$Minimum level of logs to be fetched.choiceshelp_str)r   ChoiceArgument
SEVERITIESlowerAddToParser)parserxmin_log_args      1lib/googlecloudsdk/command_lib/functions/flags.pyAddMinLogLevelFlagr<   l   sC    ##",-*Qwwy*-5+
 &! .   A
c                     [         R                  " S[         Vs/ s H  oR                  5       PM     snSS9nUR	                  U 5        g s  snf )Nz--ingress-settingsz]Ingress settings controls what traffic can reach the function. By default `all` will be used.r1   )r   r4   INGRESS_SETTINGSr6   r7   )r8   r9   ingress_settings_args      r;   AddIngressSettingsFlagrA   u   sH    ,,"23"2Qwwy"235	 ""6* 4r=   c                     [         R                  " S[         Vs/ s H  oR                  5       PM     snSS9nUR	                  U 5        g s  snf )Nz--egress-settingszEgress settings controls what traffic is diverted through the VPC Access Connector resource. By default `private-ranges-only` will be used.r1   r   r4   EGRESS_SETTINGSr6   r7   )r8   r9   egress_settings_args      r;   AddEgressSettingsFlagrF      sF    ++"12/Qwwy/2;	 !!&) 3r=   c           	          [         R                  " SS[         Vs/ s H  oR                  5       PM     snSS9nUR	                  U 5        g s  snf )Nz--security-levelr(   zSecurity level controls whether a function's URL supports HTTPS only or both HTTP and HTTPS. By default, `secure-always` will be used, meaning only HTTPS is supported.)defaultr2   r3   )r   r4   SECURITY_LEVELr6   r7   )r8   r9   security_level_args      r;   AddSecurityLevelFlagrK      sI    **"01.Qwwy.17	   ( 2s   Ac                 ,   [         R                  R                  5       nUR                  [        [
        5        UR                  U R                  S[        R                  R                  R                  R                  0[        S9nUR                  5       $ )N
projectsId)params
collection)r   REGISTRYCloneRegisterApiByNameAPIAPI_VERSIONParsenamer   VALUEScoreproject	GetOrFailLOCATIONS_COLLECTIONSelfLink)resourceregistryrefs      r;   GetLocationsUrir`      sq    %%'(
S+.mmJ--22::DDE% 	 	#
 
    c                 v    SnU R                  SS9nSnUR                  S[        USS9  UR                  SUS	9  g
)z?Add flags for specifying function memory and cpu to the parser.aZ    Limit on the amount of memory the function can use.

  Allowed values for v1 are: 128MB, 256MB, 512MB, 1024MB, 2048MB, 4096MB,
  and 8192MB.

  Allowed values for GCF 2nd gen are in the format: <number><unit> with allowed units
  of "k", "M", "G", "Ki", "Mi", "Gi". Ending 'b' or 'B' is allowed, but both are
  interpreted as bytes as opposed to bits.

  Examples: 1000000K, 1000000Ki, 256Mb, 512M, 1024Mi, 2G, 4Gi.

  By default, a new function is limited to 256MB of memory. When
  deploying an update to an existing function, the function keeps its old
  memory limit unless you specify this flag.Frequiredar      The number of available CPUs to set. Only valid when
    `--memory=MEMORY` is specified.

    Examples: .5, 2, 2.0, 2000m.

    By default, a new function's available CPUs is determined based on its memory value.

    When deploying an update that includes memory changes to an existing function,
    the function's available CPUs will be recalculated based on the new memory unless this flag
    is specified. When deploying an update that does not include memory changes to an existing function,
    the function's "available CPUs" setting will keep its old value unless you use this flag
    to change the setting.
    z--memoryT)typehelprd   z--cpurf   N)	add_groupadd_argumentstr)r8   memory_help_textgroupcpu_help_texts       r;   AddFunctionMemoryAndCpuFlagsrn      sS    0 

E

*%- Zc0@4PW=1ra   c                 @    [         R                  " / SQSS9nU" U 5      $ )zParse binary size to number of bytes.

Args:
  binary_size: str, memory with size suffix

Returns:
  num_bytes: int, the number of bytes
)KBMBMiBGBGiBrq   )suggested_binary_size_scalesdefault_unit)r
   
BinarySize)binary_sizebinary_size_parsers     r;   ParseMemoryStrToNumBytesrz      s(     #--#C 
K	((ra   c                     U R                   (       a@  U R                   S:  a/  [        R                  " SR                  U R                   5      5      eg g )Ni  zB--timeout: value must be less than or equal to 540s; received: {}s)timeoutr
   ArgumentTypeErrorformatargss    r;   ValidateV1TimeoutFlagr      s?    	\\dllS(

'
'L		  )\ra   c                 N    SnU R                  SU[        R                  " SS9S9  g)zAdd flag for specifying function timeout to the parser.

Args:
  parser: the argparse parser for the command.

Returns:
  None
aX        The function execution timeout, e.g. 30s for 30 seconds. Defaults to
      original value for existing function or 60 seconds for new functions.

      For GCF 1st gen functions, cannot be more than 540s.

      For GCF 2nd gen functions, cannot be more than 3600s.

      See $ gcloud topic datetimes for information on duration formats.	--timeout1slower_boundrf   re   Nri   r
   Durationr8   	help_texts     r;   AddFunctionTimeoutFlagr      s1    K) 		(<(<(N  ra   c                 &    U R                  SSSS9  g)z>Add flag for specifying function retry behavior to the parser.z--retryzEIf specified, then the function will be retried in case of a failure.
store_true)rf   actionNri   r8   s    r;   AddFunctionRetryFlagr      s"       ra   c                 B    U R                  S[        R                  SS9  g)z%Add the --allow-unauthenticated flag.z--allow-unauthenticatedzcIf set, makes this a public function. This will allow all callers, without checking authentication.r   rf   N)ri   r
   StoreTrueFalseActionr   s    r;   AddAllowUnauthenticatedFlagr   
  s&    --6	  ra   c                 ,    SnU R                  SSSUS9  g )NzBIf specified, latest function revision will be served all traffic.z#--serve-all-traffic-latest-revisionr   Fr   rH   rf   r   r   s     r;   $AddServeAllTrafficLatestRevisionFlagr     s+    J  	+	  ra   c                 2    SnU R                  S[        US9  g)z6Add flag for specifying function memory to the parser.z;  Specifies one of the Google provided buildpack stacks.
  z--buildpack-stackre   rf   N)ri   rj   r   s     r;   AddBuildpackStackFlagr   "  s!    ) 	))Dra   c                     SnU(       a  US-  nU(       a  US-  nU R                  SS[        R                  " [        R                  R
                  R                  5      UUS9  g)zAdd the --gen2 flag.zIf enabled, this command will use Cloud Functions (Second generation). If disabled with `--no-gen2`, Cloud Functions (First generation) will be used. If not specified, the value of this flag will be taken from the `functions/gen2` configuration property.z If the `functions/gen2` configuration property is not set, defaults to looking up the given function and using its generation.z This command could conflict with `--v2`. If specified `--gen2` with `--no-v2`, or `--no-gen2` with `--v2`, Second generation will be used.z--gen2F)rH   r   rf   hiddenN)ri   r	   StoreBooleanPropertyr   rW   	functionsgen2)r8   operates_on_existing_functionr   allow_v2r   s        r;   AddGen2Flagr   +  sv    
6  #	FI 	I
 	))**;*;*E*E*J*JK  ra   c                  x    [        [        R                  R                  R                  R                  5       5      $ )z;Returns whether 2nd gen should be used for Cloud Functions.)boolr   rW   r   r   GetBool ra   r;   ShouldUseGen2r   I  s(    	j))..668	99ra   c                      [         R                  R                  R                  R	                  5       =(       a    [        5       (       + $ )z;Returns whether 1st gen should be used for Cloud Functions.)r   rW   r   r   IsExplicitlySetr   r   ra   r;   ShouldUseGen1r   N  s1     !!&&668P=Pra   c                     U R                   $ N)allow_unauthenticatedr   s    r;   ShouldEnsureAllUsersInvoker   U  s    		#	##ra   c                 T    U R                  S5      =(       a    U R                  (       + $ )Nr   )IsSpecifiedr   r   s    r;   ShouldDenyAllUsersInvoker   Y  s'    
./ )((
(ra   c                 ,    SnU R                  SSSUS9  g)zAdd the --v2 flag.a8  If specified, this command will use Cloud Functions v2 APIs and return the result in the v2 format (See https://cloud.google.com/functions/docs/reference/rest/v2/projects.locations.functions#Function). If not specified, 1st gen and 2nd gen functions will use v1 and v2 APIs respectively and return the result in the corresponding format (For v1 format, see https://cloud.google.com/functions/docs/reference/rest/v1/projects.locations.functions#resource:-cloudfunction). This command conflicts with `--no-gen2`. If specified with this combination, v2 APIs will be used.z--v2r   Nr   r   r   s     r;   	AddV2Flagr   `  s-    ,  		  ra   c                 .    U R                  S[        SS9  g)z;Add flag for specifying function source code to the parser.z--sourceaB        Location of source code to deploy.

      Location of the source can be one of the following three options:

      * Source code in Google Cloud Storage (must be a `.zip` archive),
      * Reference to source repository or,
      * Local filesystem path (root directory of function source).

      Note that, depending on your runtime type, Cloud Functions will look
      for files with specific names for deployable functions. For Node.js,
      these filenames are `index.js` or `function.js`. For Python, this is
      `main.py`.

      If you do not specify the `--source` flag:

      * The current directory will be used for new function deployments.
      * If the function was previously deployed using a local filesystem path,
      then the function's source code will be updated using the current
      directory.
      * If the function was previously deployed using a Google Cloud Storage
      location or a source repository, then the function's source code will not
      be updated.

      The value of the flag will be interpreted as a Cloud Storage location, if
      it starts with `gs://`.

      The value will be interpreted as a reference to a source repository, if it
      starts with `https://`.

      Otherwise, it will be interpreted as the local filesystem path. When
      deploying source from the local filesystem, this command skips files
      specified in the `.gcloudignore` file (see `gcloud topic gcloudignore` for
      more information). If the `.gcloudignore` file doesn't exist, the command
      will try to create it.

      The minimal source repository URL is:
      `https://source.developers.google.com/projects/${PROJECT}/repos/${REPO}`

      By using the URL above, sources from the root directory of the
      repository on the revision tagged `master` will be used.

      If you want to deploy from a revision different from `master`, append one
      of the following three sources to the URL:

      * `/revisions/${REVISION}`,
      * `/moveable-aliases/${MOVEABLE_ALIAS}`,
      * `/fixed-aliases/${FIXED_ALIAS}`.

      If you'd like to deploy sources from a directory different from the root,
      you must specify a revision, a moveable alias, or a fixed alias, as above,
      and append `/paths/${PATH_TO_SOURCES_DIRECTORY}` to the URL.

      Overall, the URL should match the following regular expression:

      ```
      ^https://source\.developers\.google\.com/projects/
      (?<accountId>[^/]+)/repos/(?<repoName>[^/]+)
      (((/revisions/(?<commit>[^/]+))|(/moveable-aliases/(?<branch>[^/]+))|
      (/fixed-aliases/(?<tag>[^/]+)))(/paths/(?<path>.*))?)?$
      ```

      An example of a validly formatted source repository URL is:

      ```
      https://source.developers.google.com/projects/123456789/repos/testrepo/
      moveable-aliases/alternate-branch/paths/path-to=source
      ```

      )	completerrf   N)ri   r   r   s    r;   AddSourceFlagr   u  s"    $E
  Ira   c                 B    U R                  SS[        R                  S9  g)z3Add flag for specifying stage bucket to the parser.z--stage-bucketa  When deploying a function from a local directory, this flag's value is the name of the Google Cloud Storage bucket in which source code will be stored. Note that if you set the `--stage-bucket` flag when deploying a function, you will need to specify `--source` or `--stage-bucket` in subsequent deployments to update your source code. To use this flag successfully, the account in use must have permissions to write to this bucket. For help granting access, refer to this guide: https://cloud.google.com/storage/docs/access-control/r   N)ri   api_util%ValidateAndStandarizeBucketUriOrRaiser   s    r;   AddStageBucketFlagr     s)    B 99  ra   c                 $    U R                  SSS9  g )Nz	--runtimez          Runtime in which to run the function.

          Required when deploying a new function; optional when updating
          an existing function.

          For a list of available runtimes, run `gcloud functions runtimes list`.
          rg   r   r   s    r;   AddRuntimeFlagr     s      
ra   c            	      p    [         R                  " SSS[         R                  [        5       [	        5       S9$ )Nz'vpcaccess.projects.locations.connectors	connectorF)resource_namedisable_auto_completersrM   locationsIdconnectorsId)r   ResourceSpec DEFAULT_PROJECT_ATTRIBUTE_CONFIGRegionAttributeConfigVpcConnectorAttributeConfigr   ra   r;   GetVpcConnectorResourceSpecr     s3    			/#::').0
 ra   c                     U R                  SS9n[        R                  " S[        5       SUSS0S9n[        R
                  " U/SS	/0S
9R                  U 5        UR                  SSSS9  g)z4Add flag for specifying VPC connector to the parser.Tmutexz--vpc-connectora          The VPC Access connector that the function can connect to. It can be
        either the fully-qualified URI, or the short name of the VPC Access
        connector resource. If the short name is used, the connector must
        belong to the same project. The format of this field is either
        `projects/${PROJECT}/locations/${LOCATION}/connectors/${CONNECTOR}`
        or `${CONNECTOR}`, where `${CONNECTOR}` is the short name of the VPC
        Access connector.
      region )rl   flag_name_overridesz--vpc-connector.region--regioncommand_level_fallthroughsz--clear-vpc-connectorr   z.        Clears the VPC connector field.
      r   N)rh   r   ResourcePresentationSpecr   r   ConceptParserr7   ri   )r8   mutex_groupr]   s      r;   AddVPCConnectorMutexGroupr     s      t ,+88!#
 #R.(" j #;ZL!I	
 K
  ra   c                 &    U R                  SSSS9  g)z"Add flags for setting VPC network.z	--networkzThe VPC network that the Cloud Function 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.Trf   r   Nr   r   s    r;   _AddVpcNetworkFlagr     s#    G
   	ra   c                 &    U R                  SSSS9  g)z%Add flags for setting VPC subnetwork.z--subneta]  The VPC subnetwork that the Cloud Function 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.Tr   Nr   r   s    r;   _AddVpcSubnetFlagr   !  s"    ,   ra   c                 P    U R                  S[        R                  " 5       SSSS9  g)z'Add flags for setting VPC network tags.z--network-tagsTAGSzyApplies the given network tags (comma separated) to the Cloud Function. To clear existing tags, use --clear-network-tags.T)re   metavarrf   r   N)ri   r
   ArgListr   s    r;   _AddVpcNetworkTagsFlagr   1  s1     >   
ra   c                 (    U R                  SSSSS9  g)z(Add flags for clearing VPC network tags.z--clear-network-tagsr   z9Clears all existing network tags from the Cloud Function.Tr   rf   r   Nr   r   s    r;   _AddClearVpcNetworkTagsFlagr   @  s!    
E  ra   c                     [         R                  " S[         Vs/ s H  oR                  5       PM     snSSS9nUR	                  U 5        gs  snf )z1Add flags for setting Direct VPC egress settings.z--direct-vpc-egresszSpecify which of the outbound traffic to send through Direct VPC egress. Configuring DirectVPC network is required to use this flag.T)r2   r3   r   NrC   )r8   r9   direct_vpc_egress_args      r;   _AddDirectVpcEgressFlagr   L  sL    --"12/Qwwy/2Q  ##F+ 3s   A
c                     U R                  SSS9n[        U5        [        U5        UR                  SSS9n[	        U5        [        U5        g)zCAdd flag for specifying Direct VPC network interface to the parser.z&Direct VPC egress setting flags group.T)r   r   r   N)add_argument_groupr   r   rh   r   r   )r8   rl   
tags_groups      r;   _AddNetworkInterfaceGroupFlagsr   Z  sP    

#
#.t $ % UET$7*$j)ra   c                 (    U R                  SSSSS9  g)z#Add flags for clearing VPC network.z--clear-networkr   zNDisconnect this Cloud Function from the Direct VPC network it is connected to.Tr   Nr   r   s    r;   _AddClearVpcNetworkFlagr   g  s%       ra   c                 f    U R                  SSS9n[        U5        [        U5        [        U 5        g)z6Add flags for all Direct VPC network related settings.Tr   N)rh   r   r   r   )r8   ni_groups     r;   AddAllDirectVpcFlagsr   t  s/    D6( *(#&!ra   c                 d    U R                  SS9nUR                  SSS9  UR                  SSSS	9  g
)z8Add flag for specifying Build Worker Pool to the parser.Tr   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.
      rg   z--clear-build-worker-poolr   z?        Clears the Cloud Build Custom Worker Pool field.
      r   Nrh   ri   r8   r   s     r;   AddBuildWorkerPoolMutexGroupr   }  sP      t ,+
  
 !
  ra   c                 $    U R                  SSS9  g)z2Add flag for specifying entry point to the parser.z--entry-pointz      Name of a Google Cloud Function (as defined in source code) that will
      be executed. Defaults to the resource name suffix (ID of the function), if
       not specified.
rg   Nr   r   s    r;   AddEntryPointFlagr     s      ra   c                     U R                  SS9nUR                  S[        R                  " SS9SS9  UR                  SS	S
S9  g)z9Add flag for specifying the max instances for a function.Tr   z--max-instances   r   z        Sets the maximum number of instances for the function. A function
        execution that would exceed max-instances times out.
      r   z--clear-max-instancesr   a          Clears the maximum instances setting for the function.

        If it's any 2nd gen function or a 1st gen HTTP function, this flag sets
        maximum instances  to 0, which means there is no limit to maximum
        instances. If it's an event-driven 1st gen function, this flag sets
        maximum instances to 3000, which is the default value for 1st gen
        functions.
      r   Nrh   ri   r
   
BoundedIntr   s     r;   AddMaxInstancesFlagr     s^      t ,+!!a0
   
  ra   c                     U R                  SS9nUR                  S[        R                  " SS9SS9  UR                  SS	S
S9  g)z9Add flag for specifying the min instances for a function.Tr   z--min-instancesr   r   z        Sets the minimum number of instances for the function. This is helpful
        for reducing cold start times. Defaults to zero.
      r   z--clear-min-instancesr   zE        Clears the minimum instances setting for the function.
      r   Nr   r   s     r;   AddMinInstancesFlagr     s^      t ,+!!a0
   
  ra   c                    U R                  SS9nUR                  SS[        R                  S9  UR                  SS[        R                  S9  UR                  SS	S
S9  UR                  5       n[        R                  " [        R                  " S[        R                  " 5       SSS0USS9/SS/0S9R                  U 5        UR                  S[        R                  " 5       [        R                  SSS9  UR                  S[        R                  " 5       [        R                  SSS9  UR                  5       nUR                  SSSS9  UR                  S S!S"S9  g#)$zpAdd arguments specifying functions trigger to the parser.

Args:
  parser: the argparse parser for the command.
a        If you don't specify a trigger when deploying an update to an existing
      function it will keep its current trigger. You must specify one of the
      following when deploying a new function:
      - `--trigger-topic`,
      - `--trigger-bucket`,
      - `--trigger-http`,
      - `--trigger-event` AND `--trigger-resource`,
      - `--trigger-event-filters` and optionally `--trigger-event-filters-path-pattern`.
      rg   z--trigger-topicaO  Name of Pub/Sub topic. Every message published in this topic will trigger function execution with message contents passed as input data. Note that this flag does not accept the format of projects/PROJECT_ID/topics/TOPIC_ID. Use this flag to specify the final element TOPIC_ID. The PROJECT_ID will be read from the active configuration.r   z--trigger-bucketzGoogle Cloud Storage bucket name. Trigger the function when an object is created or overwritten in the specified Cloud Storage bucket.z--trigger-httpr   a        Function will be assigned an endpoint, which you can view by using
      the `describe` command. Any HTTP request (of a supported type) to the
      endpoint will trigger function execution. Supported HTTP request
      types are: POST, PUT, GET, DELETE, and OPTIONS.r   z--trigger-channelz]              The channel to use in the trigger for third-party event sources.
              locationr   T)r   rl   r   z--trigger-channel.location--trigger-locationr   z--trigger-event-filterszATTRIBUTE=VALUEa*        The Eventarc matching criteria for the trigger. The criteria can be
      specified either as a single comma-separated argument or as multiple
      arguments. The filters must include the ``type'' attribute, as well as any
      other attributes that are expected for the chosen type.
      )re   r   r   rf   z$--trigger-event-filters-path-patternzATTRIBUTE=PATH_PATTERNa        The Eventarc matching criteria for the trigger in path pattern format.
      The criteria can be specified as a single comma-separated argument or as
      multiple arguments.

      The provided attribute/value pair will be used with the
      `match-path-pattern` operator to configure the trigger, see
      https://cloud.google.com/eventarc/docs/reference/rest/v1/projects.locations.triggers#eventfilter
      and https://cloud.google.com/eventarc/docs/path-patterns for more details about on
      how to construct path patterns.

      For example, to filter on events for Compute Engine VMs in a given zone:
      `--trigger-event-filters-path-pattern=resourceName='/projects/*/zones/us-central1-a/instances/*'z--trigger-event
EVENT_TYPEz~Specifies which action should trigger the function. For a list of acceptable values, call `gcloud functions event-types list`.r   rf   z--trigger-resourceRESOURCEa  Specifies which resource from `--trigger-event` is being observed. E.g. if `--trigger-event` is  `providers/cloud.storage/eventTypes/object.change`, `--trigger-resource` must be a bucket name. For a list of expected resources, call `gcloud functions event-types list`.N)add_mutually_exclusive_groupri   r   ValidatePubsubTopicNameOrRaiser   r   r   r   r   r   eventarc_flagsChannelResourceSpecr7   r
   ArgDictUpdateAction)r8   trigger_groupeventarc_trigger_grouptrigger_provider_spec_groups       r;   AddTriggerFlagGroupr    s    55 	<
5 	- " 22    99   9   );;=

5
5!002 $.r"2*	 ')=(>"  K%% %%
 &  %%, %%&j & ( !. @ @ B**1	 +  **1	 + ra   c                   (   ^  \ rS rSrU 4S jrSrU =r$ )LocationsCompleteriG  c                 <   > [         [        U ]
  " S[        SS.UD6  g )Nz"alpha functions regions list --uri)rO   list_commandr   )superr  __init__r[   )selfkwargs	__class__s     r;   r  LocationsCompleter.__init__I  s(    	
d, '9 ra   r   )__name__
__module____qualname____firstlineno__r  __static_attributes____classcell__r  s   @r;   r  r  G  s     ra   r  c                   f   ^  \ rS rSrSr\R                  R                  4U 4S jjrU 4S jr	Sr
U =r$ )RegionFallthroughiQ  zCustom fallthrough for region dependent on GCF generation.

For GCF gen1 this falls back to the functions/region property.

For GCF gen2 the property fallback is only used if it is explicitly set.
Otherwise the region is prompted for.
c                 |   > [         [        U ]  [        R                  R
                  R                  5        Xl        g r   )r  r   r  r   rW   r   r   release_track)r  r"  r  s     r;   r  RegionFallthrough.__init__Z  s+    	
T+J,=,=,G,G,N,NO&ra   c                 $  > [        5       (       + nU(       d  U R                  R                  5       (       a  [        [        U ]  U5      $ [        R                  " 5       (       d  [        R                  " SS5      e[        R                  " U R                  5      nUR                  5        Vs/ s H  oDR                  PM     nn[        R                  " USS9nXV   n[         R"                  R%                  SR'                  U5      5        U$ s  snf )Nr   z_You must specify a region. Either use the flag `--region` or set the functions/region property.zPlease specify a region:
)messagezNTo make this the default region, run `gcloud config set functions/region {}`.
)r   propertyr   r  r   _Callr   	CanPromptr   RequiredArgumentException	client_v2FunctionsClientr"  ListRegions
locationIdPromptChoicer   statusPrintr~   )	r  parsed_argsuse_gen1r   lregionsidxr   r  s	           r;   r'  RegionFallthrough._Call^  s     ?"H4==0022$d1+>>!!00
0  &&t'9'9:F%+%7%7%9:%9||%9G:

!
!'3O
PC\FJJ	55;VF^
 M ;s   -D)r"  )r  r  r  r  __doc__r   ReleaseTrackALPHAr  r'  r  r  r  s   @r;   r   r   Q  s(     $(#4#4#:#: ' ra   r   c                     U R                  SU[        [        R                  " [        R
                  R                  R                  5      S9  g )Nr   )rf   r   r   )ri   r  r	   StorePropertyr   rW   r   r   r   s     r;   AddRegionFlagr<  x  s>    """:#4#4#>#>#E#EF	  ra   c                  J    [         R                  " SS[        [        5       /S9$ )Nr   zyThe Cloud region for the {resource}. Overrides the default `functions/region` property value for this command invocation.)rV   r   r   fallthroughs)r    ResourceParameterAttributeConfigr  r   r   ra   r;   r   r     s,    		2	2K #%'(
 ra   c                 .    U R                  SS[        S9  g)z7Add flag for specifying trigger location to the parser.r   zhThe location of the trigger, which must be a region or multi-region where the relevant events originate.)rf   r   N)ri   r  r   s    r;   AddTriggerLocationFlagrA    s"    8 #  ra   c                  J    [         R                  " SS[        R                  S9$ )NfunctionThe name of the {resource}.)rV   r   
value_type)r   r?  r   ValidateFunctionNameOrRaiser   ra   r;   FunctionAttributeConfigrG    s$    		2	2-55
 ra   c                  ,    [         R                  " SSS9$ )Nr   rD  )rV   r   )r   r?  r   ra   r;   r   r     s    		2	2-
 ra   c            	      p    [         R                  " SSS[         R                  [        5       [	        5       S9$ )Nz+cloudfunctions.projects.locations.functionsrC  F)r   r   rM   r   functionsId)r   r   r   r   rG  r   ra   r;   GetFunctionResourceSpecrK    s3    			3#::'))+
 ra   c                     U=(       d    SR                  U5      n[        R                  R                  S[	        5       UUS9R                  U 5        g)a  Adds a Cloud Function resource argument.

NOTE: May be used only if it's the only resource arg in the command.
Args:
  parser: the argparse parser for the command.
  verb: (Optional) str, the verb to describe the resource, such as 'to
    update'.
  help_text_override: (Optional)str, the help text to use for the resource
    argument. If override is providded, verb will be ignored.
  required: bool, whether the argument is required.
zThe Cloud Function name {}.NAMErc   N)r~   r   r   ForResourcerK  r7   )r8   verbhelp_text_overriderd   r   s        r;   AddFunctionResourceArgrQ    sN     !N$A$H$H$N)++	 , 
 Kra   c                 $    U R                  SSS9  g )Nz--service-accountaS        The email address of the IAM service account associated with the
      function at runtime. The service account represents the identity of the
      running function, and determines what permissions the function has.

      If not provided, the function will use the project's default service
      account for Compute Engine.
      rg   r   r   s    r;   AddServiceAccountFlagrS    s    
  
ra   c                 $    U R                  SSS9  g )Nz--run-service-accountah        The email address of the IAM service account associated with the Cloud
      Run service for the function. The service account represents the identity
      of the running function, and determines what permissions the function
      has.

      If not provided, the function will use the project's default service
      account for Compute Engine.
      rg   r   r   s    r;   AddRunServiceAccountFlagrU    s    
  ra   c                 $    U R                  SSS9  g )Nz--trigger-service-accounta        The email address of the IAM service account associated with the Eventarc
      trigger for the function. This is used for authenticated invocation.

      If not provided, the function will use the project's default service
      account for Compute Engine.
      rg   r   r   s    r;   AddTriggerServiceAccountFlagrW    s    !
  	ra   c                 .    U R                  SS[        S9  g )N--dataz:JSON string with data that will be passed to the function.r   )ri   _ValidateJsonOrRaiseDataErrorr   s    r;   AddDataFlagr[    s    K(  ra   c                 .    U R                  SS[        S9  g )N--cloud-eventa  
      JSON encoded string with a CloudEvent in structured content mode.

      Mutually exclusive with --data flag.

      Use for Cloud Functions 2nd Gen CloudEvent functions. The CloudEvent
      object will be sent to your function as a binary content mode message with
      the top-level 'data' field set as the HTTP body and all other JSON fields
      sent as HTTP headers.
      r   )ri   #_ValidateJsonOrRaiseCloudEventErrorr   s    r;   AddCloudEventsFlagr_    s"    	
 /  ra   c                 P    SnU R                  SU[        R                  " SS9SS9  g)z5Add flag for specifying gcloud timeout to the parser.z      The gcloud command timeout, e.g. 30s for 30 seconds. Defaults to the
      function execution timeout duration of the function.

      See $ gcloud topic datetimes for information on duration formats.r   r   r   T)rf   re   r   Nr   r   s     r;   AddGcloudHttpTimeoutFlagra    s6    K)
 	D1	  ra   c                 &    U R                  SSSS9  g )Npolicy_filePOLICY_FILEzFPath to a local JSON or YAML formatted file containing a valid policy.r  r   r   s    r;   AddIAMPolicyFileArgre    s     '	  ra   c                 $    U R                  SSS9  g )Nz--ignore-filea  Override the .gcloudignore file in the source directory and use the specified file instead. By default, the source directory is your current directory. Note that it could be changed by the --source flag, in which case your .gcloudignore file will be searched in the overridden directory.  For example, `--ignore-file=.mygcloudignore` combined with `--source=./mydir` would point to `./mydir/.mygcloudignore`rg   r   r   s    r;   AddIgnoreFileFlagrg  (  s    '  ra   c                     U[         R                  R                  [         R                  R                  [         R                  R                  4;   a$  U R                  S[        R                  5       SS9  gg)z3Adds flags for selecting the runtime update policy.z--runtime-update-policyzx        Runtime update policy for the function being deployed. The option
        `automatic` is used by default.
      )r2   rf   N)r   r8  r9  BETAGAri   RUNTIME_UPDATE_POLICY_MAPPINGvalues)r8   tracks     r;   AddRuntimeUpdatePolicyrn  8  sj    



 
 !-446
  ra   c           
          [         R                  " S[        [        R	                  5       5      S[
        R                  " SSS9S9nUR                  U 5        g)zEAdds flags for selecting the Docker registry type for Cloud Function.z--docker-registryz        Docker Registry to use for storing the function's Docker images.
        The option `artifact-registry` is used by default.
      av          With the general transition from Container Registry to
        Artifact Registry, the option to specify docker registry is deprecated.
        All container image storage and management will automatically
        transition to Artifact Registry.
        For more information, see
        https://cloud.google.com/artifact-registry/docs/transition/transition-from-gcr)warn)r2   r3   r   N)r   r4   sortedDOCKER_REGISTRY_MAPPINGrl  r	   DeprecationActionr7   )r8   docker_registry_args     r;   AddDockerRegistryFlagsru  J  sX    ++,3356
 &&': BZ [ !!&)ra   c                     U R                  SS9nUR                  S[        R                  " [        [
        5      SS9  UR                  SSSS	9  g
)z(Adds flags for configuring the CMEK key.Tr   z	--kms-keya          Sets the user managed KMS crypto key used to encrypt the Cloud Function
        and its resources.

        The KMS crypto key name should match the pattern
        `projects/${PROJECT}/locations/${LOCATION}/keyRings/${KEYRING}/cryptoKeys/${CRYPTOKEY}`
        where ${PROJECT} is the project, ${LOCATION} is the location of the key
        ring, and ${KEYRING} is the key ring that contains the ${CRYPTOKEY}
        crypto key.

        If this flag is set, then a Docker repository created in Artifact
        Registry must be specified using the `--docker-repository` flag and the
        repository must be encrypted using the `same` KMS key.
      r   z--clear-kms-keyr   zF        Clears the KMS crypto key used to encrypt the function.
      r   N)rh   ri   r
   RegexpValidator_KMS_KEY_NAME_PATTERN_KMS_KEY_NAME_ERRORr8   kmskey_groups     r;   AddKMSKeyFlagsr|  _  sd    !!!-,&&
!4
  ( 
  ra   c                     U R                  SS9nUR                  S[        R                  " [        [
        5      SS9  UR                  SSSS	9  g
)zDAdds flags for configuring the Docker repository for Cloud Function.Tr   z--docker-repositorya          Sets the Docker repository to be used for storing the Cloud Function's
        Docker images while the function is being deployed. `DOCKER_REPOSITORY`
        must be an Artifact Registry Docker repository present in the `same`
        project and location as the Cloud Function.

        **Preview:** for 2nd gen functions, a Docker Artifact registry
        repository in a different project and/or location may be used.
        Additional requirements apply, see
        https://cloud.google.com/functions/docs/building#image_registry

        The repository name should match one of these patterns:

        * `projects/${PROJECT}/locations/${LOCATION}/repositories/${REPOSITORY}`,
        * `{LOCATION}-docker.pkg.dev/{PROJECT}/{REPOSITORY}`.

        where `${PROJECT}` is the project, `${LOCATION}` is the location of the
        repository and `${REPOSITORY}` is a valid repository ID.
      r   z--clear-docker-repositoryr   zJ        Clears the Docker repository configuration of the function.
      r   N)rh   ri   r
   rw  _DOCKER_REPOSITORY_NAME_PATTERN_DOCKER_REPOSITORY_NAME_ERRORrz  s     r;   AddDockerRepositoryFlagsr    sd    !!!-,&&
)+H
  2 !
  ra   c                 L    U R                  S[        R                  " SSS9SS9  g )Nz--concurrencyr   i  )r   upper_boundzSet the maximum number of concurrent requests allowed per container instance. Leave concurrency unspecified to receive the server default value.r   )ri   r
   r   r   s    r;   AddConcurrencyFlagr    s-    !!aTB#	  ra   c                    U R                  SSS9nUR                  5       nUR                  SSSS9  [        U5        UR                  SSS	S9  UR                  S
SSS9  UR                  SSSS9  UR                  SSSS9  g)z$Adds upgrade related function flags.Ta         Upgrade a 1st gen Cloud Function to the 2nd gen environment.
      You must specify one of the following flags:
      - `--setup-config` and optionally `--trigger-service-account`,
      - `--redirect-traffic`,
      - `--rollback-traffic`,
      - `--commit`,
      - `--abort`.
  )r   rf   z--setup-configr   zhSets up the function upgrade config by creating a 2nd gen copy of the function's code and configuration.r   z--redirect-trafficzARedirects production traffic to the 2nd gen copy of the function.z--rollback-trafficzRolls back production traffic to the original 1st gen copy of the function. The 2nd gen copy will still be available for testing.z--commitz_Finishes the upgrade process and permanently deletes the original 1st gen copy of the function.z--abortzUndoes all steps of the upgrade process done so far. All traffic will point to the original 1st gen function copy and the 2nd gen function copy will be deleted.N)rh   r   ri   rW  )r8   upgrade_groupsetup_config_groups      r;   AddUpgradeFlagsr    s    "" # - %779!!4	 "  12N  
 M	   +	   ,	  ra   c                     [        U S5      $ )NrY  _ValidateJsonOrRaiseErrordatas    r;   rZ  rZ    s    	"4	22ra   c                     [        U S5      $ )Nr]  r  r  s    r;   r^  r^    s    	"4	99ra   c                      [         R                  " U 5        U $ ! [         a3  n[        R                  " US[
        R                  " U5      -   5      eSnAff = f)zEChecks validity of json string or raises an InvalidArgumentException.zIs not a valid JSON: N)jsonloads
ValueErrorr   InvalidArgumentExceptionsix	text_type)r  arg_namees      r;   r  r    sO    JJtK	 

-
-)CMM!,<< s    
A.AAc                 d    U R                  SS9nUR                  SSS9  UR                  SSSS	9  g
)zHAdds flags for configuring the build service account for Cloud Function.Tr   z--build-service-accounta+            IAM service account whose credentials will be used for the build step.
          Must be of the format projects/${PROJECT_ID}/serviceAccounts/${ACCOUNT_EMAIL_ADDRESS}.

          If not provided, the function will use the project's default
          service account for Cloud Build.
      rg   z--clear-build-service-accountr   z8          Clears the build service account field.
      r   Nr   r   s     r;   AddBuildServiceAccountFlagr    sP      t ,+
  	 %
  ra   c                 d    U R                  SS9nUR                  SSS9  UR                  SSSS	9  g
)zBAdd flag for specifying Binary Authorization Policy to the parser.Tr   z--binary-authorizationz        Name of the Binary Authorization policy that the function image should
        be checked against when deploying to Cloud Run.

        Example: default

        The flag is only applicable to 2nd gen functions.
      rg   z--clear-binary-authorizationr   z<        Clears the Binary Authorization policy field.
      r   Nr   r   s     r;    AddBinaryAuthorizationMutexGroupr    sP      t ,+
  
 $
  ra   )TFF)r   r   T)}r7  
__future__r   r   r   r  argcomplete.completersr   #googlecloudsdk.api_lib.functions.v1r   r   #googlecloudsdk.api_lib.functions.v2r   r*  googlecloudsdk.callioper	   r
   r   r    googlecloudsdk.calliope.conceptsr   r   #googlecloudsdk.command_lib.eventarcr   r  googlecloudsdk.command_lib.utilr   (googlecloudsdk.command_lib.util.conceptsr   r   googlecloudsdk.corer   r   r   googlecloudsdk.core.consoler   r  rS   rT   r[   SIGNATURE_TYPESr5   rD   r?   rI   INGRESS_SETTINGS_MAPPINGEGRESS_SETTINGS_MAPPING"DIRECT_VPC_EGRESS_SETTINGS_MAPPINGSECURITY_LEVEL_MAPPINGrx  ry  (_DOCKER_REPOSITORY_NAME_RESOURCE_PATTERN#_DOCKER_REPOSITORY_NAME_PKG_PATTERNr~   r~  r  rr  rk  r<   rA   rF   rK   r`   rn   rz   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   r   r   r  ListCommandCompleterr  PropertyFallthroughr   r<  r   rA  rG  r   rK  rQ  rS  rU  rW  r[  r_  ra  re  rg  rn  ru  r|  r  r  r  rZ  r^  r  r  r  r   ra   r;   <module>r     s   I &  '  7 @ C + / ( . 5 1 G 6 D G # * ) 2 
22 1'
(%0@ !#45*2  1 
 '<#& " %( " 
2  P ) O $ #,"2"2,'# 
A  /,  ! "	+
*)"2J)"2			E HM<:
$*K\&!H 	,
*
".	4(vr88 $00 $N		 6:.
"  $**@"J	7t3:,ra   