
                             d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddl	mZ dd	lZd
 Zd Zd Zd Zd Zd Zd Zy	)zHHelpers for writing commands interacting with Cloud Dataflow snapshots.
    )absolute_import)division)unicode_literals)arg_parsers)dataflow_util)
properties)	resourcesNc                 V    | j                  ddd       | j                  dddd	       y
)zRegister flags for specifying a single Snapshot ID.

  Args:
    parser: The argparse.ArgParser to configure with snapshot arguments.
  snapshotSNAPSHOT_IDz"ID of the Cloud Dataflow snapshot.)metavarhelp--regionT	REGION_IDz,Region ID of the snapshot regional endpoint.requiredr   r   Nadd_argumentparsers    9lib/googlecloudsdk/command_lib/dataflow/snapshot_utils.pyArgsForSnapshotRefr      sA     	/  1 	9	  ;    c                 X    | j                  dddd       | j                  dddd       y	)
zRegister flags for specifying a single Job ID.

  Args:
    parser: The argparse.ArgParser to configure with job-filtering arguments.
  --job-idTJOB_IDzThe job ID to snapshot.r   r   r   :The region ID of the snapshot and job's regional endpoint.Nr   r   s    r   ArgsForSnapshotJobRefr   0   sE     	$	  &
 	H	  Jr   c                 X    | j                  dddd       | j                  dddd	       y
)zRegister flags for listing Cloud Dataflow snapshots.

  Args:
    parser: The argparse.ArgParser to configure with job-filtering arguments.
  r   Fr   z/The job ID to use to filter the snapshots list.r   r   Tr   r   Nr   r   s    r   ArgsForListSnapshotr    B   sE     	<	  >
 	H	  Jr   c           	      Z    | j                  dddt        j                  dd      d       y	)
z~Register flags for specifying a snapshot ttl.

  Args:
    parser: the argparse.ArgParser to configure with a ttl argument.
  z--snapshot-ttl7dDURATION1h30d)lower_boundupper_boundzTime to live for the snapshot.)defaultr   typer   N)r   r   Durationr   s    r   ArgsForSnapshotTtlr+   T   s3     	DeD+  -r   c                     | j                   }t        j                  |       }t        j                  j                  |t        j                  j                  j                  j                  |dd      S )zExtract the Snapshot Ref for a command. Used with ArgsForSnapshotRef.

  Args:
    args: The command line arguments.
  Returns:
    A Snapshot resource.
  	projectIdlocationz%dataflow.projects.locations.snapshotsparams
collection)r   r   	GetRegionr	   REGISTRYParser   VALUEScoreproject	GetOrFail)argsr   regions      r   ExtractSnapshotRefr<   b   sf     ]](""4(&				!	!!((--55?? 9 
" 
: :r   c                     | j                   }t        j                  |       }t        j                  j                  |t        j                  j                  j                  j                  |dd      S )zExtract the Job Ref for a command. Used with ArgsForSnapshotJobRef.

  Args:
    args: The command line arguments.
  Returns:
    A Job resource.
  r-   z dataflow.projects.locations.jobsr0   )job_idr   r3   r	   r4   r5   r   r6   r7   r8   r9   )r:   jobr;   s      r   ExtractSnapshotJobRefr@   u   sf     	#""4(&				!	!	!((--55?? 4 
" 
5 5r   c                 F    t        j                  | j                        dz   S )zExtract the Duration string for the Snapshot ttl.

  Args:
    args: The command line arguments.
  Returns:
    A duration string for the snapshot ttl.
  s)six	text_typesnapshot_ttl)r:   s    r   ExtractSnapshotTtlDurationrF      s     
t((	)C	//r   )__doc__
__future__r   r   r   googlecloudsdk.callioper   #googlecloudsdk.command_lib.dataflowr   googlecloudsdk.corer   r	   rC   r   r   r    r+   r<   r@   rF    r   r   <module>rM      sI    '  ' / = * ) 
;"J$J$-:&5&0r   