
    [                      `   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SS.r " S S\R0                  5      r " S S\5      r " S S5      r " S S\\5      r " S S\\5      rS rS rS  r S! r!g)"zGeneral utilities for copies.    )absolute_import)division)unicode_literalsN)	cloud_api)errors)manifest_util)storage_url)resource_reference)resource_util)task)
exceptions)log)
properties   Z   im  )nearlinecoldlinearchivec                   >   ^  \ rS rSrSr    SU 4S jjrS rSrU =r$ )CopyTask*   zHParent task that handles common attributes and an __init__ status print.c                   > [         [        U ]  5         Xl        X l        X0l        X@l        XPl        X`l        [        U R                  =(       a    U R                  R                  5      U l        U(       a  U R                  (       a  UR                  R                  nOUR                  R                  n[        R                   R#                  SR%                  UUR                  R                  5      5        gg)aI  Initializes task.

Args:
  source_resource (resource_reference.Resource): Source resource to copy.
  destination_resource (resource_reference.Resource): Target resource to
    copy to.
  print_created_message (bool): Print a message containing the URL of the
    copy result.
  print_source_version (bool): Print source object version in status message
    enabled by the `verbose` kwarg.
  user_request_args (UserRequestArgs|None): Various user-set values
    typically converted to an API-specific RequestConfig.
  verbose (bool): Print a "copying" status message on initialization.
zCopying {} to {}N)superr   __init___source_resource_destination_resource_print_created_message_print_source_version_user_request_args_verboseboolmanifest_path_send_manifest_messagesr	   
url_stringversionless_url_stringr   statusPrintformat)	selfsource_resourcedestination_resourceprint_created_messageprint_source_versionuser_request_argsverbosesource_string	__class__s	           <lib/googlecloudsdk/command_lib/storage/tasks/cp/copy_util.pyr   CopyTask.__init__-   s    . 
(D"$+!5"7!5/M#'ID$;$;$I$I$D  		#	#'33>>'33JJ	jj

#
#"..EE     c                     U R                   (       a/  [        R                  R                  SR	                  U5      5        g g )NzCreated: {})r   r   r&   r'   r(   )r)   resources     r2   #_print_created_message_if_requested,CopyTask._print_created_message_if_requested\   s-    ""	jj}++H56 #r4   )r   r   r   r#   r   r   r    )FFNF)	__name__
__module____qualname____firstlineno____doc__r   r7   __static_attributes____classcell__r1   s   @r2   r   r   *   s$    P " -^7 7r4   r   c                   :   ^  \ rS rSrSr     SU 4S jjrSrU =r$ )ObjectCopyTaska   zAParent task that handles common attributes for object copy tasks.c                 N   > X0l         XPl        [        [        U ]  UUUUUU5        g)a  Initializes task.

Args:
  source_resource (resource_reference.Resource): See parent class.
  destination_resource (resource_reference.Resource): See parent class.
  posix_to_set (PosixAttributes|None): POSIX info set as custom cloud
    metadata on target.
  print_created_message (bool): See parent class.
  print_source_version (bool): See parent class.
  user_request_args (UserRequestArgs|None): See parent class.
  verbose (bool): Print a "copying" status message on initialization.
N)_posix_to_setr   r   rB   r   )	r)   r*   r+   posix_to_setr,   r-   r.   r/   r1   s	           r2   r   ObjectCopyTask.__init__d   s4    , & "6	.$(r4   )rE   r   )NFFNF)r9   r:   r;   r<   r=   r   r>   r?   r@   s   @r2   rB   rB   a   s!    I ! " "r4   rB   c                   "    \ rS rSrSrSS jrSrg)_ExitHandlerMixin   z(Provides an exit handler for copy tasks.Nc                     U(       au  U R                   (       ac  U(       d/  [        R                  " SR                  U R                  5      5      e[
        R                  " X R                  U R                  U5        ggg)z/Send copy result info to manifest if requested.z1Unable to send message to manifest for source: {}N)r#   command_errorsErrorr(   r   r   send_error_messager   )r)   errortask_status_queues      r2   exit_handler_ExitHandlerMixin.exit_handler   sf    --""?FF%%
 	

 &&'8:O:O'+'A'A5J .ur4    )NN)r9   r:   r;   r<   r=   rQ   r>   rS   r4   r2   rI   rI      s    0
Jr4   rI   c                       \ rS rSrSrSrg)CopyTaskWithExitHandler   z;Parent task with an exit handler for non-object copy tasks.rS   Nr9   r:   r;   r<   r=   r>   rS   r4   r2   rU   rU      s     Dr4   rU   c                       \ rS rSrSrSrg)ObjectCopyTaskWithExitHandler   z7Parent task with an exit handler for object copy tasks.rS   NrW   rS   r4   r2   rY   rY      s    ?r4   rY   c                 $    SR                  U 5      $ )z(Returns standardized no clobber warning.z3Skipping existing destination item (no-clobber): {})r(   )destination_urls    r2   get_no_clobber_messager]      s    	>	E	E
 r4   c                    U (       a  U R                   (       d  g UR                  UR                  R                  UR                  R                  [
        R                  R                  S9  g! [        R                   a     gf = f)zAReturns if cloud destination object exists if no-clobber enabled.F)fields_scopeT)

no_clobberget_object_metadatar	   bucket_nameresource_namer   FieldsScopeSHORT
api_errorsNotFoundError)r.   
api_clientr+   s      r2   check_for_cloud_clobberri      sw      1 < <""((44((66**00 # 2 
 
	!	! s   AA- -BBc                 Z    U R                   b  U R                   $ U R                  (       a  gg)z=Prioritizes user-input generation over no-clobber zero value.Nr   )precondition_generation_matchr`   )request_configs    r2   get_generation_match_valuerm      s)    11=777	r4   c                    [        U [        R                  5      (       a  g[        R                  R
                  R                  R                  5       (       aV  U R                  R                  [        R                  R                  L a%  U R                  (       a  U R                  [        ;   d  g[        U R                  R                  5          n[         R"                  " U R                  5      n[         R"                  " [$        R$                  R'                  5       5      nX2[$        R(                  " US9-   :  a;  [*        R,                  " SR/                  X R                  U R                  U5      5      eg)zGRaises error if Google Cloud Storage object will incur an extra charge.N)daysaF  Deleting {} may incur an early deletion charge. Note: the source object of a mv operation is deleted.
The object appears to have been created on {}, and the minimum time before deletion for the {} storage class is {} days.
To allow deleting the object anyways, run "gcloud config set storage/check_mv_early_deletion_fee False")
isinstancer
   FolderResourcer   VALUESstoragecheck_mv_early_deletion_feeGetBoolr	   schemeProviderPrefixGCScreation_timestorage_class_EARLY_DELETION_MINIMUM_DAYSlowerr   convert_datetime_object_to_utcdatetimenow	timedeltar   rM   r(   )object_resourceminimum_lifetimecreation_datetime_utccurrent_datetime_utcs       r2   &raise_if_mv_early_deletion_fee_appliesr      s/   !3!B!BCC




#
#
?
?
G
G
I
I

%
%
,
,0J0J0N0N
N++

'
'+G
G
1##))+-'FF##%&EE H4F4F5  



J
 &"?"? ..0@BC Cr4   )"r=   
__future__r   r   r   r~   googlecloudsdk.api_lib.storager   r   rf   "googlecloudsdk.command_lib.storagerL   r   r	   ,googlecloudsdk.command_lib.storage.resourcesr
   r   (googlecloudsdk.command_lib.storage.tasksr   googlecloudsdk.corer   r   r   r{   Taskr   rB   rI   rU   rY   r]   ri   rm   r   rS   r4   r2   <module>r      s    $ &  '  4 ? G < : K F 9 * # *   47tyy 47n%X %PJ J D 	D@$5~ @Cr4   