Constructor

DlpServiceClient

new DlpServiceClient(options)

Construct an instance of DlpServiceClient.

Parameter

options

Optional

object

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

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

analyzeDataSourceRisk

analyzeDataSourceRisk(request, options, callback) returns Promise

Schedules a job to compute risk analysis metrics over content in a Google Cloud Platform repository.

Parameter

request

Object

The request object that will be sent.

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

var client = new dlp.v2beta1.DlpServiceClient({
  // optional auth parameters.
});

var privacyMetric = {};
var sourceTable = {};
var request = {
  privacyMetric: privacyMetric,
  sourceTable: sourceTable,
};

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

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

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

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

var privacyMetric = {};
var sourceTable = {};
var request = {
  privacyMetric: privacyMetric,
  sourceTable: sourceTable,
};

// Handle the operation using the event emitter pattern.
client.analyzeDataSourceRisk(request)
  .then(responses => {
    var operation = responses[0];
    var 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);
  });

createInspectOperation

createInspectOperation(request, options, callback) returns Promise

Schedules a job scanning content in a Google Cloud Platform data repository.

Parameter

request

Object

The request object that will be sent.

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

var client = new dlp.v2beta1.DlpServiceClient({
  // optional auth parameters.
});

var name = 'EMAIL_ADDRESS';
var infoTypesElement = {
  name: name,
};
var infoTypes = [infoTypesElement];
var inspectConfig = {
  infoTypes: infoTypes,
};
var url = 'gs://example_bucket/example_file.png';
var fileSet = {
  url: url,
};
var cloudStorageOptions = {
  fileSet: fileSet,
};
var storageConfig = {
  cloudStorageOptions: cloudStorageOptions,
};
var outputConfig = {};
var request = {
  inspectConfig: inspectConfig,
  storageConfig: storageConfig,
  outputConfig: outputConfig,
};

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

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

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

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

var name = 'EMAIL_ADDRESS';
var infoTypesElement = {
  name: name,
};
var infoTypes = [infoTypesElement];
var inspectConfig = {
  infoTypes: infoTypes,
};
var url = 'gs://example_bucket/example_file.png';
var fileSet = {
  url: url,
};
var cloudStorageOptions = {
  fileSet: fileSet,
};
var storageConfig = {
  cloudStorageOptions: cloudStorageOptions,
};
var outputConfig = {};
var request = {
  inspectConfig: inspectConfig,
  storageConfig: storageConfig,
  outputConfig: outputConfig,
};

// Handle the operation using the event emitter pattern.
client.createInspectOperation(request)
  .then(responses => {
    var operation = responses[0];
    var 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);
  });

deidentifyContent

deidentifyContent(request, options, callback) returns Promise

De-identifies potentially sensitive info from a list of strings. This method has limits on input size and output size.

Parameter

request

Object

The request object that will be sent.

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

Returns

Promise 

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

Example

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

var client = new dlp.v2beta1.DlpServiceClient({
  // optional auth parameters.
});

var deidentifyConfig = {};
var inspectConfig = {};
var items = [];
var request = {
  deidentifyConfig: deidentifyConfig,
  inspectConfig: inspectConfig,
  items: items,
};
client.deidentifyContent(request)
  .then(responses => {
    var 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.

inspectContent

inspectContent(request, options, callback) returns Promise

Finds potentially sensitive info in a list of strings. This method has limits on input size, processing time, and output size.

Parameter

request

Object

The request object that will be sent.

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

Returns

Promise 

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

Example

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

var client = new dlp.v2beta1.DlpServiceClient({
  // optional auth parameters.
});

var name = 'EMAIL_ADDRESS';
var infoTypesElement = {
  name: name,
};
var infoTypes = [infoTypesElement];
var inspectConfig = {
  infoTypes: infoTypes,
};
var type = 'text/plain';
var value = 'My email is example@example.com.';
var itemsElement = {
  type: type,
  value: value,
};
var items = [itemsElement];
var request = {
  inspectConfig: inspectConfig,
  items: items,
};
client.inspectContent(request)
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

listInfoTypes

listInfoTypes(request, options, callback) returns Promise

Returns sensitive information types for given category.

Parameter

request

Object

The request object that will be sent.

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

Returns

Promise 

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

Example

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

var client = new dlp.v2beta1.DlpServiceClient({
  // optional auth parameters.
});

var category = 'PII';
var languageCode = 'en';
var request = {
  category: category,
  languageCode: languageCode,
};
client.listInfoTypes(request)
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

listInspectFindings

listInspectFindings(request, options, callback) returns Promise

Returns list of results for given inspect operation result set id.

Parameter

request

Object

The request object that will be sent.

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

Returns

Promise 

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

Example

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

var client = new dlp.v2beta1.DlpServiceClient({
  // optional auth parameters.
});

var formattedName = client.resultPath('[RESULT]');
client.listInspectFindings({name: formattedName})
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

listRootCategories

listRootCategories(request, options, callback) returns Promise

Returns the list of root categories of sensitive information.

Parameter

request

Object

The request object that will be sent.

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

Returns

Promise 

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

Example

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

var client = new dlp.v2beta1.DlpServiceClient({
  // optional auth parameters.
});

var languageCode = 'en';
client.listRootCategories({languageCode: languageCode})
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

matchResultFromResultName

matchResultFromResultName(resultName) returns String

Parse the resultName from a result resource.

Parameter

resultName

String

A fully-qualified path representing a result resources.

Returns

String 

  • A string representing the result.

redactContent

redactContent(request, options, callback) returns Promise

Redacts potentially sensitive info from a list of strings. This method has limits on input size, processing time, and output size.

Parameter

request

Object

The request object that will be sent.

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

Returns

Promise 

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

Example

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

var client = new dlp.v2beta1.DlpServiceClient({
  // optional auth parameters.
});

var name = 'EMAIL_ADDRESS';
var infoTypesElement = {
  name: name,
};
var infoTypes = [infoTypesElement];
var inspectConfig = {
  infoTypes: infoTypes,
};
var type = 'text/plain';
var value = 'My email is example@example.com.';
var itemsElement = {
  type: type,
  value: value,
};
var items = [itemsElement];
var request = {
  inspectConfig: inspectConfig,
  items: items,
};
client.redactContent(request)
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

resultPath

resultPath(result) returns String

Return a fully-qualified result resource name string.

Parameter

result

String

Returns

String