
    .                        S 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
rSr\\-   rSrSrSr " S S\R&                  5      r " S S\R&                  5      r " S S\R&                  5      r " S S\R&                  5      rS rS rS rS rS rS rSCS jrS rSDS  jr S! r!S" r"S# r#S\RH                  RJ                  4S$ jr&   SES% jr'S& r(S' r)S( r* " S) S*\RV                  5      r, SDS+ jr-SDS, jr.SCS- jr/S\RH                  RJ                  4S. jr0S/ r1S0 r2 SFS1 jr3SDS2 jr4SDS3 jr5S4 r6S5 r7S6 r8S7 r9S8 r:S9 r;S: r<S; r=S< r>S= r?S> r@S? rAS@ rBSA rCSB rDg)Gz.Generic flags that apply to multiple commands.    N)	cloud_api)actions)arg_parsers)base)errors)
properties)	resources)projectbucketname)locationsizetimeCreatedtimeDeletedupdatedstorageClassetagretentionExpirationTimecrc32cmd5Hash
generationmetagenerationcontentTypecontentEncodingtimeStorageClassUpdateda  
Sets the IP filter for the bucket. The IP filter is a list of ip
ranges that are allowed to access the bucket. For example,
The following JSON document shows the IP filter configuration with mode
enabled and list of public network sources and vpc network sources:

  {
    "mode": "Enabled",
    "publicNetworkSource": { "allowedIpCidrRanges": ["0.0.0.0/0"] },
    "vpcNetworkSources": [
        {
            "network": "projects/PROJECT_NAME/global/networks/NETWORK_NAME",
            "allowedIpCidrRanges": ["0.0.0.0/0"]
        },
    ]
  }

For more information about supported configurations, see
[Cloud Storage bucket IP filtering configurations](https://cloud.google.com/storage/docs/create-ip-filter#ip-filtering-configurations)
a  
Sets the encryption enforcement configuration for the bucket from a JSON file.
This configuration determines restrictions on the types of encryption (GMEK,
CMEK, CSEK) allowed for new objects created in the bucket.

The JSON file should contain an object with keys among "gmekEnforcement",
"cmekEnforcement", and "csekEnforcement". Each of these keys, if present,
should have a "restrictionMode" key, determining whether the corresponding
encryption type should be allowed or restricted for new objects.

Valid values for "restrictionMode" are:
- "NotRestricted": The encryption type is allowed for new objects.
- "FullyRestricted": The encryption type is not allowed for new objects.

Example JSON file content, to enforce only CMEK for new objects:

  {
    "gmekEnforcement": {
      "restrictionMode": "FullyRestricted"
    },
    "cmekEnforcement": {
      "restrictionMode": "NotRestricted"
    },
    "csekEnforcement": {
      "restrictionMode": "FullyRestricted"
    }
  }

Omitted keys will not be sent in the API request. To clear a specific
enforcement setting during an update, set its value to null.
For example, to clear the "gmekEnforcement" setting:

  {
    "gmekEnforcement": null
  }
a   
Path to a local JSON or YAML file containing custom contexts one wants to set on
an object. For example:

1. The following JSON document shows two key value
pairs, i.e. (key1, value1) and (key2, value2):

  ```
    {
      "key1": {"value": "value1"},
      "key2": {"value": "value2"}
    }
  ```

2. The following YAML document shows two key value
pairs, i.e. (key1, value1) and (key2, value2):

  ```
    key1:
      value: value1
    key2:
      value: value2
  ```

Note: Currently object contexts only supports string format for values.
c                        \ rS rSrSrSrSrSrg)ReplicationStrategy|   z2Enum class for specifying the replication setting.DEFAULTASYNC_TURBO N)__name__
__module____qualname____firstlineno____doc__r   r    __static_attributes__r!       /lib/googlecloudsdk/command_lib/storage/flags.pyr   r   |   s    :'+r(   r   c                        \ rS rSrSrSrSrSrg)RetentionMode   z-Enum class for specifying the retention mode.LockedUnlockedr!   N)r"   r#   r$   r%   r&   LOCKEDUNLOCKEDr'   r!   r(   r)   r+   r+      s    5&(r(   r+   c                       \ rS rSrSrSrg)	LogAction   	transformr!   N)r"   r#   r$   r%   	TRANSFORMr'   r!   r(   r)   r2   r2      s    )r(   r2   c                       \ rS rSrSrSrSrg)LogActionState   	succeededfailedr!   N)r"   r#   r$   r%   	SUCCEEDEDFAILEDr'   r!   r(   r)   r7   r7      s    )&r(   r7   c                     [        U SS5      (       a  [        R                  R                  $ [        U SS5      (       a  [        R                  R                  $ [        R                  R
                  $ )z4Returns object version to query based on user flags.soft_deletedFall_versions)getattrr   ObjectStateSOFT_DELETEDLIVE_AND_NONCURRENTLIVE)	flag_argss    r)   get_object_state_from_flagsrF      sV    Y..  ---Y..  444				#	##r(   c                     U R                  SS[        R                  " 5       SS9  U R                  S[        S[        S9  g)	z3Adds flags that allow users to set object contexts.z--custom-contextsCUSTOM_CONTEXTS_KEYS_AND_VALUESz\Sets custom contexts on objects. The existing custom contexts (if any) would be overwritten.metavartypehelpz--custom-contexts-fileCUSTOM_CONTEXTS_FILErK   rJ   rL   N)add_argumentr   ArgDictstr_CUSTOM_CONTEXT_FILE_HELP_TEXTparsers    r)   add_object_context_setter_flagsrU      sM    / (   	$)	  r(   c                 "    U R                  SSS9$ )zDReturns a group of flags that allow users to handle object contexts.zOBJECT CONTEXTSz1Group that allow users to handle object contexts.categoryrL   )add_mutually_exclusive_grouprS   s    r)   get_object_context_grouprZ      s     		,	, 
