
    I                         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rSr	\	4S jr
\	4S	 jrS
 rS r " S S\5      r " S S\5      rg)zData Pipelines API utilities.    )
list_pager)apis)
properties)	resourcesNv1c                 0    [         R                  " SU 5      $ Ndatapipelines)r   GetMessagesModuleapi_versions    0lib/googlecloudsdk/api_lib/datapipelines/util.pyr   r          				==    c                 0    [         R                  " SU 5      $ r	   )r   GetClientInstancer   s    r   r   r      r   r   c                 r    [         R                  R                  U R                  SS9nUR	                  5       $ )Nzdatapipelines.pipelines
collectionr   REGISTRYParseRelativeNamenameSelfLink)resourcepipelines     r   GetPipelineURIr   #   s6    11mm 9 2 ;(				r   c                 r    [         R                  R                  U R                  SS9nUR	                  5       $ )Nzdatapipelines.pipelines.jobsr   r   )r   jobs     r   	GetJobURIr    )   s4    ,,mm > 	- 	@#	r   c                   h    \ rS rSrSrSS jrS rS rS rS r	SS	 jr
S
 rS rS rS rS rS rSrg)PipelinesClient/   z0Client for Pipelines for the Data Pipelines API.Nc                     U=(       d
    [        5       U l        U=(       d
    [        5       U l        U R                  R                  U l        g N)r   clientr   messagesprojects_locations_pipelines_serviceselfr&   r'   s      r   __init__PipelinesClient.__init__2   s3    /-/DK3 1 3DMKK<<DMr   c                 j    U R                   R                  US9nU R                  R                  U5      $ )zDescribe a Pipeline in the given project and region.

Args:
  pipeline: str, the name for the Pipeline being described.

Returns:
  Described Pipeline Resource.
r   )r'   1DatapipelinesProjectsLocationsPipelinesGetRequestr)   Get)r+   r   describe_reqs      r   DescribePipelinesClient.Describe7   s6     ==RR S L==\**r   c                 j    U R                   R                  US9nU R                  R                  U5      $ )zDelete a Pipeline in the given project and region.

Args:
  pipeline: str, the name for the Pipeline being described.

Returns:
  Empty Response.
r/   )r'   4DatapipelinesProjectsLocationsPipelinesDeleteRequestr)   Delete)r+   r   
delete_reqs      r   r7   PipelinesClient.DeleteD   s6     SS T J==
++r   c                 j    U R                   R                  US9nU R                  R                  U5      $ )zStop a Pipeline in the given project and region.

Args:
  pipeline: str, the name for the Pipeline being described.

Returns:
  Pipeline resource.
r/   )r'   2DatapipelinesProjectsLocationsPipelinesStopRequestr)   Stopr+   r   stop_reqs      r   r<   PipelinesClient.StopQ   s6     }}OO P H==h''r   c                 j    U R                   R                  US9nU R                  R                  U5      $ )zRun a Pipeline in the given project and region.

Args:
  pipeline: str, the name for the Pipeline being described.

Returns:
  Job resource which was created.
r/   )r'   1DatapipelinesProjectsLocationsPipelinesRunRequestr)   Runr=   s      r   rB   PipelinesClient.Run^   s6     }}NN O H==X&&r   c           
          U R                   R                  X4S9n[        R                  " U R                  R
                  USSUUSS9$ )a  List Pipelines for the given project and region.

Args:
  limit: int or None, the total number of results to return.
  page_size: int, the number of entries in each batch (affects requests
    made, but not the yielded results).
  input_filter: string, optional filter to pass, eg:
    "type:BATCH,status:ALL", to filter out the pipelines based on staus or
    type.
  region: string, relative name to the region.

