
    p                     B   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rSr	S	R                  \\	5      rS
R                  \5      r " S S\R                  5      r " S S\R                  5      r " S S\R                  5      r " S S\R                  5      r " S S\R                  5      r " S S\R                  5      r " S S\R                  5      r " S S\R                  5      r " S S\R                  5      r " S S\R                  5      rS rS!S  jrg)"z[Utils for managng the many transfer job flags.

Tested more through command surface tests.
    )absolute_import)division)unicode_literalsN)arg_parsersai  POSIX filesystem - Specify the `posix://` scheme followed by the absolute path to the desired directory, starting from the root of the host machine (denoted by a leading slash). For example:
* posix:///path/directory/

A file transfer agent must be installed on the POSIX filesystem, and you need an agent pool flag on this `jobs` command to activate the agent.a  Hadoop Distributed File System (HDFS) - Specify the `hdfs://` scheme followed by the absolute path to the desired directory, starting from the root of the file system (denoted by a leading slash). For example:
* hdfs:///path/directory/

Namenode details should not be included in the path specification, as they are required separately during the agent installation process.

A file transfer agent must be installed, and you need an agent pool flag on this `jobs` command to activate the agent.a  The source of your data. Available sources and formatting information:

Public clouds -
* [Google Cloud Storage] gs://example-bucket/example-folder/
* [Amazon S3] s3://examplebucket/example-folder
* [Azure Blob Storage or Data Lake Storage] http://examplestorageaccount.blob.core.windows.net/examplecontainer/examplefolder

{}

{}

Publicly-accessible objects - Specify the URL of a TSV file containing a list of URLs of publicly-accessible objects. For example:
* http://example.com/tsvfilea  The destination of your transferred data. Available destinations and  formatting information:

Google Cloud Storage - Specify the `gs://` scheme; name of the bucket; and, if transferring to a folder, the path to the folder. For example:
* gs://example-bucket/example-folder/

{}c                       \ rS rSrSrSrSrg)
AuthMethodB   AWS_SIGNATURE_V2AWS_SIGNATURE_V4 N)__name__
__module____qualname____firstlineno__r
   r   __static_attributes__r       9lib/googlecloudsdk/command_lib/transfer/jobs_flag_util.pyr   r   B   s    ''r   r   c                       \ rS rSrSrSrSrg)DeleteOptionG   zdestination-if-uniquezsource-after-transferr   N)r   r   r   r   DESTINATION_IF_UNIQUESOURCE_AFTER_TRANSFERr   r   r   r   r   r   G   s    11r   r   c                        \ rS rSrSrSrSrSrg)	JobStatusL   deleteddisabledenabledr   N)r   r   r   r   DELETEDDISABLEDENABLEDr   r   r   r   r   r   L   s    '('r   r   c                        \ rS rSrSrSrSrSrg)	LogActionR   copydeletefindr   N)r   r   r   r   COPYDELETEFINDr   r   r   r   r#   r#   R   s    	$&	$r   r#   c                        \ rS rSrSrSrSrSrg)LogActionStateX   failed	succeededskippedr   N)r   r   r   r   FAILED	SUCCEEDEDSKIPPEDr   r   r   r   r,   r,   X   s    &)'r   r,   c                   8    \ rS rSrSrSrSrSrSrSr	Sr
