@maxim_mazurok/gapi.client.webrisk-v1 0.0.20220806

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/index.d.ts ADDED
@@ -0,0 +1,602 @@
1
+ /* Type definitions for non-npm package Web Risk API v1 0.0 */
2
+ // Project: https://cloud.google.com/web-risk/
3
+ // Definitions by: Maxim Mazurok <https://github.com/Maxim-Mazurok>
4
+ // Nick Amoscato <https://github.com/namoscato>
5
+ // Declan Vong <https://github.com/declanvong>
6
+ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
7
+ // TypeScript Version: 2.8
8
+
9
+ // IMPORTANT
10
+ // This file was generated by https://github.com/Maxim-Mazurok/google-api-typings-generator. Please do not edit it manually.
11
+ // In case of any problems please post issue to https://github.com/Maxim-Mazurok/google-api-typings-generator
12
+ // Generated from: https://webrisk.googleapis.com/$discovery/rest?version=v1
13
+ // Revision: 20220806
14
+
15
+ /// <reference types="gapi.client" />
16
+
17
+ declare namespace gapi.client {
18
+ /** Load Web Risk API v1 */
19
+ function load(urlOrObject: "https://webrisk.googleapis.com/$discovery/rest?version=v1"): Promise<void>;
20
+ /** @deprecated Please load APIs with discovery documents. */
21
+ function load(name: "webrisk", version: "v1"): Promise<void>;
22
+ /** @deprecated Please load APIs with discovery documents. */
23
+ function load(name: "webrisk", version: "v1", callback: () => any): void;
24
+
25
+ namespace webrisk {
26
+ interface GoogleCloudWebriskV1ComputeThreatListDiffResponse {
27
+ /** A set of entries to add to a local threat type's list. */
28
+ additions?: GoogleCloudWebriskV1ThreatEntryAdditions;
29
+ /**
30
+ * The expected SHA256 hash of the client state; that is, of the sorted list of all hashes present in the database after applying the provided diff. If the client state doesn't match
31
+ * the expected state, the client must discard this diff and retry later.
32
+ */
33
+ checksum?: GoogleCloudWebriskV1ComputeThreatListDiffResponseChecksum;
34
+ /**
35
+ * The new opaque client version token. This should be retained by the client and passed into the next call of ComputeThreatListDiff as 'version_token'. A separate version token should
36
+ * be stored and used for each threatList.
37
+ */
38
+ newVersionToken?: string;
39
+ /**
40
+ * The soonest the client should wait before issuing any diff request. Querying sooner is unlikely to produce a meaningful diff. Waiting longer is acceptable considering the use case.
41
+ * If this field is not set clients may update as soon as they want.
42
+ */
43
+ recommendedNextDiff?: string;
44
+ /** A set of entries to remove from a local threat type's list. This field may be empty. */
45
+ removals?: GoogleCloudWebriskV1ThreatEntryRemovals;
46
+ /** The type of response. This may indicate that an action must be taken by the client when the response is received. */
47
+ responseType?: string;
48
+ }
49
+ interface GoogleCloudWebriskV1ComputeThreatListDiffResponseChecksum {
50
+ /** The SHA256 hash of the client state; that is, of the sorted list of all hashes present in the database. */
51
+ sha256?: string;
52
+ }
53
+ interface GoogleCloudWebriskV1RawHashes {
54
+ /**
55
+ * The number of bytes for each prefix encoded below. This field can be anywhere from 4 (shortest prefix) to 32 (full SHA256 hash). In practice this is almost always 4, except in
56
+ * exceptional circumstances.
57
+ */
58
+ prefixSize?: number;
59
+ /** The hashes, in binary format, concatenated into one long string. Hashes are sorted in lexicographic order. For JSON API users, hashes are base64-encoded. */
60
+ rawHashes?: string;
61
+ }
62
+ interface GoogleCloudWebriskV1RawIndices {
63
+ /** The indices to remove from a lexicographically-sorted local list. */
64
+ indices?: number[];
65
+ }
66
+ interface GoogleCloudWebriskV1RiceDeltaEncoding {
67
+ /** The encoded deltas that are encoded using the Golomb-Rice coder. */
68
+ encodedData?: string;
69
+ /** 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`. */
70
+ entryCount?: number;
71
+ /** The offset of the first entry in the encoded data, or, if only a single integer was encoded, that single integer's value. If the field is empty or missing, assume zero. */
72
+ firstValue?: string;
73
+ /** The Golomb-Rice parameter, which is a number between 2 and 28. This field is missing (that is, zero) if `num_entries` is zero. */
74
+ riceParameter?: number;
75
+ }
76
+ interface GoogleCloudWebriskV1SearchHashesResponse {
77
+ /** For requested entities that did not match the threat list, how long to cache the response until. */
78
+ negativeExpireTime?: string;
79
+ /** The full hashes that matched the requested prefixes. The hash will be populated in the key. */
80
+ threats?: GoogleCloudWebriskV1SearchHashesResponseThreatHash[];
81
+ }
82
+ interface GoogleCloudWebriskV1SearchHashesResponseThreatHash {
83
+ /** The cache lifetime for the returned match. Clients must not cache this response past this timestamp to avoid false positives. */
84
+ expireTime?: string;
85
+ /** A 32 byte SHA256 hash. This field is in binary format. For JSON requests, hashes are base64-encoded. */
86
+ hash?: string;
87
+ /** The ThreatList this threat belongs to. This must contain at least one entry. */
88
+ threatTypes?: string[];
89
+ }
90
+ interface GoogleCloudWebriskV1SearchUrisResponse {
91
+ /** The threat list matches. This may be empty if the URI is on no list. */
92
+ threat?: GoogleCloudWebriskV1SearchUrisResponseThreatUri;
93
+ }
94
+ interface GoogleCloudWebriskV1SearchUrisResponseThreatUri {
95
+ /** The cache lifetime for the returned match. Clients must not cache this response past this timestamp to avoid false positives. */
96
+ expireTime?: string;
97
+ /** The ThreatList this threat belongs to. */
98
+ threatTypes?: string[];
99
+ }
100
+ interface GoogleCloudWebriskV1Submission {
101
+ /** ThreatTypes found to be associated with the submitted URI after reviewing it. This may be empty if the URI was not added to any list. */
102
+ threatTypes?: string[];
103
+ /** Required. The URI that is being reported for malicious content to be analyzed. */
104
+ uri?: string;
105
+ }
106
+ interface GoogleCloudWebriskV1SubmitUriMetadata {
107
+ /** Creation time of the operation. */
108
+ createTime?: string;
109
+ /** The state of the operation. */
110
+ state?: string;
111
+ /** Latest update time of the operation. */
112
+ updateTime?: string;
113
+ }
114
+ interface GoogleCloudWebriskV1SubmitUriRequest {
115
+ /** Required. The submission that contains the URI to be scanned. */
116
+ submission?: GoogleCloudWebriskV1Submission;
117
+ }
118
+ interface GoogleCloudWebriskV1ThreatEntryAdditions {
119
+ /** The raw SHA256-formatted entries. Repeated to allow returning sets of hashes with different prefix sizes. */
120
+ rawHashes?: GoogleCloudWebriskV1RawHashes[];
121
+ /**
122
+ * The encoded 4-byte prefixes of SHA256-formatted entries, using a Golomb-Rice encoding. The hashes are converted to uint32, sorted in ascending order, then delta encoded and stored
123
+ * as encoded_data.
124
+ */
125
+ riceHashes?: GoogleCloudWebriskV1RiceDeltaEncoding;
126
+ }
127
+ interface GoogleCloudWebriskV1ThreatEntryRemovals {
128
+ /** The raw removal indices for a local list. */
129
+ rawIndices?: GoogleCloudWebriskV1RawIndices;
130
+ /**
131
+ * The encoded local, lexicographically-sorted list indices, using a Golomb-Rice encoding. Used for sending compressed removal indices. The removal indices (uint32) are sorted in
132
+ * ascending order, then delta encoded and stored as encoded_data.
133
+ */
134
+ riceIndices?: GoogleCloudWebriskV1RiceDeltaEncoding;
135
+ }
136
+ // tslint:disable-next-line:no-empty-interface
137
+ interface GoogleLongrunningCancelOperationRequest {
138
+ }
139
+ interface GoogleLongrunningListOperationsResponse {
140
+ /** The standard List next-page token. */
141
+ nextPageToken?: string;
142
+ /** A list of operations that matches the specified filter in the request. */
143
+ operations?: GoogleLongrunningOperation[];
144
+ }
145
+ interface GoogleLongrunningOperation {
146
+ /** If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available. */
147
+ done?: boolean;
148
+ /** The error result of the operation in case of failure or cancellation. */
149
+ error?: GoogleRpcStatus;
150
+ /**
151
+ * Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such
152
+ * metadata. Any method that returns a long-running operation should document the metadata type, if any.
153
+ */
154
+ metadata?: { [P in string]: any };
155
+ /**
156
+ * The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending
157
+ * with `operations/{unique_id}`.
158
+ */
159
+ name?: string;
160
+ /**
161
+ * The normal response of the operation in case of success. If the original method returns no data on success, such as `Delete`, the response is `google.protobuf.Empty`. If the
162
+ * original method is standard `Get`/`Create`/`Update`, the response should be the resource. For other methods, the response should have the type `XxxResponse`, where `Xxx` is the
163
+ * original method name. For example, if the original method name is `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`.
164
+ */
165
+ response?: { [P in string]: any };
166
+ }
167
+ // tslint:disable-next-line:no-empty-interface
168
+ interface GoogleProtobufEmpty {
169
+ }
170
+ interface GoogleRpcStatus {
171
+ /** The status code, which should be an enum value of google.rpc.Code. */
172
+ code?: number;
173
+ /** A list of messages that carry the error details. There is a common set of message types for APIs to use. */
174
+ details?: Array<{ [P in string]: any }>;
175
+ /**
176
+ * A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the
177
+ * client.
178
+ */
179
+ message?: string;
180
+ }
181
+ interface HashesResource {
182
+ /**
183
+ * Gets the full hashes that match the requested hash prefix. This is used after a hash prefix is looked up in a threatList and there is a match. The client side threatList only holds
184
+ * partial hashes so the client must query this method to determine if there is a full hash match of a threat.
185
+ */
186
+ search(request?: {
187
+ /** V1 error format. */
188
+ "$.xgafv"?: string;
189
+ /** OAuth access token. */
190
+ access_token?: string;
191
+ /** Data format for response. */
192
+ alt?: string;
193
+ /** JSONP */
194
+ callback?: string;
195
+ /** Selector specifying which fields to include in a partial response. */
196
+ fields?: string;
197
+ /**
198
+ * A hash prefix, consisting of the most significant 4-32 bytes of a SHA256 hash. For JSON requests, this field is base64-encoded. Note that if this parameter is provided by a URI,
199
+ * it must be encoded using the web safe base64 variant (RFC 4648).
200
+ */
201
+ hashPrefix?: string;
202
+ /** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
203
+ key?: string;
204
+ /** OAuth 2.0 token for the current user. */
205
+ oauth_token?: string;
206
+ /** Returns response with indentations and line breaks. */
207
+ prettyPrint?: boolean;
208
+ /** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
209
+ quotaUser?: string;
210
+ /** Required. The ThreatLists to search in. Multiple ThreatLists may be specified. */
211
+ threatTypes?: string | string[];
212
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
213
+ upload_protocol?: string;
214
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
215
+ uploadType?: string;
216
+ }): Request<GoogleCloudWebriskV1SearchHashesResponse>;
217
+ }
218
+ interface OperationsResource {
219
+ /**
220
+ * Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support
221
+ * this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the
222
+ * operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a
223
+ * google.rpc.Status.code of 1, corresponding to `Code.CANCELLED`.
224
+ */
225
+ cancel(request: {
226
+ /** V1 error format. */
227
+ "$.xgafv"?: string;
228
+ /** OAuth access token. */
229
+ access_token?: string;
230
+ /** Data format for response. */
231
+ alt?: string;
232
+ /** JSONP */
233
+ callback?: string;
234
+ /** Selector specifying which fields to include in a partial response. */
235
+ fields?: string;
236
+ /** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
237
+ key?: string;
238
+ /** The name of the operation resource to be cancelled. */
239
+ name: string;
240
+ /** OAuth 2.0 token for the current user. */
241
+ oauth_token?: string;
242
+ /** Returns response with indentations and line breaks. */
243
+ prettyPrint?: boolean;
244
+ /** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
245
+ quotaUser?: string;
246
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
247
+ upload_protocol?: string;
248
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
249
+ uploadType?: string;
250
+ /** Request body */
251
+ resource: GoogleLongrunningCancelOperationRequest;
252
+ }): Request<{}>;
253
+ cancel(request: {
254
+ /** V1 error format. */
255
+ "$.xgafv"?: string;
256
+ /** OAuth access token. */
257
+ access_token?: string;
258
+ /** Data format for response. */
259
+ alt?: string;
260
+ /** JSONP */
261
+ callback?: string;
262
+ /** Selector specifying which fields to include in a partial response. */
263
+ fields?: string;
264
+ /** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
265
+ key?: string;
266
+ /** The name of the operation resource to be cancelled. */
267
+ name: string;
268
+ /** OAuth 2.0 token for the current user. */
269
+ oauth_token?: string;
270
+ /** Returns response with indentations and line breaks. */
271
+ prettyPrint?: boolean;
272
+ /** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
273
+ quotaUser?: string;
274
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
275
+ upload_protocol?: string;
276
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
277
+ uploadType?: string;
278
+ },
279
+ body: GoogleLongrunningCancelOperationRequest): Request<{}>;
280
+ /**
281
+ * Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't
282
+ * support this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
283
+ */
284
+ delete(request?: {
285
+ /** V1 error format. */
286
+ "$.xgafv"?: string;
287
+ /** OAuth access token. */
288
+ access_token?: string;
289
+ /** Data format for response. */
290
+ alt?: string;
291
+ /** JSONP */
292
+ callback?: string;
293
+ /** Selector specifying which fields to include in a partial response. */
294
+ fields?: string;
295
+ /** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
296
+ key?: string;
297
+ /** The name of the operation resource to be deleted. */
298
+ name: string;
299
+ /** OAuth 2.0 token for the current user. */
300
+ oauth_token?: string;
301
+ /** Returns response with indentations and line breaks. */
302
+ prettyPrint?: boolean;
303
+ /** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
304
+ quotaUser?: string;
305
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
306
+ upload_protocol?: string;
307
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
308
+ uploadType?: string;
309
+ }): Request<{}>;
310
+ /** Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service. */
311
+ get(request?: {
312
+ /** V1 error format. */
313
+ "$.xgafv"?: string;
314
+ /** OAuth access token. */
315
+ access_token?: string;
316
+ /** Data format for response. */
317
+ alt?: string;
318
+ /** JSONP */
319
+ callback?: string;
320
+ /** Selector specifying which fields to include in a partial response. */
321
+ fields?: string;
322
+ /** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
323
+ key?: string;
324
+ /** The name of the operation resource. */
325
+ name: string;
326
+ /** OAuth 2.0 token for the current user. */
327
+ oauth_token?: string;
328
+ /** Returns response with indentations and line breaks. */
329
+ prettyPrint?: boolean;
330
+ /** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
331
+ quotaUser?: string;
332
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
333
+ upload_protocol?: string;
334
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
335
+ uploadType?: string;
336
+ }): Request<GoogleLongrunningOperation>;
337
+ /**
338
+ * Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`. NOTE: the `name` binding allows API services
339
+ * to override the binding to use different resource name schemes, such as `users/*‍/operations`. To override the binding, API services can add a binding such as
340
+ * `"/v1/{name=users/*}/operations"` to their service configuration. For backwards compatibility, the default name includes the operations collection id, however overriding users must
341
+ * ensure the name binding is the parent resource, without the operations collection id.
342
+ */
343
+ list(request?: {
344
+ /** V1 error format. */
345
+ "$.xgafv"?: string;
346
+ /** OAuth access token. */
347
+ access_token?: string;
348
+ /** Data format for response. */
349
+ alt?: string;
350
+ /** JSONP */
351
+ callback?: string;
352
+ /** Selector specifying which fields to include in a partial response. */
353
+ fields?: string;
354
+ /** The standard list filter. */
355
+ filter?: string;
356
+ /** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
357
+ key?: string;
358
+ /** The name of the operation's parent resource. */
359
+ name: string;
360
+ /** OAuth 2.0 token for the current user. */
361
+ oauth_token?: string;
362
+ /** The standard list page size. */
363
+ pageSize?: number;
364
+ /** The standard list page token. */
365
+ pageToken?: string;
366
+ /** Returns response with indentations and line breaks. */
367
+ prettyPrint?: boolean;
368
+ /** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
369
+ quotaUser?: string;
370
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
371
+ upload_protocol?: string;
372
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
373
+ uploadType?: string;
374
+ }): Request<GoogleLongrunningListOperationsResponse>;
375
+ }
376
+ interface SubmissionsResource {
377
+ /**
378
+ * Creates a Submission of a URI suspected of containing phishing content to be reviewed. If the result verifies the existence of malicious phishing content, the site will be added to
379
+ * the [Google's Social Engineering lists](https://support.google.com/webmasters/answer/6350487/) in order to protect users that could get exposed to this threat in the future. Only
380
+ * allowlisted projects can use this method during Early Access. Please reach out to Sales or your customer engineer to obtain access.
381
+ */
382
+ create(request: {
383
+ /** V1 error format. */
384
+ "$.xgafv"?: string;
385
+ /** OAuth access token. */
386
+ access_token?: string;
387
+ /** Data format for response. */
388
+ alt?: string;
389
+ /** JSONP */
390
+ callback?: string;
391
+ /** Selector specifying which fields to include in a partial response. */
392
+ fields?: string;
393
+ /** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
394
+ key?: string;
395
+ /** OAuth 2.0 token for the current user. */
396
+ oauth_token?: string;
397
+ /** Required. The name of the project that is making the submission. This string is in the format "projects/{project_number}". */
398
+ parent: string;
399
+ /** Returns response with indentations and line breaks. */
400
+ prettyPrint?: boolean;
401
+ /** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
402
+ quotaUser?: string;
403
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
404
+ upload_protocol?: string;
405
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
406
+ uploadType?: string;
407
+ /** Request body */
408
+ resource: GoogleCloudWebriskV1Submission;
409
+ }): Request<GoogleCloudWebriskV1Submission>;
410
+ create(request: {
411
+ /** V1 error format. */
412
+ "$.xgafv"?: string;
413
+ /** OAuth access token. */
414
+ access_token?: string;
415
+ /** Data format for response. */
416
+ alt?: string;
417
+ /** JSONP */
418
+ callback?: string;
419
+ /** Selector specifying which fields to include in a partial response. */
420
+ fields?: string;
421
+ /** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
422
+ key?: string;
423
+ /** OAuth 2.0 token for the current user. */
424
+ oauth_token?: string;
425
+ /** Required. The name of the project that is making the submission. This string is in the format "projects/{project_number}". */
426
+ parent: string;
427
+ /** Returns response with indentations and line breaks. */
428
+ prettyPrint?: boolean;
429
+ /** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
430
+ quotaUser?: string;
431
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
432
+ upload_protocol?: string;
433
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
434
+ uploadType?: string;
435
+ },
436
+ body: GoogleCloudWebriskV1Submission): Request<GoogleCloudWebriskV1Submission>;
437
+ }
438
+ interface UrisResource {
439
+ /**
440
+ * Submits a URI suspected of containing malicious content to be reviewed. Returns a google.longrunning.Operation which, once the review is complete, is updated with its result. You
441
+ * can use the [Pub/Sub API] (https://cloud.google.com/pubsub) to receive notifications for the returned Operation. If the result verifies the existence of malicious content, the site
442
+ * will be added to the [Google's Social Engineering lists] (https://support.google.com/webmasters/answer/6350487/) in order to protect users that could get exposed to this threat in
443
+ * the future. Only allowlisted projects can use this method during Early Access. Please reach out to Sales or your customer engineer to obtain access.
444
+ */
445
+ submit(request: {
446
+ /** V1 error format. */
447
+ "$.xgafv"?: string;
448
+ /** OAuth access token. */
449
+ access_token?: string;
450
+ /** Data format for response. */
451
+ alt?: string;
452
+ /** JSONP */
453
+ callback?: string;
454
+ /** Selector specifying which fields to include in a partial response. */
455
+ fields?: string;
456
+ /** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
457
+ key?: string;
458
+ /** OAuth 2.0 token for the current user. */
459
+ oauth_token?: string;
460
+ /** Required. The name of the project that is making the submission. This string is in the format "projects/{project_number}". */
461
+ parent: string;
462
+ /** Returns response with indentations and line breaks. */
463
+ prettyPrint?: boolean;
464
+ /** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
465
+ quotaUser?: string;
466
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
467
+ upload_protocol?: string;
468
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
469
+ uploadType?: string;
470
+ /** Request body */
471
+ resource: GoogleCloudWebriskV1SubmitUriRequest;
472
+ }): Request<GoogleLongrunningOperation>;
473
+ submit(request: {
474
+ /** V1 error format. */
475
+ "$.xgafv"?: string;
476
+ /** OAuth access token. */
477
+ access_token?: string;
478
+ /** Data format for response. */
479
+ alt?: string;
480
+ /** JSONP */
481
+ callback?: string;
482
+ /** Selector specifying which fields to include in a partial response. */
483
+ fields?: string;
484
+ /** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
485
+ key?: string;
486
+ /** OAuth 2.0 token for the current user. */
487
+ oauth_token?: string;
488
+ /** Required. The name of the project that is making the submission. This string is in the format "projects/{project_number}". */
489
+ parent: string;
490
+ /** Returns response with indentations and line breaks. */
491
+ prettyPrint?: boolean;
492
+ /** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
493
+ quotaUser?: string;
494
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
495
+ upload_protocol?: string;
496
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
497
+ uploadType?: string;
498
+ },
499
+ body: GoogleCloudWebriskV1SubmitUriRequest): Request<GoogleLongrunningOperation>;
500
+ }
501
+ interface ProjectsResource {
502
+ operations: OperationsResource;
503
+ submissions: SubmissionsResource;
504
+ uris: UrisResource;
505
+ }
506
+ interface ThreatListsResource {
507
+ /**
508
+ * Gets the most recent threat list diffs. These diffs should be applied to a local database of hashes to keep it up-to-date. If the local database is empty or excessively out-of-date,
509
+ * a complete snapshot of the database will be returned. This Method only updates a single ThreatList at a time. To update multiple ThreatList databases, this method needs to be called
510
+ * once for each list.
511
+ */
512
+ computeDiff(request?: {
513
+ /** V1 error format. */
514
+ "$.xgafv"?: string;
515
+ /** OAuth access token. */
516
+ access_token?: string;
517
+ /** Data format for response. */
518
+ alt?: string;
519
+ /** JSONP */
520
+ callback?: string;
521
+ /**
522
+ * Sets the maximum number of entries that the client is willing to have in the local database. This should be a power of 2 between 2**10 and 2**20. If zero, no database size limit
523
+ * is set.
524
+ */
525
+ "constraints.maxDatabaseEntries"?: number;
526
+ /**
527
+ * The maximum size in number of entries. The diff will not contain more entries than this value. This should be a power of 2 between 2**10 and 2**20. If zero, no diff size limit
528
+ * is set.
529
+ */
530
+ "constraints.maxDiffEntries"?: number;
531
+ /** The compression types supported by the client. */
532
+ "constraints.supportedCompressions"?: string | string[];
533
+ /** Selector specifying which fields to include in a partial response. */
534
+ fields?: string;
535
+ /** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
536
+ key?: string;
537
+ /** OAuth 2.0 token for the current user. */
538
+ oauth_token?: string;
539
+ /** Returns response with indentations and line breaks. */
540
+ prettyPrint?: boolean;
541
+ /** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
542
+ quotaUser?: string;
543
+ /**
544
+ * Required. The threat list to update. Only a single ThreatType should be specified per request. If you want to handle multiple ThreatTypes, you must make one request per
545
+ * ThreatType.
546
+ */
547
+ threatType?: string;
548
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
549
+ upload_protocol?: string;
550
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
551
+ uploadType?: string;
552
+ /**
553
+ * The current version token of the client for the requested list (the client version that was received from the last successful diff). If the client does not have a version token
554
+ * (this is the first time calling ComputeThreatListDiff), this may be left empty and a full database snapshot will be returned.
555
+ */
556
+ versionToken?: string;
557
+ }): Request<GoogleCloudWebriskV1ComputeThreatListDiffResponse>;
558
+ }
559
+ interface UrisResource {
560
+ /**
561
+ * This method is used to check whether a URI is on a given threatList. Multiple threatLists may be searched in a single query. The response will list all requested threatLists the URI
562
+ * was found to match. If the URI is not found on any of the requested ThreatList an empty response will be returned.
563
+ */
564
+ search(request?: {
565
+ /** V1 error format. */
566
+ "$.xgafv"?: string;
567
+ /** OAuth access token. */
568
+ access_token?: string;
569
+ /** Data format for response. */
570
+ alt?: string;
571
+ /** JSONP */
572
+ callback?: string;
573
+ /** Selector specifying which fields to include in a partial response. */
574
+ fields?: string;
575
+ /** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
576
+ key?: string;
577
+ /** OAuth 2.0 token for the current user. */
578
+ oauth_token?: string;
579
+ /** Returns response with indentations and line breaks. */
580
+ prettyPrint?: boolean;
581
+ /** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
582
+ quotaUser?: string;
583
+ /** Required. The ThreatLists to search in. Multiple ThreatLists may be specified. */
584
+ threatTypes?: string | string[];
585
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
586
+ upload_protocol?: string;
587
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
588
+ uploadType?: string;
589
+ /** Required. The URI to be checked for matches. */
590
+ uri?: string;
591
+ }): Request<GoogleCloudWebriskV1SearchUrisResponse>;
592
+ }
593
+
594
+ const hashes: HashesResource;
595
+
596
+ const projects: ProjectsResource;
597
+
598
+ const threatLists: ThreatListsResource;
599
+
600
+ const uris: UrisResource;
601
+ }
602
+ }
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@maxim_mazurok/gapi.client.webrisk-v1",
3
+ "version": "0.0.20220806",
4
+ "description": "TypeScript typings for Web Risk API v1",
5
+ "license": "MIT",
6
+ "author": {
7
+ "email": "maxim@mazurok.com",
8
+ "name": "Maxim Mazurok",
9
+ "url": "https://maxim.mazurok.com"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/Maxim-Mazurok/google-api-typings-generator.git"
14
+ },
15
+ "types": "index.d.ts",
16
+ "dependencies": {
17
+ "@types/gapi.client": "*",
18
+ "@types/gapi.client.discovery": "*"
19
+ }
20
+ }
package/readme.md ADDED
@@ -0,0 +1,83 @@
1
+ # TypeScript typings for Web Risk API v1
2
+
3
+
4
+ For detailed description please check [documentation](https://cloud.google.com/web-risk/).
5
+
6
+ ## Installing
7
+
8
+ Install typings for Web Risk API:
9
+
10
+ ```
11
+ npm install @types/gapi.client.webrisk-v1 --save-dev
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ You need to initialize Google API client in your code:
17
+
18
+ ```typescript
19
+ gapi.load('client', () => {
20
+ // now we can use gapi.client
21
+ // ...
22
+ });
23
+ ```
24
+
25
+ Then load api client wrapper:
26
+
27
+ ```typescript
28
+ gapi.client.load('https://webrisk.googleapis.com/$discovery/rest?version=v1', () => {
29
+ // now we can use:
30
+ // gapi.client.webrisk
31
+ });
32
+ ```
33
+
34
+ ```typescript
35
+ // Deprecated, use discovery document URL, see https://github.com/google/google-api-javascript-client/blob/master/docs/reference.md#----gapiclientloadname----version----callback--
36
+ gapi.client.load('webrisk', 'v1', () => {
37
+ // now we can use:
38
+ // gapi.client.webrisk
39
+ });
40
+ ```
41
+
42
+ Don't forget to authenticate your client before sending any request to resources:
43
+
44
+ ```typescript
45
+ // declare client_id registered in Google Developers Console
46
+ var client_id = '',
47
+ scope = [
48
+ // See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
49
+ 'https://www.googleapis.com/auth/cloud-platform',
50
+ ],
51
+ immediate = true;
52
+ // ...
53
+
54
+ gapi.auth.authorize(
55
+ { client_id: client_id, scope: scope, immediate: immediate },
56
+ authResult => {
57
+ if (authResult && !authResult.error) {
58
+ /* handle successful authorization */
59
+ } else {
60
+ /* handle authorization error */
61
+ }
62
+ });
63
+ ```
64
+
65
+ After that you can use Web Risk API resources: <!-- TODO: make this work for multiple namespaces -->
66
+
67
+ ```typescript
68
+
69
+ /*
70
+ Gets the full hashes that match the requested hash prefix. This is used after a hash prefix is looked up in a threatList and there is a match. The client side threatList only holds partial hashes so the client must query this method to determine if there is a full hash match of a threat.
71
+ */
72
+ await gapi.client.webrisk.hashes.search({ });
73
+
74
+ /*
75
+ Gets the most recent threat list diffs. These diffs should be applied to a local database of hashes to keep it up-to-date. If the local database is empty or excessively out-of-date, a complete snapshot of the database will be returned. This Method only updates a single ThreatList at a time. To update multiple ThreatList databases, this method needs to be called once for each list.
76
+ */
77
+ await gapi.client.webrisk.threatLists.computeDiff({ });
78
+
79
+ /*
80
+ This method is used to check whether a URI is on a given threatList. Multiple threatLists may be searched in a single query. The response will list all requested threatLists the URI was found to match. If the URI is not found on any of the requested ThreatList an empty response will be returned.
81
+ */
82
+ await gapi.client.webrisk.uris.search({ });
83
+ ```
package/tests.ts ADDED
@@ -0,0 +1,123 @@
1
+ /* This is stub file for gapi.client.webrisk-v1 definition tests */
2
+ // IMPORTANT
3
+ // This file was generated by https://github.com/Maxim-Mazurok/google-api-typings-generator. Please do not edit it manually.
4
+ // In case of any problems please post issue to https://github.com/Maxim-Mazurok/google-api-typings-generator
5
+
6
+ // Revision: 20220806
7
+
8
+ gapi.load('client', async () => {
9
+ /** now we can use gapi.client */
10
+
11
+ await gapi.client.load('https://webrisk.googleapis.com/$discovery/rest?version=v1');
12
+ /** now we can use gapi.client.webrisk */
13
+
14
+ /** don't forget to authenticate your client before sending any request to resources: */
15
+ /** declare client_id registered in Google Developers Console */
16
+ const client_id = '<<PUT YOUR CLIENT ID HERE>>';
17
+ const scope = [
18
+ /** See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account. */
19
+ 'https://www.googleapis.com/auth/cloud-platform',
20
+ ];
21
+ const immediate = false;
22
+ gapi.auth.authorize({ client_id, scope, immediate }, authResult => {
23
+ if (authResult && !authResult.error) {
24
+ /** handle successful authorization */
25
+ run();
26
+ } else {
27
+ /** handle authorization error */
28
+ }
29
+ });
30
+
31
+ async function run() {
32
+ /**
33
+ * Gets the full hashes that match the requested hash prefix. This is used after a hash prefix is looked up in a threatList and there is a match. The client side threatList only holds
34
+ * partial hashes so the client must query this method to determine if there is a full hash match of a threat.
35
+ */
36
+ await gapi.client.webrisk.hashes.search({
37
+ hashPrefix: "Test string",
38
+ threatTypes: "Test string",
39
+ });
40
+ /**
41
+ * Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this
42
+ * method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation
43
+ * completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of
44
+ * 1, corresponding to `Code.CANCELLED`.
45
+ */
46
+ await gapi.client.webrisk.projects.operations.cancel({
47
+ name: "Test string",
48
+ }, {
49
+ });
50
+ /**
51
+ * Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support
52
+ * this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
53
+ */
54
+ await gapi.client.webrisk.projects.operations.delete({
55
+ name: "Test string",
56
+ });
57
+ /** Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service. */
58
+ await gapi.client.webrisk.projects.operations.get({
59
+ name: "Test string",
60
+ });
61
+ /**
62
+ * Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`. NOTE: the `name` binding allows API services to
63
+ * override the binding to use different resource name schemes, such as `users/*‍/operations`. To override the binding, API services can add a binding such as
64
+ * `"/v1/{name=users/*}/operations"` to their service configuration. For backwards compatibility, the default name includes the operations collection id, however overriding users must
65
+ * ensure the name binding is the parent resource, without the operations collection id.
66
+ */
67
+ await gapi.client.webrisk.projects.operations.list({
68
+ filter: "Test string",
69
+ name: "Test string",
70
+ pageSize: 42,
71
+ pageToken: "Test string",
72
+ });
73
+ /**
74
+ * Creates a Submission of a URI suspected of containing phishing content to be reviewed. If the result verifies the existence of malicious phishing content, the site will be added to the
75
+ * [Google's Social Engineering lists](https://support.google.com/webmasters/answer/6350487/) in order to protect users that could get exposed to this threat in the future. Only
76
+ * allowlisted projects can use this method during Early Access. Please reach out to Sales or your customer engineer to obtain access.
77
+ */
78
+ await gapi.client.webrisk.projects.submissions.create({
79
+ parent: "Test string",
80
+ }, {
81
+ threatTypes: [
82
+ "Test string"
83
+ ],
84
+ uri: "Test string",
85
+ });
86
+ /**
87
+ * Submits a URI suspected of containing malicious content to be reviewed. Returns a google.longrunning.Operation which, once the review is complete, is updated with its result. You can
88
+ * use the [Pub/Sub API] (https://cloud.google.com/pubsub) to receive notifications for the returned Operation. If the result verifies the existence of malicious content, the site will be
89
+ * added to the [Google's Social Engineering lists] (https://support.google.com/webmasters/answer/6350487/) in order to protect users that could get exposed to this threat in the future.
90
+ * Only allowlisted projects can use this method during Early Access. Please reach out to Sales or your customer engineer to obtain access.
91
+ */
92
+ await gapi.client.webrisk.projects.uris.submit({
93
+ parent: "Test string",
94
+ }, {
95
+ submission: {
96
+ threatTypes: [
97
+ "Test string"
98
+ ],
99
+ uri: "Test string",
100
+ },
101
+ });
102
+ /**
103
+ * Gets the most recent threat list diffs. These diffs should be applied to a local database of hashes to keep it up-to-date. If the local database is empty or excessively out-of-date, a
104
+ * complete snapshot of the database will be returned. This Method only updates a single ThreatList at a time. To update multiple ThreatList databases, this method needs to be called once
105
+ * for each list.
106
+ */
107
+ await gapi.client.webrisk.threatLists.computeDiff({
108
+ "constraints.maxDatabaseEntries": 42,
109
+ "constraints.maxDiffEntries": 42,
110
+ "constraints.supportedCompressions": "Test string",
111
+ threatType: "Test string",
112
+ versionToken: "Test string",
113
+ });
114
+ /**
115
+ * This method is used to check whether a URI is on a given threatList. Multiple threatLists may be searched in a single query. The response will list all requested threatLists the URI was
116
+ * found to match. If the URI is not found on any of the requested ThreatList an empty response will be returned.
117
+ */
118
+ await gapi.client.webrisk.uris.search({
119
+ threatTypes: "Test string",
120
+ uri: "Test string",
121
+ });
122
+ }
123
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "commonjs",
4
+ "lib": ["es6", "dom"],
5
+ "noImplicitAny": true,
6
+ "noImplicitThis": true,
7
+ "strictNullChecks": true,
8
+ "baseUrl": "../",
9
+ "typeRoots": [
10
+ "../"
11
+ ],
12
+ "types": [],
13
+ "noEmit": true,
14
+ "forceConsistentCasingInFileNames": true,
15
+ "strictFunctionTypes": true
16
+ },
17
+ "files": ["index.d.ts", "tests.ts"]
18
+ }
package/tslint.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "dtslint/dtslint.json",
3
+ "rules": {
4
+ "no-redundant-jsdoc": false
5
+ }
6
+ }