
    U              
          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  SS
KJr  SSKJr  SSKJr  \R&                  R(                  R*                  r\R&                  R.                  R0                  r\R4                  " S\R6                  " SS5      R8                  R:                  SSSSSS.S9r\R4                  " S\R6                  " SS5      R>                  R@                  SSSSSS.S9r!\R4                  " S\R6                  " SS5      RD                  R@                  SSSSSS.S9r#\R4                  " S\R6                  " SS5      RH                  R@                  SSSSSS.S9r%\R4                  " S\R6                  " SS5      RL                  RN                  SSSS S!.S9r(\R4                  " S"\R6                  " SS5      RL                  RR                  S#SS$S%S&S'.S(9r*\R4                  " S)\R6                  " SS5      RV                  RX                  S*SS+S,S-.S9r-S. r.S/ r/S0 r0S1 r1S2 r2S3 r3S4 r4S5 r5S6 r6S7 r7S8 r8S9 r9S: r:S; r;S< r<S= r=S> r>S[S? jr?S[S@ jr@S[SA jrAS\SB jrBS[SC jrCS[SD jrDS[SE jrESF rFSG rGSH rHSI rISJ rJSK rKSL rLSM rMSN rNSO rO " SP SQ5      rPSR\P4SS jrQST rRSU rSSV rTSW rUSX rVSY rWgZ)]z1Shared resource flags for Cloud Spanner commands.    )absolute_import)division)unicode_literals)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-    InstancePartitionAttributeConfigr3      s    		2	2D
 r,   c                  ,    [         R                  " SSS9$ )z Get database resource attribute.databasez.The Cloud Spanner database for the {resource}.r1   r2   r+   r,   r-   DatabaseAttributeConfigr6      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}.r1   r2   r+   r,   r-   BackupAttributeConfigr9      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}.r1   r2   r+   r,   r-   BackupScheduleAttributeConfigr<      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}.r1   r2   r+   r,   r-   SessionAttributeConfigr?      s    		2	2 O
Q Qr,   c                  *    [         R                  " SS9$ )Nkms-key)r%   r2   r+   r,   r-   KmsKeyAttributeConfigrB      s    		2	2		BBr,   c                  ,    [         R                  " SSS9$ )Nkms-keyringz!KMS keyring id of the {resource}.r1   r2   r+   r,   r-   KmsKeyringAttributeConfigrE      s    		2	2$G
I Ir,   c                  ,    [         R                  " SSS9$ )Nkms-locationz"Cloud location for the {resource}.r1   r2   r+   r,   r-   KmsLocationAttributeConfigrH      s    		2	2%I
K Kr,   c                  ,    [         R                  " SSS9$ )Nkms-projectz$Cloud project id for the {resource}.r1   r2   r+   r,   r-   KmsProjectAttributeConfigrK     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-   GetInstanceResourceSpecrR   
  s*    			")+::	
< <r,   c                  n    [         R                  " SS[        5       [        5       [         R                  S9$ )Nz-spanner.projects.instances.instancePartitionsr0   )rM   instancePartitionsIdrN   rO   )r   rP   r3   r.   rQ   r+   r,   r-    GetInstancePartitionResourceSpecrU     s0    			5(;=)+::
 r,   c                  n    [         R                  " SS[        5       [        5       [         R                  S9$ )Nz$spanner.projects.instances.databasesr5   )rM   databasesIdrN   rO   )r   rP   r6   r.   rQ   r+   r,   r-   GetDatabaseResourceSpecrX     s0    			,)+)+::
< <r,   c            	      t    [         R                  " SS[        5       [        5       [	        5       [        5       S9$ )Nz/cloudkms.projects.locations.keyRings.cryptoKeyskey)rM   cryptoKeysId
keyRingsIdlocationsIdrO   )r   rP   rB   rE   rH   rK   r+   r,   r-   GetKmsKeyResourceSpecr^   %  s3    			7(**,,.*,
. .r,   c                  n    [         R                  " SS[        5       [        5       [         R                  S9$ )Nz"spanner.projects.instances.backupsr8   )rM   	backupsIdrN   rO   )r   rP   r9   r.   rQ   r+   r,   r-   GetBackupResourceSpecra   /  s0    			*%')+::
< <r,   c            	          [         R                  " SS[        5       [        5       [	        5       [         R
                  S9$ )Nz4spanner.projects.instances.databases.backupSchedulesr;   )rM   backupSchedulesIdrW   rN   rO   )r   rP   r<   r6   r.   rQ   r+   r,   r-   GetBackupScheduleResourceSpecrd   8  s6    			<%57)+)+::
< <r,   c            	          [         R                  " SS[        5       [        5       [	        5       [         R
                  S9$ )Nz-spanner.projects.instances.databases.sessionsr>   )rM   
sessionsIdrW   rN   rO   )r   rP   r?   r6   r.   rQ   r+   r,   r-   GetSessionResourceSpecrg   B  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ForResourcerR   formatAddToParserparserverb
positionalr%   s       r-   AddInstanceResourceArgrr   L  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 {}.Tri   N)r   rj   rk   rU   rl   rm   rn   s       r-   AddInstancePartitionResourceArgrv   _  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.
r5   z
--databasezThe Cloud Spanner database {}.Tri   N)r   rj   rk   rX   rl   rm   rn   s       r-   AddDatabaseResourceArgrx   s  rs   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.
rA   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 {}. )rG   rD   rJ   )r   prefixespluralr|   flag_name_overridesN)	add_groupr   rj   r   ResourcePresentationSpecr^   rl   rm   )ro   rp   rq   kms_key_namekms_key_namesr|   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 {}.Tri   N)r   rj   rk   rg   rl   rm   rn   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.
r8   z--backupzThe Cloud Spanner backup {}.Tri   N)r   rj   rk   ra   rl   rm   rn   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 {}.Tri   N)r   rj   rk   rd   rl   rm   rn   s       r-   AddBackupScheduleResourceArgr     sN     )	.A$++
#%-44T:	 ,  ![(r,   c                 @    [         R                  R                  U 5      $ N)%_CREATE_BACKUP_ENCRYPTION_TYPE_MAPPER
choice_argrm   ro   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   rm   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$   r8   r   r   --destination--destination-instancez--destination-backupN)r   r   ra   r   rj   rm   ro   	arg_specss     r-   AddCopyBackupResourceArgsr     sx     11


!
-) 11


!
2.)* 	*66v>r,   c                 @    [         R                  R                  U 5      $ r   )#_COPY_BACKUP_ENCRYPTION_TYPE_MAPPERr   rm   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$   r5   N)r   r   ra   rX   r   rj   rm   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   rm   r   s    r-   AddRestoreDbEncryptionTypeArgr   8  s    	+	6	6	B	B6	JJr,   c                 @    [         R                  U R                  5      $ r   )r   r   r   r   s    r-   GetRestoreDbEncryptionTyper   <  s    	+	<	<

 r,   c                   "    \ rS rSrSrSS jrSrg)CloudKmsKeyNameiA  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__H  s    $d(r,   r   )NN)__name__
__module____qualname____firstlineno____doc__r   __static_attributes__r+   r,   r-   r   r   A  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.
)rA   rD   rG   rJ   rz   -_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   P  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   rm   r   s    r-   AddInstanceTypeArgr   z  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   rm   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   rm   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)Xr   
__future__r   r   r   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.   r3   r6   r9   r<   r?   rB   rE   rH   rK   rR   rU   rX   r^   ra   rd   rg   rr   rv   rx   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      s_   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,   