Constructor

DataLabelingServiceClient

new DataLabelingServiceClient(options)

Construct an instance of DataLabelingServiceClient.

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

annotatedDatasetPath

annotatedDatasetPath(project, dataset, annotatedDataset) returns String

Return a fully-qualified annotated_dataset resource name string.

Parameter

project

String

dataset

String

annotatedDataset

String

Returns

String 

annotationSpecSetPath

annotationSpecSetPath(project, annotationSpecSet) returns String

Return a fully-qualified annotation_spec_set resource name string.

Parameter

project

String

annotationSpecSet

String

Returns

String 

createAnnotationSpecSet

createAnnotationSpecSet(request, options, callback) returns Promise

Creates an annotation spec set by providing a set of labels.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

Required. AnnotationSpecSet resource parent, format: projects/{project_id}

annotationSpecSet

Object

Required. Annotation spec set to create. Annotation specs must be included. Only one annotation spec will be accepted for annotation specs with same display_name.

This object should have the same structure as AnnotationSpecSet

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 AnnotationSpecSet.

Returns

Promise 

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

Example

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

const client = new datalabeling.v1beta1.DataLabelingServiceClient({
  // optional auth parameters.
});

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

createDataset

createDataset(request, options, callback) returns Promise

Creates dataset. If success return a Dataset resource.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

Required. Dataset resource parent, format: projects/{project_id}

dataset

Object

Required. The dataset to be created.

This object should have the same structure as Dataset

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 Dataset.

Returns

Promise 

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

Example

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

const client = new datalabeling.v1beta1.DataLabelingServiceClient({
  // optional auth parameters.
});

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

createInstruction

createInstruction(request, options, callback) returns Promise

Creates an instruction for how data should be labeled.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

Required. Instruction resource parent, format: projects/{project_id}

instruction

Object

Required. Instruction of how to perform the labeling task.

This object should have the same structure as Instruction

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 datalabeling = require('@google-cloud/datalabeling');

const client = new datalabeling.v1beta1.DataLabelingServiceClient({
  // optional auth parameters.
});

const formattedParent = client.projectPath('[PROJECT]');
const instruction = {};
const request = {
  parent: formattedParent,
  instruction: instruction,
};

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

    // Operation#promise starts polling for the completion of the LRO.
    return operation.promise();
  })
  .then(responses => {
    const result = responses[0];
    const metadata = responses[1];
    const finalApiResponse = responses[2];
  })
  .catch(err => {
    console.error(err);
  });

const formattedParent = client.projectPath('[PROJECT]');
const instruction = {};
const request = {
  parent: formattedParent,
  instruction: instruction,
};

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

    // 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);
  });

const formattedParent = client.projectPath('[PROJECT]');
const instruction = {};
const request = {
  parent: formattedParent,
  instruction: instruction,
};

// Handle the operation using the await pattern.
const [operation] = await client.createInstruction(request);

const [response] = await operation.promise();

dataItemPath

dataItemPath(project, dataset, dataItem) returns String

Return a fully-qualified data_item resource name string.

Parameter

project

String

dataset

String

dataItem

String

Returns

String 

datasetPath

datasetPath(project, dataset) returns String

Return a fully-qualified dataset resource name string.

Parameter

project

String

dataset

String

Returns

String 

deleteAnnotatedDataset

deleteAnnotatedDataset(request, options, callback) returns Promise

Deletes an annotated dataset by resource name.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

Optional

string

Required. Name of the annotated dataset to delete, format: projects/{project_id}/datasets/{dataset_id}/annotatedDatasets/ {annotated_dataset_id}

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 datalabeling = require('@google-cloud/datalabeling');

const client = new datalabeling.v1beta1.DataLabelingServiceClient({
  // optional auth parameters.
});


client.deleteAnnotatedDataset({}).catch(err => {
  console.error(err);
});

deleteAnnotationSpecSet

deleteAnnotationSpecSet(request, options, callback) returns Promise

Deletes an annotation spec set by resource name.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

Required. AnnotationSpec resource name, format: projects/{project_id}/annotationSpecSets/{annotation_spec_set_id}.

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 datalabeling = require('@google-cloud/datalabeling');

const client = new datalabeling.v1beta1.DataLabelingServiceClient({
  // optional auth parameters.
});

const formattedName = client.annotationSpecSetPath('[PROJECT]', '[ANNOTATION_SPEC_SET]');
client.deleteAnnotationSpecSet({name: formattedName}).catch(err => {
  console.error(err);
});

deleteDataset

deleteDataset(request, options, callback) returns Promise

Deletes a dataset by resource name.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

Required. Dataset resource name, format: projects/{project_id}/datasets/{dataset_id}

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 datalabeling = require('@google-cloud/datalabeling');

