
    ~U              
       h   S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJ	r	  SSK
Jr  SSK
Jr  SS	KJr  \R                  R                   R"                  r\R                  R&                  R(                  r\	R,                  " S
\R.                  " SS5      R0                  R2                  SSSSSS.S9r\	R,                  " S
\R.                  " SS5      R6                  R8                  SSSSSS.S9r\	R,                  " S
\R.                  " SS5      R<                  R8                  SSSSSS.S9r\	R,                  " S
\R.                  " SS5      R@                  R8                  SSSSSS.S9r!\	R,                  " S\R.                  " SS5      RD                  RF                  SSSSS.S9r$\	R,                  " S\R.                  " SS5      RD                  RJ                  S SS!S"S#S$.S%9r&\	R,                  " S&\R.                  " SS5      RN                  RP                  S'SS(S)S*.S9r)S+ r*S, r+S- r,S. r-S/ r.S0 r/S1 r0S2 r1S3 r2S4 r3S5 r4S6 r5S7 r6S8 r7S9 r8S: r9S; r:SXS< jr;SXS= jr<SXS> jr=SYS? jr>SXS@ jr?SXSA jr@SXSB jrASC rBSD rCSE rDSF rESG rFSH rGSI rHSJ rISK rJSL rK " SM SN5      rLSO\L4SP jrMSQ rNSR rOSS rPST rQSU rRSV rSgW)Zz1Shared resource flags for Cloud Spanner commands.    )apis)
exceptions)concepts)deps)	arg_utils)concept_parsers)presentation_specs)
propertiesz--encryption-typespannerv1z"The encryption type of the backup.F)zuse-database-encryptionz6Use the same encryption configuration as the database.)zgoogle-default-encryptionzUse Google default encryption.)customer-managed-encryptionz^Use the provided Cloud KMS key for encryption.If this option is selected, kms-key must be set.)USE_DATABASE_ENCRYPTIONGOOGLE_DEFAULT_ENCRYPTIONCUSTOMER_MANAGED_ENCRYPTION)help_strrequiredcustom_mappings)r   z_Use the provided Cloud KMS key for encryption. If this option is selected, kms-key must be set.z)The encryption type of the copied backup.)'use-config-default-or-backup-encryptionz}Use the default encryption configuration if one exists. otherwise use the same encryption configuration as the source backup.)'USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTIONr   r   z-The encryption type of the restored database.)r   zvUse the default encryption configuration if one exists, otherwise use the same encryption configuration as the backup.z--instance-typez%Specifies the type for this instance.)provisionedzSProvisioned instances have dedicated resources, standard usage limits, and support.)zfree-instancezFree trial instances provide no guarantees for dedicated resources, both node_count and processing_units should be 0. They come with stricter usage limits and limited support.)PROVISIONEDFREE_INSTANCEz--default-storage-typez5Specifies the default storage type for this instance.T)ssdz1Use ssd as default storage type for this instance)hddz1Use hdd as default storage type for this instance)SSDHDD)r   r   hiddenr   z--expire-behaviorz-The expire behavior of a free trial instance.)zfree-to-provisionedzUWhen the free trial instance expires, upgrade the instance to a provisioned instance.)zremove-after-grace-periodzWhen the free trial instance expires, disable the instance, and delete it after the grace period passes if it has not been upgraded to a provisioned instance.)FREE_TO_PROVISIONEDREMOVE_AFTER_GRACE_PERIODc                  `    [         R                  " SS[        R                  " [        5      /S9$ )z3Get instance resource attribute with default value.instancez.The Cloud Spanner instance for the {resource}.)name	help_textfallthroughs)r    ResourceParameterAttributeConfigr   PropertyFallthrough	_INSTANCE     7lib/googlecloudsdk/command_lib/spanner/resource_args.pyInstanceAttributeConfigr+      s,    		2	2@,,Y78
: :r)   c                  ,    [         R                  " SSS9$ )z=Get instance partition resource attribute with default value.instance partitionz2The Spanner instance partition for the {resource}.r"   r#   r   r%   r(   r)   r*    InstancePartitionAttributeConfigr0      s    		2	2D
 r)   c                  ,    [         R                  " SSS9$ )z Get database resource attribute.databasez.The Cloud Spanner database for the {resource}.r.   r/   r(   r)   r*   DatabaseAttributeConfigr3      s    		2	2@
B Br)   c                  ,    [         R                  " SSS9$ )zGet backup resource attribute.backupz,The Cloud Spanner backup for the {resource}.r.   r/   r(   r)   r*   BackupAttributeConfigr6      s    		2	2>
@ @r)   c                  ,    [         R                  " SSS9$ )z'Get backup schedule resource attribute.backup-schedulez5The Cloud Spanner backup schedule for the {resource}.r.   r/   r(   r)   r*   BackupScheduleAttributeConfigr9      s    		2	2G
I Ir)   c                  ,    [         R                  " SSS9$ )zGet session resource attribute.sessionz-The Cloud Spanner session for the {resource}.r.   r/   r(   r)   r*   SessionAttributeConfigr<      s    		2	2 O
Q Qr)   c                  *    [         R                  " SS9$ )Nkms-key)r"   r/   r(   r)   r*   KmsKeyAttributeConfigr?      s    		2	2		BBr)   c                  ,    [         R                  " SSS9$ )Nkms-keyringz!KMS keyring id of the {resource}.r.   r/   r(   r)   r*   KmsKeyringAttributeConfigrB      s    		2	2$G
I Ir)   c                  ,    [         R                  " SSS9$ )Nkms-locationz"Cloud location for the {resource}.r.   r/   r(   r)   r*   KmsLocationAttributeConfigrE      s    		2	2%I
K Kr)   c                  ,    [         R                  " SSS9$ )Nkms-projectz$Cloud project id for the {resource}.r.   r/   r(   r)   r*   KmsProjectAttributeConfigrH     s    		2	2$J
L Lr)   c                  \    [         R                  " SS[        5       [         R                  S9$ )Nzspanner.projects.instancesr!   )resource_nameinstancesId
projectsId)r   ResourceSpecr+    DEFAULT_PROJECT_ATTRIBUTE_CONFIGr(   r)   r*   GetInstanceResourceSpecrO     s*    			")+::	
< <r)   c                  n    [         R                  " SS[        5       [        5       [         R                  S9$ )Nz-spanner.projects.instances.instancePartitionsr-   )rJ   instancePartitionsIdrK   rL   )r   rM   r0   r+   rN   r(   r)   r*    GetInstancePartitionResourceSpecrR     s0    			5(;=)+::
 r)   c                  n    [         R                  " SS[        5       [        5       [         R                  S9$ )Nz$spanner.projects.instances.databasesr2   )rJ   databasesIdrK   rL   )r   rM   r3   r+   rN   r(   r)   r*   GetDatabaseResourceSpecrU     s0    			,)+)+::
< <r)   c            	      t    [         R                  " SS[        5       [        5       [	        5       [        5       S9$ )Nz/cloudkms.projects.locations.keyRings.cryptoKeyskey)rJ   cryptoKeysId
keyRingsIdlocationsIdrL   )r   rM   r?   rB   rE   rH   r(   r)   r*   GetKmsKeyResourceSpecr[   "  s3    			7(**,,.*,
. .r)   c                  n    [         R                  " SS[        5       [        5       [         R                  S9$ )Nz"spanner.projects.instances.backupsr5   )rJ   	backupsIdrK   rL   )r   rM   r6   r+   rN   r(   r)   r*   GetBackupResourceSpecr^   ,  s0    			*%')+::
< <r)   c            	          [         R                  " SS[        5       [        5       [	        5       [         R
                  S9$ )Nz4spanner.projects.instances.databases.backupSchedulesr8   )rJ   backupSchedulesIdrT   rK   rL   )r   rM   r9   r3   r+   rN   r(   r)   r*   GetBackupScheduleResourceSpecra   5  s6    			<%57)+)+::
