@google-cloud/containeranalysis 5.1.1 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,928 +0,0 @@
1
- "use strict";
2
- // Copyright 2023 Google LLC
3
- //
4
- // Licensed under the Apache License, Version 2.0 (the "License");
5
- // you may not use this file except in compliance with the License.
6
- // You may obtain a copy of the License at
7
- //
8
- // https://www.apache.org/licenses/LICENSE-2.0
9
- //
10
- // Unless required by applicable law or agreed to in writing, software
11
- // distributed under the License is distributed on an "AS IS" BASIS,
12
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- // See the License for the specific language governing permissions and
14
- // limitations under the License.
15
- //
16
- // ** This file is automatically generated by gapic-generator-typescript. **
17
- // ** https://github.com/googleapis/gapic-generator-typescript **
18
- // ** All changes to this file may be overwritten. **
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.GrafeasClient = void 0;
21
- const jsonProtos = require("../../protos/protos.json");
22
- /**
23
- * Client JSON configuration object, loaded from
24
- * `src/v1/grafeas_client_config.json`.
25
- * This file defines retry strategy and timeouts for all API methods in this library.
26
- */
27
- const gapicConfig = require("./grafeas_client_config.json");
28
- const version = require('../../../package.json').version;
29
- /**
30
- * [Grafeas](https://grafeas.io) API.
31
- *
32
- * Retrieves analysis results of Cloud components such as Docker container
33
- * images.
34
- *
35
- * Analysis results are stored as a series of occurrences. An `Occurrence`
36
- * contains information about a specific analysis instance on a resource. An
37
- * occurrence refers to a `Note`. A note contains details describing the
38
- * analysis and is generally stored in a separate project, called a `Provider`.
39
- * Multiple occurrences can refer to the same note.
40
- *
41
- * For example, an SSL vulnerability could affect multiple images. In this case,
42
- * there would be one note for the vulnerability and an occurrence for each
43
- * image with the vulnerability referring to that note.
44
- * @class
45
- * @memberof v1
46
- */
47
- class GrafeasClient {
48
- /**
49
- * Construct an instance of GrafeasClient.
50
- *
51
- * @param {object} [options] - The configuration object.
52
- * The options accepted by the constructor are described in detail
53
- * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
54
- * The common options are:
55
- * @param {object} [options.credentials] - Credentials object.
56
- * @param {string} [options.credentials.client_email]
57
- * @param {string} [options.credentials.private_key]
58
- * @param {string} [options.email] - Account email address. Required when
59
- * using a .pem or .p12 keyFilename.
60
- * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or
61
- * .p12 key downloaded from the Google Developers Console. If you provide
62
- * a path to a JSON file, the projectId option below is not necessary.
63
- * NOTE: .pem and .p12 require you to specify options.email as well.
64
- * @param {number} [options.port] - The port on which to connect to
65
- * the remote host.
66
- * @param {string} [options.projectId] - The project ID from the Google
67
- * Developer's Console, e.g. 'grape-spaceship-123'. We will also check
68
- * the environment variable GCLOUD_PROJECT for your project ID. If your
69
- * app is running in an environment which supports
70
- * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials},
71
- * your project ID will be detected automatically.
72
- * @param {string} [options.apiEndpoint] - The domain name of the
73
- * API remote host.
74
- * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
75
- * Follows the structure of {@link gapicConfig}.
76
- * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
77
- * Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
78
- * For more information, please check the
79
- * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
80
- * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you
81
- * need to avoid loading the default gRPC version and want to use the fallback
82
- * HTTP implementation. Load only fallback version and pass it to the constructor:
83
- * ```
84
- * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC
85
- * const client = new GrafeasClient({fallback: 'rest'}, gax);
86
- * ```
87
- */
88
- constructor(opts, gaxInstance) {
89
- var _a, _b;
90
- this._terminated = false;
91
- this.descriptors = {
92
- page: {},
93
- stream: {},
94
- longrunning: {},
95
- batching: {},
96
- };
97
- // Ensure that options include all the required fields.
98
- const staticMembers = this.constructor;
99
- const servicePath = (opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint) || staticMembers.servicePath;
100
- this._providedCustomServicePath = !!((opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint));
101
- const port = (opts === null || opts === void 0 ? void 0 : opts.port) || staticMembers.port;
102
- const clientConfig = (_a = opts === null || opts === void 0 ? void 0 : opts.clientConfig) !== null && _a !== void 0 ? _a : {};
103
- const fallback = (_b = opts === null || opts === void 0 ? void 0 : opts.fallback) !== null && _b !== void 0 ? _b : (typeof window !== 'undefined' && typeof (window === null || window === void 0 ? void 0 : window.fetch) === 'function');
104
- opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts);
105
- // Request numeric enum values if REST transport is used.
106
- opts.numericEnums = true;
107
- // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
108
- if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) {
109
- opts['scopes'] = staticMembers.scopes;
110
- }
111
- // Load google-gax module synchronously if needed
112
- if (!gaxInstance) {
113
- gaxInstance = require('google-gax');
114
- }
115
- // Choose either gRPC or proto-over-HTTP implementation of google-gax.
116
- this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance;
117
- // Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
118
- this._gaxGrpc = new this._gaxModule.GrpcClient(opts);
119
- // Save options to use in initialize() method.
120
- this._opts = opts;
121
- // Save the auth object to the client, for use by other methods.
122
- this.auth = this._gaxGrpc.auth;
123
- // Set useJWTAccessWithScope on the auth object.
124
- this.auth.useJWTAccessWithScope = true;
125
- // Set defaultServicePath on the auth object.
126
- this.auth.defaultServicePath = staticMembers.servicePath;
127
- // Set the default scopes in auth client if needed.
128
- if (servicePath === staticMembers.servicePath) {
129
- this.auth.defaultScopes = staticMembers.scopes;
130
- }
131
- // Determine the client header string.
132
- const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
133
- if (typeof process !== 'undefined' && 'versions' in process) {
134
- clientHeader.push(`gl-node/${process.versions.node}`);
135
- }
136
- else {
137
- clientHeader.push(`gl-web/${this._gaxModule.version}`);
138
- }
139
- if (!opts.fallback) {
140
- clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
141
- }
142
- else if (opts.fallback === 'rest') {
143
- clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`);
144
- }
145
- if (opts.libName && opts.libVersion) {
146
- clientHeader.push(`${opts.libName}/${opts.libVersion}`);
147
- }
148
- // Load the applicable protos.
149
- this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
150
- // This API contains "path templates"; forward-slash-separated
151
- // identifiers to uniquely identify resources within the API.
152
- // Create useful helper objects for these.
153
- this.pathTemplates = {
154
- notePathTemplate: new this._gaxModule.PathTemplate('projects/{project}/notes/{note}'),
155
- occurrencePathTemplate: new this._gaxModule.PathTemplate('projects/{project}/occurrences/{occurrence}'),
156
- projectPathTemplate: new this._gaxModule.PathTemplate('projects/{project}'),
157
- };
158
- // Some of the methods on this service return "paged" results,
159
- // (e.g. 50 results at a time, with tokens to get subsequent
160
- // pages). Denote the keys used for pagination and results.
161
- this.descriptors.page = {
162
- listOccurrences: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'occurrences'),
163
- listNotes: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'notes'),
164
- listNoteOccurrences: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'occurrences'),
165
- };
166
- // Put together the default options sent with requests.
167
- this._defaults = this._gaxGrpc.constructSettings('google.devtools.containeranalysis.v1.Grafeas', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
168
- // Set up a dictionary of "inner API calls"; the core implementation
169
- // of calling the API is handled in `google-gax`, with this code
170
- // merely providing the destination and request information.
171
- this.innerApiCalls = {};
172
- // Add a warn function to the client constructor so it can be easily tested.
173
- this.warn = this._gaxModule.warn;
174
- }
175
- /**
176
- * Initialize the client.
177
- * Performs asynchronous operations (such as authentication) and prepares the client.
178
- * This function will be called automatically when any class method is called for the
179
- * first time, but if you need to initialize it before calling an actual method,
180
- * feel free to call initialize() directly.
181
- *
182
- * You can await on this method if you want to make sure the client is initialized.
183
- *
184
- * @returns {Promise} A promise that resolves to an authenticated service stub.
185
- */
186
- initialize() {
187
- // If the client stub promise is already initialized, return immediately.
188
- if (this.grafeasStub) {
189
- return this.grafeasStub;
190
- }
191
- // Put together the "service stub" for
192
- // google.devtools.containeranalysis.v1.Grafeas.
193
- this.grafeasStub = this._gaxGrpc.createStub(this._opts.fallback
194
- ? this._protos.lookupService('google.devtools.containeranalysis.v1.Grafeas')
195
- : // eslint-disable-next-line @typescript-eslint/no-explicit-any
196
- this._protos.google.devtools.containeranalysis.v1.Grafeas, this._opts, this._providedCustomServicePath);
197
- // Iterate over each of the methods that the service provides
198
- // and create an API call method for each.
199
- const grafeasStubMethods = [
200
- 'getOccurrence',
201
- 'listOccurrences',
202
- 'deleteOccurrence',
203
- 'createOccurrence',
204
- 'batchCreateOccurrences',
205
- 'updateOccurrence',
206
- 'getOccurrenceNote',
207
- 'getNote',
208
- 'listNotes',
209
- 'deleteNote',
210
- 'createNote',
211
- 'batchCreateNotes',
212
- 'updateNote',
213
- 'listNoteOccurrences',
214
- ];
215
- for (const methodName of grafeasStubMethods) {
216
- const callPromise = this.grafeasStub.then(stub => (...args) => {
217
- if (this._terminated) {
218
- return Promise.reject('The client has already been closed.');
219
- }
220
- const func = stub[methodName];
221
- return func.apply(stub, args);
222
- }, (err) => () => {
223
- throw err;
224
- });
225
- const descriptor = this.descriptors.page[methodName] || undefined;
226
- const apiCall = this._gaxModule.createApiCall(callPromise, this._defaults[methodName], descriptor, this._opts.fallback);
227
- this.innerApiCalls[methodName] = apiCall;
228
- }
229
- return this.grafeasStub;
230
- }
231
- /**
232
- * The DNS address for this API service.
233
- * @returns {string} The DNS address for this service.
234
- */
235
- static get servicePath() {
236
- return 'containeranalysis.googleapis.com';
237
- }
238
- /**
239
- * The DNS address for this API service - same as servicePath(),
240
- * exists for compatibility reasons.
241
- * @returns {string} The DNS address for this service.
242
- */
243
- static get apiEndpoint() {
244
- return 'containeranalysis.googleapis.com';
245
- }
246
- /**
247
- * The port for this API service.
248
- * @returns {number} The default port for this service.
249
- */
250
- static get port() {
251
- return 443;
252
- }
253
- /**
254
- * The scopes needed to make gRPC calls for every method defined
255
- * in this service.
256
- * @returns {string[]} List of default scopes.
257
- */
258
- static get scopes() {
259
- return [];
260
- }
261
- /**
262
- * Return the project ID used by this class.
263
- * @returns {Promise} A promise that resolves to string containing the project ID.
264
- */
265
- getProjectId(callback) {
266
- if (callback) {
267
- this.auth.getProjectId(callback);
268
- return;
269
- }
270
- return this.auth.getProjectId();
271
- }
272
- getOccurrence(request, optionsOrCallback, callback) {
273
- var _a;
274
- request = request || {};
275
- let options;
276
- if (typeof optionsOrCallback === 'function' && callback === undefined) {
277
- callback = optionsOrCallback;
278
- options = {};
279
- }
280
- else {
281
- options = optionsOrCallback;
282
- }
283
- options = options || {};
284
- options.otherArgs = options.otherArgs || {};
285
- options.otherArgs.headers = options.otherArgs.headers || {};
286
- options.otherArgs.headers['x-goog-request-params'] =
287
- this._gaxModule.routingHeader.fromParams({
288
- name: (_a = request.name) !== null && _a !== void 0 ? _a : '',
289
- });
290
- this.initialize();
291
- return this.innerApiCalls.getOccurrence(request, options, callback);
292
- }
293
- deleteOccurrence(request, optionsOrCallback, callback) {
294
- var _a;
295
- request = request || {};
296
- let options;
297
- if (typeof optionsOrCallback === 'function' && callback === undefined) {
298
- callback = optionsOrCallback;
299
- options = {};
300
- }
301
- else {
302
- options = optionsOrCallback;
303
- }
304
- options = options || {};
305
- options.otherArgs = options.otherArgs || {};
306
- options.otherArgs.headers = options.otherArgs.headers || {};
307
- options.otherArgs.headers['x-goog-request-params'] =
308
- this._gaxModule.routingHeader.fromParams({
309
- name: (_a = request.name) !== null && _a !== void 0 ? _a : '',
310
- });
311
- this.initialize();
312
- return this.innerApiCalls.deleteOccurrence(request, options, callback);
313
- }
314
- createOccurrence(request, optionsOrCallback, callback) {
315
- var _a;
316
- request = request || {};
317
- let options;
318
- if (typeof optionsOrCallback === 'function' && callback === undefined) {
319
- callback = optionsOrCallback;
320
- options = {};
321
- }
322
- else {
323
- options = optionsOrCallback;
324
- }
325
- options = options || {};
326
- options.otherArgs = options.otherArgs || {};
327
- options.otherArgs.headers = options.otherArgs.headers || {};
328
- options.otherArgs.headers['x-goog-request-params'] =
329
- this._gaxModule.routingHeader.fromParams({
330
- parent: (_a = request.parent) !== null && _a !== void 0 ? _a : '',
331
- });
332
- this.initialize();
333
- return this.innerApiCalls.createOccurrence(request, options, callback);
334
- }
335
- batchCreateOccurrences(request, optionsOrCallback, callback) {
336
- var _a;
337
- request = request || {};
338
- let options;
339
- if (typeof optionsOrCallback === 'function' && callback === undefined) {
340
- callback = optionsOrCallback;
341
- options = {};
342
- }
343
- else {
344
- options = optionsOrCallback;
345
- }
346
- options = options || {};
347
- options.otherArgs = options.otherArgs || {};
348
- options.otherArgs.headers = options.otherArgs.headers || {};
349
- options.otherArgs.headers['x-goog-request-params'] =
350
- this._gaxModule.routingHeader.fromParams({
351
- parent: (_a = request.parent) !== null && _a !== void 0 ? _a : '',
352
- });
353
- this.initialize();
354
- return this.innerApiCalls.batchCreateOccurrences(request, options, callback);
355
- }
356
- updateOccurrence(request, optionsOrCallback, callback) {
357
- var _a;
358
- request = request || {};
359
- let options;
360
- if (typeof optionsOrCallback === 'function' && callback === undefined) {
361
- callback = optionsOrCallback;
362
- options = {};
363
- }
364
- else {
365
- options = optionsOrCallback;
366
- }
367
- options = options || {};
368
- options.otherArgs = options.otherArgs || {};
369
- options.otherArgs.headers = options.otherArgs.headers || {};
370
- options.otherArgs.headers['x-goog-request-params'] =
371
- this._gaxModule.routingHeader.fromParams({
372
- name: (_a = request.name) !== null && _a !== void 0 ? _a : '',
373
- });
374
- this.initialize();
375
- return this.innerApiCalls.updateOccurrence(request, options, callback);
376
- }
377
- getOccurrenceNote(request, optionsOrCallback, callback) {
378
- var _a;
379
- request = request || {};
380
- let options;
381
- if (typeof optionsOrCallback === 'function' && callback === undefined) {
382
- callback = optionsOrCallback;
383
- options = {};
384
- }
385
- else {
386
- options = optionsOrCallback;
387
- }
388
- options = options || {};
389
- options.otherArgs = options.otherArgs || {};
390
- options.otherArgs.headers = options.otherArgs.headers || {};
391
- options.otherArgs.headers['x-goog-request-params'] =
392
- this._gaxModule.routingHeader.fromParams({
393
- name: (_a = request.name) !== null && _a !== void 0 ? _a : '',
394
- });
395
- this.initialize();
396
- return this.innerApiCalls.getOccurrenceNote(request, options, callback);
397
- }
398
- getNote(request, optionsOrCallback, callback) {
399
- var _a;
400
- request = request || {};
401
- let options;
402
- if (typeof optionsOrCallback === 'function' && callback === undefined) {
403
- callback = optionsOrCallback;
404
- options = {};
405
- }
406
- else {
407
- options = optionsOrCallback;
408
- }
409
- options = options || {};
410
- options.otherArgs = options.otherArgs || {};
411
- options.otherArgs.headers = options.otherArgs.headers || {};
412
- options.otherArgs.headers['x-goog-request-params'] =
413
- this._gaxModule.routingHeader.fromParams({
414
- name: (_a = request.name) !== null && _a !== void 0 ? _a : '',
415
- });
416
- this.initialize();
417
- return this.innerApiCalls.getNote(request, options, callback);
418
- }
419
- deleteNote(request, optionsOrCallback, callback) {
420
- var _a;
421
- request = request || {};
422
- let options;
423
- if (typeof optionsOrCallback === 'function' && callback === undefined) {
424
- callback = optionsOrCallback;
425
- options = {};
426
- }
427
- else {
428
- options = optionsOrCallback;
429
- }
430
- options = options || {};
431
- options.otherArgs = options.otherArgs || {};
432
- options.otherArgs.headers = options.otherArgs.headers || {};
433
- options.otherArgs.headers['x-goog-request-params'] =
434
- this._gaxModule.routingHeader.fromParams({
435
- name: (_a = request.name) !== null && _a !== void 0 ? _a : '',
436
- });
437
- this.initialize();
438
- return this.innerApiCalls.deleteNote(request, options, callback);
439
- }
440
- createNote(request, optionsOrCallback, callback) {
441
- var _a;
442
- request = request || {};
443
- let options;
444
- if (typeof optionsOrCallback === 'function' && callback === undefined) {
445
- callback = optionsOrCallback;
446
- options = {};
447
- }
448
- else {
449
- options = optionsOrCallback;
450
- }
451
- options = options || {};
452
- options.otherArgs = options.otherArgs || {};
453
- options.otherArgs.headers = options.otherArgs.headers || {};
454
- options.otherArgs.headers['x-goog-request-params'] =
455
- this._gaxModule.routingHeader.fromParams({
456
- parent: (_a = request.parent) !== null && _a !== void 0 ? _a : '',
457
- });
458
- this.initialize();
459
- return this.innerApiCalls.createNote(request, options, callback);
460
- }
461
- batchCreateNotes(request, optionsOrCallback, callback) {
462
- var _a;
463
- request = request || {};
464
- let options;
465
- if (typeof optionsOrCallback === 'function' && callback === undefined) {
466
- callback = optionsOrCallback;
467
- options = {};
468
- }
469
- else {
470
- options = optionsOrCallback;
471
- }
472
- options = options || {};
473
- options.otherArgs = options.otherArgs || {};
474
- options.otherArgs.headers = options.otherArgs.headers || {};
475
- options.otherArgs.headers['x-goog-request-params'] =
476
- this._gaxModule.routingHeader.fromParams({
477
- parent: (_a = request.parent) !== null && _a !== void 0 ? _a : '',
478
- });
479
- this.initialize();
480
- return this.innerApiCalls.batchCreateNotes(request, options, callback);
481
- }
482
- updateNote(request, optionsOrCallback, callback) {
483
- var _a;
484
- request = request || {};
485
- let options;
486
- if (typeof optionsOrCallback === 'function' && callback === undefined) {
487
- callback = optionsOrCallback;
488
- options = {};
489
- }
490
- else {
491
- options = optionsOrCallback;
492
- }
493
- options = options || {};
494
- options.otherArgs = options.otherArgs || {};
495
- options.otherArgs.headers = options.otherArgs.headers || {};
496
- options.otherArgs.headers['x-goog-request-params'] =
497
- this._gaxModule.routingHeader.fromParams({
498
- name: (_a = request.name) !== null && _a !== void 0 ? _a : '',
499
- });
500
- this.initialize();
501
- return this.innerApiCalls.updateNote(request, options, callback);
502
- }
503
- listOccurrences(request, optionsOrCallback, callback) {
504
- var _a;
505
- request = request || {};
506
- let options;
507
- if (typeof optionsOrCallback === 'function' && callback === undefined) {
508
- callback = optionsOrCallback;
509
- options = {};
510
- }
511
- else {
512
- options = optionsOrCallback;
513
- }
514
- options = options || {};
515
- options.otherArgs = options.otherArgs || {};
516
- options.otherArgs.headers = options.otherArgs.headers || {};
517
- options.otherArgs.headers['x-goog-request-params'] =
518
- this._gaxModule.routingHeader.fromParams({
519
- parent: (_a = request.parent) !== null && _a !== void 0 ? _a : '',
520
- });
521
- this.initialize();
522
- return this.innerApiCalls.listOccurrences(request, options, callback);
523
- }
524
- /**
525
- * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object.
526
- * @param {Object} request
527
- * The request object that will be sent.
528
- * @param {string} request.parent
529
- * The name of the project to list occurrences for in the form of
530
- * `projects/[PROJECT_ID]`.
531
- * @param {string} request.filter
532
- * The filter expression.
533
- * @param {number} request.pageSize
534
- * Number of occurrences to return in the list. Must be positive. Max allowed
535
- * page size is 1000. If not specified, page size defaults to 20.
536
- * @param {string} request.pageToken
537
- * Token to provide to skip to a particular spot in the list.
538
- * @param {object} [options]
539
- * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
540
- * @returns {Stream}
541
- * An object stream which emits an object representing [Occurrence]{@link grafeas.v1.Occurrence} on 'data' event.
542
- * The client library will perform auto-pagination by default: it will call the API as many
543
- * times as needed. Note that it can affect your quota.
544
- * We recommend using `listOccurrencesAsync()`
545
- * method described below for async iteration which you can stop as needed.
546
- * Please see the
547
- * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination)
548
- * for more details and examples.
549
- */
550
- listOccurrencesStream(request, options) {
551
- var _a;
552
- request = request || {};
553
- options = options || {};
554
- options.otherArgs = options.otherArgs || {};
555
- options.otherArgs.headers = options.otherArgs.headers || {};
556
- options.otherArgs.headers['x-goog-request-params'] =
557
- this._gaxModule.routingHeader.fromParams({
558
- parent: (_a = request.parent) !== null && _a !== void 0 ? _a : '',
559
- });
560
- const defaultCallSettings = this._defaults['listOccurrences'];
561
- const callSettings = defaultCallSettings.merge(options);
562
- this.initialize();
563
- return this.descriptors.page.listOccurrences.createStream(this.innerApiCalls.listOccurrences, request, callSettings);
564
- }
565
- /**
566
- * Equivalent to `listOccurrences`, but returns an iterable object.
567
- *
568
- * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
569
- * @param {Object} request
570
- * The request object that will be sent.
571
- * @param {string} request.parent
572
- * The name of the project to list occurrences for in the form of
573
- * `projects/[PROJECT_ID]`.
574
- * @param {string} request.filter
575
- * The filter expression.
576
- * @param {number} request.pageSize
577
- * Number of occurrences to return in the list. Must be positive. Max allowed
578
- * page size is 1000. If not specified, page size defaults to 20.
579
- * @param {string} request.pageToken
580
- * Token to provide to skip to a particular spot in the list.
581
- * @param {object} [options]
582
- * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
583
- * @returns {Object}
584
- * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols).
585
- * When you iterate the returned iterable, each element will be an object representing
586
- * [Occurrence]{@link grafeas.v1.Occurrence}. The API will be called under the hood as needed, once per the page,
587
- * so you can stop the iteration when you don't need more results.
588
- * Please see the
589
- * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination)
590
- * for more details and examples.
591
- * @example <caption>include:samples/generated/v1/grafeas.list_occurrences.js</caption>
592
- * region_tag:containeranalysis_v1_generated_Grafeas_ListOccurrences_async
593
- */
594
- listOccurrencesAsync(request, options) {
595
- var _a;
596
- request = request || {};
597
- options = options || {};
598
- options.otherArgs = options.otherArgs || {};
599
- options.otherArgs.headers = options.otherArgs.headers || {};
600
- options.otherArgs.headers['x-goog-request-params'] =
601
- this._gaxModule.routingHeader.fromParams({
602
- parent: (_a = request.parent) !== null && _a !== void 0 ? _a : '',
603
- });
604
- const defaultCallSettings = this._defaults['listOccurrences'];
605
- const callSettings = defaultCallSettings.merge(options);
606
- this.initialize();
607
- return this.descriptors.page.listOccurrences.asyncIterate(this.innerApiCalls['listOccurrences'], request, callSettings);
608
- }
609
- listNotes(request, optionsOrCallback, callback) {
610
- var _a;
611
- request = request || {};
612
- let options;
613
- if (typeof optionsOrCallback === 'function' && callback === undefined) {
614
- callback = optionsOrCallback;
615
- options = {};
616
- }
617
- else {
618
- options = optionsOrCallback;
619
- }
620
- options = options || {};
621
- options.otherArgs = options.otherArgs || {};
622
- options.otherArgs.headers = options.otherArgs.headers || {};
623
- options.otherArgs.headers['x-goog-request-params'] =
624
- this._gaxModule.routingHeader.fromParams({
625
- parent: (_a = request.parent) !== null && _a !== void 0 ? _a : '',
626
- });
627
- this.initialize();
628
- return this.innerApiCalls.listNotes(request, options, callback);
629
- }
630
- /**
631
- * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object.
632
- * @param {Object} request
633
- * The request object that will be sent.
634
- * @param {string} request.parent
635
- * The name of the project to list notes for in the form of
636
- * `projects/[PROJECT_ID]`.
637
- * @param {string} request.filter
638
- * The filter expression.
639
- * @param {number} request.pageSize
640
- * Number of notes to return in the list. Must be positive. Max allowed page
641
- * size is 1000. If not specified, page size defaults to 20.
642
- * @param {string} request.pageToken
643
- * Token to provide to skip to a particular spot in the list.
644
- * @param {object} [options]
645
- * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
646
- * @returns {Stream}
647
- * An object stream which emits an object representing [Note]{@link grafeas.v1.Note} on 'data' event.
648
- * The client library will perform auto-pagination by default: it will call the API as many
649
- * times as needed. Note that it can affect your quota.
650
- * We recommend using `listNotesAsync()`
651
- * method described below for async iteration which you can stop as needed.
652
- * Please see the
653
- * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination)
654
- * for more details and examples.
655
- */
656
- listNotesStream(request, options) {
657
- var _a;
658
- request = request || {};
659
- options = options || {};
660
- options.otherArgs = options.otherArgs || {};
661
- options.otherArgs.headers = options.otherArgs.headers || {};
662
- options.otherArgs.headers['x-goog-request-params'] =
663
- this._gaxModule.routingHeader.fromParams({
664
- parent: (_a = request.parent) !== null && _a !== void 0 ? _a : '',
665
- });
666
- const defaultCallSettings = this._defaults['listNotes'];
667
- const callSettings = defaultCallSettings.merge(options);
668
- this.initialize();
669
- return this.descriptors.page.listNotes.createStream(this.innerApiCalls.listNotes, request, callSettings);
670
- }
671
- /**
672
- * Equivalent to `listNotes`, but returns an iterable object.
673
- *
674
- * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
675
- * @param {Object} request
676
- * The request object that will be sent.
677
- * @param {string} request.parent
678
- * The name of the project to list notes for in the form of
679
- * `projects/[PROJECT_ID]`.
680
- * @param {string} request.filter
681
- * The filter expression.
682
- * @param {number} request.pageSize
683
- * Number of notes to return in the list. Must be positive. Max allowed page
684
- * size is 1000. If not specified, page size defaults to 20.
685
- * @param {string} request.pageToken
686
- * Token to provide to skip to a particular spot in the list.
687
- * @param {object} [options]
688
- * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
689
- * @returns {Object}
690
- * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols).
691
- * When you iterate the returned iterable, each element will be an object representing
692
- * [Note]{@link grafeas.v1.Note}. The API will be called under the hood as needed, once per the page,
693
- * so you can stop the iteration when you don't need more results.
694
- * Please see the
695
- * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination)
696
- * for more details and examples.
697
- * @example <caption>include:samples/generated/v1/grafeas.list_notes.js</caption>
698
- * region_tag:containeranalysis_v1_generated_Grafeas_ListNotes_async
699
- */
700
- listNotesAsync(request, options) {
701
- var _a;
702
- request = request || {};
703
- options = options || {};
704
- options.otherArgs = options.otherArgs || {};
705
- options.otherArgs.headers = options.otherArgs.headers || {};
706
- options.otherArgs.headers['x-goog-request-params'] =
707
- this._gaxModule.routingHeader.fromParams({
708
- parent: (_a = request.parent) !== null && _a !== void 0 ? _a : '',
709
- });
710
- const defaultCallSettings = this._defaults['listNotes'];
711
- const callSettings = defaultCallSettings.merge(options);
712
- this.initialize();
713
- return this.descriptors.page.listNotes.asyncIterate(this.innerApiCalls['listNotes'], request, callSettings);
714
- }
715
- listNoteOccurrences(request, optionsOrCallback, callback) {
716
- var _a;
717
- request = request || {};
718
- let options;
719
- if (typeof optionsOrCallback === 'function' && callback === undefined) {
720
- callback = optionsOrCallback;
721
- options = {};
722
- }
723
- else {
724
- options = optionsOrCallback;
725
- }
726
- options = options || {};
727
- options.otherArgs = options.otherArgs || {};
728
- options.otherArgs.headers = options.otherArgs.headers || {};
729
- options.otherArgs.headers['x-goog-request-params'] =
730
- this._gaxModule.routingHeader.fromParams({
731
- name: (_a = request.name) !== null && _a !== void 0 ? _a : '',
732
- });
733
- this.initialize();
734
- return this.innerApiCalls.listNoteOccurrences(request, options, callback);
735
- }
736
- /**
737
- * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object.
738
- * @param {Object} request
739
- * The request object that will be sent.
740
- * @param {string} request.name
741
- * The name of the note to list occurrences for in the form of
742
- * `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
743
- * @param {string} request.filter
744
- * The filter expression.
745
- * @param {number} request.pageSize
746
- * Number of occurrences to return in the list.
747
- * @param {string} request.pageToken
748
- * Token to provide to skip to a particular spot in the list.
749
- * @param {object} [options]
750
- * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
751
- * @returns {Stream}
752
- * An object stream which emits an object representing [Occurrence]{@link grafeas.v1.Occurrence} on 'data' event.
753
- * The client library will perform auto-pagination by default: it will call the API as many
754
- * times as needed. Note that it can affect your quota.
755
- * We recommend using `listNoteOccurrencesAsync()`
756
- * method described below for async iteration which you can stop as needed.
757
- * Please see the
758
- * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination)
759
- * for more details and examples.
760
- */
761
- listNoteOccurrencesStream(request, options) {
762
- var _a;
763
- request = request || {};
764
- options = options || {};
765
- options.otherArgs = options.otherArgs || {};
766
- options.otherArgs.headers = options.otherArgs.headers || {};
767
- options.otherArgs.headers['x-goog-request-params'] =
768
- this._gaxModule.routingHeader.fromParams({
769
- name: (_a = request.name) !== null && _a !== void 0 ? _a : '',
770
- });
771
- const defaultCallSettings = this._defaults['listNoteOccurrences'];
772
- const callSettings = defaultCallSettings.merge(options);
773
- this.initialize();
774
- return this.descriptors.page.listNoteOccurrences.createStream(this.innerApiCalls.listNoteOccurrences, request, callSettings);
775
- }
776
- /**
777
- * Equivalent to `listNoteOccurrences`, but returns an iterable object.
778
- *
779
- * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
780
- * @param {Object} request
781
- * The request object that will be sent.
782
- * @param {string} request.name
783
- * The name of the note to list occurrences for in the form of
784
- * `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
785
- * @param {string} request.filter
786
- * The filter expression.
787
- * @param {number} request.pageSize
788
- * Number of occurrences to return in the list.
789
- * @param {string} request.pageToken
790
- * Token to provide to skip to a particular spot in the list.
791
- * @param {object} [options]
792
- * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
793
- * @returns {Object}
794
- * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols).
795
- * When you iterate the returned iterable, each element will be an object representing
796
- * [Occurrence]{@link grafeas.v1.Occurrence}. The API will be called under the hood as needed, once per the page,
797
- * so you can stop the iteration when you don't need more results.
798
- * Please see the
799
- * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination)
800
- * for more details and examples.
801
- * @example <caption>include:samples/generated/v1/grafeas.list_note_occurrences.js</caption>
802
- * region_tag:containeranalysis_v1_generated_Grafeas_ListNoteOccurrences_async
803
- */
804
- listNoteOccurrencesAsync(request, options) {
805
- var _a;
806
- request = request || {};
807
- options = options || {};
808
- options.otherArgs = options.otherArgs || {};
809
- options.otherArgs.headers = options.otherArgs.headers || {};
810
- options.otherArgs.headers['x-goog-request-params'] =
811
- this._gaxModule.routingHeader.fromParams({
812
- name: (_a = request.name) !== null && _a !== void 0 ? _a : '',
813
- });
814
- const defaultCallSettings = this._defaults['listNoteOccurrences'];
815
- const callSettings = defaultCallSettings.merge(options);
816
- this.initialize();
817
- return this.descriptors.page.listNoteOccurrences.asyncIterate(this.innerApiCalls['listNoteOccurrences'], request, callSettings);
818
- }
819
- // --------------------
820
- // -- Path templates --
821
- // --------------------
822
- /**
823
- * Return a fully-qualified note resource name string.
824
- *
825
- * @param {string} project
826
- * @param {string} note
827
- * @returns {string} Resource name string.
828
- */
829
- notePath(project, note) {
830
- return this.pathTemplates.notePathTemplate.render({
831
- project: project,
832
- note: note,
833
- });
834
- }
835
- /**
836
- * Parse the project from Note resource.
837
- *
838
- * @param {string} noteName
839
- * A fully-qualified path representing Note resource.
840
- * @returns {string} A string representing the project.
841
- */
842
- matchProjectFromNoteName(noteName) {
843
- return this.pathTemplates.notePathTemplate.match(noteName).project;
844
- }
845
- /**
846
- * Parse the note from Note resource.
847
- *
848
- * @param {string} noteName
849
- * A fully-qualified path representing Note resource.
850
- * @returns {string} A string representing the note.
851
- */
852
- matchNoteFromNoteName(noteName) {
853
- return this.pathTemplates.notePathTemplate.match(noteName).note;
854
- }
855
- /**
856
- * Return a fully-qualified occurrence resource name string.
857
- *
858
- * @param {string} project
859
- * @param {string} occurrence
860
- * @returns {string} Resource name string.
861
- */
862
- occurrencePath(project, occurrence) {
863
- return this.pathTemplates.occurrencePathTemplate.render({
864
- project: project,
865
- occurrence: occurrence,
866
- });
867
- }
868
- /**
869
- * Parse the project from Occurrence resource.
870
- *
871
- * @param {string} occurrenceName
872
- * A fully-qualified path representing Occurrence resource.
873
- * @returns {string} A string representing the project.
874
- */
875
- matchProjectFromOccurrenceName(occurrenceName) {
876
- return this.pathTemplates.occurrencePathTemplate.match(occurrenceName)
877
- .project;
878
- }
879
- /**
880
- * Parse the occurrence from Occurrence resource.
881
- *
882
- * @param {string} occurrenceName
883
- * A fully-qualified path representing Occurrence resource.
884
- * @returns {string} A string representing the occurrence.
885
- */
886
- matchOccurrenceFromOccurrenceName(occurrenceName) {
887
- return this.pathTemplates.occurrencePathTemplate.match(occurrenceName)
888
- .occurrence;
889
- }
890
- /**
891
- * Return a fully-qualified project resource name string.
892
- *
893
- * @param {string} project
894
- * @returns {string} Resource name string.
895
- */
896
- projectPath(project) {
897
- return this.pathTemplates.projectPathTemplate.render({
898
- project: project,
899
- });
900
- }
901
- /**
902
- * Parse the project from Project resource.
903
- *
904
- * @param {string} projectName
905
- * A fully-qualified path representing Project resource.
906
- * @returns {string} A string representing the project.
907
- */
908
- matchProjectFromProjectName(projectName) {
909
- return this.pathTemplates.projectPathTemplate.match(projectName).project;
910
- }
911
- /**
912
- * Terminate the gRPC channel and close the client.
913
- *
914
- * The client will no longer be usable and all future behavior is undefined.
915
- * @returns {Promise} A promise that resolves when the client is closed.
916
- */
917
- close() {
918
- if (this.grafeasStub && !this._terminated) {
919
- return this.grafeasStub.then(stub => {
920
- this._terminated = true;
921
- stub.close();
922
- });
923
- }
924
- return Promise.resolve();
925
- }
926
- }
927
- exports.GrafeasClient = GrafeasClient;
928
- //# sourceMappingURL=grafeas_client.js.map