const client = new datalabeling.v1beta1.DataLabelingServiceClient({
  // optional auth parameters.
});

const formattedName = client.datasetPath('[PROJECT]', '[DATASET]');
client.deleteDataset({name: formattedName}).catch(err => {
  console.error(err);
});

deleteInstruction

deleteInstruction(request, options, callback) returns Promise

Deletes an instruction object by resource name.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

Required. Instruction resource name, format: projects/{project_id}/instructions/{instruction_id}

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 datalabeling = require('@google-cloud/datalabeling');

const client = new datalabeling.v1beta1.DataLabelingServiceClient({
  // optional auth parameters.
});

const formattedName = client.instructionPath('[PROJECT]', '[INSTRUCTION]');
client.deleteInstruction({name: formattedName}).catch(err => {
  console.error(err);
});

examplePath

examplePath(project, dataset, annotatedDataset, example) returns String

Return a fully-qualified example resource name string.

Parameter

project

String

dataset

String

annotatedDataset

String

example

String

Returns

String 

exportData

exportData(request, options, callback) returns Promise

Exports data and annotations from dataset.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

Required. Dataset resource name, format: projects/{project_id}/datasets/{dataset_id}

annotatedDataset

string

Required. Annotated dataset resource name. DataItem in Dataset and their annotations in specified annotated dataset will be exported. It's in format of projects/{project_id}/datasets/{dataset_id}/annotatedDatasets/ {annotated_dataset_id}

outputConfig

Object

Required. Specify the output destination.

This object should have the same structure as OutputConfig

filter

Optional

string

Optional. Filter is not supported at this moment.

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 datalabeling = require('@google-cloud/datalabeling');

const client = new datalabeling.v1beta1.DataLabelingServiceClient({
  // optional auth parameters.
});

const formattedName = client.datasetPath('[PROJECT]', '[DATASET]');
const annotatedDataset = '';
const outputConfig = {};
const request = {
  name: formattedName,
  annotatedDataset: annotatedDataset,
  outputConfig: outputConfig,
};

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

    // Operation#promise starts polling for the completion of the LRO.
    return operation.promise();
  })
  .then(responses => {
    const result = responses[0];
    const metadata = responses[1];
    const finalApiResponse = responses[2];
  })
  .catch(err => {
    console.error(err);
  });

const formattedName = client.datasetPath('[PROJECT]', '[DATASET]');
const annotatedDataset = '';
const outputConfig = {};
const request = {
  name: formattedName,
  annotatedDataset: annotatedDataset,
  outputConfig: outputConfig,
};

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

    // 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);
  });

const formattedName = client.datasetPath('[PROJECT]', '[DATASET]');
const annotatedDataset = '';
const outputConfig = {};
const request = {
  name: formattedName,
  annotatedDataset: annotatedDataset,
  outputConfig: outputConfig,
};

// Handle the operation using the await pattern.
const [operation] = await client.exportData(request);

const [response] = await operation.promise();

getAnnotatedDataset

getAnnotatedDataset(request, options, callback) returns Promise

Gets an annotated dataset by resource name.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

Required. Name of the annotated dataset to get, format: projects/{project_id}/datasets/{dataset_id}/annotatedDatasets/ {annotated_dataset_id}

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 AnnotatedDataset.

Returns

Promise 

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

Example

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

const client = new datalabeling.v1beta1.DataLabelingServiceClient({
  // optional auth parameters.
});

const formattedName = client.annotatedDatasetPath('[PROJECT]', '[DATASET]', '[ANNOTATED_DATASET]');
client.getAnnotatedDataset({name: formattedName})
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

getAnnotationSpecSet

getAnnotationSpecSet(request, options, callback) returns Promise

Gets an annotation spec set by resource name.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

Required. AnnotationSpecSet resource name, format: projects/{project_id}/annotationSpecSets/{annotation_spec_set_id}

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 AnnotationSpecSet.

Returns

Promise 

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

Example

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

const client = new datalabeling.v1beta1.DataLabelingServiceClient({
  // optional auth parameters.
});

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

getDataItem

getDataItem(request, options, callback) returns Promise

Gets a data item in a dataset by resource name. This API can be called after data are imported into dataset.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

Required. The name of the data item to get, format: projects/{project_id}/datasets/{dataset_id}/dataItems/{data_item_id}

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 DataItem.

Returns

Promise 

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

Example

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

const client = new datalabeling.v1beta1.DataLabelingServiceClient({
  // optional auth parameters.
});

const formattedName = client.dataItemPath('[PROJECT]', '[DATASET]', '[DATA_ITEM]');
client.getDataItem({name: formattedName})
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

getDataset

getDataset(request, options, callback) returns Promise

