@googleapis/safebrowsing 10.0.0 → 12.1.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.
package/v5.ts CHANGED
@@ -23,7 +23,7 @@ import {
23
23
  Compute,
24
24
  UserRefreshClient,
25
25
  BaseExternalAccountClient,
26
- GaxiosPromise,
26
+ GaxiosResponseWithHTTP2,
27
27
  GoogleConfigurable,
28
28
  createAPIRequest,
29
29
  MethodOptions,
@@ -113,6 +113,8 @@ export namespace safebrowsing_v5 {
113
113
  export class Safebrowsing {
114
114
  context: APIRequestContext;
115
115
  hashes: Resource$Hashes;
116
+ hashList: Resource$Hashlist;
117
+ hashLists: Resource$Hashlists;
116
118
 
117
119
  constructor(options: GlobalOptions, google?: GoogleConfigurable) {
118
120
  this.context = {
@@ -121,9 +123,20 @@ export namespace safebrowsing_v5 {
121
123
  };
122
124
 
123
125
  this.hashes = new Resource$Hashes(this.context);
126
+ this.hashList = new Resource$Hashlist(this.context);
127
+ this.hashLists = new Resource$Hashlists(this.context);
124
128
  }
125
129
  }
126
130
 
131
+ /**
132
+ * The response containing multiple hash lists.
133
+ */
134
+ export interface Schema$GoogleSecuritySafebrowsingV5BatchGetHashListsResponse {
135
+ /**
136
+ * The hash lists in the same order given in the request.
137
+ */
138
+ hashLists?: Schema$GoogleSecuritySafebrowsingV5HashList[];
139
+ }
127
140
  /**
128
141
  * The full hash identified with one or more matches.
129
142
  */
@@ -150,6 +163,189 @@ export namespace safebrowsing_v5 {
150
163
  */
151
164
  threatType?: string | null;
152
165
  }
166
+ /**
167
+ * A list of hashes identified by its name.
168
+ */
169
+ export interface Schema$GoogleSecuritySafebrowsingV5HashList {
170
+ /**
171
+ * The 8-byte additions.
172
+ */
173
+ additionsEightBytes?: Schema$GoogleSecuritySafebrowsingV5RiceDeltaEncoded64Bit;
174
+ /**
175
+ * The 4-byte additions.
176
+ */
177
+ additionsFourBytes?: Schema$GoogleSecuritySafebrowsingV5RiceDeltaEncoded32Bit;
178
+ /**
179
+ * The 16-byte additions.
180
+ */
181
+ additionsSixteenBytes?: Schema$GoogleSecuritySafebrowsingV5RiceDeltaEncoded128Bit;
182
+ /**
183
+ * The 32-byte additions.
184
+ */
185
+ additionsThirtyTwoBytes?: Schema$GoogleSecuritySafebrowsingV5RiceDeltaEncoded256Bit;
186
+ /**
187
+ * The Rice-delta encoded version of removal indices. Since each hash list definitely has less than 2^32 entries, the indices are treated as 32-bit integers and encoded.
188
+ */
189
+ compressedRemovals?: Schema$GoogleSecuritySafebrowsingV5RiceDeltaEncoded32Bit;
190
+ /**
191
+ * Metadata about the hash list. This is not populated by the `GetHashList` method, but this is populated by the `ListHashLists` method.
192
+ */
193
+ metadata?: Schema$GoogleSecuritySafebrowsingV5HashListMetadata;
194
+ /**
195
+ * Clients should wait at least this long to get the hash list again. If omitted or zero, clients SHOULD fetch immediately because it indicates that the server has an additional update to be sent to the client, but could not due to the client-specified constraints.
196
+ */
197
+ minimumWaitDuration?: string | null;
198
+ /**
199
+ * The name of the hash list. Note that the Global Cache is also just a hash list and can be referred to here.
200
+ */
201
+ name?: string | null;
202
+ /**
203
+ * When true, this is a partial diff containing additions and removals based on what the client already has. When false, this is the complete hash list. When false, the client MUST delete any locally stored version for this hash list. This means that either the version possessed by the client is seriously out-of-date or the client data is believed to be corrupt. The `compressed_removals` field will be empty. When true, the client MUST apply an incremental update by applying removals and then additions.
204
+ */
205
+ partialUpdate?: boolean | null;
206
+ /**
207
+ * The sorted list of all hashes, hashed again with SHA256. This is the checksum for the sorted list of all hashes present in the database after applying the provided update. In the case that no updates were provided, the server will omit this field to indicate that the client should use the existing checksum.
208
+ */
209
+ sha256Checksum?: string | null;
210
+ /**
211
+ * The version of the hash list. The client MUST NOT manipulate those bytes.
212
+ */
213
+ version?: string | null;
214
+ }
215
+ /**
216
+ * Metadata about a particular hash list.
217
+ */
218
+ export interface Schema$GoogleSecuritySafebrowsingV5HashListMetadata {
219
+ /**
220
+ * A human-readable description about this list. Written in English.
221
+ */
222
+ description?: string | null;
223
+ /**
224
+ * The supported hash length for this hash list. Each hash list will support exactly one length. If a different hash length is introduced for the same set of threat types or safe types, it will be introduced as a separate list with a distinct name and respective hash length set.
225
+ */
226
+ hashLength?: string | null;
227
+ /**
228
+ * Unordered list. If not empty, this specifies that the hash list represents a list of likely safe hashes, and this enumerates the ways they are considered likely safe. This field is mutually exclusive with the threat_types field.
229
+ */
230
+ likelySafeTypes?: string[] | null;
231
+ /**
232
+ * Unordered list. If not empty, this specifies that the hash list is a kind of threat list, and this enumerates the kind of threats associated with hashes or hash prefixes in this hash list. May be empty if the entry does not represent a threat, i.e. in the case that it represents a likely safe type.
233
+ */
234
+ threatTypes?: string[] | null;
235
+ }
236
+ /**
237
+ * The response containing metadata about hash lists.
238
+ */
239
+ export interface Schema$GoogleSecuritySafebrowsingV5ListHashListsResponse {
240
+ /**
241
+ * The hash lists in an arbitrary order. Only metadata about the hash lists will be included, not the contents.
242
+ */
243
+ hashLists?: Schema$GoogleSecuritySafebrowsingV5HashList[];
244
+ /**
245
+ * A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
246
+ */
247
+ nextPageToken?: string | null;
248
+ }
249
+ /**
250
+ * Same as `RiceDeltaEncoded32Bit` except this encodes 128-bit numbers.
251
+ */
252
+ export interface Schema$GoogleSecuritySafebrowsingV5RiceDeltaEncoded128Bit {
253
+ /**
254
+ * The encoded deltas that are encoded using the Golomb-Rice coder.
255
+ */
256
+ encodedData?: string | null;
257
+ /**
258
+ * The number of entries that are delta encoded in the encoded data. If only a single integer was encoded, this will be zero and the single value will be stored in `first_value`.
259
+ */
260
+ entriesCount?: number | null;
261
+ /**
262
+ * The upper 64 bits of the first entry in the encoded data (hashes). If the field is empty, the upper 64 bits are all zero.
263
+ */
264
+ firstValueHi?: string | null;
265
+ /**
266
+ * The lower 64 bits of the first entry in the encoded data (hashes). If the field is empty, the lower 64 bits are all zero.
267
+ */
268
+ firstValueLo?: string | null;
269
+ /**
270
+ * The Golomb-Rice parameter. This parameter is guaranteed to be between 99 and 126, inclusive.
271
+ */
272
+ riceParameter?: number | null;
273
+ }
274
+ /**
275
+ * Same as `RiceDeltaEncoded32Bit` except this encodes 256-bit numbers.
276
+ */
277
+ export interface Schema$GoogleSecuritySafebrowsingV5RiceDeltaEncoded256Bit {
278
+ /**
279
+ * The encoded deltas that are encoded using the Golomb-Rice coder.
280
+ */
281
+ encodedData?: string | null;
282
+ /**
283
+ * The number of entries that are delta encoded in the encoded data. If only a single integer was encoded, this will be zero and the single value will be stored in `first_value`.
284
+ */
285
+ entriesCount?: number | null;
286
+ /**
287
+ * The first 64 bits of the first entry in the encoded data (hashes). If the field is empty, the first 64 bits are all zero.
288
+ */
289
+ firstValueFirstPart?: string | null;
290
+ /**
291
+ * The last 64 bits of the first entry in the encoded data (hashes). If the field is empty, the last 64 bits are all zero.
292
+ */
293
+ firstValueFourthPart?: string | null;
294
+ /**
295
+ * The 65 through 128th bits of the first entry in the encoded data (hashes). If the field is empty, the 65 through 128th bits are all zero.
296
+ */
297
+ firstValueSecondPart?: string | null;
298
+ /**
299
+ * The 129 through 192th bits of the first entry in the encoded data (hashes). If the field is empty, the 129 through 192th bits are all zero.
300
+ */
301
+ firstValueThirdPart?: string | null;
302
+ /**
303
+ * The Golomb-Rice parameter. This parameter is guaranteed to be between 227 and 254, inclusive.
304
+ */
305
+ riceParameter?: number | null;
306
+ }
307
+ /**
308
+ * The Rice-Golomb encoded data. Used for either hashes or removal indices. It is guaranteed that every hash or index here has the same length, and this length is exactly 32 bits. Generally speaking, if we sort all the entries lexicographically, we will find that the higher order bits tend not to change as frequently as lower order bits. This means that if we also take the adjacent difference between entries, the higher order bits have a high probability of being zero. This exploits this high probability of zero by essentially choosing a certain number of bits; all bits more significant than this are likely to be zero so we use unary encoding. See the `rice_parameter` field. Historical note: the Rice-delta encoding was first used in V4 of this API. In V5, two significant improvements were made: firstly, the Rice-delta encoding is now available with hash prefixes longer than 4 bytes; secondly, the encoded data are now treated as big-endian so as to avoid a costly sorting step.
309
+ */
310
+ export interface Schema$GoogleSecuritySafebrowsingV5RiceDeltaEncoded32Bit {
311
+ /**
312
+ * The encoded deltas that are encoded using the Golomb-Rice coder.
313
+ */
314
+ encodedData?: string | null;
315
+ /**
316
+ * The number of entries that are delta encoded in the encoded data. If only a single integer was encoded, this will be zero and the single value will be stored in `first_value`.
317
+ */
318
+ entriesCount?: number | null;
319
+ /**
320
+ * The first entry in the encoded data (hashes or indices), or, if only a single hash prefix or index was encoded, that entry's value. If the field is empty, the entry is zero.
321
+ */
322
+ firstValue?: number | null;
323
+ /**
324
+ * The Golomb-Rice parameter. This parameter is guaranteed to be between 3 and 30, inclusive.
325
+ */
326
+ riceParameter?: number | null;
327
+ }
328
+ /**
329
+ * Same as `RiceDeltaEncoded32Bit` except this encodes 64-bit numbers.
330
+ */
331
+ export interface Schema$GoogleSecuritySafebrowsingV5RiceDeltaEncoded64Bit {
332
+ /**
333
+ * The encoded deltas that are encoded using the Golomb-Rice coder.
334
+ */
335
+ encodedData?: string | null;
336
+ /**
337
+ * The number of entries that are delta encoded in the encoded data. If only a single integer was encoded, this will be zero and the single value will be stored in `first_value`.
338
+ */
339
+ entriesCount?: number | null;
340
+ /**
341
+ * The first entry in the encoded data (hashes), or, if only a single hash prefix was encoded, that entry's value. If the field is empty, the entry is zero.
342
+ */
343
+ firstValue?: string | null;
344
+ /**
345
+ * The Golomb-Rice parameter. This parameter is guaranteed to be between 35 and 62, inclusive.
346
+ */
347
+ riceParameter?: number | null;
348
+ }
153
349
  /**
154
350
  * The response returned after searching threat hashes. If nothing is found, the server will return an OK status (HTTP status code 200) with the `full_hashes` field empty, rather than returning a NOT_FOUND status (HTTP status code 404). **What's new in V5**: There is a separation between `FullHash` and `FullHashDetail`. In the case when a hash represents a site having multiple threats (e.g. both MALWARE and SOCIAL_ENGINEERING), the full hash does not need to be sent twice as in V4. Furthermore, the cache duration has been simplified into a single `cache_duration` field.
155
351
  */
@@ -172,6 +368,53 @@ export namespace safebrowsing_v5 {
172
368
 
173
369
  /**
174
370
  * Search for full hashes matching the specified prefixes. This is a custom method as defined by https://google.aip.dev/136 (the custom method refers to this method having a custom name within Google's general API development nomenclature; it does not refer to using a custom HTTP method).
371
+ * @example
372
+ * ```js
373
+ * // Before running the sample:
374
+ * // - Enable the API at:
375
+ * // https://console.developers.google.com/apis/api/safebrowsing.googleapis.com
376
+ * // - Login into gcloud by running:
377
+ * // ```sh
378
+ * // $ gcloud auth application-default login
379
+ * // ```
380
+ * // - Install the npm module by running:
381
+ * // ```sh
382
+ * // $ npm install googleapis
383
+ * // ```
384
+ *
385
+ * const {google} = require('googleapis');
386
+ * const safebrowsing = google.safebrowsing('v5');
387
+ *
388
+ * async function main() {
389
+ * const auth = new google.auth.GoogleAuth({
390
+ * // Scopes can be specified either as an array or as a single, space-delimited string.
391
+ * scopes: [],
392
+ * });
393
+ *
394
+ * // Acquire an auth client, and bind it to all future calls
395
+ * const authClient = await auth.getClient();
396
+ * google.options({auth: authClient});
397
+ *
398
+ * // Do the magic
399
+ * const res = await safebrowsing.hashes.search({
400
+ * // Required. The hash prefixes to be looked up. Clients MUST NOT send more than 1000 hash prefixes. However, following the URL processing procedure, clients SHOULD NOT need to send more than 30 hash prefixes. Currently each hash prefix is required to be exactly 4 bytes long. This MAY be relaxed in the future.
401
+ * hashPrefixes: 'placeholder-value',
402
+ * });
403
+ * console.log(res.data);
404
+ *
405
+ * // Example response
406
+ * // {
407
+ * // "cacheDuration": "my_cacheDuration",
408
+ * // "fullHashes": []
409
+ * // }
410
+ * }
411
+ *
412
+ * main().catch(e => {
413
+ * console.error(e);
414
+ * throw e;
415
+ * });
416
+ *
417
+ * ```
175
418
  *
176
419
  * @param params - Parameters for request
177
420
  * @param options - Optionally override request options, such as `url`, `method`, and `encoding`.
@@ -181,11 +424,13 @@ export namespace safebrowsing_v5 {
181
424
  search(
182
425
  params: Params$Resource$Hashes$Search,
183
426
  options: StreamMethodOptions
184
- ): GaxiosPromise<Readable>;
427
+ ): Promise<GaxiosResponseWithHTTP2<Readable>>;
185
428
  search(
186
429
  params?: Params$Resource$Hashes$Search,
187
430
  options?: MethodOptions
188
- ): GaxiosPromise<Schema$GoogleSecuritySafebrowsingV5SearchHashesResponse>;
431
+ ): Promise<
432
+ GaxiosResponseWithHTTP2<Schema$GoogleSecuritySafebrowsingV5SearchHashesResponse>
433
+ >;
189
434
  search(
190
435
  params: Params$Resource$Hashes$Search,
191
436
  options: StreamMethodOptions | BodyResponseCallback<Readable>,
@@ -220,8 +465,10 @@ export namespace safebrowsing_v5 {
220
465
  | BodyResponseCallback<Readable>
221
466
  ):
222
467
  | void
223
- | GaxiosPromise<Schema$GoogleSecuritySafebrowsingV5SearchHashesResponse>
224
- | GaxiosPromise<Readable> {
468
+ | Promise<
469
+ GaxiosResponseWithHTTP2<Schema$GoogleSecuritySafebrowsingV5SearchHashesResponse>
470
+ >
471
+ | Promise<GaxiosResponseWithHTTP2<Readable>> {
225
472
  let params = (paramsOrCallback || {}) as Params$Resource$Hashes$Search;
226
473
  let options = (optionsOrCallback || {}) as MethodOptions;
227
474
 
@@ -270,4 +517,528 @@ export namespace safebrowsing_v5 {
270
517
  */
271
518
  hashPrefixes?: string[];
272
519
  }
520
+
521
+ export class Resource$Hashlist {
522
+ context: APIRequestContext;
523
+ constructor(context: APIRequestContext) {
524
+ this.context = context;
525
+ }
526
+
527
+ /**
528
+ * Get the latest contents of a hash list. A hash list may either by a threat list or a non-threat list such as the Global Cache. This is a standard Get method as defined by https://google.aip.dev/131 and the HTTP method is also GET.
529
+ * @example
530
+ * ```js
531
+ * // Before running the sample:
532
+ * // - Enable the API at:
533
+ * // https://console.developers.google.com/apis/api/safebrowsing.googleapis.com
534
+ * // - Login into gcloud by running:
535
+ * // ```sh
536
+ * // $ gcloud auth application-default login
537
+ * // ```
538
+ * // - Install the npm module by running:
539
+ * // ```sh
540
+ * // $ npm install googleapis
541
+ * // ```
542
+ *
543
+ * const {google} = require('googleapis');
544
+ * const safebrowsing = google.safebrowsing('v5');
545
+ *
546
+ * async function main() {
547
+ * const auth = new google.auth.GoogleAuth({
548
+ * // Scopes can be specified either as an array or as a single, space-delimited string.
549
+ * scopes: [],
550
+ * });
551
+ *
552
+ * // Acquire an auth client, and bind it to all future calls
553
+ * const authClient = await auth.getClient();
554
+ * google.options({auth: authClient});
555
+ *
556
+ * // Do the magic
557
+ * const res = await safebrowsing.hashList.get({
558
+ * // Required. The name of this particular hash list. It may be a threat list, or it may be the Global Cache.
559
+ * name: 'placeholder-value',
560
+ * // Sets the maximum number of entries that the client is willing to have in the local database for the list. (The server MAY cause the client to store less than this number of entries.) If omitted or zero, no database size limit is set.
561
+ * 'sizeConstraints.maxDatabaseEntries': 'placeholder-value',
562
+ * // The maximum size in number of entries. The update will not contain more entries than this value, but it is possible that the update will contain fewer entries than this value. This MUST be at least 1024. If omitted or zero, no update size limit is set.
563
+ * 'sizeConstraints.maxUpdateEntries': 'placeholder-value',
564
+ * // The version of the hash list that the client already has. If this is the first time the client is fetching the hash list, this field MUST be left empty. Otherwise, the client SHOULD supply the version previously received from the server. The client MUST NOT manipulate those bytes. **What's new in V5**: in V4 of the API, this was called `states`; it is now renamed to `version` for clarity.
565
+ * version: 'placeholder-value',
566
+ * });
567
+ * console.log(res.data);
568
+ *
569
+ * // Example response
570
+ * // {
571
+ * // "additionsEightBytes": {},
572
+ * // "additionsFourBytes": {},
573
+ * // "additionsSixteenBytes": {},
574
+ * // "additionsThirtyTwoBytes": {},
575
+ * // "compressedRemovals": {},
576
+ * // "metadata": {},
577
+ * // "minimumWaitDuration": "my_minimumWaitDuration",
578
+ * // "name": "my_name",
579
+ * // "partialUpdate": false,
580
+ * // "sha256Checksum": "my_sha256Checksum",
581
+ * // "version": "my_version"
582
+ * // }
583
+ * }
584
+ *
585
+ * main().catch(e => {
586
+ * console.error(e);
587
+ * throw e;
588
+ * });
589
+ *
590
+ * ```
591
+ *
592
+ * @param params - Parameters for request
593
+ * @param options - Optionally override request options, such as `url`, `method`, and `encoding`.
594
+ * @param callback - Optional callback that handles the response.
595
+ * @returns A promise if used with async/await, or void if used with a callback.
596
+ */
597
+ get(
598
+ params: Params$Resource$Hashlist$Get,
599
+ options: StreamMethodOptions
600
+ ): Promise<GaxiosResponseWithHTTP2<Readable>>;
601
+ get(
602
+ params?: Params$Resource$Hashlist$Get,
603
+ options?: MethodOptions
604
+ ): Promise<
605
+ GaxiosResponseWithHTTP2<Schema$GoogleSecuritySafebrowsingV5HashList>
606
+ >;
607
+ get(
608
+ params: Params$Resource$Hashlist$Get,
609
+ options: StreamMethodOptions | BodyResponseCallback<Readable>,
610
+ callback: BodyResponseCallback<Readable>
611
+ ): void;
612
+ get(
613
+ params: Params$Resource$Hashlist$Get,
614
+ options:
615
+ | MethodOptions
616
+ | BodyResponseCallback<Schema$GoogleSecuritySafebrowsingV5HashList>,
617
+ callback: BodyResponseCallback<Schema$GoogleSecuritySafebrowsingV5HashList>
618
+ ): void;
619
+ get(
620
+ params: Params$Resource$Hashlist$Get,
621
+ callback: BodyResponseCallback<Schema$GoogleSecuritySafebrowsingV5HashList>
622
+ ): void;
623
+ get(
624
+ callback: BodyResponseCallback<Schema$GoogleSecuritySafebrowsingV5HashList>
625
+ ): void;
626
+ get(
627
+ paramsOrCallback?:
628
+ | Params$Resource$Hashlist$Get
629
+ | BodyResponseCallback<Schema$GoogleSecuritySafebrowsingV5HashList>
630
+ | BodyResponseCallback<Readable>,
631
+ optionsOrCallback?:
632
+ | MethodOptions
633
+ | StreamMethodOptions
634
+ | BodyResponseCallback<Schema$GoogleSecuritySafebrowsingV5HashList>
635
+ | BodyResponseCallback<Readable>,
636
+ callback?:
637
+ | BodyResponseCallback<Schema$GoogleSecuritySafebrowsingV5HashList>
638
+ | BodyResponseCallback<Readable>
639
+ ):
640
+ | void
641
+ | Promise<
642
+ GaxiosResponseWithHTTP2<Schema$GoogleSecuritySafebrowsingV5HashList>
643
+ >
644
+ | Promise<GaxiosResponseWithHTTP2<Readable>> {
645
+ let params = (paramsOrCallback || {}) as Params$Resource$Hashlist$Get;
646
+ let options = (optionsOrCallback || {}) as MethodOptions;
647
+
648
+ if (typeof paramsOrCallback === 'function') {
649
+ callback = paramsOrCallback;
650
+ params = {} as Params$Resource$Hashlist$Get;
651
+ options = {};
652
+ }
653
+
654
+ if (typeof optionsOrCallback === 'function') {
655
+ callback = optionsOrCallback;
656
+ options = {};
657
+ }
658
+
659
+ const rootUrl = options.rootUrl || 'https://safebrowsing.googleapis.com/';
660
+ const parameters = {
661
+ options: Object.assign(
662
+ {
663
+ url: (rootUrl + '/v5/hashList/{name}').replace(
664
+ /([^:]\/)\/+/g,
665
+ '$1'
666
+ ),
667
+ method: 'GET',
668
+ apiVersion: '',
669
+ },
670
+ options
671
+ ),
672
+ params,
673
+ requiredParams: ['name'],
674
+ pathParams: ['name'],
675
+ context: this.context,
676
+ };
677
+ if (callback) {
678
+ createAPIRequest<Schema$GoogleSecuritySafebrowsingV5HashList>(
679
+ parameters,
680
+ callback as BodyResponseCallback<unknown>
681
+ );
682
+ } else {
683
+ return createAPIRequest<Schema$GoogleSecuritySafebrowsingV5HashList>(
684
+ parameters
685
+ );
686
+ }
687
+ }
688
+ }
689
+
690
+ export interface Params$Resource$Hashlist$Get extends StandardParameters {
691
+ /**
692
+ * Required. The name of this particular hash list. It may be a threat list, or it may be the Global Cache.
693
+ */
694
+ name?: string;
695
+ /**
696
+ * Sets the maximum number of entries that the client is willing to have in the local database for the list. (The server MAY cause the client to store less than this number of entries.) If omitted or zero, no database size limit is set.
697
+ */
698
+ 'sizeConstraints.maxDatabaseEntries'?: number;
699
+ /**
700
+ * The maximum size in number of entries. The update will not contain more entries than this value, but it is possible that the update will contain fewer entries than this value. This MUST be at least 1024. If omitted or zero, no update size limit is set.
701
+ */
702
+ 'sizeConstraints.maxUpdateEntries'?: number;
703
+ /**
704
+ * The version of the hash list that the client already has. If this is the first time the client is fetching the hash list, this field MUST be left empty. Otherwise, the client SHOULD supply the version previously received from the server. The client MUST NOT manipulate those bytes. **What's new in V5**: in V4 of the API, this was called `states`; it is now renamed to `version` for clarity.
705
+ */
706
+ version?: string;
707
+ }
708
+
709
+ export class Resource$Hashlists {
710
+ context: APIRequestContext;
711
+ constructor(context: APIRequestContext) {
712
+ this.context = context;
713
+ }
714
+
715
+ /**
716
+ * Get multiple hash lists at once. It is very common for a client to need to get multiple hash lists. Using this method is preferred over using the regular Get method multiple times. This is a standard batch Get method as defined by https://google.aip.dev/231 and the HTTP method is also GET.
717
+ * @example
718
+ * ```js
719
+ * // Before running the sample:
720
+ * // - Enable the API at:
721
+ * // https://console.developers.google.com/apis/api/safebrowsing.googleapis.com
722
+ * // - Login into gcloud by running:
723
+ * // ```sh
724
+ * // $ gcloud auth application-default login
725
+ * // ```
726
+ * // - Install the npm module by running:
727
+ * // ```sh
728
+ * // $ npm install googleapis
729
+ * // ```
730
+ *
731
+ * const {google} = require('googleapis');
732
+ * const safebrowsing = google.safebrowsing('v5');
733
+ *
734
+ * async function main() {
735
+ * const auth = new google.auth.GoogleAuth({
736
+ * // Scopes can be specified either as an array or as a single, space-delimited string.
737
+ * scopes: [],
738
+ * });
739
+ *
740
+ * // Acquire an auth client, and bind it to all future calls
741
+ * const authClient = await auth.getClient();
742
+ * google.options({auth: authClient});
743
+ *
744
+ * // Do the magic
745
+ * const res = await safebrowsing.hashLists.batchGet({
746
+ * // Required. The names of the particular hash lists. The list MAY be a threat list, or it may be the Global Cache. The names MUST NOT contain duplicates; if they did, the client will get an error.
747
+ * names: 'placeholder-value',
748
+ * // Sets the maximum number of entries that the client is willing to have in the local database for the list. (The server MAY cause the client to store less than this number of entries.) If omitted or zero, no database size limit is set.
749
+ * 'sizeConstraints.maxDatabaseEntries': 'placeholder-value',
750
+ * // The maximum size in number of entries. The update will not contain more entries than this value, but it is possible that the update will contain fewer entries than this value. This MUST be at least 1024. If omitted or zero, no update size limit is set.
751
+ * 'sizeConstraints.maxUpdateEntries': 'placeholder-value',
752
+ * // The versions of the hash list that the client already has. If this is the first time the client is fetching the hash lists, the field should be left empty. Otherwise, the client should supply the versions previously received from the server. The client MUST NOT manipulate those bytes. The client need not send the versions in the same order as the corresponding list names. The client may send fewer or more versions in a request than there are names. However the client MUST NOT send multiple versions that correspond to the same name; if it did, the client will get an error. Historical note: in V4 of the API, this was called `states`; it is now renamed to `version` for clarity.
753
+ * version: 'placeholder-value',
754
+ * });
755
+ * console.log(res.data);
756
+ *
757
+ * // Example response
758
+ * // {
759
+ * // "hashLists": []
760
+ * // }
761
+ * }
762
+ *
763
+ * main().catch(e => {
764
+ * console.error(e);
765
+ * throw e;
766
+ * });
767
+ *
768
+ * ```
769
+ *
770
+ * @param params - Parameters for request
771
+ * @param options - Optionally override request options, such as `url`, `method`, and `encoding`.
772
+ * @param callback - Optional callback that handles the response.
773
+ * @returns A promise if used with async/await, or void if used with a callback.
774
+ */
775
+ batchGet(
776
+ params: Params$Resource$Hashlists$Batchget,
777
+ options: StreamMethodOptions
778
+ ): Promise<GaxiosResponseWithHTTP2<Readable>>;
779
+ batchGet(
780
+ params?: Params$Resource$Hashlists$Batchget,
781
+ options?: MethodOptions
782
+ ): Promise<
783
+ GaxiosResponseWithHTTP2<Schema$GoogleSecuritySafebrowsingV5BatchGetHashListsResponse>
784
+ >;
785
+ batchGet(
786
+ params: Params$Resource$Hashlists$Batchget,
787
+ options: StreamMethodOptions | BodyResponseCallback<Readable>,
788
+ callback: BodyResponseCallback<Readable>
789
+ ): void;
790
+ batchGet(
791
+ params: Params$Resource$Hashlists$Batchget,
792
+ options:
793
+ | MethodOptions
794
+ | BodyResponseCallback<Schema$GoogleSecuritySafebrowsingV5BatchGetHashListsResponse>,
795
+ callback: BodyResponseCallback<Schema$GoogleSecuritySafebrowsingV5BatchGetHashListsResponse>
796
+ ): void;
797
+ batchGet(
798
+ params: Params$Resource$Hashlists$Batchget,
799
+ callback: BodyResponseCallback<Schema$GoogleSecuritySafebrowsingV5BatchGetHashListsResponse>
800
+ ): void;
801
+ batchGet(
802
+ callback: BodyResponseCallback<Schema$GoogleSecuritySafebrowsingV5BatchGetHashListsResponse>
803
+ ): void;
804
+ batchGet(
805
+ paramsOrCallback?:
806
+ | Params$Resource$Hashlists$Batchget
807
+ | BodyResponseCallback<Schema$GoogleSecuritySafebrowsingV5BatchGetHashListsResponse>
808
+ | BodyResponseCallback<Readable>,
809
+ optionsOrCallback?:
810
+ | MethodOptions
811
+ | StreamMethodOptions
812
+ | BodyResponseCallback<Schema$GoogleSecuritySafebrowsingV5BatchGetHashListsResponse>
813
+ | BodyResponseCallback<Readable>,
814
+ callback?:
815
+ | BodyResponseCallback<Schema$GoogleSecuritySafebrowsingV5BatchGetHashListsResponse>
816
+ | BodyResponseCallback<Readable>
817
+ ):
818
+ | void
819
+ | Promise<
820
+ GaxiosResponseWithHTTP2<Schema$GoogleSecuritySafebrowsingV5BatchGetHashListsResponse>
821
+ >
822
+ | Promise<GaxiosResponseWithHTTP2<Readable>> {
823
+ let params = (paramsOrCallback ||
824
+ {}) as Params$Resource$Hashlists$Batchget;
825
+ let options = (optionsOrCallback || {}) as MethodOptions;
826
+
827
+ if (typeof paramsOrCallback === 'function') {
828
+ callback = paramsOrCallback;
829
+ params = {} as Params$Resource$Hashlists$Batchget;
830
+ options = {};
831
+ }
832
+
833
+ if (typeof optionsOrCallback === 'function') {
834
+ callback = optionsOrCallback;
835
+ options = {};
836
+ }
837
+
838
+ const rootUrl = options.rootUrl || 'https://safebrowsing.googleapis.com/';
839
+ const parameters = {
840
+ options: Object.assign(
841
+ {
842
+ url: (rootUrl + '/v5/hashLists:batchGet').replace(
843
+ /([^:]\/)\/+/g,
844
+ '$1'
845
+ ),
846
+ method: 'GET',
847
+ apiVersion: '',
848
+ },
849
+ options
850
+ ),
851
+ params,
852
+ requiredParams: [],
853
+ pathParams: [],
854
+ context: this.context,
855
+ };
856
+ if (callback) {
857
+ createAPIRequest<Schema$GoogleSecuritySafebrowsingV5BatchGetHashListsResponse>(
858
+ parameters,
859
+ callback as BodyResponseCallback<unknown>
860
+ );
861
+ } else {
862
+ return createAPIRequest<Schema$GoogleSecuritySafebrowsingV5BatchGetHashListsResponse>(
863
+ parameters
864
+ );
865
+ }
866
+ }
867
+
868
+ /**
869
+ * List hash lists. In the V5 API, Google will never remove a hash list that has ever been returned by this method. This enables clients to skip using this method and simply hard-code all hash lists they need. This is a standard List method as defined by https://google.aip.dev/132 and the HTTP method is GET.
870
+ * @example
871
+ * ```js
872
+ * // Before running the sample:
873
+ * // - Enable the API at:
874
+ * // https://console.developers.google.com/apis/api/safebrowsing.googleapis.com
875
+ * // - Login into gcloud by running:
876
+ * // ```sh
877
+ * // $ gcloud auth application-default login
878
+ * // ```
879
+ * // - Install the npm module by running:
880
+ * // ```sh
881
+ * // $ npm install googleapis
882
+ * // ```
883
+ *
884
+ * const {google} = require('googleapis');
885
+ * const safebrowsing = google.safebrowsing('v5');
886
+ *
887
+ * async function main() {
888
+ * const auth = new google.auth.GoogleAuth({
889
+ * // Scopes can be specified either as an array or as a single, space-delimited string.
890
+ * scopes: [],
891
+ * });
892
+ *
893
+ * // Acquire an auth client, and bind it to all future calls
894
+ * const authClient = await auth.getClient();
895
+ * google.options({auth: authClient});
896
+ *
897
+ * // Do the magic
898
+ * const res = await safebrowsing.hashLists.list({
899
+ * // The maximum number of hash lists to return. The service may return fewer than this value. If unspecified, the server will choose a page size, which may be larger than the number of hash lists so that pagination is not necessary.
900
+ * pageSize: 'placeholder-value',
901
+ * // A page token, received from a previous `ListHashLists` call. Provide this to retrieve the subsequent page.
902
+ * pageToken: 'placeholder-value',
903
+ * });
904
+ * console.log(res.data);
905
+ *
906
+ * // Example response
907
+ * // {
908
+ * // "hashLists": [],
909
+ * // "nextPageToken": "my_nextPageToken"
910
+ * // }
911
+ * }
912
+ *
913
+ * main().catch(e => {
914
+ * console.error(e);
915
+ * throw e;
916
+ * });
917
+ *
918
+ * ```
919
+ *
920
+ * @param params - Parameters for request
921
+ * @param options - Optionally override request options, such as `url`, `method`, and `encoding`.
922
+ * @param callback - Optional callback that handles the response.
923
+ * @returns A promise if used with async/await, or void if used with a callback.
924
+ */
925
+ list(
926
+ params: Params$Resource$Hashlists$List,
927
+ options: StreamMethodOptions
928
+ ): Promise<GaxiosResponseWithHTTP2<Readable>>;
929
+ list(
930
+ params?: Params$Resource$Hashlists$List,
931
+ options?: MethodOptions
932
+ ): Promise<
933
+ GaxiosResponseWithHTTP2<Schema$GoogleSecuritySafebrowsingV5ListHashListsResponse>
934
+ >;
935
+ list(
936
+ params: Params$Resource$Hashlists$List,
937
+ options: StreamMethodOptions | BodyResponseCallback<Readable>,
938
+ callback: BodyResponseCallback<Readable>
939
+ ): void;
940
+ list(
941
+ params: Params$Resource$Hashlists$List,
942
+ options:
943
+ | MethodOptions
944
+ | BodyResponseCallback<Schema$GoogleSecuritySafebrowsingV5ListHashListsResponse>,
945
+ callback: BodyResponseCallback<Schema$GoogleSecuritySafebrowsingV5ListHashListsResponse>
946
+ ): void;
947
+ list(
948
+ params: Params$Resource$Hashlists$List,
949
+ callback: BodyResponseCallback<Schema$GoogleSecuritySafebrowsingV5ListHashListsResponse>
950
+ ): void;
951
+ list(
952
+ callback: BodyResponseCallback<Schema$GoogleSecuritySafebrowsingV5ListHashListsResponse>
953
+ ): void;
954
+ list(
955
+ paramsOrCallback?:
956
+ | Params$Resource$Hashlists$List
957
+ | BodyResponseCallback<Schema$GoogleSecuritySafebrowsingV5ListHashListsResponse>
958
+ | BodyResponseCallback<Readable>,
959
+ optionsOrCallback?:
960
+ | MethodOptions
961
+ | StreamMethodOptions
962
+ | BodyResponseCallback<Schema$GoogleSecuritySafebrowsingV5ListHashListsResponse>
963
+ | BodyResponseCallback<Readable>,
964
+ callback?:
965
+ | BodyResponseCallback<Schema$GoogleSecuritySafebrowsingV5ListHashListsResponse>
966
+ | BodyResponseCallback<Readable>
967
+ ):
968
+ | void
969
+ | Promise<
970
+ GaxiosResponseWithHTTP2<Schema$GoogleSecuritySafebrowsingV5ListHashListsResponse>
971
+ >
972
+ | Promise<GaxiosResponseWithHTTP2<Readable>> {
973
+ let params = (paramsOrCallback || {}) as Params$Resource$Hashlists$List;
974
+ let options = (optionsOrCallback || {}) as MethodOptions;
975
+
976
+ if (typeof paramsOrCallback === 'function') {
977
+ callback = paramsOrCallback;
978
+ params = {} as Params$Resource$Hashlists$List;
979
+ options = {};
980
+ }
981
+
982
+ if (typeof optionsOrCallback === 'function') {
983
+ callback = optionsOrCallback;
984
+ options = {};
985
+ }
986
+
987
+ const rootUrl = options.rootUrl || 'https://safebrowsing.googleapis.com/';
988
+ const parameters = {
989
+ options: Object.assign(
990
+ {
991
+ url: (rootUrl + '/v5/hashLists').replace(/([^:]\/)\/+/g, '$1'),
992
+ method: 'GET',
993
+ apiVersion: '',
994
+ },
995
+ options
996
+ ),
997
+ params,
998
+ requiredParams: [],
999
+ pathParams: [],
1000
+ context: this.context,
1001
+ };
1002
+ if (callback) {
1003
+ createAPIRequest<Schema$GoogleSecuritySafebrowsingV5ListHashListsResponse>(
1004
+ parameters,
1005
+ callback as BodyResponseCallback<unknown>
1006
+ );
1007
+ } else {
1008
+ return createAPIRequest<Schema$GoogleSecuritySafebrowsingV5ListHashListsResponse>(
1009
+ parameters
1010
+ );
1011
+ }
1012
+ }
1013
+ }
1014
+
1015
+ export interface Params$Resource$Hashlists$Batchget
1016
+ extends StandardParameters {
1017
+ /**
1018
+ * Required. The names of the particular hash lists. The list MAY be a threat list, or it may be the Global Cache. The names MUST NOT contain duplicates; if they did, the client will get an error.
1019
+ */
1020
+ names?: string[];
1021
+ /**
1022
+ * Sets the maximum number of entries that the client is willing to have in the local database for the list. (The server MAY cause the client to store less than this number of entries.) If omitted or zero, no database size limit is set.
1023
+ */
1024
+ 'sizeConstraints.maxDatabaseEntries'?: number;
1025
+ /**
1026
+ * The maximum size in number of entries. The update will not contain more entries than this value, but it is possible that the update will contain fewer entries than this value. This MUST be at least 1024. If omitted or zero, no update size limit is set.
1027
+ */
1028
+ 'sizeConstraints.maxUpdateEntries'?: number;
1029
+ /**
1030
+ * The versions of the hash list that the client already has. If this is the first time the client is fetching the hash lists, the field should be left empty. Otherwise, the client should supply the versions previously received from the server. The client MUST NOT manipulate those bytes. The client need not send the versions in the same order as the corresponding list names. The client may send fewer or more versions in a request than there are names. However the client MUST NOT send multiple versions that correspond to the same name; if it did, the client will get an error. Historical note: in V4 of the API, this was called `states`; it is now renamed to `version` for clarity.
1031
+ */
1032
+ version?: string[];
1033
+ }
1034
+ export interface Params$Resource$Hashlists$List extends StandardParameters {
1035
+ /**
1036
+ * The maximum number of hash lists to return. The service may return fewer than this value. If unspecified, the server will choose a page size, which may be larger than the number of hash lists so that pagination is not necessary.
1037
+ */
1038
+ pageSize?: number;
1039
+ /**
1040
+ * A page token, received from a previous `ListHashLists` call. Provide this to retrieve the subsequent page.
1041
+ */
1042
+ pageToken?: string;
1043
+ }
273
1044
  }