
    `                         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
mZ d
 Zd Zd Zd Zd Zy)zBHelpers for writing commands interacting with jobs and their IDs.
    )absolute_import)division)unicode_literals)actions)arg_parsers)dataflow_util)
properties)	resourcesc                 v    | j                  ddd       | j                  dddt        j                  z          y)	zRegister flags for specifying a single Job ID.

  Args:
    parser: The argparse.ArgParser to configure with job-filtering arguments.
  jobJOB_IDzJob ID to operate on.metavarhelp--region	REGION_IDz*Region ID of the job's regional endpoint. Nadd_argumentr   DEFAULT_REGION_MESSAGE)parsers    4lib/googlecloudsdk/command_lib/dataflow/job_utils.pyArgsForJobRefr      sD     	eX4KL9001  3    c                 z     | j                   	 dddd| | j                  dddt        j                  z          y)	zRegister flags for specifying jobs using positional job IDs.

  Args:
    parser: The argparse.ArgParser to configure with job ID arguments.
    **kwargs: Extra arguments to pass to the add_argument call.
  r   zJob IDs to operate on.r   r   r   z*Region ID of the jobs' regional endpoint. N)jobsr   )r   kwargss     r   ArgsForJobRefsr   ,   sY     &I%=IAGI 	9001  3r   c                     | j                   }t        j                  |       }t        j                  j                  |t        j                  j                  j                  j                  |dd      S )zExtract the Job Ref for a command. Used with ArgsForJobRef.

  Args:
    args: The command line arguments.
  Returns:
    A Job resource.
  	projectIdlocation dataflow.projects.locations.jobsparams
collection)r   r   	GetRegionr
   REGISTRYParser	   VALUEScoreproject	GetOrFail)argsr   regions      r   ExtractJobRefr/   =   sf     	#""4(&				!	!	!((--55?? 4 
" 
5 5r   c           	         | j                   }t        j                  |       }|D cg c]S  }t        j                  j                  |t        j                  j                  j                  j                  |dd      U c}S c c}w )zExtract the Job Refs for a command. Used with ArgsForJobRefs.

  Args:
    args: The command line arguments that were provided to this invocation.
  Returns:
    A list of job resources.
  r   r"   r#   )r   r   r&   r
   r'   r(   r	   r)   r*   r+   r,   )r-   r   r.   r   s       r   ExtractJobRefsr1   P   s     
$""4(& EI
 EIS 
%,,1199CC  8  9 EI
  
s   ABc           
      "   | j                  dd       | j                  dt        j                  t        j                  j
                  j                        d       | j                  dt        d	       | j                  d
d       | j                  dt        d	       | j                  dt        j                  dd      d	       | j                  dd       | j                  dd       | j                  dd      }|j                  dt        j                  dd      d	       |j                  dt        j                  dd      d 	       |j                  d!t        j                  dd      d t        j                  d!d"d#$      %       y&)'zRegister flags applicable to all template launches.

  Args:
    parser: argparse.ArgumentParser to register arguments with.
  z--dataflow-kms-keyz/The Cloud KMS key to protect the job resources.)r   z--disable-public-ipsz<The Cloud Dataflow workers must not use public IP addresses.)actionr   z--max-workersz%The maximum number of workers to run.)typer   z	--networkzHThe Compute Engine network for launching instances to run your pipeline.z--num-workersz%The initial number of workers to use.z--service-account-emailz	.*@.*\..*z"must provide a valid email addressz*The service account to run the workers as.z--subnetworkzKThe Compute Engine subnetwork for launching instances to run your pipeline.z--worker-machine-typezEThe type of machine to use for workers. Defaults to server-specified.TzWorker location options.)mutexr   z--worker-regionz	\w+-\w+\dzmust provide a valid regionz!The region to run the workers in.z--worker-zonez\w+-\w+\d-\wzmust provide a valid zonezThe zone to run the workers in.z--zonezSThe {flag_name} option is deprecated; use --worker-region or --worker-zone instead.F)warnremoved)r4   r   r3   N)r   r   StoreBooleanPropertyr	   r)   dataflowdisable_public_ipsintr   RegexpValidator	add_groupDeprecationAction)r   groups     r   
CommonArgsr@   e   s    	<  > 	))



$
$
7
79I	  K 	C&M  O 	  
 	C&M  O 	&&|'KM7	  9 	  
 	  
 

,F

G%&&|'DF.	  0 &&'BD,	  . &&'BD,&&
@	  	r   N)__doc__
__future__r   r   r   googlecloudsdk.callioper   r   #googlecloudsdk.command_lib.dataflowr   googlecloudsdk.corer	   r
   r   r   r/   r1   r@    r   r   <module>rG      s>    '  ' + / = * )33"5&*Br   