
    P                         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\R                   5      rg)z#Task for composing storage objects.    )absolute_import)division)unicode_literals)api_factory)	cloud_api)request_config_factory)errors)task)logc                   H   ^  \ rS rSrSr    SU 4S jjrSS jrS rSrU =r	$ )	ComposeObjectsTask   zComposes storage objects.c                 r   > [         [        U ]  5         Xl        X l        X0l        X@l        XPl        X`l        g)am  Initializes task.

Args:
  source_resources (list[ObjectResource|UnknownResource]): The objects to
    compose. This field accepts UnknownResources since it should allow
    ComposeObjectsTasks to be initialized before the target objects have
    been created.
  destination_resource (resource_reference.UnknownResource): Metadata for
    the resulting composite object.
  original_source_resource (Resource|None): Useful for finding metadata to
    apply to final object. For instance, if doing a composite upload, this
    would represent the pre-split local file.
  posix_to_set (PosixAttributes|None): POSIX info set as custom cloud
    metadata on target. If preserving POSIX, avoids re-parsing metadata from
    file system.
  print_status_message (bool): If True, the task prints the status message.
  user_request_args (UserRequestArgs|None): Values for RequestConfig.
N)	superr   __init___source_resources_destination_resource_original_source_resource_posix_to_set_print_status_message_user_request_args)selfsource_resourcesdestination_resourceoriginal_source_resourceposix_to_setprint_status_messageuser_request_args	__class__s          Dlib/googlecloudsdk/command_lib/storage/tasks/compose_objects_task.pyr   ComposeObjectsTask.__init__!   s7    6 

d,.-!5%="%!5/    c                    AU R                   R                  R                  n[        R                  " U5      n[
        R                  R                  UR                  ;  a%  [        R                  " SR                  U5      5      eU R                   HQ  nUR                  R                  U R                   R                  R                  :w  d  M=  [        R                  " S5      e   [        R                  " U R                   R                  U R                   S9nU R"                  (       aL  [$        R&                  R)                  SR                  U R                   [+        U R                  5      5      5        UR-                  U R                  U R                   UU R.                  U R0                  S9n[2        R4                  " [2        R6                  " [2        R8                  R:                  US9// S9$ )Nz4Compose is not available with requested provider: {}z$Inter-bucket composing not supported)r   z*Composing {} from {} component object(s).
)r   r   )topicpayload)messagesadditional_task_iterators)r   storage_urlschemer   get_apir   
CapabilityCOMPOSE_OBJECTScapabilitiescommand_errorsErrorformatr   bucket_namer   get_request_configr   r   r   statuswritelencompose_objectsr   r   r
   OutputMessageTopicCREATED_RESOURCE)r   task_status_queueproviderapisource_resourcerequest_configcreated_resources          r    executeComposeObjectsTask.executeD   s   ))55<<H


h
'C++33C3CC  
@
G
G   11		$	$	0	0D4N4N4Z4Z4f4f	f""24 	4 2 ,>>""..113N !!	jjDKK

$
$c$*@*@&AC D **""!%!?!?'' +  ;;LLjj11;KM
 #%& &r"   c                     [        U[        5      (       d  [        $ U R                  UR                  :H  =(       a9    U R                  UR                  :H  =(       a    U R
                  UR
                  :H  $ N)
isinstancer   NotImplementedr   r   r   )r   others     r    __eq__ComposeObjectsTask.__eq__g   sd    e/00""e&=&== @&&%*E*EE@##u'?'??Ar"   )r   r   r   r   r   r   )NNFNrD   )
__name__
__module____qualname____firstlineno____doc__r   rA   rH   __static_attributes____classcell__)r   s   @r    r   r      s,    !  $ !0F!&FA Ar"   r   N)rN   
__future__r   r   r   googlecloudsdk.api_lib.storager   r   r   "googlecloudsdk.command_lib.storager	   r.   (googlecloudsdk.command_lib.storage.tasksr
   googlecloudsdk.corer   Taskr    r"   r    <module>rX      s;    * &  ' 7 4 A G 9 #NA NAr"   