feat(clients): discovery: generic engine for all Google Discovery APIs
Directory and document cache with caps, parameter and body validation before traffic, path/query/repeated/regional handling, key-or-OAuth choice, paging, long-running wait, whole-directory checker script, demo at /google/discovery. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
// Routes: GET /google/discovery (page) and GET /google/discovery/status.
|
||||
// Both answer without a credential and never touch the network.
|
||||
#include "support/GoogleRig.hpp"
|
||||
|
||||
using namespace molo::example::test;
|
||||
|
||||
int main() {
|
||||
{
|
||||
GoogleRig rig(false);
|
||||
Fixture f(rig.client);
|
||||
auto page = f.client->get("/google/discovery");
|
||||
check(page.status == 200, "page 200");
|
||||
check(contains(page.headers.get("Content-Type"), "text/html"), "html");
|
||||
check(contains(page.body, "Google Discovery") && contains(page.body, "viewport"), "page and mobile viewport");
|
||||
check(contains(page.body, "/embedded/google_discovery.js"), "script wired");
|
||||
check(f.client->post("/google/discovery", "{}", "application/json").status == 405, "post to the page is 405");
|
||||
|
||||
auto st = f.client->get("/google/discovery/status");
|
||||
check(st.status == 200, "status 200");
|
||||
check(contains(st.headers.get("Content-Type"), "application/json"), "json");
|
||||
check(contains(st.body, "\"configured\":false"), "not configured");
|
||||
check(contains(st.body, "\"max_pages\":50") && contains(st.body, "\"max_items\":10000"), "caps shown");
|
||||
check(contains(st.body, "https://discovery.googleapis.com/discovery/v1/apis"), "directory url shown");
|
||||
check(f.client->post("/google/discovery/status", "{}", "application/json").status == 405, "post to status is 405");
|
||||
check(rig.mock->send_count() == 0, "no upstream traffic");
|
||||
}
|
||||
{
|
||||
GoogleRig rig(true);
|
||||
Fixture f(rig.client);
|
||||
auto st = f.client->get("/google/discovery/status");
|
||||
check(contains(st.body, "\"configured\":true"), "configured with a key");
|
||||
check(!contains(st.body, kTestKey), "credential never shown");
|
||||
check(rig.mock->send_count() == 0, "status makes no upstream call");
|
||||
}
|
||||
return finish("google/discovery/page");
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
// Routes: POST /google/discovery/{apis,methods,describe,plan,call}
|
||||
// Bad input is 422 (with or without a credential) before anything else; a
|
||||
// well formed request without a credential is 503 google_not_configured;
|
||||
// GET is 405; nothing reaches Google in any of these cases.
|
||||
#include "support/GoogleRig.hpp"
|
||||
|
||||
using namespace molo::example::test;
|
||||
|
||||
namespace {
|
||||
struct Route {
|
||||
const char* path;
|
||||
const char* valid;
|
||||
const char* bad;
|
||||
};
|
||||
|
||||
const Route kRoutes[] = {
|
||||
{"/google/discovery/apis", "{\"filter\":\"bigquery\",\"limit\":10}", "{\"limit\":0}"},
|
||||
{"/google/discovery/methods", "{\"api\":\"bigquery:v2\",\"filter\":\"jobs\"}", "{}"},
|
||||
{"/google/discovery/describe", "{\"api\":\"bigquery\",\"method\":\"bigquery.jobs.query\"}",
|
||||
"{\"api\":\"bigquery\"}"},
|
||||
{"/google/discovery/plan",
|
||||
"{\"api\":\"serviceusage\",\"method\":\"serviceusage.services.list\",\"params\":{\"parent\":\"projects/p\"}}",
|
||||
"{\"api\":\"serviceusage\",\"method\":\"serviceusage.services.list\",\"params\":[1]}"},
|
||||
{"/google/discovery/call",
|
||||
"{\"api\":\"serviceusage\",\"method\":\"serviceusage.services.list\",\"params\":{\"parent\":\"projects/p\"},\"maxPages\":2}",
|
||||
"{\"api\":\"serviceusage\",\"method\":\"serviceusage.services.list\",\"maxPages\":51}"},
|
||||
};
|
||||
} // namespace
|
||||
|
||||
int main() {
|
||||
GoogleRig rig(false);
|
||||
Fixture f(rig.client);
|
||||
for (const Route& r : kRoutes) {
|
||||
std::string p = r.path;
|
||||
auto ok = f.client->post(r.path, r.valid, "application/json");
|
||||
check(ok.status == 503 && contains(ok.body, "google_not_configured"), p + ": no credential is 503");
|
||||
check(f.client->post(r.path, r.bad, "application/json").status == 422, p + ": bad input is 422");
|
||||
check(f.client->post(r.path, "not json", "application/json").status == 422, p + ": invalid json is 422");
|
||||
check(f.client->post(r.path, "[]", "application/json").status == 422, p + ": non-object body is 422");
|
||||
check(f.client->get(r.path).status == 405, p + ": get is 405");
|
||||
}
|
||||
// Shape rules shared by the method routes.
|
||||
const char* methods[] = {"/google/discovery/describe", "/google/discovery/plan", "/google/discovery/call"};
|
||||
for (const char* path : methods) {
|
||||
std::string p = path;
|
||||
check(f.client->post(path, "{\"api\":\"../x\",\"method\":\"a.b\"}", "application/json").status == 422, p + ": path-like api is 422");
|
||||
check(f.client->post(path, "{\"api\":\"a:b:c\",\"method\":\"a.b\"}", "application/json").status == 422, p + ": two colons is 422");
|
||||
check(f.client->post(path, "{\"api\":\"a\",\"method\":\"a b\"}", "application/json").status == 422, p + ": spaced method is 422");
|
||||
check(f.client->post(path, "{\"api\":5,\"method\":\"a.b\"}", "application/json").status == 422, p + ": non-string api is 422");
|
||||
}
|
||||
const char* callers[] = {"/google/discovery/plan", "/google/discovery/call"};
|
||||
for (const char* path : callers) {
|
||||
std::string p = path;
|
||||
std::string head = "{\"api\":\"tasks\",\"method\":\"tasks.tasks.list\",";
|
||||
check(f.client->post(path, head + "\"auth\":\"magic\"}", "application/json").status == 422, p + ": unknown auth is 422");
|
||||
check(f.client->post(path, head + "\"body\":[1]}", "application/json").status == 422, p + ": array body is 422");
|
||||
check(f.client->post(path, head + "\"wait\":\"yes\"}", "application/json").status == 422, p + ": non-bool wait is 422");
|
||||
check(f.client->post(path, head + "\"maxPages\":\"3\"}", "application/json").status == 422, p + ": text maxPages is 422");
|
||||
}
|
||||
check(f.client->post("/google/discovery/call",
|
||||
"{\"api\":\"tasks\",\"method\":\"tasks.tasks.list\",\"confirm\":\"yes\"}",
|
||||
"application/json").status == 422,
|
||||
"non-bool confirm is 422");
|
||||
std::string big(600 * 1024, 'a');
|
||||
check(f.client->post("/google/discovery/plan", "{\"x\":\"" + big + "\"}", "application/json").status == 413,
|
||||
"oversized body is 413");
|
||||
check(rig.mock->send_count() == 0, "nothing reached Google");
|
||||
return finish("google/discovery/routes");
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
{
|
||||
"rootUrl": "https://abusiveexperiencereport.googleapis.com/",
|
||||
"baseUrl": "https://abusiveexperiencereport.googleapis.com/",
|
||||
"servicePath": "",
|
||||
"resources": {
|
||||
"sites": {
|
||||
"methods": {
|
||||
"get": {
|
||||
"httpMethod": "GET",
|
||||
"parameters": {
|
||||
"name": {
|
||||
"pattern": "^sites/[^/]+$",
|
||||
"required": true,
|
||||
"location": "path",
|
||||
"description": "Required. The name of the site whose summary to get, e.g. `sites/http%3A%2F%2Fwww.google.com%2F`. Format: `sites/{site}`",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"id": "abusiveexperiencereport.sites.get",
|
||||
"path": "v1/{+name}",
|
||||
"flatPath": "v1/sites/{sitesId}",
|
||||
"description": "Gets a site's Abusive Experience Report summary.",
|
||||
"parameterOrder": [
|
||||
"name"
|
||||
],
|
||||
"response": {
|
||||
"$ref": "SiteSummaryResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"violatingSites": {
|
||||
"methods": {
|
||||
"list": {
|
||||
"httpMethod": "GET",
|
||||
"parameters": {},
|
||||
"parameterOrder": [],
|
||||
"flatPath": "v1/violatingSites",
|
||||
"path": "v1/violatingSites",
|
||||
"description": "Lists sites that are failing in the Abusive Experience Report.",
|
||||
"response": {
|
||||
"$ref": "ViolatingSitesResponse"
|
||||
},
|
||||
"id": "abusiveexperiencereport.violatingSites.list"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"kind": "discovery#restDescription",
|
||||
"ownerDomain": "google.com",
|
||||
"batchPath": "batch",
|
||||
"mtlsRootUrl": "https://abusiveexperiencereport.mtls.googleapis.com/",
|
||||
"parameters": {
|
||||
"quotaUser": {
|
||||
"description": "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.",
|
||||
"location": "query",
|
||||
"type": "string"
|
||||
},
|
||||
"$.xgafv": {
|
||||
"enum": [
|
||||
"1",
|
||||
"2"
|
||||
],
|
||||
"type": "string",
|
||||
"location": "query",
|
||||
"description": "V1 error format.",
|
||||
"enumDescriptions": [
|
||||
"v1 error format",
|
||||
"v2 error format"
|
||||
]
|
||||
},
|
||||
"callback": {
|
||||
"location": "query",
|
||||
"description": "JSONP",
|
||||
"type": "string"
|
||||
},
|
||||
"alt": {
|
||||
"enum": [
|
||||
"json",
|
||||
"media",
|
||||
"proto"
|
||||
],
|
||||
"enumDescriptions": [
|
||||
"Responses with Content-Type of application/json",
|
||||
"Media download with context-dependent Content-Type",
|
||||
"Responses with Content-Type of application/x-protobuf"
|
||||
],
|
||||
"type": "string",
|
||||
"default": "json",
|
||||
"location": "query",
|
||||
"description": "Data format for response."
|
||||
},
|
||||
"key": {
|
||||
"location": "query",
|
||||
"description": "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.",
|
||||
"type": "string"
|
||||
},
|
||||
"prettyPrint": {
|
||||
"description": "Returns response with indentations and line breaks.",
|
||||
"default": "true",
|
||||
"location": "query",
|
||||
"type": "boolean"
|
||||
},
|
||||
"oauth_token": {
|
||||
"location": "query",
|
||||
"description": "OAuth 2.0 token for the current user.",
|
||||
"type": "string"
|
||||
},
|
||||
"fields": {
|
||||
"type": "string",
|
||||
"location": "query",
|
||||
"description": "Selector specifying which fields to include in a partial response."
|
||||
},
|
||||
"upload_protocol": {
|
||||
"description": "Upload protocol for media (e.g. \"raw\", \"multipart\").",
|
||||
"type": "string",
|
||||
"location": "query"
|
||||
},
|
||||
"uploadType": {
|
||||
"location": "query",
|
||||
"type": "string",
|
||||
"description": "Legacy upload protocol for media (e.g. \"media\", \"multipart\")."
|
||||
},
|
||||
"access_token": {
|
||||
"description": "OAuth access token.",
|
||||
"type": "string",
|
||||
"location": "query"
|
||||
}
|
||||
},
|
||||
"description": "Views Abusive Experience Report data, and gets a list of sites that have a significant number of abusive experiences.",
|
||||
"version": "v1",
|
||||
"icons": {
|
||||
"x32": "http://www.google.com/images/icons/product/search-32.gif",
|
||||
"x16": "http://www.google.com/images/icons/product/search-16.gif"
|
||||
},
|
||||
"title": "Abusive Experience Report API",
|
||||
"version_module": true,
|
||||
"canonicalName": "Abusive Experience Report",
|
||||
"id": "abusiveexperiencereport:v1",
|
||||
"schemas": {
|
||||
"SiteSummaryResponse": {
|
||||
"type": "object",
|
||||
"description": "Response message for GetSiteSummary.",
|
||||
"properties": {
|
||||
"reviewedSite": {
|
||||
"type": "string",
|
||||
"description": "The name of the reviewed site, e.g. `google.com`."
|
||||
},
|
||||
"lastChangeTime": {
|
||||
"description": "The time at which the site's status last changed.",
|
||||
"format": "google-datetime",
|
||||
"type": "string"
|
||||
},
|
||||
"underReview": {
|
||||
"description": "Whether the site is currently under review.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"filterStatus": {
|
||||
"type": "string",
|
||||
"description": "The site's [enforcement status](https://support.google.com/webtools/answer/7538608).",
|
||||
"enumDescriptions": [
|
||||
"N/A.",
|
||||
"Enforcement is on.",
|
||||
"Enforcement is off.",
|
||||
"Enforcement is paused.",
|
||||
"Enforcement is pending."
|
||||
],
|
||||
"enum": [
|
||||
"UNKNOWN",
|
||||
"ON",
|
||||
"OFF",
|
||||
"PAUSED",
|
||||
"PENDING"
|
||||
]
|
||||
},
|
||||
"reportUrl": {
|
||||
"type": "string",
|
||||
"description": "A link to the full Abusive Experience Report for the site. Not set in ViolatingSitesResponse. Note that you must complete the [Search Console verification process](https://support.google.com/webmasters/answer/9008080) for the site before you can access the full report."
|
||||
},
|
||||
"enforcementTime": {
|
||||
"description": "The time at which [enforcement](https://support.google.com/webtools/answer/7538608) against the site began or will begin. Not set when the filter_status is OFF.",
|
||||
"type": "string",
|
||||
"format": "google-datetime"
|
||||
},
|
||||
"abusiveStatus": {
|
||||
"description": "The site's Abusive Experience Report status.",
|
||||
"enum": [
|
||||
"UNKNOWN",
|
||||
"PASSING",
|
||||
"FAILING"
|
||||
],
|
||||
"type": "string",
|
||||
"enumDescriptions": [
|
||||
"Not reviewed.",
|
||||
"Passing.",
|
||||
"Failing."
|
||||
]
|
||||
}
|
||||
},
|
||||
"id": "SiteSummaryResponse"
|
||||
},
|
||||
"ViolatingSitesResponse": {
|
||||
"properties": {
|
||||
"violatingSites": {
|
||||
"description": "The list of violating sites.",
|
||||
"items": {
|
||||
"$ref": "SiteSummaryResponse"
|
||||
},
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"type": "object",
|
||||
"description": "Response message for ListViolatingSites.",
|
||||
"id": "ViolatingSitesResponse"
|
||||
}
|
||||
},
|
||||
"fullyEncodeReservedExpansion": true,
|
||||
"basePath": "",
|
||||
"ownerName": "Google",
|
||||
"protocol": "rest",
|
||||
"discoveryVersion": "v1",
|
||||
"revision": "20261021",
|
||||
"documentationLink": "https://developers.google.com/abusive-experience-report/",
|
||||
"name": "abusiveexperiencereport"
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,96 @@
|
||||
{
|
||||
"kind": "discovery#directoryList",
|
||||
"discoveryVersion": "v1",
|
||||
"items": [
|
||||
{
|
||||
"kind": "discovery#directoryItem",
|
||||
"id": "abusiveexperiencereport:v1",
|
||||
"name": "abusiveexperiencereport",
|
||||
"version": "v1",
|
||||
"title": "Abusive Experience Report API",
|
||||
"description": "Views Abusive Experience Report data, and gets a list of sites that have a significant number of abusive experiences.",
|
||||
"discoveryRestUrl": "https://abusiveexperiencereport.googleapis.com/$discovery/rest?version=v1",
|
||||
"icons": {
|
||||
"x16": "https://www.gstatic.com/images/branding/product/1x/googleg_16dp.png",
|
||||
"x32": "https://www.gstatic.com/images/branding/product/1x/googleg_32dp.png"
|
||||
},
|
||||
"documentationLink": "https://developers.google.com/abusive-experience-report/",
|
||||
"preferred": true
|
||||
},
|
||||
{
|
||||
"kind": "discovery#directoryItem",
|
||||
"id": "admob:v1",
|
||||
"name": "admob",
|
||||
"version": "v1",
|
||||
"title": "AdMob API",
|
||||
"description": "The AdMob API allows publishers to programmatically get information about their AdMob account.",
|
||||
"discoveryRestUrl": "https://admob.googleapis.com/$discovery/rest?version=v1",
|
||||
"icons": {
|
||||
"x16": "https://www.gstatic.com/images/branding/product/1x/googleg_16dp.png",
|
||||
"x32": "https://www.gstatic.com/images/branding/product/1x/googleg_32dp.png"
|
||||
},
|
||||
"documentationLink": "https://developers.google.com/admob/api/",
|
||||
"preferred": true
|
||||
},
|
||||
{
|
||||
"kind": "discovery#directoryItem",
|
||||
"id": "groupsmigration:v1",
|
||||
"name": "groupsmigration",
|
||||
"version": "v1",
|
||||
"title": "Groups Migration API",
|
||||
"description": "The Groups Migration API allows domain administrators to archive emails into Google groups.",
|
||||
"discoveryRestUrl": "https://groupsmigration.googleapis.com/$discovery/rest?version=v1",
|
||||
"icons": {
|
||||
"x16": "https://www.gstatic.com/images/branding/product/1x/googleg_16dp.png",
|
||||
"x32": "https://www.gstatic.com/images/branding/product/1x/googleg_32dp.png"
|
||||
},
|
||||
"documentationLink": "https://developers.google.com/google-apps/groups-migration/",
|
||||
"preferred": true
|
||||
},
|
||||
{
|
||||
"kind": "discovery#directoryItem",
|
||||
"id": "tasks:v1",
|
||||
"name": "tasks",
|
||||
"version": "v1",
|
||||
"title": "Google Tasks API",
|
||||
"description": "The Google Tasks API lets you manage your tasks and task lists.",
|
||||
"discoveryRestUrl": "https://tasks.googleapis.com/$discovery/rest?version=v1",
|
||||
"icons": {
|
||||
"x16": "https://www.gstatic.com/images/branding/product/1x/googleg_16dp.png",
|
||||
"x32": "https://www.gstatic.com/images/branding/product/1x/googleg_32dp.png"
|
||||
},
|
||||
"documentationLink": "https://developers.google.com/workspace/tasks/",
|
||||
"preferred": true
|
||||
},
|
||||
{
|
||||
"kind": "discovery#directoryItem",
|
||||
"id": "workflows:v1beta",
|
||||
"name": "workflows",
|
||||
"version": "v1beta",
|
||||
"title": "Workflows API",
|
||||
"description": "Manage workflow definitions. To execute workflows and manage executions, see the Workflows Executions API.",
|
||||
"discoveryRestUrl": "https://workflows.googleapis.com/$discovery/rest?version=v1beta",
|
||||
"icons": {
|
||||
"x16": "https://www.gstatic.com/images/branding/product/1x/googleg_16dp.png",
|
||||
"x32": "https://www.gstatic.com/images/branding/product/1x/googleg_32dp.png"
|
||||
},
|
||||
"documentationLink": "https://cloud.google.com/workflows",
|
||||
"preferred": false
|
||||
},
|
||||
{
|
||||
"kind": "discovery#directoryItem",
|
||||
"id": "workflows:v1",
|
||||
"name": "workflows",
|
||||
"version": "v1",
|
||||
"title": "Workflows API",
|
||||
"description": "Manage workflow definitions. To execute workflows and manage executions, see the Workflows Executions API.",
|
||||
"discoveryRestUrl": "https://workflows.googleapis.com/$discovery/rest?version=v1",
|
||||
"icons": {
|
||||
"x16": "https://www.gstatic.com/images/branding/product/1x/googleg_16dp.png",
|
||||
"x32": "https://www.gstatic.com/images/branding/product/1x/googleg_32dp.png"
|
||||
},
|
||||
"documentationLink": "https://cloud.google.com/workflows",
|
||||
"preferred": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
{
|
||||
"title": "Groups Migration API",
|
||||
"mtlsRootUrl": "https://groupsmigration.mtls.googleapis.com/",
|
||||
"description": "The Groups Migration API allows domain administrators to archive emails into Google groups.",
|
||||
"ownerDomain": "google.com",
|
||||
"batchPath": "batch",
|
||||
"kind": "discovery#restDescription",
|
||||
"canonicalName": "Groups Migration",
|
||||
"documentationLink": "https://developers.google.com/google-apps/groups-migration/",
|
||||
"schemas": {
|
||||
"Groups": {
|
||||
"id": "Groups",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"kind": {
|
||||
"description": "The kind of insert resource this is.",
|
||||
"type": "string"
|
||||
},
|
||||
"responseCode": {
|
||||
"type": "string",
|
||||
"description": "The status of the insert request."
|
||||
}
|
||||
},
|
||||
"description": "JSON response template for groups migration API."
|
||||
}
|
||||
},
|
||||
"parameters": {
|
||||
"quotaUser": {
|
||||
"type": "string",
|
||||
"location": "query",
|
||||
"description": "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."
|
||||
},
|
||||
"$.xgafv": {
|
||||
"description": "V1 error format.",
|
||||
"enum": [
|
||||
"1",
|
||||
"2"
|
||||
],
|
||||
"enumDescriptions": [
|
||||
"v1 error format",
|
||||
"v2 error format"
|
||||
],
|
||||
"type": "string",
|
||||
"location": "query"
|
||||
},
|
||||
"prettyPrint": {
|
||||
"location": "query",
|
||||
"default": "true",
|
||||
"description": "Returns response with indentations and line breaks.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"fields": {
|
||||
"location": "query",
|
||||
"description": "Selector specifying which fields to include in a partial response.",
|
||||
"type": "string"
|
||||
},
|
||||
"access_token": {
|
||||
"location": "query",
|
||||
"description": "OAuth access token.",
|
||||
"type": "string"
|
||||
},
|
||||
"callback": {
|
||||
"location": "query",
|
||||
"description": "JSONP",
|
||||
"type": "string"
|
||||
},
|
||||
"oauth_token": {
|
||||
"type": "string",
|
||||
"location": "query",
|
||||
"description": "OAuth 2.0 token for the current user."
|
||||
},
|
||||
"uploadType": {
|
||||
"type": "string",
|
||||
"description": "Legacy upload protocol for media (e.g. \"media\", \"multipart\").",
|
||||
"location": "query"
|
||||
},
|
||||
"key": {
|
||||
"description": "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.",
|
||||
"type": "string",
|
||||
"location": "query"
|
||||
},
|
||||
"upload_protocol": {
|
||||
"type": "string",
|
||||
"description": "Upload protocol for media (e.g. \"raw\", \"multipart\").",
|
||||
"location": "query"
|
||||
},
|
||||
"alt": {
|
||||
"location": "query",
|
||||
"enumDescriptions": [
|
||||
"Responses with Content-Type of application/json",
|
||||
"Media download with context-dependent Content-Type",
|
||||
"Responses with Content-Type of application/x-protobuf"
|
||||
],
|
||||
"description": "Data format for response.",
|
||||
"type": "string",
|
||||
"default": "json",
|
||||
"enum": [
|
||||
"json",
|
||||
"media",
|
||||
"proto"
|
||||
]
|
||||
}
|
||||
},
|
||||
"discoveryVersion": "v1",
|
||||
"icons": {
|
||||
"x16": "http://www.google.com/images/icons/product/search-16.gif",
|
||||
"x32": "http://www.google.com/images/icons/product/search-32.gif"
|
||||
},
|
||||
"baseUrl": "https://groupsmigration.googleapis.com/",
|
||||
"servicePath": "",
|
||||
"rootUrl": "https://groupsmigration.googleapis.com/",
|
||||
"auth": {
|
||||
"oauth2": {
|
||||
"scopes": {
|
||||
"https://www.googleapis.com/auth/apps.groups.migration": {
|
||||
"description": "Upload messages to any Google group in your domain"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"protocol": "rest",
|
||||
"id": "groupsmigration:v1",
|
||||
"name": "groupsmigration",
|
||||
"version": "v1",
|
||||
"basePath": "",
|
||||
"resources": {
|
||||
"archive": {
|
||||
"methods": {
|
||||
"insert": {
|
||||
"flatPath": "groups/v1/groups/{groupId}/archive",
|
||||
"response": {
|
||||
"$ref": "Groups"
|
||||
},
|
||||
"scopes": [
|
||||
"https://www.googleapis.com/auth/apps.groups.migration"
|
||||
],
|
||||
"path": "groups/v1/groups/{groupId}/archive",
|
||||
"supportsMediaUpload": true,
|
||||
"mediaUpload": {
|
||||
"accept": [
|
||||
"message/rfc822"
|
||||
],
|
||||
"maxSize": "26214400",
|
||||
"protocols": {
|
||||
"simple": {
|
||||
"multipart": true,
|
||||
"path": "/upload/groups/v1/groups/{groupId}/archive"
|
||||
}
|
||||
}
|
||||
},
|
||||
"id": "groupsmigration.archive.insert",
|
||||
"description": "Inserts a new mail into the archive of the Google group.",
|
||||
"parameters": {
|
||||
"groupId": {
|
||||
"type": "string",
|
||||
"location": "path",
|
||||
"required": true,
|
||||
"description": "The group ID"
|
||||
}
|
||||
},
|
||||
"httpMethod": "POST",
|
||||
"parameterOrder": [
|
||||
"groupId"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"revision": "20261019",
|
||||
"ownerName": "Google"
|
||||
}
|
||||
@@ -0,0 +1,836 @@
|
||||
{
|
||||
"resources": {
|
||||
"tasklists": {
|
||||
"methods": {
|
||||
"delete": {
|
||||
"parameters": {
|
||||
"tasklist": {
|
||||
"required": true,
|
||||
"type": "string",
|
||||
"description": "Task list identifier.",
|
||||
"location": "path"
|
||||
}
|
||||
},
|
||||
"description": "Deletes the authenticated user's specified task list. If the list contains assigned tasks, both the assigned tasks and the original tasks in the assignment surface (Docs, Chat Spaces) are deleted.",
|
||||
"scopes": [
|
||||
"https://www.googleapis.com/auth/tasks"
|
||||
],
|
||||
"parameterOrder": [
|
||||
"tasklist"
|
||||
],
|
||||
"httpMethod": "DELETE",
|
||||
"path": "tasks/v1/users/@me/lists/{tasklist}",
|
||||
"flatPath": "tasks/v1/users/@me/lists/{tasklist}",
|
||||
"id": "tasks.tasklists.delete"
|
||||
},
|
||||
"get": {
|
||||
"path": "tasks/v1/users/@me/lists/{tasklist}",
|
||||
"parameters": {
|
||||
"tasklist": {
|
||||
"location": "path",
|
||||
"description": "Task list identifier.",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"flatPath": "tasks/v1/users/@me/lists/{tasklist}",
|
||||
"id": "tasks.tasklists.get",
|
||||
"httpMethod": "GET",
|
||||
"response": {
|
||||
"$ref": "TaskList"
|
||||
},
|
||||
"description": "Returns the authenticated user's specified task list.",
|
||||
"scopes": [
|
||||
"https://www.googleapis.com/auth/tasks",
|
||||
"https://www.googleapis.com/auth/tasks.readonly"
|
||||
],
|
||||
"parameterOrder": [
|
||||
"tasklist"
|
||||
]
|
||||
},
|
||||
"patch": {
|
||||
"response": {
|
||||
"$ref": "TaskList"
|
||||
},
|
||||
"parameters": {
|
||||
"tasklist": {
|
||||
"description": "Task list identifier.",
|
||||
"required": true,
|
||||
"type": "string",
|
||||
"location": "path"
|
||||
}
|
||||
},
|
||||
"scopes": [
|
||||
"https://www.googleapis.com/auth/tasks"
|
||||
],
|
||||
"request": {
|
||||
"$ref": "TaskList"
|
||||
},
|
||||
"flatPath": "tasks/v1/users/@me/lists/{tasklist}",
|
||||
"parameterOrder": [
|
||||
"tasklist"
|
||||
],
|
||||
"description": "Updates the authenticated user's specified task list. This method supports patch semantics.",
|
||||
"httpMethod": "PATCH",
|
||||
"id": "tasks.tasklists.patch",
|
||||
"path": "tasks/v1/users/@me/lists/{tasklist}"
|
||||
},
|
||||
"update": {
|
||||
"id": "tasks.tasklists.update",
|
||||
"response": {
|
||||
"$ref": "TaskList"
|
||||
},
|
||||
"description": "Updates the authenticated user's specified task list.",
|
||||
"request": {
|
||||
"$ref": "TaskList"
|
||||
},
|
||||
"parameterOrder": [
|
||||
"tasklist"
|
||||
],
|
||||
"flatPath": "tasks/v1/users/@me/lists/{tasklist}",
|
||||
"parameters": {
|
||||
"tasklist": {
|
||||
"description": "Task list identifier.",
|
||||
"required": true,
|
||||
"type": "string",
|
||||
"location": "path"
|
||||
}
|
||||
},
|
||||
"httpMethod": "PUT",
|
||||
"path": "tasks/v1/users/@me/lists/{tasklist}",
|
||||
"scopes": [
|
||||
"https://www.googleapis.com/auth/tasks"
|
||||
]
|
||||
},
|
||||
"list": {
|
||||
"id": "tasks.tasklists.list",
|
||||
"response": {
|
||||
"$ref": "TaskLists"
|
||||
},
|
||||
"flatPath": "tasks/v1/users/@me/lists",
|
||||
"httpMethod": "GET",
|
||||
"scopes": [
|
||||
"https://www.googleapis.com/auth/tasks",
|
||||
"https://www.googleapis.com/auth/tasks.readonly"
|
||||
],
|
||||
"path": "tasks/v1/users/@me/lists",
|
||||
"parameters": {
|
||||
"maxResults": {
|
||||
"location": "query",
|
||||
"format": "int32",
|
||||
"description": "Maximum number of task lists returned on one page. Optional. The default is 1000 (max allowed: 1000).",
|
||||
"type": "integer"
|
||||
},
|
||||
"pageToken": {
|
||||
"description": "Token specifying the result page to return. Optional.",
|
||||
"location": "query",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"description": "Returns all the authenticated user's task lists. A user can have up to 2000 lists at a time.",
|
||||
"parameterOrder": []
|
||||
},
|
||||
"insert": {
|
||||
"response": {
|
||||
"$ref": "TaskList"
|
||||
},
|
||||
"scopes": [
|
||||
"https://www.googleapis.com/auth/tasks"
|
||||
],
|
||||
"path": "tasks/v1/users/@me/lists",
|
||||
"parameterOrder": [],
|
||||
"description": "Creates a new task list and adds it to the authenticated user's task lists. A user can have up to 2000 lists at a time.",
|
||||
"flatPath": "tasks/v1/users/@me/lists",
|
||||
"id": "tasks.tasklists.insert",
|
||||
"parameters": {},
|
||||
"request": {
|
||||
"$ref": "TaskList"
|
||||
},
|
||||
"httpMethod": "POST"
|
||||
}
|
||||
}
|
||||
},
|
||||
"tasks": {
|
||||
"methods": {
|
||||
"move": {
|
||||
"flatPath": "tasks/v1/lists/{tasklist}/tasks/{task}/move",
|
||||
"parameterOrder": [
|
||||
"tasklist",
|
||||
"task"
|
||||
],
|
||||
"description": "Moves the specified task to another position in the destination task list. If the destination list is not specified, the task is moved within its current list. This can include putting it as a child task under a new parent and/or move it to a different position among its sibling tasks. A user can have up to 2,000 subtasks per task.",
|
||||
"response": {
|
||||
"$ref": "Task"
|
||||
},
|
||||
"id": "tasks.tasks.move",
|
||||
"path": "tasks/v1/lists/{tasklist}/tasks/{task}/move",
|
||||
"parameters": {
|
||||
"tasklist": {
|
||||
"location": "path",
|
||||
"type": "string",
|
||||
"description": "Task list identifier.",
|
||||
"required": true
|
||||
},
|
||||
"destinationTasklist": {
|
||||
"description": "Optional. Destination task list identifier. If set, the task is moved from tasklist to the destinationTasklist list. Otherwise the task is moved within its current list. Recurrent tasks cannot currently be moved between lists.",
|
||||
"type": "string",
|
||||
"location": "query"
|
||||
},
|
||||
"task": {
|
||||
"required": true,
|
||||
"type": "string",
|
||||
"description": "Task identifier.",
|
||||
"location": "path"
|
||||
},
|
||||
"parent": {
|
||||
"type": "string",
|
||||
"location": "query",
|
||||
"description": "Optional. New parent task identifier. If the task is moved to the top level, this parameter is omitted. The task set as parent must exist in the task list and can not be hidden. Exceptions: 1. Assigned and repeating tasks cannot be set as parent tasks (have subtasks), or be moved under a parent task (become subtasks). 2. Tasks that are both completed and hidden cannot be nested, so the parent field must be empty."
|
||||
},
|
||||
"previous": {
|
||||
"type": "string",
|
||||
"location": "query",
|
||||
"description": "Optional. New previous sibling task identifier. If the task is moved to the first position among its siblings, this parameter is omitted. The task set as previous must exist in the task list and can not be hidden. Exceptions: 1. Tasks that are both completed and hidden can only be moved to position 0, so the previous field must be empty."
|
||||
}
|
||||
},
|
||||
"scopes": [
|
||||
"https://www.googleapis.com/auth/tasks"
|
||||
],
|
||||
"httpMethod": "POST"
|
||||
},
|
||||
"delete": {
|
||||
"id": "tasks.tasks.delete",
|
||||
"flatPath": "tasks/v1/lists/{tasklist}/tasks/{task}",
|
||||
"description": "Deletes the specified task from the task list. If the task is assigned, both the assigned task and the original task (in Docs, Chat Spaces) are deleted. To delete the assigned task only, navigate to the assignment surface and unassign the task from there.",
|
||||
"parameters": {
|
||||
"tasklist": {
|
||||
"required": true,
|
||||
"location": "path",
|
||||
"type": "string",
|
||||
"description": "Task list identifier."
|
||||
},
|
||||
"task": {
|
||||
"required": true,
|
||||
"description": "Task identifier.",
|
||||
"type": "string",
|
||||
"location": "path"
|
||||
}
|
||||
},
|
||||
"path": "tasks/v1/lists/{tasklist}/tasks/{task}",
|
||||
"parameterOrder": [
|
||||
"tasklist",
|
||||
"task"
|
||||
],
|
||||
"scopes": [
|
||||
"https://www.googleapis.com/auth/tasks"
|
||||
],
|
||||
"httpMethod": "DELETE"
|
||||
},
|
||||
"update": {
|
||||
"scopes": [
|
||||
"https://www.googleapis.com/auth/tasks"
|
||||
],
|
||||
"flatPath": "tasks/v1/lists/{tasklist}/tasks/{task}",
|
||||
"id": "tasks.tasks.update",
|
||||
"httpMethod": "PUT",
|
||||
"path": "tasks/v1/lists/{tasklist}/tasks/{task}",
|
||||
"response": {
|
||||
"$ref": "Task"
|
||||
},
|
||||
"parameters": {
|
||||
"tasklist": {
|
||||
"required": true,
|
||||
"location": "path",
|
||||
"description": "Task list identifier.",
|
||||
"type": "string"
|
||||
},
|
||||
"task": {
|
||||
"location": "path",
|
||||
"required": true,
|
||||
"description": "Task identifier.",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"description": "Updates the specified task.",
|
||||
"request": {
|
||||
"$ref": "Task"
|
||||
},
|
||||
"parameterOrder": [
|
||||
"tasklist",
|
||||
"task"
|
||||
]
|
||||
},
|
||||
"list": {
|
||||
"scopes": [
|
||||
"https://www.googleapis.com/auth/tasks",
|
||||
"https://www.googleapis.com/auth/tasks.readonly"
|
||||
],
|
||||
"description": "Returns all tasks in the specified task list. Doesn't return assigned tasks by default (from Docs, Chat Spaces). A user can have up to 20,000 non-hidden tasks per list and up to 100,000 tasks in total at a time.",
|
||||
"httpMethod": "GET",
|
||||
"parameterOrder": [
|
||||
"tasklist"
|
||||
],
|
||||
"id": "tasks.tasks.list",
|
||||
"parameters": {
|
||||
"showAssigned": {
|
||||
"location": "query",
|
||||
"type": "boolean",
|
||||
"description": "Optional. Flag indicating whether tasks assigned to the current user are returned in the result. Optional. The default is False."
|
||||
},
|
||||
"dueMin": {
|
||||
"description": "Lower bound for a task's due date (as a RFC 3339 timestamp) to filter by. Optional. The default is not to filter by due date.",
|
||||
"type": "string",
|
||||
"location": "query"
|
||||
},
|
||||
"showCompleted": {
|
||||
"location": "query",
|
||||
"type": "boolean",
|
||||
"description": "Flag indicating whether completed tasks are returned in the result. Note that showHidden must also be True to show tasks completed in first party clients, such as the web UI and Google's mobile apps. Optional. The default is True."
|
||||
},
|
||||
"completedMin": {
|
||||
"type": "string",
|
||||
"description": "Lower bound for a task's completion date (as a RFC 3339 timestamp) to filter by. Optional. The default is not to filter by completion date.",
|
||||
"location": "query"
|
||||
},
|
||||
"maxResults": {
|
||||
"description": "Maximum number of tasks returned on one page. Optional. The default is 20 (max allowed: 100).",
|
||||
"type": "integer",
|
||||
"location": "query",
|
||||
"format": "int32"
|
||||
},
|
||||
"dueMax": {
|
||||
"location": "query",
|
||||
"type": "string",
|
||||
"description": "Upper bound for a task's due date (as a RFC 3339 timestamp) to filter by. Optional. The default is not to filter by due date."
|
||||
},
|
||||
"showDeleted": {
|
||||
"type": "boolean",
|
||||
"description": "Flag indicating whether deleted tasks are returned in the result. Optional. The default is False.",
|
||||
"location": "query"
|
||||
},
|
||||
"showHidden": {
|
||||
"location": "query",
|
||||
"type": "boolean",
|
||||
"description": "Flag indicating whether hidden tasks are returned in the result. Optional. The default is False."
|
||||
},
|
||||
"updatedMin": {
|
||||
"type": "string",
|
||||
"description": "Lower bound for a task's last modification time (as a RFC 3339 timestamp) to filter by. Optional. The default is not to filter by last modification time.",
|
||||
"location": "query"
|
||||
},
|
||||
"pageToken": {
|
||||
"type": "string",
|
||||
"location": "query",
|
||||
"description": "Token specifying the result page to return. Optional."
|
||||
},
|
||||
"completedMax": {
|
||||
"type": "string",
|
||||
"description": "Upper bound for a task's completion date (as a RFC 3339 timestamp) to filter by. Optional. The default is not to filter by completion date.",
|
||||
"location": "query"
|
||||
},
|
||||
"tasklist": {
|
||||
"location": "path",
|
||||
"description": "Task list identifier.",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"flatPath": "tasks/v1/lists/{tasklist}/tasks",
|
||||
"path": "tasks/v1/lists/{tasklist}/tasks",
|
||||
"response": {
|
||||
"$ref": "Tasks"
|
||||
}
|
||||
},
|
||||
"patch": {
|
||||
"request": {
|
||||
"$ref": "Task"
|
||||
},
|
||||
"flatPath": "tasks/v1/lists/{tasklist}/tasks/{task}",
|
||||
"path": "tasks/v1/lists/{tasklist}/tasks/{task}",
|
||||
"response": {
|
||||
"$ref": "Task"
|
||||
},
|
||||
"parameterOrder": [
|
||||
"tasklist",
|
||||
"task"
|
||||
],
|
||||
"scopes": [
|
||||
"https://www.googleapis.com/auth/tasks"
|
||||
],
|
||||
"description": "Updates the specified task. This method supports patch semantics.",
|
||||
"parameters": {
|
||||
"task": {
|
||||
"location": "path",
|
||||
"type": "string",
|
||||
"description": "Task identifier.",
|
||||
"required": true
|
||||
},
|
||||
"tasklist": {
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"location": "path",
|
||||
"description": "Task list identifier."
|
||||
}
|
||||
},
|
||||
"id": "tasks.tasks.patch",
|
||||
"httpMethod": "PATCH"
|
||||
},
|
||||
"insert": {
|
||||
"path": "tasks/v1/lists/{tasklist}/tasks",
|
||||
"scopes": [
|
||||
"https://www.googleapis.com/auth/tasks"
|
||||
],
|
||||
"httpMethod": "POST",
|
||||
"response": {
|
||||
"$ref": "Task"
|
||||
},
|
||||
"request": {
|
||||
"$ref": "Task"
|
||||
},
|
||||
"parameters": {
|
||||
"previous": {
|
||||
"location": "query",
|
||||
"description": "Previous sibling task identifier. If the task is created at the first position among its siblings, this parameter is omitted. Optional.",
|
||||
"type": "string"
|
||||
},
|
||||
"parent": {
|
||||
"description": "Parent task identifier. If the task is created at the top level, this parameter is omitted. An assigned task cannot be a parent task, nor can it have a parent. Setting the parent to an assigned task results in failure of the request. Optional.",
|
||||
"type": "string",
|
||||
"location": "query"
|
||||
},
|
||||
"tasklist": {
|
||||
"description": "Task list identifier.",
|
||||
"required": true,
|
||||
"type": "string",
|
||||
"location": "path"
|
||||
}
|
||||
},
|
||||
"parameterOrder": [
|
||||
"tasklist"
|
||||
],
|
||||
"description": "Creates a new task on the specified task list. Tasks assigned from Docs or Chat Spaces cannot be inserted from Tasks Public API; they can only be created by assigning them from Docs or Chat Spaces. A user can have up to 20,000 non-hidden tasks per list and up to 100,000 tasks in total at a time.",
|
||||
"id": "tasks.tasks.insert",
|
||||
"flatPath": "tasks/v1/lists/{tasklist}/tasks"
|
||||
},
|
||||
"get": {
|
||||
"flatPath": "tasks/v1/lists/{tasklist}/tasks/{task}",
|
||||
"id": "tasks.tasks.get",
|
||||
"parameters": {
|
||||
"tasklist": {
|
||||
"description": "Task list identifier.",
|
||||
"required": true,
|
||||
"type": "string",
|
||||
"location": "path"
|
||||
},
|
||||
"task": {
|
||||
"location": "path",
|
||||
"description": "Task identifier.",
|
||||
"type": "string",
|
||||
"required": true
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"$ref": "Task"
|
||||
},
|
||||
"httpMethod": "GET",
|
||||
"scopes": [
|
||||
"https://www.googleapis.com/auth/tasks",
|
||||
"https://www.googleapis.com/auth/tasks.readonly"
|
||||
],
|
||||
"description": "Returns the specified task.",
|
||||
"path": "tasks/v1/lists/{tasklist}/tasks/{task}",
|
||||
"parameterOrder": [
|
||||
"tasklist",
|
||||
"task"
|
||||
]
|
||||
},
|
||||
"clear": {
|
||||
"scopes": [
|
||||
"https://www.googleapis.com/auth/tasks"
|
||||
],
|
||||
"parameters": {
|
||||
"tasklist": {
|
||||
"location": "path",
|
||||
"description": "Task list identifier.",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"flatPath": "tasks/v1/lists/{tasklist}/clear",
|
||||
"id": "tasks.tasks.clear",
|
||||
"path": "tasks/v1/lists/{tasklist}/clear",
|
||||
"httpMethod": "POST",
|
||||
"description": "Clears all completed tasks from the specified task list. The affected tasks will be marked as 'hidden' and no longer be returned by default when retrieving all tasks for a task list.",
|
||||
"parameterOrder": [
|
||||
"tasklist"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"ownerDomain": "google.com",
|
||||
"baseUrl": "https://tasks.googleapis.com/",
|
||||
"icons": {
|
||||
"x32": "http://www.google.com/images/icons/product/search-32.gif",
|
||||
"x16": "http://www.google.com/images/icons/product/search-16.gif"
|
||||
},
|
||||
"protocol": "rest",
|
||||
"fullyEncodeReservedExpansion": true,
|
||||
"rootUrl": "https://tasks.googleapis.com/",
|
||||
"auth": {
|
||||
"oauth2": {
|
||||
"scopes": {
|
||||
"https://www.googleapis.com/auth/tasks": {
|
||||
"description": "Create, edit, organize, and delete all your tasks"
|
||||
},
|
||||
"https://www.googleapis.com/auth/tasks.readonly": {
|
||||
"description": "View your tasks"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"name": "tasks",
|
||||
"kind": "discovery#restDescription",
|
||||
"documentationLink": "https://developers.google.com/workspace/tasks/",
|
||||
"basePath": "",
|
||||
"servicePath": "",
|
||||
"ownerName": "Google",
|
||||
"batchPath": "batch",
|
||||
"revision": "20261020",
|
||||
"parameters": {
|
||||
"oauth_token": {
|
||||
"description": "OAuth 2.0 token for the current user.",
|
||||
"type": "string",
|
||||
"location": "query"
|
||||
},
|
||||
"prettyPrint": {
|
||||
"description": "Returns response with indentations and line breaks.",
|
||||
"default": "true",
|
||||
"location": "query",
|
||||
"type": "boolean"
|
||||
},
|
||||
"callback": {
|
||||
"type": "string",
|
||||
"description": "JSONP",
|
||||
"location": "query"
|
||||
},
|
||||
"$.xgafv": {
|
||||
"description": "V1 error format.",
|
||||
"location": "query",
|
||||
"enumDescriptions": [
|
||||
"v1 error format",
|
||||
"v2 error format"
|
||||
],
|
||||
"enum": [
|
||||
"1",
|
||||
"2"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"uploadType": {
|
||||
"type": "string",
|
||||
"location": "query",
|
||||
"description": "Legacy upload protocol for media (e.g. \"media\", \"multipart\")."
|
||||
},
|
||||
"fields": {
|
||||
"description": "Selector specifying which fields to include in a partial response.",
|
||||
"location": "query",
|
||||
"type": "string"
|
||||
},
|
||||
"access_token": {
|
||||
"type": "string",
|
||||
"description": "OAuth access token.",
|
||||
"location": "query"
|
||||
},
|
||||
"key": {
|
||||
"description": "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.",
|
||||
"type": "string",
|
||||
"location": "query"
|
||||
},
|
||||
"quotaUser": {
|
||||
"location": "query",
|
||||
"description": "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.",
|
||||
"type": "string"
|
||||
},
|
||||
"alt": {
|
||||
"type": "string",
|
||||
"enumDescriptions": [
|
||||
"Responses with Content-Type of application/json",
|
||||
"Media download with context-dependent Content-Type",
|
||||
"Responses with Content-Type of application/x-protobuf"
|
||||
],
|
||||
"location": "query",
|
||||
"default": "json",
|
||||
"enum": [
|
||||
"json",
|
||||
"media",
|
||||
"proto"
|
||||
],
|
||||
"description": "Data format for response."
|
||||
},
|
||||
"upload_protocol": {
|
||||
"description": "Upload protocol for media (e.g. \"raw\", \"multipart\").",
|
||||
"location": "query",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"title": "Google Tasks API",
|
||||
"mtlsRootUrl": "https://tasks.mtls.googleapis.com/",
|
||||
"schemas": {
|
||||
"SpaceInfo": {
|
||||
"properties": {
|
||||
"space": {
|
||||
"description": "Output only. The Chat space where this task originates from. The format is \"spaces/{space}\".",
|
||||
"type": "string",
|
||||
"readOnly": true
|
||||
}
|
||||
},
|
||||
"type": "object",
|
||||
"id": "SpaceInfo",
|
||||
"description": "Information about the Chat Space where a task was assigned from."
|
||||
},
|
||||
"TaskList": {
|
||||
"id": "TaskList",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"updated": {
|
||||
"description": "Output only. Last modification time of the task list (as a RFC 3339 timestamp).",
|
||||
"type": "string",
|
||||
"readOnly": true
|
||||
},
|
||||
"id": {
|
||||
"type": "string",
|
||||
"description": "Task list identifier."
|
||||
},
|
||||
"selfLink": {
|
||||
"readOnly": true,
|
||||
"description": "Output only. URL pointing to this task list. Used to retrieve, update, or delete this task list.",
|
||||
"type": "string"
|
||||
},
|
||||
"etag": {
|
||||
"type": "string",
|
||||
"description": "ETag of the resource."
|
||||
},
|
||||
"title": {
|
||||
"description": "Title of the task list. Maximum length allowed: 1024 characters.",
|
||||
"type": "string"
|
||||
},
|
||||
"kind": {
|
||||
"description": "Output only. Type of the resource. This is always \"tasks#taskList\".",
|
||||
"readOnly": true,
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"TaskLists": {
|
||||
"id": "TaskLists",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"kind": {
|
||||
"type": "string",
|
||||
"description": "Type of the resource. This is always \"tasks#taskLists\"."
|
||||
},
|
||||
"etag": {
|
||||
"type": "string",
|
||||
"description": "ETag of the resource."
|
||||
},
|
||||
"nextPageToken": {
|
||||
"type": "string",
|
||||
"description": "Token that can be used to request the next page of this result."
|
||||
},
|
||||
"items": {
|
||||
"items": {
|
||||
"$ref": "TaskList"
|
||||
},
|
||||
"description": "Collection of task lists.",
|
||||
"type": "array"
|
||||
}
|
||||
}
|
||||
},
|
||||
"AssignmentInfo": {
|
||||
"type": "object",
|
||||
"id": "AssignmentInfo",
|
||||
"description": "Information about the source of the task assignment (Document, Chat Space).",
|
||||
"properties": {
|
||||
"surfaceType": {
|
||||
"enum": [
|
||||
"CONTEXT_TYPE_UNSPECIFIED",
|
||||
"GMAIL",
|
||||
"DOCUMENT",
|
||||
"SPACE"
|
||||
],
|
||||
"enumDescriptions": [
|
||||
"Unknown value for this task's context.",
|
||||
"The task is created from Gmail.",
|
||||
"The task is assigned from a document.",
|
||||
"The task is assigned from a Chat Space."
|
||||
],
|
||||
"description": "Output only. The type of surface this assigned task originates from. Currently limited to DOCUMENT or SPACE.",
|
||||
"readOnly": true,
|
||||
"type": "string"
|
||||
},
|
||||
"linkToTask": {
|
||||
"description": "Output only. An absolute link to the original task in the surface of assignment (Docs, Chat spaces, etc.).",
|
||||
"type": "string",
|
||||
"readOnly": true
|
||||
},
|
||||
"spaceInfo": {
|
||||
"description": "Output only. Information about the Chat Space where this task originates from. This field is read-only.",
|
||||
"readOnly": true,
|
||||
"$ref": "SpaceInfo"
|
||||
},
|
||||
"driveResourceInfo": {
|
||||
"$ref": "DriveResourceInfo",
|
||||
"description": "Output only. Information about the Drive file where this task originates from. Currently, the Drive file can only be a document. This field is read-only.",
|
||||
"readOnly": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"Tasks": {
|
||||
"properties": {
|
||||
"items": {
|
||||
"type": "array",
|
||||
"description": "Collection of tasks.",
|
||||
"items": {
|
||||
"$ref": "Task"
|
||||
}
|
||||
},
|
||||
"kind": {
|
||||
"description": "Type of the resource. This is always \"tasks#tasks\".",
|
||||
"type": "string"
|
||||
},
|
||||
"nextPageToken": {
|
||||
"type": "string",
|
||||
"description": "Token used to access the next page of this result."
|
||||
},
|
||||
"etag": {
|
||||
"type": "string",
|
||||
"description": "ETag of the resource."
|
||||
}
|
||||
},
|
||||
"type": "object",
|
||||
"id": "Tasks"
|
||||
},
|
||||
"DriveResourceInfo": {
|
||||
"properties": {
|
||||
"driveFileId": {
|
||||
"description": "Output only. Identifier of the file in the Drive API.",
|
||||
"readOnly": true,
|
||||
"type": "string"
|
||||
},
|
||||
"resourceKey": {
|
||||
"description": "Output only. Resource key required to access files shared via a shared link. Not required for all files. See also developers.google.com/drive/api/guides/resource-keys.",
|
||||
"readOnly": true,
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object",
|
||||
"description": "Information about the Drive resource where a task was assigned from (the document, sheet, etc.).",
|
||||
"id": "DriveResourceInfo"
|
||||
},
|
||||
"Task": {
|
||||
"id": "Task",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"hidden": {
|
||||
"type": "boolean",
|
||||
"description": "Flag indicating whether the task is hidden. This is the case if the task had been marked completed when the task list was last cleared. The default is False. This field is read-only."
|
||||
},
|
||||
"position": {
|
||||
"description": "Output only. String indicating the position of the task among its sibling tasks under the same parent task or at the top level. If this string is greater than another task's corresponding position string according to lexicographical ordering, the task is positioned after the other task under the same parent task (or at the top level). Use the \"move\" method to move the task to another position.",
|
||||
"type": "string",
|
||||
"readOnly": true
|
||||
},
|
||||
"webViewLink": {
|
||||
"description": "Output only. An absolute link to the task in the Google Tasks Web UI.",
|
||||
"type": "string",
|
||||
"readOnly": true
|
||||
},
|
||||
"due": {
|
||||
"type": "string",
|
||||
"description": "Scheduled date for the task (as an RFC 3339 timestamp). Optional. This represents the day that the task should be done, or that the task is visible on the calendar grid. It doesn't represent the deadline of the task. Only date information is recorded; the time portion of the timestamp is discarded when setting this field. It isn't possible to read or write the time that a task is scheduled for using the API."
|
||||
},
|
||||
"completed": {
|
||||
"description": "Completion date of the task (as a RFC 3339 timestamp). This field is omitted if the task has not been completed.",
|
||||
"type": "string"
|
||||
},
|
||||
"links": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"properties": {
|
||||
"link": {
|
||||
"type": "string",
|
||||
"description": "The URL."
|
||||
},
|
||||
"type": {
|
||||
"description": "Type of the link, e.g. \"email\", \"generic\", \"chat_message\", \"keep_note\".",
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"description": "The description (might be empty)."
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"readOnly": true,
|
||||
"description": "Output only. Collection of links. This collection is read-only."
|
||||
},
|
||||
"status": {
|
||||
"description": "Status of the task. This is either \"needsAction\" or \"completed\".",
|
||||
"type": "string"
|
||||
},
|
||||
"assignmentInfo": {
|
||||
"description": "Output only. Context information for assigned tasks. A task can be assigned to a user, currently possible from surfaces like Docs and Chat Spaces. This field is populated for tasks assigned to the current user and identifies where the task was assigned from. This field is read-only.",
|
||||
"$ref": "AssignmentInfo",
|
||||
"readOnly": true
|
||||
},
|
||||
"parent": {
|
||||
"readOnly": true,
|
||||
"description": "Output only. Parent task identifier. This field is omitted if it is a top-level task. Use the \"move\" method to move the task under a different parent or to the top level. A parent task can never be an assigned task (from Chat Spaces, Docs). This field is read-only.",
|
||||
"type": "string"
|
||||
},
|
||||
"deleted": {
|
||||
"description": "Flag indicating whether the task has been deleted. For assigned tasks this field is read-only. They can only be deleted by calling tasks.delete, in which case both the assigned task and the original task (in Docs or Chat Spaces) are deleted. To delete the assigned task only, navigate to the assignment surface and unassign the task from there. The default is False.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"id": {
|
||||
"description": "Task identifier.",
|
||||
"type": "string"
|
||||
},
|
||||
"updated": {
|
||||
"type": "string",
|
||||
"readOnly": true,
|
||||
"description": "Output only. Last modification time of the task (as a RFC 3339 timestamp)."
|
||||
},
|
||||
"selfLink": {
|
||||
"type": "string",
|
||||
"readOnly": true,
|
||||
"description": "Output only. URL pointing to this task. Used to retrieve, update, or delete this task."
|
||||
},
|
||||
"kind": {
|
||||
"readOnly": true,
|
||||
"description": "Output only. Type of the resource. This is always \"tasks#task\".",
|
||||
"type": "string"
|
||||
},
|
||||
"notes": {
|
||||
"type": "string",
|
||||
"description": "Notes describing the task. Tasks assigned from Google Docs cannot have notes. Optional. Maximum length allowed: 8192 characters."
|
||||
},
|
||||
"etag": {
|
||||
"description": "ETag of the resource.",
|
||||
"type": "string"
|
||||
},
|
||||
"title": {
|
||||
"description": "Title of the task. Maximum length allowed: 1024 characters.",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"discoveryVersion": "v1",
|
||||
"id": "tasks:v1",
|
||||
"canonicalName": "Tasks",
|
||||
"description": "The Google Tasks API lets you manage your tasks and task lists.",
|
||||
"version": "v1"
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,502 @@
|
||||
// Discovery engine: deterministic local tests. The documents under
|
||||
// fixtures/ are REAL Discovery documents saved verbatim from Google on
|
||||
// 2026-10-25 (never edited); the engine's behavior against all 310
|
||||
// reachable documents is checked by tools/check_discovery_directory.py.
|
||||
// MockTransport only records what the engine sends; no Google reply is
|
||||
// scripted to prove a behavior.
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
|
||||
#include "framework.h"
|
||||
#include "clients/transports/mock_transport.h"
|
||||
#include "google/credentials.h"
|
||||
#include "google/discovery/caps.h"
|
||||
#include "google/discovery/engine.h"
|
||||
#include "google/discovery/validate.h"
|
||||
|
||||
using namespace molo::google;
|
||||
using namespace molo::google::discovery;
|
||||
using HttpMethod = molo::clients::Method;
|
||||
using molo::clients::body::Json;
|
||||
using molo::clients::transports::MockTransport;
|
||||
|
||||
namespace {
|
||||
|
||||
const char* kFixtures = "tests/src/google/discovery/fixtures";
|
||||
|
||||
// Counts fetches so cache behavior is observable.
|
||||
struct CountingSource : DocumentSource {
|
||||
FileDocumentSource inner{kFixtures};
|
||||
int fetches = 0;
|
||||
std::string fetch(const std::string& url, std::size_t max) override {
|
||||
++fetches;
|
||||
return inner.fetch(url, max);
|
||||
}
|
||||
};
|
||||
|
||||
struct Rig {
|
||||
MockTransport* mock;
|
||||
std::shared_ptr<GoogleClient> client;
|
||||
std::shared_ptr<Catalog> catalog;
|
||||
std::unique_ptr<Engine> engine;
|
||||
Rig(bool key, bool oauth) {
|
||||
auto t = std::make_unique<MockTransport>();
|
||||
mock = t.get();
|
||||
client = std::make_shared<GoogleClient>(std::move(t),
|
||||
key ? Credentials::api_key("KEYVALUE") : nullptr,
|
||||
oauth ? Credentials::bearer("TOKENVALUE") : nullptr);
|
||||
catalog = std::make_shared<Catalog>(std::make_shared<FileDocumentSource>(kFixtures));
|
||||
engine = std::make_unique<Engine>(client, catalog);
|
||||
}
|
||||
// Answers the next request to `path` so the request can be inspected.
|
||||
void accept(HttpMethod m, const std::string& path) {
|
||||
molo::clients::HeaderMap h;
|
||||
h.set("Content-Type", "application/json");
|
||||
mock->expect_response(m, path, molo::clients::ClientResponse(200, h, "{}"));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename F>
|
||||
bool invalid(F&& f, const std::string& needle = "") {
|
||||
try {
|
||||
f();
|
||||
} catch (const GoogleError& e) {
|
||||
return e.http_status() == 400 && e.status() == "INVALID_ARGUMENT" &&
|
||||
e.message().find(needle) != std::string::npos;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Json obj(std::initializer_list<std::pair<std::string, Json>> kv) {
|
||||
Json o = Json::object();
|
||||
for (const auto& [k, v] : kv) o.set(k, v);
|
||||
return o;
|
||||
}
|
||||
|
||||
// A minimal but structurally real document, for shapes no fixture holds.
|
||||
Json doc_with(const Json& methods, const std::string& root = "https://x.googleapis.com/") {
|
||||
Json d = obj({{"kind", Json("discovery#restDescription")}, {"protocol", Json("rest")},
|
||||
{"id", Json("x:v1")}, {"name", Json("x")}, {"version", Json("v1")},
|
||||
{"rootUrl", Json(root)}, {"servicePath", Json("")},
|
||||
{"schemas", Json::object()}});
|
||||
d.set("methods", methods);
|
||||
return d;
|
||||
}
|
||||
|
||||
Json method(const std::string& id, const std::string& verb, const std::string& path,
|
||||
const Json& params = Json::object()) {
|
||||
return obj({{"id", Json(id)}, {"httpMethod", Json(verb)}, {"path", Json(path)},
|
||||
{"parameters", params}});
|
||||
}
|
||||
|
||||
const Method& m_of(const Api& a, const char* id) {
|
||||
const Method* m = a.find(id);
|
||||
if (!m) FAIL(std::string("missing method ") + id);
|
||||
return *m;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST(discovery, caps_are_hard_ceilings) {
|
||||
static_assert(DiscoveryCaps::kMaxPages <= 50);
|
||||
static_assert(DiscoveryCaps::kMaxDocBytes >= 6419010, "must hold compute v1");
|
||||
static_assert(DiscoveryCaps::kMinRefetch.count() >= 60);
|
||||
ASSERT_EQ(DiscoveryCaps::kMaxItems, std::size_t{10000});
|
||||
}
|
||||
|
||||
TEST(discovery, directory_lists_preferred_and_finds_versions) {
|
||||
CountingSource src;
|
||||
Directory d = Directory::parse(src.fetch(kDirectoryUrl, 1 << 20));
|
||||
ASSERT_EQ(d.items().size(), std::size_t{6});
|
||||
ASSERT_EQ(d.find("workflows")->version, std::string("v1"));
|
||||
ASSERT_EQ(d.find("workflows", "v1beta")->id, std::string("workflows:v1beta"));
|
||||
ASSERT_TRUE(d.find("workflows", "v9") == nullptr);
|
||||
ASSERT_TRUE(d.find("nope") == nullptr);
|
||||
ASSERT_EQ(d.search("WORK", 10).size(), std::size_t{1}); // preferred only
|
||||
ASSERT_EQ(d.search("work", 10, false).size(), std::size_t{2});
|
||||
ASSERT_EQ(d.search("", 2).size(), std::size_t{2});
|
||||
}
|
||||
|
||||
TEST(discovery, directory_rejects_hostile_items) {
|
||||
ASSERT_THROW(Directory::parse("{}"), GoogleError);
|
||||
ASSERT_THROW(Directory::parse("not json"), GoogleError);
|
||||
std::string evil =
|
||||
R"({"kind":"discovery#directoryList","items":[{"id":"a:v1","name":"a","version":"v1","discoveryRestUrl":"https://evil.example/doc"}]})";
|
||||
ASSERT_THROW(Directory::parse(evil), GoogleError);
|
||||
}
|
||||
|
||||
TEST(discovery, host_allowlist) {
|
||||
ASSERT_TRUE(is_google_host_url("https://tasks.googleapis.com/"));
|
||||
ASSERT_TRUE(is_google_host_url("https://workflows.us-central1.rep.googleapis.com/"));
|
||||
ASSERT_FALSE(is_google_host_url("http://tasks.googleapis.com/"));
|
||||
ASSERT_FALSE(is_google_host_url("https://googleapis.com/"));
|
||||
ASSERT_FALSE(is_google_host_url("https://evilgoogleapis.com/"));
|
||||
ASSERT_FALSE(is_google_host_url("https://x.googleapis.com.evil.example/"));
|
||||
ASSERT_FALSE(is_google_host_url("https://user@x.googleapis.com/"));
|
||||
ASSERT_FALSE(is_google_host_url("https://x.googleapis.com:8443/"));
|
||||
}
|
||||
|
||||
TEST(discovery, http_source_refuses_foreign_hosts_before_traffic) {
|
||||
auto t = std::make_unique<MockTransport>();
|
||||
MockTransport* mock = t.get();
|
||||
HttpDocumentSource src(std::move(t));
|
||||
ASSERT_TRUE(invalid([&] { src.fetch("https://evil.example/x", 1000); }, "googleapis.com"));
|
||||
ASSERT_EQ(mock->send_count(), std::size_t{0});
|
||||
}
|
||||
|
||||
TEST(discovery, parses_real_documents) {
|
||||
Rig r(true, true);
|
||||
auto tasks = r.catalog->api("tasks");
|
||||
ASSERT_EQ(tasks->id(), std::string("tasks:v1"));
|
||||
ASSERT_EQ(tasks->methods().size(), std::size_t{14});
|
||||
const Method& list = m_of(*tasks, "tasks.tasks.list");
|
||||
ASSERT_TRUE(tasks->is_pageable(list));
|
||||
ASSERT_EQ(tasks->items_key(list), std::string("items"));
|
||||
ASSERT_TRUE(list.needs_oauth());
|
||||
ASSERT_TRUE(list.support == Support::kFull);
|
||||
auto wf = r.catalog->api("workflows:v1");
|
||||
ASSERT_TRUE(wf->endpoints().size() > 10);
|
||||
ASSERT_TRUE(wf->is_operation_schema("Operation"));
|
||||
ASSERT_EQ(wf->operation_getters().size(), std::size_t{1});
|
||||
}
|
||||
|
||||
TEST(discovery, classifies_limited_shapes_from_real_documents) {
|
||||
Rig r(true, true);
|
||||
auto gm = r.catalog->api("groupsmigration");
|
||||
const Method& ins = m_of(*gm, "groupsmigration.archive.insert");
|
||||
ASSERT_TRUE(ins.support == Support::kLimited);
|
||||
ASSERT_TRUE(ins.media.supported && ins.media.simple);
|
||||
auto ad = r.catalog->api("admob");
|
||||
ASSERT_TRUE(m_of(*ad, "admob.accounts.mediationReport.generate").support == Support::kLimited);
|
||||
ASSERT_TRUE(m_of(*ad, "admob.accounts.get").support == Support::kFull); // streamingType NONE
|
||||
}
|
||||
|
||||
TEST(discovery, classifies_rejected_shapes) {
|
||||
Json bidi = method("x.a", "POST", "v1/a");
|
||||
bidi.set("streamingType", Json("BIDI"));
|
||||
Json objp = method("x.b", "GET", "v1/b", obj({{"ext", obj({{"type", Json("object")}, {"location", Json("query")}})}}));
|
||||
Json noparam = method("x.c", "GET", "v1/{id}/c");
|
||||
Json head = method("x.d", "HEAD", "v1/d");
|
||||
Api a = Api::parse(doc_with(obj({{"a", bidi}, {"b", objp}, {"c", noparam}, {"d", head}})));
|
||||
for (const char* id : {"x.a", "x.b", "x.c", "x.d"}) {
|
||||
ASSERT_TRUE(m_of(a, id).support == Support::kRejected);
|
||||
ASSERT_FALSE(m_of(a, id).notes.empty());
|
||||
}
|
||||
CallArgs args;
|
||||
ASSERT_TRUE(invalid([&] { Planner::plan(a, m_of(a, "x.a"), args); }, "cannot be called"));
|
||||
}
|
||||
|
||||
TEST(discovery, document_validation_rejects_untrusted_shapes) {
|
||||
ASSERT_THROW(Api::parse(doc_with(Json::object(), "https://evil.example/")), GoogleError);
|
||||
ASSERT_THROW(Api::parse(doc_with(Json::object(), "http://x.googleapis.com/")), GoogleError);
|
||||
Json d = doc_with(Json::object());
|
||||
d.set("kind", Json("other"));
|
||||
ASSERT_THROW(Api::parse(d), GoogleError);
|
||||
Json ep = doc_with(Json::object());
|
||||
Json row = obj({{"location", Json("l")}, {"endpointUrl", Json("https://evil.example/")}});
|
||||
Json rows = Json::array();
|
||||
rows.push(row);
|
||||
ep.set("endpoints", rows);
|
||||
ASSERT_THROW(Api::parse(ep), GoogleError);
|
||||
}
|
||||
|
||||
TEST(discovery, plan_builds_the_url_and_picks_credentials) {
|
||||
Rig r(true, true);
|
||||
CallArgs a;
|
||||
a.params.set("name", Json("sites/example.com"));
|
||||
PreparedCall p = r.engine->plan("abusiveexperiencereport", "abusiveexperiencereport.sites.get", a);
|
||||
ASSERT_EQ(p.endpoint.base_url, std::string("https://abusiveexperiencereport.googleapis.com"));
|
||||
ASSERT_EQ(p.path, std::string("/v1/sites/example.com"));
|
||||
ASSERT_TRUE(p.endpoint.prefer_key); // no scopes declared: the key
|
||||
a.auth = AuthMode::kOAuth;
|
||||
ASSERT_FALSE(r.engine->plan("abusiveexperiencereport", "abusiveexperiencereport.sites.get", a).endpoint.prefer_key);
|
||||
CallArgs t;
|
||||
t.params.set("tasklist", Json("L1"));
|
||||
ASSERT_FALSE(r.engine->plan("tasks", "tasks.tasks.list", t).endpoint.prefer_key); // scoped: OAuth
|
||||
t.auth = AuthMode::kKey;
|
||||
ASSERT_TRUE(r.engine->plan("tasks", "tasks.tasks.list", t).endpoint.prefer_key);
|
||||
ASSERT_THROW(auth_mode_from("magic"), GoogleError);
|
||||
ASSERT_TRUE(auth_mode_from("") == AuthMode::kAuto);
|
||||
}
|
||||
|
||||
TEST(discovery, path_values_are_encoded_and_reserved_expansion_keeps_slashes) {
|
||||
Rig r(true, true);
|
||||
CallArgs t;
|
||||
t.params.set("tasklist", Json("a b/c?x"));
|
||||
ASSERT_EQ(r.engine->plan("tasks", "tasks.tasks.list", t).path,
|
||||
std::string("/tasks/v1/lists/a%20b%2Fc%3Fx/tasks"));
|
||||
CallArgs w;
|
||||
w.params.set("name", Json("projects/p1/locations/us-central1/workflows/w 1"));
|
||||
ASSERT_EQ(r.engine->plan("workflows", "workflows.projects.locations.workflows.get", w).path,
|
||||
std::string("/v1/projects/p1/locations/us-central1/workflows/w%201"));
|
||||
}
|
||||
|
||||
TEST(discovery, dot_segments_and_patterns_are_rejected) {
|
||||
Rig r(true, true);
|
||||
CallArgs t;
|
||||
t.params.set("tasklist", Json(".."));
|
||||
ASSERT_TRUE(invalid([&] { r.engine->plan("tasks", "tasks.tasks.list", t); }, "dot segment"));
|
||||
CallArgs w;
|
||||
w.params.set("name", Json("projects/p/../x"));
|
||||
ASSERT_TRUE(invalid([&] { r.engine->plan("workflows", "workflows.projects.locations.workflows.get", w); }));
|
||||
w.params.set("name", Json("nonsense"));
|
||||
ASSERT_TRUE(invalid([&] { r.engine->plan("workflows", "workflows.projects.locations.workflows.get", w); }, "does not match"));
|
||||
}
|
||||
|
||||
TEST(discovery, parameter_validation_before_traffic) {
|
||||
Rig r(true, true);
|
||||
CallArgs t;
|
||||
t.params.set("tasklist", Json("L1"));
|
||||
ASSERT_TRUE(invalid([&] { r.engine->plan("tasks", "tasks.tasks.list", CallArgs{}); }, "required parameter tasklist"));
|
||||
t.params.set("nope", Json(1));
|
||||
ASSERT_TRUE(invalid([&] { r.engine->plan("tasks", "tasks.tasks.list", t); }, "no parameter 'nope'"));
|
||||
t.params = obj({{"tasklist", Json("L1")}, {"maxResults", Json("abc")}});
|
||||
ASSERT_TRUE(invalid([&] { r.engine->plan("tasks", "tasks.tasks.list", t); }, "integer"));
|
||||
t.params = obj({{"tasklist", Json("L1")}, {"showCompleted", Json("yes")}});
|
||||
ASSERT_TRUE(invalid([&] { r.engine->plan("tasks", "tasks.tasks.list", t); }, "true or false"));
|
||||
t.params = obj({{"tasklist", Json("L1")}, {"maxResults", Json(20)}, {"showCompleted", Json(true)},
|
||||
{"dueMin", Json("2026-10-25T10:00:00Z")}});
|
||||
PreparedCall p = r.engine->plan("tasks", "tasks.tasks.list", t);
|
||||
ASSERT_EQ(p.path, std::string("/tasks/v1/lists/L1/tasks?dueMin=2026-10-25T10%3A00%3A00Z&maxResults=20&showCompleted=true"));
|
||||
ASSERT_EQ(r.mock->send_count(), std::size_t{0});
|
||||
}
|
||||
|
||||
TEST(discovery, reserved_global_parameters_are_refused) {
|
||||
Rig r(true, true);
|
||||
for (const char* name : {"key", "access_token", "oauth_token", "alt", "callback", "uploadType"}) {
|
||||
CallArgs a;
|
||||
a.params = obj({{"tasklist", Json("L1")}, {name, Json("x")}});
|
||||
ASSERT_TRUE(invalid([&] { r.engine->plan("tasks", "tasks.tasks.list", a); }, name));
|
||||
}
|
||||
CallArgs ok;
|
||||
ok.params = obj({{"tasklist", Json("L1")}, {"fields", Json("items(id)")}, {"quotaUser", Json("u")}});
|
||||
ASSERT_TRUE(r.engine->plan("tasks", "tasks.tasks.list", ok).path.find("fields=items%28id%29") != std::string::npos);
|
||||
}
|
||||
|
||||
TEST(discovery, repeated_enum_and_range_checks) {
|
||||
Param rep;
|
||||
rep.name = "r";
|
||||
rep.type = "string";
|
||||
rep.location = "query";
|
||||
rep.repeated = true;
|
||||
rep.enum_values = {"A", "B"};
|
||||
ASSERT_TRUE(invalid([&] { ParamValidator::values(rep, Json::object()); }, "scalar"));
|
||||
Json arr = Json::array();
|
||||
arr.push(Json("A"));
|
||||
arr.push(Json("B"));
|
||||
ASSERT_EQ(ParamValidator::values(rep, arr).size(), std::size_t{2});
|
||||
ASSERT_EQ(ParamValidator::values(rep, Json("A")).size(), std::size_t{1});
|
||||
arr.push(Json("C"));
|
||||
ASSERT_TRUE(invalid([&] { ParamValidator::values(rep, arr); }, "enum"));
|
||||
Json many = Json::array();
|
||||
rep.enum_values.clear();
|
||||
for (int i = 0; i < 101; ++i) many.push(Json("v"));
|
||||
ASSERT_TRUE(invalid([&] { ParamValidator::values(rep, many); }, "more than"));
|
||||
Param n;
|
||||
n.name = "n";
|
||||
n.type = "integer";
|
||||
n.format = "int32";
|
||||
n.location = "query";
|
||||
n.minimum = 1;
|
||||
n.maximum = 100;
|
||||
ASSERT_EQ(ParamValidator::values(n, Json(50))[0], std::string("50"));
|
||||
ASSERT_TRUE(invalid([&] { ParamValidator::values(n, Json(0)); }, "minimum"));
|
||||
ASSERT_TRUE(invalid([&] { ParamValidator::values(n, Json(101)); }, "maximum"));
|
||||
ASSERT_TRUE(invalid([&] { ParamValidator::values(n, Json(1.5)); }, "integer"));
|
||||
Param big;
|
||||
big.name = "b";
|
||||
big.type = "string";
|
||||
big.format = "int64";
|
||||
big.location = "query";
|
||||
ASSERT_EQ(ParamValidator::values(big, Json("9007199254740993"))[0], std::string("9007199254740993"));
|
||||
ASSERT_TRUE(invalid([&] { ParamValidator::values(big, Json("1x")); }, "64-bit"));
|
||||
Param s;
|
||||
s.name = "s";
|
||||
s.type = "string";
|
||||
s.location = "query";
|
||||
ASSERT_TRUE(invalid([&] { ParamValidator::values(s, Json(std::string(2049, 'a'))); }, "cap"));
|
||||
ASSERT_TRUE(invalid([&] { ParamValidator::values(s, Json("a\nb")); }, "control"));
|
||||
ASSERT_TRUE(invalid([&] { ParamValidator::values(s, Json()); }, "null"));
|
||||
}
|
||||
|
||||
TEST(discovery, repeated_parameter_from_a_real_document) {
|
||||
Rig r(true, true);
|
||||
CallArgs a;
|
||||
a.params = obj({{"name", Json("projects/p1")}});
|
||||
Json types = Json::array();
|
||||
types.push(Json("a"));
|
||||
types.push(Json("b"));
|
||||
a.params.set("extraLocationTypes", types);
|
||||
PreparedCall p = r.engine->plan("workflows", "workflows.projects.locations.list", a);
|
||||
ASSERT_EQ(p.path, std::string("/v1/projects/p1/locations?extraLocationTypes=a&extraLocationTypes=b"));
|
||||
}
|
||||
|
||||
TEST(discovery, body_is_validated_against_the_schema) {
|
||||
Rig r(true, true);
|
||||
auto make = [&](Json body) {
|
||||
CallArgs a;
|
||||
a.params = obj({{"parent", Json("projects/p1/locations/us-central1")}, {"workflowId", Json("w1")}});
|
||||
a.body = std::move(body);
|
||||
return r.engine->plan("workflows", "workflows.projects.locations.workflows.create", a);
|
||||
};
|
||||
PreparedCall ok = make(obj({{"description", Json("d")}, {"labels", obj({{"k", Json("v")}})},
|
||||
{"callLogLevel", Json("LOG_ALL_CALLS")}}));
|
||||
ASSERT_TRUE(ok.has_body);
|
||||
ASSERT_TRUE(ok.http == HttpMethod::kPost);
|
||||
ASSERT_TRUE(ok.operation);
|
||||
ASSERT_TRUE(invalid([&] { make(obj({{"bogus", Json(1)}})); }, "no property bogus"));
|
||||
ASSERT_TRUE(invalid([&] { make(obj({{"description", Json(5)}})); }, "must be a string"));
|
||||
ASSERT_TRUE(invalid([&] { make(obj({{"callLogLevel", Json("LOUD")}})); }, "enum"));
|
||||
ASSERT_TRUE(invalid([&] { make(obj({{"labels", obj({{"k", Json(1)}})}})); }, "/labels/k"));
|
||||
ASSERT_TRUE(invalid([&] { make(Json("text")); }, "must be an object"));
|
||||
Json deep = Json::object();
|
||||
ASSERT_TRUE(make(deep).has_body); // empty body is {} and valid
|
||||
}
|
||||
|
||||
TEST(discovery, body_rules_follow_the_method_declaration) {
|
||||
Rig r(true, true);
|
||||
CallArgs g;
|
||||
g.params = obj({{"name", Json("projects/p1/locations/us-central1/workflows/w")}});
|
||||
g.body = obj({});
|
||||
ASSERT_TRUE(invalid([&] { r.engine->plan("workflows", "workflows.projects.locations.workflows.get", g); }, "no request body"));
|
||||
CallArgs c;
|
||||
c.params = obj({{"tasklist", Json("L1")}});
|
||||
PreparedCall clear = r.engine->plan("tasks", "tasks.tasks.clear", c); // POST without a request schema
|
||||
ASSERT_TRUE(clear.has_body);
|
||||
ASSERT_EQ(clear.body.dump(), std::string("{}"));
|
||||
}
|
||||
|
||||
TEST(discovery, regional_endpoints_come_from_the_document) {
|
||||
Rig r(true, true);
|
||||
CallArgs a;
|
||||
a.params = obj({{"name", Json("projects/p1/locations/us-central1/workflows/w")}});
|
||||
a.location = "us-central1";
|
||||
PreparedCall p = r.engine->plan("workflows", "workflows.projects.locations.workflows.get", a);
|
||||
ASSERT_EQ(p.endpoint.base_url, std::string("https://workflows.us-central1.rep.googleapis.com"));
|
||||
a.location = "mars-north1";
|
||||
ASSERT_TRUE(invalid([&] { r.engine->plan("workflows", "workflows.projects.locations.workflows.get", a); }, "no endpoint for location"));
|
||||
CallArgs t;
|
||||
t.params = obj({{"tasklist", Json("L")}});
|
||||
t.location = "us-central1";
|
||||
ASSERT_TRUE(invalid([&] { r.engine->plan("tasks", "tasks.tasks.list", t); }, "no regional endpoints"));
|
||||
}
|
||||
|
||||
TEST(discovery, paging_arguments_are_checked_before_traffic) {
|
||||
Rig r(true, true);
|
||||
CallArgs a;
|
||||
a.params = obj({{"name", Json("sites/example.com")}});
|
||||
a.max_pages = 3;
|
||||
ASSERT_TRUE(invalid([&] { r.engine->call("abusiveexperiencereport", "abusiveexperiencereport.sites.get", a); }, "not pageable"));
|
||||
a.max_pages = 0;
|
||||
ASSERT_TRUE(invalid([&] { r.engine->call("abusiveexperiencereport", "abusiveexperiencereport.sites.get", a); }, "max_pages"));
|
||||
a.max_pages = DiscoveryCaps::kMaxPages + 1;
|
||||
ASSERT_TRUE(invalid([&] { r.engine->call("abusiveexperiencereport", "abusiveexperiencereport.sites.get", a); }, "max_pages"));
|
||||
ASSERT_EQ(r.mock->send_count(), std::size_t{0});
|
||||
}
|
||||
|
||||
TEST(discovery, unknown_api_and_method_are_named) {
|
||||
Rig r(true, true);
|
||||
try {
|
||||
r.engine->plan("nosuchapi", "x.y", CallArgs{});
|
||||
FAIL("expected throw");
|
||||
} catch (const GoogleError& e) {
|
||||
ASSERT_EQ(e.http_status(), 404);
|
||||
}
|
||||
try {
|
||||
r.engine->plan("tasks", "tasks.nope", CallArgs{});
|
||||
FAIL("expected throw");
|
||||
} catch (const GoogleError& e) {
|
||||
ASSERT_EQ(e.http_status(), 404);
|
||||
}
|
||||
ASSERT_TRUE(invalid([&] { r.engine->plan("../etc", "x", CallArgs{}); }, "name or name:version"));
|
||||
}
|
||||
|
||||
TEST(discovery, no_credential_is_503_after_validation) {
|
||||
Rig r(false, false);
|
||||
CallArgs a;
|
||||
a.params = obj({{"tasklist", Json("L1")}});
|
||||
try {
|
||||
r.engine->call("tasks", "tasks.tasks.list", a);
|
||||
FAIL("expected throw");
|
||||
} catch (const NotConfiguredError& e) {
|
||||
ASSERT_EQ(e.http_status(), 503);
|
||||
}
|
||||
ASSERT_TRUE(invalid([&] { r.engine->call("tasks", "tasks.tasks.list", CallArgs{}); }, "required"));
|
||||
ASSERT_EQ(r.mock->send_count(), std::size_t{0});
|
||||
}
|
||||
|
||||
TEST(discovery, call_sends_the_planned_request_with_the_chosen_credential) {
|
||||
Rig r(true, true);
|
||||
r.accept(HttpMethod::kPost, "/tasks/v1/lists/L1/tasks");
|
||||
CallArgs a;
|
||||
a.params = obj({{"tasklist", Json("L1")}});
|
||||
a.body = obj({{"title", Json("write tests")}});
|
||||
CallResult res = r.engine->call("tasks", "tasks.tasks.insert", a);
|
||||
ASSERT_EQ(res.pages, std::size_t{1});
|
||||
auto seen = r.mock->seen();
|
||||
ASSERT_EQ(seen.size(), std::size_t{1});
|
||||
ASSERT_EQ(seen[0].method, std::string("POST"));
|
||||
ASSERT_EQ(seen[0].body, std::string("{\"title\":\"write tests\"}"));
|
||||
ASSERT_EQ(seen[0].headers.get("Authorization").value_or(""), std::string("Bearer TOKENVALUE"));
|
||||
|
||||
Rig k(true, true);
|
||||
k.accept(HttpMethod::kGet, "/v1/sites/example.com");
|
||||
CallArgs g;
|
||||
g.params = obj({{"name", Json("sites/example.com")}});
|
||||
k.engine->call("abusiveexperiencereport", "abusiveexperiencereport.sites.get", g);
|
||||
ASSERT_EQ(k.mock->seen()[0].headers.get("x-goog-api-key").value_or(""), std::string("KEYVALUE"));
|
||||
}
|
||||
|
||||
TEST(discovery, catalog_caches_expires_and_honors_the_refetch_floor) {
|
||||
auto src = std::make_shared<CountingSource>();
|
||||
auto now = std::make_shared<std::chrono::steady_clock::time_point>(
|
||||
std::chrono::steady_clock::time_point{} + std::chrono::hours(1000));
|
||||
Catalog cat(src, [now] { return *now; });
|
||||
cat.api("tasks");
|
||||
ASSERT_EQ(src->fetches, 2); // directory + document
|
||||
cat.api("tasks");
|
||||
cat.api("tasks:v1");
|
||||
ASSERT_EQ(src->fetches, 2);
|
||||
ASSERT_EQ(cat.stats().cached, std::size_t{1});
|
||||
// forgetting inside the floor still serves the cached document
|
||||
cat.forget("tasks");
|
||||
*now += std::chrono::seconds(30);
|
||||
cat.api("tasks");
|
||||
ASSERT_EQ(src->fetches, 2);
|
||||
// past the floor the forgotten document is fetched again
|
||||
*now += std::chrono::seconds(31);
|
||||
cat.api("tasks");
|
||||
ASSERT_EQ(src->fetches, 3);
|
||||
// past the max age, directory and document are both refetched
|
||||
*now += DiscoveryCaps::kMaxAge + std::chrono::seconds(1);
|
||||
cat.api("tasks");
|
||||
ASSERT_EQ(src->fetches, 5);
|
||||
}
|
||||
|
||||
TEST(discovery, catalog_rejects_a_document_that_is_not_the_one_listed) {
|
||||
struct Swap : DocumentSource {
|
||||
FileDocumentSource inner{kFixtures};
|
||||
std::string fetch(const std::string& url, std::size_t max) override {
|
||||
if (url.find("tasks") != std::string::npos && url.find("directory") == std::string::npos &&
|
||||
url != kDirectoryUrl)
|
||||
return inner.fetch("https://workflows.googleapis.com/$discovery/rest?version=v1", max);
|
||||
return inner.fetch(url, max);
|
||||
}
|
||||
};
|
||||
Catalog cat(std::make_shared<Swap>());
|
||||
ASSERT_THROW(cat.api("tasks"), GoogleError);
|
||||
}
|
||||
|
||||
TEST(discovery, list_and_describe_report_the_declaration) {
|
||||
Rig r(true, true);
|
||||
Json apis = r.engine->list_apis("task", 10);
|
||||
ASSERT_EQ(apis.as_array().size(), std::size_t{1});
|
||||
Json ms = r.engine->list_methods("tasks", "tasks.tasks.", 3);
|
||||
ASSERT_EQ(ms.find("methods")->as_array().size(), std::size_t{3});
|
||||
ASSERT_TRUE(ms.find("truncated")->as_bool());
|
||||
Json d = r.engine->describe("tasks", "tasks.tasks.list");
|
||||
ASSERT_TRUE(d.find("pageable")->as_bool());
|
||||
ASSERT_EQ(d.find("itemsKey")->as_string(), std::string("items"));
|
||||
Json wf = r.engine->describe("workflows", "workflows.projects.locations.workflows.delete");
|
||||
ASSERT_TRUE(wf.find("operation")->as_bool());
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
// Opt-in live checks (MOLO_LIVE_NET=1): the real directory, real documents
|
||||
// fetched over HTTPS with no credential, and read-only calls on the project
|
||||
// behind GOOGLE_ACCESS_TOKEN (GOOGLE_CLOUD_PROJECT, default lisa-448004).
|
||||
// Nothing is created, changed or deleted. A disabled API is reported loudly.
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
#include "framework.h"
|
||||
#include "google/credentials.h"
|
||||
#include "google/discovery/caps.h"
|
||||
#include "google/discovery/engine.h"
|
||||
|
||||
using namespace molo::google;
|
||||
using namespace molo::google::discovery;
|
||||
using molo::clients::body::Json;
|
||||
|
||||
namespace {
|
||||
bool net() { return std::getenv("MOLO_LIVE_NET") != nullptr; }
|
||||
bool authed() { return net() && !Credentials::env("GOOGLE_ACCESS_TOKEN").empty(); }
|
||||
std::string project() {
|
||||
std::string p = Credentials::env("GOOGLE_CLOUD_PROJECT");
|
||||
return p.empty() ? "lisa-448004" : p;
|
||||
}
|
||||
void skip(const char* name, const char* why) {
|
||||
std::cout << "SKIP " << name << " (" << why << ")\n";
|
||||
}
|
||||
Engine make_engine(std::shared_ptr<Catalog>& cat) {
|
||||
cat = std::make_shared<Catalog>(std::make_shared<HttpDocumentSource>());
|
||||
return Engine(GoogleClient::from_env(), cat);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
TEST(discovery_live, directory_and_documents_from_google) {
|
||||
if (!net()) return skip("discovery_live.directory_and_documents_from_google", "set MOLO_LIVE_NET=1");
|
||||
Catalog cat(std::make_shared<HttpDocumentSource>());
|
||||
auto dir = cat.directory();
|
||||
std::cout << " directory: " << dir->items().size() << " items, " << dir->preferred_count()
|
||||
<< " preferred\n";
|
||||
ASSERT_TRUE(dir->preferred_count() >= 300);
|
||||
for (const char* name : {"serviceusage", "cloudresourcemanager", "tasks", "workflows"}) {
|
||||
auto api = cat.api(name);
|
||||
std::cout << " " << api->id() << ": " << api->methods().size() << " methods, "
|
||||
<< api->endpoints().size() << " regional endpoints, " << api->raw_bytes << " bytes\n";
|
||||
ASSERT_TRUE(api->methods().size() > 5);
|
||||
}
|
||||
ASSERT_EQ(cat.stats().fetches, std::size_t{5});
|
||||
}
|
||||
|
||||
TEST(discovery_live, sizes_of_the_largest_documents_fit_the_caps) {
|
||||
if (!net()) return skip("discovery_live.sizes_of_the_largest_documents_fit_the_caps", "set MOLO_LIVE_NET=1");
|
||||
Catalog cat(std::make_shared<HttpDocumentSource>());
|
||||
for (const char* name : {"compute", "aiplatform"}) {
|
||||
auto api = cat.api(name);
|
||||
std::cout << " " << api->id() << ": " << api->methods().size() << " methods, " << api->raw_bytes
|
||||
<< " bytes\n";
|
||||
ASSERT_TRUE(api->raw_bytes <= DiscoveryCaps::kMaxDocBytes);
|
||||
ASSERT_TRUE(api->methods().size() <= DiscoveryCaps::kMaxMethods);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(discovery_live, read_only_calls_page_and_get) {
|
||||
if (!authed()) return skip("discovery_live.read_only_calls_page_and_get", "needs MOLO_LIVE_NET=1 and GOOGLE_ACCESS_TOKEN");
|
||||
std::shared_ptr<Catalog> cat;
|
||||
Engine e = make_engine(cat);
|
||||
try {
|
||||
CallArgs get;
|
||||
get.params.set("name", Json("projects/" + project() + "/services/serviceusage.googleapis.com"));
|
||||
CallResult p = e.call("serviceusage", "serviceusage.services.get", get);
|
||||
std::cout << " serviceusage.services.get: " << p.body.dump().substr(0, 120) << "\n";
|
||||
ASSERT_TRUE(p.body.find("name") != nullptr);
|
||||
|
||||
CallArgs list;
|
||||
list.params = Json::object();
|
||||
list.params.set("parent", Json("projects/" + project()));
|
||||
list.params.set("pageSize", Json(3));
|
||||
list.params.set("filter", Json("state:ENABLED"));
|
||||
list.max_pages = 3;
|
||||
CallResult s = e.call("serviceusage", "serviceusage.services.list", list);
|
||||
std::cout << " serviceusage.services.list: pages=" << s.pages << " items="
|
||||
<< s.body.find("services")->as_array().size() << " truncated=" << s.truncated << "\n";
|
||||
ASSERT_EQ(s.items_key, std::string("services"));
|
||||
ASSERT_TRUE(s.pages >= 2);
|
||||
ASSERT_TRUE(s.body.find("services")->as_array().size() > 3);
|
||||
ASSERT_TRUE(s.truncated || s.body.find("nextPageToken") == nullptr);
|
||||
} catch (const GoogleError& err) {
|
||||
if (err.http_status() == 403 || err.status() == "PERMISSION_DENIED")
|
||||
std::cout << " API NOT ENABLED or permission denied: " << err.message() << "\n";
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
TEST(discovery_live, operation_reply_is_detected_and_a_missing_one_is_4xx) {
|
||||
if (!authed()) return skip("discovery_live.operation_reply_is_detected_and_a_missing_one_is_4xx", "needs MOLO_LIVE_NET=1 and GOOGLE_ACCESS_TOKEN");
|
||||
std::shared_ptr<Catalog> cat;
|
||||
Engine e = make_engine(cat);
|
||||
CallArgs a;
|
||||
a.params.set("name", Json("operations/does-not-exist-0000"));
|
||||
PreparedCall p = e.plan("serviceusage", "serviceusage.operations.get", a);
|
||||
ASSERT_TRUE(p.operation);
|
||||
try {
|
||||
e.call("serviceusage", "serviceusage.operations.get", a);
|
||||
FAIL("expected a 4xx");
|
||||
} catch (const GoogleError& err) {
|
||||
std::cout << " serviceusage.operations.get(missing): " << err.http_status() << " " << err.status() << "\n";
|
||||
ASSERT_TRUE(err.http_status() == 404 || err.http_status() == 400); // Google rejects the name shape with 400
|
||||
}
|
||||
}
|
||||
|
||||
TEST(discovery_live, completed_operation_with_wait_returns_without_polling) {
|
||||
if (!authed()) return skip("discovery_live.completed_operation_with_wait_returns_without_polling", "needs MOLO_LIVE_NET=1 and GOOGLE_ACCESS_TOKEN");
|
||||
std::shared_ptr<Catalog> cat;
|
||||
Engine e = make_engine(cat);
|
||||
// Find a finished operation of the project, then fetch it again with wait.
|
||||
CallArgs list;
|
||||
list.params.set("name", Json("operations"));
|
||||
list.params.set("pageSize", Json(5));
|
||||
list.params.set("filter", Json("done=true"));
|
||||
try {
|
||||
CallResult l = e.call("serviceusage", "serviceusage.operations.list", list);
|
||||
const Json* ops = l.body.find("operations");
|
||||
if (!ops || ops->as_array().empty()) {
|
||||
std::cout << " no finished operations visible to this identity: wait path not exercised\n";
|
||||
return;
|
||||
}
|
||||
std::string name = ops->as_array()[0].find("name")->as_string();
|
||||
CallArgs get;
|
||||
get.params.set("name", Json(name));
|
||||
get.wait = true;
|
||||
CallResult g = e.call("serviceusage", "serviceusage.operations.get", get);
|
||||
std::cout << " waited on " << name << ": done=" << g.body.find("done")->as_bool() << "\n";
|
||||
ASSERT_TRUE(g.operation_waited);
|
||||
ASSERT_TRUE(g.body.find("done")->as_bool());
|
||||
} catch (const GoogleError& err) {
|
||||
std::cout << " NOT EXERCISED (wait polling needs a finished operation): " << err.http_status() << " " << err.status() << ": " << err.message() << "\n";
|
||||
if (err.http_status() == 403 || err.http_status() == 400) return; // loud, not a failure of the engine
|
||||
throw;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user