Constructor

WorkflowTemplateServiceClient

new WorkflowTemplateServiceClient(options)

Construct an instance of WorkflowTemplateServiceClient.

Parameter

options

Optional

object

The configuration object. See the subsequent parameters for more details.

Values in options have the following properties:

Parameter

credentials

Optional

object

Credentials object.

credentials.client_email

Optional

string

credentials.private_key

Optional

string

email

Optional

string

Account email address. Required when using a .pem or .p12 keyFilename.

keyFilename

Optional

string

Full path to the a .json, .pem, or .p12 key downloaded from the Google Developers Console. If you provide a path to a JSON file, the projectId option below is not necessary. NOTE: .pem and .p12 require you to specify options.email as well.

port

Optional

number

The port on which to connect to the remote host.

projectId

Optional

string

The project ID from the Google Developer's Console, e.g. 'grape-spaceship-123'. We will also check the environment variable GCLOUD_PROJECT for your project ID. If your app is running in an environment which supports Application Default Credentials, your project ID will be detected automatically.

promise

Optional

function()

Custom promise module to use instead of native Promises.

servicePath

Optional

string

The domain name of the API remote host.

Properties

port

static

The port for this API service.

scopes

static

The scopes needed to make gRPC calls for every method defined in this service.

servicePath

static

The DNS address for this API service.

Methods

createWorkflowTemplate

createWorkflowTemplate(request, options, callback) returns Promise

Creates new workflow template.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

Required. The "resource name" of the region, as described in https://cloud.google.com/apis/design/resource_names of the form projects/{project_id}/regions/{region}

template

Object

Required. The Dataproc workflow template to create.

This object should have the same structure as WorkflowTemplate

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing WorkflowTemplate.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing WorkflowTemplate. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const dataproc = require('@google-cloud/dataproc');

const client = new dataproc.v1.WorkflowTemplateServiceClient({
  // optional auth parameters.
});

const formattedParent = client.regionPath('[PROJECT]', '[REGION]');
const template = {};
const request = {
  parent: formattedParent,
  template: template,
};
client.createWorkflowTemplate(request)
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

deleteWorkflowTemplate

deleteWorkflowTemplate(request, options, callback) returns Promise

Deletes a workflow template. It does not cancel in-progress workflows.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

Required. The "resource name" of the workflow template, as described in https://cloud.google.com/apis/design/resource_names of the form projects/{project_id}/regions/{region}/workflowTemplates/{template_id}

version

Optional

number

Optional. The version of workflow template to delete. If specified, will only delete the template if the current server version matches specified version.

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error)

The function which will be called with the result of the API call.

Returns

Promise 

  • The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const dataproc = require('@google-cloud/dataproc');

const client = new dataproc.v1.WorkflowTemplateServiceClient({
  // optional auth parameters.
});

const formattedName = client.workflowTemplatePath('[PROJECT]', '[REGION]', '[WORKFLOW_TEMPLATE]');
client.deleteWorkflowTemplate({name: formattedName}).catch(err => {
  console.error(err);
});

getProjectId

getProjectId(callback)

Return the project ID used by this class.

Parameter

callback

function(Error, string)

the callback to be called with the current project Id.

getWorkflowTemplate

getWorkflowTemplate(request, options, callback) returns Promise

Retrieves the latest workflow template.

Can retrieve previously instantiated template by specifying optional version parameter.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

Required. The "resource name" of the workflow template, as described in https://cloud.google.com/apis/design/resource_names of the form projects/{project_id}/regions/{region}/workflowTemplates/{template_id}

version

Optional

number

Optional. The version of workflow template to retrieve. Only previously instatiated versions can be retrieved.

If unspecified, retrieves the current version.

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing WorkflowTemplate.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing WorkflowTemplate. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const dataproc = require('@google-cloud/dataproc');

const client = new dataproc.v1.WorkflowTemplateServiceClient({
  // optional auth parameters.
});

