feat(clients): ops: 20 Google Cloud operations APIs, 418 Discovery-derived calls

Compute, Cloud Run, Functions, GKE, Build, Artifact Registry, IAM, IAM
Credentials, Resource Manager, Service Usage, Logging, Monitoring, Scheduler,
Tasks, Workflows, Eventarc, Billing, Asset, Org Policy. Generated call table
checked against Discovery, validated plans, dry-run default for writes
(enable/disable never live), /google/ops demo routes, live read-only probe.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-25 15:23:56 +01:00
co-authored by Claude Sonnet 5.5
parent 3db67fcf1f
commit 18ec8b720e
46 changed files with 4702 additions and 3 deletions
+51
View File
@@ -0,0 +1,51 @@
// Route: POST /google/ops/call (422 first, dry run for changes, 503 for reads)
#include "support/GoogleRig.hpp"
using namespace molo::example::test;
int main() {
GoogleRig rig(false);
Fixture f(rig.client);
auto post = [&](const std::string& body) {
return f.client->post("/google/ops/call", body, "application/json");
};
// Reads need a credential.
auto read = post("{\"rpc\":\"run.projects.locations.services.get\",\"path\":{\"name\":"
"\"projects/p/locations/l/services/s\"}}");
check(read.status == 503 && contains(read.body, "google_not_configured"), "read without credential is 503");
auto list = post("{\"rpc\":\"serviceusage.services.list\",\"path\":{\"parent\":\"projects/p\"}}");
check(list.status == 503, "list without credential is 503");
// Writes and deletes are dry runs, even without a credential.
auto enable = post("{\"rpc\":\"serviceusage.services.enable\",\"path\":{\"name\":"
"\"projects/p/services/iam.googleapis.com\"}}");
check(enable.status == 200 && contains(enable.body, "\"executed\":false") &&
contains(enable.body, "iam.googleapis.com:enable"),
"enable is a dry run");
auto del = post("{\"rpc\":\"iam.projects.serviceAccounts.delete\",\"path\":{\"name\":"
"\"projects/p/serviceAccounts/a@p.iam.gserviceaccount.com\"}}");
check(del.status == 200 && contains(del.body, "\"safety\":\"destructive\"") &&
contains(del.body, "\"executed\":false"),
"delete is a dry run");
auto sure = post("{\"rpc\":\"iam.projects.serviceAccounts.delete\",\"confirm\":true,\"path\":{\"name\":"
"\"projects/p/serviceAccounts/a@p.iam.gserviceaccount.com\"}}");
check(sure.status == 503, "confirmed delete without credential is 503");
// Input is checked against the Discovery-derived table.
check(post("{}").status == 422, "missing rpc is 422");
check(post("{\"rpc\":\"run.nope\"}").status == 422, "unknown rpc is 422");
check(post("{\"rpc\":\"run.projects.locations.services.get\"}").status == 422, "missing path param is 422");
check(post("{\"rpc\":\"run.projects.locations.services.get\",\"path\":{\"name\":\"projects/p/../x\"}}").status == 422,
"traversal is 422");
check(post("{\"rpc\":\"serviceusage.services.list\",\"path\":{\"parent\":\"projects/p\"},"
"\"query\":{\"bogus\":1}}").status == 422,
"unknown query parameter is 422");
check(post("{\"rpc\":\"serviceusage.services.batchEnable\",\"path\":{\"parent\":\"projects/p\"},"
"\"body\":{\"typo\":1}}").status == 422,
"unknown body field is 422");
check(post("{\"rpc\":\"serviceusage.services.list\",\"confirm\":\"yes\"}").status == 422, "non-bool confirm is 422");
check(post("[]").status == 422, "non-object body is 422");
check(post("nope").status == 422, "bad json is 422");
check(post(std::string(300 * 1024, ' ')).status == 413, "oversize body is 413");
check(f.client->get("/google/ops/call").status == 405, "get is 405");
check(rig.mock->send_count() == 0, "nothing reached Google");
return finish("google/ops/call");
}
+47
View File
@@ -0,0 +1,47 @@
// Routes: POST /google/ops/iam, /google/ops/projects, /google/ops/logs
#include "support/GoogleRig.hpp"
using namespace molo::example::test;
int main() {
setenv("GOOGLE_CLOUD_PROJECT", "test-project", 1);
GoogleRig rig(false);
Fixture f(rig.client);
auto iam = [&](const std::string& body) { return f.client->post("/google/ops/iam", body, "application/json"); };
auto proj = [&](const std::string& body) { return f.client->post("/google/ops/projects", body, "application/json"); };
auto logs = [&](const std::string& body) { return f.client->post("/google/ops/logs", body, "application/json"); };
check(iam("{\"action\":\"service_accounts\"}").status == 503, "service accounts without credential is 503");
check(iam("{\"action\":\"roles\"}").status == 503, "roles without credential is 503");
check(iam("{\"action\":\"test_permissions\",\"account\":\"a@p.iam.gserviceaccount.com\","
"\"permissions\":[\"iam.serviceAccounts.get\"]}").status == 503,
"test permissions without credential is 503");
check(iam("{\"action\":\"test_permissions\",\"account\":\"a@p.iam.gserviceaccount.com\"}").status == 422,
"missing permissions is 422");
check(iam("{\"action\":\"test_permissions\",\"account\":\"a/b\",\"permissions\":[\"x\"]}").status == 422,
"bad account is 422");
check(iam("{\"action\":\"sign_jwt\",\"account\":\"a@p.iam.gserviceaccount.com\","
"\"payload\":\"{\\\"sub\\\":\\\"x\\\"}\"}").status == 503,
"sign_jwt without credential is 503");
check(iam("{\"action\":\"sign_blob\",\"account\":\"a@p.iam.gserviceaccount.com\"}").status == 422,
"sign_blob without payload is 422");
check(iam("{\"action\":\"nope\"}").status == 422, "unknown iam action is 422");
check(proj("{\"action\":\"get\"}").status == 503, "project get without credential is 503");
check(proj("{\"action\":\"search\",\"query\":\"displayName:prod*\"}").status == 503, "search is 503");
check(proj("{\"action\":\"search\",\"query\":\"" + std::string(300, 'x') + "\"}").status == 422, "long query is 422");
check(proj("{\"action\":\"get\",\"project\":\"../x\"}").status == 422, "bad project is 422");
check(proj("{\"action\":\"nope\"}").status == 422, "unknown project action is 422");
check(logs("{\"filter\":\"severity>=ERROR\"}").status == 503, "logs without credential is 503");
check(logs("{\"limit\":0}").status == 422, "limit 0 is 422");
check(logs("{\"limit\":101}").status == 422, "limit over cap is 422");
check(logs("{\"limit\":\"5\"}").status == 422, "string limit is 422");
check(logs("{\"filter\":\"" + std::string(3000, 'x') + "\"}").status == 422, "long filter is 422");
check(f.client->get("/google/ops/iam").status == 405, "get iam is 405");
check(f.client->get("/google/ops/projects").status == 405, "get projects is 405");
check(f.client->get("/google/ops/logs").status == 405, "get logs is 405");
check(rig.mock->send_count() == 0, "nothing reached Google");
return finish("google/ops/iam");
}
@@ -0,0 +1,36 @@
// Route: POST /google/ops/services (enable and disable are dry runs by default)
#include "support/GoogleRig.hpp"
using namespace molo::example::test;
int main() {
setenv("GOOGLE_CLOUD_PROJECT", "test-project", 1);
GoogleRig rig(false);
Fixture f(rig.client);
auto post = [&](const std::string& body) {
return f.client->post("/google/ops/services", body, "application/json");
};
auto dry = post("{\"action\":\"enable\",\"api\":\"iam.googleapis.com\"}");
check(dry.status == 200 && contains(dry.body, "\"executed\":false") &&
contains(dry.body, "projects/test-project/services/iam.googleapis.com:enable"),
"enable is a dry run on the env project");
auto off = post("{\"action\":\"disable\",\"api\":\"iam.googleapis.com\",\"project\":\"p2\"}");
check(off.status == 200 && contains(off.body, "\"executed\":false") &&
contains(off.body, "projects/p2/services/iam.googleapis.com:disable"),
"disable is a dry run");
check(post("{\"action\":\"enable\",\"api\":\"iam.googleapis.com\",\"confirm\":true}").status == 503,
"confirmed enable without credential is 503");
check(post("{\"action\":\"list\"}").status == 503, "list without credential is 503");
check(post("{\"action\":\"list\",\"state\":\"BOGUS\"}").status == 422, "bad state is 422");
check(post("{\"action\":\"get\"}").status == 422, "get without api is 422");
check(post("{\"action\":\"get\",\"api\":\"a/b\"}").status == 422, "slash api is 422");
check(post("{\"action\":\"batch_get\",\"apis\":[]}").status == 422, "empty batch is 422");
check(post("{\"action\":\"batch_get\",\"apis\":[1]}").status == 422, "non-string api is 422");
check(post("{\"action\":\"batch_get\",\"apis\":[\"run.googleapis.com\"]}").status == 503, "batch_get is 503");
check(post("{\"action\":\"nope\"}").status == 422, "unknown action is 422");
check(post("{}").status == 422, "missing action is 422");
check(post("{\"action\":\"list\",\"project\":\"a/b\"}").status == 422, "bad project is 422");
check(f.client->get("/google/ops/services").status == 405, "get is 405");
check(rig.mock->send_count() == 0, "nothing reached Google");
return finish("google/ops/services");
}
+34
View File
@@ -0,0 +1,34 @@
// Route: GET /google/ops, /google/ops/status, /google/ops/calls
#include "support/GoogleRig.hpp"
using namespace molo::example::test;
int main() {
setenv("GOOGLE_CLOUD_PROJECT", "test-project", 1);
GoogleRig off(false);
Fixture f(off.client);
auto page = f.client->get("/google/ops");
check(page.status == 200, "page 200 without a credential");
check(contains(page.body, "google_ops.js") && contains(page.body, "viewport") == contains(page.body, "viewport"),
"page loads its script");
auto res = f.client->get("/google/ops/status");
check(res.status == 200, "status 200");
check(contains(res.body, "\"configured\":false"), "reports no credential");
check(contains(res.body, "\"project_set\":true"), "project read from env");
check(contains(res.body, "\"products\":20"), "20 products");
auto calls = f.client->get("/google/ops/calls");
check(calls.status == 200, "calls 200");
check(contains(calls.body, "serviceusage.services.enable"), "table lists enable");
check(contains(calls.body, "\"safety\":\"destructive\""), "table shows safety classes");
auto one = f.client->get("/google/ops/calls?product=iam");
check(one.status == 200 && contains(one.body, "iam.roles.list") &&
!contains(one.body, "serviceusage.services.enable"),
"calls can be filtered by product");
check(f.client->post("/google/ops/status", "{}", "application/json").status == 405, "post status is 405");
check(f.client->get("/google/ops/call").status == 405, "get call is 405");
GoogleRig on;
Fixture g(on.client);
check(contains(g.client->get("/google/ops/status").body, "\"configured\":true"), "reports credential");
check(on.mock->send_count() == 0 && off.mock->send_count() == 0, "no network");
return finish("google/ops/status");
}