S	rS
rSrg)PreserveMetadataField^   aclgidzkms-keymodezstorage-classsymlinkztemporary-holdztime-createduidr   N)r   r   r   r   ACLGIDKMS_KEYMODESTORAGE_CLASSSYMLINKTEMPORARY_HOLDTIME_CREATEDUIDr   r   r   r   r5   r5   ^   s/    ##'	$!-'#.,#r   r5   c                       \ rS rSrSrSrSrg)ListApij   LIST_OBJECTSLIST_OBJECTS_V2r   N)r   r   r   r   rH   rI   r   r   r   r   rF   rF   j   s    ,%/r   rF   c                       \ rS rSrSrSrSrg)NetworkProtocolo   HTTPHTTPSr   N)r   r   r   r   rM   rN   r   r   r   r   rK   rK   o   s    	$
%r   rK   c                        \ rS rSrSrSrSrSrg)OverwriteOptiont   always	differentneverr   N)r   r   r   r   ALWAYS	DIFFERENTNEVERr   r   r   r   rP   rP   t   s    &)
%r   rP   c                       \ rS rSrSrSrSrg)RequestModelz   
PATH_STYLEVIRTUAL_HOSTED_STYLEr   N)r   r   r   r   r[   r\   r   r   r   r   rY   rY   z   s    */r   rY   c                 $    U R                  SSS9  g )Nz--source-creds-filea^  Path to a local file on your machine that includes credentials for an Amazon S3 or Azure Blob Storage source (not required for Google Cloud Storage sources). If not specified for an S3 source, gcloud will check your system for an AWS config file. However, this flag must be specified to use AWS's "role_arn" auth service. For formatting, see:

S3: https://cloud.google.com/storage-transfer/docs/reference/rest/v1/TransferSpec#AwsAccessKey
Note: Be sure to put quotations around the JSON value strings.

Azure: https://cloud.google.com/storage-transfer/docs/reference/rest/v1/TransferSpec#AzureCredentials