const formattedName = client.workflowTemplatePath('[PROJECT]', '[REGION]', '[WORKFLOW_TEMPLATE]');
client.getWorkflowTemplate({name: formattedName})
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

instantiateInlineWorkflowTemplate

instantiateInlineWorkflowTemplate(request, options, callback) returns Promise

Instantiates a template and begins execution.

This method is equivalent to executing the sequence CreateWorkflowTemplate, InstantiateWorkflowTemplate, DeleteWorkflowTemplate.

The returned Operation can be used to track execution of workflow by polling operations.get. The Operation will complete when entire workflow is finished.

The running workflow can be aborted via operations.cancel. This will cause any inflight jobs to be cancelled and workflow-owned clusters to be deleted.

The Operation.metadata will be WorkflowMetadata.

On successful completion, Operation.response will be Empty.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

Required. The "resource name" of the workflow template region, as described in https://cloud.google.com/apis/design/resource_names of the form projects/{project_id}/regions/{region}

template

Object

Required. The workflow template to instantiate.

This object should have the same structure as WorkflowTemplate

requestId

Optional

string

Optional. A tag that prevents multiple concurrent workflow instances with the same tag from running. This mitigates risk of concurrent instances started due to retries.

It is recommended to always set this value to a UUID.

The tag must contain only letters (a-z, A-Z), numbers (0-9), underscores (_), and hyphens (-). The maximum length is 40 characters.

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is a gax.Operation object.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is a gax.Operation object. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const dataproc = require('@google-cloud/dataproc');

const client = new dataproc.v1.WorkflowTemplateServiceClient({
  // optional auth parameters.
});

const formattedParent = client.regionPath('[PROJECT]', '[REGION]');
const template = {};
const request = {
  parent: formattedParent,
  template: template,
};

// Handle the operation using the promise pattern.
client.instantiateInlineWorkflowTemplate(request)
  .then(responses => {
    const operation = responses[0];
    const initialApiResponse = responses[1];

    // Operation#promise starts polling for the completion of the LRO.
    return operation.promise();
  })
  .then(responses => {
    // The final result of the operation.
    const result = responses[0];

    // The metadata value of the completed operation.
    const metadata = responses[1];

    // The response of the api call returning the complete operation.
    const finalApiResponse = responses[2];
  })
  .catch(err => {
    console.error(err);
  });

const formattedParent = client.regionPath('[PROJECT]', '[REGION]');
const template = {};
const request = {
  parent: formattedParent,
  template: template,
};

// Handle the operation using the event emitter pattern.
client.instantiateInlineWorkflowTemplate(request)
  .then(responses => {
    const operation = responses[0];
    const initialApiResponse = responses[1];

    // Adding a listener for the "complete" event starts polling for the
    // completion of the operation.
    operation.on('complete', (result, metadata, finalApiResponse) => {
      // doSomethingWith(result);
    });

    // Adding a listener for the "progress" event causes the callback to be
    // called on any change in metadata when the operation is polled.
    operation.on('progress', (metadata, apiResponse) => {
      // doSomethingWith(metadata)
    });

    // Adding a listener for the "error" event handles any errors found during polling.
    operation.on('error', err => {
      // throw(err);
    });
  })
  .catch(err => {
    console.error(err);
  });

instantiateWorkflowTemplate

instantiateWorkflowTemplate(request, options, callback) returns Promise

Instantiates a template and begins execution.

The returned Operation can be used to track execution of workflow by polling operations.get. The Operation will complete when entire workflow is finished.

The running workflow can be aborted via operations.cancel. This will cause any inflight jobs to be cancelled and workflow-owned clusters to be deleted.

The Operation.metadata will be WorkflowMetadata.

On successful completion, Operation.response will be Empty.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

Required. The "resource name" of the workflow template, as described in https://cloud.google.com/apis/design/resource_names of the form projects/{project_id}/regions/{region}/workflowTemplates/{template_id}

version

Optional

number

Optional. The version of workflow template to instantiate. If specified, the workflow will be instantiated only if the current version of the workflow template has the supplied version.

This option cannot be used to instantiate a previous version of workflow template.

