Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.

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 <bencoe@google.com>
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
juffalow authored Jun 20, 2022
1 parent 34a4589 commit bef8ba7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 6 additions & 2 deletions 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 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 bef8ba7

Please sign in to comment.