Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move DLP from REST to gRPC + client libraries #413

Merged
merged 3 commits into from
Jun 30, 2017
Merged

Move DLP from REST to gRPC + client libraries #413

merged 3 commits into from
Jun 30, 2017

Conversation

ace-n
Copy link
Contributor

@ace-n ace-n commented Jun 30, 2017

No description provided.

Change-Id: Iaa03400842667a478e9e29e87ba36fcbda257d60
@ace-n ace-n requested review from theacodes and jmdobry June 30, 2017 19:33
dlp/inspect.js Outdated
'Authorization': `Bearer ${authToken}`,
'Content-Type': 'application/json'
// Create a GCS File inspection job, and resolve it using promises
// TODO: is the client library going to handle pagination if no user settings are specified?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODOs?

Change-Id: I7fdc39e1528dd222c6795c70cce972efc5c60e1c
dlp/inspect.js Outdated
.then((findingsBody) => {
const findings = findingsBody.result.findings;
console.log(JSON.stringify(findings, null, 2));
// Create a GCS File inspection job, and resolve it using event handlers

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latter part of this comment seems unhelpful. Would it be better to say:

// Create an operation to instance the data in Google Cloud Storage,
// wait for it to complete, then list the findings.

dlp/inspect.js Outdated
// TODO this doesn't produce meaningful results
});

// Handle job errors

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is obvious.

return resolve(completeJobResponse);
});

// Handle changes in job metadata (e.g. progress updates)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is also obvious.

dlp/inspect.js Outdated

// Handle changes in job metadata (e.g. progress updates)
operation.on('progress', (metadata) => {
// TODO this doesn't produce meaningful results

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this does nothing, why not just leave it out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This provides (and prints out) semi-meaningful results now.

Copy link

@theacodes theacodes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks mostly fine except for the TODOs and the mostly obvious comments.

Comments should say why you're doing something, not what you're doing.

dlp/inspect.js Outdated
})
.catch((err) => {
console.log('Error in inspectString:', err);
console.log('Error in inspectString:', err.message || err);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Why not: Error in inspectString: ${err.message || err} to be consistent with other logging style.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment throughout, since this catch block is copy-pasted

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done - will address.

dlp/inspect.js Outdated
dlp.createInspectOperation(request)
.then((createJobResponse) => {
const operation = createJobResponse[0];
return new Promise((resolve, reject) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between this construct and just operation.promise() which you used above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This uses event handlers - and I wanted to avoid "callback hell".

(If you think the nested callback approach would be better idiomatically vs. mixing promises and event handlers, I'm happy to switch to it.)

category: category,
languageCode: languageCode
})
.then((body) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the type of body? In other then blocks you use more descriptive names like createJobResponse

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps apiResponse would be a better name here - WDYT?

(Something like listInfoTypesResponse seems a little long-winded.)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either one SGTM

})
.then((body) => {
const infoTypes = body[0].infoTypes;
console.log(`Info types for category ${category}:`);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any possibility of infoTypes being empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having a valid category without valid info types is the only way I can see to trigger this. (Invalid categories are detected outside this sample and the resulting errors are handled correctly.)

@codecov-io
Copy link

Codecov Report

Merging #413 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #413   +/-   ##
=======================================
  Coverage   83.88%   83.88%           
=======================================
  Files           4        4           
  Lines         422      422           
=======================================
  Hits          354      354           
  Misses         68       68

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 48733aa...b4d30ae. Read the comment docs.

@ace-n ace-n merged commit bf789f6 into master Jun 30, 2017
@ace-n ace-n deleted the dlp-vtk branch June 30, 2017 21:57
NimJay pushed a commit that referenced this pull request Nov 11, 2022
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
ace-n pushed a commit that referenced this pull request Nov 11, 2022
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
ahrarmonsur pushed a commit that referenced this pull request Nov 16, 2022
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: sofisl <55454395+sofisl@users.noreply.github.com>
ahrarmonsur pushed a commit that referenced this pull request Nov 16, 2022
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: sofisl <55454395+sofisl@users.noreply.github.com>
ahrarmonsur pushed a commit that referenced this pull request Nov 16, 2022
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: sofisl <55454395+sofisl@users.noreply.github.com>
ahrarmonsur pushed a commit that referenced this pull request Nov 16, 2022
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: sofisl <55454395+sofisl@users.noreply.github.com>
ahrarmonsur pushed a commit that referenced this pull request Nov 16, 2022
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: sofisl <55454395+sofisl@users.noreply.github.com>
ace-n pushed a commit that referenced this pull request Nov 17, 2022
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: sofisl <55454395+sofisl@users.noreply.github.com>
Shabirmean pushed a commit that referenced this pull request Feb 16, 2023
* Move DLP from REST to gRPC + client libraries

* Update package.json

* Address comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants