
    8)                     0   S r SSKJr  SSKJr  SSKJr  SSKrSSKJr  SSKJr	  SSK
Jr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  S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  \R8                   " S S\R:                  5      5       rg)z4Implementation of rm command for deleting resources.    )absolute_import)division)unicode_literalsN)	cloud_api)errors)base)flags)folder_util)name_expansion)plurality_checkable_iterator)rm_command_util)stdin_iterator)user_request_args_factory)task_executor)task_graph_executor)task_status)delete_task_iterator_factory)logc                   8    \ rS rSrSrSSS.r\S 5       rS rSr	g	)
Rm(   zDelete objects and buckets.z)
      Delete objects and buckets.
      a  

      The following command deletes a Cloud Storage object named ``my-object''
      from the bucket ``my-bucket'':

        $ {command} gs://my-bucket/my-object

      The following command deletes all objects directly within the directory
      ``my-dir'' but no objects within subdirectories:

        $ {command} gs://my-bucket/my-dir/*

      The following command deletes all objects and subdirectories within the
      directory ``my-dir'':

        $ {command} gs://my-bucket/my-dir/**

      Note that for buckets that contain
      [versioned objects](https://cloud.google.com/storage/docs/object-versioning),
      the above command only affects live versions. Use the `--recursive` flag
      instead to delete all versions.

      The following command deletes all versions of all resources in
      ``my-bucket'' and then deletes the bucket.

        $ {command} --recursive gs://my-bucket/

      The following command deletes all text files in the top-level of
      ``my-bucket'', but not text files in subdirectories:

        $ {command} -recursive gs://my-bucket/*.txt

      The following command deletes one wildcard expression per line passed
      in by stdin:

        $ some_program | {command} -I
      )DESCRIPTIONEXAMPLESc                 D   UR                  SSSS9  UR                  SSSSS	S