Gets dataset by resource name.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

Required. Dataset resource name, format: projects/{project_id}/datasets/{dataset_id}

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 Dataset.

Returns

Promise 

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

Example

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

const client = new datalabeling.v1beta1.DataLabelingServiceClient({
  // optional auth parameters.
});

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

getExample

getExample(request, options, callback) returns Promise

Gets an example by resource name, including both data and annotation.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

Required. Name of example, format: projects/{project_id}/datasets/{dataset_id}/annotatedDatasets/ {annotated_dataset_id}/examples/{example_id}

filter

Optional

string

Optional. An expression for filtering Examples. Filter by annotation_spec.display_name is supported. Format "annotation_spec.display_name = {display_name}"

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 Example.

Returns

Promise 

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

Example

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

const client = new datalabeling.v1beta1.DataLabelingServiceClient({
  // optional auth parameters.
});

const formattedName = client.examplePath('[PROJECT]', '[DATASET]', '[ANNOTATED_DATASET]', '[EXAMPLE]');
client.getExample({name: formattedName})
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

getInstruction

getInstruction(request, options, callback) returns Promise

Gets an instruction by resource name.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

Required. Instruction resource name, format: projects/{project_id}/instructions/{instruction_id}

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 Instruction.

Returns

Promise 

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

Example

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

const client = new datalabeling.v1beta1.DataLabelingServiceClient({
  // optional auth parameters.
});

const formattedName = client.instructionPath('[PROJECT]', '[INSTRUCTION]');
client.getInstruction({name: formattedName})
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .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.

importData

importData(request, options, callback) returns Promise

Imports data into dataset based on source locations defined in request. It can be called multiple times for the same dataset. Each dataset can only have one long running operation running on it. For example, no labeling task (also long running operation) can be started while importing is still ongoing. Vice versa.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

Required. Dataset resource name, format: projects/{project_id}/datasets/{dataset_id}

inputConfig

Object

Required. Specify the input source of the data.

This object should have the same structure as InputConfig

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 datalabeling = require('@google-cloud/datalabeling');

const client = new datalabeling.v1beta1.DataLabelingServiceClient({
  // optional auth parameters.
});

const formattedName = client.datasetPath('[PROJECT]', '[DATASET]');
const inputConfig = {};
const request = {
  name: formattedName,
  inputConfig: inputConfig,
};

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

    // Operation#promise starts polling for the completion of the LRO.
    return operation.promise();
  })
  .then(responses => {
    const result = responses[0];
    const metadata = responses[1];
    const finalApiResponse = responses[2];
  })
  .catch(err => {
    console.error(err);
  });

const formattedName = client.datasetPath('[PROJECT]', '[DATASET]');
const inputConfig = {};
const request = {
  name: formattedName,
  inputConfig: inputConfig,
};

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

    // 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);
  });

const formattedName = client.datasetPath('[PROJECT]', '[DATASET]');
const inputConfig = {};
const request = {
  name: formattedName,
  inputConfig: inputConfig,
};

// Handle the operation using the await pattern.
const [operation] = await client.importData(request);

const [response] = await operation.promise();

instructionPath

instructionPath(project, instruction) returns String

Return a fully-qualified instruction resource name string.

Parameter

project

String

instruction

String

Returns

String 

labelAudio

labelAudio(request, options, callback) returns Promise

Starts a labeling task for audio. The type of audio labeling task is configured by feature in the request.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

Required. Name of the dataset to request labeling task, format: projects/{project_id}/datasets/{dataset_id}

basicConfig

Object

Required. Basic human annotation config.

This object should have the same structure as HumanAnnotationConfig

feature

number

Required. The type of audio labeling task.

The number should be among the values of Feature

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 datalabeling = require('@google-cloud/datalabeling');

const client = new datalabeling.v1beta1.DataLabelingServiceClient({
  // optional auth parameters.
});

const formattedParent = client.datasetPath('[PROJECT]', '[DATASET]');
const basicConfig = {};
const feature = 'FEATURE_UNSPECIFIED';
const request = {
  parent: formattedParent,
  basicConfig: basicConfig,
  feature: feature,
};

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

    // Operation#promise starts polling for the completion of the LRO.
    return operation.promise();
  })
  .then(responses => {
    const result = responses[0];
    const metadata = responses[1];
    const finalApiResponse = responses[2];
  })
  .catch(err => {
    console.error(err);
  });

const formattedParent = client.datasetPath('[PROJECT]', '[DATASET]');
const basicConfig = {};
const feature = 'FEATURE_UNSPECIFIED';
const request = {
  parent: formattedParent,
  basicConfig: basicConfig,
  feature: feature,
};

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

    // 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);
  });

