class_docstr: Start a Templated Cloud Dataflow job; the parameters of the operation will be passed to the job.
  
  .. seealso::
      For more information on how to use this operator, take a look at the guide:
      :ref:`howto/operator:DataflowTemplatedJobStartOperator`
  
  :param template: The reference to the Dataflow template.
  :param job_name: The 'jobName' to use when executing the Dataflow template
      (templated).
  :param options: Map of job runtime environment options.
      It will update environment argument if passed.
  
      .. seealso::
          For more information on possible configurations, look at the API documentation
          `https://cloud.google.com/dataflow/pipelines/specifying-exec-params
          <https://cloud.google.com/dataflow/docs/reference/rest/v1b3/RuntimeEnvironment>`__
  
  :param dataflow_default_options: Map of default job environment options.
  :param parameters: Map of job specific parameters for the template.
  :param project_id: Optional, the Google Cloud project ID in which to start a job.
      If set to None or missing, the default project_id from the Google Cloud connection is used.
  :param location: Job location.
  :param gcp_conn_id: The connection ID to use connecting to Google Cloud.
  :param poll_sleep: The time in seconds to sleep between polling Google
      Cloud Platform for the dataflow job status while the job is in the
      JOB_STATE_RUNNING state.
  :param impersonation_chain: Optional service account to impersonate using short-term
      credentials, or chained list of accounts required to get the access_token
      of the last account in the list, which will be impersonated in the request.
      If set as a string, the account must grant the originating account
      the Service Account Token Creator IAM role.
      If set as a sequence, the identities from the list must grant
      Service Account Token Creator IAM role to the directly preceding identity, with first
      account from the list granting this role to the originating account (templated).
  :param environment: Optional, Map of job runtime environment options.
  
      .. seealso::
          For more information on possible configurations, look at the API documentation
          `https://cloud.google.com/dataflow/pipelines/specifying-exec-params
          <https://cloud.google.com/dataflow/docs/reference/rest/v1b3/RuntimeEnvironment>`__
  :param cancel_timeout: How long (in seconds) operator should wait for the pipeline to be
      successfully cancelled when task is being killed.
  :param append_job_name: True if unique suffix has to be appended to job name.
  :param wait_until_finished: (Optional)
      If True, wait for the end of pipeline execution before exiting.
      If False, only submits job.
      If None, default behavior.
  
      The default behavior depends on the type of pipeline:
  
      * for the streaming pipeline, wait for jobs to start,
      * for the batch pipeline, wait for the jobs to complete.
  
      .. warning::
  
          You cannot call ``PipelineResult.wait_until_finish`` method in your pipeline code for the operator
          to work properly. i. e. you must use asynchronous execution. Otherwise, your pipeline will
          always wait until finished. For more information, look at:
          `Asynchronous execution
          <https://cloud.google.com/dataflow/docs/guides/specifying-exec-params#python_10>`__
  
      The process of starting the Dataflow job in Airflow consists of two steps:
  
      * running a subprocess and reading the stderr/stderr log for the job id.
      * loop waiting for the end of the job ID from the previous step.
        This loop checks the status of the job.
  
      Step two is started just after step one has finished, so if you have wait_until_finished in your
      pipeline code, step two will not start until the process stops. When this process stops,
      steps two will run, but it will only execute one iteration as the job will be in a terminal state.
  
      If you in your pipeline do not call the wait_for_pipeline method but pass wait_until_finish=True
      to the operator, the second loop will wait for the job's terminal state.
  
      If you in your pipeline do not call the wait_for_pipeline method, and pass wait_until_finish=False
      to the operator, the second loop will check once is job not in terminal state and exit the loop.
  :param expected_terminal_state: The expected terminal state of the operator on which the corresponding
      Airflow task succeeds. When not specified, it will be determined by the hook.
  
  It's a good practice to define dataflow_* parameters in the default_args of the dag
  like the project, zone and staging location.
  
  .. seealso::
      https://cloud.google.com/dataflow/docs/reference/rest/v1b3/LaunchTemplateParameters
      https://cloud.google.com/dataflow/docs/reference/rest/v1b3/RuntimeEnvironment
  
  .. code-block:: python
  
     default_args = {
         "dataflow_default_options": {
             "zone": "europe-west1-d",
             "tempLocation": "gs://my-staging-bucket/staging/",
         }
     }
  
  You need to pass the path to your dataflow template as a file reference with the
  ``template`` parameter. Use ``parameters`` to pass on parameters to your job.
  Use ``environment`` to pass on runtime environment variables to your job.
  
  .. code-block:: python
  
     t1 = DataflowTemplatedJobStartOperator(
         task_id="dataflow_example",
         template="{{var.value.gcp_dataflow_base}}",
         parameters={
             "inputFile": "gs://bucket/input/my_input.txt",
             "outputFile": "gs://bucket/output/my_output.txt",
         },
         gcp_conn_id="airflow-conn-id",
         dag=my_dag,
     )
  
  ``template``, ``dataflow_default_options``, ``parameters``, and ``job_name`` are
  templated, so you can use variables in them.
  
  Note that ``dataflow_default_options`` is expected to save high-level options
  for project information, which apply to all dataflow operators in the DAG.
  
      .. seealso::
          https://cloud.google.com/dataflow/docs/reference/rest/v1b3
          /LaunchTemplateParameters
          https://cloud.google.com/dataflow/docs/reference/rest/v1b3/RuntimeEnvironment
          For more detail on job template execution have a look at the reference:
          https://cloud.google.com/dataflow/docs/templates/executing-templates
  
  :param deferrable: Run operator in the deferrable mode.
