MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / inspectGCSSendToScc

Function inspectGCSSendToScc

dlp/inspectGcsSendToScc.js:35–117  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33 // const gcsPath = 'gcs-file-path';
34
35 async function inspectGCSSendToScc() {
36 // Specify the storage configuration object with GCS URL.
37 const storageConfig = {
38 cloudStorageOptions: {
39 fileSet: {
40 url: gcsPath,
41 },
42 },
43 };
44
45 // Construct the info types to look for in the GCS file.
46 const infoTypes = [
47 {name: 'EMAIL_ADDRESS'},
48 {name: 'PERSON_NAME'},
49 {name: 'LOCATION'},
50 {name: 'PHONE_NUMBER'},
51 ];
52
53 // Construct the inspection configuration.
54 const inspectConfig = {
55 infoTypes,
56 minLikelihood: DLP.protos.google.privacy.dlp.v2.Likelihood.UNLIKELY,
57 limits: {
58 maxFindingsPerItem: 100,
59 },
60 };
61
62 // Specify the action that is triggered when the job completes.
63 const action = {
64 publishSummaryToCscc: {},
65 };
66
67 // Configure the inspection job we want the service to perform.
68 const jobConfig = {
69 inspectConfig,
70 storageConfig,
71 actions: [action],
72 };
73
74 // Construct the job creation request to be sent by the client.
75 const request = {
76 parent: `projects/${projectId}/locations/global`,
77 inspectJob: jobConfig,
78 };
79
80 // Send the job creation request and process the response.
81 const [jobsResponse] = await dlpClient.createDlpJob(request);
82 const jobName = jobsResponse.name;
83
84 // Waiting for a maximum of 15 minutes for the job to get complete.
85 let job;
86 let numOfAttempts = 30;
87 while (numOfAttempts > 0) {
88 // Fetch DLP Job status
89 [job] = await dlpClient.getDlpJob({name: jobName});
90
91 // Check if the job has completed.
92 if (job.state === 'DONE') {

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected