Skip to content

Commit

Permalink
feat!: drop node8 support, support for async iterators (#440)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: The library now supports Node.js v10+. The last version to support Node.js v8 is tagged legacy-8 on NPM.

New feature: methods with pagination now support async iteration.
  • Loading branch information
alexander-fenster authored Mar 31, 2020
1 parent 655fddf commit a249f95
Show file tree
Hide file tree
Showing 12 changed files with 114 additions and 114 deletions.
28 changes: 14 additions & 14 deletions dlp/deid.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,11 +402,11 @@ async function reidentifyWithFpe(
// [END dlp_reidentify_fpe]
}

const cli = require(`yargs`)
const cli = require('yargs')
.demand(1)
.command(
`deidMask <string>`,
`Deidentify sensitive data in a string by masking it with a character.`,
'deidMask <string>',
'Deidentify sensitive data in a string by masking it with a character.',
{
maskingCharacter: {
type: 'string',
Expand All @@ -428,8 +428,8 @@ const cli = require(`yargs`)
)
)
.command(
`deidFpe <string> <wrappedKey> <keyName>`,
`Deidentify sensitive data in a string using Format Preserving Encryption (FPE).`,
'deidFpe <string> <wrappedKey> <keyName>',
'Deidentify sensitive data in a string using Format Preserving Encryption (FPE).',
{
alphabet: {
type: 'string',
Expand Down Expand Up @@ -459,8 +459,8 @@ const cli = require(`yargs`)
)
)
.command(
`reidFpe <string> <surrogateType> <wrappedKey> <keyName>`,
`Reidentify sensitive data in a string using Format Preserving Encryption (FPE).`,
'reidFpe <string> <surrogateType> <wrappedKey> <keyName>',
'Reidentify sensitive data in a string using Format Preserving Encryption (FPE).',
{
alphabet: {
type: 'string',
Expand All @@ -485,8 +485,8 @@ const cli = require(`yargs`)
)
)
.command(
`deidDateShift <inputCsvFile> <outputCsvFile> <lowerBoundDays> <upperBoundDays> [dateFields...]`,
`Deidentify dates in a CSV file by pseudorandomly shifting them.`,
'deidDateShift <inputCsvFile> <outputCsvFile> <lowerBoundDays> <upperBoundDays> [dateFields...]',
'Deidentify dates in a CSV file by pseudorandomly shifting them.',
{
contextFieldId: {
type: 'string',
Expand Down Expand Up @@ -524,19 +524,19 @@ const cli = require(`yargs`)
alias: 'callingProjectId',
default: process.env.GCLOUD_PROJECT || '',
})
.example(`node $0 deidMask "My SSN is 372819127"`)
.example('node $0 deidMask "My SSN is 372819127"')
.example(
`node $0 deidFpe "My SSN is 372819127" <YOUR_ENCRYPTED_AES_256_KEY> projects/my-project/locations/global/keyrings/my-keyring -s SSN_TOKEN`
'node $0 deidFpe "My SSN is 372819127" <YOUR_ENCRYPTED_AES_256_KEY> projects/my-project/locations/global/keyrings/my-keyring -s SSN_TOKEN'
)
.example(
`node $0 reidFpe "My SSN is SSN_TOKEN(9):#########" <YOUR_ENCRYPTED_AES_256_KEY> projects/my-project/locations/global/keyrings/my-keyring SSN_TOKEN -a NUMERIC`
'node $0 reidFpe "My SSN is SSN_TOKEN(9):#########" <YOUR_ENCRYPTED_AES_256_KEY> projects/my-project/locations/global/keyrings/my-keyring SSN_TOKEN -a NUMERIC'
)
.example(
`node $0 deidDateShift dates.csv dates-shifted.csv 30 30 birth_date register_date [-w <YOUR_ENCRYPTED_AES_256_KEY> -n projects/my-project/locations/global/keyrings/my-keyring]`
'node $0 deidDateShift dates.csv dates-shifted.csv 30 30 birth_date register_date [-w <YOUR_ENCRYPTED_AES_256_KEY> -n projects/my-project/locations/global/keyrings/my-keyring]'
)
.wrap(120)
.recommendCommands()
.epilogue(`For more information, see https://cloud.google.com/dlp/docs.`);
.epilogue('For more information, see https://cloud.google.com/dlp/docs.');

if (module === require.main) {
cli.help().strict().argv; // eslint-disable-line
Expand Down
52 changes: 26 additions & 26 deletions dlp/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ async function inspectString(
const [response] = await dlp.inspectContent(request);
const findings = response.result.findings;
if (findings.length > 0) {
console.log(`Findings:`);
console.log('Findings:');
findings.forEach(finding => {
if (includeQuote) {
console.log(`\tQuote: ${finding.quote}`);
Expand All @@ -84,7 +84,7 @@ async function inspectString(
console.log(`\tLikelihood: ${finding.likelihood}`);
});
} else {
console.log(`No findings.`);
console.log('No findings.');
}
} catch (err) {
console.log(`Error in inspectString: ${err.message || err}`);
Expand Down Expand Up @@ -168,7 +168,7 @@ async function inspectFile(
const [response] = await dlp.inspectContent(request);
const findings = response.result.findings;
if (findings.length > 0) {
console.log(`Findings:`);
console.log('Findings:');
findings.forEach(finding => {
if (includeQuote) {
console.log(`\tQuote: ${finding.quote}`);
Expand All @@ -177,7 +177,7 @@ async function inspectFile(
console.log(`\tLikelihood: ${finding.likelihood}`);
});
} else {
console.log(`No findings.`);
console.log('No findings.');
}
} catch (err) {
console.log(`Error in inspectFile: ${err.message || err}`);
Expand Down Expand Up @@ -300,7 +300,7 @@ async function inspectGCSFile(
});

setTimeout(() => {
console.log(`Waiting for DLP job to fully complete`);
console.log('Waiting for DLP job to fully complete');
}, 500);
const [job] = await dlp.getDlpJob({name: jobName});
console.log(`Job ${job.name} status: ${job.state}`);
Expand All @@ -313,7 +313,7 @@ async function inspectGCSFile(
);
});
} else {
console.log(`No findings.`);
console.log('No findings.');
}
} catch (err) {
console.log(`Error in inspectGCSFile: ${err.message || err}`);
Expand Down Expand Up @@ -446,7 +446,7 @@ async function inspectDatastore(
});
// Wait for DLP job to fully complete
setTimeout(() => {
console.log(`Waiting for DLP job to fully complete`);
console.log('Waiting for DLP job to fully complete');
}, 500);
const [job] = await dlp.getDlpJob({name: jobName});
console.log(`Job ${job.name} status: ${job.state}`);
Expand All @@ -459,7 +459,7 @@ async function inspectDatastore(
);
});
} else {
console.log(`No findings.`);
console.log('No findings.');
}
} catch (err) {
console.log(`Error in inspectDatastore: ${err.message || err}`);
Expand Down Expand Up @@ -590,7 +590,7 @@ async function inspectBigquery(
});
// Wait for DLP job to fully complete
setTimeout(() => {
console.log(`Waiting for DLP job to fully complete`);
console.log('Waiting for DLP job to fully complete');
}, 500);
const [job] = await dlp.getDlpJob({name: jobName});
console.log(`Job ${job.name} status: ${job.state}`);
Expand All @@ -603,7 +603,7 @@ async function inspectBigquery(
);
});
} else {
console.log(`No findings.`);
console.log('No findings.');
}
} catch (err) {
console.log(`Error in inspectBigquery: ${err.message || err}`);
Expand All @@ -615,8 +615,8 @@ async function inspectBigquery(
const cli = require(`yargs`) // eslint-disable-line
.demand(1)
.command(
`string <string>`,
`Inspect a string using the Data Loss Prevention API.`,
'string <string>',
'Inspect a string using the Data Loss Prevention API.',
{},
opts =>
inspectString(
Expand All @@ -630,8 +630,8 @@ const cli = require(`yargs`) // eslint-disable-line
)
)
.command(
`file <filepath>`,
`Inspects a local text, PNG, or JPEG file using the Data Loss Prevention API.`,
'file <filepath>',
'Inspects a local text, PNG, or JPEG file using the Data Loss Prevention API.',
{},
opts =>
inspectFile(
Expand All @@ -645,8 +645,8 @@ const cli = require(`yargs`) // eslint-disable-line
)
)
.command(
`gcsFile <bucketName> <fileName> <topicId> <subscriptionId>`,
`Inspects a text file stored on Google Cloud Storage with the Data Loss Prevention API, using Pub/Sub for job notifications.`,
'gcsFile <bucketName> <fileName> <topicId> <subscriptionId>',
'Inspects a text file stored on Google Cloud Storage with the Data Loss Prevention API, using Pub/Sub for job notifications.',
{},
opts =>
inspectGCSFile(
Expand All @@ -662,8 +662,8 @@ const cli = require(`yargs`) // eslint-disable-line
)
)
.command(
`bigquery <datasetName> <tableName> <topicId> <subscriptionId>`,
`Inspects a BigQuery table using the Data Loss Prevention API using Pub/Sub for job notifications.`,
'bigquery <datasetName> <tableName> <topicId> <subscriptionId>',
'Inspects a BigQuery table using the Data Loss Prevention API using Pub/Sub for job notifications.',
{},
opts => {
inspectBigquery(
Expand All @@ -681,8 +681,8 @@ const cli = require(`yargs`) // eslint-disable-line
}
)
.command(
`datastore <kind> <topicId> <subscriptionId>`,
`Inspect a Datastore instance using the Data Loss Prevention API using Pub/Sub for job notifications.`,
'datastore <kind> <topicId> <subscriptionId>',
'Inspect a Datastore instance using the Data Loss Prevention API using Pub/Sub for job notifications.',
{
namespaceId: {
type: 'string',
Expand Down Expand Up @@ -781,15 +781,15 @@ const cli = require(`yargs`) // eslint-disable-line
type: 'string',
global: true,
})
.example(`node $0 string "My email address is me@somedomain.com"`)
.example(`node $0 file resources/test.txt`)
.example(`node $0 gcsFile my-bucket my-file.txt my-topic my-subscription`)
.example(`node $0 bigquery my-dataset my-table my-topic my-subscription`)
.example(`node $0 datastore my-datastore-kind my-topic my-subscription`)
.example('node $0 string "My email address is me@somedomain.com"')
.example('node $0 file resources/test.txt')
.example('node $0 gcsFile my-bucket my-file.txt my-topic my-subscription')
.example('node $0 bigquery my-dataset my-table my-topic my-subscription')
.example('node $0 datastore my-datastore-kind my-topic my-subscription')
.wrap(120)
.recommendCommands()
.epilogue(
`For more information, see https://cloud.google.com/dlp/docs. Optional flags are explained at https://cloud.google.com/dlp/docs/reference/rest/v2/InspectConfig`
'For more information, see https://cloud.google.com/dlp/docs. Optional flags are explained at https://cloud.google.com/dlp/docs/reference/rest/v2/InspectConfig'
);

if (module === require.main) {
Expand Down
14 changes: 7 additions & 7 deletions dlp/jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ function deleteJob(jobName) {
const cli = require(`yargs`) // eslint-disable-line
.demand(1)
.command(
`list <filter>`,
`List Data Loss Prevention API jobs corresponding to a given filter.`,
'list <filter>',
'List Data Loss Prevention API jobs corresponding to a given filter.',
{
jobType: {
type: 'string',
Expand All @@ -98,8 +98,8 @@ const cli = require(`yargs`) // eslint-disable-line
opts => listJobs(opts.callingProject, opts.filter, opts.jobType)
)
.command(
`delete <jobName>`,
`Delete results of a Data Loss Prevention API job.`,
'delete <jobName>',
'Delete results of a Data Loss Prevention API job.',
{},
opts => deleteJob(opts.jobName)
)
Expand All @@ -108,11 +108,11 @@ const cli = require(`yargs`) // eslint-disable-line
alias: 'callingProject',
default: process.env.GCLOUD_PROJECT || '',
})
.example(`node $0 list "state=DONE" -t RISK_ANALYSIS_JOB`)
.example(`node $0 delete projects/YOUR_GCLOUD_PROJECT/dlpJobs/X-#####`)
.example('node $0 list "state=DONE" -t RISK_ANALYSIS_JOB')
.example('node $0 delete projects/YOUR_GCLOUD_PROJECT/dlpJobs/X-#####')
.wrap(120)
.recommendCommands()
.epilogue(`For more information, see https://cloud.google.com/dlp/docs.`);
.epilogue('For more information, see https://cloud.google.com/dlp/docs.');

if (module === require.main) {
cli.help().strict().argv; // eslint-disable-line
Expand Down
12 changes: 6 additions & 6 deletions dlp/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ async function listInfoTypes(languageCode, filter) {
filter: filter,
});
const infoTypes = response.infoTypes;
console.log(`Info types:`);
console.log('Info types:');
infoTypes.forEach(infoType => {
console.log(`\t${infoType.name} (${infoType.displayName})`);
});

// [END dlp_list_info_types]
}

const cli = require(`yargs`)
const cli = require('yargs')
.demand(1)
.command(
`infoTypes [filter]`,
`List the types of sensitive information the DLP API supports.`,
'infoTypes [filter]',
'List the types of sensitive information the DLP API supports.',
{},
opts => listInfoTypes(opts.languageCode, opts.filter)
)
Expand All @@ -55,10 +55,10 @@ const cli = require(`yargs`)
type: 'string',
global: true,
})
.example(`node $0 infoTypes "supported_by=INSPECT"`)
.example('node $0 infoTypes "supported_by=INSPECT"')
.wrap(120)
.recommendCommands()
.epilogue(`For more information, see https://cloud.google.com/dlp/docs`);
.epilogue('For more information, see https://cloud.google.com/dlp/docs');

if (module === require.main) {
cli.help().strict().argv; // eslint-disable-line
Expand Down
4 changes: 2 additions & 2 deletions dlp/quickstart.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async function quickStart() {
const [response] = await dlp.inspectContent(request);
const findings = response.result.findings;
if (findings.length > 0) {
console.log(`Findings:`);
console.log('Findings:');
findings.forEach(finding => {
if (includeQuote) {
console.log(`\tQuote: ${finding.quote}`);
Expand All @@ -71,7 +71,7 @@ async function quickStart() {
console.log(`\tLikelihood: ${finding.likelihood}`);
});
} else {
console.log(`No findings.`);
console.log('No findings.');
}
// [END dlp_quickstart]
}
Expand Down
14 changes: 7 additions & 7 deletions dlp/redact.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ async function redactImage(
// [END dlp_redact_image]
}

const cli = require(`yargs`)
const cli = require('yargs')
.demand(1)
.command(
`string <string>`,
`Redact a string using the Data Loss Prevention API.`,
'string <string>',
'Redact a string using the Data Loss Prevention API.',
{},
opts =>
redactText(
Expand All @@ -145,8 +145,8 @@ const cli = require(`yargs`)
)
)
.command(
`image <filepath> <outputPath>`,
`Redact sensitive data from an image using the Data Loss Prevention API.`,
'image <filepath> <outputPath>',
'Redact sensitive data from an image using the Data Loss Prevention API.',
{},
opts =>
redactImage(
Expand Down Expand Up @@ -187,11 +187,11 @@ const cli = require(`yargs`)
type: 'string',
global: true,
})
.example(`node $0 image resources/test.png result.png -t MALE_NAME`)
.example('node $0 image resources/test.png result.png -t MALE_NAME')
.wrap(120)
.recommendCommands()
.epilogue(
`For more information, see https://cloud.google.com/dlp/docs. Optional flags are explained at https://cloud.google.com/dlp/docs/reference/rest/v2/projects.image/redact#ImageRedactionConfig`
'For more information, see https://cloud.google.com/dlp/docs. Optional flags are explained at https://cloud.google.com/dlp/docs/reference/rest/v2/projects.image/redact#ImageRedactionConfig'
);

if (module === require.main) {
Expand Down
Loading

0 comments on commit a249f95

Please sign in to comment.