requestId

Optional

string

Optional. A tag that prevents multiple concurrent workflow instances with the same tag from running. This mitigates risk of concurrent instances started due to retries.

It is recommended to always set this value to a UUID.

The tag must contain only letters (a-z, A-Z), numbers (0-9), underscores (_), and hyphens (-). The maximum length is 40 characters.

parameters

Optional

Object with string properties

Optional. Map from parameter names to values that should be used for those parameters. Values may not exceed 100 characters.

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is a gax.Operation object.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is a gax.Operation object. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const dataproc = require('@google-cloud/dataproc');

const client = new dataproc.v1.WorkflowTemplateServiceClient({
  // optional auth parameters.
});

const formattedName = client.workflowTemplatePath('[PROJECT]', '[REGION]', '[WORKFLOW_TEMPLATE]');

// Handle the operation using the promise pattern.
client.instantiateWorkflowTemplate({name: formattedName})
  .then(responses => {
    const operation = responses[0];
    const initialApiResponse = responses[1];

    // Operation#promise starts polling for the completion of the LRO.
    return operation.promise();
  })
  .then(responses => {
    // The final result of the operation.
    const result = responses[0];

    // The metadata value of the completed operation.
    const metadata = responses[1];

    // The response of the api call returning the complete operation.
    const finalApiResponse = responses[2];
  })
  .catch(err => {
    console.error(err);
  });

const formattedName = client.workflowTemplatePath('[PROJECT]', '[REGION]', '[WORKFLOW_TEMPLATE]');

// Handle the operation using the event emitter pattern.
client.instantiateWorkflowTemplate({name: formattedName})
  .then(responses => {
    const operation = responses[0];
    const initialApiResponse = responses[1];

    // Adding a listener for the "complete" event starts polling for the
    // completion of the operation.
    operation.on('complete', (result, metadata, finalApiResponse) => {
      // doSomethingWith(result);
    });

    // Adding a listener for the "progress" event causes the callback to be
    // called on any change in metadata when the operation is polled.
    operation.on('progress', (metadata, apiResponse) => {
      // doSomethingWith(metadata)
    });

    // Adding a listener for the "error" event handles any errors found during polling.
    operation.on('error', err => {
      // throw(err);
    });
  })
  .catch(err => {
    console.error(err);
  });

listWorkflowTemplates

listWorkflowTemplates(request, options, callback) returns Promise

Lists workflows that match the specified filter in the request.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

Required. The "resource name" of the region, as described in https://cloud.google.com/apis/design/resource_names of the form projects/{project_id}/regions/{region}

pageSize

Optional

number

The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Array, nullable Object, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is Array of WorkflowTemplate.

When autoPaginate: false is specified through options, it contains the result in a single response. If the response indicates the next page exists, the third parameter is set to be used for the next request object. The fourth parameter keeps the raw response object of an object representing ListWorkflowTemplatesResponse.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is Array of WorkflowTemplate.

    When autoPaginate: false is specified through options, the array has three elements. The first element is Array of WorkflowTemplate in a single response. The second element is the next request object if the response indicates the next page exists, or null. The third element is an object representing ListWorkflowTemplatesResponse.

    The promise has a method named "cancel" which cancels the ongoing API call.

Example

const dataproc = require('@google-cloud/dataproc');

const client = new dataproc.v1.WorkflowTemplateServiceClient({
  // optional auth parameters.
});

// Iterate over all elements.
const formattedParent = client.regionPath('[PROJECT]', '[REGION]');

client.listWorkflowTemplates({parent: formattedParent})
  .then(responses => {
    const resources = responses[0];
    for (let i = 0; i < resources.length; i += 1) {
      // doThingsWith(resources[i])
    }
  })
  .catch(err => {
    console.error(err);
  });

// Or obtain the paged response.
const formattedParent = client.regionPath('[PROJECT]', '[REGION]');