const formattedParent = client.datasetPath('[PROJECT]', '[DATASET]');
const basicConfig = {};
const feature = 'FEATURE_UNSPECIFIED';
const request = {
  parent: formattedParent,
  basicConfig: basicConfig,
  feature: feature,
};

// Handle the operation using the await pattern.
const [operation] = await client.labelAudio(request);

const [response] = await operation.promise();

labelImage

labelImage(request, options, callback) returns Promise

Starts a labeling task for image. The type of image labeling task is configured by feature in the request.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

Required. Name of the dataset to request labeling task, format: projects/{project_id}/datasets/{dataset_id}

basicConfig

Object

Required. Basic human annotation config.

This object should have the same structure as HumanAnnotationConfig

feature

number

Required. The type of image labeling task.

The number should be among the values of Feature

imageClassificationConfig

Optional

Object

Configuration for image classification task. One of image_classification_config, bounding_poly_config, polyline_config and segmentation_config is required.

This object should have the same structure as ImageClassificationConfig

boundingPolyConfig

Optional

Object

Configuration for bounding box and bounding poly task. One of image_classification_config, bounding_poly_config, polyline_config and segmentation_config is required.

This object should have the same structure as BoundingPolyConfig

polylineConfig

Optional

Object

Configuration for polyline task. One of image_classification_config, bounding_poly_config, polyline_config and segmentation_config is required.

This object should have the same structure as PolylineConfig

segmentationConfig

Optional

Object

Configuration for segmentation task. One of image_classification_config, bounding_poly_config, polyline_config and segmentation_config is required.

This object should have the same structure as SegmentationConfig

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 datalabeling = require('@google-cloud/datalabeling');

const client = new datalabeling.v1beta1.DataLabelingServiceClient({
  // optional auth parameters.
});

const formattedParent = client.datasetPath('[PROJECT]', '[DATASET]');
const basicConfig = {};
const feature = 'FEATURE_UNSPECIFIED';
const request = {
  parent: formattedParent,
  basicConfig: basicConfig,
  feature: feature,
};

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

    // Operation#promise starts polling for the completion of the LRO.
    return operation.promise();
  })
  .then(responses => {
    const result = responses[0];
    const metadata = responses[1];
    const finalApiResponse = responses[2];
  })
  .catch(err => {
    console.error(err);
  });

const formattedParent = client.datasetPath('[PROJECT]', '[DATASET]');
const basicConfig = {};
const feature = 'FEATURE_UNSPECIFIED';
const request = {
  parent: formattedParent,
  basicConfig: basicConfig,
  feature: feature,
};

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

    // 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);
  });

const formattedParent = client.datasetPath('[PROJECT]', '[DATASET]');
const basicConfig = {};
const feature = 'FEATURE_UNSPECIFIED';
const request = {
  parent: formattedParent,
  basicConfig: basicConfig,
  feature: feature,
};

// Handle the operation using the await pattern.
const [operation] = await client.labelImage(request);

const [response] = await operation.promise();

labelText

labelText(request, options, callback) returns Promise

Starts a labeling task for text. The type of text labeling task is configured by feature in the request.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

Required. Name of the data set to request labeling task, format: projects/{project_id}/datasets/{dataset_id}

basicConfig

Object

Required. Basic human annotation config.

This object should have the same structure as HumanAnnotationConfig

feature

number

Required. The type of text labeling task.

The number should be among the values of Feature

textClassificationConfig

Optional

Object

Configuration for text classification task. One of text_classification_config and text_entity_extraction_config is required.

This object should have the same structure as TextClassificationConfig

textEntityExtractionConfig

Optional

Object

Configuration for entity extraction task. One of text_classification_config and text_entity_extraction_config is required.

This object should have the same structure as TextEntityExtractionConfig

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 datalabeling = require('@google-cloud/datalabeling');

const client = new datalabeling.v1beta1.DataLabelingServiceClient({
  // optional auth parameters.
});

const formattedParent = client.datasetPath('[PROJECT]', '[DATASET]');
const basicConfig = {};
const feature = 'FEATURE_UNSPECIFIED';
const request = {
  parent: formattedParent,
  basicConfig: basicConfig,
  feature: feature,
};

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

    // Operation#promise starts polling for the completion of the LRO.
    return operation.promise();
  })
  .then(responses => {
    const result = responses[0];
    const metadata = responses[1];
    const finalApiResponse = responses[2];
  })
  .catch(err => {
    console.error(err);
  });

const formattedParent = client.datasetPath('[PROJECT]', '[DATASET]');
const basicConfig = {};
const feature = 'FEATURE_UNSPECIFIED';
const request = {
  parent: formattedParent,
  basicConfig: basicConfig,
  feature: feature,
};

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

    // 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);
  });