Returns:
  Generator of matching devices.
)filterparent	pipelinesListpageSizefieldmethod
batch_sizelimitbatch_size_attribute)r'   2DatapipelinesProjectsLocationsPipelinesListRequestr   YieldFromListr&   r(   )r+   rN   	page_sizeinput_filterregionlist_reqs         r   rH   PipelinesClient.Listk   sS     }}OO P ,H##00') )r   c                 P   UR                   n[        R                  R                  R                  R                  SS9nU R                  UR                  U R                  R                  R                  5      nU R                  UR                  U R                  R                  R                  5      nSnU(       a#  U R                  R                  R                  US9nU R                  R                  R                  R                  nUR                   (       a  UOSnU R                  UR"                  U R                  R                  R$                  5      n	Sn
U	(       a#  U R                  R                  R%                  U	S9n
U R                  R                  U R                  R                  UR&                  UR(                  UR*                  UR,                  UR.                  UR0                  UR2                  UR4                  UUR6                  UR8                  UR:                  UR<                  (       a  UR<                  O/ U
S9UR>                  U(       a#  U R                  R                  R                  US9OSUS9nU R                  RA                  URB                  UUUS9$ )zCreate a Legacy Template request for the Pipeline workload.

Args:
  args: Any, list of args needed to create a Pipeline.

Returns:
  Legacy Template request.
TrequiredNadditionalProperties)serviceAccountEmail
maxWorkers
numWorkersnetwork
subnetworkmachineTypetempLocation
kmsKeyNameipConfigurationworkerRegion
workerZoneenableStreamingEngineadditionalExperimentsadditionalUserLabels)environmentupdate
parameterstransformNameMapping)gcsPathlocation	projectIdlaunchParameters)"rT   r   VALUEScoreprojectr1   ConvertDictArgumentsrl   r'   2GoogleCloudDatapipelinesV1LaunchTemplateParametersParametersValuetransform_name_mappingsTransformNameMappingValue,GoogleCloudDatapipelinesV1RuntimeEnvironmentIpConfigurationValueValuesEnumWORKER_IP_PRIVATEdisable_public_ipsadditional_user_labelsAdditionalUserLabelsValuedataflow_service_account_emailmax_workersnum_workersr_   r`   worker_machine_typetemp_locationdataflow_kms_keyworker_regionworker_zoneenable_streaming_engineadditional_experimentsrk   /GoogleCloudDatapipelinesV1LaunchTemplateRequesttemplate_file_gcs_location)r+   argsro   
project_idparams_listtransform_mapping_listrx   
ip_privateip_configurationuser_labels_listr~   launch_parameters               r   CreateLegacyTemplateRequest+PipelinesClient.CreateLegacyTemplateRequest   sX    {{H""''//33T3BJ++	;	;OOMK "66$$HH	"	"$ # $ ` ` z z5 !{ !7 KKjj||J%)%<%<z$00##T]]	5	56O6OQ "#}}YYss/  t  1 }}WWMMNN $ C C''''LL00++,,,++''"&">">&*&A&A $(#>#>GI!7 O 9  {{ 2= ==	;	;OO!, =L =.BF4+ X 6, ==HH//)	 I + +r   c                 b   UR                   n[        R                  R                  R                  R                  SS9nU R                  UR                  U R                  R                  R                  5      nU R                  UR                  U R                  R                  R                  5      nSnU(       a#  U R                  R                  R                  US9nU R                  R                  R                  R                  nUR                   (       a  UOSnU R                  UR"                  U R                  R                  R$                  5      n	Sn
U	(       a#  U R                  R                  R%                  U	S9n
SnUR&                  (       au  UR&                  S:X  a+  U R                  R                  R(                  R*                  nO:UR&                  S:X  a*  U R                  R                  R(                  R,                  nU R                  R                  UR.                  U R                  R                  UR0                  UR2                  UR4                  UR6                  UR8                  UR:                  UR<                  UR>                  UUR@                  URB                  URD                  UURF                  (       a  URF                  O/ U
S9URH                  U(       a#  U R                  R                  R                  US9OSUS9nU R                  RK                  UUUS	9$ )
zCreate a Flex Template request for the Pipeline workload.

Args:
  args: Any, list of args needed to create a Pipeline.

Returns:
  Flex Template request.
TrX   NrZ   SPEED_OPTIMIZEDCOST_OPTIMIZED)r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   
flexrsGoalrh   ri   )containerSpecGcsPathrj   rk   rl   transformNameMappings)ro   rp   launchParameter)&rT   r   rr   rs   rt   r1   ru   rl   r'   5GoogleCloudDatapipelinesV1LaunchFlexTemplateParameterrw   rx   TransformNameMappingsValue8GoogleCloudDatapipelinesV1FlexTemplateRuntimeEnvironmentr{   r|   r}   r~   r   flexrs_goalFlexrsGoalValueValuesEnumFLEXRS_SPEED_OPTIMIZEDFLEXRS_COST_OPTIMIZEDr   r   r   r   r_   r`   r   r   r   r   r   r   r   rk   3GoogleCloudDatapipelinesV1LaunchFlexTemplateRequest)r+   r   ro   r   r   r   rx   r   r   r   r~   r   r   s                r   CreateFlexTemplateRequest)PipelinesClient.CreateFlexTemplateRequest   s    {{H""''//33T3BJ++	>	>PK "66$$KK	#	#% # $ c c ~ ~5 ! !7 WWvv  I  IJ%)%<%<z$00##NN	"	"$ "#}}ee/  @  1 K			.	.mm\\vv  N  N//mm\\vv  M  M}}ZZ!<<MM	A	A $ C C''''LL00++,,,++''"&">">"&*&A&A $(#>#>GI!7! 
B 
9" {{ 2= ==	>	>!, @O @.BF51 [ 72 ==LL( M * *r   c           	         UR                   S:X  aN  U R                  R                  R                  U R                  R                  R                  R                  5      nOMU R                  R                  R                  U R                  R                  R                  R
                  5      nU R                  R                  UR                  UR                  S9nUR                  S:X  a+  U R                  U5      nU R                  R                  US9nO*U R                  U5      nU R                  R                  US9nUR                  (       a  UR                  n	OUR                  SS5      S   n	U R                  R                  UU	UUUR                  US	9n
U R                  R!                  XS
9nU R"                  R%                  U5      $ )zCreate a Pipeline in the given project and region.

Args:
  pipeline: str, the name for the Pipeline being created.
  parent: str, relative name to the region.
  args: Any, list of args needed to create a Pipeline.

Returns:
  Pipeline resource.
	streamingscheduletimeZoneclassicdataflowLaunchTemplateRequestdataflowFlexTemplateRequest/   )r   displayNametypescheduleInfoschedulerServiceAccountEmailworkload)"googleCloudDatapipelinesV1PipelinerF   )pipeline_typer'   "GoogleCloudDatapipelinesV1PipelineTypeValueValuesEnumPIPELINE_TYPE_STREAMINGPIPELINE_TYPE_BATCH&GoogleCloudDatapipelinesV1ScheduleSpecr   	time_zonetemplate_typer   "GoogleCloudDatapipelinesV1Workloadr   display_namersplitscheduler_service_account_email4DatapipelinesProjectsLocationsPipelinesCreateRequestr)   Create)r+   r   rF   r   r   schedule_infolegacy_template_requestr   flex_template_requestr   pipeline_spec
create_reqs               r   r   PipelinesClient.Create  s    [(mmFFZZ
--
:
:
N
N""$m mmFFZZ
--
:
:
N
N m MMHH I 9M Y& $ @ @ FAA(? B Ah #<<TBAA&; B =h &&l__S!,R0lMMDD "%)%I%I E M SS+8 T IJ==
++r   c                    / nUS:X  a  SnOSnUR                   (       a,  US:X  a  UR                  US-   5        OUR                  S5        UR                  (       a  UR                  US-   5        UR                  (       a  UR                  US-   5        UR                  (       a/  US:X  a  UR                  US-   5        OUR                  US	-   5        UR
                  (       a  UR                  US
-   5        UR                  (       a  UR                  US-   5        UR                  (       a  UR                  US-   5        UR                  (       a  UR                  US-   5        UR                  (       a  UR                  US-   5        UR                  (       a  UR                  US-   5        UR                  (       a  UR                  US-   5        UR                  (       a  UR                  US-   5        UR                  (       a  UR                  US-   5        UR                  (       a  UR                  US-   5        UR                  (       a  UR                  US-   5        UR                   (       a  UR                  US-   5        UR"                  (       a  US:X  a  UR                  US-   5        UR$                  (       a  UR                  US-   5        UR&                  (       a  UR                  US-   5        U$ )zGiven a set of args for the workload, create the required update mask.

Args:
  template_type: str, the type of the pipeline.
  args: Any, object with args needed for updating a pipeline.

Returns:
  Update mask.
flexz9workload.dataflow_flex_template_request.launch_parameter.z<workload.dataflow_launch_template_request.launch_parameters.container_spec_gcs_pathz2workload.dataflow_launch_template_request.gcs_pathrl   rk   rx   transform_name_mappingzenvironment.max_workerszenvironment.num_workersz!environment.service_account_emailzenvironment.temp_locationzenvironment.networkzenvironment.subnetworkzenvironment.machine_typezenvironment.kms_key_namezenvironment.ip_configurationzenvironment.worker_regionzenvironment.worker_zonez#environment.enable_streaming_enginezenvironment.flexrs_goalz"environment.additional_user_labelsz"environment.additional_experiments)r   appendrl   rk   rx   r   r   r   r   r_   r`   r   r   r}   r   r   r   r   r~   r   )r+   r   r   update_maskprefix_strings        r   WorkloadUpdateMask"PipelinesClient.WorkloadUpdateMask=  sy    KQmTm&&	&	 =+DDEOP56{{12##	&	 =+DDE=+CCD)BBC)BBC**)LLM)DDE||)>>?)AAB)CCD)CCD)GGH)DDE)BBC##)NNO	&	 =+DDE"")MMN"")MMNr   c                    / nSnUR                   (       d  UR                  (       ay  Su  pVUR                   (       a  UR                   nUR                  S5        UR                  (       a  UR                  nUR                  S5        U R                  R	                  XVS9nUR
                  (       a  UR                  S5        UR                  S:X  a?  X0R                  SU5      -  nU R                  U5      nU R                  R                  US9nO>X0R                  S	U5      -  nU R                  U5      n	U R                  R                  U	S
9nU R                  R                  UUR
                  UUR                  US9n
U R                  R                  U
USR                  U5      S9nU R                  R!                  U5      $ )zUpdate a Pipeline in the given project and region.

Args:
  pipeline: str, the name for the Pipeline being updated.
  args: Any, object with args needed to update a Pipeline.

Returns:
  Pipeline resource.
NNNzschedule_info.schedulezschedule_info.time_zoner   r   r   r   r   r   )r   r   r   r   r   ,)r   r   
updateMask)r   r   r   r'   r   r   r   r   r   r   r   r   r   3DatapipelinesProjectsLocationsPipelinesPatchRequestjoinr)   Patch)r+   r   r   r   r   r   r   r   r   r   r   
update_reqs               r   r   PipelinesClient.Patch  s    KM}}&h	==34	NN	45mmJJ K 1m (Y&,,Y==k $ @ @ FAA(? B Ah ,,VT::k"<<TBAA&; B =h MMDD%%"%)%I%I E M RR+888K( S *J ==z**r   c                     / nU(       a=  [         R                  " U5       H#  u  pEUR                  UR                  XES95        M%     U$ )zConvert dictionary arguments to parameter list .

Args:
  arguments: Arguments for create job using template.
  value_message: the value message of the arguments

Returns:
  List of value_message.AdditionalProperty
)keyvalue)six	iteritemsr   AdditionalProperty)r+   	argumentsvalue_messager   kvs         r   ru   $PipelinesClient.ConvertDictArguments  sE     K--	*$!=;;;KL + r   r)   r&   r'   r   )N2    r   )__name__
__module____qualname____firstlineno____doc__r,   r3   r7   r<   rB   rH   r   r   r   r   r   ru   __static_attributes__ r   r   r"   r"   /   sH    8=
+,(')4=+~G*R.,`Pd1+fr   r"   c                   ,    \ rS rSrSrSS jrSS jrSrg)	
JobsClienti  zQClient used for interacting with job related service from the Data Pipelines API.Nc                     U=(       d
    [        5       U l        U=(       d
    [        5       U l        U R                  R                  U l        g r%   )r   r&   r   r'   !projects_locations_pipelines_jobsr)   r*   s      r   r,   JobsClient.__init__  s3    /-/DK3 1 3DMKKAADMr   c           
      |    U R                   R                  US9n[        R                  " U R                  USSUUSS9$ )aF  Make API calls to list jobs for pipelines.

Args:
  limit: int or None, the total number of results to return.
  page_size: int, the number of entries in each batch (affects requests
    made, but not the yielded results).
  pipeline: string, the name of the pipeline to list jobs for.

Returns:
  Generator that yields jobs.
)rF   jobsrH   rI   rJ   )r'   6DatapipelinesProjectsLocationsPipelinesJobsListRequestr   rQ   r)   )r+   rN   rR   r   rU   s        r   rH   JobsClient.List  sM     }}SS T H##') )r   r   r   )Nr   r   )r   r   r   r   r   r,   rH   r   r   r   r   r   r     s    YB
)r   r   )r   apitools.base.pyr   googlecloudsdk.api_lib.utilr   googlecloudsdk.corer   r   r   _DEFAULT_API_VERSIONr   r   r   r    objectr"   r   r   r   r   <module>r     sZ    $ ( , * ) 
  #7 > #7 >bf bJ) )r   