
    -                       S r SSKJr  SSKJr  SSKJr  SSKrSSKrSSKrSSKJ	r	  SSKJ
r
  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  S rS rS rSS jrSS jrSS jrS rSS jrSS jrS r S r!S r"S r#S r$S r%S r&S r'S r(S  r)S! r*S" r+S# r,S$ r-S% r.S& r/S' r0S( r1S) r2S* r3S+ r4S, r5S- r6S. r7S/ r8SS0 jr9S1 r:S2 r;S3 r<SS4 jr=SS5 jr>SS6 jr?S7 r@S8 rAS9 rBS: rCS; rDS< rESS= jrFS> rGS? rH SS@ jrISA rJSB rKSC rLSSD jrMSE rNSF rOSG rPSH rQSI rRSJ rSSK rTSL rUSM rVSN rWSO rXSP rYSQ rZSR r[SS r\ST r]SU r^SV r_SW r`SSX jraSSY jrbSZ rcS[ rdS\ reS] rfS^ rgS_ rhS` riSSa jrjSb rkSc rlSd rmSe rnSf roSg rpSSh jrqSi rrSj rsSk rtSl ruSm rvSn rwSSo jrxSp rySq rzSr r{Ss r|St r}SSu jr~Sv rSSw jrSSx jrSy rSSz jrS{ rS| rS}\GR                  S~S4S jrS rS rS rg)a#  Common flags for some of the AlloyDB commands.

Flags are specified with functions that take in a single argument, the parser,
and add the newly constructed flag to that parser.

Example:

def AddFlagName(parser):
  parser.add_argument(
    '--flag-name',
    ... // Other flag details.
  )
    )absolute_import)division)unicode_literalsN)arg_parsers)base)
exceptions)concepts)resource_args)	arg_utils)concept_parsers)
propertiesc                 2    SSS.nU R                  SSUSS9  g)	z{Adds an '--availability-type' flag to the parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
zProvide high availability instances. Recommended for production instances; instances automatically fail over to another zone within your selected region.zProvide zonal availability instances. Not recommended for production instances; instance does not automatically fail over to another zone.)REGIONALZONALz--availability-typeFz Specifies level of availability.requiredchoiceshelpNadd_argument)parserchoices_args     /lib/googlecloudsdk/command_lib/alloydb/flags.pyAddAvailabilityTyper   1   s4    9
>+ 	-	      c                 .    U R                  S[        SS9  g)zvAdds a positional backup argument to parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
backupzAlloyDB backup IDtyper   Nr   strr   s    r   	AddBackupr#   L   s     	hS/BCr   c                 *    U R                  SSSSSS9  g)z3Adds the `--enforced-retention` flag to the parser.z--enforced-retention
store_trueFTzIf set, enforces the retention period for this backup. Backups with enforced retention cannot be deleted before they are out of retention.)actionr   hiddenr   Nr   r"   s    r   AddEnforcedRetentionr(   U   s&      
r   c                 j    U(       a  U R                  S[        SS9  gU R                  SU[        SS9  g)a  Adds a positional cluster argument to parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
  positional: whether or not --cluster is positional.
  required: whether or not the argument is required. Only relevant if the
    argument is non-positional.
clusterzAlloyDB cluster IDr   z	--clusterr   r   r   Nr    )r   
positionalr   s      r   
AddClusterr-   d   s:     
	2FG
hS7K  r   c                 0    U R                  SU[        SS9  g)zAdds a positional cluster argument to parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
  required: Whether or not --primary-cluster is required.
z--primary-clusterzAlloyDB primary cluster IDr+   Nr    r   r   s     r   AddPrimaryClusterr0   u   s#     	'	  r   c                 j    SnU(       a  US-  nU R                  S[        R                  " SS9SSUS9  g	)
zAdds a `--database-flags` flag to parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
  update: Whether or not database flags were provided as part of an update.
a  Comma-separated list of database flags to set on the instance. Use an equals sign to separate flag name and value. Flags without values, like skip_grant_tables, can be written out without a value after, e.g., `skip_grant_tables=`. Use on/off for booleans. View the Instance Resource API for allowed flags. (e.g., `--database-flags max_allowed_packet=55555,skip_grant_tables=,log_output=1`)zA

The value given for this argument *replaces* the existing list.z--database-flags   )
min_lengthz
FLAG=VALUEFr   metavarr   r   N)r   r   ArgDict)r   updatehelp_s      r   AddDatabaseFlagsr9      sM    *  	ME 	!,  r   c                 .    U R                  S[        SS9  g)zxAdds a positional instance argument to parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
instancezAlloyDB instance IDr   Nr    r"   s    r   AddInstancer<      s     	js1FGr   c                 8    U R                  S[        USSS.SS9  g)zAdds an --instance-type flag to parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
  required: Whether or not --instance-type is required.
z--instance-typez4PRIMARY instances support read and write operations.a7  READ_POOL instances support read operations only. Each read pool instance consists of one or more homogeneous nodes.   * Read pool of size 1 can only have zonal availability.   * Read pools with node count of 2 or more can have      regional availability (nodes are present in 2 or      more zones in a region).)PRIMARY	READ_POOLzSpecifies instance type.r   r   r   r   Nr    r/   s     r   AddInstanceTyperA      s2     	K- &!  r   c                 6    U R                  S[        USS0SS9  g)zAdds a --fault-type flag to parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
  required: Whether or not --fault-type is required.
--fault-typestop-vmz,stop-vm fault type supports stopping the VM.zSpecifies fault type.r@   Nr    r/   s     r   AddFaultTyperE      s,     	HI"  r   c                 ^    [         R                  " SU R                  R                  SSS0SS9$ )NrC   FSTOP_VMrD   z'Type of fault to inject in an instance.r   custom_mappingshelp_str)r   ChoiceEnumMapperInjectFaultRequestFaultTypeValueValuesEnumalloydb_messagess    r   GetInjectFaultTypeFlagMapperrP      s9    		#	#))BB
Y 9
 r   c                 .    U R                  S[        SS9  g)zyAdds a positional operation argument to parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
	operationzAlloyDB operation IDr   Nr    r"   s    r   AddOperationrS      s     	k2HIr   c                 D    U R                  SSS[        R                  S9  g)zdAdds --enable-connection-pooling flag.

Args:
  parser: The current argparse parser to add this to.
z--enable-connection-poolingFz+Enable connection pooling for the instance.)r   r   r&   Nr   r   StoreTrueFalseActionr"   s    r   AddEnableConnectionPoolingrW      s)     	#8--	  r   c                 0    U R                  SSSS.SSSS9  g)	zgAdds --connection-pooling-pool-mode flag.

Args:
  parser: The current argparse parser to add this to.
z--connection-pooling-pool-modez,Session mode for managed connection pooling.z0Transaction mode for managed connection pooling.)SESSIONTRANSACTIONFNz-The pool mode for managed connection pooling.)r   r   defaultr   r   r"   s    r   AddConnectionPoolingPoolModer\      s0     	&CK :  	r   c                 2    U R                  S[        SSSS9  g)zkAdds --connection-pooling-min-pool-size flag.

Args:
  parser: The current argparse parser to add this to.
z"--connection-pooling-min-pool-sizeFNz1The min pool size for managed connection pooling.r   r   r[   r   r    r"   s    r   AddConnectionPoolingMinPoolSizer_   
  &     	*>  r   c                 2    U R                  S[        SSSS9  g)zkAdds --connection-pooling-max-pool-size flag.

Args:
  parser: The current argparse parser to add this to.
z"--connection-pooling-max-pool-sizeFNz1The max pool size for managed connection pooling.r^   r    r"   s    r   AddConnectionPoolingMaxPoolSizerb     r`   r   c                 2    U R                  S[        SSSS9  g)ztAdds --connection-pooling-max-client-connections flag.

Args:
  parser: The current argparse parser to add this to.
z+--connection-pooling-max-client-connectionsFNz:The max client connections for managed connection pooling.r^   r    r"   s    r   (AddConnectionPoolingMaxClientConnectionsrd   (  s&     	3G  r   c                 2    U R                  S[        SSSS9  g)zqAdds --connection-pooling-server-idle-timeout flag.

Args:
  parser: The current argparse parser to add this to.
z(--connection-pooling-server-idle-timeoutFNz7The server idle timeout for managed connection pooling.r^   r    r"   s    r   %AddConnectionPoolingServerIdleTimeoutrf   7  s&     	0D  r   c                 2    U R                  S[        SSSS9  g)zpAdds --connection-pooling-query-wait-timeout flag.

Args:
  parser: The current argparse parser to add this to.
z'--connection-pooling-query-wait-timeoutFNz6The query wait timeout for managed connection pooling.r^   r    r"   s    r   $AddConnectionPoolingQueryWaitTimeoutrh   F  s&     	/C  r   c                 P    U R                  SS[        R                  " 5       SSS9  g)ziAdds --connection-pooling-stats-users flag.

Args:
  parser: The current argparse parser to add this to.
z --connection-pooling-stats-usersFSTATS_USERSzJComma-separated list of database users to access connection pooling stats.r   r   r5   r   Nr   r   ArgListr"   s    r   AddConnectionPoolingStatsUsersrn   U  s1     	(   	r   c                 P    U R                  SS[        R                  " 5       SSS9  g)zwAdds --connection-pooling-ignore-startup-parameters flag.

Args:
  parser: The current argparse parser to add this to.
z.--connection-pooling-ignore-startup-parametersFSTARTUP_PARAMETERSzYComma-separated list of startup parameters that should be ignored by the connection pool.rk   Nrl   r"   s    r   +AddConnectionPoolingIgnoreStartupParametersrq   g  s1     	6 ""  	r   c                 2    U R                  S[        SSSS9  g)zmAdds --connection-pooling-server-lifetime flag.

Args:
  parser: The current argparse parser to add this to.
z$--connection-pooling-server-lifetimeFNa  The lifetime of a server connection in seconds. The pooler will close an unused (not currently linked to any client connection) server connection that has been connected longer than this. Setting  it to 0 means the connection is to be used only once, then closed. r^   r    r"   s    r   "AddConnectionPoolingServerLifetimers   y  s)     	,Q  r   c                 2    U R                  S[        SSSS9  g)z|Adds --connection-pooling-client-connection-idle-timeout flag.

Args:
  parser: The current argparse parser to add this to.
z3--connection-pooling-client-connection-idle-timeoutFNzWThe maximum number of seconds a client is allowed to be idle before it is disconnected.r^   r    r"   s    r   /AddConnectionPoolingClientConnectionIdleTimeoutru     s(     	;'  	r   c                 N    U R                  S[        R                  " SS9SSSS9  g)zuAdds --connection-pooling-max-prepared-statements flag.

Args:
  parser: The current argparse parser to add this to.
z,--connection-pooling-max-prepared-statementsr   )lower_boundFNz2The maximum number of prepared statements allowed.r^   r   r   
BoundedIntr"   s    r   )AddConnectionPoolingMaxPreparedStatementsrz     s1     	4!!a0
>  r   c                 (    U R                  SSSSS9  g)z?Adds the `--enable-private-service-connect` flag to the parser. --enable-private-service-connectFr%   zBEnable Private Service Connect (PSC) connectivity for the cluster.r   r&   r   Nr   r"   s    r   AddEnablePrivateServiceConnectr~     s!    (O	  r   c                 P    U R                  SS[        R                  " 5       SSS9  g)z5Adds the `--allowed-psc-projects` flag to the parser.z--allowed-psc-projectsFALLOWED_PSC_PROJECTSa  Comma-separated list of allowed consumer projects to create endpoints for Private Service Connect (PSC) connectivity for the instance. Only instances in PSC-enabled clusters are allowed to set this field.(e.g., `--allowed-psc-projects=project1,12345678,project2)rk   Nrl   r"   s    r   AddAllowedPSCProjectsr     s0     $A  r   c                 0    U R                  SS[        SS9  g)z;Adds the `--psc-network-attachment-uri` flag to the parser.z--psc-network-attachment-uriFa   Full URI of the network attachment that is configured to support outbound connectivity from an AlloyDB instance which uses Private Service Connect (PSC). For example, this would be of the form:`psc-network-attachment-uri=projects/test-project/regions/us-central1/networkAttachments/my-na`r+   Nr    r"   s    r   AddPSCNetworkAttachmentUrir     s$    $l  r   c                 &    U R                  SSSS9  g )Nz"--clear-psc-network-attachment-urir%   z`Disable outbound connectivity from an AlloyDB instance which uses Private Service Connect (PSC).r&   r   r   r"   s    r   ClearPSCNetworkAttachmentUrir     s    *q  r   c           	          U R                  SS[        R                  " [        [        S.SS/S9[        R                  " 5       SS9  g	)
z5Adds the `--psc-auto-connections` flag to the parser.z--psc-auto-connectionsF)projectnetworkr   r   )specrequired_keysa  Comma-separated list of consumer project and consumer network pairs to create endpoints for Private Service Connect (PSC) connectivity for the instance. Only instances in PSC-enabled clusters are allowed to set this field. Both project and network must be specified. (e.g., `--psc-auto-connections=project=project1,network=projects/vpc-host-project1/global/networks/network1` `--psc-auto-connections=project=project2,network=projects/vpc-host-project2/global/networks/network2`))r   r   r&   r   N)r   r   	ArgObjectr!   FlattenActionr"   s    r   AddPSCAutoConnectionsr     sR       #I. &&(t  r   c                 &    U R                  SSSS9  g)z;Adds the `--clear-psc-auto-connections` flag to the parser.z--clear-psc-auto-connectionsr%   z8Remove all PSC auto connections for an AlloyDB instance.r   Nr   r"   s    r   ClearPSCAutoConnectionsr     s    $I  r   c                 R    U R                  SSSS9n[        U5        [        U5        g)z-Adds PSC auto connection flags to the parser.TFz4PSC auto connection options for an AlloyDB instance.mutexr   r   N)	add_groupr   r   )r   psc_auto_connection_groups     r   AddPSCAutoConnectionGroupr     s5    $..A /  1234r   c                 0    U R                  SS[        SS9  g)z(Adds the `--network` flag to the parser.	--networkFaB  Network in the current project that the instance will be part of. To specify using a network with a shared VPC, use the full URL of the network. For an example host project, `testproject`, and shared network, `testsharednetwork`, this would be of the form:`--network=projects/testproject/global/networks/testsharednetwork`r+   Nr    r"   s    r   
AddNetworkr     s#      r   c                 0    U R                  SS[        SS9  g)z8Adds the `--allocated-ip-range-name` flag to the parser.--allocated-ip-range-nameFaa  Name of the allocated IP range for the private IP AlloyDB cluster, for example: "google-managed-services-default". If set, the instance IPs for this cluster will be created in the allocated range. The range name must comply with RFC 1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`.r+   Nr    r"   s    r   AddAllocatedIPRangeNamer   #  s#    !=  r   c                 0    U R                  SS[        SS9  g)z<Adds the `--allocated-ip-range-override` flag to the parser.z--allocated-ip-range-overrideFa  Name of the allocated IP range for the private IP AlloyDB instance, for example: "google-managed-services-default". If set, the instance IPs will be created from this allocated range and will override the IP range used by the parent cluster. The range name must comply with RFC 1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`.r+   Nr    r"   s    r   AddAllocatedIPRangeOverrider   4  s#    %+  r   c                 0    U R                  SS[        SS9  g)zmAdds a --node-count flag to parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
z--read-pool-node-countFz<Read capacity, i.e. number of nodes in a read pool instance.r+   Nr   intr"   s    r   AddReadPoolNodeCountr   F  s#     	I	  r   c                 0    U R                  SU[        SS9  g)zAdds a --region flag to parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
  required: Whether or not --region is required.
z--regionzRegional location (e.g. `asia-east1`, `us-east1`). See the full list of regions at https://cloud.google.com/sql/docs/instance-locations.r+   Nr    r/   s     r   	AddRegionr   T  s&     	B  	r   c                 0    U R                  SS[        SS9  g)zgAdds a --zone flag to parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
z--zoneFzHPrimary Compute Engine zone (e.g. `us-central1-a`, `us-central1-b`, etc.r+   Nr    r"   s    r   AddZoner   g  s%     	  r   c                 (    U R                  SSSSS9  g)zhAdds a --force flag to parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
z--forceFr%   zDefault value is false.

If flag is specified, deletes instances (if any) within this cluster, before deleting the cluster.

If flag is not specified, cluster delete will fail if there are instances present in the cluster.r}   Nr   r"   s    r   AddForcer   x  s%     	2  r   c                 6    U R                  SU[        / SQSS9  g)zAdds a --cpu-count flag to parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
  required: Whether or not --cpu-count is required.
z--cpu-count)r2                   0   @   H   `      a'  Whole number value indicating how many vCPUs the machine should contain. If the instance does not have a machine-type, the vCPU count will be used to determine the machine type where each vCPU corresponds to an N2  high-mem machine:  (https://cloud.google.com/compute/docs/general-purpose-machines#n2_machine_types). where CPU_COUNT can be one of: 2, 4, 8, 16, 32, 64, 96, 128. If the instance has a machine-type, cpu-count must have the same value as the vCPU count in the machine-type. Eg: if machine-type is c4a-highmem-4-lssd, cpu-count must be 4.r   r   r   r   Nr   r/   s     r   AddCPUCountr     s(     	76  r   c                     U R                  SUUR                  R                  R                  UR                  R                  R                  /UR                  R                  SS9  g)zAdds a --activation-policy flag to parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
  required: Whether or not --activation-policy is required.
z--activation-policyzActivation Policy for the instance. Required to START or STOP an instance. ALWAYS - The instance is up and running. NEVER - The instance is stopped.)r   r   r   r   N)r   InstanceActivationPolicyValueValuesEnumALWAYSNEVER)r   rO   r   s      r   AddActivationPolicyr     sb     	

#
#
C
C
J
J

#
#
C
C
I
I $$DD-  r   c                 r    / SQnU R                  SU[        [        R                  " 5       (       a  UOSSS9  g)zAdds a --machine-type flag to parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
  required: Whether or not --machine-type is required.
)zn2-highmem-2zn2-highmem-4zn2-highmem-8zn2-highmem-16zn2-highmem-32zn2-highmem-64zn2-highmem-96zn2-highmem-128zc4a-highmem-1zc4a-highmem-4-lssdzc4a-highmem-8-lssdzc4a-highmem-16-lssdzc4a-highmem-32-lssdzc4a-highmem-48-lssdzc4a-highmem-64-lssdzc4a-highmem-72-lssdzc4-highmem-4-lssdzc4-highmem-8-lssdzc4-highmem-16-lssdzc4-highmem-24-lssdzc4-highmem-32-lssdzc4-highmem-48-lssdzc4-highmem-96-lssdzc4-highmem-144-lssdzc4-highmem-192-lssdzc4-highmem-288-lssdzz3-highmem-14-standardlssdzz3-highmem-22-standardlssdzz3-highmem-44-standardlssdzz3-highmem-88-standardlssdz--machine-typeNz(Specifies machine type for the instance.r   )r   r!   r   IsDefaultUniverse)r   r   r   s      r   AddMachineTyper     s>    '@ 	#5577gT5  r   c                 P    U R                  SU[        R                  " 5       SSS9  g)zAdds a --db-roles flag to parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
  required: Whether or not --db-roles is required.
z
--db-rolesROLEzSComma separated list of database roles this new user will be granted upon creation.rk   Nrl   r/   s     r   
AddDBRolesr     s1     	   	r   c                 8    U R                  S[        SSS.SSS9  g)	zgAdds a --type flag to parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
z--typezEThis database user can authenticate via password-based authenticationz@This database user can authenticate via IAM-based authentication)BUILT_IN	IAM_BASEDr   z"Type corresponds to the user type.)r   r   r[   r   Nr    r"   s    r   AddUserTyper     s5     	  Q	 /  r   c                 N    U R                  S[        R                  " 5       SSS9  g)zsAdds a --keep-extra-roles flag to parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
z--keep-extra-rolesFz:If the user already exists and has extra roles, keep them.r   r[   r   Nr   r   
ArgBooleanr"   s    r   AddKeepExtraRolesr     s,     	!!#G	  r   c                 N    U R                  S[        R                  " 5       SSS9  g)lAdds a --superuser flag to parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
--superuserFzQIf true, new user will have AlloyDB superuser privileges. Default value is false.r   Nr   r"   s    r   AddCreateSuperuserr   '  s.     	!!#  r   c                 P    U R                  S[        R                  " 5       SSSS9  g)r   r   FTz4If true, user will have AlloyDB superuser privileges)r   r[   r   r   Nr   r"   s    r   AddSetSuperuserr   8  s/     	!!#A  r   c                 .    U R                  S[        SS9  g)zxAdds a positional username argument to parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
usernamezAlloyDB usernamer   Nr    r"   s    r   AddUsernamer   G  s     	js1CDr   c                 0    U R                  SS[        SS9  g)zkAdds a --password flag to parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.

--passwordTzAInitial postgres user password to set up during cluster creation.r+   Nr    r"   s    r   AddPasswordr   P  s#     	N	  r   c                 0    U R                  SU[        SS9  g)zAdds a --password flag to parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
  required: Whether or not --password is required.
r   z Password for this database user.r+   Nr    r/   s     r   AddUserPasswordr   ^  s#     	-	  r   c                 &  ^^^ U R                   R                  m[        SS5       Vs/ s H  nTR                  U5      PM     nnU Vs/ s H  o3R                  PM     snm[        T5      mUUU4S jn[        R                  " UUS9$ s  snf s  snf )z.Returns an ArgList accepting days of the week.r2   r   c                    > U R                  5       nUT;  a3  [        R                  " SR                  U SR	                  T5      S95      eTR                  U5      $ )Nz"{value} must be one of [{choices}]z, )valuer   )upperr   ArgumentTypeErrorformatjoinlookup_by_name)r   value_upperday_of_week_enumvisible_choicesvisible_choices_sets     r   _ParseDayOfWeek-_GetDayOfWeekArgList.<locals>._ParseDayOfWeekv  s^    ++-K--))
.
5
5499_#= 6  
 **;77r   )element_typer   )WeeklySchedule"DaysOfWeekValueListEntryValuesEnumrangelookup_by_numbernamesetr   rm   )rO   ir   cr   r   r   r   s        @@@r   _GetDayOfWeekArgListr   m  s     %%HH  <AA;G;a..q1;'G%,-WVVW-/O,8 
		"
  H-s   B		Bc                 8   ^  U 4S jn[         R                  " US9$ )z=Returns an ArgList accepting start times of the form `HH:00`.c                    > [         R                  " SU 5      nU(       a5  [        UR                  S5      5      nUS::  a  US:  a  TR	                  US9$ [
        R                  " SR                  U 5      5      e)Nz^(\d?\d):00$r2      r   )hoursz9Failed to parse time of day: {0}, expected format: HH:00.)rematchr   groupGoogleTypeTimeOfDayr   r   r   )r   mhourrO   s      r   _ParseTimeOfDay-_GetTimeOfDayArgList.<locals>._ParseTimeOfDay  sl    
%(A_d		33$3??

'
'CJJ	
 r   )r   )r   rm   )rO   r   s   ` r   _GetTimeOfDayArgListr     s    
 
		/	::r   c           	         SnU(       d  US-  nU R                  SUS9nUR                  SS9nUR                  SSU(       + [        U5      S	S
9  UR                  SSU(       + [        U5      SS
9  UR                  SSS9nUR                  SS[        R
                  " SS9SS9  UR                  SS[        SS9  UR                  SS[        R
                  " SSS9SS9  U[        R                  R                  :X  d  U[        R                  R                  :X  a  UR                  SSSS SS!S"9  [        R                  " US#[        5       S$S%S&9  U(       a  UR                  S'SS(S)9  UR                  S*SS+S)9  g),a  Adds automated backup flags.

Args:
  parser: argparse.ArgumentParser: Parser object for command line inputs.
  alloydb_messages: Message module.
  release_track: The command version being used - GA/BETA/ALPHA.
  update: If True, adds update specific flags.
zAutomated backup policy.z0 If unspecified, automated backups are disabled.Tr   r   zEnable automated backup policy.r   --automated-backup-days-of-weekDAYS_OF_WEEKComma-separated list of days of the week to perform a backup. At least one day of the week must be provided. (e.g., --automated-backup-days-of-week=MONDAY,WEDNESDAY,SUNDAY))r5   r   r   r   --automated-backup-start-timesSTART_TIMESComma-separated list of times during the day to start a backup. At least one start time must be provided. The start times are assumed to be in UTC and required to be an exact hour in the format HH:00. (e.g., `--automated-backup-start-times=01:00,13:00`)]Retention policy. If no retention policy is provided, all automated backups will be retained.#--automated-backup-retention-periodRETENTION_PERIODsparsed_unit~Retention period of the backup relative to creation time.  See `$ gcloud topic datetimes` for information on duration formats.r5   r   r   "--automated-backup-retention-countRETENTION_COUNT2Number of most recent successful backups retained.--automated-backup-windowTIMEOUT_PERIOD5mrw   r  a7  Length of the time window beginning at start time during which a backup can be taken. If a backup does not succeed within this time window, it will be canceled and considered failed. The backup window must be at least 5 minutes long. There is no upper bound on the window. If not set, it will default to 1 hour.z%--automated-backup-enforced-retentionr%   NFzIf set, enforces the retention period for automated backups. Backups created by this policy cannot be deleted before they are out of retention.r&   r[   r   r'   r   automated backupsjThe 'AlloyDB Service Agent' service account must hold permission 'Cloud KMS CryptoKey Encrypter/Decrypter'!--automated-backup-encryption-keyflag_overridespermission_infor   z--clear-automated-backupzdClears the automated backup policy on the cluster. The default automated backup policy will be used.r   z--disable-automated-backupz*Disables automated backups on the cluster.)r   r   r   r   r   Durationr   r   ReleaseTrackALPHABETAkms_resource_argsAddKmsKeyResourceArg"GetAutomatedBackupKmsFlagOverrides)r   rO   release_trackr7   automated_backup_helpr   policy_groupretention_groups           r   AddAutomatedBackupFlagsr(    s    5	OO


,A

B%&GH,'z 01L  
 &z 01:   !**4 + / + C0L   *?	   !DcB'   t((...	$++00	0/!   ((797 /	 	"@	   "7  r   c           	         U R                  SSS9nUR                  SSSSS9  UR                  S	S
[        U5      SS9  UR                  SS[        U5      SS9  UR                  SSS9nUR                  SS[        R
                  " SS9SS9  UR                  SS[        SS9  UR                  SS[        R
                  " SSS9SS9  [        R                  " US[        5       S S!S"9  g)#zAdds automated backup flags.

Args:
  parser: argparse.ArgumentParser: Parser object for command line inputs.
  alloydb_messages: Message module.
FzjAutomated backup policy. If unspecified, automated backups are copied from the associated primary cluster.r   z--enable-automated-backupr%   Nz)Enables Automated Backups on the cluster.r&   r[   r   r  r  r  r  r  r  r  Tr  r  r	  r
  r  r  r  r  r  r  r  r  r  a;  The length of the time window beginning at start time during which a backup can be taken. If a backup does not succeed within this time window, it will be canceled and considered failed. The backup window must be at least 5 minutes long. There is no upper bound on the window. If not set, it will default to 1 hour.r  r  r  r  )
r   r   r   r   r   r  r   r!  r"  r#  )r   rO   r   r'  s       r   )AddAutomatedBackupFlagsForCreateSecondaryr+    sX    

9  % !6	   ' 01L  
 & 01:   OO4 $ / + C0L   *?	   !DcB'   ((797 /	r   c                     [         R                  R                  S[        5       SR	                  U5      SS9R                  U 5        g)zAdd a resource argument for a KMS Key used to create a CMEK encrypted resource.

Args:
  parser: argparser, the parser for the command.
  verb: str, the verb used to describe the resource, such as 'to create'.
	--kms-keyzCloud KMS key to be used {}.F)r   N)r   ConceptParserForResourceGetKmsKeyResourceSpecr   AddToParser)r   verbs     r   AddEncryptionConfigFlagsr3  u  sC     ++$++D1	 , 
 Kr   c                 >   U R                  SSSS9nUR                  S[        SS9  U[        R                  R
                  :X  d  U[        R                  R                  :X  a  UR                  S[        SS9  UR                  S	S
9nUR                  SSSS9nUR                  SSS
9  U[        R                  R
                  :X  d  U[        R                  R                  :X  a  UR                  SSS
9  UR                  S[        R                  R                  SSS9  g)zAdds RestoreCluster flags.

Args:
  parser: argparse.ArgumentParser: Parser object for command line inputs.
  release_track: The command version being used - GA/BETA/ALPHA.
TzRestoreCluster source types.r   z--backupa  AlloyDB backup to restore from. This must either be the full backup name (projects/myProject/locations/us-central1/backups/myBackup) or the backup ID (myBackup). In the second case, the project and location are assumed to be the same as the restored cluster that is being created.r   z--backupdr-backupzBackup DR backup to restore from. This is a resource path of the form projects/myProject/locations/us-central1/backupVaults/myBackupVault/dataSources/myDataSource/backups/myBackup.zARestore a cluster from a source cluster at a given point in time.r   z-Source for a point in time restore operation.)r   r   r   z--source-clustera$  AlloyDB source cluster to restore from. This must either be the full cluster name (projects/myProject/locations/us-central1/backups/myCluster) or the cluster ID (myCluster). In the second case, the project and location are assumed to be the same as the restored cluster that is being created.z--backupdr-data-sourcezBackup DR data source to restore from. This is a resource path of the form projects/myProject/locations/us-central1/backupVaults/myBackupVault/dataSources/myDataSource.z--point-in-timezWPoint in time to restore to, in RFC 3339 format. For example, 2012-11-15T16:19:00.094Z.)r   r   r   N)
r   r   r!   r   r  r  r   r   DatetimeParse)r   r$  r   
pitr_grouppitr_source_groups        r   AddRestoreClusterSourceFlagsr9    sU    

4&D  % 	   t((...	$++00	0	~	   N  * !**: + 
    ! 
 t((...	$++00	0"" m #  %%&  r   c           	         SnU(       d  US-  nU R                  SUS9nUR                  SSSSS	9  UR                  S
S[        SS9  U[        R                  R
                  :X  d  U[        R                  R                  :X  a  UR                  SSSSSSS9  UnU(       a!  UR                  SSS9nUR                  SSSS9  [        R                  " US[        5       SSS9  g)a  Adds Continuous backup configuration flags.

Args:
  parser: argparse.ArgumentParser: Parser object for command line inputs.
  release_track: The command version being used - GA/BETA/ALPHA.
  update: Whether database flags were provided as part of an update.
z Continuous Backup configuration.z0 If unspecified, continuous backups are enabled.Fr   --enable-continuous-backupr%   N*Enables Continuous Backups on the cluster.r*  (--continuous-backup-recovery-window-daysRECOVERY_PERIODQRecovery window of the log files and backups saved to support Continuous Backups.r  z&--continuous-backup-enforced-retentionTzIf set, enforces the retention period for continuous backups. Backups created by this configuration cannot be deleted before they are out of retention.r  z0Encryption configuration for Continuous Backups.(--clear-continuous-backup-encryption-keyzClears the encryption configuration for Continuous Backups. Google default encryption will be used for future Continuous Backups.r   continuous backupkThe 'AlloyDB Service Agent's service account must hold permission 'Cloud KMS CryptoKey Encrypter/Decrypter'"--continuous-backup-encryption-keyr  )
r   r   r   r   r  r  r   r!  r"  #GetContinuousBackupKmsFlagOverrides)r   r$  r7   continuous_backup_helpr   
cmek_groups         r   AddContinuousBackupConfigFlagsrG    s+    >	PP


-C

D%"7	   0    t((...	$++00	0	0*   *K ! J 2#	   ((8:7 0	r   c                     U R                  SSS9nUR                  SSSSS9  UR                  S	S
[        SS9  [        R                  " US[        5       SSS9  g)z}Adds Continuous backup configuration flags.

Args:
  parser: argparse.ArgumentParser: Parser object for command line inputs.
FzsContinuous Backup configuration. If unspecified, continuous backups are copied from the associated primary cluster.r   r;  r%   Nr<  r*  r=  r>  r?  r  rA  rB  rC  r  )r   r   r   r!  r"  rD  r   r   s     r   0AddContinuousBackupConfigFlagsForCreateSecondaryrJ    s     

=  % "7	   0    ((8:7 0	r   c           	      N    U R                  SS[        R                  " SSS9SS9  g )Nz%--insights-config-query-string-lengthF   i  rw   upper_boundzQuery string length in bytes to be stored by the query insights
        feature. Default length is 1024 bytes. Allowed range: 256 to 4500
        bytes.r+   rx   r"   s    r   "AddInsightsConfigQueryStringLengthrO  C  s0    -!!ctD	  r   c           	      N    U R                  SS[        R                  " SSS9SS9  g )Nz(--insights-config-query-plans-per-minuteFr      rM  zaNumber of query plans to sample every minute.
        Default value is 5. Allowed range: 0 to 20.r+   rx   r"   s    r   $AddInsightsConfigQueryPlansPerMinuterR  N  s0    0!!aR@7	  r   c                 >    U (       a  S[         R                  0$ SS S.$ )Nr&   r%   )r&   r[   )r   rV   )show_negated_in_helps    r   _GetKwargsForBoolFlagrU  X  s'    +22  #t44r   c                 F    [        U5      nU R                  "  SSSS.UD6  g )NFzLAllow application tags to be recorded by the query insights
        feature.r   r   )z)--insights-config-record-application-tagsrU  r   r   rT  kwargss      r   &AddInsightsConfigRecordApplicationTagsr[  a  s5     !56&1
 	r   c                 F    [        U5      nU R                  "  SSSS.UD6  g )NFz;Add outbound Public IP connectivity to an AlloyDB instance.rW  )z--outbound-public-iprX  rY  s      r   AddOutboundPublicIpr]  l  s3     !56&L 		r   c                 F    [        U5      nU R                  "  SSSS.UD6  g )NFzNAllow the client address to be recorded by the query insights
        feature.rW  )z'--insights-config-record-client-addressrX  rY  s      r   $AddInsightsConfigRecordClientAddressr_  v  s5     !56&/
 	r   c                 F    [        U5      nU R                  "  SSSS.UD6  g )NFz'Enable enhanced query insights feature.rW  )z--observability-config-enabledrX  rY  s      r   AddObservabilityConfigEnabledra    s3     !56&&8 		r   c                 F    [        U5      nU R                  "  SSSS.UD6  g )NFzgAllow preservation of comments in query string recorded by the
        enhanced query insights feature.rW  )z(--observability-config-preserve-commentsrX  rY  s      r   &AddObservabilityConfigPreserveCommentsrc    s5     !56&0,
 	r   c                 F    [        U5      nU R                  "  SSSS.UD6  g )NFz)Track wait events during query execution.rW  )z(--observability-config-track-wait-eventsrX  rY  s      r   %AddObservabilityConfigTrackWaitEventsre    s3     !56&0: 		r   c           	      N    U R                  SS[        R                  " SSS9SS9  g )Nz.--observability-config-max-query-string-lengthFi   i rM  zvQuery string length in bytes to be stored by the enhanced query
        insights feature. Default length is 10k bytes.r+   rx   r"   s    r   *AddObservabilityConfigMaxQueryStringLengthrg    s0    6!!dG:	  r   c                 F    [        U5      nU R                  "  SSSS.UD6  g )NFzUAllow application tags to be recorded by the enhanced query
        insights feature.rW  )z.--observability-config-record-application-tagsrX  rY  s      r   +AddObservabilityConfigRecordApplicationTagsri    s5     !56&6
 	r   c           	      N    U R                  SS[        R                  " SSS9SS9  g )Nz---observability-config-query-plans-per-minuteFr   rQ  rM  zdNumber of query plans to sample every minute.
        Default value is 200. Allowed range: 0 to 200.r+   rx   r"   s    r   )AddObservabilityConfigQueryPlansPerMinuterk    s0    5!!aR@:	  r   c                 F    [        U5      nU R                  "  SSSS.UD6  g )NFzTrack actively running queries.rW  )z+--observability-config-track-active-queriesrX  rY  s      r   (AddObservabilityConfigTrackActiveQueriesrm    s3     !56&30 		r   c                  *    [         R                  " SS9$ )Nkms-key)r   r	    ResourceParameterAttributeConfig r   r   KmsKeyAttributeConfigrs    s    		2	2		BBr   c                  ,    [         R                  " SSS9$ )Nkms-keyringz!KMS keyring id of the {resource}.r   	help_textrp  rr  r   r   KmsKeyringAttributeConfigrx    s    		2	2$G
 r   c                  ,    [         R                  " SSS9$ )Nkms-locationz"Cloud location for the {resource}.rv  rp  rr  r   r   KmsLocationAttributeConfigr{    s    		2	2%I
 r   c                  ,    [         R                  " SSS9$ )Nkms-projectz$Cloud project id for the {resource}.rv  rp  rr  r   r   KmsProjectAttributeConfigr~    s    		2	2$J
 r   c            	      t    [         R                  " SS[        5       [        5       [	        5       [        5       S9$ )Nz/cloudkms.projects.locations.keyRings.cryptoKeyskey)resource_namecryptoKeysId
keyRingsIdlocationsId
projectsId)r	   ResourceSpecrs  rx  r{  r~  rr  r   r   r0  r0    s3    			7(**,,.*,
 r   c           	         SSSSS.nU(       a  UOUn[        U R                  US   SS R                  S	S
5      5      R                  5       nU(       a  UR	                  5       $ UR                  5        H  n[        XSS R                  S	S
5      S5      (       d  M)  SR                  US   US   US   US   5      nSnUR                  US   US   US   US   US   5      n[        R                  " XV5      e   g)zDParse the KMS key resource arg, make sure the key format is correct.r-  z--kms-keyringz--kms-locationz--kms-projectro  ru  rz  r}  ro  r   N-_z{} {} {} {}r}  rz  ru  ztSpecify fully qualified KMS key ID with {}, or use combination of {}, {}, {} and {} to specify the key ID in pieces.)	getattrCONCEPTSreplacer6  RelativeNamevaluesr   r   InvalidArgumentException)argsr  	kms_flagskms_refkeywordparameter_namemessages          r   GetAndValidateKmsKeyNamer    s+    $&$	) !/nI)
mmYy)!"-55c3?	EG 
 !! ##%	qr{**34d	;	;&--m$n%m$i 	
 	
 ..i m$n%m$i 
 11.JJ) &* r   c                     U R                   SL aU  U R                  (       d)  U R                  (       d  U(       a+  U R                  (       a  [        R
                  " SSSS5      eggg)zYValidate the arguments for continuous backup, ensure the correct set of flags are passed.Fz--no-enable-continuous-backupr=  rC  r@  N)enable_continuous_backup&continuous_backup_recovery_window_days continuous_backup_encryption_key&clear_continuous_backup_encryption_keyr   ConflictingArgumentsException)r  r7   s     r   ValidateContinuousBackupFlagsr    s]     ##u,

5
522DD 
2
2'2,2	  Ef	 -r   c                     U R                   SL aM  U R                  (       d"  U R                  (       d  U R                  (       a  [        R
                  " SSSS5      egg)zoValidate the arguments for automated backup for secondary clusters, ensure the correct set of flags are passed.Fz--no-enable-automated-backupr  r  r  N)enable_automated_backup%automated_backup_recovery_window_daysautomated_backup_encryption_keyautomated_backup_start_timesr   r  r  s    r   .ValidateAutomatedBackupFlagsForCreateSecondaryr  .  sX     ""e+

4
411.. 
2
2&()#	  /	 ,r   c                     U R                   (       a(  U R                  (       a  [        R                  " SS5      eU R                   (       a)  U R                  (       a  [        R                  " SS5      egg)zTValidate the arguments for connectivity, ensure the correct set of flags are passed.r|   r   r   N)enable_private_service_connectr   r   r  allocated_ip_range_namer  s    r   ValidateConnectivityFlagsr  C  sa     
((T\\

2
2*  
((T-I-I

2
2*#  .J(r   c                      SSSSS.$ )Nr  z)--automated-backup-encryption-key-keyringz*--automated-backup-encryption-key-locationz)--automated-backup-encryption-key-projectr  rr  rr  r   r   r#  r#  R  s    4@B@	
 r   c                      SSSSS.$ )NrC  z*--continuous-backup-encryption-key-keyringz+--continuous-backup-encryption-key-locationz*--continuous-backup-encryption-key-projectr  rr  rr  r   r   rD  rD  [  s    5ACA	
 r   c                 `    [         R                  " SU R                  R                  SSSS.SS9$ )Nz--viewFbasicfull)INSTANCE_VIEW_BASICINSTANCE_VIEW_FULLzView of the instance to return.rH   )r   rK   3AlloydbProjectsLocationsClustersInstancesGetRequestViewValueValuesEnumrN   s    r   GetInstanceViewFlagMapperr  d  s:    		#	#JJ^^!( & 1	
 	r   c                 L    [        U5      R                  R                  U 5        g)zAdds a view flag to parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
  alloydb_messages: Message module.
N)r  
choice_argr1  r   rO   s     r   AddViewr  q  s     ,-88DDVLr   c                 ,    U R                  SSSS0SS9  g)zuAdds an '--update-mode' flag to the parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
z--update-modeFFORCE_APPLYzUPerforms a forced update when applicable. This will be fast but may incur a downtime.zoSpecify the mode for updating the instance. If unspecified, the update would follow a least disruptive approachr   Nr   r"   s    r   AddUpdateModer  {  s0     	
<@  r   c           	          SnU(       a  U R                  SS[        SSS.US9  gU(       a   US-  nU R                  SS[        SSS.US9  gUS	-  nU R                  SS[        SSS.S
US9  g)a  Adds SSL Mode flag.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
  default_from_primary: If true, we get the default SSL mode from the primary.
    This is always true for secondary instances.
  update: If True, does not set the default SSL mode.
zGSpecify the SSL mode to use when the instance connects to the database.z
--ssl-modeFz>SSL connections are required. CA verification is not enforced.z>SSL connections are optional. CA verification is not enforced.)ENCRYPTED_ONLYALLOW_UNENCRYPTED_AND_ENCRYPTEDr   zA Default SSL mode will match what is set on the primary instance.z$ Default SSL mode is ENCRYPTED_ONLY.r  )r   r   r   r[   r   Nr    )r   default_from_primaryr7   ssl_mode_helps       r   
AddSSLModer    s     P  
 Q Q
    KM  Q Q
    ;;M
 Q Q
 !  r   c                 D    U R                  SS[        R                  SS9  g)zgAdds Require Connectors flag.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
z--require-connectorsFzXEnable or disable enforcing connectors only (ex: AuthProxy) connections to the database.r}   NrU   r"   s    r   AddRequireConnectorsr    s+     	--)  r   c                    UR                   R                  R                  UR                   R                  R                  UR                   R                  R                  UR                   R                  R
                  /nU[        R                  R                  [        R                  R                  4;   a/  UR                  UR                   R                  R                  5        U R                  SSUR                   R                  USS9  g)zAdds Database Version flag.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
  alloydb_messages: Message module.
  release_track: The command version being used - GA/BETA/ALPHA.
z--database-versionFz Database version of the cluster.r   N)ClusterDatabaseVersionValueValuesEnumPOSTGRES_14POSTGRES_15POSTGRES_16POSTGRES_17r   r  r  r   appendPOSTGRES_18r   )r   rO   r$  r   s       r   AddDatabaseVersionr    s     ==II==II==II==II	' t((..0A0A0F0FGGNN  ??KK 	##BB-  r   c                 N   UR                   R                  R                  UR                   R                  R                  UR                   R                  R                  UR                   R                  R
                  /nU R                  SSUR                   R                  USS9  g)zAdds Version flag.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
  alloydb_messages: Message module.
z	--versionTz(Target database version for the upgrade.r   N)UpgradeClusterRequestVersionValueValuesEnumr  r  r  r  r   )r   rO   r   s      r   
AddVersionr    s     ,,CCOO,,CCOO,,CCOO,,CCOO	' 	11HH5  r   c                     U R                  SSUR                  R                  UR                  R                  R                  UR                  R                  R                  /SS9  g)zAdds SubscriptionType flag.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
  alloydb_messages: Message module.
z--subscription-typeFz!Subscription type of the cluster.r   N)r   r  SubscriptionTypeValueValuesEnumSTANDARDTRIALr  s     r   AddSubscriptionTyper    sb     	##CC 
"
"
B
B
K
K

"
"
B
B
H
H
 /  
r   c           	          / SQnU R                  SS[        R                  " 5       [        R                  SR	                  U5      S9  g)(Makes the base.Argument for --tags flag.z%List of tags KEY=VALUE pairs to bind.zEach item must be expressed asz4`<tag-key-namespaced-name>=<tag-value-short-name>`.
z?Example: `123/environment=production,123/costCenter=marketing`
--tags	KEY=VALUE
)r5   r   r&   r   Nr   r   r6   UpdateActionr   r   
help_partss     r   AddTagsr  '  sE    * 	 %%99Z   r   c           
          / SQnU R                  SS[        R                  " 5       [        R                  SSR	                  U5      S9  g)r  r  r  r  Tr  )r5   r   r&   r'   r   Nr  r  s     r   
AddTagsArgr  8  sH    * 	 %%99Z   r   c                     [        X5      nU(       d  gU" [        UR                  5       5       VVs/ s H  u  pEUR                  XES9PM     snnS9$ s  snnf )zMakes the tags message object.N)r  r   )additionalProperties)r  sorteditemsAdditionalProperty)r  tags_messagetags_arg_nametagsr  r   s         r   GetTagsFromArgsr  J  s\    		%$		 #4::<00jc 
)
)c
)
?0
 s   A
c                 0    U R                  SS[        SS9  g)zmAdds Assign Inbound Public IP flag.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
z--assign-inbound-public-ipFa  Specify to enable or disable public IP on an instance.
          ASSIGN_INBOUND_PUBLIC_IP must be one of:
          * *NO_PUBLIC_IP*
          ** This disables public IP on the instance. Updating an instance to
          disable public IP will clear the list of authorized networks.
          * *ASSIGN_IPV4*
          ** Assign an inbound public IPv4 address for the instance.
          Public IP is enabled.r+   Nr    r"   s    r   AddAssignInboundPublicIpr  X  s%     	"#	  r   c                 P    U R                  S[        R                  " 5       SSSS9  g)zAdds a `--authorized-external-networks` flag to parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
z--authorized-external-networksAUTHORIZED_NETWORKFzComma-separated list of authorized external networks to set on the instance. Authorized networks should use CIDR notation (e.g. 1.2.3.4/30). This flag is only allowed to be set for instances with public IP enabled.r4   Nrl   r"   s    r   AddAuthorizedExternalNetworksr  m  s1     	& "  r   c                 0    U R                  SS[        SS9  g)zxAdds a `--maintenance-version` flag to parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
--maintenance-versionFzmMaintenance version to update the cluster to. Use `latest` to apply the latest available maintenance version.r+   Nr    r"   s    r   AddMaintenanceVersionr    s%     	=  r   c                     U R                   R                  5       S:X  a   UR                  R                  R                  $ [
        R                  " SSR                  U R                   5      5      e)z.Returns the maintenance version from the args.latestr  z`Invalid maintenance version: {}. Use `latest` to apply the latest available maintenance version.)maintenance_versionlowerr  0MaintenanceVersionSelectionPolicyValueValuesEnum+MAINTENANCE_VERSION_SELECTION_POLICY_LATESTr   r  r   )r  rO   s     r   GetValidatedMaintenanceVersionr    s`    	##%1  QQ}} 	++((.t/G/G(H	 r   c                 *    U R                  SSSSSS9  g)z.Adds maintenance window any flag to the group.z--maintenance-window-anyFr%   z-Remove the user-specified maintenance window.r   r&   r[   r   Nr   r   s    r   _AddMaintenanceWindowAnyr    s$     :  r   c                 :   UR                   R                  nU R                  SSUUR                  UR                  UR
                  UR                  UR                  UR                  UR                  /SS9  U R                  SS[        R                  " SSS9S	S
9  g)z8Adds maintenance window day and hour flags to the group.z--maintenance-window-dayTz5Day of week for maintenance window, in UTC time zone.r   z--maintenance-window-hourr   r   rM  z5Hour of day for maintenance window, in UTC time zone.r+   N)MaintenanceWindowDayValueValuesEnumr   MONDAYTUESDAY	WEDNESDAYTHURSDAYFRIDAYSATURDAYSUNDAYr   ry   )r   rO   r   s      r   _AddMaintenanceWindowDayAndHourr	    s    %77JJ 

!
!

"
"

$
$

#
#

!
!

#
#

!
! C   !!!aR@B	  r   c                     U(       a6  U R                  SSS9nUR                  SS9n[        U5        [        XA5        gU R                  SS9n[        XQ5        g)zAdds maintenance window related flags to parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
  alloydb_messages: Message module
  update: If false, only allow user to configure maintenance window day and
    hour.
Tz)Configure a preferred maintenance window.r   z/Specify preferred day and time for maintenance.r   N)r   r  r	  r   rO   r7   parent_groupchild_groupr   s         r   AddMaintenanceWindowr    sp     ##D $ L ((> ) K \*#KB>  E $E<r   c                     U S:  d  U S:  a%  [         R                  " SR                  U5      5      eUS:  d  US:  a%  [         R                  " SR                  U5      5      eg)z!Validates value of month and day.r2      z)Failed to parse date: {0}, invalid month.   z'Failed to parse date: {0}, invalid day.N)r   r   r   )monthdayr   s      r   _ValidateMonthAndDayr    se    
QY%"*

'
'3::5A  	1Wb

'
'188?  	r   c                    ^  U 4S jnU$ )zreturns google.type.Date date.c                 F  > [         R                  " SU 5      nU(       ae  UR                  5       R                  S5      n[	        US   5      n[	        US   5      n[	        US   5      n[        XEU 5        T	R                  X4US9$ [         R                  " SU 5      nU(       aW  UR                  5       R                  S5      n[	        US   5      n[	        US   5      n[        XEU 5        T	R                  SXES9$ SnS	n[        R                  " UR                  X5      5      e)
Nz^\d{4}-\d{2}-\d{2}r  r   r2   r   )yearr  r  z\d{2}-\d{2}z"YYYY-MM-DD" or "MM-DD"z.Failed to parse date: {}, expected format: {}.)
r   	fullmatchr   splitr   r  GoogleTypeDater   r   r   )
r   
full_matchymdr  r  r  no_year_matchfmterr_msgalloydb_messages
            r   r6  _GetDate.<locals>.Parse  s   3U;J$$S)cQ[d#a&keAKc5u-+++LLLL7M!'',c#a&keAKc5u-++%+II
#C>G

'
'u(B
CCr   rr  r   r6  s   ` r   _GetDater#    s    D, 
,r   c                    ^  U 4S jnU$ )z<returns google.type.TimeOfDay time of day from HH:MM format.c                    >  [         R                   R                  U S5      nUR                  UR                  p2TR	                  UUS9$ ! [
         a    [        R                  " SU < S35      ef = f)Nz%H:%M)r   minuteszFailed to parse time of day: z, expected format HH:MM.)datetimestrptimer   minuter   
ValueErrorr   r   )r   dtr   r)  r   s       r   r6  _GetTimeOfDay.<locals>.Parse	  s~    
%%eW5bWWbiiF00 1    )))%2J
K s   AA
 
&A0rr  r"  s   ` r   _GetTimeOfDayr-    s     
,r   c                 *    U R                  SSSSSS9  g)z6Adds remove deny maintenance period flag to the group.z --remove-deny-maintenance-periodFr%   z#Remove the deny maintenance period.r  Nr   r  s    r   _AddRemoveDenyMaintenancePeriodr/    s$    (0  r   c                     U R                  SS[        U5      SS9  U R                  SS[        U5      SS9  U R                  SS[        U5      SS9  g	)
zLAdds deny maintenance period start and end date and time flags to the group.z$--deny-maintenance-period-start-dateTzXDate when the deny maintenance period begins, that is 2020-11-01 or 11-01 for recurring.r+   z"--deny-maintenance-period-end-datezVDate when the deny maintenance period ends, that is 2020-11-01 or 11-01 for recurring.z--deny-maintenance-period-timez[Time when the deny maintenance period starts and ends, for example 05:00, in UTC time zone.N)r   r#  r-  )r   rO   s     r   $_AddDenyMaintenancePeriodDateAndTimer1  $  s{    ,$%"   *$%"   &)*&  r   c                     U(       a6  U R                  SSS9nUR                  SS9n[        U5        [        XA5        gU R                  SS9n[        XQ5        g)a  Adds deny maintenance period flags to parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
  alloydb_messages: Message module
  update: If false, only allow user to configure deny maintenance period start
    and end date and time.
Tz Specify maintenance deny period.r   z;Specify preferred day and time for maintenance deny period.r   N)r   r/  r1  r  s         r   AddDenyMaintenancePeriodr3  C  sp     ##; $ L ((J ) K $L1(GJ  E )Ar   c                 P    U R                  SS[        R                  " 5       SSS9  g)zsAdds the `--node-ids` flag to the parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
z
--node-idsFNODE_IDSzsComma-separated list of node IDs. Only supported for read pool instances. (e.g., `--node-ids=node-1,node-2,node-3`)rk   Nrl   r"   s    r   
AddNodeIdsr6  \  s1     	 0  
r   c                 0    U R                  SU[        SS9  g)zAdds a --database flag to parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
  required: Whether or not --database is required.
z
--databasezDatabase name.r+   Nr    r/   s     r   AddDatabaser8  o  s#     		  r   c                 P    U R                  SUSS9nUR                  S[        SS9  g)Adds a --gcs-uri flag to parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
  required: Whether or not --gcs-uri is required.
Tz4Destination URI where the file needs to be exported.r   	--gcs-urizEPath to the Google Cloud Storage file to which export has to be done.r   Nr   r   r!   )r   r   destination_uri_groups      r   AddDestinationURIr>  ~  sC     !**A + 
 $$$	 % r   c                    U R                  SSSS9nUR                  SS9nUR                  S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  UR                  SS[        SS9  UR                  SS9nUR                  SSSSS	9  UR                  SSSSS	9  UR                  SS[        SS9  UR                  SS9nUR                  SSSSS	9  UR                  SSSSS	9  g) zoAdds a --select-query flag to parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
TzExport options for the cluster.r   z#CSV export options for the cluster.r   --csvr%   z Specifies destination file type.r}   z--select-queryz#Select query to be used for export.r+   --field-delimiterFz&Field delimiter to be used for export.--escape-characterz'Escape character to be used for export.--quote-characterz&Quote character to be used for export.z#SQL export options for the cluster.--sqlz--schema-onlyz#Export only schema of the database.z--tablesz>Comma-separated list of table names which need to be exported.z+SQL export options to clean target objects.z--clean-target-objectsztIf true, output commands to DROP all the dumped database objects prior to outputting the commands for creating them.z--if-exist-target-objectsz}If true, use DROP ... IF EXISTS commands to check for the object's existence before dropping it in clean_target_objects mode.Nr<  )r   export_options_groupcsv_export_options_groupsql_export_options_groupclean_target_options_groups        r   AddExportOptionsrI    s     ))4&G *  2;;0 <  ''-	 (  ''0	 (  ''3	 (  ''4	 (  ''3	 (  2;;0 <  ''-	 (  ''0	 (  ''K	 (   8AA8  B   ))A *  ))!H * r   c                 P    U R                  SUSS9nUR                  S[        SS9  g)r:  Tz"URI of the source file for import.r   r;  zGPath to the Google Cloud Storage file from which import has to be done.r   Nr<  )r   r   source_uri_groups      r   AddSourceURIrL    sC     %%/ & 
 $	   r   c                 0    U R                  SS[        SS9  g)zeAdds --user flag to parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
z--userFzDatabase user for the import.r+   Nr    r"   s    r   AddImportUserrN   	  s#     	*	  r   c                    U R                  SSSS9nUR                  SS9nUR                  S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  UR                  SS[        SS9  UR                  SS[        SS9  UR                  SS9nUR                  SSSSS	9  g)zxAdds different import options flags to parser.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
TzImport options for the cluster.r   z#CSV import options for the cluster.r   r@  r%   zSpecify source file type.r}   z--tablez0Table name to which the data has to be imported.r+   z	--columnsFz;Comma-separated list of column names to be used for import.rA  z#Field delimiter in the source file.rB  z$Escape character in the source file.rC  z#Quote character in the source file.z#SQL import options for the cluster.rD  Nr<  )r   import_options_groupcsv_import_options_groupsql_import_options_groups       r   AddImportOptionsrS  	  s?     ))4&G *  2;;0 <  ''&	 (  ''=	 (  ''H	 (  ''0	 (  ''1	 (  ''0	 (  2;;0 <  ''&	 ( r   r   returnc                     U R                  SSSS9nU R                  SS[        SS9  U R                  SS[        SS9  UR                  S	S
9nUR                  SS[        SS9  g)zcAdds the Migrate Cloud SQL specific flags.

Args:
  parser: Parser object for command line inputs.
TzMigrate Cloud SQL strategy.r   z--cloud-sql-project-idzJCloudSQL project to migrate from. This must be the project ID (myProject).r+   z--cloud-sql-instance-idzPCloudSQL instance ID to migrate from. This must be the instance ID (myInstance).zUMigrate CloudSQL instance to an AlloyDB cluster by restoring from an existing backup.r   z--cloud-sql-backup-idzJCloudSQL backup ID to migrate from. This must be the backup ID (myBackup).N)r   r   r!   r   )r   r   migrate_cloud_sql_groups      r   AddMigrateCloudSqlFlagsrW  I	  s     

4&C  % 	%   	'   "OO! ,  &&# ' r   c           	      V   U R                  SS[        R                  SS9  U R                  SS[        R                  " SSS9S	S
S9  U R                  SS[        R                  " SS9S	SS9  U R                  SS[        R
                  " SSS9S	SS9  U R                  SS[        S	SS9  U R                  SS[        S	SS9  U R                  SS[        R                  " SS9S	SS9  U R                  SS[        S	SS9  U R                  SS[        S	SS9  U R                  SS[        S	SS9  g	)z+Add Autoscaler specific flags to the group.z--enable-autoscalerFz#Enable autoscaler for the instance.r}   z--autoscaler-max-node-countr2   rQ  rM  Nz&Maximum node count for the autoscaler.r   r   r[   r   z%--autoscaler-cool-down-period-secondsr
  r  z/Cool down period in seconds for the autoscaler.z--autoscaler-target-cpu-usager   z$Target CPU usage for the autoscaler.z--autoscaler-set-schedulez@The name of the schedule to create or update for the autoscaler.z--autoscaler-schedule-cron-expz,Cron expression for the autoscaler schedule.z&--autoscaler-schedule-duration-secondsz@Duration for which the autoscaler schedule is active in seconds.z--autoscaler-schedule-time-zonez&Time zone for the autoscaler schedule.z$--autoscaler-schedule-min-node-countz/Minimum node count for the autoscaler schedule.z!--autoscaler-schedule-descriptionz(Description for the autoscaler schedule.)r   r   rV   ry   r  BoundedFloatr!   r   r  s    r   _AddAutoscalerFlagsr[  v	  s   --0	   #!!aR@3   -C0<   %##qA1   !M   &9   .C0M   '3   ,<   )5  r   c                 :    U R                  SSS9n[        U5        g)z{Add Autoscaler specific flags for create command.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
Autoscaler flags.Tr   r'   N)r   r[  rI  s     r   AddAutoscalerCreateFlagsr_  	  s"     

 3D

A%er   c                     U R                  SSS9n[        U5        UR                  SS[        SSS9  UR                  S	S[        SS
S9  UR                  SS[        SSS9  g)z{Add Autoscaler specific flags for update command.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
r]  Tr^  z--autoscaler-delete-scheduleFNz6The name of the schedule to delete for the autoscaler.rY  z--autoscaler-disable-schedulez7The name of the schedule to disable for the autoscaler.z--autoscaler-enable-schedulez6The name of the schedule to enable for the autoscaler.)r   r[  r   r!   rI  s     r   AddAutoscalerUpdateFlagsra  	  s     

 3D

A%e$C   %D   $C  r   )TT)T)F)N)FF)r  )__doc__
__future__r   r   r   argparser'  r   googlecloudsdk.callioper   r   r    googlecloudsdk.calliope.conceptsr	   googlecloudsdk.command_lib.kmsr
   r!  $googlecloudsdk.command_lib.util.apisr   (googlecloudsdk.command_lib.util.conceptsr   googlecloudsdk.corer   r   r#   r(   r-   r0   r9   r<   rA   rE   rP   rS   rW   r\   r_   rb   rd   rf   rh   rn   rq   rs   ru   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+  r3  r9  rG  rJ  rO  rR  rU  r[  r]  r_  ra  rc  re  rg  ri  rk  rm  rs  rx  r{  r~  r0  r  r  r  r  r#  rD  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r	  r  r  r#  r-  r/  r1  r3  r6  r8  r>  rI  rL  rN  rS  PARSERrW  r[  r_  ra  rr  r   r   <module>rl     s  " '  '   	 / ( . 5 M : D *6D":H6 	J$$$($"" 2	5$"$&"(40-`&0"E2;& 5:yx^BK\DN'T5C
&T2*
M,=@"6,("$*("
4=2
	8&>B2&,Sl,8v*HOO * *ZOdr   