Skip to content

Commit 46c47ea

Browse files
feat(safebrowsing): update the API
#### safebrowsing:v5 The following keys were added: - resources.urls.methods.search.description - resources.urls.methods.search.flatPath - resources.urls.methods.search.httpMethod - resources.urls.methods.search.id - resources.urls.methods.search.parameterOrder - resources.urls.methods.search.parameters.urls.description - resources.urls.methods.search.parameters.urls.location - resources.urls.methods.search.parameters.urls.repeated - resources.urls.methods.search.parameters.urls.type - resources.urls.methods.search.path - resources.urls.methods.search.response.$ref - schemas.GoogleSecuritySafebrowsingV5SearchUrlsResponse.description - schemas.GoogleSecuritySafebrowsingV5SearchUrlsResponse.id - schemas.GoogleSecuritySafebrowsingV5SearchUrlsResponse.properties.cacheDuration.description - schemas.GoogleSecuritySafebrowsingV5SearchUrlsResponse.properties.cacheDuration.format - schemas.GoogleSecuritySafebrowsingV5SearchUrlsResponse.properties.cacheDuration.type - schemas.GoogleSecuritySafebrowsingV5SearchUrlsResponse.properties.threats.description - schemas.GoogleSecuritySafebrowsingV5SearchUrlsResponse.properties.threats.items.$ref - schemas.GoogleSecuritySafebrowsingV5SearchUrlsResponse.properties.threats.type - schemas.GoogleSecuritySafebrowsingV5SearchUrlsResponse.type - schemas.GoogleSecuritySafebrowsingV5ThreatUrl.description - schemas.GoogleSecuritySafebrowsingV5ThreatUrl.id - schemas.GoogleSecuritySafebrowsingV5ThreatUrl.properties.threatTypes.description - schemas.GoogleSecuritySafebrowsingV5ThreatUrl.properties.threatTypes.items.enum - schemas.GoogleSecuritySafebrowsingV5ThreatUrl.properties.threatTypes.items.enumDescriptions - schemas.GoogleSecuritySafebrowsingV5ThreatUrl.properties.threatTypes.items.type - schemas.GoogleSecuritySafebrowsingV5ThreatUrl.properties.threatTypes.type - schemas.GoogleSecuritySafebrowsingV5ThreatUrl.properties.url.description - schemas.GoogleSecuritySafebrowsingV5ThreatUrl.properties.url.type - schemas.GoogleSecuritySafebrowsingV5ThreatUrl.type The following keys were changed: - resources.hashList.methods.get.description - resources.hashLists.methods.batchGet.description - resources.hashLists.methods.list.description - resources.hashes.methods.search.description
1 parent c76e0ea commit 46c47ea

File tree

2 files changed

+269
-9
lines changed

2 files changed

+269
-9
lines changed

discovery/safebrowsing-v5.json