const formattedParent = client.datasetPath('[PROJECT]', '[DATASET]');
const basicConfig = {};
const feature = 'FEATURE_UNSPECIFIED';
const request = {
  parent: formattedParent,
  basicConfig: basicConfig,
  feature: feature,
};

// Handle the operation using the await pattern.
const [operation] = await client.labelText(request);

const [response] = await operation.promise();

labelVideo

labelVideo(request, options, callback) returns Promise

Starts a labeling task for video. The type of video labeling task is configured by feature in the request.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

Required. Name of the dataset to request labeling task, format: projects/{project_id}/datasets/{dataset_id}

basicConfig

Object

Required. Basic human annotation config.

This object should have the same structure as HumanAnnotationConfig

feature

number

Required. The type of video labeling task.

The number should be among the values of Feature

videoClassificationConfig

Optional

Object

Configuration for video classification task. One of video_classification_config, object_detection_config, object_tracking_config and event_config is required.

This object should have the same structure as VideoClassificationConfig

objectDetectionConfig

Optional

Object

Configuration for video object detection task. One of video_classification_config, object_detection_config, object_tracking_config and event_config is required.

This object should have the same structure as ObjectDetectionConfig

objectTrackingConfig

Optional

Object

Configuration for video object tracking task. One of video_classification_config, object_detection_config, object_tracking_config and event_config is required.

This object should have the same structure as ObjectTrackingConfig

eventConfig

Optional

Object

Configuration for video event task. One of video_classification_config, object_detection_config, object_tracking_config and event_config is required.

This object should have the same structure as EventConfig

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 datalabeling = require('@google-cloud/datalabeling');

const client = new datalabeling.v1beta1.DataLabelingServiceClient({
  // optional auth parameters.
});

const formattedParent = client.datasetPath('[PROJECT]', '[DATASET]');
const basicConfig = {};
const feature = 'FEATURE_UNSPECIFIED';
const request = {
  parent: formattedParent,
  basicConfig: basicConfig,
  feature: feature,
};

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

    // Operation#promise starts polling for the completion of the LRO.
    return operation.promise();
  })
  .then(responses => {
    const result = responses[0];
    const metadata = responses[1];
    const finalApiResponse = responses[2];
  })
  .catch(err => {
    console.error(err);
  });

const formattedParent = client.datasetPath('[PROJECT]', '[DATASET]');
const basicConfig = {};
const feature = 'FEATURE_UNSPECIFIED';
const request = {
  parent: formattedParent,
  basicConfig: basicConfig,
  feature: feature,
};

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

    // 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);
  });

const formattedParent = client.datasetPath('[PROJECT]', '[DATASET]');
const basicConfig = {};
const feature = 'FEATURE_UNSPECIFIED';
const request = {
  parent: formattedParent,
  basicConfig: basicConfig,
  feature: feature,
};

// Handle the operation using the await pattern.
const [operation] = await client.labelVideo(request);

const [response] = await operation.promise();

listAnnotatedDatasets

listAnnotatedDatasets(request, options, callback) returns Promise

Lists annotated datasets for a dataset. Pagination is supported.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

Required. Name of the dataset to list annotated datasets, format: projects/{project_id}/datasets/{dataset_id}

filter

Optional

string

Optional. Filter is not supported at this moment.

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 AnnotatedDataset.

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 ListAnnotatedDatasetsResponse.

Returns

Promise 

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

    When autoPaginate: false is specified through options, the array has three elements. The first element is Array of AnnotatedDataset 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 ListAnnotatedDatasetsResponse.

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

Example

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

const client = new datalabeling.v1beta1.DataLabelingServiceClient({
  // optional auth parameters.
});

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

client.listAnnotatedDatasets({parent: formattedParent})
  .then(responses => {
    const resources = responses[0];
    for (const resource of resources) {
      // doThingsWith(resource)
    }
  })
  .catch(err => {
    console.error(err);
  });

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


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 (const resource of resources) {
    // doThingsWith(resource);
  }
  if (nextRequest) {
    // Fetch the next page.
    return client.listAnnotatedDatasets(nextRequest, options).then(callback);
  }
}
client.listAnnotatedDatasets({parent: formattedParent}, options)
  .then(callback)
  .catch(err => {
    console.error(err);
  });

listAnnotatedDatasetsStream

listAnnotatedDatasetsStream(request, options) returns Stream

Equivalent to listAnnotatedDatasets, but returns a NodeJS Stream object.

This fetches the paged responses for listAnnotatedDatasets 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. Name of the dataset to list annotated datasets, format: projects/{project_id}/datasets/{dataset_id}

filter

Optional

string

Optional. Filter is not supported at this moment.

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 AnnotatedDataset on 'data' event.

Example

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

