Constructor

DlpServiceClient

new DlpServiceClient(options)

Construct an instance of DlpServiceClient.

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 usaing 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 above 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

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.

Values in request have the following properties:

Parameter

privacyMetric

Object

Privacy metric to compute.

This object should have the same structure as PrivacyMetric

sourceTable

Object

Input dataset to compute metrics over.

This object should have the same structure as BigQueryTable

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.

Values in request have the following properties:

Parameter

inspectConfig

Object

Configuration for the inspector.

This object should have the same structure as InspectConfig

storageConfig

Object

Specification of the data set to process.

This object should have the same structure as StorageConfig

outputConfig

Object

Optional location to store findings.

This object should have the same structure as OutputStorageConfig

operationConfig

Optional

Object

Additional configuration settings for long running operations.

This object should have the same structure as OperationConfig

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.

Values in request have the following properties:

Parameter

deidentifyConfig

Object

Configuration for the de-identification of the list of content items.

This object should have the same structure as DeidentifyConfig

inspectConfig

Object

Configuration for the inspector.

This object should have the same structure as InspectConfig

items

Array of Object

The list of items to inspect. Up to 100 are allowed per request. All items will be treated as text/*.

This object should have the same structure as ContentItem

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.

Values in request have the following properties:

Parameter

inspectConfig

Object

Configuration for the inspector.

This object should have the same structure as InspectConfig

items

Array of Object

The list of items to inspect. Items in a single request are considered "related" unless inspect_config.independent_inputs is true. Up to 100 are allowed per request.

This object should have the same structure as ContentItem

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.

Values in request have the following properties:

Parameter

category

string

Category name as returned by ListRootCategories.

languageCode

string

Optional BCP-47 language code for localized info type friendly names. If omitted, or if localized strings are not available, en-US strings will be returned.

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.

Values in request have the following properties:

Parameter

name

string

Identifier of the results set returned as metadata of the longrunning operation created by a call to InspectDataSource. Should be in the format of inspect/results/{id}.

pageSize

Optional

number

Maximum number of results to return. If 0, the implementation selects a reasonable value.

pageToken

Optional

string

The value returned by the last ListInspectFindingsResponse; indicates that this is a continuation of a prior ListInspectFindings call, and that the system should return the next page of data.

filter

Optional

string

Restricts findings to items that match. Supports info_type and likelihood.

Examples:

  • info_type=EMAIL_ADDRESS
  • info_type=PHONE_NUMBER,EMAIL_ADDRESS
  • likelihood=VERY_LIKELY
  • likelihood=VERY_LIKELY,LIKELY
  • info_type=EMAIL_ADDRESS,likelihood=VERY_LIKELY,LIKELY

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.

Values in request have the following properties:

Parameter

languageCode

string

Optional language code for localized friendly category names. If omitted or if localized strings are not available, en-US strings will be returned.

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.

Values in request have the following properties:

Parameter

inspectConfig

Object

Configuration for the inspector.

This object should have the same structure as InspectConfig

items

Array of Object

The list of items to inspect. Up to 100 are allowed per request.

This object should have the same structure as ContentItem

replaceConfigs

Array of Object

The strings to replace findings text findings with. Must specify at least one of these or one ImageRedactionConfig if redacting images.

This object should have the same structure as ReplaceConfig

imageRedactionConfigs

Optional

Array of Object

The configuration for specifying what content to redact from images.

This object should have the same structure as ImageRedactionConfig

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 name2 = 'EMAIL_ADDRESS';
var infoType = {
  name: name2,
};
var replaceWith = 'REDACTED';
var replaceConfigsElement = {
  infoType: infoType,
  replaceWith: replaceWith,
};
var replaceConfigs = [replaceConfigsElement];
var request = {
  inspectConfig: inspectConfig,
  items: items,
  replaceConfigs: replaceConfigs,
};
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