How to use the @google-cloud/dlp.DlpServiceClient function in @google-cloud/dlp

To help you get started, we’ve selected a few @google-cloud/dlp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GoogleCloudPlatform / node-red-contrib-google-cloud / dlp.js View on Github external
node.error(e.details);
                } else {
                    console.log(e);
                }
            }
        } // Input


        // We must have EITHER credentials or a keyFilename.  If neither are supplied, that
        // is an error.  If both are supplied, then credentials will be used.
        if (credentials) {
            dlpServiceClient = new DLP.DlpServiceClient({
                "credentials": credentials
            });
        } else if (keyFilename) {
            dlpServiceClient = new DLP.DlpServiceClient({
                "keyFilename": keyFilename
            });
        } else {
            dlpServiceClient = new DLP.DlpServiceClient({});
        }

        node.on("input", Input);
    } // DLPNode
github googleapis / nodejs-dlp / samples / triggers.js View on Github external
async function deleteTrigger(triggerId) {
  // [START dlp_delete_trigger]
  // Imports the Google Cloud Data Loss Prevention library
  const DLP = require('@google-cloud/dlp');

  // Instantiates a client
  const dlp = new DLP.DlpServiceClient();

  // The name of the trigger to be deleted
  // Parent project ID is automatically extracted from this parameter
  // const triggerId = 'projects/my-project/triggers/my-trigger';

  // Construct trigger deletion request
  const request = {
    name: triggerId,
  };
  try {
    // Run trigger deletion request
    await dlp.deleteJobTrigger(request);
    console.log(`Successfully deleted trigger ${triggerId}.`);
  } catch (err) {
    console.log(`Error in deleteTrigger: ${err.message || err}`);
  }
github googleapis / nodejs-dlp / samples / jobs.js View on Github external
function deleteJob(jobName) {
  // [START dlp_delete_job]
  // Imports the Google Cloud Data Loss Prevention library
  const DLP = require('@google-cloud/dlp');

  // Instantiates a client
  const dlp = new DLP.DlpServiceClient();

  // The name of the job whose results should be deleted
  // Parent project ID is automatically extracted from this parameter
  // const jobName = 'projects/my-project/dlpJobs/X-#####'

  // Construct job deletion request
  const request = {
    name: jobName,
  };

  // Run job deletion request
  dlp
    .deleteDlpJob(request)
    .then(() => {
      console.log(`Successfully deleted job ${jobName}.`);
    })
github googleapis / nodejs-dlp / samples / deid.js View on Github external
async function deidentifyWithFpe(
  callingProjectId,
  string,
  alphabet,
  surrogateType,
  keyName,
  wrappedKey
) {
  // [START dlp_deidentify_fpe]
  // Imports the Google Cloud Data Loss Prevention library
  const DLP = require('@google-cloud/dlp');

  // Instantiates a client
  const dlp = new DLP.DlpServiceClient();

  // The project ID to run the API call under
  // const callingProjectId = process.env.GCLOUD_PROJECT;

  // The string to deidentify
  // const string = 'My SSN is 372819127';

  // The set of characters to replace sensitive ones with
  // For more information, see https://cloud.google.com/dlp/docs/reference/rest/v2/organizations.deidentifyTemplates#ffxcommonnativealphabet
  // const alphabet = 'ALPHA_NUMERIC';

  // The name of the Cloud KMS key used to encrypt ('wrap') the AES-256 key
  // const keyName = 'projects/YOUR_GCLOUD_PROJECT/locations/YOUR_LOCATION/keyRings/YOUR_KEYRING_NAME/cryptoKeys/YOUR_KEY_NAME';

  // The encrypted ('wrapped') AES-256 key to use
  // This key should be encrypted using the Cloud KMS key specified above
github googleapis / nodejs-dlp / samples / inspect.js View on Github external
bucketName,
  fileName,
  topicId,
  subscriptionId,
  minLikelihood,
  maxFindings,
  infoTypes,
  customInfoTypes
) {
  // [START dlp_inspect_gcs]
  // Import the Google Cloud client libraries
  const DLP = require('@google-cloud/dlp');
  const {PubSub} = require('@google-cloud/pubsub');

  // Instantiates clients
  const dlp = new DLP.DlpServiceClient();
  const pubsub = new PubSub();

  // The project ID to run the API call under
  // const callingProjectId = process.env.GCLOUD_PROJECT;

  // The name of the bucket where the file resides.
  // const bucketName = 'YOUR-BUCKET';

  // The path to the file within the bucket to inspect.
  // Can contain wildcards, e.g. "my-image.*"
  // const fileName = 'my-image.png';

  // The minimum likelihood required before returning a match
  // const minLikelihood = 'LIKELIHOOD_UNSPECIFIED';

  // The maximum number of findings to report per request (0 = server maximum)
github googleapis / nodejs-dlp / samples / quickstart.js View on Github external
async function quickStart() {
  // [START dlp_quickstart]

  // Instantiates a client
  const dlp = new DLP.DlpServiceClient();

  // The string to inspect
  const string = 'Robert Frost';

  // The project ID to run the API call under
  const projectId = process.env.GCLOUD_PROJECT;

  // The minimum likelihood required before returning a match
  const minLikelihood = 'LIKELIHOOD_UNSPECIFIED';

  // The maximum number of findings to report (0 = server maximum)
  const maxFindings = 0;

  // The infoTypes of information to match
  const infoTypes = [{name: 'PERSON_NAME'}, {name: 'US_STATE'}];
github googleapis / nodejs-speech / samples / speech-to-text-to-dlp.js View on Github external
async function deidentifyText(transcription) {
    // Creates a DLP Service Client
    const dlpClient = new DLP.DlpServiceClient();

    // Construct DLP request
    const item = {value: transcription};

    const infoTypes = [
      {name: 'PHONE_NUMBER'},
      {name: 'EMAIL_ADDRESS'},
      {name: 'CREDIT_CARD_NUMBER'},
      {name: 'US_SOCIAL_SECURITY_NUMBER'},
    ];

    const primitiveTransformation = {
      replaceWithInfoTypeConfig: {},
    };

    const transformations = [
github googleapis / nodejs-dlp / samples / risk.js View on Github external
async function kAnonymityAnalysis(
  callingProjectId,
  tableProjectId,
  datasetId,
  tableId,
  topicId,
  subscriptionId,
  quasiIds
) {
  // [START dlp_k_anonymity]
  // Import the Google Cloud client libraries
  const DLP = require('@google-cloud/dlp');
  const {PubSub} = require('@google-cloud/pubsub');

  // Instantiates clients
  const dlp = new DLP.DlpServiceClient();
  const pubsub = new PubSub();

  // The project ID to run the API call under
  // const callingProjectId = process.env.GCLOUD_PROJECT;

  // The project ID the table is stored under
  // This may or (for public datasets) may not equal the calling project ID
  // const tableProjectId = process.env.GCLOUD_PROJECT;

  // The ID of the dataset to inspect, e.g. 'my_dataset'
  // const datasetId = 'my_dataset';

  // The ID of the table to inspect, e.g. 'my_table'
  // const tableId = 'my_table';

  // The name of the Pub/Sub topic to notify once the job completes
github googleapis / nodejs-dlp / samples / templates.js View on Github external
async function createInspectTemplate(
  callingProjectId,
  templateId,
  displayName,
  infoTypes,
  includeQuote,
  minLikelihood,
  maxFindings
) {
  // [START dlp_create_inspect_template]
  // Imports the Google Cloud Data Loss Prevention library
  const DLP = require('@google-cloud/dlp');

  // Instantiates a client
  const dlp = new DLP.DlpServiceClient();

  // The project ID to run the API call under
  // const callingProjectId = process.env.GCLOUD_PROJECT;

  // The minimum likelihood required before returning a match
  // const minLikelihood = 'LIKELIHOOD_UNSPECIFIED';

  // The maximum number of findings to report per request (0 = server maximum)
  // const maxFindings = 0;

  // The infoTypes of information to match
  // const infoTypes = [{ name: 'PHONE_NUMBER' }, { name: 'EMAIL_ADDRESS' }, { name: 'CREDIT_CARD_NUMBER' }];

  // Whether to include the matching string
  // const includeQuote = true;
github googleapis / nodejs-dlp / samples / risk.js View on Github external
callingProjectId,
  tableProjectId,
  datasetId,
  tableId,
  topicId,
  subscriptionId,
  sensitiveAttribute,
  quasiIds
) {
  // [START dlp_l_diversity]
  // Import the Google Cloud client libraries
  const DLP = require('@google-cloud/dlp');
  const {PubSub} = require('@google-cloud/pubsub');

  // Instantiates clients
  const dlp = new DLP.DlpServiceClient();
  const pubsub = new PubSub();

  // The project ID to run the API call under
  // const callingProjectId = process.env.GCLOUD_PROJECT;

  // The project ID the table is stored under
  // This may or (for public datasets) may not equal the calling project ID
  // const tableProjectId = process.env.GCLOUD_PROJECT;

  // The ID of the dataset to inspect, e.g. 'my_dataset'
  // const datasetId = 'my_dataset';

  // The ID of the table to inspect, e.g. 'my_table'
  // const tableId = 'my_table';

  // The name of the Pub/Sub topic to notify once the job completes

@google-cloud/dlp

DLP API client for Node.js

Apache-2.0
Latest version published 29 days ago

Package Health Score

92 / 100
Full package analysis

Popular @google-cloud/dlp functions