Lines changed: 79 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
"hashList": {
100100
"methods": {
101101
"get": {
102-
"description": "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.",
102+
"description": "Gets 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.",
103103
"flatPath": "v5/hashList/{name}",
104104
"httpMethod": "GET",
105105
"id": "safebrowsing.hashList.get",
@@ -142,7 +142,7 @@
142142
"hashLists": {
143143
"methods": {
144144
"batchGet": {
145-
"description": "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.",
145+
"description": "Gets 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.",
146146
"flatPath": "v5/hashLists:batchGet",
147147
"httpMethod": "GET",
148148
"id": "safebrowsing.hashLists.batchGet",
@@ -180,7 +180,7 @@
180180
}
181181
},
182182
"list": {
183-
"description": "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.",
183+
"description": "Lists 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.",
184184
"flatPath": "v5/hashLists",
185185
"httpMethod": "GET",
186186
"id": "safebrowsing.hashLists.list",
@@ -208,7 +208,7 @@
208208
"hashes": {
209209
"methods": {
210210
"search": {
211-
"description": "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).",
211+
"description": "Searches 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).",
212212
"flatPath": "v5/hashes:search",
213213
"httpMethod": "GET",
214214
"id": "safebrowsing.hashes.search",
@@ -228,9 +228,32 @@
228228
}
229229
}
230230
}
231+
},
232+
"urls": {
233+
"methods": {
234+
"search": {
235+
"description": "Searches for URLs matching known threats. Each URL and it's host-suffix and path-prefix expressions (up to a limited depth) are checked. This means that the response may contain URLs that were not included in the request, but are expressions of the requested URLs.",
236+
"flatPath": "v5/urls:search",
237+
"httpMethod": "GET",
238+
"id": "safebrowsing.urls.search",
239+
"parameterOrder": [],
240+
"parameters": {
241+
"urls": {
242+
"description": "Required. The URLs to be looked up. Clients MUST NOT send more than 50 URLs.",
243+
"location": "query",
244+
"repeated": true,
245+
"type": "string"
246+
}
247+
},
248+
"path": "v5/urls:search",
249+
"response": {
250+
"$ref": "GoogleSecuritySafebrowsingV5SearchUrlsResponse"
251+
}
252+
}
253+
}
231254
}
232255
},
233-
"revision": "20250518",
256+
"revision": "20251214",
234257
"rootUrl": "https://safebrowsing.googleapis.com/",
235258
"schemas": {
236259
"GoogleSecuritySafebrowsingV5BatchGetHashListsResponse": {
@@ -595,6 +618,57 @@
595618
}
596619
},
597620
"type": "object"
621+
},
622+
"GoogleSecuritySafebrowsingV5SearchUrlsResponse": {
623+
"description": "The response returned after searching threats matching the specified URLs. If nothing is found, the server will return an OK status (HTTP status code 200) with the `threats` field empty, rather than returning a NOT_FOUND status (HTTP status code 404).",
624+
"id": "GoogleSecuritySafebrowsingV5SearchUrlsResponse",
625+
"properties": {
626+
"cacheDuration": {
627+
"description": "The client-side cache duration. The client MUST add this duration to the current time to determine the expiration time. The expiration time then applies to every URL queried by the client in the request, regardless of how many URLs are returned in the response. Even if the server returns no matches for a particular URL, this fact MUST also be cached by the client. If and only if the field `threats` is empty, the client MAY increase the `cache_duration` to determine a new expiration that is later than that specified by the server. In any case, the increased cache duration must not be longer than 24 hours. Important: the client MUST NOT assume that the server will return the same cache duration for all responses. The server MAY choose different cache durations for different responses depending on the situation.",
628+
"format": "google-duration",
629+
"type": "string"
630+
},
631+
"threats": {
632+
"description": "Unordered list. The unordered list of threat matches found. Each entry contains a URL and the threat types that were found matching that URL. The list size can be greater than the number of URLs in the request as the all expressions of the URL would've been considered.",
633+
"items": {
634+
"$ref": "GoogleSecuritySafebrowsingV5ThreatUrl"
635+
},
636+
"type": "array"
637+
}
638+
},
639+
"type": "object"
640+
},
641+
"GoogleSecuritySafebrowsingV5ThreatUrl": {
642+
"description": "A URL matching one or more threats.",
643+
"id": "GoogleSecuritySafebrowsingV5ThreatUrl",
644+
"properties": {
645+
"threatTypes": {
646+
"description": "Unordered list. The unordered list of threat that the URL is classified as.",
647+
"items": {
648+
"enum": [
649+
"THREAT_TYPE_UNSPECIFIED",
650+
"MALWARE",
651+
"SOCIAL_ENGINEERING",
652+
"UNWANTED_SOFTWARE",
653+
"POTENTIALLY_HARMFUL_APPLICATION"
654+
],
655+
"enumDescriptions": [
656+
"Unknown threat type. If this is returned by the server, the client shall disregard the enclosing `FullHashDetail` altogether.",
657+
"Malware threat type. Malware is any software or mobile application specifically designed to harm a computer, a mobile device, the software it's running, or its users. Malware exhibits malicious behavior that can include installing software without user consent and installing harmful software such as viruses. More information can be found [here](https://developers.google.com/search/docs/monitor-debug/security/malware).",
658+
"Social engineering threat type. Social engineering pages falsely purport to act on behalf of a third party with the intention of confusing viewers into performing an action with which the viewer would only trust a true agent of that third party. Phishing is a type of social engineering that tricks the viewer into performing the specific action of providing information, such as login credentials. More information can be found [here](https://developers.google.com/search/docs/monitor-debug/security/social-engineering).",
659+
"Unwanted software threat type. Unwanted software is any software that does not adhere to [Google's Software Principles](https://www.google.com/about/software-principles.html) but isn't malware.",
660+
"Potentially harmful application threat type [as used by Google Play Protect for the Play Store](https://developers.google.com/android/play-protect/potentially-harmful-applications)."
661+
],
662+
"type": "string"
663+
},
664+
"type": "array"
665+
},
666+
"url": {
667+
"description": "The requested URL that was matched by one or more threats.",
668+
"type": "string"
669+
}
670+
},
671+
"type": "object"
598672
}
599673
},
600674
"servicePath": "",

src/apis/safebrowsing/v5.ts

Lines changed: 190 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export namespace safebrowsing_v5 {
115115
hashes: Resource$Hashes;
116116
hashList: Resource$Hashlist;
117117
hashLists: Resource$Hashlists;
118+
urls: Resource$Urls;
118119

119120
constructor(options: GlobalOptions, google?: GoogleConfigurable) {
120121
this.context = {
@@ -125,6 +126,7 @@ export namespace safebrowsing_v5 {
125126
this.hashes = new Resource$Hashes(this.context);
126127
this.hashList = new Resource$Hashlist(this.context);
127128
this.hashLists = new Resource$Hashlists(this.context);
129+
this.urls = new Resource$Urls(this.context);
128130
}
129131
}
130132

@@ -359,6 +361,32 @@ export namespace safebrowsing_v5 {
359361
*/
360362
fullHashes?: Schema$GoogleSecuritySafebrowsingV5FullHash[];
361363
}
364+
/**
365+
* The response returned after searching threats matching the specified URLs. If nothing is found, the server will return an OK status (HTTP status code 200) with the `threats` field empty, rather than returning a NOT_FOUND status (HTTP status code 404).
366+
*/
367+
export interface Schema$GoogleSecuritySafebrowsingV5SearchUrlsResponse {
368+
/**
369+
* The client-side cache duration. The client MUST add this duration to the current time to determine the expiration time. The expiration time then applies to every URL queried by the client in the request, regardless of how many URLs are returned in the response. Even if the server returns no matches for a particular URL, this fact MUST also be cached by the client. If and only if the field `threats` is empty, the client MAY increase the `cache_duration` to determine a new expiration that is later than that specified by the server. In any case, the increased cache duration must not be longer than 24 hours. Important: the client MUST NOT assume that the server will return the same cache duration for all responses. The server MAY choose different cache durations for different responses depending on the situation.
370+
*/
371+
cacheDuration?: string | null;
372+
/**
373+
* Unordered list. The unordered list of threat matches found. Each entry contains a URL and the threat types that were found matching that URL. The list size can be greater than the number of URLs in the request as the all expressions of the URL would've been considered.
374+
*/
375+
threats?: Schema$GoogleSecuritySafebrowsingV5ThreatUrl[];
376+
}
377+
/**
378+
* A URL matching one or more threats.
379+
*/
380+
export interface Schema$GoogleSecuritySafebrowsingV5ThreatUrl {
381+
/**
382+
* Unordered list. The unordered list of threat that the URL is classified as.
383+
*/
384+
threatTypes?: string[] | null;
385+
/**
386+
* The requested URL that was matched by one or more threats.
387+
*/
388+
url?: string | null;
389+
}
362390

363391
export class Resource$Hashes {
364392
context: APIRequestContext;
@@ -367,7 +395,7 @@ export namespace safebrowsing_v5 {
367395
}
368396

369397
/**
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).
398+
* Searches 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).
371399
* @example
372400
* ```js
373401
* // Before running the sample:
@@ -525,7 +553,7 @@ export namespace safebrowsing_v5 {
525553
}
526554

527555
/**
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.
556+
* Gets 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.
529557
* @example
530558
* ```js
531559
* // Before running the sample:
@@ -713,7 +741,7 @@ export namespace safebrowsing_v5 {
713741
}
714742

715743
/**
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.
744+
* Gets 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.
717745
* @example
718746
* ```js
719747
* // Before running the sample:
@@ -866,7 +894,7 @@ export namespace safebrowsing_v5 {
866894
}
867895

868896
/**
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.
897+
* Lists 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.
870898
* @example
871899
* ```js
872900
* // Before running the sample:
@@ -1040,4 +1068,162 @@ export namespace safebrowsing_v5 {
10401068
*/
10411069
pageToken?: string;
10421070
}
1071+
1072+
export class Resource$Urls {
1073+
context: APIRequestContext;
1074+
constructor(context: APIRequestContext) {
1075+
this.context = context;
1076+
}
1077+
1078+
/**
1079+
* Searches for URLs matching known threats. Each URL and it's host-suffix and path-prefix expressions (up to a limited depth) are checked. This means that the response may contain URLs that were not included in the request, but are expressions of the requested URLs.
1080+
* @example
1081+
* ```js
1082+
* // Before running the sample:
1083+
* // - Enable the API at:
1084+
* // https://console.developers.google.com/apis/api/safebrowsing.googleapis.com
1085+
* // - Login into gcloud by running:
1086+
* // ```sh
1087+
* // $ gcloud auth application-default login
1088+
* // ```
1089+
* // - Install the npm module by running:
1090+
* // ```sh
1091+
* // $ npm install googleapis
1092+
* // ```
1093+
*
1094+
* const {google} = require('googleapis');
1095+
* const safebrowsing = google.safebrowsing('v5');
1096+
*
1097+
* async function main() {
1098+
* const auth = new google.auth.GoogleAuth({
1099+
* // Scopes can be specified either as an array or as a single, space-delimited string.
1100+
* scopes: [],
1101+
* });
1102+
*
1103+
* // Acquire an auth client, and bind it to all future calls
1104+
* const authClient = await auth.getClient();
1105+
* google.options({auth: authClient});
1106+
*
1107+
* // Do the magic
1108+
* const res = await safebrowsing.urls.search({
1109+
* // Required. The URLs to be looked up. Clients MUST NOT send more than 50 URLs.
1110+
* urls: 'placeholder-value',
1111+
* });
1112+
* console.log(res.data);
1113+
*
1114+
* // Example response
1115+
* // {
1116+
* // "cacheDuration": "my_cacheDuration",
1117+
* // "threats": []
1118+
* // }
1119+
* }
1120+
*
1121+
* main().catch(e => {
1122+
* console.error(e);
1123+
* throw e;
1124+
* });
1125+
*
1126+
* ```
1127+
*
1128+
* @param params - Parameters for request
1129+
* @param options - Optionally override request options, such as `url`, `method`, and `encoding`.
1130+
* @param callback - Optional callback that handles the response.
1131+
* @returns A promise if used with async/await, or void if used with a callback.
1132+
*/
1133+
search(
1134+
params: Params$Resource$Urls$Search,
1135+
options: StreamMethodOptions
1136+
): Promise<GaxiosResponseWithHTTP2<Readable>>;
1137+
search(
1138+
params?: Params$Resource$Urls$Search,
1139+
options?: MethodOptions
1140+
): Promise<
1141+
GaxiosResponseWithHTTP2<Schema$GoogleSecuritySafebrowsingV5SearchUrlsResponse>
1142+
>;
1143+
search(
1144+
params: Params$Resource$Urls$Search,
1145+
options: StreamMethodOptions | BodyResponseCallback<Readable>,
1146+
callback: BodyResponseCallback<Readable>
1147+
): void;
1148+
search(
1149+
params: Params$Resource$Urls$Search,
1150+
options:
1151+
| MethodOptions
1152+
| BodyResponseCallback<Schema$GoogleSecuritySafebrowsingV5SearchUrlsResponse>,
1153+
callback: BodyResponseCallback<Schema$GoogleSecuritySafebrowsingV5SearchUrlsResponse>
1154+
): void;
1155+
search(
1156+
params: Params$Resource$Urls$Search,
1157+
callback: BodyResponseCallback<Schema$GoogleSecuritySafebrowsingV5SearchUrlsResponse>
1158+
): void;
1159+
search(
1160+
callback: BodyResponseCallback<Schema$GoogleSecuritySafebrowsingV5SearchUrlsResponse>
1161+
): void;
1162+
search(
1163+
paramsOrCallback?:
1164+
| Params$Resource$Urls$Search
1165+
| BodyResponseCallback<Schema$GoogleSecuritySafebrowsingV5SearchUrlsResponse>
1166+
| BodyResponseCallback<Readable>,
1167+
optionsOrCallback?:
1168+
| MethodOptions
1169+
| StreamMethodOptions
1170+
| BodyResponseCallback<Schema$GoogleSecuritySafebrowsingV5SearchUrlsResponse>
1171+
| BodyResponseCallback<Readable>,
1172+
callback?:
1173+
| BodyResponseCallback<Schema$GoogleSecuritySafebrowsingV5SearchUrlsResponse>
1174+
| BodyResponseCallback<Readable>
1175+
):
1176+
| void
1177+
| Promise<
1178+
GaxiosResponseWithHTTP2<Schema$GoogleSecuritySafebrowsingV5SearchUrlsResponse>
1179+
>
1180+
| Promise<GaxiosResponseWithHTTP2<Readable>> {
1181+
let params = (paramsOrCallback || {}) as Params$Resource$Urls$Search;
1182+
let options = (optionsOrCallback || {}) as MethodOptions;
1183+
1184+
if (typeof paramsOrCallback === 'function') {
1185+
callback = paramsOrCallback;
1186+
params = {} as Params$Resource$Urls$Search;
1187+
options = {};
1188+
}
1189+
1190+
if (typeof optionsOrCallback === 'function') {
1191+
callback = optionsOrCallback;
1192+
options = {};
1193+
}
1194+
1195+
const rootUrl = options.rootUrl || 'https://safebrowsing.googleapis.com/';
1196+
const parameters = {
1197+
options: Object.assign(
1198+
{
1199+
url: (rootUrl + '/v5/urls:search').replace(/([^:]\/)\/+/g, '$1'),
1200+
method: 'GET',
1201+
apiVersion: '',
1202+
},
1203+
options
1204+
),
1205+
params,
1206+
requiredParams: [],
1207+
pathParams: [],
1208+
context: this.context,
1209+
};
1210+
if (callback) {
1211+
createAPIRequest<Schema$GoogleSecuritySafebrowsingV5SearchUrlsResponse>(
1212+
parameters,
1213+
callback as BodyResponseCallback<unknown>
1214+
);
1215+
} else {
1216+
return createAPIRequest<Schema$GoogleSecuritySafebrowsingV5SearchUrlsResponse>(
1217+
parameters
1218+
);
1219+
}
1220+
}
1221+
}
1222+
1223+
export interface Params$Resource$Urls$Search extends StandardParameters {
1224+
/**
1225+
* Required. The URLs to be looked up. Clients MUST NOT send more than 50 URLs.
1226+
*/
1227+
urls?: string[];
1228+
}
10431229
}

0 commit comments

Comments
 (0)