const client = new datalabeling.v1beta1.DataLabelingServiceClient({
  // optional auth parameters.
});

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

listAnnotationSpecSets

listAnnotationSpecSets(request, options, callback) returns Promise

Lists annotation spec sets for a project. Pagination is supported.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

Required. Parent of AnnotationSpecSet resource, format: projects/{project_id}

filter

Optional

string

Optional. Filter is not supported at this moment.

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 AnnotationSpecSet.

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 ListAnnotationSpecSetsResponse.

Returns

Promise 

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

    When autoPaginate: false is specified through options, the array has three elements. The first element is Array of AnnotationSpecSet 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 ListAnnotationSpecSetsResponse.

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

Example

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

const client = new datalabeling.v1beta1.DataLabelingServiceClient({
  // optional auth parameters.
});

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

client.listAnnotationSpecSets({parent: formattedParent})
  .then(responses => {
    const resources = responses[0];
    for (const resource of resources) {
      // doThingsWith(resource)
    }
  })
  .catch(err => {
    console.error(err);
  });

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


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 (const resource of resources) {
    // doThingsWith(resource);
  }
  if (nextRequest) {
    // Fetch the next page.
    return client.listAnnotationSpecSets(nextRequest, options).then(callback);
  }
}
client.listAnnotationSpecSets({parent: formattedParent}, options)
  .then(callback)
  .catch(err => {
    console.error(err);
  });

listAnnotationSpecSetsStream

listAnnotationSpecSetsStream(request, options) returns Stream

Equivalent to listAnnotationSpecSets, but returns a NodeJS Stream object.

This fetches the paged responses for listAnnotationSpecSets 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. Parent of AnnotationSpecSet resource, format: projects/{project_id}

filter

Optional

string

Optional. Filter is not supported at this moment.

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 AnnotationSpecSet on 'data' event.

Example

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

const client = new datalabeling.v1beta1.DataLabelingServiceClient({
  // optional auth parameters.
});

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

listDataItems

listDataItems(request, options, callback) returns Promise

Lists data items in a dataset. This API can be called after data are imported into dataset. Pagination is supported.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

Required. Name of the dataset to list data items, format: projects/{project_id}/datasets/{dataset_id}

filter

Optional

string

Optional. Filter is not supported at this moment.

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 DataItem.

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 ListDataItemsResponse.

Returns

Promise 

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

    When autoPaginate: false is specified through options, the array has three elements. The first element is Array of DataItem 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 ListDataItemsResponse.

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

Example

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

const client = new datalabeling.v1beta1.DataLabelingServiceClient({
  // optional auth parameters.
});

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

client.listDataItems({parent: formattedParent})
  .then(responses => {
    const resources = responses[0];
    for (const resource of resources) {
      // doThingsWith(resource)
    }
  })
  .catch(err => {
    console.error(err);
  });

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


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 (const resource of resources) {
    // doThingsWith(resource);
  }
  if (nextRequest) {
    // Fetch the next page.
    return client.listDataItems(nextRequest, options).then(callback);
  }
}
client.listDataItems({parent: formattedParent}, options)
  .then(callback)
  .catch(err => {
    console.error(err);
  });

listDataItemsStream

listDataItemsStream(request, options) returns Stream

Equivalent to listDataItems, but returns a NodeJS Stream object.

This fetches the paged responses for listDataItems 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. Name of the dataset to list data items, format: projects/{project_id}/datasets/{dataset_id}

filter

Optional

string

Optional. Filter is not supported at this moment.

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 DataItem on 'data' event.

Example

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

const client = new datalabeling.v1beta1.DataLabelingServiceClient({
  // optional auth parameters.
});

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

listDatasets

listDatasets(request, options, callback) returns Promise

Lists datasets under a project. Pagination is supported.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

Required. Dataset resource parent, format: projects/{project_id}

filter

Optional

string

Optional. Filter on dataset is not supported at this moment.

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 Dataset.

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 ListDatasetsResponse.

Returns

Promise 

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

    When autoPaginate: false is specified through options, the array has three elements. The first element is Array of Dataset 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 ListDatasetsResponse.

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

Example

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

const client = new datalabeling.v1beta1.DataLabelingServiceClient({
  // optional auth parameters.
});

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

client.listDatasets({parent: formattedParent})
  .then(responses => {
    const resources = responses[0];
    for (const resource of resources) {
      // doThingsWith(resource)
    }
  })
  .catch(err => {
    console.error(err);
  });

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


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 (const resource of resources) {
    // doThingsWith(resource);
  }
  if (nextRequest) {
    // Fetch the next page.
    return client.listDatasets(nextRequest, options).then(callback);
  }
}
client.listDatasets({parent: formattedParent}, options)
  .then(callback)
  .catch(err => {
    console.error(err);
  });

