
    ]/                         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Jr  S r	SS jr
S	 rS
 r SS jrS rS rSS jrS rS rSS jrS rS rS rg)z5Flags and helpers for the firestore related commands.    )absolute_import)division)unicode_literalsN)arg_parsersc                 N    U R                  SS[        R                  " 5       SS9  g)z^Adds flag for collection group ids to the given parser.

Args:
  parser: The argparse parser.
z--collection-idsCOLLECTION_GROUP_IDSa)  
      List specifying which collection groups will be included in the operation.
      When omitted, all collection groups are included.

      For example, to operate on only the `customers` and `orders`
      collections groups:

        $ {command} --collection-ids='customers','orders'
      metavartypehelpNadd_argumentr   ArgListparsers    1lib/googlecloudsdk/command_lib/firestore/flags.pyAddCollectionGroupIdsFlagr      s.     	$ 
	      c           
      `    U(       d  SnOSnU R                  SS[        U(       d  SOSUUUS9  g)zAdds flag for database id to the given parser.

Args:
  parser: The argparse parser.
  required: Whether the flag must be set for running the command, a bool.
  hidden: Whether the flag is hidden, a bool.
z      The database to operate on. The default value is `(default)`.

      For example, to operate on database `foo`:

        $ {command} --database='foo'
      z      The database to operate on.

      For example, to operate on database `foo`:

        $ {command} --database='foo'
      z
--databaseDATABASEz	(default)N)r
   r   defaultrequiredhiddenr   r   str)r   r   r   helper_texts       r   AddDatabaseIdFlagr   1   sC     

K
K 	!)kt  r   c                 N    U R                  SS[        R                  " 5       SS9  g)z0Adds flag for namespace ids to the given parser.z--namespace-idsNAMESPACE_IDSaI  
      List specifying which namespaces will be included in the operation.
      When omitted, all namespaces are included.

      This is only supported for Datastore Mode databases.

      For example, to operate on only the `customers` and `orders` namespaces:

        $ {command} --namespaces-ids='customers','orders'
      r	   Nr   r   s    r   AddNamespaceIdsFlagr    T   s,     	
	  r   c           	      4    U R                  SS[        SSSS9  g)zWAdds flag for snapshot time to the given parser.

Args:
  parser: The argparse parser.
z--snapshot-timeSNAPSHOT_TIMENFa  
      The version of the database to export.

      The timestamp must be in the past, rounded to the minute and not older
      than `earliestVersionTime`. If specified, then the exported documents will
      represent a consistent view of the database at the provided time.
      Otherwise, there are no guarantees about the consistency of the exported
      documents.

      For example, to operate on snapshot time `2023-05-26T10:20:00.00Z`:

        $ {command} --snapshot-time='2023-05-26T10:20:00.00Z'
      )r
   r   r   r   r   r   r   s    r   AddSnapshotTimeFlagr#   g   s+     	
  r   c           
      6    U R                  SSUU[        USS9  g)a  Adds flag for location to the given parser.

Args:
  parser: The argparse parser.
  required: Whether the flag must be set for running the command, a bool.
  hidden: Whether the flag is hidden in document. a bool.
  suggestion_aliases: A list of flag name aliases. A list of string.
z
--locationLOCATIONz
      The location to operate on. Available locations are listed at
      https://cloud.google.com/firestore/docs/locations.

      For example, to operate on location `us-east1`:

        $ {command} --location='us-east1'
      )r
   r   r   r   suggestion_aliasesr   Nr   )r   r   r   r&   s       r   AddLocationFlagr'      s.     	+
  r   c                 2    U R                  SSS[        SS9  g)zPAdds flag for backup to the given parser.

Args:
  parser: The argparse parser.
z--backupBACKUPTz
      The backup to operate on.

      For example, to operate on backup `cf9f748a-7980-4703-b1a1-d1ffff591db0`:

        $ {command} --backup='cf9f748a-7980-4703-b1a1-d1ffff591db0'
      r
   r   r   r   Nr   r   s    r   AddBackupFlagr+      s(     	
  r   c                 2    U R                  SSS[        SS9  g)z\Adds flag for backup schedule id to the given parser.

Args:
  parser: The argparse parser.
z--backup-scheduleBACKUP_SCHEDULETz
      The backup schedule to operate on.

      For example, to operate on backup schedule `091a49a0-223f-4c98-8c69-a284abbdb26b`:

        $ {command} --backup-schedule='091a49a0-223f-4c98-8c69-a284abbdb26b'
      r*   Nr   r   s    r   AddBackupScheduleFlagr.      s(     	
  r   c           	      x    U R                  SSU[        R                  " 5       [        R                  " S5      S9  g)zAdds flag for retention to the given parser.

Args:
  parser: The argparse parser.
  required: Whether the flag must be set for running the command, a bool.
z--retention	RETENTIONa*            The rention of the backup. At what relative time in the future,
          compared to the creation time of the backup should the backup be
          deleted, i.e. keep backups for 7 days.

          For example, to set retention as 7 days.

          $ {command} --retention=7d
          r*   N)r   r   Durationtextwrapdedent)r   r   s     r   AddRetentionFlagr4      s=     	!??    r   c                     U R                  SSS9nSnUR                  S[        USS9  SnUR                  S[        R                  R
                  [        R                  R                  US	S
9  g)zTAdds flag for recurrence to the given parser.

Args:
  parser: The argparse parser.
z)Recurrence settings of a backup schedule.T)r   r   a^        The recurrence settings of a backup schedule.

      Currently only daily and weekly backup schedules are supported.

      When a weekly backup schedule is created, day-of-week is needed.

      For example, to create a weekly backup schedule which creates backups on
      Monday.

        $ {command} --recurrence=weekly --day-of-week=MON
  z--recurrence)r   r   r   z     The day of week (UTC time zone) of when backups are created.

      The available values are: `MON`, `TUE`, `WED`, `THU`, `FRI`, `SAT`,`SUN`.
      Values are case insensitive.

      This is required when creating a weekly backup schedule.
  z--day-of-weekF)choicesr   r   r   N)	add_groupr   r   r   	DayOfWeekDAYSParse)r   group	help_texts      r   AddRecurrenceFlagr=      s     

6  %) ^#IM) ##((  &&  r   c           
         U R                  S[        R                  " [        R                  " S5      R                  US95      S9nUR                  SS[        S/ SQ[        R                  " S	5      S
9  [        US5        g)zAdds flags for the database's encryption configuration to the given parser.

Args:
  parser: The argparse parser.
  source_type: "backup" if a restore; "database" if a clone
Fa              The encryption configuration of the new database being created from the $source_type.
            If not specified, the same encryption settings as the $source_type will be used.

            To create a CMEK-enabled database:

              $$ {command} --encryption-type=customer-managed-encryption --kms-key-name=projects/PROJECT_ID/locations/LOCATION_ID/keyRings/KEY_RING_ID/cryptoKeys/CRYPTO_KEY_ID

            To create a Google-default-encrypted database:

              $$ {command} --encryption-type=google-default-encryption

            To create a database using the same encryption settings as the $source_type:

              $$ {command} --encryption-type=use-source-encryption
            )source_type)r   r   z--encryption-typeENCRYPTION_TYPET)zuse-source-encryptionzcustomer-managed-encryptionzgoogle-default-encryptionzE          The encryption type of the destination database.
          )r
   r   r   r6   r   zWThis flag must only be specified when encryption-type is `customer-managed-encryption`.N)	add_argument_groupr2   r3   stringTemplate
substituter   r   AddKmsKeyNameFlag)r   r?   encryption_configs      r   AddEncryptionConfigGrouprG     s     //??6?? ,  46 0 &   
 ??   !  (r   c           	      ~    [         R                  " S5      nU(       a  US-   U-   nU R                  SS[        SSUS9  g)zAdds flag for KMS Key Name to the given parser.

Args:
  parser: The argparse parser.
  additional_help_text: Additional help text to be added to the flag.
aL  
      The resource ID of a Cloud KMS key. If set, the database created will be a Customer-Managed Encryption Key (CMEK) database encrypted with this key.
      This feature is allowlist only in initial launch.

      Only a key in the same location as this database is allowed to be used for encryption.
      For Firestore's nam5 multi-region, this corresponds to Cloud KMS location us.
      For Firestore's eur3 multi-region, this corresponds to Cloud KMS location europe.
      See https://cloud.google.com/kms/docs/locations.

      This value should be the KMS key resource ID in the format of `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
      How to retrieve this resource ID is listed at https://cloud.google.com/kms/docs/getting-resource-ids#getting_the_id_for_a_key_and_version.
    z