class_docstr_tok: ["Start","a","Templated","Cloud","Dataflow","job",";","the","parameters","of","the","operation","will","be","passed","to","the","job",".","..","seealso",":",":","For","more","information","on","how","to","use","this","operator",",","take","a","look","at","the","guide",":",":","ref",":","`","howto\/operator",":","DataflowTemplatedJobStartOperator","`",":","param","template",":","The","reference","to","the","Dataflow","template",".",":","param","job_name",":","The","'jobName","'","to","use","when","executing","the","Dataflow","template","(","templated",")",".",":","param","options",":","Map","of","job","runtime","environment","options",".","It","will","update","environment","argument","if","passed",".","..","seealso",":",":","For","more","information","on","possible","configurations",",","look","at","the","API","documentation","`","https",":","\/\/cloud.google.com\/dataflow\/pipelines\/specifying-exec-params","<","https",":","\/\/cloud.google.com\/dataflow\/docs\/reference\/rest\/v1b3\/RuntimeEnvironment",">","`","__",":","param","dataflow_default_options",":","Map","of","default","job","environment","options",".",":","param","parameters",":","Map","of","job","specific","parameters","for","the","template",".",":","param","project_id",":","Optional",",","the","Google","Cloud","project","ID","in","which","to","start","a","job",".","If","set","to","None","or","missing",",","the","default","project_id","from","the","Google","Cloud","connection","is","used",".",":","param","location",":","Job","location",".",":","param","gcp_conn_id",":","The","connection","ID","to","use","connecting","to","Google","Cloud",".",":","param","poll_sleep",":","The","time","in","seconds","to","sleep","between","polling","Google","Cloud","Platform","for","the","dataflow","job","status","while","the","job","is","in","the","JOB_STATE_RUNNING","state",".",":","param","impersonation_chain",":","Optional","service","account","to","impersonate","using","short-term","credentials",",","or","chained","list","of","accounts","required","to","get","the","access_token","of","the","last","account","in","the","list",",","which","will","be","impersonated","in","the","request",".","If","set","as","a","string",",","the","account","must","grant","the","originating","account","the","Service","Account","Token","Creator","IAM","role",".","If","set","as","a","sequence",",","the","identities","from","the","list","must","grant","Service","Account","Token","Creator","IAM","role","to","the","directly","preceding","identity",",","with","first","account","from","the","list","granting","this","role","to","the","originating","account","(","templated",")",".",":","param","environment",":","Optional",",","Map","of","job","runtime","environment","options",".","..","seealso",":",":","For","more","information","on","possible","configurations",",","look","at","the","API","documentation","`","https",":","\/\/cloud.google.com\/dataflow\/pipelines\/specifying-exec-params","<","https",":","\/\/cloud.google.com\/dataflow\/docs\/reference\/rest\/v1b3\/RuntimeEnvironment",">","`","__",":","param","cancel_timeout",":","How","long","(","in","seconds",")","operator","should","wait","for","the","pipeline","to","be","successfully","cancelled","when","task","is","being","killed",".",":","param","append_job_name",":","True","if","unique","suffix","has","to","be","appended","to","job","name",".",":","param","wait_until_finished",":","(","Optional",")","If","True",",","wait","for","the","end","of","pipeline","execution","before","exiting",".","If","False",",","only","submits","job",".","If","None",",","default","behavior",".","The","default","behavior","depends","on","the","type","of","pipeline",":","*","for","the","streaming","pipeline",",","wait","for","jobs","to","start",",","*","for","the","batch","pipeline",",","wait","for","the","jobs","to","complete",".","..","warning",":",":","You","can","not","call","``","PipelineResult.wait_until_finish","``","method","in","your","pipeline","code","for","the","operator","to","work","properly",".","i.","e.","you","must","use","asynchronous","execution",".","Otherwise",",","your","pipeline","will","always","wait","until","finished",".","For","more","information",",","look","at",":","`","Asynchronous","execution","<","https",":","\/\/cloud.google.com\/dataflow\/docs\/guides\/specifying-exec-params","#","python_10",">","`","__","The","process","of","starting","the","Dataflow","job","in","Airflow","consists","of","two","steps",":","*","running","a","subprocess","and","reading","the","stderr\/stderr","log","for","the","job","id",".","*","loop","waiting","for","the","end","of","the","job","ID","from","the","previous","step",".","This","loop","checks","the","status","of","the","job",".","Step","two","is","started","just","after","step","one","has","finished",",","so","if","you","have","wait_until_finished","in","your","pipeline","code",",","step","two","will","not","start","until","the","process","stops",".","When","this","process","stops",",","steps","two","will","run",",","but","it","will","only","execute","one","iteration","as","the","job","will","be","in","a","terminal","state",".","If","you","in","your","pipeline","do","not","call","the","wait_for_pipeline","method","but","pass","wait_until_finish=True","to","the","operator",",","the","second","loop","will","wait","for","the","job","'s","terminal","state",".","If","you","in","your","pipeline","do","not","call","the","wait_for_pipeline","method",",","and","pass","wait_until_finish=False","to","the","operator",",","the","second","loop","will","check","once","is","job","not","in","terminal","state","and","exit","the","loop",".",":","param","expected_terminal_state",":","The","expected","terminal","state","of","the","operator","on","which","the","corresponding","Airflow","task","succeeds",".","When","not","specified",",","it","will","be","determined","by","the","hook",".","It","'s","a","good","practice","to","define","dataflow_","*","parameters","in","the","default_args","of","the","dag","like","the","project",",","zone","and","staging","location",".","..","seealso",":",":","https",":","\/\/cloud.google.com\/dataflow\/docs\/reference\/rest\/v1b3\/LaunchTemplateParameters","https",":","\/\/cloud.google.com\/dataflow\/docs\/reference\/rest\/v1b3\/RuntimeEnvironment","..","code-block",":",":","python","default_args","=","{","``","dataflow_default_options","''",":","{","``","zone","''",":","``","europe-west1-d","''",",","``","tempLocation","''",":","``","gs",":","\/\/my-staging-bucket\/staging\/","''",",","}","}","You","need","to","pass","the","path","to","your","dataflow","template","as","a","file","reference","with","the","``","template","``","parameter",".","Use","``","parameters","``","to","pass","on","parameters","to","your","job",".","Use","``","environment","``","to","pass","on","runtime","environment","variables","to","your","job",".","..","code-block",":",":","python","t1","=","DataflowTemplatedJobStartOperator","(","task_id=","''","dataflow_example","''",",","template=","''","{","{","var.value.gcp_dataflow_base","}","}","''",",","parameters=","{","``","inputFile","''",":","``","gs",":","\/\/bucket\/input\/my_input.txt","''",",","``","outputFile","''",":","``","gs",":","\/\/bucket\/output\/my_output.txt","''",",","}",",","gcp_conn_id=","''","airflow-conn-id","''",",","dag=my_dag",",",")","``","template","``",",","``","dataflow_default_options","``",",","``","parameters","``",",","and","``","job_name","``","are","templated",",","so","you","can","use","variables","in","them",".","Note","that","``","dataflow_default_options","``","is","expected","to","save","high-level","options","for","project","information",",","which","apply","to","all","dataflow","operators","in","the","DAG",".","..","seealso",":",":","https",":","\/\/cloud.google.com\/dataflow\/docs\/reference\/rest\/v1b3","\/LaunchTemplateParameters","https",":","\/\/cloud.google.com\/dataflow\/docs\/reference\/rest\/v1b3\/RuntimeEnvironment","For","more","detail","on","job","template","execution","have","a","look","at","the","reference",":","https",":","\/\/cloud.google.com\/dataflow\/docs\/templates\/executing-templates",":","param","deferrable",":","Run","operator","in","the","deferrable","mode","."]
code: def on_kill(self) -> None:
      self.log.info("On kill.")
      if self.job is not None:
          self.log.info("Cancelling job %s", self.job_name)
          self.hook.cancel_job(
              job_name=self.job_name,
              job_id=self.job.get("id"),
              project_id=self.job.get("projectId"),
              location=self.job.get("location"),
          )
  
imports: from __future__ import annotations
  import copy
  import re
  import uuid
  import warnings
  from contextlib import ExitStack
  from enum import Enum
  from functools import cached_property
  from typing import TYPE_CHECKING, Any, Sequence
  from airflow.configuration import conf
  from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
  from airflow.providers.apache.beam.hooks.beam import BeamHook, BeamRunnerType
  from airflow.providers.google.cloud.hooks.dataflow import DEFAULT_DATAFLOW_LOCATION, DataflowHook, process_line_and_extract_dataflow_job_id_callback
  from airflow.providers.google.cloud.hooks.gcs import GCSHook
  from airflow.providers.google.cloud.links.dataflow import DataflowJobLink
  from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
  from airflow.providers.google.cloud.triggers.dataflow import TemplateJobStartTrigger
  from airflow.version import version
label_desc: Use image node_id 6 for calling the DataflowTemplatedJobStartOperator obj's underlying member method code with example usage: obj.on_kill() without return types