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

samples: update sample to use protos, until typing can be fixed #311

Merged
merged 5 commits into from
Jun 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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