const options = {autoPaginate: false};
const callback = responses => {
  // The actual resources in a response.
  const resources = responses[0];
  // The next request if the response shows that there are more responses.
  const nextRequest = responses[1];
  // The actual response object, if necessary.
  // const rawResponse = responses[2];
  for (let i = 0; i < resources.length; i += 1) {
    // doThingsWith(resources[i]);
  }
  if (nextRequest) {
    // Fetch the next page.
    return client.listWorkflowTemplates(nextRequest, options).then(callback);
  }
}
client.listWorkflowTemplates({parent: formattedParent}, options)
  .then(callback)
  .catch(err => {
    console.error(err);
  });

listWorkflowTemplatesStream

listWorkflowTemplatesStream(request, options) returns Stream

Equivalent to listWorkflowTemplates, but returns a NodeJS Stream object.

This fetches the paged responses for listWorkflowTemplates continuously and invokes the callback registered for 'data' event for each element in the responses.

The returned object has 'end' method when no more elements are required.

autoPaginate option will be ignored.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

Required. The "resource name" of the region, as described in https://cloud.google.com/apis/design/resource_names of the form projects/{project_id}/regions/{region}

pageSize

Optional

number

The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

See also
https://nodejs.org/api/stream.html
Returns

Stream 

An object stream which emits an object representing WorkflowTemplate on 'data' event.

Example

const dataproc = require('@google-cloud/dataproc');

const client = new dataproc.v1.WorkflowTemplateServiceClient({
  // optional auth parameters.
});

const formattedParent = client.regionPath('[PROJECT]', '[REGION]');
client.listWorkflowTemplatesStream({parent: formattedParent})
  .on('data', element => {
    // doThingsWith(element)
  }).on('error', err => {
    console.log(err);
  });

matchProjectFromRegionName

matchProjectFromRegionName(regionName) returns String

Parse the regionName from a region resource.

Parameter

regionName

String

A fully-qualified path representing a region resources.

Returns

String 

  • A string representing the project.

matchProjectFromWorkflowTemplateName

matchProjectFromWorkflowTemplateName(workflowTemplateName) returns String

Parse the workflowTemplateName from a workflow_template resource.

Parameter

workflowTemplateName

String

A fully-qualified path representing a workflow_template resources.

Returns

String 

  • A string representing the project.

matchRegionFromRegionName

matchRegionFromRegionName(regionName) returns String

Parse the regionName from a region resource.

Parameter

regionName

String

A fully-qualified path representing a region resources.

Returns

String 

  • A string representing the region.

matchRegionFromWorkflowTemplateName

matchRegionFromWorkflowTemplateName(workflowTemplateName) returns String

Parse the workflowTemplateName from a workflow_template resource.

Parameter

workflowTemplateName

String

A fully-qualified path representing a workflow_template resources.

Returns

String 

  • A string representing the region.

matchWorkflowTemplateFromWorkflowTemplateName

matchWorkflowTemplateFromWorkflowTemplateName(workflowTemplateName) returns String

Parse the workflowTemplateName from a workflow_template resource.

Parameter

workflowTemplateName

String

A fully-qualified path representing a workflow_template resources.

Returns

String 

  • A string representing the workflow_template.

regionPath

regionPath(project, region) returns String

Return a fully-qualified region resource name string.

Parameter

project

String

region

String

Returns

String 

updateWorkflowTemplate

updateWorkflowTemplate(request, options, callback) returns Promise

Updates (replaces) workflow template. The updated template must contain version that matches the current server version.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

template

Object

Required. The updated workflow template.

The template.version field must match the current version.

This object should have the same structure as WorkflowTemplate

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing WorkflowTemplate.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing WorkflowTemplate. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const dataproc = require('@google-cloud/dataproc');

const client = new dataproc.v1.WorkflowTemplateServiceClient({
  // optional auth parameters.
});

const template = {};
client.updateWorkflowTemplate({template: template})
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

workflowTemplatePath

workflowTemplatePath(project, region, workflowTemplate) returns String

Return a fully-qualified workflow_template resource name string.

Parameter

project

String

region

String

workflowTemplate

String

Returns

String