9  UR                  SSSSS
9  UR                  SSSSS9  [        R                  " U5        [        R                  " U5        [        R                  " U5        [        R
                  " U5        g )Nurls*z$The URLs of the resources to delete.)nargshelpz--recursivez-Rz-r
store_truead  Recursively delete the contents of buckets or directories that match the path expression. By default, this will delete managed folders as well. If the path is set to a bucket, like ``gs://bucket'', the bucket is also deleted. This option implies the `--all-versions` option. If you want to delete only live object versions, use the ``**'' wildcard instead.)actionr   z--all-versionsz-az\Delete all [versions](https://cloud.google.com/storage/docs/object-versioning) of an object.z--exclude-managed-foldersFa  Excludes managed folders from command operations. By default gcloud storage includes managed folders in recursive removals. Please note that this flag would not be applicable for hierarchical namespace buckets as we always list managed folders for these buckets.)r    defaultr   )add_argumentr	   add_additional_headers_flagadd_continue_on_error_flagadd_precondition_flagsadd_read_paths_from_stdin_flag)clsparsers     lib/surface/storage/rm.pyArgsRm.ArgsY   s    
3  5 F   	   #"   
%%f-	$$V,	  (	((0    c                 4	   UR                   (       aO  [        R                  R                  n[        R
                  R                  n[        R                  R                  nOJ[        R                  R                  n[        R                  " U5      n[        R                  R                  nUR                   =(       a    UR                  (       + n[        R                  " 5       n[        R                  " [         R"                  " UR$                  UR&                  5      [        R(                  R*                  U[,        R.                  R0                  [,        R2                  R4                  UUR                   (       + UUS9	n[6        R8                  " U5      n[:        R<                  R?                  5       n	[@        RB                  " UU	US9n
[D        RF                  RI                  S5        [J        RL                  " U
RO                  5       SU	[P        RR                  " [P        RT                  RV                  S S9URX                  S9nUR                   (       aW  [        R                  " UR$                  [,        R2                  RZ                  U(       + UUS9n [\        R^                  " UU	SS9nOSnU(       al  [        R                  " UR$                  [,        R.                  Rj                  SS[        R                  R                  US9n [\        Rl                  " UUU	SS9nOSn[n        Rp                  " U
Rs                  5       5      nUR                   (       a  URu                  5       (       dm  [D        RF                  RI                  S5        [J        RL                  " USU	[P        RR                  " [P        RT                  RV                  S S9URX                  S9nOSn[w        UUUU5      U l<        g ! [`        Rb                   a>  nURd                  Rf                  S	:w  a  e [D        Rh                  " S
5        Sn S nAGNS nAff = f! [`        Rb                   a>  nURd                  Rf                  S	:w  a  e [D        Rh                  " S5        Sn S nAGNoS nAff = f)N)fields_scopeinclude_bucketsmanaged_folder_settingfolder_settingobject_stateraise_error_for_unmatched_urlsrecursion_requestedurl_found_match_tracker)task_status_queueuser_request_argszRemoving objects:T)increment_typemanifest_path)parallelizabler6   progress_manager_argscontinue_on_error)r1   r3   r4   r5   )verbosei  z4Unable to delete folders due to missing permissions.r   F)r0   r3   (raise_managed_folder_precondition_errorsr4   r5   z<Unable to delete managed folders due to missing permissions.zRemoving buckets:)=	recursiver   BucketSettingYESr   ObjectStateLIVE_AND_NONCURRENTRecursionSettingNOr	   get_object_state_from_flagsNO_WITH_WARNINGexclude_managed_folderscollectionsOrderedDictNameExpansionIteratorr   get_urls_iterabler   read_paths_from_stdinFieldsScopeSHORTr
   ManagedFolderSettingDO_NOT_LISTFolderSettingLIST_AS_PREFIXESr   'get_user_request_args_from_command_argsr   multiprocessing_contextQueuer   DeleteTaskIteratorFactoryr   statusPrintr   execute_tasksobject_iteratorr   ProgressManagerArgsIncrementTypeINTEGERr<   LIST_AS_FOLDERSr   remove_folders
api_errorsGcsApiErrorpayloadstatus_codewarningLIST_WITHOUT_OBJECTSremove_managed_foldersr   PluralityCheckableIteratorbucket_iteratoris_emptymax	exit_code)selfargsbucket_settingr2   recursion_setting(should_perform_managed_folder_operationsr5   name_expansion_iteratorr7   r6   task_iterator_factoryobject_exit_codefolder_expansion_iteratorfolder_exit_codeerror!managed_folder_expansion_iteratormanaged_folder_exit_coderi   bucket_exit_codes                      r)   RunRm.Run   s   ~~%3377n**>>l(99==%3366n66t<l(99II 	;t;;; - *557 -BB((D4N4NO**00&*??KK"00AA!+/>>'9- 7
 	"II$O +CCIIK$>>#//	1  JJ()$22--/+)==&44<<D
 00 ~~"0"F"F
))$22BB-U)U/"9#*99%
 /*8*N*N
))!,!A!A!V!V)- 49,==AA"9
+'%#2#I#I-	$
  "#2MM--/O
 ~~o6688	jj*+&44
- + ? ?(66>> ! !22	  	DNw ## ==$$+
JK8 ## %==$$+
J	
 $% %s0   O0 	Q 0Q3P==QR3RR)rl   N)
__name__
__module____qualname____firstlineno____doc__detailed_helpclassmethodr*   r{   __static_attributes__ r,   r)   r   r   (   s2    #
$
+-Z ,1 ,1\Hr,   r   )r   
__future__r   r   r   rI   googlecloudsdk.api_lib.storager   r   ra   googlecloudsdk.callioper   "googlecloudsdk.command_lib.storager	   r
   r   r   r   r   r   (googlecloudsdk.command_lib.storage.tasksr   r   r   +googlecloudsdk.command_lib.storage.tasks.rmr   googlecloudsdk.corer   UniverseCompatibleCommandr   r   r,   r)   <module>r      sk    ; &  '  4 ? ( 4 : = K > = H B H @ T # g g gr,   