Files
retoorandClaude Sonnet 5.5 18ec8b720e 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>
2026-10-25 15:23:56 +01:00

37 lines
2.2 KiB
C++

// 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");
}