= 
- 
 r(   c                    [        U 5      n[        U5        UR                  SSSS9  UR                  SS9nUR                  SS[        R
                  " 5       S	S
9  UR                  SS[        R                  " 5       SS
9  g)z)Adds common object context related flags.z--clear-custom-contexts
store_truez&Clears all custom contexts on objects.actionrL   a_  Flags that preserve the existing contexts on the object, and can be specified together. However they cannot be specified with `--clear-custom-contexts`, `--custom-contexts` or `--custom-contexts-file`. If `--update-custom-contexts` and `--remove-custom-contexts` are specified together, the `--remove-custom-contexts` would be applied first on object.rL   z--update-custom-contextsrH   z}Updates the custom contexts on the object, if an entry is found, it would be overwritten, otherwise the entry would be added.rI   z--remove-custom-contextsCUSTOM_CONTEXTS_KEYSzYRemoves the custom contexts on the object, if an entry is not found, it would be ignored.N)rZ   rU   rO   	add_groupr   rP   ArgList)rT   context_groupcontext_subgroups      r)   add_object_contexts_flagsre      s    *62-!-03  
 #,,J - 	  / G     $ "   r(   c                     U R                  S[        R                  " [        R                  R
                  R                  5      SSS9  g)zHAdds a flag that allows users to specify arbitrary headers in API calls.z--additional-headerszHEADER=VALUEzIncludes arbitrary headers in storage API calls. Accepts a comma separated list of key=value pairs, e.g. `header1=value1,header2=value2`.)r^   rJ   rL   N)rO   r   StorePropertyr   VALUESstorageadditional_headersrS   s    r)   add_additional_headers_flagrk      sC    ""



#
#
6
68*  +r(   c                     U R                  SS9nUR                  S[        R                  SS9  UR                  SSS9  g	)
z4Adds flags required for modifying Autoclass feature.	AUTOCLASSrX   z--enable-autoclasszhThe Autoclass feature automatically selects the best storage class for objects based on access patterns.r]   z"--autoclass-terminal-storage-classzThe storage class that objects in the bucket eventually transition to if they are not read for a certain length of time. Only valid if Autoclass is enabled.r_   N)ra   rO   r   StoreTrueFalseAction)rT   autoclass_groups     r)   add_autoclass_flagsrq      sV    $$k$:/--/  0
 *-  .r(   c                 >    U(       a  SnOSnU R                  SSUS9  g)z.Adds flag to commands that need object hashes.zAPI requests to the LIST endpoint do not fetch the hashes for encrypted objects by default. If this flag is set, a GET request is sent for each encrypted object in order to fetch hashes. This can significantly increase the cost of the command.zIf the initial GET request returns an object encrypted with a customer-supplied encryption key, the hash fields will be null. If the matching decryption key is present on the system, this flag retries the GET request with the key.z--fetch-encrypted-object-hashesr\   r]   NrO   )rT   is_list	help_texts      r)   &add_fetch_encrypted_object_hashes_flagrv      s6    	? 	1 
 	'9  Nr(   c                 (    U R                  SSSSS9  g)z=Adds predefined ACL flag shared for both buckets and objects.z-az--predefined-aclz--canned-aclzApplies predefined, or "canned," ACLs to a resource. See docs for a list of predefined ACL constants: https://cloud.google.com/storage/docs/access-control/lists#predefined-aclr_   Nrs   rS   s    r)   add_predefined_acl_flagrx     s#    