help)add_argument)parsers    r   add_source_creds_flagrb      s    
-  .r   c           	      T   AU R                  S5        U(       a  U R                  SSS9  O(U R                  S[        S9  U R                  S[        S9  U R	                  SSS9nU(       a  UR                  S	[        S
 [         5       5      SS9  UR                  S[        S9  UR                  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  UR                  SSSS9  OUR                  SSS9  UR                  SS S9  [        U5        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(       d   U R	                  S)S9nUR                  S*SS+S9  U R	                  S,SS9nUR                  S-S.S9  UR                  S/S0S9  UR                  S1S2S9  U(       a  UR                  S3SS4S9  U R	                  S5SS9nU(       a  UR                  S6SS7S9  OUR                  S8SS9S9  UR                  S:[        R                  R                  S;S<9  UR                  S=[        R                  " 5       S>S<9  UR                  S?[        R                  R                  S@S<9  U R	                  SASS9nU(       af  UR                  SBSSCS9  UR                  SDSSES9  UR                  SFSSGS9  UR                  SHSSIS9  UR                  SJSSKS9  UR                  SLSSMS9  UR                  SN[        R                  " 5       SOSPSQ9  UR                  SR[        R                  " 5       SSSTSQ9  UR                  SU[        R                  R                  SVS<9  UR                  SW[        R                  R                  SXS<9  UR                  SY[        R                  " 5       SZS<9  UR                  S[[        R                  " 5       S\S<9  U R	                  S]SS9nU(       a3  UR                  S^SS_S9  UR                  S`SSaS9  UR                  SbSScS9  UR                  Sd[        Se [         5       5      SfS9  UR                  Sg[        Sh [         5       5      SiS9  UR                  Sj[        R                  " [        Sk [         5       5      Sl9SmSnSQ9  UR                  SoSpS9  U R	                  SqSS9n	U(       a"  U	R                  SrSSsS9  U	R                  StSSuS9  U	R                  SvSwS9  U	R                  Sx[        R                  " / SyQSl9SzS{SQ9  U	R                  S|S}S~/SS9  U R	                  SSS9n
U(       a  U
R                  SSSS9  U
R                  S[        R                   SS9  U
R                  S[        R                  " [        S ["         5       5      Sl9SSSQ9  U
R                  S[        R                  " [        S [$         5       5      Sl9SSSQ9  U R	                  SSS9nUR                  SSS9  UR                  SSS9  UR                  S[        S [&         5       5      SS9  UR                  S[        S [(         5       5      SS9  UR                  S[        S [*         5       5      SS9  UR                  S[        S [,         5       5      SS9  UR                  SSS9  U(       aw  UR                  SSSS9  UR                  SSSS9  UR                  SSSS9  UR                  SSSS9  UR                  SSSS9  UR                  SSSS9  UR                  SSSS9  U(       d"  U R	                  SSS9nUR                  SSSS9  gg)z1Adds flags to job create and job update commands.Fnamez.Name of the transfer job you'd like to update.r^   sourcedestinationzJOB INFORMATION)r_   	sort_argsz--statusc              3   8   #    U  H  oR                   v   M     g 7fNvalue).0statuss     r   	<genexpr>setup_parser.<locals>.<genexpr>   s     <)||)   zdSpecify this flag to change the status of the job. Options include 'enabled', 'disabled', 'deleted'.)choicesr_   z--sourcez--destinationz--clear-description
store_truez-Remove the description from the transfer job.)actionr_   z--clear-source-creds-filez3Remove the source creds file from the transfer job.z--clear-source-agent-poolz3Remove the source agent pool from the transfer job.z--clear-destination-agent-poolz8Remove the destination agent pool from the transfer job.z!--clear-intermediate-storage-pathz;Remove the intermediate storage path from the transfer job.z--clear-manifest-filez/Remove the manifest file from the transfer job.z--namezA unique identifier for the job. Referring to your source and destination is recommended. If left blank, the name is auto-generated upon submission of the job.z--descriptionzZAn optional description to help identify the job using details that don't fit in its name.z--source-agent-poolzgIf using a POSIX filesystem source, specify the ID of the agent pool associated with source filesystem.z--destination-agent-poolzqIf using a POSIX filesystem destination, specify the ID of the agent pool associated with destination filesystem.z--intermediate-storage-pathaA  If transferring between filesystems, specify the path to a folder in a Google Cloud Storage bucket (gs://example-bucket/example-folder) to use as intermediary storage. Recommended: Use an empty folder reserved for this transfer job to ensure transferred data doesn't interact with any of your existing Cloud Storage data.z--manifest-filea  Path to a .csv file containing a list of files to transfer from your source. For manifest files in Cloud Storage, specify the absolute path (e.g., `gs://mybucket/manifest.csv`). For manifest files stored in a source or destination POSIX file system, provide the relative path (e.g., `source://path/to/manfest.csv` or `destination://path/to/manifest.csv`). For manifest file formatting, see https://cloud.google.com/storage-transfer/docs/manifest.zREPLICATION OPTIONSz--replicationzEnable replication to automatically copy all new and existing objects from the source to the destination. Note: Objects deleted from the source bucket will not be deleted from the destination bucket. Please note that it is an event-driven transfer.ah  EVENT STREAM

Configure an event stream to transfer data whenever it is added or changed at your source, enabling you to act on the data in near real time. This event-driven transfer execution mode is available for transfers from Google Cloud Storage and Amazon S3. For formatting information, see https://cloud.google.com/sdk/gcloud/reference/topic/datetimes.z--event-stream-namea  Specify an event stream that Storage Transfer Service can use to listen for when objects are created or updated. For Google Cloud Storage sources, specify a Cloud Pub/Sub subscription, using format "projects/yourproject/subscriptions/yoursubscription". For Amazon S3 sources, specify the Amazon Resource Name (ARN) of an Amazon Simple Queue Service (SQS) queue using format "arn:aws:sqs:region:account_id:queue_name".z--event-stream-startszSet when to start listening for events UTC using the %Y-%m-%dT%H:%M:%S%z datetime format (e.g., 2020-04-12T06:42:12+04:00). If not set, the job will start running and listening for events upon the successful submission of the create job command.z--event-stream-expireszSet when to stop listening for events UTC using the %Y-%m-%dT%H:%M:%S%z datetime format (e.g., 2020-04-12T06:42:12+04:00). If not set, the job will continue running and listening for events indefinitely.z--clear-event-streamzRemove the job's entire event stream configuration by clearing all scheduling all event stream flags. The job will no longer listen for events unless a new configuratin is specified.zSCHEDULE

A job's schedule determines when and how often the job will run. For formatting information, see https://cloud.google.com/sdk/gcloud/reference/topic/datetimes.z--clear-schedulezRemove the job's entire schedule by clearing all scheduling flags. The job will no longer run unless an operation is manually started or a new schedule is specified.z--do-not-runzDisable default Transfer Service behavior of running job upon creation if no schedule is set. If this flag is specified, the job won't run until an operation is manually started or a schedule is added.z--schedule-startszSet when the job will start using the %Y-%m-%dT%H:%M:%S%z datetime format (e.g., 2020-04-12T06:42:12+04:00). If not set, the job will run upon the successful submission of the create job command unless the --do-not-run flag is included.)typer_   z--schedule-repeats-everyzSet the frequency of the job using the absolute duration format (e.g., 1 month is p1m; 1 hour 30 minutes is 1h30m). If not set, the job will run once.z--schedule-repeats-untilab  Set when the job will stop recurring using the %Y-%m-%dT%H:%M:%S%z datetime format (e.g., 2020-04-12T06:42:12+04:00). If specified, you must also include a value for the --schedule-repeats-every flag. If not specified, the job will continue to repeat as specified in its repeat-every field unless the job is manually disabled or you add this field later.a  OBJECT CONDITIONS

A set of conditions to determine which objects are transferred. For time-based object condition formatting tips, see https://cloud.google.com/sdk/gcloud/reference/topic/datetimes. Note: If you specify multiple conditions, objects must have at least one of the specified 'include' prefixes and all of the specified time conditions. If an object has an 'exclude' prefix, it will be excluded even if it matches other conditions.z--clear-include-prefixeszIRemove the list of object prefixes to include from the object conditions.z--clear-exclude-prefixeszIRemove the list of object prefixes to exclude from the object conditions.z(--clear-include-modified-before-absolutezDRemove the maximum modification datetime from the object conditions.z'--clear-include-modified-after-absolutezDRemove the minimum modification datetime from the object conditions.z(--clear-include-modified-before-relativezJRemove the maximum duration since modification from the object conditions.z'--clear-include-modified-after-relativezJRemove the minimum duration since modification from the object conditions.z--include-prefixesINCLUDED_PREFIXESzInclude only objects that start with the specified prefix(es). Separate multiple prefixes with commas, omitting spaces after the commas (e.g., --include-prefixes=foo,bar).)rt   metavarr_   z--exclude-prefixesEXCLUDED_PREFIXESzExclude any objects that start with the prefix(es) entered. Separate multiple prefixes with commas, omitting spaces after the commas (e.g., --exclude-prefixes=foo,bar).z"--include-modified-before-absolutezInclude objects last modified before an absolute date/time. Ex. by specifying '2020-01-01', the transfer would include objects last modified before January 1, 2020. Use the %Y-%m-%dT%H:%M:%S%z datetime format.z!--include-modified-after-absolutezInclude objects last modified after an absolute date/time. Ex. by specifying '2020-01-01', the transfer would include objects last modified after January 1, 2020. Use the %Y-%m-%dT%H:%M:%S%z datetime format.z"--include-modified-before-relativea"  Include objects that were modified before a relative date/time in the past. Ex. by specifying a duration of '10d', the transfer would include objects last modified *more than* 10 days before its start time. Use the absolute duration format (ex. 1m for 1 month; 1h30m for 1 hour 30 minutes).z!--include-modified-after-relativea!  Include objects that were modified after a relative date/time in the past. Ex. by specifying a duration of '10d', the transfer would include objects last modified *less than* 10 days before its start time. Use the absolute duration format (ex. 1m for 1 month; 1h30m for 1 hour 30 minutes).zTRANSFER OPTIONSz--clear-delete-fromzRemove a specified deletion option from the transfer job. If  this flag is specified, the transfer job won't delete any data from your source or destination.z--clear-preserve-metadatazGSkips preserving optional metadata fields of objects being transferred.z--clear-custom-storage-classz3Reverts to using destination default storage class.z--overwrite-whenc              3   8   #    U  H  oR                   v   M     g 7fri   rj   rl   options     r   rn   ro          @f\\rp   a  Determine when destination objects are overwritten by source objects. Options include:
 - 'different' - Overwrites files with the same name if the contents are different (e.g., if etags or checksums don't match)
 - 'always' - Overwrite destination file whenever source file has the same name -- even if they're identical
 - 'never' - Never overwrite destination file when source file has the same namez--delete-fromc              3   8   #    U  H  oR                   v   M     g 7fri   rj   ry   s     r   rn   ro          =f\\rp   a  By default, transfer jobs won't delete any data from your source or destination. These options enable you to delete data if needed for your use case. Options include:
 - 'destination-if-unique' - Delete files from destination if they're not also at source. Use to sync destination to source (i.e., make destination match source exactly)
 - 'source-after-transfer' - Delete files from source after they're transferredz--preserve-metadatac              3   8   #    U  H  oR                   v   M     g 7fri   rj   )rl   fields     r   rn   ro     s     H2G2Grp   )rq   METADATA_FIELDSzSpecify object metadata values that can optionally be preserved. Example: --preserve-metadata=storage-class,uid

For more info, see: https://cloud.google.com/storage-transfer/docs/metadata-preservation

z--custom-storage-classa  Specifies the storage class to set on objects being transferred to Cloud Storage buckets. If unspecified, the objects' storage class is set to the destination bucket default. Valid values are:

 - Any of the values listed in the Cloud Storage documentation:   [Available storage classes](https://cloud.google.com/storage/docs/storage-classes#classes).
 - `preserve` - Preserves each object's original storage class. Only   supported for transfers between Cloud Storage buckets.
 
Custom storage class settings are ignored if the destination bucket is [Autoclass-enabled](https://cloud.google.com/storage/docs/autoclass). Objects transferred into Autoclass-enabled buckets are initially set to the `STANDARD` storage class.zwNOTIFICATION CONFIG

A configuration for receiving notifications oftransfer operation status changes via Cloud Pub/Sub.z--clear-notification-configzfRemove the job's full notification configuration to no longer receive notifications via Cloud Pub/Sub.z --clear-notification-event-typesz4Remove the event types from the notification config.z--notification-pubsub-topicz%Pub/Sub topic used for notifications.z--notification-event-types)successr.   abortedEVENT_TYPESa-  Define which change of transfer operation status will trigger Pub/Sub notifications. Choices include 'success', 'failed', 'aborted'. To trigger notifications for all three status changes, you can leave this flag unspecified as long as you've specified a topic for the --notification-pubsub-topic flag.z--notification-payload-formatjsonnonezIf 'none', no transfer operation details are included with notifications. If 'json', a json representation of the relevant transfer operation is included in notification messages (e.g., to see errors after an operation fails).zLOGGING 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=storage_transfer_job"z--clear-log-configz%Remove the job's full logging config.z--enable-posix-transfer-logszSets whether to generate logs for transfers with a POSIX filesystem source. This setting will later be merged with other log configurations.z--log-actionsc              3   8   #    U  H  oR                   v   M     g 7fri   rj   ry   s     r   rn   ro     s     >I&Irp   LOG_ACTIONSzDefine the transfer operation actions to report in logs. Separate multiple actions with commas, omitting spaces after the commas (e.g., --log-actions=find,copy).z--log-action-statesc              3   8   #    U  H  oR                   v   M     g 7fri   rj   ry   s     r   rn   ro     s     CN&Nrp   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).zADDITIONAL OPTIONSz--source-endpointzFor transfers from S3-compatible sources, specify your storage system's endpoint. Check with your provider for formatting (ex. s3.us-east-1.amazonaws.com for Amazon S3).z--source-signing-regionzFor transfers from S3-compatible sources, specify a region for signing requests. You can leave this unspecified if your storage provider doesn't require a signing region.z--source-auth-methodc              3   8   #    U  H  oR                   v   M     g 7fri   rj   ry   s     r   rn   ro   ,  s     ;
f\\
rp   aI  For transfers from S3-compatible sources, choose a process for adding authentication information to S3 API requests. Refer to AWS's SigV4 (https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html) and SigV2 (https://docs.aws.amazon.com/general/latest/gr/signature-version-2.html) documentation for more information.z--source-list-apic              3   8   #    U  H  oR                   v   M     g 7fri   rj   ry   s     r   rn   ro   4  s     8f\\rp   aZ  For transfers from S3-compatible sources, choose the version of the S3 listing API for returning objects from the bucket. Refer to AWS's ListObjectsV2 (https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html) and ListObjects (https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjects.html) documentation for more information.z--source-network-protocolc              3   8   #    U  H  oR                   v   M     g 7fri   rj   ry   s     r   rn   ro   =  r{   rp   zeFor transfers from S3-compatible sources, choose the network protocol agents should use for this job.z--source-request-modelc              3   8   #    U  H  oR                   v   M     g 7fri   rj   ry   s     r   rn   ro   B  r}   rp   a<  For transfers from S3-compatible sources, choose which addressing style to use. Determines if the bucket name is in the hostname or part of the URL. For example, https://s3.region.amazonaws.com/bucket-name/key-name for path style and Ex. https://bucket-name.s3.region.amazonaws.com/key-name for virtual-hosted style.z--s3-cloudfront-domaina  For transfers from S3, optionally route egress traffic through a CloudFront instance. Supply the endpoint of the CloudFront instance: https://example.cloudfront.net. See documentation (https://cloud.google.com/storage-transfer/docs/s3-cloudfront) for more information.z--clear-source-endpointzRemoves source endpoint.z--clear-source-signing-regionzRemoves source signing region.z--clear-source-auth-methodzRemoves source auth method.z--clear-source-list-apizRemoves source list API.z--clear-source-network-protocolz Removes source network protocol.z--clear-source-request-modelzRemoves source request model.z--clear-s3-cloudfront-domainzRemoves S3 CloudFront domain.zEXECUTION OPTIONSz
--no-asynczFor jobs set to run upon creation, this flag blocks other tasks in your terminal until the job's initial, immediate transfer operation has completed. If not included, tasks will run asynchronously.N)SetSortArgsr`   _SOURCE_HELP_TEXT_DESTINATION_HELP_TEXT	add_groupsortedr   rb   r   DatetimeParseDurationArgListrP   r   r5   StoreTrueFalseActionr#   r,   r   rF   rK   rY   )ra   	is_updaterelease_trackjob_informationreplication_groupevent_streamscheduleobject_conditionstransfer_optionsnotification_configlogging_configadditional_optionsexecution_optionss                r   setup_parserr      s
    U
E  G '89
,BC$$*;u$M/  <)<<5 ! 6
   2C D  7M N  < ! >   #B ! D   #B ! D   (G ! I   +J ! L   > ! @
   6 ! 7
 %  &
 (1  2  <  = #@  A F  G 
((.C(D""	 # 
 !!N  " , ;  = *  , >  @ >	  @ N 	  (
 B  D    %%?  @  !)  *  %%J  K &&C  ' 	 """ # 
 """ # 
 ""2 # 
 ""1 # 
 ""2 # 
 ""1 # 
    !8	 ! 9    !8	 ! 9   *%%. ! /   )%%. ! /   *!. ! /   )!. ! / %%+=%O!!' " ( !!# " 
 !!&B " D
 @@@   
 ===   
 H2GHHJ"   # .   /  ((A	 ) 
 $$%; % <
 $$*C % E ""#2 # 4 """'GH;	 # < ""%v/ # 0 ##G  $ . 4   6 $--   >I>>@*  + CNCCE!A  B ''5 ( 2!!4 " 5
 !!4 " 5
 !!;
;;F " G !!888 "  !!!@@@2 " 3
 !!===9 " : !!# " 	 ##!' $ ) ##'- $ / ##$* $ , ##!' $ ) ##)/ $ 1 ##&, $ . ##&, $  
(( E ) 3"" #  
r   )FN)__doc__
__future__r   r   r   enumgooglecloudsdk.callioper   &_POSIX_SOURCE_OR_DESTINATION_HELP_TEXT_HDFS_SOURCE_HELP_TEXTformatr   r   Enumr   r   r   r#   r,   r5   rF   rK   rP   rY   rb   r   r   r   r   <module>r      s  
 '  '  /M '5 
# 	&	/1GH 	 	&	/0 ( (
2499 2
		 		 TYY 	DII 	&dii &
dii 
dii 0499 0
. kr   