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
+183
View File
@@ -0,0 +1,183 @@
# Google Cloud operations (ops) - Specification
Owned directory: `src/google/ops/`. Namespace `molo::google::ops`. Depends on
the `src/google` foundation (`GoogleClient`, `Service`, `operation.h`,
`resource.h`). Plan: `plans/18-breadth.md` (method: plans 16 and 17).
## 1. Scope
Twenty Discovery APIs, 418 calls, one table:
| Product object | Discovery API | Typed methods cover |
|---|---|---|
| `Compute` | compute v1 | instances (list, get, insert, start, stop, reset, delete), zones, regions, machine types, disks, networks, subnetworks, firewalls, images, project, zone operations (get, wait) |
| `CloudRun` | run v2 | services, revisions, jobs, executions, tasks, run / cancel / delete, IAM policy |
| `CloudFunctions` | cloudfunctions v2 | functions, runtimes, locations, upload / download URLs, create, delete |
| `Gke` | container v1 | clusters, node pools, operations, server config, create, resize, delete |
| `CloudBuild` | cloudbuild v1 | builds, triggers, worker pools, create / cancel / retry / run, delete |
| `ArtifactRegistry` | artifactregistry v1 | repositories, packages, versions, tags, files, docker images, delete |
| `Iam` | iam v1 | roles, grantable roles, testable permissions, service accounts, keys, policy, testIamPermissions, create / enable / disable / delete |
| `IamCredentials` | iamcredentials v1 | signJwt, signBlob, access token, id token |
| `ResourceManager` | cloudresourcemanager v3 | projects, folders, organizations, liens, tags, IAM policy, testIamPermissions, create / delete |
| `ServiceUsage` | serviceusage v1 | list, get, batchGet, enable, disable, batchEnable, operations |
| `CloudLogging` | logging v2 | entries.list, entries.write, log names, sinks, metrics, exclusions, buckets |
| `CloudMonitoring` | monitoring v3 | time series, metric and resource descriptors, alert policies, channels, groups, uptime checks, services |
| `CloudScheduler` | cloudscheduler v1 | jobs: list, get, create, pause, resume, run, delete |
| `CloudTasks` | cloudtasks v2 | queues, tasks, pause, resume, purge, delete |
| `Workflows`, `WorkflowExecutions` | workflows v1, workflowexecutions v1 | workflows, revisions, executions, step entries, start, cancel |
| `Eventarc` | eventarc v1 | triggers, channels, providers, pipelines, message buses, enrollments |
| `Billing` | cloudbilling v1 | accounts, account projects, project billing info, services, SKUs, link project |
| `CloudAsset` | cloudasset v1 | searchAllResources, searchAllIamPolicies, assets, feeds, saved queries, exportAssets |
| `OrgPolicy` | orgpolicy v2 | constraints, policies, effective policy, custom constraints, create, delete |
Every one of the 418 rows is also reachable through the generic
`OpsProduct::read / list / call` of its product (a product refuses rows of
another product). Not covered: media upload and download, aggregated compute
lists (map-shaped responses), the legacy `zones` surface of GKE, Cloud Build
GitHub / Bitbucket configs, IAM workforce and workload identity pools,
Logging folder / organization / billing scopes, A2A rows that Cloud Billing's
Discovery document carries by mistake.
## 2. Module map
| File | Concern |
|---|---|
| `caps.h` | Static ceilings (`OpsCaps`) |
| `calls.cpp` | GENERATED table of products and calls from Discovery (`tools/gen_calls.py`); never hand edited |
| `calls.h`, `calls_lookup.cpp` | `Product`, `CallSpec`, `Safety`, lookup, endpoints |
| `call_plan.h/.cpp` | `Args`, `CallPlan` (all local validation), resource name checks |
| `ops_client.h/.cpp` | `OpsClient`: read, list (page walk), execute (dry run gate), wait; `Outcome` |
| `ops_product.h/.cpp` | `OpsProduct : Service` base, `Names` |
| `api_state.h/.cpp` | `ApiState`, `DisabledApi`: recognises "API not enabled" |
| one header per product | typed methods (see section 1), `service_usage.cpp` for `ServiceUsage` |
| `ops.h` | `Ops`: all products over one client |
| `tools/gen_calls.py` | Selection list plus generator: everything else is read from Discovery |
| `tools/check_discovery.py` | Fails on any drift between `calls.cpp` and Discovery |
## 3. Static caps
| Knob | Value |
|---|---|
| path segment / segments per resource name | 256 chars / 12 |
| rendered path plus query | 1024 chars |
| query value / values of a repeated parameter | 1024 chars / 100 |
| request body | 1 MiB |
| list page walk / items returned | 20 pages (demo 5) / 5000 |
| default page size | 100 |
| batchGet / batchEnable names | 20 |
| logging entries per read / resource names | 1000 (demo 100) / 10 |
| sign payload | 64 KiB |
| operation name | 512 chars, `projects/` or `organizations/` prefix |
| wait for an operation | `operation.h`: 600 s, 400 polls |
## 4. Contracts
- Every URL comes from the table. Path parameters are validated against the
shape Discovery declares (`projects/*/locations/*/services/*`), each segment
`[A-Za-z0-9._~@:-]` or `%XX` (never an encoded dot), no `..`. Query keys and
top level body keys must be declared by Discovery; GET and DELETE take no body.
Invalid input is `GoogleError` 400 `INVALID_ARGUMENT` before any traffic.
- No credential: a call that passes validation throws `NotConfiguredError`.
- Safety classes come from the table: read (runs), write, destructive.
`OpsClient::execute(rpc, args, confirm)` has no default for `confirm`;
a write or destructive call with `confirm=false` is a DRY RUN: it returns an
`Outcome` with `executed=false` and the full plan, sends nothing and needs no
credential. Typed write methods default `confirm=false`; typed destructive
methods (delete, purge) have no default.
- `ServiceUsage::enable / disable / batch_enable` are writes with the dry run
default. Enabling an API is the human's job; no code path of this package,
demo or test calls them with `confirm=true`.
- POST rows that only read or sign (getIamPolicy, testIamPermissions,
signJwt, signBlob, entries.list, query verbs, zone operation wait) are
classed read.
- List rows walk `nextPageToken` (query for GET, body for POST) up to the page
and item caps. Long-running rows are tagged `lro` (google.longrunning, poll
with `OpsProduct::wait`) or `compute` (Compute operation, poll with
`zone_operation`); GKE operations are polled by `operation(name)` status.
- A disabled API answers 403; `ApiState::disabled` turns it into
`API NOT ENABLED: <service>, a human enables it at <console URL>` and the
demo answers 502 `api_not_enabled`.
## 5. Example routes (`/google/ops`)
GET `/google/ops` (page), `/status`, `/calls[?product=]`. POST `/call` (any
row: `{rpc,path,query,body,confirm}`), `/services` (list, get, batch_get,
enable, disable), `/projects` (get, search), `/iam` (service_accounts, roles,
test_permissions, sign_jwt, sign_blob), `/logs`. Validation first (422), then
the credential (503 `google_not_configured`); non-read calls are dry runs
unless `"confirm":true`; oversize body 413.
## Required APIs
Enable these on the project (placeholder project `example-214512124`). A
disabled API answers 403 `SERVICE_DISABLED`.
- `compute.googleapis.com`: https://console.developers.google.com/apis/api/compute.googleapis.com/overview?project=example-214512124
- `run.googleapis.com`: https://console.developers.google.com/apis/api/run.googleapis.com/overview?project=example-214512124
- `cloudfunctions.googleapis.com`: https://console.developers.google.com/apis/api/cloudfunctions.googleapis.com/overview?project=example-214512124
- `container.googleapis.com`: https://console.developers.google.com/apis/api/container.googleapis.com/overview?project=example-214512124
- `cloudbuild.googleapis.com`: https://console.developers.google.com/apis/api/cloudbuild.googleapis.com/overview?project=example-214512124
- `artifactregistry.googleapis.com`: https://console.developers.google.com/apis/api/artifactregistry.googleapis.com/overview?project=example-214512124
- `iam.googleapis.com`: https://console.developers.google.com/apis/api/iam.googleapis.com/overview?project=example-214512124
- `iamcredentials.googleapis.com`: https://console.developers.google.com/apis/api/iamcredentials.googleapis.com/overview?project=example-214512124
- `cloudresourcemanager.googleapis.com`: https://console.developers.google.com/apis/api/cloudresourcemanager.googleapis.com/overview?project=example-214512124
- `serviceusage.googleapis.com`: https://console.developers.google.com/apis/api/serviceusage.googleapis.com/overview?project=example-214512124
- `logging.googleapis.com`: https://console.developers.google.com/apis/api/logging.googleapis.com/overview?project=example-214512124
- `monitoring.googleapis.com`: https://console.developers.google.com/apis/api/monitoring.googleapis.com/overview?project=example-214512124
- `cloudscheduler.googleapis.com`: https://console.developers.google.com/apis/api/cloudscheduler.googleapis.com/overview?project=example-214512124
- `cloudtasks.googleapis.com`: https://console.developers.google.com/apis/api/cloudtasks.googleapis.com/overview?project=example-214512124
- `workflows.googleapis.com`: https://console.developers.google.com/apis/api/workflows.googleapis.com/overview?project=example-214512124
- `workflowexecutions.googleapis.com`: https://console.developers.google.com/apis/api/workflowexecutions.googleapis.com/overview?project=example-214512124
- `eventarc.googleapis.com`: https://console.developers.google.com/apis/api/eventarc.googleapis.com/overview?project=example-214512124
- `cloudbilling.googleapis.com`: https://console.developers.google.com/apis/api/cloudbilling.googleapis.com/overview?project=example-214512124
- `cloudasset.googleapis.com`: https://console.developers.google.com/apis/api/cloudasset.googleapis.com/overview?project=example-214512124
- `orgpolicy.googleapis.com`: https://console.developers.google.com/apis/api/orgpolicy.googleapis.com/overview?project=example-214512124
Scope: all calls use `cloud-platform`; no other scope is needed.
## Sources
- Discovery documents fetched 2026-10-25 (`https://<api>.googleapis.com/$discovery/rest?version=<v>`),
revisions recorded per product in `calls.cpp`.
## Verified against discovery
`python3 -I src/google/ops/tools/check_discovery.py`, 2026-10-25:
`ops discovery: 20 products, 418 calls` / `discovery ok`. Checks, per row:
HTTP method, path, query parameters (exact set), request body fields (exact
set of non read-only top level fields), path shapes, list item key is an array
of the response, long-running kind, safety consistency; per product: version,
root URL, service path.
## Verified live
Service account on project `lisa-448004`, read-only, 2026-10-25
(`make google-live`, test `ops_live.read_only_probe_of_every_product`):
serviceusage list (49 enabled), get, batchGet; compute zones (130) and
instances (0); iam serviceAccounts (4), roles, testIamPermissions (1 of 1
held); logging log names (3) and entries; monitoring alert policies (0);
billing project info; cloudasset search (155). `API NOT ENABLED` on the
project for: cloudresourcemanager, run, cloudfunctions, container,
cloudbuild, artifactregistry, cloudscheduler, cloudtasks, workflows,
eventarc, orgpolicy (enabling is the human's job; those product paths are
verified by Discovery only).
## Unverified
- Every write and destructive call: never sent to Google by design (dry run
plus Discovery check only), including enable / disable.
- signJwt, signBlob, generateAccessToken, generateIdToken (needs
iamcredentials enabled and impersonation rights); body field names come from
Discovery.
- All responses of the 11 products whose API is not enabled.
- Compute `wait`, long-running `wait()` polling against a real operation.
- `ServiceState` parsing is tested on the documented shape only (no scripted
Google reply); live use parsed real `services.list` output.
## Gaps
- Typed response classes exist only for `ServiceState`; other replies are Json.
- GKE and Compute operations have no wait helper (poll `operation` /
`zone_operation`).
- Folder and organization scopes of Logging, Org Policy writes outside
projects: reachable only through generic `call` rows that were selected.
+42
View File
@@ -0,0 +1,42 @@
#include "google/ops/api_state.h"
namespace molo::google::ops {
std::string DisabledApi::loud() const {
return "API NOT ENABLED: " + (service.empty() ? std::string("(unnamed)") : service) +
(activation_url.empty() ? "" : ", a human enables it at " + activation_url);
}
std::string ApiState::service_in(const std::string& text) {
const std::string suffix = ".googleapis.com";
std::size_t at = 0;
while ((at = text.find(suffix, at)) != std::string::npos) {
std::size_t start = at;
while (start > 0) {
char c = text[start - 1];
if ((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '-') --start;
else break;
}
if (start < at) return text.substr(start, at + suffix.size() - start);
at += suffix.size();
}
return "";
}
std::optional<DisabledApi> ApiState::disabled(const GoogleError& e, const std::string& project) {
if (e.http_status() != 403) return std::nullopt;
const std::string& m = e.message();
bool off = e.status() == "SERVICE_DISABLED" ||
m.find("has not been used in project") != std::string::npos ||
m.find("it is disabled") != std::string::npos ||
m.find("SERVICE_DISABLED") != std::string::npos;
if (!off) return std::nullopt;
DisabledApi d;
d.service = service_in(m);
if (!d.service.empty() && !project.empty())
d.activation_url = "https://console.developers.google.com/apis/api/" + d.service +
"/overview?project=" + project;
return d;
}
} // namespace molo::google::ops
+31
View File
@@ -0,0 +1,31 @@
#pragma once
// Recognises "the API is not enabled on this project" so callers can say so
// loudly instead of showing a bare 403. Enabling is a human decision: this
// class only reports.
#include <optional>
#include <string>
#include "google/errors.h"
namespace molo::google::ops {
struct DisabledApi {
std::string service; // e.g. iam.googleapis.com ("" when Google named none)
std::string activation_url; // console page where a human enables it
// "API NOT ENABLED: iam.googleapis.com, enable it at https://..."
std::string loud() const;
};
class ApiState {
public:
// Set when the error is Google's "has not been used in project ... or it is
// disabled" / SERVICE_DISABLED answer (HTTP 403).
static std::optional<DisabledApi> disabled(const GoogleError& error,
const std::string& project);
// "services/serviceusage.googleapis.com" style segment of the API host in a text.
static std::string service_in(const std::string& text);
};
} // namespace molo::google::ops
+72
View File
@@ -0,0 +1,72 @@
#pragma once
// Artifact Registry v1. `parent` is projects/{p}/locations/{l}; deeper names
// are full resource names (.../repositories/{r}/packages/{pkg}).
#include "google/ops/ops_product.h"
namespace molo::google::ops {
class ArtifactRegistry : public OpsProduct {
public:
using Json = clients::body::Json;
explicit ArtifactRegistry(std::shared_ptr<GoogleClient> c, Sleeper s = nullptr)
: OpsProduct(std::move(c), "artifactregistry", std::move(s)) {}
Json locations(const std::string& project_name) const {
return list("artifactregistry.projects.locations.list", at("name", project_name));
}
Json repositories(const std::string& parent) const {
return list("artifactregistry.projects.locations.repositories.list", at("parent", parent));
}
Json repository(const std::string& name) const {
return read("artifactregistry.projects.locations.repositories.get", at("name", name));
}
Json packages(const std::string& repository_name) const {
return list("artifactregistry.projects.locations.repositories.packages.list",
at("parent", repository_name));
}
Json versions(const std::string& package_name) const {
return list("artifactregistry.projects.locations.repositories.packages.versions.list",
at("parent", package_name));
}
Json tags(const std::string& package_name) const {
return list("artifactregistry.projects.locations.repositories.packages.tags.list",
at("parent", package_name));
}
Json files(const std::string& repository_name) const {
return list("artifactregistry.projects.locations.repositories.files.list",
at("parent", repository_name));
}
Json docker_images(const std::string& repository_name) const {
return list("artifactregistry.projects.locations.repositories.dockerImages.list",
at("parent", repository_name));
}
Json project_settings(const std::string& name) const {
return read("artifactregistry.projects.getProjectSettings", at("name", name));
}
Json operation(const std::string& name) const {
return read("artifactregistry.projects.locations.operations.get", at("name", name));
}
Outcome create_repository(const std::string& parent, const std::string& repository_id,
const Json& repository, bool confirm = false) const {
Args a = at("parent", parent);
a.query("repositoryId", Json(repository_id)).body(repository);
return call("artifactregistry.projects.locations.repositories.create", a, confirm);
}
Outcome delete_repository(const std::string& name, bool confirm) const {
return call("artifactregistry.projects.locations.repositories.delete", at("name", name),
confirm);
}
Outcome delete_package(const std::string& name, bool confirm) const {
return call("artifactregistry.projects.locations.repositories.packages.delete",
at("name", name), confirm);
}
Outcome delete_version(const std::string& name, bool confirm) const {
return call("artifactregistry.projects.locations.repositories.packages.versions.delete",
at("name", name), confirm);
}
};
} // namespace molo::google::ops
+45
View File
@@ -0,0 +1,45 @@
#pragma once
// Cloud Billing v1: accounts, the billing link of a project, the public
// catalog (services, SKUs). Re-linking a project to another account is a
// write (dry run unless confirm) and moves cost.
#include "google/ops/ops_product.h"
namespace molo::google::ops {
class Billing : public OpsProduct {
public:
using Json = clients::body::Json;
explicit Billing(std::shared_ptr<GoogleClient> c, Sleeper s = nullptr)
: OpsProduct(std::move(c), "cloudbilling", std::move(s)) {}
Json accounts() const { return list("cloudbilling.billingAccounts.list", Args()); }
Json account(const std::string& name) const {
return read("cloudbilling.billingAccounts.get", at("name", name));
}
Json account_projects(const std::string& account_name) const {
return list("cloudbilling.billingAccounts.projects.list", at("name", account_name));
}
Json account_policy(const std::string& account_name) const {
return read("cloudbilling.billingAccounts.getIamPolicy", at("resource", account_name));
}
Json project_billing_info(const std::string& project_name) const {
return read("cloudbilling.projects.getBillingInfo", at("name", project_name));
}
Json services() const { return list("cloudbilling.services.list", Args()); }
// service_name: services/{id}
Json skus(const std::string& service_name) const {
return list("cloudbilling.services.skus.list", at("parent", service_name), 5);
}
// billing_account_name: billingAccounts/{id}, or "" to unlink the project.
Outcome link_project(const std::string& project_name, const std::string& billing_account_name,
bool confirm = false) const {
Args a = at("name", project_name);
a.field("billingAccountName", Json(billing_account_name));
return call("cloudbilling.projects.updateBillingInfo", a, confirm);
}
};
} // namespace molo::google::ops
+208
View File
@@ -0,0 +1,208 @@
#include "google/ops/call_plan.h"
#include <cmath>
#include "clients/url.h"
#include "google/errors.h"
#include "google/ops/caps.h"
namespace molo::google::ops {
using clients::body::Json;
namespace {
bool hex(char c) {
return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');
}
std::string lower(std::string s) {
for (char& c : s)
if (c >= 'A' && c <= 'Z') c = static_cast<char>(c - 'A' + 'a');
return s;
}
[[noreturn]] void bad(const std::string& why) { throw GoogleError::invalid(why); }
std::string query_value(const std::string& key, const Json& v) {
if (v.is_string()) {
if (v.as_string().size() > OpsCaps::kMaxQueryValueChars) bad(key + " too long");
return clients::Url::encode_component(v.as_string());
}
if (v.is_bool()) return v.as_bool() ? "true" : "false";
if (v.is_number()) {
double d = v.as_number();
if (d != std::floor(d) || std::fabs(d) > 1e15) bad(key + " must be an integer");
return std::to_string(static_cast<long long>(d));
}
bad(key + " must be a string, number or boolean");
}
} // namespace
bool valid_name_segment(const std::string& s) {
if (s.empty() || s.size() > OpsCaps::kMaxSegmentChars || s == "." || s == "..") return false;
for (std::size_t i = 0; i < s.size(); ++i) {
char c = s[i];
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') ||
c == '-' || c == '_' || c == '.' || c == '~' || c == '@' || c == ':')
continue;
if (c == '%' && i + 2 < s.size() + 0 && hex(s[i + 1]) && hex(s[i + 2])) {
if (lower(s.substr(i, 3)) == "%2e") return false; // no encoded dots
i += 2;
continue;
}
return false;
}
return true;
}
void check_resource_name(const std::string& what, const std::string& value,
const std::string& shape) {
std::vector<std::string> parts, want;
auto split = [](const std::string& s, std::vector<std::string>& out) {
std::size_t at = 0;
while (true) {
std::size_t end = s.find('/', at);
out.push_back(s.substr(at, end == std::string::npos ? end : end - at));
if (end == std::string::npos) break;
at = end + 1;
}
};
split(value, parts);
if (parts.size() > OpsCaps::kMaxSegments) bad(what + " has too many segments");
for (const std::string& p : parts)
if (!valid_name_segment(p)) bad(what + " has an invalid segment");
if (shape.empty()) return;
split(shape, want);
if (parts.size() != want.size()) bad(what + " must look like " + shape);
for (std::size_t i = 0; i < want.size(); ++i)
if (want[i] != "*" && want[i] != parts[i]) bad(what + " must look like " + shape);
}
// --- Args ---------------------------------------------------------------------
Args& Args::path(const std::string& name, const std::string& value) {
path_.set(name, Json(value));
return *this;
}
Args& Args::query(const std::string& name, const Json& value) {
query_.set(name, value);
return *this;
}
Args& Args::body(Json value) {
body_ = std::move(value);
return *this;
}
Args& Args::field(const std::string& name, Json value) {
if (!body_.is_object()) body_ = Json::object();
body_.set(name, std::move(value));
return *this;
}
Args Args::from_json(const Json& doc) {
Args a;
if (!doc.is_object()) bad("arguments must be a JSON object");
for (const char* key : {"path", "query", "body"}) {
const Json* v = doc.find(key);
if (v && !v->is_null() && !v->is_object()) bad(std::string(key) + " must be a JSON object");
}
if (const Json* p = doc.find("path"); p && p->is_object())
for (const auto& [k, v] : p->as_object()) {
if (!v.is_string()) bad("path." + k + " must be a string");
a.path(k, v.as_string());
}
if (const Json* q = doc.find("query"); q && q->is_object())
for (const auto& [k, v] : q->as_object()) a.query(k, v);
if (const Json* b = doc.find("body"); b && b->is_object()) a.body(*b);
return a;
}
// --- CallPlan -----------------------------------------------------------------
CallPlan CallPlan::build(const CallSpec& spec, const Args& args) {
CallPlan plan;
plan.spec_ = &spec;
// Path: every {x} / {+x} must be supplied; nothing else may be.
std::string tmpl = spec.path, rendered;
std::vector<std::string> used;
for (std::size_t i = 0; i < tmpl.size();) {
if (tmpl[i] != '{') {
rendered += tmpl[i++];
continue;
}
std::size_t close = tmpl.find('}', i);
if (close == std::string::npos) bad("bad path template");
std::string name = tmpl.substr(i + 1, close - i - 1);
bool multi = !name.empty() && name[0] == '+';
if (multi) name.erase(0, 1);
const Json* v = args.path_args().find(name);
if (!v || !v->is_string()) bad("path parameter " + name + " is required");
const std::string& value = v->as_string();
if (multi) check_resource_name(name, value, spec.shape_of(name));
else if (!valid_name_segment(value)) bad("path parameter " + name + " is invalid");
rendered += value;
used.push_back(name);
i = close + 1;
}
for (const auto& [k, v] : args.path_args().as_object()) {
(void)v;
bool known = false;
for (const std::string& u : used) known = known || u == k;
if (!known) bad("unknown path parameter " + k);
}
// Query: only declared parameters; arrays repeat the key.
std::string query;
for (const auto& [k, v] : args.query_args().as_object()) {
if (!spec.has_query(k)) bad("unknown query parameter " + k + " for " + spec.rpc);
if (v.is_null()) continue;
if (v.is_array()) {
if (v.as_array().size() > OpsCaps::kMaxQueryValues) bad(k + " has too many values");
for (const Json& item : v.as_array()) {
if (!item.is_string()) bad(k + " values must be strings");
query += (query.empty() ? "" : "&") + k + "=" + query_value(k, item);
}
} else {
query += (query.empty() ? "" : "&") + k + "=" + query_value(k, v);
}
}
plan.path_ = "/" + rendered + (query.empty() ? "" : "?" + query);
if (plan.path_.size() > OpsCaps::kMaxPathChars) bad("request path too long");
// Body: only the declared top level fields; bodiless verbs take none.
bool bodiless = spec.method() == clients::Method::kGet ||
spec.method() == clients::Method::kDelete;
if (args.has_body()) {
if (!args.body_arg().is_object()) bad("body must be a JSON object");
if (bodiless && !args.body_arg().as_object().empty())
bad(std::string(spec.rpc) + " takes no request body");
for (const auto& [k, v] : args.body_arg().as_object()) {
(void)v;
if (!spec.has_body_field(k)) bad("unknown body field " + k + " for " + spec.rpc);
}
if (args.body_arg().dump().size() > OpsCaps::kMaxBodyBytes) bad("body too large");
}
if (!bodiless) {
plan.has_body_ = true;
plan.body_ = args.has_body() ? args.body_arg() : Json::object();
}
return plan;
}
std::string CallPlan::url() const { return endpoint_of(product_named(spec_->product())).base_url + path_; }
Json CallPlan::to_json() const {
Json o = Json::object();
o.set("rpc", Json(spec_->rpc));
o.set("http", Json(spec_->http));
o.set("url", Json(url()));
o.set("safety", Json(spec_->safe() == Safety::kRead
? "read"
: spec_->safe() == Safety::kWrite ? "write" : "destructive"));
if (has_body_) o.set("body", body_);
return o;
}
} // namespace molo::google::ops
+70
View File
@@ -0,0 +1,70 @@
#pragma once
// A validated, not yet sent request: the table row plus path, query and body
// arguments. Building a plan does all local validation (no network, no
// credential), so a plan can also be shown as a dry run.
#include <string>
#include <utility>
#include <vector>
#include "clients/body/json.h"
#include "google/ops/calls.h"
namespace molo::google::ops {
// Arguments of one call. Path and query values are strings (query also
// numbers, bools and string arrays); the body is a JSON object.
class Args {
public:
Args& path(const std::string& name, const std::string& value);
Args& query(const std::string& name, const clients::body::Json& value);
Args& body(clients::body::Json value);
// One body field.
Args& field(const std::string& name, clients::body::Json value);
const clients::body::Json& path_args() const { return path_; }
const clients::body::Json& query_args() const { return query_; }
const clients::body::Json& body_arg() const { return body_; }
bool has_body() const { return !body_.is_null(); }
// From the JSON shape used by the demo: {"path":{},"query":{},"body":{}}.
static Args from_json(const clients::body::Json& doc);
private:
clients::body::Json path_ = clients::body::Json::object();
clients::body::Json query_ = clients::body::Json::object();
clients::body::Json body_;
};
class CallPlan {
public:
// Throws GoogleError 400 INVALID_ARGUMENT on any violation.
static CallPlan build(const CallSpec& spec, const Args& args);
const CallSpec& spec() const { return *spec_; }
clients::Method method() const { return spec_->method(); }
const std::string& path() const { return path_; } // "/v2/projects/p/...?x=y"
bool has_body() const { return has_body_; }
const clients::body::Json& body() const { return body_; }
// Full URL for display: endpoint base + path.
std::string url() const;
// {"rpc","http","url","safety","body"} for dry runs and logs (no credential).
clients::body::Json to_json() const;
private:
const CallSpec* spec_ = nullptr;
std::string path_;
bool has_body_ = false;
clients::body::Json body_;
};
// Segment and resource-name validation shared by plan building and the typed
// helpers: each segment 1..256 of [A-Za-z0-9._~@:%-], not "." or "..".
bool valid_name_segment(const std::string& s);
// A resource name: segments split by '/', matching `shape` ("projects/*/x/*")
// segment for segment when the shape is not empty.
void check_resource_name(const std::string& what, const std::string& value,
const std::string& shape);
} // namespace molo::google::ops
+460
View File
@@ -0,0 +1,460 @@
// GENERATED by tools/gen_calls.py from Google's Discovery documents; do not edit.
// tools/check_discovery.py re-reads this file and fails on any drift.
#include "google/ops/calls.h"
namespace molo::google::ops {
// PRODUCTS-BEGIN (name, version, root url, service path, discovery revision)
static const Product kProducts[] = {
{"compute", "v1", "https://compute.googleapis.com", "compute/v1", "20261016"},
{"run", "v2", "https://run.googleapis.com", "", "20261016"},
{"cloudfunctions", "v2", "https://cloudfunctions.googleapis.com", "", "20261015"},
{"container", "v1", "https://container.googleapis.com", "", "20260922"},
{"cloudbuild", "v1", "https://cloudbuild.googleapis.com", "", "20261010"},
{"artifactregistry", "v1", "https://artifactregistry.googleapis.com", "", "20261022"},
{"iam", "v1", "https://iam.googleapis.com", "", "20261016"},
{"iamcredentials", "v1", "https://iamcredentials.googleapis.com", "", "20261013"},
{"cloudresourcemanager", "v3", "https://cloudresourcemanager.googleapis.com", "", "20261018"},
{"serviceusage", "v1", "https://serviceusage.googleapis.com", "", "20261013"},
{"logging", "v2", "https://logging.googleapis.com", "", "20261016"},
{"monitoring", "v3", "https://monitoring.googleapis.com", "", "20261015"},
{"cloudscheduler", "v1", "https://cloudscheduler.googleapis.com", "", "20261020"},
{"cloudtasks", "v2", "https://cloudtasks.googleapis.com", "", "20261005"},
{"workflows", "v1", "https://workflows.googleapis.com", "", "20261007"},
{"workflowexecutions", "v1", "https://workflowexecutions.googleapis.com", "", "20261012"},
{"eventarc", "v1", "https://eventarc.googleapis.com", "", "20261014"},
{"cloudbilling", "v1", "https://cloudbilling.googleapis.com", "", "20261016"},
{"cloudasset", "v1", "https://cloudasset.googleapis.com", "", "20261017"},
{"orgpolicy", "v2", "https://orgpolicy.googleapis.com", "", "20261015"},
};
// PRODUCTS-END
// CALLS-BEGIN (rpc, http, path, safety R/W/D, kind, items key, body fields, query params, path shapes)
static const CallSpec kCalls[] = {
{"compute.instances.list", "GET", "projects/{project}/zones/{zone}/instances", "R", "", "items", "", "pageToken,maxResults,returnPartialSuccess,filter,orderBy", "project= zone="},
{"compute.instances.get", "GET", "projects/{project}/zones/{zone}/instances/{instance}", "R", "", "", "", "", "project= zone= instance="},
{"compute.instances.insert", "POST", "projects/{project}/zones/{zone}/instances", "W", "compute", "", "instanceEncryptionKey,sourceMachineImage,labelFingerprint,sourceMachineImageEncryptionKey,workloadIdentityConfig,reservationAffinity,serviceAccounts,params,minCpuPlatform,localSsdEncryptionMode,description,scheduling,shieldedInstanceConfig,canIpForward,fingerprint,name,displayDevice,guestAccelerators,tags,shieldedInstanceIntegrityPolicy,privateIpv6GoogleAccess,metadata,advancedMachineFeatures,labels,keyRevocationActionType,resourcePolicies,confidentialInstanceConfig,deletionProtection,hostname,networkPerformanceConfig,disks,networkInterfaces,machineType", "sourceInstanceTemplate,sourceMachineImage,requestId", "project= zone="},
{"compute.instances.delete", "DELETE", "projects/{project}/zones/{zone}/instances/{instance}", "D", "compute", "", "", "requestId,noGracefulShutdown", "project= zone= instance="},
{"compute.instances.start", "POST", "projects/{project}/zones/{zone}/instances/{instance}/start", "W", "compute", "", "", "requestId", "project= zone= instance="},
{"compute.instances.stop", "POST", "projects/{project}/zones/{zone}/instances/{instance}/stop", "W", "compute", "", "", "requestId,discardLocalSsd,noGracefulShutdown", "project= zone= instance="},
{"compute.instances.reset", "POST", "projects/{project}/zones/{zone}/instances/{instance}/reset", "W", "compute", "", "", "requestId", "project= zone= instance="},
{"compute.zones.list", "GET", "projects/{project}/zones", "R", "", "items", "", "pageToken,orderBy,maxResults,returnPartialSuccess,filter", "project="},
{"compute.zones.get", "GET", "projects/{project}/zones/{zone}", "R", "", "", "", "", "project= zone="},
{"compute.regions.list", "GET", "projects/{project}/regions", "R", "", "items", "", "maxResults,returnPartialSuccess,orderBy,pageToken,filter", "project="},
{"compute.regions.get", "GET", "projects/{project}/regions/{region}", "R", "", "", "", "", "project= region="},
{"compute.machineTypes.list", "GET", "projects/{project}/zones/{zone}/machineTypes", "R", "", "items", "", "returnPartialSuccess,maxResults,orderBy,pageToken,filter", "project= zone="},
{"compute.machineTypes.get", "GET", "projects/{project}/zones/{zone}/machineTypes/{machineType}", "R", "", "", "", "", "project= zone= machineType="},
{"compute.disks.list", "GET", "projects/{project}/zones/{zone}/disks", "R", "", "items", "", "returnPartialSuccess,filter,orderBy,maxResults,pageToken", "project= zone="},
{"compute.disks.get", "GET", "projects/{project}/zones/{zone}/disks/{disk}", "R", "", "", "", "", "project= zone= disk="},
{"compute.networks.list", "GET", "projects/{project}/global/networks", "R", "", "items", "", "maxResults,returnPartialSuccess,filter,orderBy,pageToken", "project="},
{"compute.networks.get", "GET", "projects/{project}/global/networks/{network}", "R", "", "", "", "", "project= network="},
{"compute.subnetworks.list", "GET", "projects/{project}/regions/{region}/subnetworks", "R", "", "items", "", "filter,maxResults,returnPartialSuccess,orderBy,views,pageToken", "project= region="},
{"compute.subnetworks.get", "GET", "projects/{project}/regions/{region}/subnetworks/{subnetwork}", "R", "", "", "", "views", "project= region= subnetwork="},
{"compute.firewalls.list", "GET", "projects/{project}/global/firewalls", "R", "", "items", "", "returnPartialSuccess,orderBy,pageToken,filter,maxResults", "project="},
{"compute.firewalls.get", "GET", "projects/{project}/global/firewalls/{firewall}", "R", "", "", "", "", "project= firewall="},
{"compute.images.list", "GET", "projects/{project}/global/images", "R", "", "items", "", "orderBy,maxResults,filter,returnPartialSuccess,pageToken", "project="},
{"compute.images.get", "GET", "projects/{project}/global/images/{image}", "R", "", "", "", "", "project= image="},
{"compute.addresses.list", "GET", "projects/{project}/regions/{region}/addresses", "R", "", "items", "", "returnPartialSuccess,filter,orderBy,maxResults,pageToken", "project= region="},
{"compute.instanceTemplates.list", "GET", "projects/{project}/global/instanceTemplates", "R", "", "items", "", "pageToken,filter,orderBy,returnPartialSuccess,maxResults", "project="},
{"compute.instanceTemplates.get", "GET", "projects/{project}/global/instanceTemplates/{instanceTemplate}", "R", "", "", "", "", "project= instanceTemplate="},
{"compute.instanceGroups.list", "GET", "projects/{project}/zones/{zone}/instanceGroups", "R", "", "items", "", "pageToken,orderBy,maxResults,filter,returnPartialSuccess", "project= zone="},
{"compute.snapshots.list", "GET", "projects/{project}/global/snapshots", "R", "", "items", "", "maxResults,pageToken,orderBy,returnPartialSuccess,filter", "project="},
{"compute.snapshots.get", "GET", "projects/{project}/global/snapshots/{snapshot}", "R", "", "", "", "", "project= snapshot="},
{"compute.backendServices.list", "GET", "projects/{project}/global/backendServices", "R", "", "items", "", "orderBy,filter,returnPartialSuccess,maxResults,pageToken", "project="},
{"compute.forwardingRules.list", "GET", "projects/{project}/regions/{region}/forwardingRules", "R", "", "items", "", "pageToken,orderBy,maxResults,returnPartialSuccess,filter", "project= region="},
{"compute.projects.get", "GET", "projects/{project}", "R", "", "", "", "", "project="},
{"compute.zoneOperations.list", "GET", "projects/{project}/zones/{zone}/operations", "R", "", "items", "", "filter,maxResults,orderBy,pageToken,returnPartialSuccess", "project= zone="},
{"compute.zoneOperations.get", "GET", "projects/{project}/zones/{zone}/operations/{operation}", "R", "compute", "", "", "", "project= zone= operation="},
{"compute.zoneOperations.wait", "POST", "projects/{project}/zones/{zone}/operations/{operation}/wait", "R", "compute", "", "", "", "project= zone= operation="},
{"compute.globalOperations.list", "GET", "projects/{project}/global/operations", "R", "", "items", "", "maxResults,returnPartialSuccess,pageToken,orderBy,filter", "project="},
{"compute.globalOperations.get", "GET", "projects/{project}/global/operations/{operation}", "R", "compute", "", "", "", "project= operation="},
{"compute.regionOperations.list", "GET", "projects/{project}/regions/{region}/operations", "R", "", "items", "", "orderBy,filter,returnPartialSuccess,pageToken,maxResults", "project= region="},
{"compute.regionOperations.get", "GET", "projects/{project}/regions/{region}/operations/{operation}", "R", "compute", "", "", "", "project= region= operation="},
{"run.projects.locations.services.list", "GET", "v2/{+parent}/services", "R", "", "services", "", "showDeleted,pageSize,pageToken", "parent=projects/*/locations/*"},
{"run.projects.locations.services.get", "GET", "v2/{+name}", "R", "", "", "", "", "name=projects/*/locations/*/services/*"},
{"run.projects.locations.services.create", "POST", "v2/{+parent}/services", "W", "lro", "", "annotations,name,multiRegionSettings,template,customAudiences,binaryAuthorization,labels,traffic,launchStage,invokerIamDisabled,description,ingress,scaling,clientVersion,etag,defaultUriDisabled,iapEnabled,buildConfig,sshEnabled,client,functionalType", "validateOnly,serviceId", "parent=projects/*/locations/*"},
{"run.projects.locations.services.patch", "PATCH", "v2/{+name}", "W", "lro", "", "annotations,name,multiRegionSettings,template,customAudiences,binaryAuthorization,labels,traffic,launchStage,invokerIamDisabled,description,ingress,scaling,clientVersion,etag,defaultUriDisabled,iapEnabled,buildConfig,sshEnabled,client,functionalType", "allowMissing,forceNewRevision,updateMask,validateOnly", "name=projects/*/locations/*/services/*"},
{"run.projects.locations.services.delete", "DELETE", "v2/{+name}", "D", "lro", "", "", "validateOnly,etag", "name=projects/*/locations/*/services/*"},
{"run.projects.locations.services.getIamPolicy", "GET", "v2/{+resource}:getIamPolicy", "R", "", "", "", "options.requestedPolicyVersion", "resource=projects/*/locations/*/services/*"},
{"run.projects.locations.services.setIamPolicy", "POST", "v2/{+resource}:setIamPolicy", "W", "", "", "policy,updateMask", "", "resource=projects/*/locations/*/services/*"},
{"run.projects.locations.services.testIamPermissions", "POST", "v2/{+resource}:testIamPermissions", "R", "", "", "permissions", "", "resource=projects/*/locations/*/services/*"},
{"run.projects.locations.services.revisions.list", "GET", "v2/{+parent}/revisions", "R", "", "revisions", "", "showDeleted,pageToken,pageSize", "parent=projects/*/locations/*/services/*"},
{"run.projects.locations.services.revisions.get", "GET", "v2/{+name}", "R", "", "", "", "", "name=projects/*/locations/*/services/*/revisions/*"},
{"run.projects.locations.services.revisions.delete", "DELETE", "v2/{+name}", "D", "lro", "", "", "validateOnly,etag", "name=projects/*/locations/*/services/*/revisions/*"},
{"run.projects.locations.jobs.list", "GET", "v2/{+parent}/jobs", "R", "", "jobs", "", "showDeleted,pageToken,pageSize", "parent=projects/*/locations/*"},
{"run.projects.locations.jobs.get", "GET", "v2/{+name}", "R", "", "", "", "", "name=projects/*/locations/*/jobs/*"},
{"run.projects.locations.jobs.create", "POST", "v2/{+parent}/jobs", "W", "lro", "", "launchStage,etag,clientVersion,template,labels,functionalType,annotations,runExecutionToken,name,binaryAuthorization,startExecutionToken,client", "validateOnly,jobId", "parent=projects/*/locations/*"},
{"run.projects.locations.jobs.patch", "PATCH", "v2/{+name}", "W", "lro", "", "launchStage,etag,clientVersion,template,labels,functionalType,annotations,runExecutionToken,name,binaryAuthorization,startExecutionToken,client", "allowMissing,validateOnly", "name=projects/*/locations/*/jobs/*"},
{"run.projects.locations.jobs.delete", "DELETE", "v2/{+name}", "D", "lro", "", "", "etag,validateOnly", "name=projects/*/locations/*/jobs/*"},
{"run.projects.locations.jobs.run", "POST", "v2/{+name}:run", "W", "lro", "", "etag,overrides,validateOnly", "", "name=projects/*/locations/*/jobs/*"},
{"run.projects.locations.jobs.getIamPolicy", "GET", "v2/{+resource}:getIamPolicy", "R", "", "", "", "options.requestedPolicyVersion", "resource=projects/*/locations/*/jobs/*"},
{"run.projects.locations.jobs.setIamPolicy", "POST", "v2/{+resource}:setIamPolicy", "W", "", "", "policy,updateMask", "", "resource=projects/*/locations/*/jobs/*"},
{"run.projects.locations.jobs.testIamPermissions", "POST", "v2/{+resource}:testIamPermissions", "R", "", "", "permissions", "", "resource=projects/*/locations/*/jobs/*"},
{"run.projects.locations.jobs.executions.list", "GET", "v2/{+parent}/executions", "R", "", "executions", "", "showDeleted,pageToken,pageSize", "parent=projects/*/locations/*/jobs/*"},
{"run.projects.locations.jobs.executions.get", "GET", "v2/{+name}", "R", "", "", "", "", "name=projects/*/locations/*/jobs/*/executions/*"},
{"run.projects.locations.jobs.executions.cancel", "POST", "v2/{+name}:cancel", "W", "lro", "", "etag,validateOnly", "", "name=projects/*/locations/*/jobs/*/executions/*"},
{"run.projects.locations.jobs.executions.delete", "DELETE", "v2/{+name}", "D", "lro", "", "", "etag,validateOnly", "name=projects/*/locations/*/jobs/*/executions/*"},
{"run.projects.locations.jobs.executions.tasks.list", "GET", "v2/{+parent}/tasks", "R", "", "tasks", "", "showDeleted,pageSize,pageToken", "parent=projects/*/locations/*/jobs/*/executions/*"},
{"run.projects.locations.jobs.executions.tasks.get", "GET", "v2/{+name}", "R", "", "", "", "", "name=projects/*/locations/*/jobs/*/executions/*/tasks/*"},
{"run.projects.locations.operations.list", "GET", "v2/{+name}/operations", "R", "", "operations", "", "pageSize,returnPartialSuccess,pageToken,filter", "name=projects/*/locations/*"},
{"run.projects.locations.operations.get", "GET", "v2/{+name}", "R", "lro", "", "", "", "name=projects/*/locations/*/operations/*"},
{"run.projects.locations.operations.wait", "POST", "v2/{+name}:wait", "R", "lro", "", "timeout", "", "name=projects/*/locations/*/operations/*"},
{"cloudfunctions.projects.locations.functions.list", "GET", "v2/{+parent}/functions", "R", "", "functions", "", "pageSize,orderBy,filter,pageToken", "parent=projects/*/locations/*"},
{"cloudfunctions.projects.locations.functions.get", "GET", "v2/{+name}", "R", "", "", "", "revision", "name=projects/*/locations/*/functions/*"},
{"cloudfunctions.projects.locations.functions.create", "POST", "v2/{+parent}/functions", "W", "lro", "", "kmsKeyName,name,description,buildConfig,labels,eventTrigger,environment,serviceConfig", "functionId", "parent=projects/*/locations/*"},
{"cloudfunctions.projects.locations.functions.patch", "PATCH", "v2/{+name}", "W", "lro", "", "kmsKeyName,name,description,buildConfig,labels,eventTrigger,environment,serviceConfig", "updateMask", "name=projects/*/locations/*/functions/*"},
{"cloudfunctions.projects.locations.functions.delete", "DELETE", "v2/{+name}", "D", "lro", "", "", "", "name=projects/*/locations/*/functions/*"},
{"cloudfunctions.projects.locations.functions.generateUploadUrl", "POST", "v2/{+parent}/functions:generateUploadUrl", "W", "", "", "environment,kmsKeyName", "", "parent=projects/*/locations/*"},
{"cloudfunctions.projects.locations.functions.generateDownloadUrl", "POST", "v2/{+name}:generateDownloadUrl", "W", "", "", "", "", "name=projects/*/locations/*/functions/*"},
{"cloudfunctions.projects.locations.functions.getIamPolicy", "GET", "v2/{+resource}:getIamPolicy", "R", "", "", "", "options.requestedPolicyVersion", "resource=projects/*/locations/*/functions/*"},
{"cloudfunctions.projects.locations.functions.setIamPolicy", "POST", "v2/{+resource}:setIamPolicy", "W", "", "", "updateMask,policy", "", "resource=projects/*/locations/*/functions/*"},
{"cloudfunctions.projects.locations.functions.testIamPermissions", "POST", "v2/{+resource}:testIamPermissions", "R", "", "", "permissions", "", "resource=projects/*/locations/*/functions/*"},
{"cloudfunctions.projects.locations.list", "GET", "v2/{+name}/locations", "R", "", "locations", "", "pageToken,pageSize,extraLocationTypes,filter", "name=projects/*"},
{"cloudfunctions.projects.locations.runtimes.list", "GET", "v2/{+parent}/runtimes", "R", "", "runtimes", "", "filter", "parent=projects/*/locations/*"},
{"cloudfunctions.projects.locations.operations.list", "GET", "v2/{+name}/operations", "R", "", "operations", "", "pageToken,pageSize,filter,returnPartialSuccess", "name=projects/*/locations/*"},
{"cloudfunctions.projects.locations.operations.get", "GET", "v2/{+name}", "R", "lro", "", "", "", "name=projects/*/locations/*/operations/*"},
{"container.projects.locations.getServerConfig", "GET", "v1/{+name}/serverConfig", "R", "", "", "", "zone,projectId", "name=projects/*/locations/*"},
{"container.projects.locations.clusters.list", "GET", "v1/{+parent}/clusters", "R", "", "clusters", "", "zone,projectId", "parent=projects/*/locations/*"},
{"container.projects.locations.clusters.get", "GET", "v1/{+name}", "R", "", "", "", "zone,projectId,clusterId", "name=projects/*/locations/*/clusters/*"},
{"container.projects.locations.clusters.create", "POST", "v1/{+parent}/clusters", "W", "", "", "zone,cluster,parent,projectId", "", "parent=projects/*/locations/*"},
{"container.projects.locations.clusters.update", "PUT", "v1/{+name}", "W", "", "", "zone,projectId,clusterId,update,name", "", "name=projects/*/locations/*/clusters/*"},
{"container.projects.locations.clusters.delete", "DELETE", "v1/{+name}", "D", "", "", "", "projectId,clusterId,zone", "name=projects/*/locations/*/clusters/*"},
{"container.projects.locations.clusters.fetchClusterUpgradeInfo", "GET", "v1/{+name}:fetchClusterUpgradeInfo", "R", "", "", "", "version", "name=projects/*/locations/*/clusters/*"},
{"container.projects.locations.clusters.checkAutopilotCompatibility", "GET", "v1/{+name}:checkAutopilotCompatibility", "R", "", "", "", "", "name=projects/*/locations/*/clusters/*"},
{"container.projects.locations.clusters.getJwks", "GET", "v1/{+parent}/jwks", "R", "", "", "", "", "parent=projects/*/locations/*/clusters/*"},
{"container.projects.locations.clusters.nodePools.list", "GET", "v1/{+parent}/nodePools", "R", "", "nodePools", "", "projectId,zone,clusterId", "parent=projects/*/locations/*/clusters/*"},
{"container.projects.locations.clusters.nodePools.get", "GET", "v1/{+name}", "R", "", "", "", "nodePoolId,projectId,zone,clusterId", "name=projects/*/locations/*/clusters/*/nodePools/*"},
{"container.projects.locations.clusters.nodePools.create", "POST", "v1/{+parent}/nodePools", "W", "", "", "projectId,zone,nodePool,clusterId,parent", "", "parent=projects/*/locations/*/clusters/*"},
{"container.projects.locations.clusters.nodePools.update", "PUT", "v1/{+name}", "W", "", "", "queuedProvisioning,labels,kubeletConfig,tags,resourceManagerTags,linuxNodeConfig,windowsNodeConfig,storagePools,diskSizeGb,taintConfig,clusterId,gcfsConfig,loggingConfig,containerdConfig,image,nodeNetworkConfig,maintenancePolicy,workloadMetadataConfig,diskType,nodeDrainConfig,confidentialNodes,fastSocket,maxRunDuration,imageType,bootDisk,nodeVersion,resourceLabels,imageProject,name,taints,flexStart,nodePoolId,consolidationDelay,zone,etag,machineType,upgradeSettings,locations,accelerators,gvnic,projectId", "", "name=projects/*/locations/*/clusters/*/nodePools/*"},
{"container.projects.locations.clusters.nodePools.delete", "DELETE", "v1/{+name}", "D", "", "", "", "clusterId,nodePoolId,zone,projectId", "name=projects/*/locations/*/clusters/*/nodePools/*"},
{"container.projects.locations.clusters.nodePools.setSize", "POST", "v1/{+name}:setSize", "W", "", "", "projectId,nodeCount,zone,clusterId,nodePoolId,name", "", "name=projects/*/locations/*/clusters/*/nodePools/*"},
{"container.projects.locations.clusters.nodePools.rollback", "POST", "v1/{+name}:rollback", "W", "", "", "zone,respectPdb,nodePoolId,clusterId,name,projectId", "", "name=projects/*/locations/*/clusters/*/nodePools/*"},
{"container.projects.locations.operations.list", "GET", "v1/{+parent}/operations", "R", "", "operations", "", "projectId,zone", "parent=projects/*/locations/*"},
{"container.projects.locations.operations.get", "GET", "v1/{+name}", "R", "", "", "", "projectId,operationId,zone", "name=projects/*/locations/*/operations/*"},
{"container.projects.locations.operations.cancel", "POST", "v1/{+name}:cancel", "W", "", "", "operationId,zone,name,projectId", "", "name=projects/*/locations/*/operations/*"},
{"container.projects.aggregated.usableSubnetworks.list", "GET", "v1/{+parent}/aggregated/usableSubnetworks", "R", "", "subnetworks", "", "pageSize,filter,pageToken", "parent=projects/*"},
{"cloudbuild.projects.locations.builds.list", "GET", "v1/{+parent}/builds", "R", "", "builds", "", "filter,pageSize,projectId,pageToken", "parent=projects/*/locations/*"},
{"cloudbuild.projects.locations.builds.get", "GET", "v1/{+name}", "R", "", "", "", "projectId,id", "name=projects/*/locations/*/builds/*"},
{"cloudbuild.projects.locations.builds.create", "POST", "v1/{+parent}/builds", "W", "lro", "", "steps,serviceAccount,options,tags,gitConfig,logsBucket,images,queueTtl,source,availableSecrets,substitutions,artifacts,dependencies,timeout,secrets", "projectId", "parent=projects/*/locations/*"},
{"cloudbuild.projects.locations.builds.cancel", "POST", "v1/{+name}:cancel", "W", "", "", "name,projectId,id", "", "name=projects/*/locations/*/builds/*"},
{"cloudbuild.projects.locations.builds.retry", "POST", "v1/{+name}:retry", "W", "lro", "", "name,id,projectId", "", "name=projects/*/locations/*/builds/*"},
{"cloudbuild.projects.locations.builds.approve", "POST", "v1/{+name}:approve", "W", "lro", "", "approvalResult", "", "name=projects/*/locations/*/builds/*"},
{"cloudbuild.projects.builds.list", "GET", "v1/projects/{projectId}/builds", "R", "", "builds", "", "pageToken,filter,parent,pageSize", "projectId="},
{"cloudbuild.projects.builds.get", "GET", "v1/projects/{projectId}/builds/{id}", "R", "", "", "", "name", "projectId= id="},
{"cloudbuild.projects.builds.create", "POST", "v1/projects/{projectId}/builds", "W", "lro", "", "steps,serviceAccount,options,tags,gitConfig,logsBucket,images,queueTtl,source,availableSecrets,substitutions,artifacts,dependencies,timeout,secrets", "parent", "projectId="},
{"cloudbuild.projects.builds.cancel", "POST", "v1/projects/{projectId}/builds/{id}:cancel", "W", "", "", "name,projectId,id", "", "projectId= id="},
{"cloudbuild.projects.builds.retry", "POST", "v1/projects/{projectId}/builds/{id}:retry", "W", "lro", "", "name,id,projectId", "", "projectId= id="},
{"cloudbuild.projects.locations.triggers.list", "GET", "v1/{+parent}/triggers", "R", "", "triggers", "", "pageToken,pageSize,projectId", "parent=projects/*/locations/*"},
{"cloudbuild.projects.locations.triggers.get", "GET", "v1/{+name}", "R", "", "", "", "projectId,triggerId", "name=projects/*/locations/*/triggers/*"},
{"cloudbuild.projects.locations.triggers.create", "POST", "v1/{+parent}/triggers", "W", "", "", "gitFileSource,resourceName,build,ignoredFiles,webhookConfig,developerConnectEventConfig,github,triggerTemplate,includeBuildLogs,tags,sourceToBuild,bitbucketServerTriggerConfig,pubsubConfig,disabled,autodetect,substitutions,description,eventType,approvalConfig,repositoryEventConfig,filter,serviceAccount,name,filename,includedFiles", "projectId", "parent=projects/*/locations/*"},
{"cloudbuild.projects.locations.triggers.patch", "PATCH", "v1/{+resourceName}", "W", "", "", "gitFileSource,resourceName,build,ignoredFiles,webhookConfig,developerConnectEventConfig,github,triggerTemplate,includeBuildLogs,tags,sourceToBuild,bitbucketServerTriggerConfig,pubsubConfig,disabled,autodetect,substitutions,description,eventType,approvalConfig,repositoryEventConfig,filter,serviceAccount,name,filename,includedFiles", "updateMask,projectId,triggerId", "resourceName=projects/*/locations/*/triggers/*"},
{"cloudbuild.projects.locations.triggers.delete", "DELETE", "v1/{+name}", "D", "", "", "", "projectId,triggerId", "name=projects/*/locations/*/triggers/*"},
{"cloudbuild.projects.locations.triggers.run", "POST", "v1/{+name}:run", "W", "lro", "", "triggerId,projectId,source", "", "name=projects/*/locations/*/triggers/*"},
{"cloudbuild.projects.locations.workerPools.list", "GET", "v1/{+parent}/workerPools", "R", "", "workerPools", "", "pageToken,pageSize", "parent=projects/*/locations/*"},
{"cloudbuild.projects.locations.workerPools.get", "GET", "v1/{+name}", "R", "", "", "", "", "name=projects/*/locations/*/workerPools/*"},
{"cloudbuild.projects.locations.workerPools.create", "POST", "v1/{+parent}/workerPools", "W", "lro", "", "displayName,annotations,privatePoolV1Config", "workerPoolId,validateOnly", "parent=projects/*/locations/*"},
{"cloudbuild.projects.locations.workerPools.patch", "PATCH", "v1/{+name}", "W", "lro", "", "displayName,annotations,privatePoolV1Config", "updateMask,validateOnly", "name=projects/*/locations/*/workerPools/*"},
{"cloudbuild.projects.locations.workerPools.delete", "DELETE", "v1/{+name}", "D", "lro", "", "", "allowMissing,validateOnly,etag", "name=projects/*/locations/*/workerPools/*"},
{"cloudbuild.projects.locations.getDefaultServiceAccount", "GET", "v1/{+name}", "R", "", "", "", "", "name=projects/*/locations/*/defaultServiceAccount"},
{"cloudbuild.projects.locations.operations.get", "GET", "v1/{+name}", "R", "lro", "", "", "", "name=projects/*/locations/*/operations/*"},
{"cloudbuild.projects.locations.operations.cancel", "POST", "v1/{+name}:cancel", "W", "", "", "", "", "name=projects/*/locations/*/operations/*"},
{"artifactregistry.projects.locations.list", "GET", "v1/{+name}/locations", "R", "", "locations", "", "pageSize,extraLocationTypes,pageToken,filter", "name=projects/*"},
{"artifactregistry.projects.locations.get", "GET", "v1/{+name}", "R", "", "", "", "", "name=projects/*/locations/*"},
{"artifactregistry.projects.locations.getProjectConfig", "GET", "v1/{+name}", "R", "", "", "", "", "name=projects/*/locations/*/projectConfig"},
{"artifactregistry.projects.getProjectSettings", "GET", "v1/{+name}", "R", "", "", "", "", "name=projects/*/projectSettings"},
{"artifactregistry.projects.locations.repositories.list", "GET", "v1/{+parent}/repositories", "R", "", "repositories", "", "pageToken,pageSize,filter,orderBy", "parent=projects/*/locations/*"},
{"artifactregistry.projects.locations.repositories.get", "GET", "v1/{+name}", "R", "", "", "", "", "name=projects/*/locations/*/repositories/*"},
{"artifactregistry.projects.locations.repositories.create", "POST", "v1/{+parent}/repositories", "W", "lro", "", "kmsKeyName,name,format,platformLogsConfig,labels,cleanupPolicies,dockerConfig,disallowUnspecifiedMode,remoteRepositoryConfig,cleanupPolicyDryRun,description,vulnerabilityScanningConfig,virtualRepositoryConfig,mode,mavenConfig", "repositoryId", "parent=projects/*/locations/*"},
{"artifactregistry.projects.locations.repositories.patch", "PATCH", "v1/{+name}", "W", "", "", "kmsKeyName,name,format,platformLogsConfig,labels,cleanupPolicies,dockerConfig,disallowUnspecifiedMode,remoteRepositoryConfig,cleanupPolicyDryRun,description,vulnerabilityScanningConfig,virtualRepositoryConfig,mode,mavenConfig", "updateMask", "name=projects/*/locations/*/repositories/*"},
{"artifactregistry.projects.locations.repositories.delete", "DELETE", "v1/{+name}", "D", "lro", "", "", "", "name=projects/*/locations/*/repositories/*"},
{"artifactregistry.projects.locations.repositories.getIamPolicy", "GET", "v1/{+resource}:getIamPolicy", "R", "", "", "", "options.requestedPolicyVersion", "resource=projects/*/locations/*/repositories/*"},
{"artifactregistry.projects.locations.repositories.setIamPolicy", "POST", "v1/{+resource}:setIamPolicy", "W", "", "", "policy", "", "resource=projects/*/locations/*/repositories/*"},
{"artifactregistry.projects.locations.repositories.testIamPermissions", "POST", "v1/{+resource}:testIamPermissions", "R", "", "", "permissions", "", "resource=projects/*/locations/*/repositories/*"},
{"artifactregistry.projects.locations.repositories.packages.list", "GET", "v1/{+parent}/packages", "R", "", "packages", "", "orderBy,pageToken,filter,pageSize", "parent=projects/*/locations/*/repositories/*"},
{"artifactregistry.projects.locations.repositories.packages.get", "GET", "v1/{+name}", "R", "", "", "", "", "name=projects/*/locations/*/repositories/*/packages/*"},
{"artifactregistry.projects.locations.repositories.packages.delete", "DELETE", "v1/{+name}", "D", "lro", "", "", "", "name=projects/*/locations/*/repositories/*/packages/*"},
{"artifactregistry.projects.locations.repositories.packages.versions.list", "GET", "v1/{+parent}/versions", "R", "", "versions", "", "view,orderBy,filter,pageToken,pageSize", "parent=projects/*/locations/*/repositories/*/packages/*"},
{"artifactregistry.projects.locations.repositories.packages.versions.get", "GET", "v1/{+name}", "R", "", "", "", "view", "name=projects/*/locations/*/repositories/*/packages/*/versions/*"},
{"artifactregistry.projects.locations.repositories.packages.versions.delete", "DELETE", "v1/{+name}", "D", "lro", "", "", "force", "name=projects/*/locations/*/repositories/*/packages/*/versions/*"},
{"artifactregistry.projects.locations.repositories.packages.versions.batchDelete", "POST", "v1/{+parent}/versions:batchDelete", "D", "lro", "", "validateOnly,names", "", "parent=projects/*/locations/*/repositories/*/packages/*"},
{"artifactregistry.projects.locations.repositories.packages.tags.list", "GET", "v1/{+parent}/tags", "R", "", "tags", "", "pageSize,filter,pageToken", "parent=projects/*/locations/*/repositories/*/packages/*"},
{"artifactregistry.projects.locations.repositories.packages.tags.get", "GET", "v1/{+name}", "R", "", "", "", "", "name=projects/*/locations/*/repositories/*/packages/*/tags/*"},
{"artifactregistry.projects.locations.repositories.packages.tags.create", "POST", "v1/{+parent}/tags", "W", "", "", "name,version", "tagId", "parent=projects/*/locations/*/repositories/*/packages/*"},
{"artifactregistry.projects.locations.repositories.packages.tags.patch", "PATCH", "v1/{+name}", "W", "", "", "name,version", "updateMask", "name=projects/*/locations/*/repositories/*/packages/*/tags/*"},
{"artifactregistry.projects.locations.repositories.packages.tags.delete", "DELETE", "v1/{+name}", "D", "", "", "", "", "name=projects/*/locations/*/repositories/*/packages/*/tags/*"},
{"artifactregistry.projects.locations.repositories.files.list", "GET", "v1/{+parent}/files", "R", "", "files", "", "pageSize,orderBy,filter,pageToken", "parent=projects/*/locations/*/repositories/*"},
{"artifactregistry.projects.locations.repositories.files.get", "GET", "v1/{+name}", "R", "", "", "", "", "name="},
{"artifactregistry.projects.locations.repositories.files.delete", "DELETE", "v1/{+name}", "D", "lro", "", "", "", "name=projects/*/locations/*/repositories/*/files/*"},
{"artifactregistry.projects.locations.repositories.dockerImages.list", "GET", "v1/{+parent}/dockerImages", "R", "", "dockerImages", "", "pageSize,pageToken,orderBy", "parent=projects/*/locations/*/repositories/*"},
{"artifactregistry.projects.locations.repositories.dockerImages.get", "GET", "v1/{+name}", "R", "", "", "", "", "name=projects/*/locations/*/repositories/*/dockerImages/*"},
{"artifactregistry.projects.locations.repositories.mavenArtifacts.list", "GET", "v1/{+parent}/mavenArtifacts", "R", "", "mavenArtifacts", "", "pageToken,pageSize", "parent=projects/*/locations/*/repositories/*"},
{"artifactregistry.projects.locations.repositories.mavenArtifacts.get", "GET", "v1/{+name}", "R", "", "", "", "", "name=projects/*/locations/*/repositories/*/mavenArtifacts/*"},
{"artifactregistry.projects.locations.repositories.npmPackages.list", "GET", "v1/{+parent}/npmPackages", "R", "", "npmPackages", "", "pageToken,pageSize", "parent=projects/*/locations/*/repositories/*"},
{"artifactregistry.projects.locations.repositories.npmPackages.get", "GET", "v1/{+name}", "R", "", "", "", "", "name=projects/*/locations/*/repositories/*/npmPackages/*"},
{"artifactregistry.projects.locations.repositories.pythonPackages.list", "GET", "v1/{+parent}/pythonPackages", "R", "", "pythonPackages", "", "pageSize,pageToken", "parent=projects/*/locations/*/repositories/*"},
{"artifactregistry.projects.locations.repositories.pythonPackages.get", "GET", "v1/{+name}", "R", "", "", "", "", "name=projects/*/locations/*/repositories/*/pythonPackages/*"},
{"artifactregistry.projects.locations.repositories.rules.list", "GET", "v1/{+parent}/rules", "R", "", "rules", "", "pageSize,pageToken", "parent=projects/*/locations/*/repositories/*"},
{"artifactregistry.projects.locations.repositories.rules.get", "GET", "v1/{+name}", "R", "", "", "", "", "name=projects/*/locations/*/repositories/*/rules/*"},
{"artifactregistry.projects.locations.repositories.rules.create", "POST", "v1/{+parent}/rules", "W", "", "", "condition,action,name,operation,packageId", "ruleId", "parent=projects/*/locations/*/repositories/*"},
{"artifactregistry.projects.locations.repositories.rules.patch", "PATCH", "v1/{+name}", "W", "", "", "condition,action,name,operation,packageId", "updateMask", "name=projects/*/locations/*/repositories/*/rules/*"},
{"artifactregistry.projects.locations.repositories.rules.delete", "DELETE", "v1/{+name}", "D", "", "", "", "", "name=projects/*/locations/*/repositories/*/rules/*"},
{"artifactregistry.projects.locations.repositories.attachments.list", "GET", "v1/{+parent}/attachments", "R", "", "attachments", "", "pageToken,filter,pageSize", "parent=projects/*/locations/*/repositories/*"},
{"artifactregistry.projects.locations.repositories.attachments.get", "GET", "v1/{+name}", "R", "", "", "", "", "name=projects/*/locations/*/repositories/*/attachments/*"},
{"artifactregistry.projects.locations.operations.get", "GET", "v1/{+name}", "R", "lro", "", "", "", "name=projects/*/locations/*/operations/*"},
{"iam.roles.list", "GET", "v1/roles", "R", "", "roles", "", "pageSize,parent,showDeleted,view,pageToken", ""},
{"iam.roles.get", "GET", "v1/{+name}", "R", "", "", "", "", "name=roles/*"},
{"iam.roles.queryGrantableRoles", "POST", "v1/roles:queryGrantableRoles", "R", "", "roles", "view,pageSize,pageToken,fullResourceName", "", ""},
{"iam.permissions.queryTestablePermissions", "POST", "v1/permissions:queryTestablePermissions", "R", "", "permissions", "pageToken,fullResourceName,pageSize", "", ""},
{"iam.projects.roles.list", "GET", "v1/{+parent}/roles", "R", "", "roles", "", "view,pageSize,showDeleted,pageToken", "parent=projects/*"},
{"iam.projects.roles.get", "GET", "v1/{+name}", "R", "", "", "", "", "name=projects/*/roles/*"},
{"iam.projects.roles.create", "POST", "v1/{+parent}/roles", "W", "", "", "roleId,role", "", "parent=projects/*"},
{"iam.projects.roles.patch", "PATCH", "v1/{+name}", "W", "", "", "includedPermissions,stage,description,name,etag,deleted,title", "updateMask", "name=projects/*/roles/*"},
{"iam.projects.roles.delete", "DELETE", "v1/{+name}", "D", "", "", "", "etag", "name=projects/*/roles/*"},
{"iam.projects.roles.undelete", "POST", "v1/{+name}:undelete", "W", "", "", "etag", "", "name=projects/*/roles/*"},
{"iam.organizations.roles.list", "GET", "v1/{+parent}/roles", "R", "", "roles", "", "showDeleted,view,pageToken,pageSize", "parent=organizations/*"},
{"iam.organizations.roles.get", "GET", "v1/{+name}", "R", "", "", "", "", "name=organizations/*/roles/*"},
{"iam.projects.serviceAccounts.list", "GET", "v1/{+name}/serviceAccounts", "R", "", "accounts", "", "pageToken,pageSize", "name=projects/*"},
{"iam.projects.serviceAccounts.get", "GET", "v1/{+name}", "R", "", "", "", "", "name=projects/*/serviceAccounts/*"},
{"iam.projects.serviceAccounts.create", "POST", "v1/{+name}/serviceAccounts", "W", "", "", "accountId,serviceAccount", "", "name=projects/*"},
{"iam.projects.serviceAccounts.patch", "PATCH", "v1/{+name}", "W", "", "", "updateMask,serviceAccount", "", "name=projects/*/serviceAccounts/*"},
{"iam.projects.serviceAccounts.update", "PUT", "v1/{+name}", "W", "", "", "description,name,etag,displayName", "", "name=projects/*/serviceAccounts/*"},
{"iam.projects.serviceAccounts.delete", "DELETE", "v1/{+name}", "D", "", "", "", "", "name=projects/*/serviceAccounts/*"},
{"iam.projects.serviceAccounts.undelete", "POST", "v1/{+name}:undelete", "W", "", "", "", "", "name=projects/*/serviceAccounts/*"},
{"iam.projects.serviceAccounts.enable", "POST", "v1/{+name}:enable", "W", "", "", "", "", "name=projects/*/serviceAccounts/*"},
{"iam.projects.serviceAccounts.disable", "POST", "v1/{+name}:disable", "W", "", "", "", "", "name=projects/*/serviceAccounts/*"},
{"iam.projects.serviceAccounts.signBlob", "POST", "v1/{+name}:signBlob", "R", "", "", "bytesToSign", "", "name=projects/*/serviceAccounts/*"},
{"iam.projects.serviceAccounts.signJwt", "POST", "v1/{+name}:signJwt", "R", "", "", "payload", "", "name=projects/*/serviceAccounts/*"},
{"iam.projects.serviceAccounts.getIamPolicy", "POST", "v1/{+resource}:getIamPolicy", "R", "", "", "", "options.requestedPolicyVersion", "resource=projects/*/serviceAccounts/*"},
{"iam.projects.serviceAccounts.setIamPolicy", "POST", "v1/{+resource}:setIamPolicy", "W", "", "", "updateMask,policy", "", "resource=projects/*/serviceAccounts/*"},
{"iam.projects.serviceAccounts.testIamPermissions", "POST", "v1/{+resource}:testIamPermissions", "R", "", "", "permissions", "", "resource=projects/*/serviceAccounts/*"},
{"iam.projects.serviceAccounts.keys.list", "GET", "v1/{+name}/keys", "R", "", "keys", "", "keyTypes", "name=projects/*/serviceAccounts/*"},
{"iam.projects.serviceAccounts.keys.get", "GET", "v1/{+name}", "R", "", "", "", "publicKeyType", "name=projects/*/serviceAccounts/*/keys/*"},
{"iam.projects.serviceAccounts.keys.create", "POST", "v1/{+name}/keys", "W", "", "", "keyAlgorithm,privateKeyType", "", "name=projects/*/serviceAccounts/*"},
{"iam.projects.serviceAccounts.keys.upload", "POST", "v1/{+name}/keys:upload", "W", "", "", "publicKeyData", "", "name=projects/*/serviceAccounts/*"},
{"iam.projects.serviceAccounts.keys.delete", "DELETE", "v1/{+name}", "D", "", "", "", "", "name=projects/*/serviceAccounts/*/keys/*"},
{"iam.projects.serviceAccounts.keys.enable", "POST", "v1/{+name}:enable", "W", "", "", "", "", "name=projects/*/serviceAccounts/*/keys/*"},
{"iam.projects.serviceAccounts.keys.disable", "POST", "v1/{+name}:disable", "W", "", "", "", "", "name=projects/*/serviceAccounts/*/keys/*"},
{"iamcredentials.projects.serviceAccounts.signJwt", "POST", "v1/{+name}:signJwt", "R", "", "", "delegates,payload", "", "name=projects/*/serviceAccounts/*"},
{"iamcredentials.projects.serviceAccounts.signBlob", "POST", "v1/{+name}:signBlob", "R", "", "", "delegates,payload", "", "name=projects/*/serviceAccounts/*"},
{"iamcredentials.projects.serviceAccounts.generateAccessToken", "POST", "v1/{+name}:generateAccessToken", "R", "", "", "scope,lifetime,delegates", "", "name=projects/*/serviceAccounts/*"},
{"iamcredentials.projects.serviceAccounts.generateIdToken", "POST", "v1/{+name}:generateIdToken", "R", "", "", "audience,delegates,includeEmail,organizationNumberIncluded", "", "name=projects/*/serviceAccounts/*"},
{"cloudresourcemanager.projects.get", "GET", "v3/{+name}", "R", "", "", "", "", "name=projects/*"},
{"cloudresourcemanager.projects.list", "GET", "v3/projects", "R", "", "projects", "", "pageToken,parent,showDeleted,pageSize", ""},
{"cloudresourcemanager.projects.search", "GET", "v3/projects:search", "R", "", "projects", "", "pageSize,pageToken,query", ""},
{"cloudresourcemanager.projects.create", "POST", "v3/projects", "W", "lro", "", "projectId,parent,displayName,tags,labels", "", ""},
{"cloudresourcemanager.projects.patch", "PATCH", "v3/{+name}", "W", "lro", "", "projectId,parent,displayName,tags,labels", "updateMask", "name=projects/*"},
{"cloudresourcemanager.projects.delete", "DELETE", "v3/{+name}", "D", "lro", "", "", "", "name=projects/*"},
{"cloudresourcemanager.projects.undelete", "POST", "v3/{+name}:undelete", "W", "lro", "", "", "", "name=projects/*"},
{"cloudresourcemanager.projects.move", "POST", "v3/{+name}:move", "W", "lro", "", "destinationParent", "", "name=projects/*"},
{"cloudresourcemanager.projects.getIamPolicy", "POST", "v3/{+resource}:getIamPolicy", "R", "", "", "options", "", "resource=projects/*"},
{"cloudresourcemanager.projects.setIamPolicy", "POST", "v3/{+resource}:setIamPolicy", "W", "", "", "policy,updateMask", "", "resource=projects/*"},
{"cloudresourcemanager.projects.testIamPermissions", "POST", "v3/{+resource}:testIamPermissions", "R", "", "", "permissions", "", "resource=projects/*"},
{"cloudresourcemanager.folders.get", "GET", "v3/{+name}", "R", "", "", "", "", "name=folders/*"},
{"cloudresourcemanager.folders.list", "GET", "v3/folders", "R", "", "folders", "", "parent,pageSize,showDeleted,pageToken", ""},
{"cloudresourcemanager.folders.search", "GET", "v3/folders:search", "R", "", "folders", "", "pageToken,pageSize,query", ""},
{"cloudresourcemanager.folders.create", "POST", "v3/folders", "W", "lro", "", "name,displayName,parent,tags", "", ""},
{"cloudresourcemanager.folders.patch", "PATCH", "v3/{+name}", "W", "lro", "", "name,displayName,parent,tags", "updateMask", "name=folders/*"},
{"cloudresourcemanager.folders.delete", "DELETE", "v3/{+name}", "D", "lro", "", "", "", "name=folders/*"},
{"cloudresourcemanager.folders.undelete", "POST", "v3/{+name}:undelete", "W", "lro", "", "", "", "name=folders/*"},
{"cloudresourcemanager.folders.move", "POST", "v3/{+name}:move", "W", "lro", "", "destinationParent", "", "name=folders/*"},
{"cloudresourcemanager.folders.getIamPolicy", "POST", "v3/{+resource}:getIamPolicy", "R", "", "", "options", "", "resource=folders/*"},
{"cloudresourcemanager.folders.setIamPolicy", "POST", "v3/{+resource}:setIamPolicy", "W", "", "", "policy,updateMask", "", "resource=folders/*"},
{"cloudresourcemanager.folders.testIamPermissions", "POST", "v3/{+resource}:testIamPermissions", "R", "", "", "permissions", "", "resource=folders/*"},
{"cloudresourcemanager.organizations.get", "GET", "v3/{+name}", "R", "", "", "", "", "name=organizations/*"},
{"cloudresourcemanager.organizations.search", "GET", "v3/organizations:search", "R", "", "organizations", "", "pageSize,pageToken,query", ""},
{"cloudresourcemanager.organizations.getIamPolicy", "POST", "v3/{+resource}:getIamPolicy", "R", "", "", "options", "", "resource=organizations/*"},
{"cloudresourcemanager.organizations.setIamPolicy", "POST", "v3/{+resource}:setIamPolicy", "W", "", "", "policy,updateMask", "", "resource=organizations/*"},
{"cloudresourcemanager.organizations.testIamPermissions", "POST", "v3/{+resource}:testIamPermissions", "R", "", "", "permissions", "", "resource=organizations/*"},
{"cloudresourcemanager.operations.get", "GET", "v3/{+name}", "R", "lro", "", "", "", "name="},
{"cloudresourcemanager.liens.list", "GET", "v3/liens", "R", "", "liens", "", "parent,pageSize,pageToken", ""},
{"cloudresourcemanager.liens.get", "GET", "v3/{+name}", "R", "", "", "", "", "name="},
{"cloudresourcemanager.liens.create", "POST", "v3/liens", "W", "", "", "reason,createTime,origin,parent,name,restrictions", "", ""},
{"cloudresourcemanager.liens.delete", "DELETE", "v3/{+name}", "D", "", "", "", "", "name="},
{"cloudresourcemanager.tagKeys.list", "GET", "v3/tagKeys", "R", "", "tagKeys", "", "pageSize,parent,pageToken", ""},
{"cloudresourcemanager.tagKeys.get", "GET", "v3/{+name}", "R", "", "", "", "", "name=tagKeys/*"},
{"cloudresourcemanager.tagValues.list", "GET", "v3/tagValues", "R", "", "tagValues", "", "pageToken,parent,pageSize", ""},
{"cloudresourcemanager.tagValues.get", "GET", "v3/{+name}", "R", "", "", "", "", "name=tagValues/*"},
{"cloudresourcemanager.tagBindings.list", "GET", "v3/tagBindings", "R", "", "tagBindings", "", "pageSize,pageToken,parent", ""},
{"serviceusage.services.list", "GET", "v1/{+parent}/services", "R", "", "services", "", "filter,pageToken,pageSize", "parent=*/*"},
{"serviceusage.services.get", "GET", "v1/{+name}", "R", "", "", "", "", "name=*/*/services/*"},
{"serviceusage.services.batchGet", "GET", "v1/{+parent}/services:batchGet", "R", "", "", "", "names", "parent=*/*"},
{"serviceusage.services.enable", "POST", "v1/{+name}:enable", "W", "lro", "", "", "", "name=*/*/services/*"},
{"serviceusage.services.disable", "POST", "v1/{+name}:disable", "W", "lro", "", "disableDependentServices,checkIfServiceHasUsage", "", "name=*/*/services/*"},
{"serviceusage.services.batchEnable", "POST", "v1/{+parent}/services:batchEnable", "W", "lro", "", "serviceIds", "", "parent=*/*"},
{"serviceusage.operations.get", "GET", "v1/{+name}", "R", "lro", "", "", "", "name=operations/*"},
{"serviceusage.operations.list", "GET", "v1/operations", "R", "", "operations", "", "pageToken,returnPartialSuccess,name,filter,pageSize", ""},
{"logging.entries.list", "POST", "v2/entries:list", "R", "", "entries", "pageSize,resourceNames,filter,orderBy,projectIds,pageToken", "", ""},
{"logging.entries.write", "POST", "v2/entries:write", "W", "", "", "partialSuccess,entries,resource,dryRun,labels,logName", "", ""},
{"logging.projects.logs.list", "GET", "v2/{+parent}/logs", "R", "", "logNames", "", "pageToken,resourceNames,pageSize", "parent=projects/*"},
{"logging.projects.logs.delete", "DELETE", "v2/{+logName}", "D", "", "", "", "", "logName=projects/*/logs/*"},
{"logging.monitoredResourceDescriptors.list", "GET", "v2/monitoredResourceDescriptors", "R", "", "resourceDescriptors", "", "pageToken,pageSize", ""},
{"logging.projects.sinks.list", "GET", "v2/{+parent}/sinks", "R", "", "sinks", "", "pageToken,filter,pageSize", "parent=projects/*"},
{"logging.projects.sinks.get", "GET", "v2/{+sinkName}", "R", "", "", "", "", "sinkName=projects/*/sinks/*"},
{"logging.projects.sinks.create", "POST", "v2/{+parent}/sinks", "W", "", "", "description,filter,includeChildren,name,bigqueryOptions,disabled,outputVersionFormat,destination,exclusions,interceptChildren", "customWriterIdentity,uniqueWriterIdentity", "parent=projects/*"},
{"logging.projects.sinks.patch", "PATCH", "v2/{+sinkName}", "W", "", "", "description,filter,includeChildren,name,bigqueryOptions,disabled,outputVersionFormat,destination,exclusions,interceptChildren", "uniqueWriterIdentity,updateMask,customWriterIdentity", "sinkName=projects/*/sinks/*"},
{"logging.projects.sinks.delete", "DELETE", "v2/{+sinkName}", "D", "", "", "", "", "sinkName=projects/*/sinks/*"},
{"logging.projects.metrics.list", "GET", "v2/{+parent}/metrics", "R", "", "metrics", "", "pageSize,pageToken", "parent=projects/*"},
{"logging.projects.metrics.get", "GET", "v2/{+metricName}", "R", "", "", "", "", "metricName=projects/*/metrics/*"},
{"logging.projects.metrics.create", "POST", "v2/{+parent}/metrics", "W", "", "", "name,bucketOptions,bucketName,disabled,labelExtractors,description,metricDescriptor,filter,valueExtractor,version", "", "parent=projects/*"},
{"logging.projects.metrics.update", "PUT", "v2/{+metricName}", "W", "", "", "name,bucketOptions,bucketName,disabled,labelExtractors,description,metricDescriptor,filter,valueExtractor,version", "", "metricName=projects/*/metrics/*"},
{"logging.projects.metrics.delete", "DELETE", "v2/{+metricName}", "D", "", "", "", "", "metricName=projects/*/metrics/*"},
{"logging.projects.exclusions.list", "GET", "v2/{+parent}/exclusions", "R", "", "exclusions", "", "pageSize,pageToken", "parent=projects/*"},
{"logging.projects.exclusions.get", "GET", "v2/{+name}", "R", "", "", "", "", "name=projects/*/exclusions/*"},
{"logging.projects.locations.buckets.list", "GET", "v2/{+parent}/buckets", "R", "", "buckets", "", "pageSize,pageToken", "parent=projects/*/locations/*"},
{"logging.projects.locations.buckets.get", "GET", "v2/{+name}", "R", "", "", "", "", "name=projects/*/locations/*/buckets/*"},
{"logging.projects.getSettings", "GET", "v2/{+name}/settings", "R", "", "", "", "", "name=projects/*"},
{"logging.projects.locations.operations.get", "GET", "v2/{+name}", "R", "lro", "", "", "", "name=projects/*/locations/*/operations/*"},
{"monitoring.projects.timeSeries.list", "GET", "v3/{+name}/timeSeries", "R", "", "timeSeries", "", "pageToken,secondaryAggregation.alignmentPeriod,view,secondaryAggregation.crossSeriesReducer,secondaryAggregation.perSeriesAligner,pageSize,aggregation.groupByFields,aggregation.perSeriesAligner,aggregation.alignmentPeriod,interval.endTime,filter,aggregation.crossSeriesReducer,orderBy,interval.startTime,secondaryAggregation.groupByFields", "name=projects/*"},
{"monitoring.projects.timeSeries.create", "POST", "v3/{+name}/timeSeries", "W", "", "", "timeSeries", "", "name=projects/*"},
{"monitoring.projects.metricDescriptors.list", "GET", "v3/{+name}/metricDescriptors", "R", "", "metricDescriptors", "", "pageSize,activeOnly,pageToken,filter", "name=projects/*"},
{"monitoring.projects.metricDescriptors.get", "GET", "v3/{+name}", "R", "", "", "", "", "name="},
{"monitoring.projects.monitoredResourceDescriptors.list", "GET", "v3/{+name}/monitoredResourceDescriptors", "R", "", "resourceDescriptors", "", "filter,pageSize,pageToken", "name=projects/*"},
{"monitoring.projects.monitoredResourceDescriptors.get", "GET", "v3/{+name}", "R", "", "", "", "", "name="},
{"monitoring.projects.alertPolicies.list", "GET", "v3/{+name}/alertPolicies", "R", "", "alertPolicies", "", "pageToken,filter,pageSize,orderBy", "name=projects/*"},
{"monitoring.projects.alertPolicies.get", "GET", "v3/{+name}", "R", "", "", "", "", "name=projects/*/alertPolicies/*"},
{"monitoring.projects.alertPolicies.create", "POST", "v3/{+name}/alertPolicies", "W", "", "", "validity,conditions,displayName,creationRecord,mutationRecord,severity,combiner,alertStrategy,enabled,name,userLabels,notificationChannels,documentation", "", "name=projects/*"},
{"monitoring.projects.alertPolicies.patch", "PATCH", "v3/{+name}", "W", "", "", "validity,conditions,displayName,creationRecord,mutationRecord,severity,combiner,alertStrategy,enabled,name,userLabels,notificationChannels,documentation", "updateMask", "name=projects/*/alertPolicies/*"},
{"monitoring.projects.alertPolicies.delete", "DELETE", "v3/{+name}", "D", "", "", "", "", "name=projects/*/alertPolicies/*"},
{"monitoring.projects.notificationChannels.list", "GET", "v3/{+name}/notificationChannels", "R", "", "notificationChannels", "", "pageToken,orderBy,filter,pageSize", "name=projects/*"},
{"monitoring.projects.notificationChannels.get", "GET", "v3/{+name}", "R", "", "", "", "", "name=projects/*/notificationChannels/*"},
{"monitoring.projects.notificationChannelDescriptors.list", "GET", "v3/{+name}/notificationChannelDescriptors", "R", "", "channelDescriptors", "", "pageSize,pageToken", "name=projects/*"},
{"monitoring.projects.notificationChannelDescriptors.get", "GET", "v3/{+name}", "R", "", "", "", "", "name=projects/*/notificationChannelDescriptors/*"},
{"monitoring.projects.groups.list", "GET", "v3/{+name}/groups", "R", "", "group", "", "ancestorsOfGroup,descendantsOfGroup,childrenOfGroup,pageToken,pageSize", "name=projects/*"},
{"monitoring.projects.groups.get", "GET", "v3/{+name}", "R", "", "", "", "", "name=projects/*/groups/*"},
{"monitoring.projects.uptimeCheckConfigs.list", "GET", "v3/{+parent}/uptimeCheckConfigs", "R", "", "uptimeCheckConfigs", "", "pageToken,pageSize,filter", "parent=projects/*"},
{"monitoring.projects.uptimeCheckConfigs.get", "GET", "v3/{+name}", "R", "", "", "", "", "name=projects/*/uptimeCheckConfigs/*"},
{"monitoring.projects.snoozes.list", "GET", "v3/{+parent}/snoozes", "R", "", "snoozes", "", "pageSize,filter,pageToken", "parent=projects/*"},
{"monitoring.projects.snoozes.get", "GET", "v3/{+name}", "R", "", "", "", "", "name=projects/*/snoozes/*"},
{"monitoring.projects.alerts.list", "GET", "v3/{+parent}/alerts", "R", "", "alerts", "", "filter,pageToken,pageSize,orderBy", "parent=projects/*"},
{"monitoring.projects.alerts.get", "GET", "v3/{+name}", "R", "", "", "", "", "name=projects/*/alerts/*"},
{"monitoring.services.list", "GET", "v3/{+parent}/services", "R", "", "services", "", "filter,pageSize,pageToken", "parent=*/*"},
{"monitoring.services.get", "GET", "v3/{+name}", "R", "", "", "", "", "name=*/*/services/*"},
{"monitoring.services.serviceLevelObjectives.list", "GET", "v3/{+parent}/serviceLevelObjectives", "R", "", "serviceLevelObjectives", "", "pageSize,pageToken,view,filter", "parent=*/*/services/*"},
{"monitoring.services.serviceLevelObjectives.get", "GET", "v3/{+name}", "R", "", "", "", "view", "name=*/*/services/*/serviceLevelObjectives/*"},
{"cloudscheduler.projects.locations.list", "GET", "v1/{+name}/locations", "R", "", "locations", "", "pageSize,pageToken,filter,extraLocationTypes", "name=projects/*"},
{"cloudscheduler.projects.locations.get", "GET", "v1/{+name}", "R", "", "", "", "", "name=projects/*/locations/*"},
{"cloudscheduler.projects.locations.jobs.list", "GET", "v1/{+parent}/jobs", "R", "", "jobs", "", "pageToken,pageSize", "parent=projects/*/locations/*"},
{"cloudscheduler.projects.locations.jobs.get", "GET", "v1/{+name}", "R", "", "", "", "", "name=projects/*/locations/*/jobs/*"},
{"cloudscheduler.projects.locations.jobs.create", "POST", "v1/{+parent}/jobs", "W", "", "", "httpTarget,description,timeZone,pubsubTarget,schedule,retryConfig,name,appEngineHttpTarget,attemptDeadline", "", "parent=projects/*/locations/*"},
{"cloudscheduler.projects.locations.jobs.patch", "PATCH", "v1/{+name}", "W", "", "", "httpTarget,description,timeZone,pubsubTarget,schedule,retryConfig,name,appEngineHttpTarget,attemptDeadline", "updateMask", "name=projects/*/locations/*/jobs/*"},
{"cloudscheduler.projects.locations.jobs.delete", "DELETE", "v1/{+name}", "D", "", "", "", "", "name=projects/*/locations/*/jobs/*"},
{"cloudscheduler.projects.locations.jobs.run", "POST", "v1/{+name}:run", "W", "", "", "", "", "name=projects/*/locations/*/jobs/*"},
{"cloudscheduler.projects.locations.jobs.pause", "POST", "v1/{+name}:pause", "W", "", "", "", "", "name=projects/*/locations/*/jobs/*"},
{"cloudscheduler.projects.locations.jobs.resume", "POST", "v1/{+name}:resume", "W", "", "", "", "", "name=projects/*/locations/*/jobs/*"},
{"cloudscheduler.projects.locations.operations.get", "GET", "v1/{+name}", "R", "lro", "", "", "", "name=projects/*/locations/*/operations/*"},
{"cloudtasks.projects.locations.list", "GET", "v2/{+name}/locations", "R", "", "locations", "", "filter,extraLocationTypes,pageSize,pageToken", "name=projects/*"},
{"cloudtasks.projects.locations.get", "GET", "v2/{+name}", "R", "", "", "", "", "name=projects/*/locations/*"},
{"cloudtasks.projects.locations.queues.list", "GET", "v2/{+parent}/queues", "R", "", "queues", "", "pageToken,pageSize,filter", "parent=projects/*/locations/*"},
{"cloudtasks.projects.locations.queues.get", "GET", "v2/{+name}", "R", "", "", "", "", "name=projects/*/locations/*/queues/*"},
{"cloudtasks.projects.locations.queues.create", "POST", "v2/{+parent}/queues", "W", "", "", "appEngineRoutingOverride,name,stackdriverLoggingConfig,state,httpTarget,rateLimits,purgeTime,retryConfig", "", "parent=projects/*/locations/*"},
{"cloudtasks.projects.locations.queues.patch", "PATCH", "v2/{+name}", "W", "", "", "appEngineRoutingOverride,name,stackdriverLoggingConfig,state,httpTarget,rateLimits,purgeTime,retryConfig", "updateMask", "name=projects/*/locations/*/queues/*"},
{"cloudtasks.projects.locations.queues.delete", "DELETE", "v2/{+name}", "D", "", "", "", "", "name=projects/*/locations/*/queues/*"},
{"cloudtasks.projects.locations.queues.pause", "POST", "v2/{+name}:pause", "W", "", "", "", "", "name=projects/*/locations/*/queues/*"},
{"cloudtasks.projects.locations.queues.resume", "POST", "v2/{+name}:resume", "W", "", "", "", "", "name=projects/*/locations/*/queues/*"},
{"cloudtasks.projects.locations.queues.purge", "POST", "v2/{+name}:purge", "D", "", "", "", "", "name=projects/*/locations/*/queues/*"},
{"cloudtasks.projects.locations.queues.getIamPolicy", "POST", "v2/{+resource}:getIamPolicy", "R", "", "", "options", "", "resource=projects/*/locations/*/queues/*"},
{"cloudtasks.projects.locations.queues.setIamPolicy", "POST", "v2/{+resource}:setIamPolicy", "W", "", "", "policy", "", "resource=projects/*/locations/*/queues/*"},
{"cloudtasks.projects.locations.queues.testIamPermissions", "POST", "v2/{+resource}:testIamPermissions", "R", "", "", "permissions", "", "resource=projects/*/locations/*/queues/*"},
{"cloudtasks.projects.locations.queues.tasks.list", "GET", "v2/{+parent}/tasks", "R", "", "tasks", "", "responseView,pageToken,pageSize", "parent=projects/*/locations/*/queues/*"},
{"cloudtasks.projects.locations.queues.tasks.get", "GET", "v2/{+name}", "R", "", "", "", "responseView", "name=projects/*/locations/*/queues/*/tasks/*"},
{"cloudtasks.projects.locations.queues.tasks.create", "POST", "v2/{+parent}/tasks", "W", "", "", "responseView,task,parent", "", "parent=projects/*/locations/*/queues/*"},
{"cloudtasks.projects.locations.queues.tasks.delete", "DELETE", "v2/{+name}", "D", "", "", "", "", "name=projects/*/locations/*/queues/*/tasks/*"},
{"cloudtasks.projects.locations.queues.tasks.run", "POST", "v2/{+name}:run", "W", "", "", "responseView", "", "name=projects/*/locations/*/queues/*/tasks/*"},
{"cloudtasks.projects.locations.operations.get", "GET", "v2/{+name}", "R", "lro", "", "", "", "name=projects/*/locations/*/operations/*"},
{"workflows.projects.locations.list", "GET", "v1/{+name}/locations", "R", "", "locations", "", "extraLocationTypes,pageSize,filter,pageToken", "name=projects/*"},
{"workflows.projects.locations.get", "GET", "v1/{+name}", "R", "", "", "", "", "name=projects/*/locations/*"},
{"workflows.projects.locations.workflows.list", "GET", "v1/{+parent}/workflows", "R", "", "workflows", "", "pageToken,pageSize,orderBy,filter", "parent=projects/*/locations/*"},
{"workflows.projects.locations.workflows.get", "GET", "v1/{+name}", "R", "", "", "", "revisionId", "name=projects/*/locations/*/workflows/*"},
{"workflows.projects.locations.workflows.create", "POST", "v1/{+parent}/workflows", "W", "lro", "", "description,sourceContents,tags,userEnvVars,serviceAccount,callLogLevel,labels,cryptoKeyName,executionHistoryLevel,name", "workflowId", "parent=projects/*/locations/*"},
{"workflows.projects.locations.workflows.patch", "PATCH", "v1/{+name}", "W", "lro", "", "description,sourceContents,tags,userEnvVars,serviceAccount,callLogLevel,labels,cryptoKeyName,executionHistoryLevel,name", "updateMask", "name=projects/*/locations/*/workflows/*"},
{"workflows.projects.locations.workflows.delete", "DELETE", "v1/{+name}", "D", "lro", "", "", "", "name=projects/*/locations/*/workflows/*"},
{"workflows.projects.locations.workflows.listRevisions", "GET", "v1/{+name}:listRevisions", "R", "", "workflows", "", "pageSize,pageToken", "name=projects/*/locations/*/workflows/*"},
{"workflows.projects.locations.operations.get", "GET", "v1/{+name}", "R", "lro", "", "", "", "name=projects/*/locations/*/operations/*"},
{"workflows.projects.locations.operations.list", "GET", "v1/{+name}/operations", "R", "", "operations", "", "pageToken,returnPartialSuccess,pageSize,filter", "name=projects/*/locations/*"},
{"workflowexecutions.projects.locations.workflows.executions.list", "GET", "v1/{+parent}/executions", "R", "", "executions", "", "view,filter,orderBy,pageToken,pageSize", "parent=projects/*/locations/*/workflows/*"},
{"workflowexecutions.projects.locations.workflows.executions.get", "GET", "v1/{+name}", "R", "", "", "", "view", "name=projects/*/locations/*/workflows/*/executions/*"},
{"workflowexecutions.projects.locations.workflows.executions.create", "POST", "v1/{+parent}/executions", "W", "", "", "callLogLevel,disableConcurrencyQuotaOverflowBuffering,argument,labels,executionHistoryLevel", "", "parent=projects/*/locations/*/workflows/*"},
{"workflowexecutions.projects.locations.workflows.executions.cancel", "POST", "v1/{+name}:cancel", "W", "", "", "", "", "name=projects/*/locations/*/workflows/*/executions/*"},
{"workflowexecutions.projects.locations.workflows.executions.stepEntries.list", "GET", "v1/{+parent}/stepEntries", "R", "", "stepEntries", "", "orderBy,pageToken,skip,view,pageSize,filter", "parent=projects/*/locations/*/workflows/*/executions/*"},
{"workflowexecutions.projects.locations.workflows.executions.stepEntries.get", "GET", "v1/{+name}", "R", "", "", "", "view", "name=projects/*/locations/*/workflows/*/executions/*/stepEntries/*"},
{"eventarc.projects.locations.list", "GET", "v1/{+name}/locations", "R", "", "locations", "", "extraLocationTypes,pageToken,filter,pageSize", "name=projects/*"},
{"eventarc.projects.locations.get", "GET", "v1/{+name}", "R", "", "", "", "", "name=projects/*/locations/*"},
{"eventarc.projects.locations.triggers.list", "GET", "v1/{+parent}/triggers", "R", "", "triggers", "", "pageToken,pageSize,filter,orderBy", "parent=projects/*/locations/*"},
{"eventarc.projects.locations.triggers.get", "GET", "v1/{+name}", "R", "", "", "", "", "name=projects/*/locations/*/triggers/*"},
{"eventarc.projects.locations.triggers.create", "POST", "v1/{+parent}/triggers", "W", "lro", "", "serviceAccount,transport,destination,channel,eventFilters,name,eventDataContentType,labels,retryPolicy", "triggerId,validateOnly", "parent=projects/*/locations/*"},
{"eventarc.projects.locations.triggers.patch", "PATCH", "v1/{+name}", "W", "lro", "", "serviceAccount,transport,destination,channel,eventFilters,name,eventDataContentType,labels,retryPolicy", "allowMissing,updateMask,validateOnly", "name=projects/*/locations/*/triggers/*"},
{"eventarc.projects.locations.triggers.delete", "DELETE", "v1/{+name}", "D", "lro", "", "", "allowMissing,validateOnly,etag", "name=projects/*/locations/*/triggers/*"},
{"eventarc.projects.locations.triggers.getIamPolicy", "GET", "v1/{+resource}:getIamPolicy", "R", "", "", "", "options.requestedPolicyVersion", "resource=projects/*/locations/*/triggers/*"},
{"eventarc.projects.locations.triggers.setIamPolicy", "POST", "v1/{+resource}:setIamPolicy", "W", "", "", "policy,updateMask", "", "resource=projects/*/locations/*/triggers/*"},
{"eventarc.projects.locations.triggers.testIamPermissions", "POST", "v1/{+resource}:testIamPermissions", "R", "", "", "permissions", "", "resource=projects/*/locations/*/triggers/*"},
{"eventarc.projects.locations.channels.list", "GET", "v1/{+parent}/channels", "R", "", "channels", "", "orderBy,pageToken,pageSize", "parent=projects/*/locations/*"},
{"eventarc.projects.locations.channels.get", "GET", "v1/{+name}", "R", "", "", "", "", "name=projects/*/locations/*/channels/*"},
{"eventarc.projects.locations.channels.create", "POST", "v1/{+parent}/channels", "W", "lro", "", "cryptoKeyName,labels,provider,name", "validateOnly,channelId", "parent=projects/*/locations/*"},
{"eventarc.projects.locations.channels.patch", "PATCH", "v1/{+name}", "W", "lro", "", "cryptoKeyName,labels,provider,name", "validateOnly,updateMask", "name=projects/*/locations/*/channels/*"},
{"eventarc.projects.locations.channels.delete", "DELETE", "v1/{+name}", "D", "lro", "", "", "validateOnly", "name=projects/*/locations/*/channels/*"},
{"eventarc.projects.locations.providers.list", "GET", "v1/{+parent}/providers", "R", "", "providers", "", "pageSize,orderBy,filter,pageToken", "parent=projects/*/locations/*"},
{"eventarc.projects.locations.providers.get", "GET", "v1/{+name}", "R", "", "", "", "", "name=projects/*/locations/*/providers/*"},
{"eventarc.projects.locations.pipelines.list", "GET", "v1/{+parent}/pipelines", "R", "", "pipelines", "", "orderBy,filter,pageSize,pageToken", "parent=projects/*/locations/*"},
{"eventarc.projects.locations.pipelines.get", "GET", "v1/{+name}", "R", "", "", "", "", "name=projects/*/locations/*/pipelines/*"},
{"eventarc.projects.locations.messageBuses.list", "GET", "v1/{+parent}/messageBuses", "R", "", "messageBuses", "", "filter,pageSize,orderBy,pageToken", "parent=projects/*/locations/*"},
{"eventarc.projects.locations.messageBuses.get", "GET", "v1/{+name}", "R", "", "", "", "", "name=projects/*/locations/*/messageBuses/*"},
{"eventarc.projects.locations.enrollments.list", "GET", "v1/{+parent}/enrollments", "R", "", "enrollments", "", "filter,pageToken,pageSize,orderBy", "parent=projects/*/locations/*"},
{"eventarc.projects.locations.enrollments.get", "GET", "v1/{+name}", "R", "", "", "", "", "name=projects/*/locations/*/enrollments/*"},
{"eventarc.projects.locations.operations.get", "GET", "v1/{+name}", "R", "lro", "", "", "", "name=projects/*/locations/*/operations/*"},
{"eventarc.projects.locations.operations.list", "GET", "v1/{+name}/operations", "R", "", "operations", "", "filter,pageToken,returnPartialSuccess,pageSize", "name=projects/*/locations/*"},
{"cloudbilling.billingAccounts.list", "GET", "v1/billingAccounts", "R", "", "billingAccounts", "", "pageToken,pageSize,filter,parent", ""},
{"cloudbilling.billingAccounts.get", "GET", "v1/{+name}", "R", "", "", "", "", "name=billingAccounts/*"},
{"cloudbilling.billingAccounts.getIamPolicy", "GET", "v1/{+resource}:getIamPolicy", "R", "", "", "", "options.requestedPolicyVersion", "resource=billingAccounts/*"},
{"cloudbilling.billingAccounts.testIamPermissions", "POST", "v1/{+resource}:testIamPermissions", "R", "", "", "permissions", "", "resource=billingAccounts/*"},
{"cloudbilling.billingAccounts.projects.list", "GET", "v1/{+name}/projects", "R", "", "projectBillingInfo", "", "pageToken,pageSize", "name=billingAccounts/*"},
{"cloudbilling.projects.getBillingInfo", "GET", "v1/{+name}/billingInfo", "R", "", "", "", "", "name=projects/*"},
{"cloudbilling.projects.updateBillingInfo", "PUT", "v1/{+name}/billingInfo", "W", "", "", "billingAccountName", "", "name=projects/*"},
{"cloudbilling.services.list", "GET", "v1/services", "R", "", "services", "", "pageSize,pageToken", ""},
{"cloudbilling.services.skus.list", "GET", "v1/{+parent}/skus", "R", "", "skus", "", "currencyCode,pageToken,pageSize,startTime,endTime", "parent=services/*"},
{"cloudasset.assets.list", "GET", "v1/{+parent}/assets", "R", "", "assets", "", "relationshipTypes,contentType,readTime,pageSize,assetTypes,pageToken", "parent=*/*"},
{"cloudasset.searchAllResources", "GET", "v1/{+scope}:searchAllResources", "R", "", "results", "", "query,assetTypes,pageSize,pageToken,orderBy,readMask", "scope=*/*"},
{"cloudasset.searchAllIamPolicies", "GET", "v1/{+scope}:searchAllIamPolicies", "R", "", "results", "", "orderBy,pageSize,pageToken,query,assetTypes", "scope=*/*"},
{"cloudasset.batchGetAssetsHistory", "GET", "v1/{+parent}:batchGetAssetsHistory", "R", "", "assets", "", "readTimeWindow.endTime,readTimeWindow.startTime,assetNames,contentType,relationshipTypes", "parent=*/*"},
{"cloudasset.analyzeIamPolicy", "GET", "v1/{+scope}:analyzeIamPolicy", "R", "", "", "", "analysisQuery.conditionContext.accessTime,executionTimeout,analysisQuery.options.analyzeServiceAccountImpersonation,analysisQuery.options.expandResources,analysisQuery.options.expandRoles,analysisQuery.resourceSelector.fullResourceName,analysisQuery.options.expandGroups,analysisQuery.options.outputGroupEdges,analysisQuery.accessSelector.permissions,analysisQuery.identitySelector.identity,savedAnalysisQuery,analysisQuery.accessSelector.roles,analysisQuery.options.outputResourceEdges", "scope=*/*"},
{"cloudasset.analyzeMove", "GET", "v1/{+resource}:analyzeMove", "R", "", "", "", "view,destinationParent", "resource=*/*"},
{"cloudasset.exportAssets", "POST", "v1/{+parent}:exportAssets", "W", "lro", "", "readTime,outputConfig,contentType,relationshipTypes,assetTypes", "", "parent=*/*"},
{"cloudasset.queryAssets", "POST", "v1/{+parent}:queryAssets", "R", "", "", "statement,timeout,pageSize,readTime,readTimeWindow,jobReference,pageToken,outputConfig", "", "parent=*/*"},
{"cloudasset.analyzeOrgPolicies", "GET", "v1/{+scope}:analyzeOrgPolicies", "R", "", "orgPolicyResults", "", "pageToken,filter,constraint,pageSize", "scope=*/*"},
{"cloudasset.feeds.list", "GET", "v1/{+parent}/feeds", "R", "", "feeds", "", "", "parent=*/*"},
{"cloudasset.feeds.get", "GET", "v1/{+name}", "R", "", "", "", "", "name=*/*/feeds/*"},
{"cloudasset.savedQueries.list", "GET", "v1/{+parent}/savedQueries", "R", "", "savedQueries", "", "pageSize,pageToken,filter", "parent=*/*"},
{"cloudasset.savedQueries.get", "GET", "v1/{+name}", "R", "", "", "", "", "name=*/*/savedQueries/*"},
{"cloudasset.operations.get", "GET", "v1/{+name}", "R", "lro", "", "", "", "name="},
{"cloudasset.effectiveIamPolicies.batchGet", "GET", "v1/{+scope}/effectiveIamPolicies:batchGet", "R", "", "", "", "names", "scope=*/*"},
{"orgpolicy.projects.constraints.list", "GET", "v2/{+parent}/constraints", "R", "", "constraints", "", "pageToken,pageSize", "parent=projects/*"},
{"orgpolicy.folders.constraints.list", "GET", "v2/{+parent}/constraints", "R", "", "constraints", "", "pageToken,pageSize", "parent=folders/*"},
{"orgpolicy.organizations.constraints.list", "GET", "v2/{+parent}/constraints", "R", "", "constraints", "", "pageToken,pageSize", "parent=organizations/*"},
{"orgpolicy.projects.policies.list", "GET", "v2/{+parent}/policies", "R", "", "policies", "", "pageSize,pageToken", "parent=projects/*"},
{"orgpolicy.projects.policies.get", "GET", "v2/{+name}", "R", "", "", "", "", "name=projects/*/policies/*"},
{"orgpolicy.projects.policies.create", "POST", "v2/{+parent}/policies", "W", "", "", "alternate,spec,name,etag,dryRunSpec", "", "parent=projects/*"},
{"orgpolicy.projects.policies.patch", "PATCH", "v2/{+name}", "W", "", "", "alternate,spec,name,etag,dryRunSpec", "updateMask", "name=projects/*/policies/*"},
{"orgpolicy.projects.policies.delete", "DELETE", "v2/{+name}", "D", "", "", "", "etag", "name=projects/*/policies/*"},
{"orgpolicy.projects.policies.getEffectivePolicy", "GET", "v2/{+name}:getEffectivePolicy", "R", "", "", "", "", "name=projects/*/policies/*"},
{"orgpolicy.folders.policies.list", "GET", "v2/{+parent}/policies", "R", "", "policies", "", "pageSize,pageToken", "parent=folders/*"},
{"orgpolicy.folders.policies.get", "GET", "v2/{+name}", "R", "", "", "", "", "name=folders/*/policies/*"},
{"orgpolicy.folders.policies.create", "POST", "v2/{+parent}/policies", "W", "", "", "alternate,spec,name,etag,dryRunSpec", "", "parent=folders/*"},
{"orgpolicy.folders.policies.patch", "PATCH", "v2/{+name}", "W", "", "", "alternate,spec,name,etag,dryRunSpec", "updateMask", "name=folders/*/policies/*"},
{"orgpolicy.folders.policies.delete", "DELETE", "v2/{+name}", "D", "", "", "", "etag", "name=folders/*/policies/*"},
{"orgpolicy.folders.policies.getEffectivePolicy", "GET", "v2/{+name}:getEffectivePolicy", "R", "", "", "", "", "name=folders/*/policies/*"},
{"orgpolicy.organizations.policies.list", "GET", "v2/{+parent}/policies", "R", "", "policies", "", "pageToken,pageSize", "parent=organizations/*"},
{"orgpolicy.organizations.policies.get", "GET", "v2/{+name}", "R", "", "", "", "", "name=organizations/*/policies/*"},
{"orgpolicy.organizations.policies.create", "POST", "v2/{+parent}/policies", "W", "", "", "alternate,spec,name,etag,dryRunSpec", "", "parent=organizations/*"},
{"orgpolicy.organizations.policies.patch", "PATCH", "v2/{+name}", "W", "", "", "alternate,spec,name,etag,dryRunSpec", "updateMask", "name=organizations/*/policies/*"},
{"orgpolicy.organizations.policies.delete", "DELETE", "v2/{+name}", "D", "", "", "", "etag", "name=organizations/*/policies/*"},
{"orgpolicy.organizations.policies.getEffectivePolicy", "GET", "v2/{+name}:getEffectivePolicy", "R", "", "", "", "", "name=organizations/*/policies/*"},
{"orgpolicy.organizations.customConstraints.list", "GET", "v2/{+parent}/customConstraints", "R", "", "customConstraints", "", "pageSize,pageToken", "parent=organizations/*"},
{"orgpolicy.organizations.customConstraints.get", "GET", "v2/{+name}", "R", "", "", "", "", "name=organizations/*/customConstraints/*"},
};
// CALLS-END
const Product* products() { return kProducts; }
std::size_t product_count() { return sizeof(kProducts) / sizeof(kProducts[0]); }
const CallSpec* call_table() { return kCalls; }
std::size_t call_count() { return sizeof(kCalls) / sizeof(kCalls[0]); }
} // namespace molo::google::ops
+67
View File
@@ -0,0 +1,67 @@
#pragma once
// The ONE table of REST calls the ops package makes (calls.cpp, generated from
// Google's Discovery documents by tools/gen_calls.py and re-checked by
// tools/check_discovery.py). Code builds every URL from this table, never from
// a literal. The rpc id is Discovery's method id (`run.projects.locations.services.get`).
#include <cstddef>
#include <string>
#include <string_view>
#include "clients/request.h"
#include "google/endpoints.h"
namespace molo::google::ops {
struct Product {
const char* name; // discovery name, also the rpc id prefix
const char* version; // v1, v2, v3
const char* root_url; // https://run.googleapis.com (no trailing slash)
const char* service_path; // "compute/v1" or "" when the path carries the version
const char* revision; // discovery revision the table was generated from
};
// Read never changes state. Write changes or creates state. Destructive
// deletes or irreversibly stops something: callers have no default.
enum class Safety { kRead, kWrite, kDestructive };
struct CallSpec {
const char* rpc;
const char* http; // GET POST PATCH PUT DELETE
const char* path; // discovery path, e.g. "v2/{+parent}/services"
const char* safety; // "R" "W" "D"
const char* kind; // "" | "lro" (google.longrunning) | "compute" (compute Operation)
const char* items_key; // list response array, "" when not a list call
const char* body_fields; // comma list: request body top level fields
const char* query_params; // comma list
const char* path_shapes; // "name=projects/*/locations/*" per path parameter, space separated
Safety safe() const;
clients::Method method() const;
std::string product() const; // rpc prefix
bool has_body_field(std::string_view f) const;
bool has_query(std::string_view q) const;
bool is_list() const { return items_key[0] != '\0'; }
bool is_lro() const { return std::string_view(kind) == "lro"; }
bool is_compute_operation() const { return std::string_view(kind) == "compute"; }
// Empty when the parameter has no declared shape.
std::string shape_of(std::string_view param) const;
};
const Product* products();
std::size_t product_count();
const CallSpec* call_table();
std::size_t call_count();
// Throws GoogleError::invalid for an unknown name.
const Product& product_named(const std::string& name);
const CallSpec& call_named(const std::string& rpc);
const CallSpec* find_call(const std::string& rpc);
// Where requests go: root_url + service_path. The table path is appended.
ServiceEndpoint endpoint_of(const Product& p);
// Where google.longrunning operation names are polled: root_url + "/" + version.
ServiceEndpoint operation_endpoint_of(const Product& p);
} // namespace molo::google::ops
+86
View File
@@ -0,0 +1,86 @@
#include "google/ops/calls.h"
#include "google/errors.h"
namespace molo::google::ops {
namespace {
bool in_list(std::string_view list, std::string_view item) {
if (item.empty()) return false;
std::size_t at = 0;
while (at <= list.size()) {
std::size_t end = list.find(',', at);
if (end == std::string_view::npos) end = list.size();
if (list.substr(at, end - at) == item) return true;
at = end + 1;
}
return false;
}
} // namespace
Safety CallSpec::safe() const {
return safety[0] == 'R' ? Safety::kRead
: safety[0] == 'D' ? Safety::kDestructive : Safety::kWrite;
}
clients::Method CallSpec::method() const {
std::string_view m = http;
if (m == "GET") return clients::Method::kGet;
if (m == "POST") return clients::Method::kPost;
if (m == "PATCH") return clients::Method::kPatch;
if (m == "PUT") return clients::Method::kPut;
return clients::Method::kDelete;
}
std::string CallSpec::product() const {
std::string_view r = rpc;
return std::string(r.substr(0, r.find('.')));
}
bool CallSpec::has_body_field(std::string_view f) const { return in_list(body_fields, f); }
bool CallSpec::has_query(std::string_view q) const { return in_list(query_params, q); }
std::string CallSpec::shape_of(std::string_view param) const {
std::string_view s = path_shapes;
std::size_t at = 0;
while (at < s.size()) {
std::size_t end = s.find(' ', at);
if (end == std::string_view::npos) end = s.size();
std::string_view item = s.substr(at, end - at);
std::size_t eq = item.find('=');
if (eq != std::string_view::npos && item.substr(0, eq) == param)
return std::string(item.substr(eq + 1));
at = end + 1;
}
return "";
}
const Product& product_named(const std::string& name) {
for (std::size_t i = 0; i < product_count(); ++i)
if (name == products()[i].name) return products()[i];
throw GoogleError::invalid("unknown ops product: " + name);
}
const CallSpec* find_call(const std::string& rpc) {
for (std::size_t i = 0; i < call_count(); ++i)
if (rpc == call_table()[i].rpc) return &call_table()[i];
return nullptr;
}
const CallSpec& call_named(const std::string& rpc) {
const CallSpec* c = find_call(rpc);
if (!c) throw GoogleError::invalid("unknown ops call: " + rpc);
return *c;
}
ServiceEndpoint endpoint_of(const Product& p) {
std::string base = p.root_url;
if (p.service_path[0] != '\0') base += std::string("/") + p.service_path;
return {p.name, base};
}
ServiceEndpoint operation_endpoint_of(const Product& p) {
return {p.name, std::string(p.root_url) + "/" + p.version};
}
} // namespace molo::google::ops
+25
View File
@@ -0,0 +1,25 @@
#pragma once
// Static ceilings for the ops package. Never autotuned.
#include <cstddef>
namespace molo::google::ops {
struct OpsCaps {
static constexpr std::size_t kMaxSegmentChars = 256; // one path segment
static constexpr std::size_t kMaxSegments = 12; // segments of a resource name
static constexpr std::size_t kMaxPathChars = 1024; // rendered path plus query
static constexpr std::size_t kMaxQueryValueChars = 1024;
static constexpr std::size_t kMaxQueryValues = 100; // values of one repeated parameter
static constexpr std::size_t kMaxBodyBytes = 1024 * 1024;
static constexpr std::size_t kMaxOperationNameChars = 512;
static constexpr int kDefaultPageSize = 100;
static constexpr int kMaxListPages = 20;
static constexpr std::size_t kMaxListItems = 5000;
static constexpr std::size_t kMaxBatchNames = 20; // serviceusage batchGet / batchEnable
static constexpr std::size_t kMaxLogEntries = 1000; // logging entries.list
static constexpr std::size_t kMaxSignPayloadBytes = 64 * 1024;
};
} // namespace molo::google::ops
+60
View File
@@ -0,0 +1,60 @@
#pragma once
// Cloud Asset v1. `scope` / `parent` is projects/{p}, folders/{f} or
// organizations/{o}. Searches are capped at OpsCaps::kMaxListItems rows.
#include <vector>
#include "google/ops/ops_product.h"
namespace molo::google::ops {
class CloudAsset : public OpsProduct {
public:
using Json = clients::body::Json;
explicit CloudAsset(std::shared_ptr<GoogleClient> c, Sleeper s = nullptr)
: OpsProduct(std::move(c), "cloudasset", std::move(s)) {}
Json search_resources(const std::string& scope, const std::string& query = "",
const std::vector<std::string>& asset_types = {}) const {
Args a = at("scope", scope);
if (!query.empty()) a.query("query", Json(query));
put_types(a, asset_types);
return list("cloudasset.searchAllResources", a, 5);
}
Json search_iam_policies(const std::string& scope, const std::string& query = "") const {
Args a = at("scope", scope);
if (!query.empty()) a.query("query", Json(query));
return list("cloudasset.searchAllIamPolicies", a, 5);
}
Json assets(const std::string& parent, const std::vector<std::string>& asset_types = {}) const {
Args a = at("parent", parent);
put_types(a, asset_types);
return list("cloudasset.assets.list", a, 5);
}
Json feeds(const std::string& parent) const {
return read("cloudasset.feeds.list", at("parent", parent));
}
Json saved_queries(const std::string& parent) const {
return list("cloudasset.savedQueries.list", at("parent", parent));
}
Json operation(const std::string& name) const {
return read("cloudasset.operations.get", at("name", name));
}
// body: ExportAssetsRequest incl. outputConfig (writes to Cloud Storage or
// BigQuery), so it is a write.
Outcome export_assets(const std::string& parent, const Json& body, bool confirm = false) const {
return call("cloudasset.exportAssets", at("parent", parent).body(body), confirm);
}
private:
static void put_types(Args& a, const std::vector<std::string>& types) {
if (types.empty()) return;
Json arr = Json::array();
for (const std::string& t : types) arr.push(Json(t));
a.query("assetTypes", arr);
}
};
} // namespace molo::google::ops
+59
View File
@@ -0,0 +1,59 @@
#pragma once
// Cloud Build v1 (regional rows: parent is projects/{p}/locations/{l}, use
// "global" for the default region).
#include "google/ops/ops_product.h"
namespace molo::google::ops {
class CloudBuild : public OpsProduct {
public:
using Json = clients::body::Json;
explicit CloudBuild(std::shared_ptr<GoogleClient> c, Sleeper s = nullptr)
: OpsProduct(std::move(c), "cloudbuild", std::move(s)) {}
Json builds(const std::string& parent) const {
return list("cloudbuild.projects.locations.builds.list", at("parent", parent));
}
Json build(const std::string& name) const {
return read("cloudbuild.projects.locations.builds.get", at("name", name));
}
Json triggers(const std::string& parent) const {
return list("cloudbuild.projects.locations.triggers.list", at("parent", parent));
}
Json trigger(const std::string& name) const {
return read("cloudbuild.projects.locations.triggers.get", at("name", name));
}
Json worker_pools(const std::string& parent) const {
return list("cloudbuild.projects.locations.workerPools.list", at("parent", parent));
}
Json default_service_account(const std::string& name) const {
return read("cloudbuild.projects.locations.getDefaultServiceAccount", at("name", name));
}
Json operation(const std::string& name) const {
return read("cloudbuild.projects.locations.operations.get", at("name", name));
}
Outcome create_build(const std::string& parent, const Json& build, bool confirm = false) const {
return call("cloudbuild.projects.locations.builds.create", at("parent", parent).body(build),
confirm);
}
Outcome cancel_build(const std::string& name, bool confirm = false) const {
return call("cloudbuild.projects.locations.builds.cancel", at("name", name), confirm);
}
Outcome retry_build(const std::string& name, bool confirm = false) const {
return call("cloudbuild.projects.locations.builds.retry", at("name", name), confirm);
}
Outcome run_trigger(const std::string& name, bool confirm = false) const {
return call("cloudbuild.projects.locations.triggers.run", at("name", name), confirm);
}
Outcome delete_trigger(const std::string& name, bool confirm) const {
return call("cloudbuild.projects.locations.triggers.delete", at("name", name), confirm);
}
Outcome delete_worker_pool(const std::string& name, bool confirm) const {
return call("cloudbuild.projects.locations.workerPools.delete", at("name", name), confirm);
}
};
} // namespace molo::google::ops
+50
View File
@@ -0,0 +1,50 @@
#pragma once
// Cloud Functions v2 (2nd gen). `parent` is projects/{p}/locations/{l}.
#include "google/ops/ops_product.h"
namespace molo::google::ops {
class CloudFunctions : public OpsProduct {
public:
using Json = clients::body::Json;
explicit CloudFunctions(std::shared_ptr<GoogleClient> c, Sleeper s = nullptr)
: OpsProduct(std::move(c), "cloudfunctions", std::move(s)) {}
Json locations(const std::string& project_name) const {
return list("cloudfunctions.projects.locations.list", at("name", project_name));
}
Json functions(const std::string& parent) const {
return list("cloudfunctions.projects.locations.functions.list", at("parent", parent));
}
Json function(const std::string& name) const {
return read("cloudfunctions.projects.locations.functions.get", at("name", name));
}
Json runtimes(const std::string& parent) const {
return list("cloudfunctions.projects.locations.runtimes.list", at("parent", parent));
}
Json operation(const std::string& name) const {
return read("cloudfunctions.projects.locations.operations.get", at("name", name));
}
Json iam_policy(const std::string& function_name) const {
return read("cloudfunctions.projects.locations.functions.getIamPolicy",
at("resource", function_name));
}
Outcome generate_upload_url(const std::string& parent, bool confirm = false) const {
return call("cloudfunctions.projects.locations.functions.generateUploadUrl",
at("parent", parent), confirm);
}
Outcome create_function(const std::string& parent, const std::string& function_id,
const Json& function, bool confirm = false) const {
Args a = at("parent", parent);
a.query("functionId", Json(function_id)).body(function);
return call("cloudfunctions.projects.locations.functions.create", a, confirm);
}
Outcome delete_function(const std::string& name, bool confirm) const {
return call("cloudfunctions.projects.locations.functions.delete", at("name", name), confirm);
}
};
} // namespace molo::google::ops
+84
View File
@@ -0,0 +1,84 @@
#pragma once
// Cloud Logging v2: read entries and log names, sinks, metrics, exclusions,
// buckets. write_entries and delete_log are explicit (dry run unless
// confirm). Entry reads are capped at OpsCaps::kMaxLogEntries.
#include <vector>
#include "google/errors.h"
#include "google/ops/ops_product.h"
namespace molo::google::ops {
class CloudLogging : public OpsProduct {
public:
using Json = clients::body::Json;
explicit CloudLogging(std::shared_ptr<GoogleClient> c, Sleeper s = nullptr)
: OpsProduct(std::move(c), "logging", std::move(s)) {}
// resource_names: projects/p, folders/f, organizations/o, ...
// filter: Logging query language; order_by "timestamp desc" or "timestamp asc".
// Returns at most `limit` entries (1..kMaxLogEntries) from one page.
Json entries(const std::vector<std::string>& resource_names, const std::string& filter,
const std::string& order_by = "timestamp desc", int limit = 50) const {
if (resource_names.empty() || resource_names.size() > 10)
throw GoogleError::invalid("resourceNames must hold 1..10 names");
if (limit < 1 || static_cast<std::size_t>(limit) > OpsCaps::kMaxLogEntries)
throw GoogleError::invalid("limit must be 1.." + std::to_string(OpsCaps::kMaxLogEntries));
if (filter.size() > 2048) throw GoogleError::invalid("filter too long");
if (order_by != "timestamp desc" && order_by != "timestamp asc")
throw GoogleError::invalid("orderBy must be 'timestamp desc' or 'timestamp asc'");
Json names = Json::array();
for (const std::string& n : resource_names) names.push(Json(n));
Args a;
a.field("resourceNames", names).field("orderBy", Json(order_by)).field("pageSize", Json(limit));
if (!filter.empty()) a.field("filter", Json(filter));
Json reply = ops_read("logging.entries.list", a);
return reply.find("entries") ? *reply.find("entries") : Json::array();
}
Json log_names(const std::string& parent) const {
return list("logging.projects.logs.list", at("parent", parent));
}
Json resource_descriptors() const { return list("logging.monitoredResourceDescriptors.list", Args()); }
Json sinks(const std::string& parent) const {
return list("logging.projects.sinks.list", at("parent", parent));
}
Json sink(const std::string& name) const {
return read("logging.projects.sinks.get", at("sinkName", name));
}
Json metrics(const std::string& parent) const {
return list("logging.projects.metrics.list", at("parent", parent));
}
Json metric(const std::string& name) const {
return read("logging.projects.metrics.get", at("metricName", name));
}
Json exclusions(const std::string& parent) const {
return list("logging.projects.exclusions.list", at("parent", parent));
}
Json buckets(const std::string& parent) const {
return list("logging.projects.locations.buckets.list", at("parent", parent));
}
Json settings(const std::string& name) const {
return read("logging.projects.getSettings", at("name", name));
}
// body: LogEntry list etc. as in the API (logName, resource, entries, ...).
Outcome write_entries(const Json& body, bool confirm = false) const {
return call("logging.entries.write", Args().body(body), confirm);
}
Outcome delete_log(const std::string& log_name, bool confirm) const {
return call("logging.projects.logs.delete", at("logName", log_name), confirm);
}
Outcome delete_sink(const std::string& sink_name, bool confirm) const {
return call("logging.projects.sinks.delete", at("sinkName", sink_name), confirm);
}
Outcome delete_metric(const std::string& metric_name, bool confirm) const {
return call("logging.projects.metrics.delete", at("metricName", metric_name), confirm);
}
private:
Json ops_read(const std::string& rpc, const Args& a) const { return read(rpc, a); }
};
} // namespace molo::google::ops
+71
View File
@@ -0,0 +1,71 @@
#pragma once
// Cloud Monitoring v3. `name` is projects/{p} unless said otherwise. Time
// series reads need a filter and an interval (RFC 3339 timestamps).
#include "google/errors.h"
#include "google/ops/ops_product.h"
namespace molo::google::ops {
class CloudMonitoring : public OpsProduct {
public:
using Json = clients::body::Json;
explicit CloudMonitoring(std::shared_ptr<GoogleClient> c, Sleeper s = nullptr)
: OpsProduct(std::move(c), "monitoring", std::move(s)) {}
// filter: e.g. metric.type = "compute.googleapis.com/instance/cpu/utilization".
Json time_series(const std::string& project_name, const std::string& filter,
const std::string& start_time, const std::string& end_time) const {
if (filter.empty() || filter.size() > 2048) throw GoogleError::invalid("bad filter");
Args a = at("name", project_name);
a.query("filter", Json(filter))
.query("interval.startTime", Json(start_time))
.query("interval.endTime", Json(end_time));
return list("monitoring.projects.timeSeries.list", a, 5);
}
Json metric_descriptors(const std::string& project_name, const std::string& filter = "") const {
Args a = at("name", project_name);
if (!filter.empty()) a.query("filter", Json(filter));
return list("monitoring.projects.metricDescriptors.list", a);
}
Json metric_descriptor(const std::string& name) const {
return read("monitoring.projects.metricDescriptors.get", at("name", name));
}
Json resource_descriptors(const std::string& project_name) const {
return list("monitoring.projects.monitoredResourceDescriptors.list", at("name", project_name));
}
Json alert_policies(const std::string& project_name) const {
return list("monitoring.projects.alertPolicies.list", at("name", project_name));
}
Json alert_policy(const std::string& name) const {
return read("monitoring.projects.alertPolicies.get", at("name", name));
}
Json notification_channels(const std::string& project_name) const {
return list("monitoring.projects.notificationChannels.list", at("name", project_name));
}
Json groups(const std::string& project_name) const {
return list("monitoring.projects.groups.list", at("name", project_name));
}
Json uptime_checks(const std::string& project_name) const {
return list("monitoring.projects.uptimeCheckConfigs.list", at("parent", project_name));
}
Json services(const std::string& project_name) const {
return list("monitoring.services.list", at("parent", project_name));
}
Json alerts(const std::string& project_name) const {
return list("monitoring.projects.alerts.list", at("parent", project_name));
}
Outcome write_time_series(const std::string& project_name, const Json& series,
bool confirm = false) const {
Args a = at("name", project_name);
a.field("timeSeries", series);
return call("monitoring.projects.timeSeries.create", a, confirm);
}
Outcome delete_alert_policy(const std::string& name, bool confirm) const {
return call("monitoring.projects.alertPolicies.delete", at("name", name), confirm);
}
};
} // namespace molo::google::ops
+68
View File
@@ -0,0 +1,68 @@
#pragma once
// Cloud Run Admin v2: services, revisions, jobs, executions, tasks.
// `parent` is projects/{p}/locations/{l} (see Names::location); service and
// job names are the full resource names.
#include "google/ops/ops_product.h"
namespace molo::google::ops {
class CloudRun : public OpsProduct {
public:
using Json = clients::body::Json;
explicit CloudRun(std::shared_ptr<GoogleClient> c, Sleeper s = nullptr)
: OpsProduct(std::move(c), "run", std::move(s)) {}
Json services(const std::string& parent) const {
return list("run.projects.locations.services.list", at("parent", parent));
}
Json service(const std::string& name) const {
return read("run.projects.locations.services.get", at("name", name));
}
Json revisions(const std::string& service_name) const {
return list("run.projects.locations.services.revisions.list", at("parent", service_name));
}
Json jobs(const std::string& parent) const {
return list("run.projects.locations.jobs.list", at("parent", parent));
}
Json job(const std::string& name) const {
return read("run.projects.locations.jobs.get", at("name", name));
}
Json executions(const std::string& job_name) const {
return list("run.projects.locations.jobs.executions.list", at("parent", job_name));
}
Json execution(const std::string& name) const {
return read("run.projects.locations.jobs.executions.get", at("name", name));
}
Json service_iam_policy(const std::string& service_name) const {
return read("run.projects.locations.services.getIamPolicy", at("resource", service_name));
}
Json operation(const std::string& name) const {
return read("run.projects.locations.operations.get", at("name", name));
}
Outcome run_job(const std::string& name, bool confirm = false) const {
return call("run.projects.locations.jobs.run", at("name", name), confirm);
}
Outcome cancel_execution(const std::string& name, bool confirm = false) const {
return call("run.projects.locations.jobs.executions.cancel", at("name", name), confirm);
}
Outcome create_service(const std::string& parent, const std::string& service_id,
const Json& service, bool confirm = false) const {
Args a = at("parent", parent);
a.query("serviceId", Json(service_id)).body(service);
return call("run.projects.locations.services.create", a, confirm);
}
Outcome delete_service(const std::string& name, bool confirm) const {
return call("run.projects.locations.services.delete", at("name", name), confirm);
}
Outcome delete_job(const std::string& name, bool confirm) const {
return call("run.projects.locations.jobs.delete", at("name", name), confirm);
}
Outcome delete_revision(const std::string& name, bool confirm) const {
return call("run.projects.locations.services.revisions.delete", at("name", name), confirm);
}
};
} // namespace molo::google::ops
+44
View File
@@ -0,0 +1,44 @@
#pragma once
// Cloud Scheduler v1. `parent` is projects/{p}/locations/{l}.
#include "google/ops/ops_product.h"
namespace molo::google::ops {
class CloudScheduler : public OpsProduct {
public:
using Json = clients::body::Json;
explicit CloudScheduler(std::shared_ptr<GoogleClient> c, Sleeper s = nullptr)
: OpsProduct(std::move(c), "cloudscheduler", std::move(s)) {}
Json locations(const std::string& project_name) const {
return list("cloudscheduler.projects.locations.list", at("name", project_name));
}
Json jobs(const std::string& parent) const {
return list("cloudscheduler.projects.locations.jobs.list", at("parent", parent));
}
Json job(const std::string& name) const {
return read("cloudscheduler.projects.locations.jobs.get", at("name", name));
}
Outcome create_job(const std::string& parent, const Json& job, bool confirm = false) const {
return call("cloudscheduler.projects.locations.jobs.create", at("parent", parent).body(job),
confirm);
}
Outcome pause_job(const std::string& name, bool confirm = false) const {
return call("cloudscheduler.projects.locations.jobs.pause", at("name", name), confirm);
}
Outcome resume_job(const std::string& name, bool confirm = false) const {
return call("cloudscheduler.projects.locations.jobs.resume", at("name", name), confirm);
}
// Fires the job now (runs its target).
Outcome run_job(const std::string& name, bool confirm = false) const {
return call("cloudscheduler.projects.locations.jobs.run", at("name", name), confirm);
}
Outcome delete_job(const std::string& name, bool confirm) const {
return call("cloudscheduler.projects.locations.jobs.delete", at("name", name), confirm);
}
};
} // namespace molo::google::ops
+59
View File
@@ -0,0 +1,59 @@
#pragma once
// Cloud Tasks v2. `parent` is projects/{p}/locations/{l}; tasks hang off a
// full queue name.
#include "google/ops/ops_product.h"
namespace molo::google::ops {
class CloudTasks : public OpsProduct {
public:
using Json = clients::body::Json;
explicit CloudTasks(std::shared_ptr<GoogleClient> c, Sleeper s = nullptr)
: OpsProduct(std::move(c), "cloudtasks", std::move(s)) {}
Json queues(const std::string& parent) const {
return list("cloudtasks.projects.locations.queues.list", at("parent", parent));
}
Json queue(const std::string& name) const {
return read("cloudtasks.projects.locations.queues.get", at("name", name));
}
Json tasks(const std::string& queue_name) const {
return list("cloudtasks.projects.locations.queues.tasks.list", at("parent", queue_name));
}
Json task(const std::string& name) const {
return read("cloudtasks.projects.locations.queues.tasks.get", at("name", name));
}
Outcome create_queue(const std::string& parent, const Json& queue, bool confirm = false) const {
return call("cloudtasks.projects.locations.queues.create", at("parent", parent).body(queue),
confirm);
}
Outcome pause_queue(const std::string& name, bool confirm = false) const {
return call("cloudtasks.projects.locations.queues.pause", at("name", name), confirm);
}
Outcome resume_queue(const std::string& name, bool confirm = false) const {
return call("cloudtasks.projects.locations.queues.resume", at("name", name), confirm);
}
Outcome create_task(const std::string& queue_name, const Json& task, bool confirm = false) const {
Args a = at("parent", queue_name);
a.field("task", task);
return call("cloudtasks.projects.locations.queues.tasks.create", a, confirm);
}
Outcome run_task(const std::string& name, bool confirm = false) const {
return call("cloudtasks.projects.locations.queues.tasks.run", at("name", name), confirm);
}
// Destructive: no default.
Outcome purge_queue(const std::string& name, bool confirm) const {
return call("cloudtasks.projects.locations.queues.purge", at("name", name), confirm);
}
Outcome delete_queue(const std::string& name, bool confirm) const {
return call("cloudtasks.projects.locations.queues.delete", at("name", name), confirm);
}
Outcome delete_task(const std::string& name, bool confirm) const {
return call("cloudtasks.projects.locations.queues.tasks.delete", at("name", name), confirm);
}
};
} // namespace molo::google::ops
+93
View File
@@ -0,0 +1,93 @@
#pragma once
// Compute Engine v1: read the fleet, and start / stop / reset / insert /
// delete instances. Compute operations are not google.longrunning: poll them
// with zone_operation / wait_zone_operation.
#include "google/ops/ops_product.h"
namespace molo::google::ops {
class Compute : public OpsProduct {
public:
explicit Compute(std::shared_ptr<GoogleClient> c, Sleeper s = nullptr)
: OpsProduct(std::move(c), "compute", std::move(s)) {}
using Json = clients::body::Json;
Json instances(const std::string& project, const std::string& zone) const {
return list("compute.instances.list", zonal(project, zone));
}
Json instance(const std::string& project, const std::string& zone,
const std::string& name) const {
return read("compute.instances.get", zonal(project, zone).path("instance", name));
}
Json zones(const std::string& project) const {
return list("compute.zones.list", at("project", project));
}
Json regions(const std::string& project) const {
return list("compute.regions.list", at("project", project));
}
Json machine_types(const std::string& project, const std::string& zone) const {
return list("compute.machineTypes.list", zonal(project, zone));
}
Json disks(const std::string& project, const std::string& zone) const {
return list("compute.disks.list", zonal(project, zone));
}
Json networks(const std::string& project) const {
return list("compute.networks.list", at("project", project));
}
Json subnetworks(const std::string& project, const std::string& region) const {
return list("compute.subnetworks.list", at("project", project).path("region", region));
}
Json firewalls(const std::string& project) const {
return list("compute.firewalls.list", at("project", project));
}
Json images(const std::string& project) const {
return list("compute.images.list", at("project", project));
}
Json project_info(const std::string& project) const {
return read("compute.projects.get", at("project", project));
}
Json zone_operation(const std::string& project, const std::string& zone,
const std::string& operation) const {
return read("compute.zoneOperations.get", zonal(project, zone).path("operation", operation));
}
// Server side wait (Google holds the request up to about two minutes).
Json wait_zone_operation(const std::string& project, const std::string& zone,
const std::string& operation) const {
return read("compute.zoneOperations.wait", zonal(project, zone).path("operation", operation));
}
// Writes: dry run unless confirm.
Outcome start_instance(const std::string& project, const std::string& zone,
const std::string& name, bool confirm = false) const {
return call("compute.instances.start", zonal(project, zone).path("instance", name), confirm);
}
Outcome stop_instance(const std::string& project, const std::string& zone,
const std::string& name, bool confirm = false) const {
return call("compute.instances.stop", zonal(project, zone).path("instance", name), confirm);
}
Outcome reset_instance(const std::string& project, const std::string& zone,
const std::string& name, bool confirm = false) const {
return call("compute.instances.reset", zonal(project, zone).path("instance", name), confirm);
}
Outcome insert_instance(const std::string& project, const std::string& zone,
const Json& body, bool confirm = false) const {
return call("compute.instances.insert", zonal(project, zone).body(body), confirm);
}
// Destructive: no default.
Outcome delete_instance(const std::string& project, const std::string& zone,
const std::string& name, bool confirm) const {
return call("compute.instances.delete", zonal(project, zone).path("instance", name), confirm);
}
private:
static Args zonal(const std::string& project, const std::string& zone) {
Args a;
a.path("project", project).path("zone", zone);
return a;
}
};
} // namespace molo::google::ops
+57
View File
@@ -0,0 +1,57 @@
#pragma once
// Eventarc v1. `parent` is projects/{p}/locations/{l}.
#include "google/ops/ops_product.h"
namespace molo::google::ops {
class Eventarc : public OpsProduct {
public:
using Json = clients::body::Json;
explicit Eventarc(std::shared_ptr<GoogleClient> c, Sleeper s = nullptr)
: OpsProduct(std::move(c), "eventarc", std::move(s)) {}
Json locations(const std::string& project_name) const {
return list("eventarc.projects.locations.list", at("name", project_name));
}
Json triggers(const std::string& parent) const {
return list("eventarc.projects.locations.triggers.list", at("parent", parent));
}
Json trigger(const std::string& name) const {
return read("eventarc.projects.locations.triggers.get", at("name", name));
}
Json channels(const std::string& parent) const {
return list("eventarc.projects.locations.channels.list", at("parent", parent));
}
Json providers(const std::string& parent) const {
return list("eventarc.projects.locations.providers.list", at("parent", parent));
}
Json pipelines(const std::string& parent) const {
return list("eventarc.projects.locations.pipelines.list", at("parent", parent));
}
Json message_buses(const std::string& parent) const {
return list("eventarc.projects.locations.messageBuses.list", at("parent", parent));
}
Json enrollments(const std::string& parent) const {
return list("eventarc.projects.locations.enrollments.list", at("parent", parent));
}
Json operation(const std::string& name) const {
return read("eventarc.projects.locations.operations.get", at("name", name));
}
Outcome create_trigger(const std::string& parent, const std::string& trigger_id,
const Json& trigger, bool confirm = false) const {
Args a = at("parent", parent);
a.query("triggerId", Json(trigger_id)).body(trigger);
return call("eventarc.projects.locations.triggers.create", a, confirm);
}
Outcome delete_trigger(const std::string& name, bool confirm) const {
return call("eventarc.projects.locations.triggers.delete", at("name", name), confirm);
}
Outcome delete_channel(const std::string& name, bool confirm) const {
return call("eventarc.projects.locations.channels.delete", at("name", name), confirm);
}
};
} // namespace molo::google::ops
+63
View File
@@ -0,0 +1,63 @@
#pragma once
// Google Kubernetes Engine (container v1). `parent` is
// projects/{p}/locations/{l}; l is a region or a zone. GKE operations are not
// google.longrunning: poll `operation(name)` until its status is DONE.
#include "google/ops/ops_product.h"
namespace molo::google::ops {
class Gke : public OpsProduct {
public:
using Json = clients::body::Json;
explicit Gke(std::shared_ptr<GoogleClient> c, Sleeper s = nullptr)
: OpsProduct(std::move(c), "container", std::move(s)) {}
Json clusters(const std::string& parent) const {
return read("container.projects.locations.clusters.list", at("parent", parent));
}
Json cluster(const std::string& name) const {
return read("container.projects.locations.clusters.get", at("name", name));
}
Json node_pools(const std::string& cluster_name) const {
return read("container.projects.locations.clusters.nodePools.list",
at("parent", cluster_name));
}
Json node_pool(const std::string& name) const {
return read("container.projects.locations.clusters.nodePools.get", at("name", name));
}
Json operations(const std::string& parent) const {
return read("container.projects.locations.operations.list", at("parent", parent));
}
Json operation(const std::string& name) const {
return read("container.projects.locations.operations.get", at("name", name));
}
Json server_config(const std::string& location_name) const {
return read("container.projects.locations.getServerConfig", at("name", location_name));
}
Json usable_subnetworks(const std::string& project_name) const {
return list("container.projects.aggregated.usableSubnetworks.list",
at("parent", project_name));
}
Outcome create_cluster(const std::string& parent, const Json& request,
bool confirm = false) const {
return call("container.projects.locations.clusters.create", at("parent", parent).body(request),
confirm);
}
Outcome set_node_pool_size(const std::string& name, int node_count, bool confirm = false) const {
Args a = at("name", name);
a.field("nodeCount", Json(node_count));
return call("container.projects.locations.clusters.nodePools.setSize", a, confirm);
}
Outcome delete_cluster(const std::string& name, bool confirm) const {
return call("container.projects.locations.clusters.delete", at("name", name), confirm);
}
Outcome delete_node_pool(const std::string& name, bool confirm) const {
return call("container.projects.locations.clusters.nodePools.delete", at("name", name),
confirm);
}
};
} // namespace molo::google::ops
+97
View File
@@ -0,0 +1,97 @@
#pragma once
// IAM v1: roles, permissions, service accounts and their keys, policies,
// testIamPermissions. Signing (signJwt, signBlob, access and id tokens) is the
// separate IAM Credentials API: see iam_credentials.h. Needs
// iam.googleapis.com enabled on the project.
#include <vector>
#include "google/ops/ops_product.h"
namespace molo::google::ops {
class Iam : public OpsProduct {
public:
using Json = clients::body::Json;
explicit Iam(std::shared_ptr<GoogleClient> c, Sleeper s = nullptr)
: OpsProduct(std::move(c), "iam", std::move(s)) {}
// Predefined roles (roles/...).
Json roles() const { return list("iam.roles.list", Args()); }
Json role(const std::string& name) const { return read("iam.roles.get", at("name", name)); }
Json project_roles(const std::string& project_name) const {
return list("iam.projects.roles.list", at("parent", project_name));
}
Json organization_roles(const std::string& organization_name) const {
return list("iam.organizations.roles.list", at("parent", organization_name));
}
// Roles that can be granted on a resource (full resource name).
Json grantable_roles(const std::string& full_resource_name) const {
Args a;
a.field("fullResourceName", Json(full_resource_name));
return list("iam.roles.queryGrantableRoles", a);
}
Json testable_permissions(const std::string& full_resource_name) const {
Args a;
a.field("fullResourceName", Json(full_resource_name));
return list("iam.permissions.queryTestablePermissions", a);
}
Json service_accounts(const std::string& project_name) const {
return list("iam.projects.serviceAccounts.list", at("name", project_name));
}
Json service_account(const std::string& name) const {
return read("iam.projects.serviceAccounts.get", at("name", name));
}
Json service_account_keys(const std::string& account_name) const {
return list("iam.projects.serviceAccounts.keys.list", at("name", account_name));
}
Json service_account_key(const std::string& key_name) const {
return read("iam.projects.serviceAccounts.keys.get", at("name", key_name));
}
Json service_account_policy(const std::string& account_name) const {
return read("iam.projects.serviceAccounts.getIamPolicy", at("resource", account_name));
}
// The subset of `permissions` the caller holds on the service account.
Json test_permissions(const std::string& account_name,
const std::vector<std::string>& permissions) const {
Json list_json = Json::array();
for (const std::string& p : permissions) list_json.push(Json(p));
Args a = at("resource", account_name);
a.field("permissions", list_json);
return read("iam.projects.serviceAccounts.testIamPermissions", a);
}
Outcome create_service_account(const std::string& project_name, const std::string& account_id,
const std::string& display_name, bool confirm = false) const {
Json sa = Json::object();
sa.set("displayName", Json(display_name));
Args a = at("name", project_name);
a.field("accountId", Json(account_id)).field("serviceAccount", sa);
return call("iam.projects.serviceAccounts.create", a, confirm);
}
Outcome create_key(const std::string& account_name, bool confirm = false) const {
return call("iam.projects.serviceAccounts.keys.create", at("name", account_name), confirm);
}
Outcome enable_service_account(const std::string& name, bool confirm = false) const {
return call("iam.projects.serviceAccounts.enable", at("name", name), confirm);
}
Outcome disable_service_account(const std::string& name, bool confirm = false) const {
return call("iam.projects.serviceAccounts.disable", at("name", name), confirm);
}
Outcome disable_key(const std::string& key_name, bool confirm = false) const {
return call("iam.projects.serviceAccounts.keys.disable", at("name", key_name), confirm);
}
Outcome delete_service_account(const std::string& name, bool confirm) const {
return call("iam.projects.serviceAccounts.delete", at("name", name), confirm);
}
Outcome delete_key(const std::string& key_name, bool confirm) const {
return call("iam.projects.serviceAccounts.keys.delete", at("name", key_name), confirm);
}
Outcome delete_role(const std::string& name, bool confirm) const {
return call("iam.projects.roles.delete", at("name", name), confirm);
}
};
} // namespace molo::google::ops
+56
View File
@@ -0,0 +1,56 @@
#pragma once
// IAM Service Account Credentials v1: signJwt, signBlob, access tokens and id
// tokens for a service account the caller may impersonate. Signing changes no
// state, so these run directly. Payload sizes are capped.
#include <vector>
#include "google/errors.h"
#include "google/ops/ops_product.h"
namespace molo::google::ops {
class IamCredentials : public OpsProduct {
public:
using Json = clients::body::Json;
explicit IamCredentials(std::shared_ptr<GoogleClient> c, Sleeper s = nullptr)
: OpsProduct(std::move(c), "iamcredentials", std::move(s)) {}
// payload: a JSON object serialized as a string (the claim set).
Json sign_jwt(const std::string& account_name, const std::string& payload) const {
check_payload(payload);
Args a = at("name", account_name);
a.field("payload", Json(payload));
return read("iamcredentials.projects.serviceAccounts.signJwt", a);
}
// base64_payload: the bytes to sign, base64 encoded.
Json sign_blob(const std::string& account_name, const std::string& base64_payload) const {
check_payload(base64_payload);
Args a = at("name", account_name);
a.field("payload", Json(base64_payload));
return read("iamcredentials.projects.serviceAccounts.signBlob", a);
}
Json generate_access_token(const std::string& account_name,
const std::vector<std::string>& scopes) const {
Json arr = Json::array();
for (const std::string& s : scopes) arr.push(Json(s));
Args a = at("name", account_name);
a.field("scope", arr);
return read("iamcredentials.projects.serviceAccounts.generateAccessToken", a);
}
Json generate_id_token(const std::string& account_name, const std::string& audience) const {
Args a = at("name", account_name);
a.field("audience", Json(audience));
return read("iamcredentials.projects.serviceAccounts.generateIdToken", a);
}
private:
static void check_payload(const std::string& p) {
if (p.empty() || p.size() > OpsCaps::kMaxSignPayloadBytes)
throw GoogleError::invalid("payload must be 1.." +
std::to_string(OpsCaps::kMaxSignPayloadBytes) + " bytes");
}
};
} // namespace molo::google::ops
+78
View File
@@ -0,0 +1,78 @@
#pragma once
// Ops: one object holding every product of the package over one GoogleClient.
// `product("run")` reaches a product by Discovery name for generic callers
// (the demo, the conformance tests).
#include <memory>
#include <vector>
#include "google/ops/artifact_registry.h"
#include "google/ops/billing.h"
#include "google/ops/cloud_asset.h"
#include "google/ops/cloud_build.h"
#include "google/ops/cloud_functions.h"
#include "google/ops/cloud_logging.h"
#include "google/ops/cloud_monitoring.h"
#include "google/ops/cloud_run.h"
#include "google/ops/cloud_scheduler.h"
#include "google/ops/cloud_tasks.h"
#include "google/ops/compute.h"
#include "google/ops/eventarc.h"
#include "google/ops/gke.h"
#include "google/ops/iam.h"
#include "google/ops/iam_credentials.h"
#include "google/ops/org_policy.h"
#include "google/ops/resource_manager.h"
#include "google/ops/service_usage.h"
#include "google/ops/workflows.h"
namespace molo::google::ops {
class Ops {
public:
explicit Ops(std::shared_ptr<GoogleClient> client, Sleeper sleeper = nullptr)
: compute(client, sleeper), run(client, sleeper), functions(client, sleeper),
gke(client, sleeper), build(client, sleeper), artifacts(client, sleeper),
iam(client, sleeper), credentials(client, sleeper), projects(client, sleeper),
services(client, sleeper), logging(client, sleeper), monitoring(client, sleeper),
scheduler(client, sleeper), tasks(client, sleeper), workflows(client, sleeper),
executions(client, sleeper), eventarc(client, sleeper), billing(client, sleeper),
assets(client, sleeper), policies(client, sleeper) {}
Compute compute;
CloudRun run;
CloudFunctions functions;
Gke gke;
CloudBuild build;
ArtifactRegistry artifacts;
Iam iam;
IamCredentials credentials;
ResourceManager projects;
ServiceUsage services;
CloudLogging logging;
CloudMonitoring monitoring;
CloudScheduler scheduler;
CloudTasks tasks;
Workflows workflows;
WorkflowExecutions executions;
Eventarc eventarc;
Billing billing;
CloudAsset assets;
OrgPolicy policies;
// All products in table order.
std::vector<const OpsProduct*> all() const {
return {&compute, &run, &functions, &gke, &build, &artifacts, &iam,
&credentials, &projects, &services, &logging, &monitoring, &scheduler, &tasks,
&workflows, &executions, &eventarc, &billing, &assets, &policies};
}
// Throws GoogleError::invalid for an unknown name.
const OpsProduct& product(const std::string& name) const {
for (const OpsProduct* p : all())
if (name == p->product().name) return *p;
throw GoogleError::invalid("unknown ops product: " + name);
}
};
} // namespace molo::google::ops
+100
View File
@@ -0,0 +1,100 @@
#include "google/ops/ops_client.h"
#include "google/errors.h"
#include "google/ops/caps.h"
namespace molo::google::ops {
using clients::body::Json;
Json Outcome::to_json() const {
Json o = Json::object();
o.set("executed", Json(executed));
o.set("plan", plan.to_json());
if (executed) o.set("response", response);
else o.set("hint", Json("dry run: nothing was sent; pass confirm:true to execute"));
return o;
}
OpsClient::OpsClient(std::shared_ptr<GoogleClient> client, Sleeper sleeper)
: client_(std::move(client)), sleeper_(std::move(sleeper)) {}
CallPlan OpsClient::plan(const std::string& rpc, const Args& args) const {
return CallPlan::build(call_named(rpc), args);
}
Json OpsClient::send(const CallPlan& plan) const {
const std::string name = plan.spec().product();
const Product& product = product_named(name);
const Json* body = plan.has_body() ? &plan.body() : nullptr;
return client_->request(plan.method(), endpoint_of(product), plan.path(), body);
}
Json OpsClient::read(const std::string& rpc, const Args& args) const {
const CallSpec& spec = call_named(rpc);
if (spec.safe() != Safety::kRead) throw GoogleError::invalid(rpc + " is not a read call");
return send(CallPlan::build(spec, args));
}
Json OpsClient::list(const std::string& rpc, const Args& args, int max_pages) const {
const CallSpec& spec = call_named(rpc);
if (!spec.is_list() || spec.safe() != Safety::kRead)
throw GoogleError::invalid(rpc + " is not a list call");
if (max_pages < 1 || max_pages > OpsCaps::kMaxListPages)
throw GoogleError::invalid("max_pages must be 1.." + std::to_string(OpsCaps::kMaxListPages));
bool by_body = spec.method() == clients::Method::kPost;
const char* size_name = by_body ? (spec.has_body_field("pageSize") ? "pageSize" : nullptr)
: spec.has_query("pageSize") ? "pageSize"
: spec.has_query("maxResults") ? "maxResults"
: nullptr;
Json items = Json::array();
std::string token;
for (int page = 0; page < max_pages; ++page) {
Args a = args;
if (size_name) {
bool given = by_body ? (a.body_arg().is_object() && a.body_arg().find(size_name))
: a.query_args().find(size_name) != nullptr;
if (!given) {
if (by_body) a.field(size_name, Json(OpsCaps::kDefaultPageSize));
else a.query(size_name, Json(OpsCaps::kDefaultPageSize));
}
}
if (!token.empty()) {
if (by_body) a.field("pageToken", Json(token));
else a.query("pageToken", Json(token));
}
Json reply = send(CallPlan::build(spec, a));
if (const Json* arr = reply.find(spec.items_key); arr && arr->is_array())
for (const Json& item : arr->as_array()) {
if (items.as_array().size() >= OpsCaps::kMaxListItems) return items;
items.push(item);
}
const Json* next = reply.find("nextPageToken");
if (!next || !next->is_string() || next->as_string().empty()) break;
token = next->as_string();
}
return items;
}
Outcome OpsClient::execute(const std::string& rpc, const Args& args, bool confirm) const {
const CallSpec& spec = call_named(rpc);
Outcome out;
out.plan = CallPlan::build(spec, args);
if (spec.safe() == Safety::kRead || confirm) {
out.response = send(out.plan);
out.executed = true;
}
return out;
}
Operation OpsClient::wait(const std::string& product, const std::string& name) const {
const Product& p = product_named(product);
if (name.empty() || name.size() > OpsCaps::kMaxOperationNameChars ||
name.find("..") != std::string::npos || name.find('?') != std::string::npos ||
(name.rfind("projects/", 0) != 0 && name.rfind("organizations/", 0) != 0))
throw GoogleError::invalid("bad operation name");
if (!client_->configured()) throw NotConfiguredError(product);
return wait_operation(*client_, operation_endpoint_of(p), name, sleeper_);
}
} // namespace molo::google::ops
+58
View File
@@ -0,0 +1,58 @@
#pragma once
// OpsClient runs table calls: plan (validate), send, page walk, wait. Writes
// and destructive calls are dry runs unless `confirm` is true, so nothing
// changes in a cloud project by accident.
#include <memory>
#include <string>
#include "google/client.h"
#include "google/operation.h"
#include "google/ops/call_plan.h"
#include "google/ops/caps.h"
namespace molo::google::ops {
struct Outcome {
bool executed = false; // false: dry run, nothing was sent
CallPlan plan;
clients::body::Json response; // set when executed
// {"executed":bool,"plan":{...},"response":{...}} ; dry runs add "hint".
clients::body::Json to_json() const;
// The reply as a long-running operation (when the row is "lro").
Operation operation() const { return Operation::from_json(response); }
};
class OpsClient {
public:
explicit OpsClient(std::shared_ptr<GoogleClient> client, Sleeper sleeper = nullptr);
bool configured() const { return client_->configured(); }
const std::shared_ptr<GoogleClient>& google() const { return client_; }
CallPlan plan(const std::string& rpc, const Args& args) const;
// Safety::kRead rows only (others throw invalid): validate, then send.
clients::body::Json read(const std::string& rpc, const Args& args) const;
// A list row: walks pages (nextPageToken) up to max_pages and kMaxListItems,
// returns the items array.
clients::body::Json list(const std::string& rpc, const Args& args,
int max_pages = OpsCaps::kMaxListPages) const;
// Any row. Reads always run. Writes and destructive rows only run when
// `confirm` is true; no default on purpose.
Outcome execute(const std::string& rpc, const Args& args, bool confirm) const;
// Polls a google.longrunning operation of `product` until done (capped by
// google::OperationCaps). The name must start with projects/ or
// organizations/ and carry no "..".
Operation wait(const std::string& product, const std::string& operation_name) const;
private:
clients::body::Json send(const CallPlan& plan) const;
std::shared_ptr<GoogleClient> client_;
Sleeper sleeper_;
};
} // namespace molo::google::ops
+69
View File
@@ -0,0 +1,69 @@
#include "google/ops/ops_product.h"
#include "google/errors.h"
namespace molo::google::ops {
using clients::body::Json;
std::string Names::project(const std::string& p) {
if (!valid_name_segment(p)) throw GoogleError::invalid("bad project id");
return "projects/" + p;
}
std::string Names::location(const std::string& p, const std::string& l) {
if (!valid_name_segment(l)) throw GoogleError::invalid("bad location");
return project(p) + "/locations/" + l;
}
std::string Names::child(const std::string& parent, const std::string& collection,
const std::string& id) {
check_resource_name("parent", parent, "");
if (!valid_name_segment(collection) || !valid_name_segment(id))
throw GoogleError::invalid("bad resource id");
return parent + "/" + collection + "/" + id;
}
OpsProduct::OpsProduct(std::shared_ptr<GoogleClient> client, const std::string& product,
Sleeper sleeper)
: Service(client, endpoint_of(product_named(product))),
product_(product_named(product)),
ops_(std::move(client), std::move(sleeper)) {}
std::vector<std::string> OpsProduct::rpcs() const {
std::vector<std::string> out;
for (std::size_t i = 0; i < call_count(); ++i)
if (call_table()[i].product() == product_.name) out.push_back(call_table()[i].rpc);
return out;
}
void OpsProduct::own(const std::string& rpc) const {
if (call_named(rpc).product() != product_.name)
throw GoogleError::invalid(rpc + " does not belong to " + product_.name);
}
Json OpsProduct::read(const std::string& rpc, const Args& args) const {
own(rpc);
return ops_.read(rpc, args);
}
Json OpsProduct::list(const std::string& rpc, const Args& args, int max_pages) const {
own(rpc);
return ops_.list(rpc, args, max_pages);
}
Outcome OpsProduct::call(const std::string& rpc, const Args& args, bool confirm) const {
own(rpc);
return ops_.execute(rpc, args, confirm);
}
CallPlan OpsProduct::plan(const std::string& rpc, const Args& args) const {
own(rpc);
return ops_.plan(rpc, args);
}
Operation OpsProduct::wait(const std::string& name) const {
return ops_.wait(product_.name, name);
}
} // namespace molo::google::ops
+56
View File
@@ -0,0 +1,56 @@
#pragma once
// Base class of every ops product (Compute, Cloud Run, ...). A product is a
// Service bound to one Discovery API; its typed methods are thin wrappers over
// table rows. The generic read / list / call are limited to the rows of the
// product, so any table row is reachable even without a typed method.
#include <memory>
#include <string>
#include <vector>
#include "google/ops/ops_client.h"
#include "google/resource.h"
#include "google/service.h"
namespace molo::google::ops {
// Resource name helpers (validated, never raw string concatenation by callers).
struct Names {
static std::string project(const std::string& project); // projects/p
static std::string location(const std::string& project, const std::string& l); // projects/p/locations/l
static std::string child(const std::string& parent, const std::string& collection,
const std::string& id);
};
class OpsProduct : public Service {
public:
OpsProduct(std::shared_ptr<GoogleClient> client, const std::string& product,
Sleeper sleeper = nullptr);
const Product& product() const { return product_; }
// Rpc ids of this product's rows.
std::vector<std::string> rpcs() const;
clients::body::Json read(const std::string& rpc, const Args& args) const;
clients::body::Json list(const std::string& rpc, const Args& args,
int max_pages = OpsCaps::kMaxListPages) const;
// Reads run; writes and destructive rows are dry runs unless confirm is true.
Outcome call(const std::string& rpc, const Args& args, bool confirm) const;
CallPlan plan(const std::string& rpc, const Args& args) const;
// Polls a long-running operation of this product.
Operation wait(const std::string& operation_name) const;
protected:
void own(const std::string& rpc) const;
static Args at(const char* name, const std::string& value) {
Args a;
a.path(name, value);
return a;
}
Product product_;
OpsClient ops_;
};
} // namespace molo::google::ops
+44
View File
@@ -0,0 +1,44 @@
#pragma once
// Organization Policy v2. `parent` is projects/{p}, folders/{f} or
// organizations/{o}; the typed methods cover the project scope, the generic
// call() reaches folders and organizations.
#include "google/ops/ops_product.h"
namespace molo::google::ops {
class OrgPolicy : public OpsProduct {
public:
using Json = clients::body::Json;
explicit OrgPolicy(std::shared_ptr<GoogleClient> c, Sleeper s = nullptr)
: OpsProduct(std::move(c), "orgpolicy", std::move(s)) {}
Json constraints(const std::string& project_name) const {
return list("orgpolicy.projects.constraints.list", at("parent", project_name));
}
Json policies(const std::string& project_name) const {
return list("orgpolicy.projects.policies.list", at("parent", project_name));
}
Json policy(const std::string& name) const {
return read("orgpolicy.projects.policies.get", at("name", name));
}
Json effective_policy(const std::string& name) const {
return read("orgpolicy.projects.policies.getEffectivePolicy", at("name", name));
}
Json custom_constraints(const std::string& organization_name) const {
return list("orgpolicy.organizations.customConstraints.list", at("parent", organization_name));
}
// policy: {"name":".../policies/{constraint}","spec":{...}}
Outcome create_policy(const std::string& project_name, const Json& policy,
bool confirm = false) const {
return call("orgpolicy.projects.policies.create", at("parent", project_name).body(policy),
confirm);
}
Outcome delete_policy(const std::string& name, bool confirm) const {
return call("orgpolicy.projects.policies.delete", at("name", name), confirm);
}
};
} // namespace molo::google::ops
+86
View File
@@ -0,0 +1,86 @@
#pragma once
// Cloud Resource Manager v3: projects, folders, organizations, liens, tags,
// IAM policies of those resources. Names are projects/{id or number},
// folders/{n}, organizations/{n}.
#include <vector>
#include "google/ops/ops_product.h"
namespace molo::google::ops {
class ResourceManager : public OpsProduct {
public:
using Json = clients::body::Json;
explicit ResourceManager(std::shared_ptr<GoogleClient> c, Sleeper s = nullptr)
: OpsProduct(std::move(c), "cloudresourcemanager", std::move(s)) {}
Json project(const std::string& name) const {
return read("cloudresourcemanager.projects.get", at("name", name));
}
// query: Google's search syntax, e.g. "displayName:prod*" ("" lists all visible).
Json search_projects(const std::string& query = "") const {
return list("cloudresourcemanager.projects.search", with_query(query));
}
// Children of a folder or organization (parent = folders/n or organizations/n).
Json projects_under(const std::string& parent) const {
return list("cloudresourcemanager.projects.list", Args().query("parent", Json(parent)));
}
Json folders_under(const std::string& parent) const {
return list("cloudresourcemanager.folders.list", Args().query("parent", Json(parent)));
}
Json search_folders(const std::string& query = "") const {
return list("cloudresourcemanager.folders.search", with_query(query));
}
Json folder(const std::string& name) const {
return read("cloudresourcemanager.folders.get", at("name", name));
}
Json search_organizations(const std::string& query = "") const {
return list("cloudresourcemanager.organizations.search", with_query(query));
}
Json organization(const std::string& name) const {
return read("cloudresourcemanager.organizations.get", at("name", name));
}
Json project_policy(const std::string& project_name) const {
return read("cloudresourcemanager.projects.getIamPolicy", at("resource", project_name));
}
// The subset of `permissions` the caller holds on the project.
Json test_project_permissions(const std::string& project_name,
const std::vector<std::string>& permissions) const {
Json arr = Json::array();
for (const std::string& p : permissions) arr.push(Json(p));
Args a = at("resource", project_name);
a.field("permissions", arr);
return read("cloudresourcemanager.projects.testIamPermissions", a);
}
Json liens(const std::string& parent) const {
return list("cloudresourcemanager.liens.list", Args().query("parent", Json(parent)));
}
Json operation(const std::string& name) const {
return read("cloudresourcemanager.operations.get", at("name", name));
}
Outcome create_project(const std::string& project_id, const std::string& display_name,
const std::string& parent, bool confirm = false) const {
Args a;
a.field("projectId", Json(project_id)).field("displayName", Json(display_name));
if (!parent.empty()) a.field("parent", Json(parent));
return call("cloudresourcemanager.projects.create", a, confirm);
}
Outcome delete_project(const std::string& name, bool confirm) const {
return call("cloudresourcemanager.projects.delete", at("name", name), confirm);
}
Outcome undelete_project(const std::string& name, bool confirm = false) const {
return call("cloudresourcemanager.projects.undelete", at("name", name), confirm);
}
private:
static Args with_query(const std::string& query) {
Args a;
if (!query.empty()) a.query("query", Json(query));
return a;
}
};
} // namespace molo::google::ops
+81
View File
@@ -0,0 +1,81 @@
#include "google/ops/service_usage.h"
#include "google/errors.h"
#include "google/ops/caps.h"
namespace molo::google::ops {
using clients::body::Json;
namespace {
std::string str(const Json& doc, const char* key) {
const Json* v = doc.find(key);
return v && v->is_string() ? v->as_string() : std::string();
}
} // namespace
ServiceState ServiceState::from_json(const Json& doc) {
ServiceState s;
if (!doc.is_object()) return s;
s.name = str(doc, "name");
s.state = str(doc, "state");
if (const Json* cfg = doc.find("config"); cfg && cfg->is_object()) {
s.api = str(*cfg, "name");
s.title = str(*cfg, "title");
}
return s;
}
std::string ServiceUsage::service_name(const std::string& project, const std::string& api) {
if (!valid_name_segment(project) || !valid_name_segment(api))
throw GoogleError::invalid("bad project or service name");
return "projects/" + project + "/services/" + api;
}
Json ServiceUsage::list_services(const std::string& parent, const std::string& filter) const {
Args a = at("parent", parent);
if (!filter.empty()) {
if (filter.size() > 128) throw GoogleError::invalid("filter too long");
a.query("filter", Json(filter));
}
return list("serviceusage.services.list", a);
}
std::vector<ServiceState> ServiceUsage::enabled_services(const std::string& parent) const {
std::vector<ServiceState> out;
Json items = list_services(parent, "state:ENABLED");
for (const Json& item : items.as_array()) out.push_back(ServiceState::from_json(item));
return out;
}
Json ServiceUsage::batch_get(const std::string& parent,
const std::vector<std::string>& names) const {
if (names.empty() || names.size() > OpsCaps::kMaxBatchNames)
throw GoogleError::invalid("names must hold 1.." + std::to_string(OpsCaps::kMaxBatchNames));
Json arr = Json::array();
for (const std::string& n : names) arr.push(Json(n));
return read("serviceusage.services.batchGet", at("parent", parent).query("names", arr));
}
Outcome ServiceUsage::disable(const std::string& name, bool disable_dependents,
bool confirm) const {
Args a = at("name", name);
if (disable_dependents) a.field("disableDependentServices", Json(true));
return call("serviceusage.services.disable", a, confirm);
}
Outcome ServiceUsage::batch_enable(const std::string& parent,
const std::vector<std::string>& api_ids, bool confirm) const {
if (api_ids.empty() || api_ids.size() > OpsCaps::kMaxBatchNames)
throw GoogleError::invalid("serviceIds must hold 1.." + std::to_string(OpsCaps::kMaxBatchNames));
Json arr = Json::array();
for (const std::string& id : api_ids) {
if (!valid_name_segment(id)) throw GoogleError::invalid("bad service id");
arr.push(Json(id));
}
Args a = at("parent", parent);
a.field("serviceIds", arr);
return call("serviceusage.services.batchEnable", a, confirm);
}
} // namespace molo::google::ops
+55
View File
@@ -0,0 +1,55 @@
#pragma once
// Service Usage v1: which APIs a project has enabled. Reads run directly.
// enable, disable and batch_enable are explicit methods that are DRY RUNS
// unless confirm is true: enabling an API is a human decision (cost, quota,
// attack surface), so nothing here calls them on its own.
#include <string>
#include <vector>
#include "google/ops/ops_product.h"
namespace molo::google::ops {
struct ServiceState {
std::string name; // projects/123/services/iam.googleapis.com
std::string api; // iam.googleapis.com
std::string state; // ENABLED, DISABLED, STATE_UNSPECIFIED
std::string title;
bool enabled() const { return state == "ENABLED"; }
static ServiceState from_json(const clients::body::Json& doc);
};
class ServiceUsage : public OpsProduct {
public:
using Json = clients::body::Json;
explicit ServiceUsage(std::shared_ptr<GoogleClient> c, Sleeper s = nullptr)
: OpsProduct(std::move(c), "serviceusage", std::move(s)) {}
// "projects/{id or number}/services/{api}"; api like iam.googleapis.com.
static std::string service_name(const std::string& project, const std::string& api);
// filter: "state:ENABLED" or "state:DISABLED" (Google's syntax) or "".
Json list_services(const std::string& parent, const std::string& filter = "") const;
std::vector<ServiceState> enabled_services(const std::string& parent) const;
Json service(const std::string& name) const {
return read("serviceusage.services.get", at("name", name));
}
ServiceState state(const std::string& name) const { return ServiceState::from_json(service(name)); }
// Up to OpsCaps::kMaxBatchNames names (full service names) in one call.
Json batch_get(const std::string& parent, const std::vector<std::string>& names) const;
Json operation(const std::string& name) const {
return read("serviceusage.operations.get", at("name", name));
}
Outcome enable(const std::string& name, bool confirm = false) const {
return call("serviceusage.services.enable", at("name", name), confirm);
}
Outcome disable(const std::string& name, bool disable_dependents = false,
bool confirm = false) const;
Outcome batch_enable(const std::string& parent, const std::vector<std::string>& api_ids,
bool confirm = false) const;
};
} // namespace molo::google::ops
+154
View File
@@ -0,0 +1,154 @@
#!/usr/bin/env python3
"""Check src/google/ops/calls.cpp against Google's Discovery documents.
Fails (exit 1) when a declared product differs from its Discovery document
(version, root URL, service path) or when a declared call is absent, or its
HTTP method, path, safety class, list item key, long-running kind, request
body fields, query parameters or path shapes differ from what Discovery says.
It also requires the safety class to be consistent (GET is read, DELETE is
destructive) and every declared body field to exist in the request schema.
Python 3 stdlib only, no credentials needed.
python3 -I src/google/ops/tools/check_discovery.py
"""
import json
import os
import re
import sys
import urllib.request
HERE = os.path.dirname(os.path.abspath(__file__))
CALLS = os.path.join(HERE, "..", "calls.cpp")
URL = "https://%s.googleapis.com/$discovery/rest?version=%s"
ROW = re.compile(r'^\s*\{(.*)\},?\s*$')
STR = re.compile(r'"([^"]*)"')
READ_POSTS = {"queryGrantableRoles", "queryTestablePermissions", "testIamPermissions",
"getIamPolicy", "signBlob", "signJwt", "generateAccessToken", "generateIdToken",
"queryAssets", "listRevisions", "wait"}
def block(text, begin, end):
a = text.index(begin)
b = text.index(end)
rows = []
for line in text[a:b].splitlines()[1:]:
m = ROW.match(line)
if m and '"' in line:
rows.append(STR.findall(m.group(1)))
return rows
def walk(node, out):
for m in node.get("methods", {}).values():
out[m["id"]] = m
for c in node.get("resources", {}).values():
walk(c, out)
def shape_of(pattern):
if not pattern or not pattern.startswith("^") or not pattern.endswith("$"):
return ""
out = []
for p in pattern[1:-1].replace("[^/]+", "\x00").split("/"):
if p == "\x00":
out.append("*")
elif re.fullmatch(r"[A-Za-z0-9_.-]+", p):
out.append(p)
else:
return ""
return "/".join(out)
def main():
text = open(CALLS).read()
products = block(text, "// PRODUCTS-BEGIN", "// PRODUCTS-END")
calls = block(text, "// CALLS-BEGIN", "// CALLS-END")
bad = []
docs, index = {}, {}
for name, version, root, service_path, revision in products:
with urllib.request.urlopen(URL % (name, version), timeout=60) as r:
doc = json.load(r)
docs[name] = doc
index[name] = {}
walk(doc, index[name])
if doc["version"] != version:
bad.append("%s: version %s != %s" % (name, version, doc["version"]))
if doc["rootUrl"].rstrip("/") != root:
bad.append("%s: root %s != %s" % (name, root, doc["rootUrl"]))
if doc["servicePath"].rstrip("/") != service_path:
bad.append("%s: servicePath %s != %s" % (name, service_path, doc["servicePath"]))
if doc["revision"] != revision:
print("note: %s revision %s (table generated from %s)" % (name, doc["revision"], revision))
seen = set()
for rpc, http, path, safety, kind, items, body, query, shapes in calls:
if rpc in seen:
bad.append("duplicate row " + rpc)
seen.add(rpc)
name = rpc.split(".", 1)[0]
if name not in docs:
bad.append("%s: product %s not declared" % (rpc, name))
continue
doc = docs[name]
m = index[name].get(rpc)
if not m:
bad.append("missing rpc " + rpc)
continue
if m["httpMethod"] != http:
bad.append("%s: http %s != %s" % (rpc, http, m["httpMethod"]))
if m["path"] != path:
bad.append("%s: path %s != %s" % (rpc, path, m["path"]))
verb = rpc.rsplit(".", 1)[1]
if http == "GET" and safety != "R":
bad.append("%s: GET must be read" % rpc)
if http == "DELETE" and safety != "D":
bad.append("%s: DELETE must be destructive" % rpc)
if safety == "R" and http not in ("GET",) and verb not in READ_POSTS and rpc != "logging.entries.list":
bad.append("%s: %s row marked read without being a known read verb" % (rpc, http))
if safety == "D" and not (http == "DELETE" or verb.startswith("delete") or verb in ("batchDelete", "purge")):
bad.append("%s: destructive without a delete verb" % rpc)
# query parameters
params = m.get("parameters", {})
want_q = sorted(k for k, v in params.items() if v.get("location") == "query")
if sorted(filter(None, query.split(","))) != want_q:
bad.append("%s: query params differ: %s vs %s" % (rpc, query, ",".join(want_q)))
# request body fields (readOnly fields are never sent)
ref = m.get("request", {}).get("$ref")
props = doc["schemas"].get(ref, {}).get("properties", {}) if ref else {}
want_b = sorted(k for k, v in props.items() if not v.get("readOnly"))
if sorted(filter(None, body.split(","))) != want_b:
bad.append("%s: body fields differ: %s vs %s" % (rpc, body, ",".join(want_b)))
# path shapes
want_s = []
for pn in re.findall(r"\{\+?([A-Za-z0-9]+)\}", path):
p = params.get(pn)
if p is None or p.get("location") != "path":
bad.append("%s: path param %s absent" % (rpc, pn))
continue
sh = shape_of(p.get("pattern", "")) if ("{+" + pn + "}") in path else ""
want_s.append("%s=%s" % (pn, sh))
if shapes.split() != want_s:
bad.append("%s: shapes differ: %s vs %s" % (rpc, shapes, " ".join(want_s)))
# list items key: must be an array property of the response
rref = m.get("response", {}).get("$ref")
rprops = doc["schemas"].get(rref, {}).get("properties", {}) if rref else {}
if items:
if rprops.get(items, {}).get("type") != "array":
bad.append("%s: items key %s is not an array of %s" % (rpc, items, rref))
# long-running kind
want_kind = ""
if name == "compute":
want_kind = "compute" if rref == "Operation" else ""
elif "done" in rprops and "name" in rprops:
want_kind = "lro"
if kind != want_kind:
bad.append("%s: kind %r != %r" % (rpc, kind, want_kind))
print("ops discovery: %d products, %d calls" % (len(products), len(calls)))
if bad:
print("\n".join(bad[:100]))
print("%d problems" % len(bad))
sys.exit(1)
print("discovery ok")
if __name__ == "__main__":
main()
+360
View File
@@ -0,0 +1,360 @@
#!/usr/bin/env python3
"""Generate src/google/ops/calls.cpp from Google's Discovery documents.
The SELECTION below names the calls the ops package wraps; every other column
(HTTP method, path, request fields, query parameters, path shapes, list item
key, long-running kind) is READ from Discovery, never typed by hand. After
generating, run tools/check_discovery.py, which re-reads the committed file
and fails on any drift. Python 3 stdlib only, no credentials.
python3 -I src/google/ops/tools/gen_calls.py > src/google/ops/calls.cpp
"""
import json
import re
import sys
import urllib.request
PRODUCTS = [
("compute", "v1"), ("run", "v2"), ("cloudfunctions", "v2"), ("container", "v1"),
("cloudbuild", "v1"), ("artifactregistry", "v1"), ("iam", "v1"),
("iamcredentials", "v1"), ("cloudresourcemanager", "v3"), ("serviceusage", "v1"),
("logging", "v2"), ("monitoring", "v3"), ("cloudscheduler", "v1"), ("cloudtasks", "v2"),
("workflows", "v1"), ("workflowexecutions", "v1"), ("eventarc", "v1"),
("cloudbilling", "v1"), ("cloudasset", "v1"), ("orgpolicy", "v2"),
]
IAM3 = "getIamPolicy setIamPolicy testIamPermissions"
CRUD = "list get create patch delete"
# product -> list of (resource prefix, space separated verbs). Ids are
# "<product>.<prefix>.<verb>".
SELECTION = {
"compute": [
("instances", "list get insert delete start stop reset"),
("zones", "list get"), ("regions", "list get"), ("machineTypes", "list get"),
("disks", "list get"), ("networks", "list get"), ("subnetworks", "list get"),
("firewalls", "list get"), ("images", "list get"), ("addresses", "list"),
("instanceTemplates", "list get"), ("instanceGroups", "list"),
("snapshots", "list get"), ("backendServices", "list"),
("forwardingRules", "list"), ("projects", "get"),
("zoneOperations", "list get wait"), ("globalOperations", "list get"),
("regionOperations", "list get"),
],
"run": [
("projects.locations.services", CRUD + " " + IAM3),
("projects.locations.services.revisions", "list get delete"),
("projects.locations.jobs", CRUD + " run " + IAM3),
("projects.locations.jobs.executions", "list get cancel delete"),
("projects.locations.jobs.executions.tasks", "list get"),
("projects.locations.operations", "list get wait"),
],
"cloudfunctions": [
("projects.locations.functions", CRUD + " generateUploadUrl generateDownloadUrl " + IAM3),
("projects.locations", "list"),
("projects.locations.runtimes", "list"),
("projects.locations.operations", "list get"),
],
"container": [
("projects.locations", "getServerConfig"),
("projects.locations.clusters", "list get create update delete fetchClusterUpgradeInfo "
"checkAutopilotCompatibility getJwks"),
("projects.locations.clusters.nodePools", "list get create update delete setSize rollback"),
("projects.locations.operations", "list get cancel"),
("projects.aggregated.usableSubnetworks", "list"),
],
"cloudbuild": [
("projects.locations.builds", "list get create cancel retry approve"),
("projects.builds", "list get create cancel retry"),
("projects.locations.triggers", CRUD + " run"),
("projects.locations.workerPools", CRUD),
("projects.locations", "getDefaultServiceAccount"),
("projects.locations.operations", "get cancel"),
],
"artifactregistry": [
("projects.locations", "list get getProjectConfig"),
("projects", "getProjectSettings"),
("projects.locations.repositories", CRUD + " " + IAM3),
("projects.locations.repositories.packages", "list get delete"),
("projects.locations.repositories.packages.versions", "list get delete batchDelete"),
("projects.locations.repositories.packages.tags", CRUD),
("projects.locations.repositories.files", "list get delete"),
("projects.locations.repositories.dockerImages", "list get"),
("projects.locations.repositories.mavenArtifacts", "list get"),
("projects.locations.repositories.npmPackages", "list get"),
("projects.locations.repositories.pythonPackages", "list get"),
("projects.locations.repositories.rules", CRUD),
("projects.locations.repositories.attachments", "list get"),
("projects.locations.operations", "get"),
],
"iam": [
("roles", "list get queryGrantableRoles"),
("permissions", "queryTestablePermissions"),
("projects.roles", "list get create patch delete undelete"),
("organizations.roles", "list get"),
("projects.serviceAccounts", "list get create patch update delete undelete enable disable "
"signBlob signJwt " + IAM3),
("projects.serviceAccounts.keys", "list get create upload delete enable disable"),
],
"iamcredentials": [
("projects.serviceAccounts", "signJwt signBlob generateAccessToken generateIdToken"),
],
"cloudresourcemanager": [
("projects", "get list search create patch delete undelete move " + IAM3),
("folders", "get list search create patch delete undelete move " + IAM3),
("organizations", "get search " + IAM3),
("operations", "get"),
("liens", "list get create delete"),
("tagKeys", "list get"), ("tagValues", "list get"), ("tagBindings", "list"),
],
"serviceusage": [
("services", "list get batchGet enable disable batchEnable"),
("operations", "get list"),
],
"logging": [
("entries", "list write"),
("projects.logs", "list delete"),
("monitoredResourceDescriptors", "list"),
("projects.sinks", "list get create patch delete"),
("projects.metrics", "list get create update delete"),
("projects.exclusions", "list get"),
("projects.locations.buckets", "list get"),
("projects.getSettings", ""),
("projects.locations.operations", "get"),
],
"monitoring": [
("projects.timeSeries", "list create"),
("projects.metricDescriptors", "list get"),
("projects.monitoredResourceDescriptors", "list get"),
("projects.alertPolicies", "list get create patch delete"),
("projects.notificationChannels", "list get"),
("projects.notificationChannelDescriptors", "list get"),
("projects.groups", "list get"),
("projects.uptimeCheckConfigs", "list get"),
("projects.snoozes", "list get"),
("projects.alerts", "list get"),
("services", "list get"),
("services.serviceLevelObjectives", "list get"),
],
"cloudscheduler": [
("projects.locations", "list get"),
("projects.locations.jobs", CRUD + " run pause resume"),
("projects.locations.operations", "get"),
],
"cloudtasks": [
("projects.locations", "list get"),
("projects.locations.queues", CRUD + " pause resume purge " + IAM3),
("projects.locations.queues.tasks", "list get create delete run"),
("projects.locations.operations", "get"),
],
"workflows": [
("projects.locations", "list get"),
("projects.locations.workflows", "list get create patch delete listRevisions"),
("projects.locations.operations", "get list"),
],
"workflowexecutions": [
("projects.locations.workflows.executions", "list get create cancel"),
("projects.locations.workflows.executions.stepEntries", "list get"),
],
"eventarc": [
("projects.locations", "list get"),
("projects.locations.triggers", CRUD + " " + IAM3),
("projects.locations.channels", CRUD),
("projects.locations.providers", "list get"),
("projects.locations.pipelines", "list get"),
("projects.locations.messageBuses", "list get"),
("projects.locations.enrollments", "list get"),
("projects.locations.operations", "get list"),
],
"cloudbilling": [
("billingAccounts", "list get getIamPolicy testIamPermissions"),
("billingAccounts.projects", "list"),
("projects", "getBillingInfo updateBillingInfo"),
("services", "list"),
("services.skus", "list"),
],
"cloudasset": [
("assets", "list"),
("", "searchAllResources searchAllIamPolicies batchGetAssetsHistory analyzeIamPolicy "
"analyzeMove exportAssets queryAssets analyzeOrgPolicies"),
("feeds", "list get"), ("savedQueries", "list get"),
("operations", "get"),
("effectiveIamPolicies", "batchGet"),
],
"orgpolicy": [
("projects.constraints", "list"),
("folders.constraints", "list"),
("organizations.constraints", "list"),
("projects.policies", CRUD + " getEffectivePolicy"),
("folders.policies", CRUD + " getEffectivePolicy"),
("organizations.policies", CRUD + " getEffectivePolicy"),
("organizations.customConstraints", "list get"),
],
}
# POST / PATCH rows that only read, or only sign: no state changes.
READ_VERBS = {"queryGrantableRoles", "queryTestablePermissions", "testIamPermissions",
"getIamPolicy", "signBlob", "signJwt", "generateAccessToken", "generateIdToken",
"queryAssets", "listRevisions", "wait"}
READ_IDS = {"logging.entries.list"}
# Response array key when Discovery's list response is ambiguous.
ITEMS_OVERRIDE = {
"logging.entries.list": "entries",
"iam.roles.queryGrantableRoles": "roles",
"iam.permissions.queryTestablePermissions": "permissions",
"cloudasset.searchAllResources": "results",
"cloudasset.searchAllIamPolicies": "results",
"cloudasset.assets.list": "assets",
"cloudasset.batchGetAssetsHistory": "assets",
"cloudasset.analyzeOrgPolicies": "orgPolicyResults",
"cloudbilling.services.skus.list": "skus",
"cloudbilling.billingAccounts.projects.list": "projectBillingInfo",
}
def fetch(name, version):
url = "https://%s.googleapis.com/$discovery/rest?version=%s" % (name, version)
with urllib.request.urlopen(url, timeout=60) as r:
return json.load(r)
def walk(node, out):
for m in node.get("methods", {}).values():
out[m["id"]] = m
for c in node.get("resources", {}).values():
walk(c, out)
def shape_of(pattern):
"""'^projects/[^/]+/locations/[^/]+$' -> 'projects/*/locations/*', else ''."""
if not pattern or not pattern.startswith("^") or not pattern.endswith("$"):
return ""
parts = pattern[1:-1].replace("[^/]+", "\x00").split("/")
out = []
for p in parts:
if p == "\x00":
out.append("*")
elif re.fullmatch(r"[A-Za-z0-9_.-]+", p):
out.append(p)
else:
return ""
return "/".join(out)
def request_fields(doc, m):
ref = m.get("request", {}).get("$ref")
if not ref:
return []
props = doc["schemas"].get(ref, {}).get("properties", {})
return [k for k, v in props.items() if not v.get("readOnly")]
def items_key(doc, rid, m):
if rid in ITEMS_OVERRIDE:
return ITEMS_OVERRIDE[rid]
verb = rid.rsplit(".", 1)[1]
if not (verb.startswith("list") or verb.startswith("search")):
return ""
ref = m.get("response", {}).get("$ref")
props = doc["schemas"].get(ref, {}).get("properties", {})
arrays = [k for k, v in props.items() if v.get("type") == "array" and k not in ("unreachable",)]
if len(arrays) == 1:
return arrays[0]
tokens = rid.split(".")
for k in arrays:
if k.lower() == tokens[-2].lower() or k.lower().startswith(tokens[-2].lower()[:5]):
return k
raise SystemExit("ambiguous list key for %s: %s (add to ITEMS_OVERRIDE)" % (rid, arrays))
def kind_of(doc, m):
ref = m.get("response", {}).get("$ref", "")
props = doc["schemas"].get(ref, {}).get("properties", {})
if doc["name"] == "compute":
return "compute" if ref == "Operation" else ""
if "done" in props and "name" in props:
return "lro"
return ""
def main():
docs, rows, missing = {}, [], []
out = []
out.append("// GENERATED by tools/gen_calls.py from Google's Discovery documents; do not edit.")
out.append("// tools/check_discovery.py re-reads this file and fails on any drift.")
out.append('#include "google/ops/calls.h"')
out.append("")
out.append("namespace molo::google::ops {")
out.append("")
out.append("// PRODUCTS-BEGIN (name, version, root url, service path, discovery revision)")
prods = []
for name, version in PRODUCTS:
doc = fetch(name, version)
docs[name] = doc
idx = {}
walk(doc, idx)
doc["_idx"] = idx
prods.append(' {"%s", "%s", "%s", "%s", "%s"},' % (
name, doc["version"], doc["rootUrl"].rstrip("/"), doc["servicePath"].rstrip("/"),
doc["revision"]))
out.extend(["static const Product kProducts[] = {"] + prods + ["};"])
out.append("// PRODUCTS-END")
out.append("")
out.append("// CALLS-BEGIN (rpc, http, path, safety R/W/D, kind, items key, body fields, "
"query params, path shapes)")
out.append("static const CallSpec kCalls[] = {")
count = 0
for name, _ in PRODUCTS:
doc = docs[name]
idx = doc["_idx"]
for prefix, verbs in SELECTION.get(name, []):
vs = verbs.split() if verbs else [""]
for v in vs:
rid = ".".join(x for x in (name, prefix, v) if x)
if prefix.endswith("getSettings"):
rid = name + "." + prefix
m = idx.get(rid)
if not m:
missing.append(rid)
continue
http = m["httpMethod"]
verb = rid.rsplit(".", 1)[1]
if http == "GET" or verb in READ_VERBS or rid in READ_IDS:
safety = "R"
elif http == "DELETE":
safety = "D"
else:
safety = "W"
# deletes by POST verb names
if verb.startswith("delete") or verb == "batchDelete" or verb == "purge":
safety = "D"
query = [k for k, v in m.get("parameters", {}).items() if v.get("location") == "query"]
shapes = []
for pn in re.findall(r"\{\+?([A-Za-z0-9]+)\}", m["path"]):
p = m["parameters"][pn]
sh = shape_of(p.get("pattern", "")) if "{+" + pn + "}" in m["path"] else ""
shapes.append("%s=%s" % (pn, sh))
body = request_fields(doc, m)
rows.append(' {"%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s"},' % (
rid, http, m["path"], safety, kind_of(doc, m), items_key(doc, rid, m),
",".join(body), ",".join(query), " ".join(shapes)))
count += 1
if missing:
sys.stderr.write("MISSING in Discovery:\n " + "\n ".join(missing) + "\n")
raise SystemExit(1)
out.extend(rows)
out.append("};")
out.append("// CALLS-END")
out.append("")
out.append("const Product* products() { return kProducts; }")
out.append("std::size_t product_count() { return sizeof(kProducts) / sizeof(kProducts[0]); }")
out.append("const CallSpec* call_table() { return kCalls; }")
out.append("std::size_t call_count() { return sizeof(kCalls) / sizeof(kCalls[0]); }")
out.append("")
out.append("} // namespace molo::google::ops")
sys.stdout.write("\n".join(out) + "\n")
sys.stderr.write("generated %d calls\n" % count)
if __name__ == "__main__":
main()
+73
View File
@@ -0,0 +1,73 @@
#pragma once
// Workflows v1 (definitions) and Workflow Executions v1 (runs). `parent` is
// projects/{p}/locations/{l}.
#include "google/ops/ops_product.h"
namespace molo::google::ops {
class Workflows : public OpsProduct {
public:
using Json = clients::body::Json;
explicit Workflows(std::shared_ptr<GoogleClient> c, Sleeper s = nullptr)
: OpsProduct(std::move(c), "workflows", std::move(s)) {}
Json workflows(const std::string& parent) const {
return list("workflows.projects.locations.workflows.list", at("parent", parent));
}
Json workflow(const std::string& name) const {
return read("workflows.projects.locations.workflows.get", at("name", name));
}
Json revisions(const std::string& name) const {
return list("workflows.projects.locations.workflows.listRevisions", at("name", name));
}
Json operation(const std::string& name) const {
return read("workflows.projects.locations.operations.get", at("name", name));
}
Outcome create_workflow(const std::string& parent, const std::string& workflow_id,
const Json& workflow, bool confirm = false) const {
Args a = at("parent", parent);
a.query("workflowId", Json(workflow_id)).body(workflow);
return call("workflows.projects.locations.workflows.create", a, confirm);
}
Outcome delete_workflow(const std::string& name, bool confirm) const {
return call("workflows.projects.locations.workflows.delete", at("name", name), confirm);
}
};
class WorkflowExecutions : public OpsProduct {
public:
using Json = clients::body::Json;
explicit WorkflowExecutions(std::shared_ptr<GoogleClient> c, Sleeper s = nullptr)
: OpsProduct(std::move(c), "workflowexecutions", std::move(s)) {}
// workflow_name: projects/{p}/locations/{l}/workflows/{w}
Json executions(const std::string& workflow_name) const {
return list("workflowexecutions.projects.locations.workflows.executions.list",
at("parent", workflow_name));
}
Json execution(const std::string& name) const {
return read("workflowexecutions.projects.locations.workflows.executions.get",
at("name", name));
}
Json step_entries(const std::string& execution_name) const {
return list("workflowexecutions.projects.locations.workflows.executions.stepEntries.list",
at("parent", execution_name));
}
// argument: the workflow input serialized as a JSON string ("" for none).
Outcome start(const std::string& workflow_name, const std::string& argument,
bool confirm = false) const {
Args a = at("parent", workflow_name);
if (!argument.empty()) a.field("argument", Json(argument));
return call("workflowexecutions.projects.locations.workflows.executions.create", a, confirm);
}
Outcome cancel(const std::string& execution_name, bool confirm = false) const {
return call("workflowexecutions.projects.locations.workflows.executions.cancel",
at("name", execution_name), confirm);
}
};
} // namespace molo::google::ops