Launch a template (async)

Demonstrates how to launch a template.

Code sample

Node.js

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
/**
 *  Required. The ID of the Cloud Platform project that the job belongs to.
 */
// const projectId = 'abc123'
/**
 *  If true, the request is validated but not actually executed.
 *  Defaults to false.
 */
// const validateOnly = true
/**
 *  A Cloud Storage path to the template from which to create
 *  the job.
 *  Must be valid Cloud Storage URL, beginning with 'gs://'.
 */
// const gcsPath = 'abc123'
/**
 *  Params for launching a dynamic template.
 */
// const dynamicTemplate = {}
/**
 *  The parameters of the template to launch. This should be part of the
 *  body of the POST request.
 */
// const launchParameters = {}
/**
 *  The regional endpoint 
 *  (https://cloud.google.com/dataflow/docs/concepts/regional-endpoints) to
 *  which to direct the request.
 */
// const location = 'abc123'

// Imports the Dataflow library
const {TemplatesServiceClient} = require('@google-cloud/dataflow').v1beta3;

// Instantiates a client
const dataflowClient = new TemplatesServiceClient();

async function callLaunchTemplate() {
  // Construct request
  const request = {
  };

  // Run request
  const response = await dataflowClient.launchTemplate(request);
  console.log(response);
}

callLaunchTemplate();

Python

from google.cloud import dataflow_v1beta3


async def sample_launch_template():
    # Create a client
    client = dataflow_v1beta3.TemplatesServiceAsyncClient()

    # Initialize request argument(s)
    request = dataflow_v1beta3.LaunchTemplateRequest(
        gcs_path="gcs_path_value",
    )

    # Make the request
    response = await client.launch_template(request=request)

    # Handle the response
    print(response)

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.