This repository has been archived by the owner on Sep 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathdlp_service_client.ts
5563 lines (5457 loc) · 208 KB
/
dlp_service_client.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
import * as gax from 'google-gax';
import {
Callback,
CallOptions,
Descriptors,
ClientOptions,
PaginationCallback,
GaxCall,
} from 'google-gax';
import * as path from 'path';
import {Transform} from 'stream';
import {RequestType} from 'google-gax/build/src/apitypes';
import * as protos from '../../protos/protos';
import * as gapicConfig from './dlp_service_client_config.json';
const version = require('../../../package.json').version;
/**
* The Cloud Data Loss Prevention (DLP) API is a service that allows clients
* to detect the presence of Personally Identifiable Information (PII) and other
* privacy-sensitive data in user-supplied, unstructured data streams, like text
* blocks or images.
* The service also includes methods for sensitive data redaction and
* scheduling of data scans on Google Cloud Platform based data sets.
*
* To learn more about concepts and find how-to guides see
* https://cloud.google.com/dlp/docs/.
* @class
* @memberof v2
*/
export class DlpServiceClient {
private _terminated = false;
private _opts: ClientOptions;
private _gaxModule: typeof gax | typeof gax.fallback;
private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient;
private _protos: {};
private _defaults: {[method: string]: gax.CallSettings};
auth: gax.GoogleAuth;
descriptors: Descriptors = {
page: {},
stream: {},
longrunning: {},
batching: {},
};
innerApiCalls: {[name: string]: Function};
pathTemplates: {[name: string]: gax.PathTemplate};
dlpServiceStub?: Promise<{[name: string]: Function}>;
/**
* Construct an instance of DlpServiceClient.
*
* @param {object} [options] - The configuration object. See the subsequent
* parameters for more details.
* @param {object} [options.credentials] - Credentials object.
* @param {string} [options.credentials.client_email]
* @param {string} [options.credentials.private_key]
* @param {string} [options.email] - Account email address. Required when
* using a .pem or .p12 keyFilename.
* @param {string} [options.keyFilename] - Full path to the a .json, .pem, or
* .p12 key downloaded from the Google Developers Console. If you provide
* a path to a JSON file, the projectId option below is not necessary.
* NOTE: .pem and .p12 require you to specify options.email as well.
* @param {number} [options.port] - The port on which to connect to
* the remote host.
* @param {string} [options.projectId] - The project ID from the Google
* Developer's Console, e.g. 'grape-spaceship-123'. We will also check
* the environment variable GCLOUD_PROJECT for your project ID. If your
* app is running in an environment which supports
* {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials},
* your project ID will be detected automatically.
* @param {string} [options.apiEndpoint] - The domain name of the
* API remote host.
*/
constructor(opts?: ClientOptions) {
// Ensure that options include the service address and port.
const staticMembers = this.constructor as typeof DlpServiceClient;
const servicePath =
opts && opts.servicePath
? opts.servicePath
: opts && opts.apiEndpoint
? opts.apiEndpoint
: staticMembers.servicePath;
const port = opts && opts.port ? opts.port : staticMembers.port;
if (!opts) {
opts = {servicePath, port};
}
opts.servicePath = opts.servicePath || servicePath;
opts.port = opts.port || port;
// users can override the config from client side, like retry codes name.
// The detailed structure of the clientConfig can be found here: https://github.com/googleapis/gax-nodejs/blob/master/src/gax.ts#L546
// The way to override client config for Showcase API:
//
// const customConfig = {"interfaces": {"google.showcase.v1beta1.Echo": {"methods": {"Echo": {"retry_codes_name": "idempotent", "retry_params_name": "default"}}}}}
// const showcaseClient = new showcaseClient({ projectId, customConfig });
opts.clientConfig = opts.clientConfig || {};
// If we're running in browser, it's OK to omit `fallback` since
// google-gax has `browser` field in its `package.json`.
// For Electron (which does not respect `browser` field),
// pass `{fallback: true}` to the DlpServiceClient constructor.
this._gaxModule = opts.fallback ? gax.fallback : gax;
// Create a `gaxGrpc` object, with any grpc-specific options
// sent to the client.
opts.scopes = (this.constructor as typeof DlpServiceClient).scopes;
this._gaxGrpc = new this._gaxModule.GrpcClient(opts);
// Save options to use in initialize() method.
this._opts = opts;
// Save the auth object to the client, for use by other methods.
this.auth = this._gaxGrpc.auth as gax.GoogleAuth;
// Determine the client header string.
const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
if (typeof process !== 'undefined' && 'versions' in process) {
clientHeader.push(`gl-node/${process.versions.node}`);
} else {
clientHeader.push(`gl-web/${this._gaxModule.version}`);
}
if (!opts.fallback) {
clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
}
if (opts.libName && opts.libVersion) {
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
}
// Load the applicable protos.
// For Node.js, pass the path to JSON proto file.
// For browsers, pass the JSON content.
const nodejsProtoPath = path.join(
__dirname,
'..',
'..',
'protos',
'protos.json'
);
this._protos = this._gaxGrpc.loadProto(
opts.fallback
? // eslint-disable-next-line @typescript-eslint/no-var-requires
require('../../protos/protos.json')
: nodejsProtoPath
);
// This API contains "path templates"; forward-slash-separated
// identifiers to uniquely identify resources within the API.
// Create useful helper objects for these.
this.pathTemplates = {
findingPathTemplate: new this._gaxModule.PathTemplate(
'projects/{project}/locations/{location}/findings/{finding}'
),
organizationPathTemplate: new this._gaxModule.PathTemplate(
'organizations/{organization}'
),
organizationDeidentifyTemplatePathTemplate: new this._gaxModule.PathTemplate(
'organizations/{organization}/deidentifyTemplates/{deidentify_template}'
),
organizationInspectTemplatePathTemplate: new this._gaxModule.PathTemplate(
'organizations/{organization}/inspectTemplates/{inspect_template}'
),
organizationLocationDeidentifyTemplatePathTemplate: new this._gaxModule.PathTemplate(
'organizations/{organization}/locations/{location}/deidentifyTemplates/{deidentify_template}'
),
organizationLocationInspectTemplatePathTemplate: new this._gaxModule.PathTemplate(
'organizations/{organization}/locations/{location}/inspectTemplates/{inspect_template}'
),
organizationLocationStoredInfoTypePathTemplate: new this._gaxModule.PathTemplate(
'organizations/{organization}/locations/{location}/storedInfoTypes/{stored_info_type}'
),
organizationStoredInfoTypePathTemplate: new this._gaxModule.PathTemplate(
'organizations/{organization}/storedInfoTypes/{stored_info_type}'
),
projectPathTemplate: new this._gaxModule.PathTemplate(
'projects/{project}'
),
projectDeidentifyTemplatePathTemplate: new this._gaxModule.PathTemplate(
'projects/{project}/deidentifyTemplates/{deidentify_template}'
),
projectDlpJobPathTemplate: new this._gaxModule.PathTemplate(
'projects/{project}/dlpJobs/{dlp_job}'
),
projectInspectTemplatePathTemplate: new this._gaxModule.PathTemplate(
'projects/{project}/inspectTemplates/{inspect_template}'
),
projectJobTriggerPathTemplate: new this._gaxModule.PathTemplate(
'projects/{project}/jobTriggers/{job_trigger}'
),
projectLocationDeidentifyTemplatePathTemplate: new this._gaxModule.PathTemplate(
'projects/{project}/locations/{location}/deidentifyTemplates/{deidentify_template}'
),
projectLocationDlpJobPathTemplate: new this._gaxModule.PathTemplate(
'projects/{project}/locations/{location}/dlpJobs/{dlp_job}'
),
projectLocationInspectTemplatePathTemplate: new this._gaxModule.PathTemplate(
'projects/{project}/locations/{location}/inspectTemplates/{inspect_template}'
),
projectLocationJobTriggerPathTemplate: new this._gaxModule.PathTemplate(
'projects/{project}/locations/{location}/jobTriggers/{job_trigger}'
),
projectLocationStoredInfoTypePathTemplate: new this._gaxModule.PathTemplate(
'projects/{project}/locations/{location}/storedInfoTypes/{stored_info_type}'
),
projectStoredInfoTypePathTemplate: new this._gaxModule.PathTemplate(
'projects/{project}/storedInfoTypes/{stored_info_type}'
),
};
// Some of the methods on this service return "paged" results,
// (e.g. 50 results at a time, with tokens to get subsequent
// pages). Denote the keys used for pagination and results.
this.descriptors.page = {
listInspectTemplates: new this._gaxModule.PageDescriptor(
'pageToken',
'nextPageToken',
'inspectTemplates'
),
listDeidentifyTemplates: new this._gaxModule.PageDescriptor(
'pageToken',
'nextPageToken',
'deidentifyTemplates'
),
listJobTriggers: new this._gaxModule.PageDescriptor(
'pageToken',
'nextPageToken',
'jobTriggers'
),
listDlpJobs: new this._gaxModule.PageDescriptor(
'pageToken',
'nextPageToken',
'jobs'
),
listStoredInfoTypes: new this._gaxModule.PageDescriptor(
'pageToken',
'nextPageToken',
'storedInfoTypes'
),
};
// Put together the default options sent with requests.
this._defaults = this._gaxGrpc.constructSettings(
'google.privacy.dlp.v2.DlpService',
gapicConfig as gax.ClientConfig,
opts.clientConfig || {},
{'x-goog-api-client': clientHeader.join(' ')}
);
// Set up a dictionary of "inner API calls"; the core implementation
// of calling the API is handled in `google-gax`, with this code
// merely providing the destination and request information.
this.innerApiCalls = {};
}
/**
* Initialize the client.
* Performs asynchronous operations (such as authentication) and prepares the client.
* This function will be called automatically when any class method is called for the
* first time, but if you need to initialize it before calling an actual method,
* feel free to call initialize() directly.
*
* You can await on this method if you want to make sure the client is initialized.
*
* @returns {Promise} A promise that resolves to an authenticated service stub.
*/
initialize() {
// If the client stub promise is already initialized, return immediately.
if (this.dlpServiceStub) {
return this.dlpServiceStub;
}
// Put together the "service stub" for
// google.privacy.dlp.v2.DlpService.
this.dlpServiceStub = this._gaxGrpc.createStub(
this._opts.fallback
? (this._protos as protobuf.Root).lookupService(
'google.privacy.dlp.v2.DlpService'
)
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
(this._protos as any).google.privacy.dlp.v2.DlpService,
this._opts
) as Promise<{[method: string]: Function}>;
// Iterate over each of the methods that the service provides
// and create an API call method for each.
const dlpServiceStubMethods = [
'inspectContent',
'redactImage',
'deidentifyContent',
'reidentifyContent',
'listInfoTypes',
'createInspectTemplate',
'updateInspectTemplate',
'getInspectTemplate',
'listInspectTemplates',
'deleteInspectTemplate',
'createDeidentifyTemplate',
'updateDeidentifyTemplate',
'getDeidentifyTemplate',
'listDeidentifyTemplates',
'deleteDeidentifyTemplate',
'createJobTrigger',
'updateJobTrigger',
'hybridInspectJobTrigger',
'getJobTrigger',
'listJobTriggers',
'deleteJobTrigger',
'activateJobTrigger',
'createDlpJob',
'listDlpJobs',
'getDlpJob',
'deleteDlpJob',
'cancelDlpJob',
'createStoredInfoType',
'updateStoredInfoType',
'getStoredInfoType',
'listStoredInfoTypes',
'deleteStoredInfoType',
'hybridInspectDlpJob',
'finishDlpJob',
];
for (const methodName of dlpServiceStubMethods) {
const callPromise = this.dlpServiceStub.then(
stub => (...args: Array<{}>) => {
if (this._terminated) {
return Promise.reject('The client has already been closed.');
}
const func = stub[methodName];
return func.apply(stub, args);
},
(err: Error | null | undefined) => () => {
throw err;
}
);
const apiCall = this._gaxModule.createApiCall(
callPromise,
this._defaults[methodName],
this.descriptors.page[methodName] ||
this.descriptors.stream[methodName] ||
this.descriptors.longrunning[methodName]
);
this.innerApiCalls[methodName] = apiCall;
}
return this.dlpServiceStub;
}
/**
* The DNS address for this API service.
*/
static get servicePath() {
return 'dlp.googleapis.com';
}
/**
* The DNS address for this API service - same as servicePath(),
* exists for compatibility reasons.
*/
static get apiEndpoint() {
return 'dlp.googleapis.com';
}
/**
* The port for this API service.
*/
static get port() {
return 443;
}
/**
* The scopes needed to make gRPC calls for every method defined
* in this service.
*/
static get scopes() {
return ['https://www.googleapis.com/auth/cloud-platform'];
}
getProjectId(): Promise<string>;
getProjectId(callback: Callback<string, undefined, undefined>): void;
/**
* Return the project ID used by this class.
* @param {function(Error, string)} callback - the callback to
* be called with the current project Id.
*/
getProjectId(
callback?: Callback<string, undefined, undefined>
): Promise<string> | void {
if (callback) {
this.auth.getProjectId(callback);
return;
}
return this.auth.getProjectId();
}
// -------------------
// -- Service calls --
// -------------------
inspectContent(
request: protos.google.privacy.dlp.v2.IInspectContentRequest,
options?: gax.CallOptions
): Promise<
[
protos.google.privacy.dlp.v2.IInspectContentResponse,
protos.google.privacy.dlp.v2.IInspectContentRequest | undefined,
{} | undefined
]
>;
inspectContent(
request: protos.google.privacy.dlp.v2.IInspectContentRequest,
options: gax.CallOptions,
callback: Callback<
protos.google.privacy.dlp.v2.IInspectContentResponse,
protos.google.privacy.dlp.v2.IInspectContentRequest | null | undefined,
{} | null | undefined
>
): void;
inspectContent(
request: protos.google.privacy.dlp.v2.IInspectContentRequest,
callback: Callback<
protos.google.privacy.dlp.v2.IInspectContentResponse,
protos.google.privacy.dlp.v2.IInspectContentRequest | null | undefined,
{} | null | undefined
>
): void;
/**
* Finds potentially sensitive info in content.
* This method has limits on input size, processing time, and output size.
*
* When no InfoTypes or CustomInfoTypes are specified in this request, the
* system will automatically choose what detectors to run. By default this may
* be all types, but may change over time as detectors are updated.
*
* For how to guides, see https://cloud.google.com/dlp/docs/inspecting-images
* and https://cloud.google.com/dlp/docs/inspecting-text,
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* The parent resource name, for example projects/my-project-id
* or projects/my-project-id/locations/{location_id}
* @param {google.privacy.dlp.v2.InspectConfig} request.inspectConfig
* Configuration for the inspector. What specified here will override
* the template referenced by the inspect_template_name argument.
* @param {google.privacy.dlp.v2.ContentItem} request.item
* The item to inspect.
* @param {string} request.inspectTemplateName
* Template to use. Any configuration directly specified in
* inspect_config will override those set in the template. Singular fields
* that are set in this request will replace their corresponding fields in the
* template. Repeated fields are appended. Singular sub-messages and groups
* are recursively merged.
* @param {string} request.locationId
* Deprecated. This field has no effect.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing [InspectContentResponse]{@link google.privacy.dlp.v2.InspectContentResponse}.
* The promise has a method named "cancel" which cancels the ongoing API call.
*/
inspectContent(
request: protos.google.privacy.dlp.v2.IInspectContentRequest,
optionsOrCallback?:
| gax.CallOptions
| Callback<
protos.google.privacy.dlp.v2.IInspectContentResponse,
| protos.google.privacy.dlp.v2.IInspectContentRequest
| null
| undefined,
{} | null | undefined
>,
callback?: Callback<
protos.google.privacy.dlp.v2.IInspectContentResponse,
protos.google.privacy.dlp.v2.IInspectContentRequest | null | undefined,
{} | null | undefined
>
): Promise<
[
protos.google.privacy.dlp.v2.IInspectContentResponse,
protos.google.privacy.dlp.v2.IInspectContentRequest | undefined,
{} | undefined
]
> | void {
request = request || {};
let options: gax.CallOptions;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
} else {
options = optionsOrCallback as gax.CallOptions;
}
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
parent: request.parent || '',
});
this.initialize();
return this.innerApiCalls.inspectContent(request, options, callback);
}
redactImage(
request: protos.google.privacy.dlp.v2.IRedactImageRequest,
options?: gax.CallOptions
): Promise<
[
protos.google.privacy.dlp.v2.IRedactImageResponse,
protos.google.privacy.dlp.v2.IRedactImageRequest | undefined,
{} | undefined
]
>;
redactImage(
request: protos.google.privacy.dlp.v2.IRedactImageRequest,
options: gax.CallOptions,
callback: Callback<
protos.google.privacy.dlp.v2.IRedactImageResponse,
protos.google.privacy.dlp.v2.IRedactImageRequest | null | undefined,
{} | null | undefined
>
): void;
redactImage(
request: protos.google.privacy.dlp.v2.IRedactImageRequest,
callback: Callback<
protos.google.privacy.dlp.v2.IRedactImageResponse,
protos.google.privacy.dlp.v2.IRedactImageRequest | null | undefined,
{} | null | undefined
>
): void;
/**
* Redacts potentially sensitive info from an image.
* This method has limits on input size, processing time, and output size.
* See https://cloud.google.com/dlp/docs/redacting-sensitive-data-images to
* learn more.
*
* When no InfoTypes or CustomInfoTypes are specified in this request, the
* system will automatically choose what detectors to run. By default this may
* be all types, but may change over time as detectors are updated.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* The parent resource name, for example projects/my-project-id
* or projects/my-project-id/locations/{location_id}.
* @param {string} request.locationId
* Deprecated. This field has no effect.
* @param {google.privacy.dlp.v2.InspectConfig} request.inspectConfig
* Configuration for the inspector.
* @param {number[]} request.imageRedactionConfigs
* The configuration for specifying what content to redact from images.
* @param {boolean} request.includeFindings
* Whether the response should include findings along with the redacted
* image.
* @param {google.privacy.dlp.v2.ByteContentItem} request.byteItem
* The content must be PNG, JPEG, SVG or BMP.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing [RedactImageResponse]{@link google.privacy.dlp.v2.RedactImageResponse}.
* The promise has a method named "cancel" which cancels the ongoing API call.
*/
redactImage(
request: protos.google.privacy.dlp.v2.IRedactImageRequest,
optionsOrCallback?:
| gax.CallOptions
| Callback<
protos.google.privacy.dlp.v2.IRedactImageResponse,
protos.google.privacy.dlp.v2.IRedactImageRequest | null | undefined,
{} | null | undefined
>,
callback?: Callback<
protos.google.privacy.dlp.v2.IRedactImageResponse,
protos.google.privacy.dlp.v2.IRedactImageRequest | null | undefined,
{} | null | undefined
>
): Promise<
[
protos.google.privacy.dlp.v2.IRedactImageResponse,
protos.google.privacy.dlp.v2.IRedactImageRequest | undefined,
{} | undefined
]
> | void {
request = request || {};
let options: gax.CallOptions;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
} else {
options = optionsOrCallback as gax.CallOptions;
}
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
parent: request.parent || '',
});
this.initialize();
return this.innerApiCalls.redactImage(request, options, callback);
}
deidentifyContent(
request: protos.google.privacy.dlp.v2.IDeidentifyContentRequest,
options?: gax.CallOptions
): Promise<
[
protos.google.privacy.dlp.v2.IDeidentifyContentResponse,
protos.google.privacy.dlp.v2.IDeidentifyContentRequest | undefined,
{} | undefined
]
>;
deidentifyContent(
request: protos.google.privacy.dlp.v2.IDeidentifyContentRequest,
options: gax.CallOptions,
callback: Callback<
protos.google.privacy.dlp.v2.IDeidentifyContentResponse,
protos.google.privacy.dlp.v2.IDeidentifyContentRequest | null | undefined,
{} | null | undefined
>
): void;
deidentifyContent(
request: protos.google.privacy.dlp.v2.IDeidentifyContentRequest,
callback: Callback<
protos.google.privacy.dlp.v2.IDeidentifyContentResponse,
protos.google.privacy.dlp.v2.IDeidentifyContentRequest | null | undefined,
{} | null | undefined
>
): void;
/**
* De-identifies potentially sensitive info from a ContentItem.
* This method has limits on input size and output size.
* See https://cloud.google.com/dlp/docs/deidentify-sensitive-data to
* learn more.
*
* When no InfoTypes or CustomInfoTypes are specified in this request, the
* system will automatically choose what detectors to run. By default this may
* be all types, but may change over time as detectors are updated.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* The parent resource name, for example projects/my-project-id
* or projects/my-project-id/locations/{location_id}.
* @param {google.privacy.dlp.v2.DeidentifyConfig} request.deidentifyConfig
* Configuration for the de-identification of the content item.
* Items specified here will override the template referenced by the
* deidentify_template_name argument.
* @param {google.privacy.dlp.v2.InspectConfig} request.inspectConfig
* Configuration for the inspector.
* Items specified here will override the template referenced by the
* inspect_template_name argument.
* @param {google.privacy.dlp.v2.ContentItem} request.item
* The item to de-identify. Will be treated as text.
* @param {string} request.inspectTemplateName
* Template to use. Any configuration directly specified in
* inspect_config will override those set in the template. Singular fields
* that are set in this request will replace their corresponding fields in the
* template. Repeated fields are appended. Singular sub-messages and groups
* are recursively merged.
* @param {string} request.deidentifyTemplateName
* Template to use. Any configuration directly specified in
* deidentify_config will override those set in the template. Singular fields
* that are set in this request will replace their corresponding fields in the
* template. Repeated fields are appended. Singular sub-messages and groups
* are recursively merged.
* @param {string} request.locationId
* Deprecated. This field has no effect.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing [DeidentifyContentResponse]{@link google.privacy.dlp.v2.DeidentifyContentResponse}.
* The promise has a method named "cancel" which cancels the ongoing API call.
*/
deidentifyContent(
request: protos.google.privacy.dlp.v2.IDeidentifyContentRequest,
optionsOrCallback?:
| gax.CallOptions
| Callback<
protos.google.privacy.dlp.v2.IDeidentifyContentResponse,
| protos.google.privacy.dlp.v2.IDeidentifyContentRequest
| null
| undefined,
{} | null | undefined
>,
callback?: Callback<
protos.google.privacy.dlp.v2.IDeidentifyContentResponse,
protos.google.privacy.dlp.v2.IDeidentifyContentRequest | null | undefined,
{} | null | undefined
>
): Promise<
[
protos.google.privacy.dlp.v2.IDeidentifyContentResponse,
protos.google.privacy.dlp.v2.IDeidentifyContentRequest | undefined,
{} | undefined
]
> | void {
request = request || {};
let options: gax.CallOptions;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
} else {
options = optionsOrCallback as gax.CallOptions;
}
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
parent: request.parent || '',
});
this.initialize();
return this.innerApiCalls.deidentifyContent(request, options, callback);
}
reidentifyContent(
request: protos.google.privacy.dlp.v2.IReidentifyContentRequest,
options?: gax.CallOptions
): Promise<
[
protos.google.privacy.dlp.v2.IReidentifyContentResponse,
protos.google.privacy.dlp.v2.IReidentifyContentRequest | undefined,
{} | undefined
]
>;
reidentifyContent(
request: protos.google.privacy.dlp.v2.IReidentifyContentRequest,
options: gax.CallOptions,
callback: Callback<
protos.google.privacy.dlp.v2.IReidentifyContentResponse,
protos.google.privacy.dlp.v2.IReidentifyContentRequest | null | undefined,
{} | null | undefined
>
): void;
reidentifyContent(
request: protos.google.privacy.dlp.v2.IReidentifyContentRequest,
callback: Callback<
protos.google.privacy.dlp.v2.IReidentifyContentResponse,
protos.google.privacy.dlp.v2.IReidentifyContentRequest | null | undefined,
{} | null | undefined
>
): void;
/**
* Re-identifies content that has been de-identified.
* See
* https://cloud.google.com/dlp/docs/pseudonymization#re-identification_in_free_text_code_example
* to learn more.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* Required. The parent resource name.
* @param {google.privacy.dlp.v2.DeidentifyConfig} request.reidentifyConfig
* Configuration for the re-identification of the content item.
* This field shares the same proto message type that is used for
* de-identification, however its usage here is for the reversal of the
* previous de-identification. Re-identification is performed by examining
* the transformations used to de-identify the items and executing the
* reverse. This requires that only reversible transformations
* be provided here. The reversible transformations are:
*
* - `CryptoDeterministicConfig`
* - `CryptoReplaceFfxFpeConfig`
* @param {google.privacy.dlp.v2.InspectConfig} request.inspectConfig
* Configuration for the inspector.
* @param {google.privacy.dlp.v2.ContentItem} request.item
* The item to re-identify. Will be treated as text.
* @param {string} request.inspectTemplateName
* Template to use. Any configuration directly specified in
* `inspect_config` will override those set in the template. Singular fields
* that are set in this request will replace their corresponding fields in the
* template. Repeated fields are appended. Singular sub-messages and groups
* are recursively merged.
* @param {string} request.reidentifyTemplateName
* Template to use. References an instance of `DeidentifyTemplate`.
* Any configuration directly specified in `reidentify_config` or
* `inspect_config` will override those set in the template. Singular fields
* that are set in this request will replace their corresponding fields in the
* template. Repeated fields are appended. Singular sub-messages and groups
* are recursively merged.
* @param {string} request.locationId
* Deprecated. This field has no effect.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing [ReidentifyContentResponse]{@link google.privacy.dlp.v2.ReidentifyContentResponse}.
* The promise has a method named "cancel" which cancels the ongoing API call.
*/
reidentifyContent(
request: protos.google.privacy.dlp.v2.IReidentifyContentRequest,
optionsOrCallback?:
| gax.CallOptions
| Callback<
protos.google.privacy.dlp.v2.IReidentifyContentResponse,
| protos.google.privacy.dlp.v2.IReidentifyContentRequest
| null
| undefined,
{} | null | undefined
>,
callback?: Callback<
protos.google.privacy.dlp.v2.IReidentifyContentResponse,
protos.google.privacy.dlp.v2.IReidentifyContentRequest | null | undefined,
{} | null | undefined
>
): Promise<
[
protos.google.privacy.dlp.v2.IReidentifyContentResponse,
protos.google.privacy.dlp.v2.IReidentifyContentRequest | undefined,
{} | undefined
]
> | void {
request = request || {};
let options: gax.CallOptions;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
} else {
options = optionsOrCallback as gax.CallOptions;
}
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
parent: request.parent || '',
});
this.initialize();
return this.innerApiCalls.reidentifyContent(request, options, callback);
}
listInfoTypes(
request: protos.google.privacy.dlp.v2.IListInfoTypesRequest,
options?: gax.CallOptions
): Promise<
[
protos.google.privacy.dlp.v2.IListInfoTypesResponse,
protos.google.privacy.dlp.v2.IListInfoTypesRequest | undefined,
{} | undefined
]
>;
listInfoTypes(
request: protos.google.privacy.dlp.v2.IListInfoTypesRequest,
options: gax.CallOptions,
callback: Callback<
protos.google.privacy.dlp.v2.IListInfoTypesResponse,
protos.google.privacy.dlp.v2.IListInfoTypesRequest | null | undefined,
{} | null | undefined
>
): void;
listInfoTypes(
request: protos.google.privacy.dlp.v2.IListInfoTypesRequest,
callback: Callback<
protos.google.privacy.dlp.v2.IListInfoTypesResponse,
protos.google.privacy.dlp.v2.IListInfoTypesRequest | null | undefined,
{} | null | undefined
>
): void;
/**
* Returns a list of the sensitive information types that the DLP API
* supports. See https://cloud.google.com/dlp/docs/infotypes-reference to
* learn more.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* The parent resource name, for example locations/{location_id}
* @param {string} request.languageCode
* BCP-47 language code for localized infoType friendly
* names. If omitted, or if localized strings are not available,
* en-US strings will be returned.
* @param {string} request.filter
* filter to only return infoTypes supported by certain parts of the
* API. Defaults to supported_by=INSPECT.
* @param {string} request.locationId
* Deprecated. This field has no effect.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing [ListInfoTypesResponse]{@link google.privacy.dlp.v2.ListInfoTypesResponse}.
* The promise has a method named "cancel" which cancels the ongoing API call.
*/
listInfoTypes(
request: protos.google.privacy.dlp.v2.IListInfoTypesRequest,
optionsOrCallback?:
| gax.CallOptions
| Callback<
protos.google.privacy.dlp.v2.IListInfoTypesResponse,
protos.google.privacy.dlp.v2.IListInfoTypesRequest | null | undefined,
{} | null | undefined
>,
callback?: Callback<
protos.google.privacy.dlp.v2.IListInfoTypesResponse,
protos.google.privacy.dlp.v2.IListInfoTypesRequest | null | undefined,
{} | null | undefined
>
): Promise<
[
protos.google.privacy.dlp.v2.IListInfoTypesResponse,
protos.google.privacy.dlp.v2.IListInfoTypesRequest | undefined,
{} | undefined
]
> | void {
request = request || {};
let options: gax.CallOptions;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
} else {
options = optionsOrCallback as gax.CallOptions;
}
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
parent: request.parent || '',
});
this.initialize();
return this.innerApiCalls.listInfoTypes(request, options, callback);
}
createInspectTemplate(
request: protos.google.privacy.dlp.v2.ICreateInspectTemplateRequest,
options?: gax.CallOptions
): Promise<
[
protos.google.privacy.dlp.v2.IInspectTemplate,
protos.google.privacy.dlp.v2.ICreateInspectTemplateRequest | undefined,
{} | undefined
]
>;
createInspectTemplate(
request: protos.google.privacy.dlp.v2.ICreateInspectTemplateRequest,
options: gax.CallOptions,
callback: Callback<
protos.google.privacy.dlp.v2.IInspectTemplate,
| protos.google.privacy.dlp.v2.ICreateInspectTemplateRequest
| null
| undefined,
{} | null | undefined
>
): void;
createInspectTemplate(
request: protos.google.privacy.dlp.v2.ICreateInspectTemplateRequest,
callback: Callback<
protos.google.privacy.dlp.v2.IInspectTemplate,
| protos.google.privacy.dlp.v2.ICreateInspectTemplateRequest
| null
| undefined,
{} | null | undefined
>
): void;
/**
* Creates an InspectTemplate for re-using frequently used configuration
* for inspecting content, images, and storage.
* See https://cloud.google.com/dlp/docs/creating-templates to learn more.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* Required. The parent resource name, for example projects/my-project-id or
* organizations/my-org-id or projects/my-project-id/locations/{location-id}.
* @param {google.privacy.dlp.v2.InspectTemplate} request.inspectTemplate
* Required. The InspectTemplate to create.
* @param {string} request.templateId
* The template id can contain uppercase and lowercase letters,
* numbers, and hyphens; that is, it must match the regular
* expression: `[a-zA-Z\\d-_]+`. The maximum length is 100
* characters. Can be empty to allow the system to generate one.
* @param {string} request.locationId
* Deprecated. This field has no effect.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing [InspectTemplate]{@link google.privacy.dlp.v2.InspectTemplate}.
* The promise has a method named "cancel" which cancels the ongoing API call.
*/
createInspectTemplate(
request: protos.google.privacy.dlp.v2.ICreateInspectTemplateRequest,