Skip to content

Commit

Permalink
samples: update sample to use protos, until typing can be fixed (#311)
Browse files Browse the repository at this point in the history
See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md
Co-authored-by: Benjamin E. Coe <[email protected]>
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
juffalow authored Jun 20, 2022
1 parent 5c48422 commit 3e6e9dd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 6 additions & 2 deletions packages/google-cloud-webrisk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,18 @@ npm install @google-cloud/web-risk
*/
async function quickstart(uri) {
// Create the WebRisk client library.
const {WebRiskServiceClient} = require('@google-cloud/web-risk');
const {WebRiskServiceClient, protos} = require('@google-cloud/web-risk');
const client = new WebRiskServiceClient();

// Create an API request to check for malware, social engineering,
// and unwanted software.
const request = {
uri: uri,
threatTypes: ['MALWARE', 'SOCIAL_ENGINEERING', 'UNWANTED_SOFTWARE'],
threatTypes: [
protos.google.cloud.webrisk.v1.ThreatType.MALWARE,
protos.google.cloud.webrisk.v1.ThreatType.SOCIAL_ENGINEERING,
protos.google.cloud.webrisk.v1.ThreatType.UNWANTED_SOFTWARE,
],
};

// call the WebRisk searchUris API.
Expand Down
9 changes: 7 additions & 2 deletions packages/google-cloud-webrisk/samples/quickstart.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,26 @@

'use strict';

// TODO: revert threat types to strings once https://github.com/googleapis/gax-nodejs/issues/1205 is fixed
// [START web_risk_quickstart]
/**
* Check a URI against the WebRisk API.
* @param {string} uri A URI to pass to the Web Risk API.
*/
async function quickstart(uri) {
// Create the WebRisk client library.
const {WebRiskServiceClient} = require('@google-cloud/web-risk');
const {WebRiskServiceClient, protos} = require('@google-cloud/web-risk');
const client = new WebRiskServiceClient();

// Create an API request to check for malware, social engineering,
// and unwanted software.
const request = {
uri: uri,
threatTypes: ['MALWARE', 'SOCIAL_ENGINEERING', 'UNWANTED_SOFTWARE'],
threatTypes: [
protos.google.cloud.webrisk.v1.ThreatType.MALWARE,
protos.google.cloud.webrisk.v1.ThreatType.SOCIAL_ENGINEERING,
protos.google.cloud.webrisk.v1.ThreatType.UNWANTED_SOFTWARE,
],
};

// call the WebRisk searchUris API.
Expand Down

0 comments on commit 3e6e9dd

Please sign in to comment.