< <r)   c            	          [         R                  " SS[        5       [        5       [	        5       [         R
                  S9$ )Nz-spanner.projects.instances.databases.sessionsr;   )rJ   
sessionsIdrT   rK   rL   )r   rM   r<   r3   r+   rN   r(   r)   r*   GetSessionResourceSpecrd   ?  s6    			5'))+)+::
< <r)   c                     U(       a  SOSn[         R                  R                  U[        5       SR	                  U5      SS9R                  U 5        g)aX  Add a resource argument for a Cloud Spanner instance.

NOTE: Must be used only if it's the only resource arg in the command.

Args:
  parser: the argparse parser for the command.
  verb: str, the verb to describe the resource, such as 'to update'.
  positional: bool, if True, means that the instance ID is a positional rather
    than a flag.
r!   z
--instancezThe Cloud Spanner instance {}.Tr   N)r   ConceptParserForResourcerO   formatAddToParserparserverb
positionalr"   s       r*   AddInstanceResourceArgro   I  L     "|$++
&--d3	 ,  ![(r)   c                     U(       a  SOSn[         R                  R                  U[        5       SR	                  U5      SS9R                  U 5        g)a\  Add a resource argument for a Spanner instance partition.

NOTE: Must be used only if it's the only resource arg in the command.

Args:
  parser: the argparse parser for the command.
  verb: str, the verb to describe the resource, such as 'to update'.
  positional: bool, if True, means that the instance ID is a positional rather
    than a flag.
instance_partitionz--instance-partitionz"The Spanner instance partition {}.Trf   N)r   rg   rh   rR   ri   rj   rk   s       r*   AddInstancePartitionResourceArgrs   \  sN     ",	1G$++
&(*11$7	 , 
 Kr)   c                     U(       a  SOSn[         R                  R                  U[        5       SR	                  U5      SS9R                  U 5        g)aX  Add a resource argument for a Cloud Spanner database.

NOTE: Must be used only if it's the only resource arg in the command.

Args:
  parser: the argparse parser for the command.
  verb: str, the verb to describe the resource, such as 'to update'.
  positional: bool, if True, means that the database ID is a positional rather
    than a flag.
r2   z
--databasezThe Cloud Spanner database {}.Trf   N)r   rg   rh   rU   ri   rj   rk   s       r*   AddDatabaseResourceArgru   p  rp   r)   c                 `   U(       a  SOSnU(       a  SOSnU R                  SSS9n[        R                  " [        R                  " U[        5       SR                  U5      S	US
9[        R                  " U[        5       SR                  U5      S	SSUSSSS.S9/5      R                  U 5        g)a$  Add a resource argument for a KMS Key used to create a CMEK database.

Args:
  parser: argparser, the parser for the command.
  verb: str, the verb used to describe the resource, such as 'to create'.
  positional: bool, optional. True if the resource arg is postional rather
    than a flag.
r>   z	--kms-keykms-keysz
--kms-keyszKMS key name groupT)mutexzCloud KMS key to be used {}.F)r   groupzCloud KMS key(s) to be used {}. )rD   rA   rG   )r   prefixespluralry   flag_name_overridesN)	add_groupr   rg   r	   ResourcePresentationSpecr[   ri   rj   )rl   rm   rn   kms_key_namekms_key_namesry   s         r*   AddKmsKeyResourceArgr     s     )k, **-


/t

<%11


!
(
/
/
5 11


!
+
2
24
8 ! , [r)   c                     U(       a  SOSn[         R                  R                  U[        5       SR	                  U5      SS9R                  U 5        g)aM  Add a resource argument for a Cloud Spanner session.

NOTE: Must be used only if it's the only resource arg in the command.

Args:
  parser: the parser for the command.
  verb: str, the verb to describe the resource, such as 'to update'.
  positional: bool, if True, means that the session ID is a positional rather
    than a flag.
r;   z	--sessionzThe Cloud Spanner session {}.Trf   N)r   rg   rh   rd   ri   rj   rk   s       r*   AddSessionResourceArgr     sL     !k$++
%,,T2	 ,  ![(r)   c                     U(       a  SOSn[         R                  R                  U[        5       SR	                  U5      SS9R                  U 5        g)aT  Add a resource argument for a Cloud Spanner backup.

NOTE: Must be used only if it's the only resource arg in the command.

Args:
  parser: the argparse parser for the command.
  verb: str, the verb to describe the resource, such as 'to update'.
  positional: bool, if True, means that the backup ID is a positional rather
    than a flag.
r5   z--backupzThe Cloud Spanner backup {}.Trf   N)r   rg   rh   r^   ri   rj   rk   s       r*   AddBackupResourceArgr     sL      Z$++
$++D1	 ,  ![(r)   c                     U(       a  SOSn[         R                  R                  U[        5       SR	                  U5      SS9R                  U 5        g)ag  Add a resource argument for a Cloud Spanner backup schedule.

NOTE: Must be used only if it's the only resource arg in the command.

Args:
  parser: the argparse parser for the command.
  verb: str, the verb to describe the resource, such as 'to update'.
  positional: bool, if True, means that the backup schedules ID is a
    positional rather than a flag.
backup_schedulez--backup-schedulez%The Cloud Spanner backup schedule {}.Trf   N)r   rg   rh   ra   ri   rj   rk   s       r*   AddBackupScheduleResourceArgr     sN     )	.A$++
#%-44T:	 ,  ![(r)   c                 @    [         R                  R                  U 5      $ N)%_CREATE_BACKUP_ENCRYPTION_TYPE_MAPPER
choice_argrj   rl   s    r*    AddCreateBackupEncryptionTypeArgr     s    	.	9	9	E	Ef	MMr)   c                 @    [         R                  U R                  5      $ r   )r   GetEnumForChoiceencryption_typeargss    r*   GetCreateBackupEncryptionTyper     s    	.	?	?

 r)   c                 @    [         R                  R                  U 5      $ r   ),_CREATE_BACKUP_ENCRYPTION_CONFIG_TYPE_MAPPERr   rj   r   s    r*   &AddCreateBackupEncryptionConfigTypeArgr     s    	5	@	@	L	L
 r)   c                 @    [         R                  U R                  5      $ r   )r   r   r   r   s    r*   #GetCreateBackupEncryptionConfigTyper     s    	5	F	F

 r)   c           
          [         R                  " S[        5       SSSSS.S9[         R                  " S[        5       SSS	S
S.S9/n[        R                  " U5      R                  U 5        g)z@Add backup resource args (source, destination) for copy command.--sourceTEXTT--source-instance--source-backupr!   r5   r   r}   --destination--destination-instancez--destination-backupN)r	   r   r^   r   rg   rj   rl   	arg_specss     r*   AddCopyBackupResourceArgsr     sx     11


!
-) 11


!
2.)* 	*66v>r)   c                 @    [         R                  R                  U 5      $ r   )#_COPY_BACKUP_ENCRYPTION_TYPE_MAPPERr   rj   r   s    r*   AddCopyBackupEncryptionTypeArgr     s    	,	7	7	C	CF	KKr)   c                 @    [         R                  U R                  5      $ r   )r   r   r   r   s    r*   GetCopyBackupEncryptionTyper     s    	,	=	=

 r)   c           
          [         R                  " S[        5       SSSSS.S9[         R                  " S[        5       SSS	S
S.S9/n[        R
                  " U5      R                  U 5        g)zCAdd backup resource args (source, destination) for restore command.r   r   Tr   r   r   r   r   r   z--destination-database)r!   r2   N)r	   r   r^   rU   r   rg   rj   r   s     r*   AddRestoreResourceArgsr     sx     11


!
-) 11

!
#
22)* 	*66v>r)   c                 @    [         R                  R                  U 5      $ r   )"_RESTORE_DB_ENCRYPTION_TYPE_MAPPERr   rj   r   s    r*   AddRestoreDbEncryptionTypeArgr   5  s    	+	6	6	B	B6	JJr)   c                 @    [         R                  U R                  5      $ r   )r   r   r   r   s    r*   GetRestoreDbEncryptionTyper   9  s    	+	<	<

 r)   c                   "    \ rS rSrSrSS jrSrg)CloudKmsKeyNamei>  zCloudKmsKeyName to encapsulate `kmsKeyName` and `kmsKeyNames` fields.

Single `kmsKeyName` and repeated `kmsKeyNames` fields are extracted from user
input, which are later used in `EncryptionConfig` to pass to Spanner backend.
Nc                 2    Xl         Uc  / U l        g X l        g r   r   r   )selfr   r   s      r*   __init__CloudKmsKeyName.__init__E  s    $d(r)   r   )NN)__name__
__module____qualname____firstlineno____doc__r   __static_attributes__r(   r)   r*   r   r   >  s    )r)   r   returnc                    U R                   R                  R                  5       nU R                   R                  R                  5       n[	        5       nU(       a  UR                  5       Ul        U$ U(       a'  U Vs/ s H  oR                  5       PM     snUl        U$ S H;  n[        XR                  SS5      S5      (       d  M&  [        R                  " SS5      e   gs  snf )zParse the KMS key resource arg, make sure the key format is correct.

Args:
  args: calliope framework gcloud args

Returns:
  CloudKmsKeyName: if CMEK.
  None: if non-CMEK.
)r>   rA   rD   rG   rw   -_NzB--kms-project --kms-location --kms-keyring --kms-key or --kms-keyszFor a single KMS key, specify fully qualified KMS key ID with --kms-key, or use combination of --kms-project, --kms-location, --kms-keyring and --kms-key to specify the key ID in pieces. Or specify fully qualified KMS key ID with --kms-keys.)CONCEPTSkms_keyParsekms_keysr   RelativeNamer   r   getattrreplacer   InvalidArgumentException)r   r   r   cloud_kms_key_namekeywords        r*   GetAndValidateKmsKeyNamer   M  s     &&,,.,--((..0-&(&2&?&?&A#2 
1 8E(8E!!#($. 
% 
sC0$	7	7115
 	
" -(s   <C!c                 @    [         R                  R                  U 5      $ r   )_INSTANCE_TYPE_MAPPERr   rj   r   s    r*   AddInstanceTypeArgr   w  s    		)	)	5	5f	==r)   c                 @    [         R                  U R                  5      $ r   )r   r   instance_typer   s    r*   GetInstanceTyper   {  s    		/	/0B0B	CCr)   c                 @    [         R                  R                  U 5      $ r   )_DEFAULT_STORAGE_TYPE_MAPPERr   rj   r   s    r*   AddDefaultStorageTypeArgr     s    	%	0	0	<	<V	DDr)   c                 @    [         R                  U R                  5      $ r   )r   r   default_storage_typer   s    r*   GetDefaultStorageTypeArgr     s    	%	6	6

 r)   c                 @    [         R                  R                  U 5      $ r   )_EXPIRE_BEHAVIOR_MAPPERr   rj   r   s    r*   AddExpireBehaviorArgr     s    	 	+	+	7	7	??r)   c                 @    [         R                  U R                  5      $ r   )r   r   expire_behaviorr   s    r*   GetExpireBehaviorr     s    	 	1	1$2F2F	GGr)   N)T)F)Tr   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper    googlecloudsdk.calliope.conceptsr   r   $googlecloudsdk.command_lib.util.apisr   (googlecloudsdk.command_lib.util.conceptsr   r	   googlecloudsdk.corer
   VALUEScoreproject_PROJECTr   r!   r'   ChoiceEnumMapperGetMessagesModule,SpannerProjectsInstancesBackupsCreateRequest-EncryptionConfigEncryptionTypeValueValuesEnumr   CreateBackupEncryptionConfigEncryptionTypeValueValuesEnumr   CopyBackupEncryptionConfigr   RestoreDatabaseEncryptionConfigr   InstanceInstanceTypeValueValuesEnumr   !DefaultStorageTypeValueValuesEnumr   FreeInstanceMetadataExpireBehaviorValueValuesEnumr   r+   r0   r3   r6   r9   r<   r?   rB   rE   rH   rO   rR   rU   r[   r^   ra   rd   ro   rs   ru   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*   <module>r      sX   8 - . 5 1 : D G * !!))%%..	(1(B(B4223`3`1$
&
(
) %2 09/I/I4""#@#@1$
&
(
0 ,4 '0&@&@4  !>!>84
&
(
' #< &/%?%?4%%&C&C<4
&
(
& ": "224h**4

 4  )994h00DKK   $444--.K.K<(6
 &:B@IQC
I
K
L
<<.<<<)&()&"J)&)()(N
?4L
?4K
) )'o 'T>DE@Hr)   