listDatasetsStream

listDatasetsStream(request, options) returns Stream

Equivalent to listDatasets, but returns a NodeJS Stream object.

This fetches the paged responses for listDatasets 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. Dataset resource parent, format: projects/{project_id}

filter

Optional

string

Optional. Filter on dataset is not supported at this moment.

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 Dataset on 'data' event.

Example

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

const client = new datalabeling.v1beta1.DataLabelingServiceClient({
  // optional auth parameters.
});

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

listExamples

listExamples(request, options, callback) returns Promise

Lists examples in an annotated dataset. Pagination is supported.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

Required. Example resource parent.

filter

Optional

string

Optional. An expression for filtering Examples. For annotated datasets that have annotation spec set, filter by annotation_spec.display_name is supported. Format "annotation_spec.display_name = {display_name}"

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 Example.

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 ListExamplesResponse.

Returns

Promise 

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

    When autoPaginate: false is specified through options, the array has three elements. The first element is Array of Example 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 ListExamplesResponse.

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

Example

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

const client = new datalabeling.v1beta1.DataLabelingServiceClient({
  // optional auth parameters.
});

// Iterate over all elements.
const formattedParent = client.annotatedDatasetPath('[PROJECT]', '[DATASET]', '[ANNOTATED_DATASET]');

client.listExamples({parent: formattedParent})
  .then(responses => {
    const resources = responses[0];
    for (const resource of resources) {
      // doThingsWith(resource)
    }
  })
  .catch(err => {
    console.error(err);
  });

// Or obtain the paged response.
const formattedParent = client.annotatedDatasetPath('[PROJECT]', '[DATASET]', '[ANNOTATED_DATASET]');


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 (const resource of resources) {
    // doThingsWith(resource);
  }
  if (nextRequest) {
    // Fetch the next page.
    return client.listExamples(nextRequest, options).then(callback);
  }
}
client.listExamples({parent: formattedParent}, options)
  .then(callback)
  .catch(err => {
    console.error(err);
  });

listExamplesStream

listExamplesStream(request, options) returns Stream

Equivalent to listExamples, but returns a NodeJS Stream object.

This fetches the paged responses for listExamples 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. Example resource parent.

filter

Optional

string

Optional. An expression for filtering Examples. For annotated datasets that have annotation spec set, filter by annotation_spec.display_name is supported. Format "annotation_spec.display_name = {display_name}"

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 Example on 'data' event.

Example

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

const client = new datalabeling.v1beta1.DataLabelingServiceClient({
  // optional auth parameters.
});

const formattedParent = client.annotatedDatasetPath('[PROJECT]', '[DATASET]', '[ANNOTATED_DATASET]');
client.listExamplesStream({parent: formattedParent})
  .on('data', element => {
    // doThingsWith(element)
  }).on('error', err => {
    console.log(err);
  });

listInstructions

listInstructions(request, options, callback) returns Promise

Lists instructions for a project. Pagination is supported.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

Required. Instruction resource parent, format: projects/{project_id}

filter

Optional

string

Optional. Filter is not supported at this moment.

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 Instruction.

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 ListInstructionsResponse.

Returns

Promise 

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

    When autoPaginate: false is specified through options, the array has three elements. The first element is Array of Instruction 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 ListInstructionsResponse.

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

Example

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

const client = new datalabeling.v1beta1.DataLabelingServiceClient({
  // optional auth parameters.
});

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

client.listInstructions({parent: formattedParent})
  .then(responses => {
    const resources = responses[0];
    for (const resource of resources) {
      // doThingsWith(resource)
    }
  })
  .catch(err => {
    console.error(err);
  });

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


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 (const resource of resources) {
    // doThingsWith(resource);
  }
  if (nextRequest) {
    // Fetch the next page.
    return client.listInstructions(nextRequest, options).then(callback);
  }
}
client.listInstructions({parent: formattedParent}, options)
  .then(callback)
  .catch(err => {
    console.error(err);
  });

listInstructionsStream

listInstructionsStream(request, options) returns Stream

Equivalent to listInstructions, but returns a NodeJS Stream object.

This fetches the paged responses for listInstructions 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. Instruction resource parent, format: projects/{project_id}

filter

Optional

string

Optional. Filter is not supported at this moment.

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 Instruction on 'data' event.

Example

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

const client = new datalabeling.v1beta1.DataLabelingServiceClient({
  // optional auth parameters.
});

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

matchAnnotatedDatasetFromAnnotatedDatasetName

matchAnnotatedDatasetFromAnnotatedDatasetName(annotatedDatasetName) returns String

Parse the annotatedDatasetName from a annotated_dataset resource.

Parameter