>  
r(   Fc                 F    U R                  SS[        R                  USS9  g)zAdds preserve ACL flag.z--preserve-aclz-paX  Preserves ACLs when copying in the cloud. This option is Cloud Storage-only, and you need OWNER access to all copied objects. If all objects in the destination bucket should have the same ACL, you can also set a default object ACL on that bucket instead of using this flag.
Preserving ACLs is the default behavior for updating existing objects.r^   hiddenrL   N)rO   r   ro   rT   r{   s     r)   add_preserve_acl_flagr}     s,    
--  r(   c                     [        U 5        U R                  SSS9  U R                  SSS[        R                  " 5       SS9  U R                  S	SS
S9  g)z2Adds flags common among commands that modify ACLs.z
--acl-filea  Path to a local JSON or YAML formatted file containing a valid policy. See the [ObjectAccessControls resource](https://cloud.google.com/storage/docs/json_api/v1/objectAccessControls) for a representation of JSON formatted files. The output of `gcloud storage [buckets|objects] describe` `--format="multi(acl:format=json)"` is a valid file and can be edited for more fine-grained control.r_   z--add-acl-grantappend	ACL_GRANTzKey-value pairs mirroring the JSON accepted by your cloud provider. For example, for Cloud Storage,`--add-acl-grant=entity=user-tim@gmail.com,role=OWNER`)r^   rJ   rK   rL   z--remove-acl-grantzKey-value pairs mirroring the JSON accepted by your cloud provider. For example, for Cloud Storage, `--remove-acl-grant=ENTITY`, where `ENTITY` has a valid ACL entity format, such as `user-tim@gmail.com`, `group-admins`, `allUsers`, etc.r]   N)rx   rO   r   rP   rS   s    r)   add_acl_modifier_flagsr   ,  su    &!3   	 C  
 	.	  
r(   c                 L    U R                  SS[        R                  " SS9SS9  g)z<Adds placement flag to set placement config for Dual-region.z--placementREGION,)custom_delim_chara(  A comma-separated list of regions that form the custom [dual-region](https://cloud.google.com/storage/docs/locations#location-dr). Only regions within the same continent are or will ever be valid. Invalid location pairs (such as mixed-continent, or with unsupported regions) will return an error.rI   N)rO   r   rb   rS   s    r)   add_placement_flagr   U  s.    58  r(   c                 f    U R                  SS9nUR                  SSSS9  UR                  SSS	S9  g
)z?Add flags indicating a precondition for an operation to happen.PRECONDITIONrn   z--if-generation-match
GENERATIONzNExecute only if the generation matches the generation of the requested object.)rJ   rL   z--if-metageneration-matchMETAGENERATIONzVExecute only if the metageneration matches the metageneration of the requested object.N)ra   rO   )rT   preconditions_groups     r)   add_precondition_flagsr   e  s[    (( )  "" # 
 ""! #  r(   c                    U R                  SS9nUR                  SSS9  UR                  SSS9  UR                  SS	S9  UR                  S
SS9  UR                  SSS9  UR                  S[        R                  R                  SS9  UR                  5       nUR                  SS[        R                  " 5       SS9  UR                  SSSS9  UR                  SS9nUR                  SS[        R                  " 5       SS9  UR                  SS[        R                  " 5       SS9  U[        R                  R                  :X  a  [        U5        U(       ag  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S*S9  g+g+),z-Add flags that allow setting object metadata.zOBJECT METADATArn   z--cache-controlz0How caches should handle requests and responses.r_   z--content-dispositionz How content should be displayed.z--content-encodingz'How content is encoded (e.g. ``gzip'').z--content-languagez5Content's language (e.g. ``en'' signifies "English").z--content-typez:Type of data contained in the object (e.g. ``text/html'').z--custom-timez9Custom time for Cloud Storage objects in RFC 3339 format.rK   rL   z--custom-metadataCUSTOM_METADATA_KEYS_AND_VALUESzxSets custom metadata on objects. When used with `--preserve-posix`, POSIX attributes are also stored in custom metadata.rI   z--clear-custom-metadatar\   zClears all custom metadata on objects. When used with `--preserve-posix`, POSIX attributes will still be stored in custom metadata.r]   zFlags that preserve unspecified existing metadata cannot be used with `--custom-metadata` or `--clear-custom-metadata`, but can be specified together:z--update-custom-metadataa%  Adds or sets individual custom metadata key value pairs on objects. Existing custom metadata not specified with this flag is not changed. This flag can be used with `--remove-custom-metadata`. When keys overlap with those provided by `--preserve-posix`, values specified by this flag are used.z--remove-custom-metadataMETADATA_KEYSzRemoves individual custom metadata keys from objects. This flag can be used with `--update-custom-metadata`. When used with `--preserve-posix`, POSIX attributes specified by this flag are not preserved.z--clear-cache-controlzClears object cache control.z--clear-content-dispositionz"Clears object content disposition.z--clear-content-encodingzClears content encoding.z--clear-content-languagezClears object content language.z--clear-content-typezClears object content type.z--clear-custom-timezClears object custom time.N)ra   rO   r   DatetimeParserY   rP   rb   r   ReleaseTrackALPHAre   )rT   allow_patchrelease_trackmetadata_groupcustom_metadata_groupupdate_custom_metadata_groups         r)   add_object_metadata_flagsr   v  st    ##->#?.=  ? -  / !L  NE  G I  K %%F  H )EEG$$/ B % D $$	 %  "7!@!@! "A "#
 ++ / . , 	0 ++   ,  d''---n-+   - %1   3 "'   ) ".   0 *   , )   ++ r(   c                     U R                  SUS9nUR                  SU=(       d    USS9  UR                  S[        R                  " 5       SUSS	9  U(       a  UR                  S
SU=(       d    USS9  gg)a  Adds flags for encryption and decryption keys.

Args:
  parser (parser_arguments.ArgumentInterceptor): Parser passed to surface.
  allow_patch (bool): Adds flags relevant for update operations if true.
  command_only_reads_data (bool): Should be set to true if a command only
      reads data from storage providers (e.g. cat, ls) and false for commands
      that also write data (e.g. cp, rewrite). Hides flags that pertain to
      write operations for read-only commands.
  hidden (bool): Hides encryption flags if true.

ENCRYPTION)rX   r{   z--encryption-keya  The encryption key to use for encrypting target objects. The specified encryption key can be a customer-supplied encryption key (An RFC 4648 section 4 base64-encoded AES256 string), or a customer-managed encryption key of the form `projects/{project}/locations/{location}/keyRings/{key-ring}/cryptoKeys/{crypto-key}`. The specified key also acts as a decryption key, which is useful when copying or moving encrypted data to a new location. Using this flag in an `objects update` command triggers a rewrite of target objects.)r{   rL   z--decryption-keysDECRYPTION_KEYa#  A comma-separated list of customer-supplied encryption keys (RFC 4648 section 4 base64-encoded AES256 strings) that will be used to decrypt Cloud Storage objects. Data encrypted with a customer-managed encryption key (CMEK) is decrypted automatically, so CMEKs do not need to be listed here.)rK   rJ   r{   rL   z--clear-encryption-keyr\   zClears the encryption key associated with an object. Using this flag triggers a rewrite of affected objects, which are then encrypted using the default encryption key set on the bucket, if one exists, or else with a Google-managed encryption key.rz   Nra   rO   r   rb   )rT   r   command_only_reads_datar{   encryption_groups        r)   add_encryption_flagsr     s     %%|F%K
 ..   &  F   	H !! 00M	 " N r(   c                 .    U R                  S[        SS9  g)zAdds the --encryption-enforcement-file flag for buckets commands.

Args:
  parser (parser_arguments.ArgumentInterceptor): Parser passed to surface.
z--encryption-enforcement-fileT)rL   r{   N)rO   !_ENCRYPTION_ENFORCEMENT_HELP_TEXTrS   s    r)   $add_encryption_enforcement_file_flagr     s      	%,  r(   c                 (    U R                  SSSSS9  g)zFAdds flag to indicate error should be skipped instead of being raised.z-cz--continue-on-errorr\   a  If any operations are unsuccessful, the command will exit with a non-zero exit status after completing the remaining operations. This flag takes effect only in sequential execution mode (i.e. processor and thread count are set to 1). Parallelism is default.r]   Nrs   rS   s    r)   add_continue_on_error_flagr     s%    
K	  Lr(   c                 ,    SSSSSS.nU (       a  X!   $ S$ )z:Returns a text to be added for create command's help text.z4 Defaults to <SOURCE_BUCKET_URL>/inventory_reports/.z' Defaults to all fields being included.z Defaults to tomorrow.z3 Defaults to one year from --schedule-starts value.z Defaults to DAILY.)destinationmetadata_fields
start_dateend_date	frequency r!   )require_create_flags	flag_nameoptional_text_maps      r)   _get_optional_help_textr   (  s/     LB,G( *>		%E2Er(   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )ArgListWithRequiredFieldsChecki4  z>ArgList that raises errror if required fields are not present.c           	         > [         [        U ]  U5      n[        [        5      [        U5      -
  nU(       a=  [
        R                  " SR                  SR                  [        U5      5      5      5      eU$ )NzFields {} are REQUIRED.r   )
superr   __call__set*REQUIRED_INVENTORY_REPORTS_METADATA_FIELDSr   ArgumentTypeErrorformatjoinsorted)self	arg_valuearglistmissing_required_fields	__class__s       r)   r   'ArgListWithRequiredFieldsCheck.__call__7  si    2DB9MG67#g,F ))
#
*
*hhv5679: : Nr(   r!   )r"   r#   r$   r%   r&   r   r'   __classcell__)r   s   @r)   r   r   4  s    F r(   r   c                     U R                  SSU(       a  [        [        5      OS[        [        S9SR	                  SR                  [        5      5      [        US5      -   S9  g)	zAdds the metadata-fields flag.z--metadata-fieldsMETADATA_FIELDSNchoicesz[The metadata fields to be included in the inventory report. The fields: "{}" are REQUIRED. z, r   )rJ   defaultrK   rL   )rO   list%ALL_INVENTORY_REPORTS_METADATA_FIELDSr   r   r   r   r   )rT   r   s     r)   *add_inventory_reports_metadata_fields_flagr   B  si     	& 9:,0)7944:FiiBC5E
!"68I
JK  Mr(   c                    U R                  SSS9nUR                  SSSS9  UR                  SS	9nUR                  S
SS/[        SSS9  UR                  S[        SSS9  UR                  S[        R                  SS9  U R                  S[        SS[        US5      -   S9  U R                  S[        SS9  U R                  S[        R                  R                  SS[        US 5      -   S9  U R                  S!S"S#/S$U(       a  S"OS%[        S&[        US'5      -   S(9  U R                  S)[        R                  R                  S*S+[        US,5      -   S9  U(       a  [        X5        g%g%)-zAdds the flags for the inventory reports create and update commands.

Args:
  parser (parser_arguments.ArgumentInterceptor): Parser passed to surface.
  require_create_flags (bool): True if create flags should be required.
TznReport format configuration. Any combination of CSV flags is valid as long as the Parquet flag is not present.mutexrL   z	--parquetr\   z#Generate reports in parquet format.r]   z%Flags for setting CSV format options.r_   z--csv-separatorz\nz\r\n	SEPARATORzeSets the character used to separate the records in the inventory report CSV file. For example, ``\n``)r   rK   rJ   rL   z--csv-delimiter	DELIMITERzaSets the delimiter that separates the fields in the inventory report CSV file. For example, ``,``rN   z--csv-headerz`Indicates whether or not headers are included in the inventory report CSV file. Default is None.z--destinationDESTINATION_URLzSSets the URL of the destination bucket and path where generated reports are stored.r   z--display-namez3Sets the editable name of the report configuration.r   z--schedule-starts
START_DATEzSets the date you want to start generating inventory reports. For example, 2022-01-30. Should be tomorrow or later based on UTC timezone.r   z--schedule-repeatsdailyweekly	FREQUENCYNz;Sets how often the inventory report configuration will run.r   )r   rJ   r   rK   rL   z--schedule-repeats-untilEND_DATEz]Sets date after which you want to stop generating inventory reports. For example, 2022-03-30.r   )	ra   rO   rQ   r   ro   r   Dayr   r   )rT   r   report_format_settingscsv_format_settingss       r)   add_inventory_reports_flagsr   S  s    "++G , H %%0 & 2 /882 9 4""g4 # 5 ""2	 # 3 ""--0 # 1
 	"#$8-HI	  K 	@  B 	??    $$8,GH	  J 	!-g4I#$8+FG  I 	 ??  &#$8*EF  H .vL r(   c                 0    U R                  S[        USS9  g)zAdds the location flag for the dataset-config commands.

Args:
  parser (parser_arguments.ArgumentInterceptor): Parser passed to surface.
  is_required (bool): True if location flag is a required field.
z
--locationz'Provide location of the dataset config.)rK   requiredrL   NrO   rQ   )rT   is_requireds     r)    add_dataset_config_location_flagr     s#     	4	  r(   c                    U R                  S[        SU(       + SS9  U[        R                  R                  :X  a  U R                  S[        SSSS9  U R                  S	[
        S
S9  U R                  SU(       + SS9nUR                  SSSS9  UR                  SSS9nUR                  S[        R                  " [        S9SSS9  UR                  S[
        SSS9  UR                  SSS9nUR                  S[        R                  " [        S9SS S9  UR                  S![
        S"S#S9  U R                  SS$S9nUR                  S%S&9nUR                  S'[        R                  " 5       S(S)S9  UR                  S*[        R                  " 5       S+S,S9  UR                  S-S&9nUR                  S.[        R                  " 5       S(S/S9  UR                  S0[        R                  " 5       S+S1S9  U R                  SS2S9n	U	R                  S3[        R                  " 5       S4S5S9  U	R                  S6[        R                  " 5       S4S7S9  g8)9a%  Adds the flags for the dataset-config create and update commands.

Args:
  parser (parser_arguments.ArgumentInterceptor): Parser passed to surface.
  is_update (bool): True if flags are for the dataset-configs update command.
  release_track (base.ReleaseTrack): The release track of command.
z--retention-period-daysRETENTION_DAYSz(Provide retention period for the config.)rK   rJ   r   rL   z%--activity-data-retention-period-daysACTIVITY_DATA_RETENTION_DAYSFzProvide retention period for the activity data in the config. This overrides the retention period for activity data. Otherwise, the `retention_period_days` value is used for activity data as well.--descriptionzDescription for dataset config.r   TzList of source options either source projects or source folders or enable organization scope. Refer [Dataset Configuration Properties](https://cloud.google.com/storage/docs/insights/datasets#dataset-config) for more details.)r   r   rL   z--enable-organization-scoper\   zBIf passed, the dataset config will be enabled on the organization.r]   zNList of source project numbers or the file containing list of project numbers.r   z--source-projects)element_typeSOURCE_PROJECT_NUMBERSzList of source project numbers.rN   z--source-projects-fileSOURCE_PROJECT_NUMBERS_IN_FILEzCCSV formatted file containing source project numbers, one per line.zDList of source folder IDs or the file containing list of folder IDs.z--source-foldersSOURCE_FOLDER_NUMBERSzList of source folder IDs.z--source-folders-fileSOURCE_FOLDER_NUMBERS_IN_FILEz>CSV formatted file containing source folder IDs, one per line.zSpecify the list of buckets to be included or excluded, both a list of bucket names and prefix regexes can be specified for either include or exclude buckets.z+Specify the list of buckets to be included.r_   z--include-bucket-namesBUCKETS_NAMESz!List of bucket names be included.z--include-bucket-prefix-regexesBUCKETS_REGEXESa*  List of bucket prefix regexes to be included. The dataset config will include all the buckets that match with the prefix regex. Examples of allowed prefix regex patterns can be testbucket```*```, testbucket.```*```foo, testb.+foo```*``` . It should follow syntax specified in google/re2 on GitHub. z+Specify the list of buckets to be excluded.z--exclude-bucket-namesz$List of bucket names to be excluded.z--exclude-bucket-prefix-regexeszList of bucket prefix regexes to be excluded. Allowed regex patterns are similar to those for the --include-bucket-prefix-regexes flag.zSpecify the list of locations for source projects to be included or excluded from [available locations](https://cloud.google.com/storage/docs/locations#available-locations).z--include-source-locationsLIST_OF_SOURCE_LOCATIONSz.List of locations for projects to be included.z--exclude-source-locationsz.List of locations for projects to be excluded.N)	rO   intr   r   r   rQ   ra   r   rb   )
rT   	is_updater   source_options_groupsource_projects_groupsource_folders_groupinclude_exclude_buckets_groupinclude_buckets_groupexclude_buckets_groupinclude_exclude_locations_groups
             r)   &add_dataset_config_create_update_flagsr     s    	}5   d''---
/.P  
 	,    ))}	 * 
 ###
N	 $  /88 9  $$C0&,	 %  $$.
O %  .77
P 8  ##C0%'	 $  ##-
J $  #)"2"2) #3 # 8AA8 B  $$ .	 %  $$' F %  8AA8 B  $$ 1	 %  $$' P %  %+$4$4^ %5 %! ".." (;	 /  ".." (;	 / r(   c                 &    U R                  SSSS9  g )Nz--rawr\   zMShows metadata in the format returned by the API instead of standardizing it.r]   rs   rS   s    r)   add_raw_display_flagr   U  s     	  r(   c                 *    U R                  SSS/SS9  g )Nz--admission-policyADMIT_ON_FIRST_MISSADMIT_ON_SECOND_MISSzbThe cache admission policy decides for each cache miss, whether to insert the missed block or not.r   rL   rs   rS   s    r)   add_admission_policy_flagr   `  s&    $&<=-	  r(   c                 (    U R                  SSSUS9  g )Nz--read-paths-from-stdinz-Ir\   r]   rs   )rT   ru   s     r)   add_read_paths_from_stdin_flagr   k  s      	l  r(   c           	         U R                  SS9nU(       a'  SnUR                  SSSS9  UR                  SSS	S9  S
nOSnSnUR                  S[        [         Vs/ s H  oUR                  PM     sn5      SR                  U5      S9  UR                  S[        R                  R                  SR                  U5      U-   SS9  gs  snf )zAdds the flags for object retention lock.

Args:
  parser (parser_arguments.ArgumentInterceptor): Parser passed to surface.
  is_update (bool): True if flags are for the objects update command.
	RETENTIONrn   objectz--clear-retentionr\   z|Clears object retention settings and unlocks the configuration. Requires --override-unlocked-retention flag as confirmation.r]   z--override-unlocked-retentionzNeeded for certain retention configuration modifications, such as clearing retention settings and reducing retention time. Note that locked configurations cannot be edited even with this flag.zi Requires --override-unlocked-retention flag to shorten the retain-until time in unlocked configurations.zdestination objectr   z--retention-modezSets the {} retention mode to either "Locked" or "Unlocked". When retention mode is "Locked", the retain until time can only be increased.r   z--retain-untilzGEnsures the {} is retained until the specified time in RFC 3339 format.DATETIME)rK   rL   rJ   N)	ra   rO   r   r+   valuer   r   r   r   )rT   r   retention_groupsubjectoverride_noteoptions         r)   add_per_object_retention_flagsr  s  s     $$ % / G  L	 !    '	 ! 		= 
 #GM?vll?@w   %%VG_   	 @s   Cc                 (    U R                  SSSUS9  g)z5Adds flag for only displaying soft-deleted resources.z--soft-deletedr\   z\Displays soft-deleted resources only. For objects, it will exclude live and noncurrent ones.)r^   rL   r{   Nrs   r|   s     r)   add_soft_deleted_flagr
    s%    /   r(   c                 .    U R                  S[        SS9  g)z9Adds flag for filtering objects by server side filtering.z--metadata-filtera  Server side filtering for objects. Works only for Google Cloud Storage URLs. The filter only works for objects, and not directories or buckets, which means commands like `storage ls` and `storage du` will still list directories or buckets even if they do not contain any objects matching the filter. See https://cloud.google.com/storage/docs/listing-objects#filter-by-object-contexts-syntax for more details.r   Nr   rS   s    r)   add_metadata_filter_flagr    s     	  r(   c                 \    [        U 5        U R                  SSSS9  U R                  SSS9  g)	z*Adds flags related to soft delete feature.z--exhaustiver\   zFor features like soft delete, the API may return an empty list. If present, continue querying. This may incur costs from repeated LIST calls and may not return any additional objects.r]   z--next-page-tokenz#Page token for resuming LIST calls.r_   N)r
  rO   rS   s    r)   add_soft_delete_flagsr    sD    C	   	0  r(   c                 &    U R                  SSSS9  g)z4Adds flag for enabling object retention for buckets.z--enable-per-object-retentionr\   zEnables each object in the bucket to have its own retention settings, which prevents deletion until stored for a specific length of time.r]   Nrs   rS   s    r)   $add_enable_per_object_retention_flagr    s     %	  r(   c                 `   U S   nUR                  S5      (       a  [        R                  R                  U5      R	                  5       n[
        R                  R                  R                  nUR                  5       (       a*  UR                  UR                  UR                  5       5      nU$ U$ )Nstorage_urlzgs://)
startswithr	   REGISTRYr   SelfLinkr   rh   coreuniverse_domainIsExplicitlySetreplacer   Get)resourcer  uriuniverse_domain_propertys       r)   _get_storage_urir    s    '+G$$



"
";
/
8
8
:C)0055EE//11KK08804468cJ	r(   c                 B    U R                   R                  [        5        g )N)display_info
AddUriFuncr  rS   s    r)    add_uri_support_to_list_commandsr"    s      !12r(   c           
          U R                  SS[        [         Vs/ s H  oR                  PM     sn5      S[        SS9  gs  snf )zAdds the recovery point objective flag for buckets commands.

Args:
  parser (parser_arguments.ArgumentInterceptor): Parser passed to surface.
z--recovery-point-objectivez--rpoSETTINGaO  Sets the [recovery point objective](https://cloud.google.com/architecture/dr-scenarios-planning-guide#basics_of_dr_planning) of a bucket. This flag can only be used with multi-region and dual-region buckets. `DEFAULT` option is valid for multi-region and dual-regions buckets. `ASYNC_TURBO` option is only valid for dual-region buckets. If unspecified when the bucket is created, it defaults to `DEFAULT` for dual-region and multi-region buckets. For more information, see [replication in Cloud Storage](https://cloud.google.com/storage/docs/availability-durability#cross-region-redundancy).)r   rJ   rK   rL   N)rO   r   r   r  rQ   )rT   r  s     r)   !add_recovery_point_objective_flagr%    sL     	"1DE1Dvll1DEF	F  H Fs   Ac                 ,    U R                  S[        S9  g)zAdds the ip filter file flag for buckets commands.

Args:
  parser (parser_arguments.ArgumentInterceptor): Parser passed to surface.
z--ip-filter-filer_   N)rO   _IP_FILTER_HELP_TEXTrS   s    r)   add_ip_filter_file_flagr(    s     	3  r(   c                     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[        SS9  g)zHAdds the GCP resource hierarchy level flag for management-hubs commands.LEVELTrX   r   r   --organizationz1Specifies organization id for the management hub.ORGANIZATIONrL   rJ   rK   	--projectz)Specifies project for the management hub.PROJECTrL   rK   rJ   --sub-folderz/Specifies sub-folder id for the management hub.
SUB_FOLDERNra   rO   rQ   )rT   management_hub_level_groups     r)   add_management_hub_level_flagsr6    s      &//dT  0   ))>	 *  ))6	 *  ))<	 * r(   c                 @   U R                  SSS9nUR                  SS[        R                  " 5       SS9  UR                  SS	[        R                  " 5       S
S9  U R                  SSS9nUR                  SSS9nUR                  SS[        R                  " 5       SS9  UR                  SS[        R                  " 5       SS9  UR                  SSS9nUR                  SS[        R                  " 5       SS9  UR                  SS[        R                  " 5       SS9  g)zBAdds the management hub filter flags for management-hubs commands.LOCATIONTrX   r   --exclude-locationsa  Comma separated list of [locations](https://cloud.google.com/storage/docs/locations#available-locations) to exclude in Management Hub filter. To clear excluded locations, provide flag with empty list. e.g `--exclude-locations=""` or `--exclude-locations=` .EXCLUDE_LOCATIONSr1  --include-locationsa  Comma separated list of [locations](https://cloud.google.com/storage/docs/locations#available-locations) to include in management hub filter. To clear included locations, provide flag with empty list. e.g `--include-locations=""` or `--include-locations=` .INCLUDE_LOCATIONSBUCKET_FILTERBUCKET_INCLUDE_FILTERzSets the cloud storage buckets inclusion filter. Full filters should be specified using available flags in this group, gcloud CLI infers missing flags of this group as empty which will result in clearing of the individual filters.rW   z--include-bucket-idszComma separated list of bucket ids to include in the management hub filter. To clear bucket id list, provide flag with empty list. e.g `--include-bucket-ids=""` or `--include-bucket-ids=` .INCLUDE_BUCKET_IDS--include-bucket-id-regexesl  Sets filter for bucket id regexes to include. Accepts list of bucket id regexes in comma separated format. If the regex contains special characters that may have a specific meaning in the shell, escape them using backslashes(\). To clear bucket id regexes list, provide flag with empty list. e.g `--include-bucket-id-regexes=""` or `--include-bucket-id-regexes=` .INCLUDE_BUCKET_ID_REGEXESBUCKET_EXCLUDE_FILTERzSets the cloud storage buckets exclusion filter. Full filters should be specified using available flags in this group, gcloud CLI infers missing flags of this group as empty which will result in clearing of the individual filters.z--exclude-bucket-idszComma separated list of bucket ids to exclude in the management hub filter. To clear bucket id list, provide flag with an empty list. e.g `--exclude-bucket-ids=""` or `--exclude-bucket-ids=` .EXCLUDE_BUCKET_IDS--exclude-bucket-id-regexeso  Sets filter for bucket id regexes to exclude. Accepts list of bucket id regexes in comma separated format. If the regex contains special characters that may have a specific meaning in the shell, escape them using backslashes(\). To clear bucket id regexes list, provide flag with an empty list. e.g `--exclude-bucket-id-regexes=""` or `--exclude-bucket-id-regexes=` .EXCLUDE_BUCKET_ID_REGEXESNr   )rT   %management_hub_localtion_filter_group"management_hub_bucket_filter_group*management_hub_include_bucket_filter_group*management_hub_exclude_bucket_filter_groups        r)   add_management_hub_filter_flagsrM  9  s   *0*:*: +; +' (44B  ! 5  (44&  ! 5  (.'7'7d (8 ($ 0R/[/[&? 0\ 0, -99D  " : 	 -99#.  ) :  0R/[/[&? 0\ 0, -99H  " : 	 -99#.  ) : r(   c                     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[        SS9  g)zUAdds the GCP resource hierarchy level flag for storage intelligence-configs commands.r*  Tr+  r,  z>Specifies organization id for the storage intelligence config.r-  r.  r/  z6Specifies project for the storage intelligence config.r0  r1  r2  z<Specifies sub-folder id for the storage intelligence config.r3  Nr4  )rT   (storage_intelligence_configs_level_groups     r)   ,add_storage_intelligence_configs_level_flagsrP    s     .4-=-=dT .> .* +77K	 8  +77C	 8  +77I	 8 r(   c                 Z    U R                  SSSS9  U R                  SS9n[        U5        g)zBAdds the settings flags for storage intelligence-configs commands.z--trial-editionr\   z/Enables Storage Intelligence for TRIAL edition.r]   FILTERSrn   N)rO   ra   -add_storage_intelligence_configs_filter_flags)rT   filterss     r)   /add_storage_intelligence_configs_settings_flagsrU    sB    
;	     ' 08r(   c                 l   U R                  SSS9nUR                  SS[        R                  " 5       SS9  UR                  SS	[        R                  " 5       S
S9  U R                  SSS9nUR                  SS[        R                  " 5       SS9  UR                  SS[        R                  " 5       SS9  g)z@Adds the filter flags for storage intelligence-configs commands.r8  Tr9  r:  a  Comma separated list of [locations](https://cloud.google.com/storage/docs/locations#available-locations) to exclude in storage intelligence filter. To clear excluded locations, provide flag with empty list. e.g `--exclude-locations=""` or `--exclude-locations=` .r;  r1  r<  a  Comma separated list of [locations](https://cloud.google.com/storage/docs/locations#available-locations) to include in storage intelligence filter. To clear included locations, provide flag with empty list. e.g `--include-locations=""` or `--include-locations=` .r=  r>  rA  rB  rC  rF  rG  rH  Nr   )rT   3storage_intelligence_configs_localtion_filter_group0storage_intelligence_configs_bucket_filter_groups      r)   rS  rS    s    8>8H8H 9I 95 6BBB  ! C  6BBB  ! C  6<5E5Ed 6F 62 3??#.  ) @  3??#.  ) @ r(   c                     U R                   (       a1  U R                   S:w  a  [        R                  " S5      eSnSU l         U$ [        R                  R
                  R                  R                  5       nU$ )zCheck if format output using gsutil style.

Args:
  args (object): User input arguments.

Returns:
  use_gsutil_style (bool): True if format with gsutil style.
gsutilzThe only valid format value for ls and du is "gsutil" (e.g. "--format=gsutil"). See other flags and commands for additional formatting options.TN)r   r   Errorr   rh   ri   run_by_gsutil_shimGetBool)argsuse_gsutil_styles     r)   check_if_use_gsutil_styler`    sm     
[[{{hLL! 
 DK 
 "((00CCKKM	r(   c                 J   U R                  SSS[        S9  U R                  SSSSS9nUR                  SS	[        S
9  UR                  SS[        R                  " 5       SS9  U R                  SSSSS9nUR                  SSS9nUR                  S[        R
                  SS9  UR                  S[        R
                  SS9  UR                  SSS9nUR                  SSSSS9  UR                  SSS S9  UR                  S!S"[        R                  " S#S$90 S%[        R                  S&9  UR                  S'S([        R                  " S#S$90 S%[        R                  S&9  U R                  S)S*[        S
9  U R                  S+S,S-S.9nUR                  S/[        R                  " [        [         Vs/ s H  ofR                  PM     sn5      S09S1S2S39  UR                  S4[        R                  " [        [         Vs/ s H  ofR                  PM     sn5      S09S5S6S39  g7s  snf s  snf )8z<Adds the flags for the batch-operations jobs create command.z--bucketTzABucket containing the objects that the batch job will operate on.)r   rL   rK   SOURCEzSource specifying objects to perform batch operations on. Must be one of `--manifest-location=``MANIFEST_LOCATION` or `--included-object-prefixes=``COMMA_SEPARATED_PREFIXES`)r   r   rX   rL   z--manifest-locationai  An absolute path to the manifest source file in a Google Cloud Storage bucket. The file must be a CSV file where each row specifies the object details i.e. ProjectId, BucketId, and Name. Generation may optionally be specified. When generation is not specified, the live object is acted upon. Format: `--manifest-location=gs://bucket_name/path/manifest_name.csv`)rL   rK   z--included-object-prefixeszA comma-separated list of object prefixes to describe the objects being transformed. An empty string means all objects in the bucket.PREFIXESr1  TRANSFORMATIONz.Transformation to be performed on the objects.PUT_OBJECT_HOLDz(Describes options to update object hold.rW   z--put-object-temporary-holdzuSets or unsets object temporary holds state. When object temporary hold is set, object cannot be deleted or replaced.r]   z--put-object-event-based-holdzxSets or unsets object event based holds state. When object event based hold is set, object cannot be deleted or replacedDELETE_OBJECTz$Describes options to delete objects.z--delete-objectr\   zIf this flag is set, objects specified in source will be deleted. When versioning is enabled on the buckets, live objects in versioned buckets will become noncurrent and objects that were already noncurrent will be skipped.)r   r^   rL   z"--enable-permanent-object-deletionz{If this flag is set and versioning is enabled on the buckets, both live and noncurrent objects will be permanently deleted.z--rewrite-objecta9  Rewrites object and the specified metadata. Currently only supports rewriting kms-key. A metadata field MUST be specified. For example, `--rewrite-object=kms-key=projects/PROJECT_ID/locations/LOCATION/keyRings/KEY_RING/cryptoKeys/CRYPTO_KEY` will rewrite the Cloud KMS key that will be used to encrypt the object.   )
min_lengthz	KEY=VALUE)rL   rK   r   rJ   r^   z--put-metadataa  Sets object metadata. To set how content should be displayed, specify the the key-value pair `Content-Disposition={VALUE}.` To set how content is encoded (e.g. "gzip"), specify the key-value pair `Content-Encoding={VALUE}`. To set content's language (e.g. "en" signifies "English"), specify the key-value pair `Content-Language={VALUE}`. To set the type of data contained in the object (e.g. "text/html"), specify the key-value pair `Content-Type={VALUE}`. To set how caches should handle requests and responses, specify the key-value pair `Cache-Control={VALUE}`. To set custom time for Cloud Storage objects in RFC 3339 format, specify the key-value pair `Custom-Time={VALUE}`. To set object retention, specify `Retain-Until={TIMESTAMP}` in RFC 3339 format and `Retention-Mode={MODE}` where mode can be `Locked` or `Unlocked`. To set custom metadata on objects, specify key-value pairs `{CUSTOM-KEY}:{VALUE}`. Note that all predefined keys (e.g. Content-Disposition) are case-insensitive. Any other key that is not specified above will be treated as a custom key. To clear a field, provide the key with an empty value (e.g. `Content-Disposition=`). Multiple key-value pairs can be specified by separating them with commas. For example, `--put-metadata=Content-Disposition=inline,Content-Encoding=gzip`r   zDescription for the batch job.LOGGING_CONFIGzLOGGING CONFIG

Configure which transfer actions and action states are reported when logs are generated for this job. Logs can be viewed by running the following command:
gcloud logging read "resource.type=storagebatchoperations.googleapis.com/Job"F)rX   rL   	sort_argsz--log-actionsr   LOG_ACTIONSzPDefine the batch job actions to report in logs. (e.g., --log-actions=transform).rN   z--log-action-statesLOG_ACTION_STATESzThe states in which the actions specified in --log-actions are logged. Separate multiple states with a comma, omitting the space after the comma (e.g., --log-action-states=succeeded,failed).N)rO   rQ   ra   r   rb   ro   rP   StoreOnceActionr   r2   r  r7   )rT   sourcetransformationput_object_holddelete_objectlogging_configr  s          r)   add_batch_jobs_flagsrs  %  s    	N	     & 	K    	"Q     ##;	 $ . #,, 5 - / #--?	   %--D	   !**1 + - 1  
 *J	    !,((   O, !,((9  < 	+  
 ##G
  $ 	. Y?Y6,,Y?@ .  
 ^D^6,,^DE "K   @ Es   -H8H c                 (    U R                  SSSSS9  g)zCAdds the dry run flag for the batch-operations jobs create command.z	--dry-runzIf true, the job will run in dry run mode, returning the total object count and, if the object configuration is a prefix list, the bytes found from source. No transformations will be performed.r\   T)rL   r^   r{   Nrs   rS   s    r)   add_batch_jobs_dry_run_flagru    s%    
   
r(   )T)F)FFF)z!Read the list of URLs from stdin.)Er&   enumgooglecloudsdk.api_lib.storager   googlecloudsdk.callioper   r   r   "googlecloudsdk.command_lib.storager   googlecloudsdk.corer   r	   r   *OPTIONAL_INVENTORY_REPORTS_METADATA_FIELDSr   r'  r   rR   Enumr   r+   r2   r7   rF   rU   rZ   re   rk   rq   rv   rx   r}   r   r   r   r   GAr   r   r   r   r   rb   r   r   r   r   r   r   r   r   r  r
  r  r  r  r  r"  r%  r(  r6  rM  rP  rU  rS  r`  rs  ru  r!   r(   r)   <module>r~     s   5  4 + / ( 5 * ) .K *.2 * /./ & *#% !J" 8$)) DII 		 TYY 
$&$N	+.N$$%R  $ T->->-A-A^+D &+16 %5Np
	L	F[%8%8  EJM"GMT  4+<+<+?+?fR :8v
"$
	3H06eP69?D0m`r(   