z--kms-key-nameKMS_KEY_NAMEFN)r
   r   r   r   r   )r2   r3   r   r   )r   additional_help_textr<   s      r   rE   rE   :  sQ     oo  	) F"%99I  r   c                     U R                  SS[        S[        R                  " SU SU SS SS	 S
S SS SU S35      S9  g )Nz--destination-databaseDESTINATION_DATABASETz"          Destination database to zM to. Destination database will be created in the same location as the source z.

          This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
          with first character a letter and the last a letter or a number. Must
          not be UUID-like /[0-9a-f]   z
(-[0-9a-f]   )   z	-[0-9a-f]   zX/.

          Using "(default)" database ID is also allowed.

          For example, to zV to database `testdb`:

          $ {command} --destination-database=testdb
          )r
   r   r   r   )r   r   r2   r3   )r   action_namer?   s      r   AddDestinationDatabaserS   [  s~    $??  ##.-/|  ~I  }J J% &'Cz!AaS	" F '- (   r   c                     U R                  SS[        R                  " 5       S[        R                  " SU SU S35      S9  g)zAdds the --tags flag to the given parser.

Args:
  parser: The parser to add the flag to.
  resource_type: The resource type to use in the help text (e.g. 'database').
z--tagsz	KEY=VALUENz,          Tags to attach to the destination zV. Example: --tags=key1=value1,key2=value2

          For example, to attach tags to a z8:

          $ --tags=key1=value1,key2=value2
          )r
   r   r   r   )r   r   ArgDictr2   r3   )r   resource_types     r   AddTagsrW   q  sV     	 ??  --:O <,,9? ;   r   c                 0    U R                  SS[        SS9  g)zaAdds positional arg for user creds id to the given parser.

Args:
  parser: The argparse parser.

user_creds
USER_CREDSz
      The user creds to operate on.

      For example, to operate on user creds `creds-name-1`:

        $ {command} creds-name-1
      r	   Nr   r   s    r   AddUserCredsIdArgr[     s%     	
	  r   )FF)FFN)F)N)__doc__
__future__r   r   r   rB   r2   googlecloudsdk.callioper   r   r   r    r#   r'   r+   r.   r4   r=   rG   rE   rS   rW   r[    r   r   <module>r`      sl    < &  '   /, F&: >B:**0&R,^B,,r   