annotatedDatasetName

String

A fully-qualified path representing a annotated_dataset resources.

Returns

String 

  • A string representing the annotated_dataset.

matchAnnotatedDatasetFromExampleName

matchAnnotatedDatasetFromExampleName(exampleName) returns String

Parse the exampleName from a example resource.

Parameter

exampleName

String

A fully-qualified path representing a example resources.

Returns

String 

  • A string representing the annotated_dataset.

matchAnnotationSpecSetFromAnnotationSpecSetName

matchAnnotationSpecSetFromAnnotationSpecSetName(annotationSpecSetName) returns String

Parse the annotationSpecSetName from a annotation_spec_set resource.

Parameter

annotationSpecSetName

String

A fully-qualified path representing a annotation_spec_set resources.

Returns

String 

  • A string representing the annotation_spec_set.

matchDataItemFromDataItemName

matchDataItemFromDataItemName(dataItemName) returns String

Parse the dataItemName from a data_item resource.

Parameter

dataItemName

String

A fully-qualified path representing a data_item resources.

Returns

String 

  • A string representing the data_item.

matchDatasetFromAnnotatedDatasetName

matchDatasetFromAnnotatedDatasetName(annotatedDatasetName) returns String

Parse the annotatedDatasetName from a annotated_dataset resource.

Parameter

annotatedDatasetName

String

A fully-qualified path representing a annotated_dataset resources.

Returns

String 

  • A string representing the dataset.

matchDatasetFromDataItemName

matchDatasetFromDataItemName(dataItemName) returns String

Parse the dataItemName from a data_item resource.

Parameter

dataItemName

String

A fully-qualified path representing a data_item resources.

Returns

String 

  • A string representing the dataset.

matchDatasetFromDatasetName

matchDatasetFromDatasetName(datasetName) returns String

Parse the datasetName from a dataset resource.

Parameter

datasetName

String

A fully-qualified path representing a dataset resources.

Returns

String 

  • A string representing the dataset.

matchDatasetFromExampleName

matchDatasetFromExampleName(exampleName) returns String

Parse the exampleName from a example resource.

Parameter

exampleName

String

A fully-qualified path representing a example resources.

Returns

String 

  • A string representing the dataset.

matchExampleFromExampleName

matchExampleFromExampleName(exampleName) returns String

Parse the exampleName from a example resource.

Parameter

exampleName

String

A fully-qualified path representing a example resources.

Returns

String 

  • A string representing the example.

matchInstructionFromInstructionName

matchInstructionFromInstructionName(instructionName) returns String

Parse the instructionName from a instruction resource.

Parameter

instructionName

String

A fully-qualified path representing a instruction resources.

Returns

String 

  • A string representing the instruction.

matchProjectFromAnnotatedDatasetName

matchProjectFromAnnotatedDatasetName(annotatedDatasetName) returns String

Parse the annotatedDatasetName from a annotated_dataset resource.

Parameter

annotatedDatasetName

String

A fully-qualified path representing a annotated_dataset resources.

Returns

String 

  • A string representing the project.

matchProjectFromAnnotationSpecSetName

matchProjectFromAnnotationSpecSetName(annotationSpecSetName) returns String

Parse the annotationSpecSetName from a annotation_spec_set resource.

Parameter

annotationSpecSetName

String

A fully-qualified path representing a annotation_spec_set resources.

Returns

String 

  • A string representing the project.

matchProjectFromDataItemName

matchProjectFromDataItemName(dataItemName) returns String

Parse the dataItemName from a data_item resource.

Parameter

dataItemName

String

A fully-qualified path representing a data_item resources.

Returns

String 

  • A string representing the project.

matchProjectFromDatasetName

matchProjectFromDatasetName(datasetName) returns String

Parse the datasetName from a dataset resource.

Parameter

datasetName

String

A fully-qualified path representing a dataset resources.

Returns

String 

  • A string representing the project.

matchProjectFromExampleName

matchProjectFromExampleName(exampleName) returns String

Parse the exampleName from a example resource.

Parameter

exampleName

String

A fully-qualified path representing a example resources.

Returns

String 

  • A string representing the project.

matchProjectFromInstructionName

matchProjectFromInstructionName(instructionName) returns String

Parse the instructionName from a instruction resource.

Parameter

instructionName

String

A fully-qualified path representing a instruction resources.

Returns

String 

  • A string representing the project.

matchProjectFromProjectName

matchProjectFromProjectName(projectName) returns String

Parse the projectName from a project resource.

Parameter

projectName

String

A fully-qualified path representing a project resources.

Returns

String 

  • A string representing the project.

projectPath

projectPath(project) returns String

Return a fully-qualified project resource name string.

Parameter

project

String

Returns

String