feat(clients): sessions+registry+optimize+armor: close gaps, loud list truncation, shared Gemini adapter

sessions: operations get/list/cancel/delete/wait for engine, session, memory and
serving profile; servingProfiles CRUD. registry: ListResult with truncated flag,
v1alpha twins, gateway/policy operations, authz IAM, deny policy update, boundary
patch/bindings. optimize: make_gemini_model over models::VertexModel (DirectModel
removed), generateSyntheticData, online evaluator operations, trace/log writers.
armor: SecurityAdmin for all SCC v2 methods (attack exposure excluded), documented
agent threat categories, floor settings fixed to location global after live run.
check_discovery.py of all four enforce coverage.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-24 05:43:13 +02:00
co-authored by Claude Sonnet 5.5
parent 29d775a923
commit a3396bfc68
83 changed files with 5020 additions and 378 deletions
+59 -18
View File
@@ -17,8 +17,16 @@ Gemini Enterprise Agent Platform, Agent Engine (`reasoningEngines`) children:
create, get, list, patch, delete, purge (explicit, guarded), revisions
(list, get), rollback, topics (managed and custom), scope maps, metadata.
- Long-running operations: every mutating call returns an Operation; the module
waits with `wait_operation` (hard caps in `OperationCaps`). `operation()`,
`cancel_operation()` and `wait()` expose them for one engine only.
waits with `wait_operation` (hard caps in `OperationCaps`). All five
Discovery operations methods (get, list, cancel, delete, wait) are wrapped
for the four places Discovery puts them: under the engine, under a session,
under a memory and under a serving profile (20 table rows). `operation()`,
`list_operations()`, `cancel_operation()`, `delete_operation()`, `wait()`
(client polling) and `wait_server()` (one POST `:wait?timeout=Ns`, 1..60 s)
work for one root only: the engine, or the location for serving profiles.
- Serving profiles (`projects.locations.servingProfiles`, location level, not
engine scoped): create (waits), get, list, patch, delete, with scope
`GEMINI_LIVE`, `INTERACTIONS_API` or `RESPONSE_API`, optional CMEK key.
Everything is against one API surface: `aiplatform` **v1beta1**. See section 6
for why not v1.
@@ -29,15 +37,18 @@ for why not v1.
|---|---|
| `caps.h` | Static ceilings (`SessionsCaps`, `MemoryCaps`) |
| `calls.h` | The ONE table of every REST call (verb, path, discovery method, request fields, query params) |
| `names.h/.cpp` | `EngineName` (validated resource name), `Check` (input validators), wire helpers |
| `names.h/.cpp` | `EngineName`, `LocationName` (validated resource names), `Check` (input validators), wire helpers |
| `operation_names.h/.cpp` | `OperationName`: validates an operation name against its root, picks the table row for each verb by owner (engine, session, memory, serving profile) |
| `operation_service.h/.cpp` | `OperationService : Service`: table-driven `send`, `settle`, loud capped `list_items` (`list_over_limit`), the operations surface |
| `serving_profile.h/.cpp` | `ServingProfileSpec`, `ServingProfilePatch`, `ServingProfile`, `ServingScope`, `ServingProfiles : OperationService` |
| `session_types.h/.cpp` | `SessionSpec`, `Session`, `SessionPatch`, `CompactRequest`, `SessionEvent`, list options |
| `memory_types.h/.cpp` | `Memory`, `MemorySpec`, `MemoryPatch`, `Topic`, `MetadataValue`, `MetadataFilter`, `MemoryGenerateRequest`, `IngestRequest`, `RetrieveRequest`, `PurgeRequest`, `MemoryRevision`, `Profile` |
| `engine_service.h/.cpp` | `EngineService : Service`: table-driven `send`, `settle`, capped `list_items`, operation helpers |
| `engine_service.h/.cpp` | `EngineService : OperationService`: one validated engine and its v1beta1 endpoint |
| `sessions.h/.cpp` | `Sessions : EngineService` |
| `memory_bank.h/.cpp` | `MemoryBank : EngineService` |
| `tools/check_discovery.py` | Verifies `calls.h` and the typed bodies against Google's Discovery document |
Tests: `tests/src/google/sessions/test_sessions.cpp`. Example:
Tests: `tests/src/google/sessions/test_sessions.cpp` and `test_sessions_gaps.cpp`. Example:
`example/app/agent/SessionsDemo.cpp` (routes under `/agent/sessions`), tests in
`tests/example/agent/sessions/`.
@@ -50,7 +61,9 @@ Tests: `tests/src/google/sessions/test_sessions.cpp`. Example:
| Session TTL | `Ns` form, 24 h minimum (Google), 3650 days maximum (ours) |
| session_state / event | 64 KiB / 256 KiB serialized |
| Labels | 20, key and value 64 chars |
| List pages / items | 10 pages of 100, 1000 items; more is `RESULT_TOO_LARGE`, narrow the filter |
| List pages / items | 10 pages of 100, 1000 items; more items OR a further page after the last allowed one is `RESULT_TOO_LARGE` (502), never a silent cut, narrow the filter |
| Server-side operation wait | 1..60 s per call (`kMaxServerWaitSeconds`) |
| Serving profile | id 1..63 `[a-z0-9-]`, display name required 128, description 4000, KMS key name 512 |
| Scope | 1..10 entries, 128 chars, no `*` |
| Fact / description / context | 4000 chars |
| Generate sources | 100 events, 64 KiB; direct memories max 5 (Google) |
@@ -83,10 +96,14 @@ Tests: `tests/src/google/sessions/test_sessions.cpp`. Example:
credential) and fails if a declared call, verb, path, request field, query
parameter, enum value, response key or nested request field is absent.
Result 2026-10-24: `OK 2026-10-24: 23 calls, 7 enums, 25 response keys, 18
nested schemas match aiplatform v1beta1 discovery`. A deliberately misspelled
field made it exit 1 (checked). Rerun it after any change to `calls.h` or the
typed bodies.
Result 2026-10-24: `OK 2026-10-24: 46 calls, 8 enums, 34 response keys, 20
nested schemas match aiplatform v1beta1 discovery`. The script also checks
coverage: every Discovery method under `reasoningEngines.operations`,
`reasoningEngines.sessions`, `reasoningEngines.memories` and `servingProfiles`
must be a table row or listed in `EXCLUDED` (empty: nothing is excluded), so a
method Google adds later fails the check. A deliberately misspelled field made
it exit 1 (checked). Rerun it after any change to `calls.h` or the typed
bodies.
From discovery (v1beta1, `projects.locations.reasoningEngines`):
sessions create (POST, `sessionId` query, returns Operation), get, list
@@ -95,9 +112,12 @@ Operation), appendEvent (POST `:appendEvent`, body `SessionEvent`), compact
(POST `:compact`, returns Operation), events.list (`sessionEvents`);
memories generate / retrieve / retrieveProfiles / create (`memoryId`) / get /
list / patch (`updateMask`) / delete / purge / rollback / ingestEvents,
memories.revisions list / get; operations get / cancel. Discovery also lists
`wait`, `list`, `delete` on operations, which this module does not wrap
(`wait_operation` polls with GET).
memories.revisions list / get; operations get / cancel / list / delete / wait
under the engine, `sessions.operations.*` and `memories.operations.*` (same
five), `locations.servingProfiles` create (`servingProfileId` query, returns
Operation) / get / list / patch (`updateMask`) / delete (returns Empty) and
`servingProfiles.operations.*`. The Method column of a `calls.h` row is
relative to `kDiscoveryPrefix` unless it starts with `aiplatform.`.
## 6. Verified live
@@ -127,6 +147,20 @@ an express key and a token; v1 refuses keys. The opt-in test `sessions_live`
the real client (sessions list / get / events, memories list / get /
revisions) and passed with the key and with the token on 2026-10-24.
Gap-closing round, same day, service-account token, read-only:
| Call | Result |
|---|---|
| GET `v1beta1/.../reasoningEngines/1/operations?pageSize=5`, `.../sessions/abc/operations`, `.../memories/abc/operations` | 200 `{}` (empty list, even though engine 1 does not exist) |
| GET `v1beta1/.../locations/us-central1/servingProfiles?pageSize=5` (also `global` host and `europe-west4`) | 501 `UNIMPLEMENTED` "Operation is not implemented, or supported, or enabled." (not available to this project) |
| GET `v1beta1/.../servingProfiles/probe` | 501 UNIMPLEMENTED |
| GET `v1beta1/.../servingProfiles/probe/operations` | 400 INVALID_ARGUMENT: "the idType servingProfiles is not a documented LRO Parent ID, the associated value must be a Long, but was instead: probe" |
| GET `v1beta1/.../servingProfiles/123/operations?pageSize=1` | 200 `{}` |
The opt-in test `sessions_live.operations_and_serving_profiles_reads` repeats
the operations lists and the servingProfiles list through the real client; it
accepts 200 or 501/403/404 for servingProfiles and prints which one it saw.
No Agent Engine exists in the project, so **no happy path was verified
live**: create, patch, delete, append, compact, generate, ingest, retrieve,
retrieveProfiles, purge, rollback are verified by discovery only. Nothing that
@@ -151,18 +185,25 @@ Neither discovery nor the docs pages read state these; they are inferred:
search model (docs); the error body when it is not is unread.
- Memory Profiles need schema configs on the engine (`MemoryBankConfig` in the
runtime module); the shape of `profile` is free-form and kept raw.
- Serving profile id charset (`[a-z0-9-]`, 1..63 is our choice) and the real
id rule: Google's LRO layer wants a numeric id for operations under a
serving profile (400 above), so Google may assign or require numeric ids.
The create/patch responses (Operation `response` is `Any`) are parsed
tolerantly with a GET fallback. `servingProfiles` itself answers 501 on this
project, so no body of it was ever seen.
- Whether `operations.wait` answers `done: false` at the timeout or an error
(the docs line says "at most the time permitted"): both are handled, a
not-done answer is returned to the caller, not retried.
- Managed topic names beyond the four in discovery, and `thought`/`audio` parts
inside event `content` (typed by `gemini_types.h`, unknown parts dropped).
## 8. Gaps
- `servingProfiles` (location-level create/get/list/patch for Gemini Live,
Interactions and Response APIs) is listed by discovery next to this product
but is not engine-scoped; not implemented here. Owner: the `live` or
`models` module.
- Engine-level Memory Bank configuration (`contextSpec.memoryBankConfig`,
customization, TTL config) is part of the Agent Engine resource: runtime
module.
- Operations `list`, `delete`, `wait` (server-side) are not wrapped.
- `servingProfiles` answers 501 for the test project in three locations, so
the happy path is Discovery-verified only. Owner: a project that has the
feature; test `sessions_live.operations_and_serving_profiles_reads`.
- Session and memory `labels` / `metadata` filters beyond a passthrough string.
- Token refresh is the caller's job (foundation gap).
+36 -1
View File
@@ -9,6 +9,9 @@
// "API keys are not supported" for sessions and memories, v1beta1 accepts an
// express API key (404 for a missing engine). See SPEC.md.
//
// Method column: relative to kDiscoveryPrefix, except rows that start with
// "aiplatform." (location-level resources such as servingProfiles) which are
// absolute Discovery method ids.
// Row: {Call, verb, path template, discovery method (under
// aiplatform.projects.locations.reasoningEngines.), request schema suffix
// (after GoogleCloudAiplatformV1beta1), request fields used, query params used}.
@@ -30,7 +33,16 @@ enum class Call {
kMemoryGenerate, kMemoryRetrieve, kMemoryRetrieveProfiles, kMemoryCreate,
kMemoryGet, kMemoryList, kMemoryPatch, kMemoryDelete, kMemoryPurge,
kMemoryRollback, kMemoryIngestEvents, kRevisionList, kRevisionGet,
kOperationGet, kOperationCancel,
kOperationGet, kOperationCancel, kOperationList, kOperationDelete, kOperationWait,
kSessionOperationGet, kSessionOperationCancel, kSessionOperationList,
kSessionOperationDelete, kSessionOperationWait,
kMemoryOperationGet, kMemoryOperationCancel, kMemoryOperationList,
kMemoryOperationDelete, kMemoryOperationWait,
kServingProfileCreate, kServingProfileGet, kServingProfileList,
kServingProfilePatch, kServingProfileDelete,
kServingProfileOperationGet, kServingProfileOperationCancel,
kServingProfileOperationList, kServingProfileOperationDelete,
kServingProfileOperationWait,
kCount
};
@@ -69,6 +81,29 @@ inline constexpr CallSpec kCalls[] = {
{Call::kRevisionGet, "GET", "/{name}", "memories.revisions.get", "", "", ""},
{Call::kOperationGet, "GET", "/{name}", "operations.get", "", "", ""},
{Call::kOperationCancel, "POST", "/{name}:cancel", "operations.cancel", "", "", ""},
{Call::kOperationList, "GET", "/{name}/operations", "operations.list", "", "", "filter pageSize pageToken"},
{Call::kOperationDelete, "DELETE", "/{name}", "operations.delete", "", "", ""},
{Call::kOperationWait, "POST", "/{name}:wait", "operations.wait", "", "", "timeout"},
{Call::kSessionOperationGet, "GET", "/{name}", "sessions.operations.get", "", "", ""},
{Call::kSessionOperationCancel, "POST", "/{name}:cancel", "sessions.operations.cancel", "", "", ""},
{Call::kSessionOperationList, "GET", "/{name}/operations", "sessions.operations.list", "", "", "filter pageSize pageToken"},
{Call::kSessionOperationDelete, "DELETE", "/{name}", "sessions.operations.delete", "", "", ""},
{Call::kSessionOperationWait, "POST", "/{name}:wait", "sessions.operations.wait", "", "", "timeout"},
{Call::kMemoryOperationGet, "GET", "/{name}", "memories.operations.get", "", "", ""},
{Call::kMemoryOperationCancel, "POST", "/{name}:cancel", "memories.operations.cancel", "", "", ""},
{Call::kMemoryOperationList, "GET", "/{name}/operations", "memories.operations.list", "", "", "filter pageSize pageToken"},
{Call::kMemoryOperationDelete, "DELETE", "/{name}", "memories.operations.delete", "", "", ""},
{Call::kMemoryOperationWait, "POST", "/{name}:wait", "memories.operations.wait", "", "", "timeout"},
{Call::kServingProfileCreate, "POST", "/{parent}/servingProfiles", "aiplatform.projects.locations.servingProfiles.create", "ServingProfile", "displayName description scope cmekConfig", "servingProfileId"},
{Call::kServingProfileGet, "GET", "/{name}", "aiplatform.projects.locations.servingProfiles.get", "", "", ""},
{Call::kServingProfileList, "GET", "/{parent}/servingProfiles", "aiplatform.projects.locations.servingProfiles.list", "", "", "pageSize pageToken"},
{Call::kServingProfilePatch, "PATCH", "/{name}", "aiplatform.projects.locations.servingProfiles.patch", "ServingProfile", "displayName description cmekConfig", "updateMask"},
{Call::kServingProfileDelete, "DELETE", "/{name}", "aiplatform.projects.locations.servingProfiles.delete", "", "", ""},
{Call::kServingProfileOperationGet, "GET", "/{name}", "aiplatform.projects.locations.servingProfiles.operations.get", "", "", ""},
{Call::kServingProfileOperationCancel, "POST", "/{name}:cancel", "aiplatform.projects.locations.servingProfiles.operations.cancel", "", "", ""},
{Call::kServingProfileOperationList, "GET", "/{name}/operations", "aiplatform.projects.locations.servingProfiles.operations.list", "", "", "filter pageSize pageToken"},
{Call::kServingProfileOperationDelete, "DELETE", "/{name}", "aiplatform.projects.locations.servingProfiles.operations.delete", "", "", ""},
{Call::kServingProfileOperationWait, "POST", "/{name}:wait", "aiplatform.projects.locations.servingProfiles.operations.wait", "", "", "timeout"},
};
// clang-format on
+3
View File
@@ -22,6 +22,9 @@ struct SessionsCaps {
static constexpr int kPageSize = 100; // Google ceiling
static constexpr std::size_t kMaxListPages = 10;
static constexpr std::size_t kMaxListItems = 1000;
static constexpr std::size_t kMaxServerWaitSeconds = 60; // one POST :wait
static constexpr std::size_t kMaxDescriptionChars = 4000;
static constexpr std::size_t kMaxKmsKeyChars = 512;
};
struct MemoryCaps {
+3 -63
View File
@@ -4,70 +4,10 @@
namespace molo::google::sessions {
using clients::body::Json;
EngineService::EngineService(std::shared_ptr<GoogleClient> client, EngineName engine,
Sleeper sleeper)
: Service(std::move(client), endpoints::aiplatform_beta(engine.location())),
engine_name_(std::move(engine)),
sleeper_(std::move(sleeper)) {}
Json EngineService::send(Call call, const std::string& resource, const Json* body,
const std::string& query) const {
const CallSpec& row = spec_of(call);
return client_->request(verb_of(row), endpoint_, expand(call, resource, query), body);
}
Operation EngineService::settle(const Json& reply) const {
Operation op = Operation::from_json(reply);
if (op.done) {
if (op.failed())
throw GoogleError(502, "OPERATION_FAILED", op.error_message, endpoint_.name);
return op;
}
if (op.name.empty())
throw GoogleError(502, "EMPTY_RESPONSE", "no operation returned", endpoint_.name);
return wait(op.name);
}
namespace {
void check_operation_name(const EngineName& engine, const std::string& name) {
const std::string prefix = engine.str() + "/";
bool ok = name.size() > prefix.size() && name.compare(0, prefix.size(), prefix) == 0 &&
name.find("/operations/") != std::string::npos &&
name.find("..") == std::string::npos && name.find('?') == std::string::npos &&
name.size() <= 512;
if (!ok) throw GoogleError::invalid("operation name must belong to this engine");
}
} // namespace
Json EngineService::operation(const std::string& operation_name) const {
check_operation_name(engine_name_, operation_name);
return send(Call::kOperationGet, operation_name);
}
void EngineService::cancel_operation(const std::string& operation_name) const {
check_operation_name(engine_name_, operation_name);
Json empty = Json::object();
send(Call::kOperationCancel, operation_name, &empty);
}
Operation EngineService::wait(const std::string& operation_name) const {
check_operation_name(engine_name_, operation_name);
return wait_operation(*client_, endpoint_, operation_name, sleeper_);
}
Json EngineService::list_items(Call call, const std::string& resource,
const std::string& query, const std::string& items_key,
std::size_t max_pages, std::size_t max_items) const {
Json items = list_all(*client_, endpoint_, expand(call, resource, query), items_key,
max_pages);
if (items.as_array().size() > max_items)
throw GoogleError(502, "RESULT_TOO_LARGE",
"more than " + std::to_string(max_items) +
" items; narrow the filter",
endpoint_.name);
return items;
}
: OperationService(std::move(client), endpoints::aiplatform_beta(engine.location()),
engine.str(), std::move(sleeper)),
engine_name_(std::move(engine)) {}
} // namespace molo::google::sessions
+5 -27
View File
@@ -1,48 +1,26 @@
#pragma once
// Base of Sessions and MemoryBank: one validated Agent Engine, the v1beta1
// aiplatform endpoint of its location, table-driven requests (calls.h) and
// long-running operation handling shared by both.
// Base of Sessions and MemoryBank: one validated Agent Engine and the v1beta1
// aiplatform endpoint of its location. Table-driven requests and the
// operations surface come from OperationService.
#include <memory>
#include <string>
#include "google/operation.h"
#include "google/service.h"
#include "google/sessions/calls.h"
#include "google/sessions/names.h"
#include "google/sessions/operation_service.h"
namespace molo::google::sessions {
class EngineService : public Service {
class EngineService : public OperationService {
public:
const EngineName& engine() const { return engine_name_; }
// Raw operation document (GET) and cancel (POST :cancel). The name must be
// an operation of this engine; nothing else is reachable through here.
clients::body::Json operation(const std::string& operation_name) const;
void cancel_operation(const std::string& operation_name) const;
// Polls until done (hard caps in OperationCaps); throws on failure.
Operation wait(const std::string& operation_name) const;
protected:
EngineService(std::shared_ptr<GoogleClient> client, EngineName engine,
Sleeper sleeper);
// One table-driven request. `resource` fills the {parent} / {name} slot.
clients::body::Json send(Call call, const std::string& resource,
const clients::body::Json* body = nullptr,
const std::string& query = "") const;
// Follows an Operation reply to completion (done replies are checked).
Operation settle(const clients::body::Json& reply) const;
// Paged list through the table; caps pages and total items.
clients::body::Json list_items(Call call, const std::string& resource,
const std::string& query,
const std::string& items_key,
std::size_t max_pages, std::size_t max_items) const;
EngineName engine_name_;
Sleeper sleeper_;
};
} // namespace molo::google::sessions
+5
View File
@@ -175,4 +175,9 @@ void MemoryBank::rollback(const std::string& memory_id,
settle(send(Call::kMemoryRollback, engine_name_.memory(memory_id), &body));
}
std::vector<Operation> MemoryBank::list_memory_operations(
const std::string& memory_id, const OperationListOptions& options) const {
return list_operations(engine_name_.memory(memory_id), options);
}
} // namespace molo::google::sessions
+4
View File
@@ -41,6 +41,10 @@ class MemoryBank : public EngineService {
MemoryRevision get_revision(const std::string& memory_id,
const std::string& revision_id) const;
void rollback(const std::string& memory_id, const std::string& revision_id) const;
// Operations that belong to one memory (update, rollback runs).
std::vector<Operation> list_memory_operations(
const std::string& memory_id, const OperationListOptions& options = {}) const;
};
} // namespace molo::google::sessions
+37
View File
@@ -59,6 +59,35 @@ EngineName::EngineName(std::string full) : full_(std::move(full)) {
if (!valid_segment(engine_)) bad("engine name: bad engine id");
}
LocationName::LocationName(std::string full) : full_(std::move(full)) {
if (full_.empty() || full_.size() > SessionsCaps::kMaxNameChars)
bad("location name missing or too long");
std::vector<std::string> parts;
std::string cur;
for (char c : full_) {
if (c == '/') {
parts.push_back(cur);
cur.clear();
} else {
cur.push_back(c);
}
}
parts.push_back(cur);
if (parts.size() != 4 || parts[0] != "projects" || parts[2] != "locations")
bad("location must look like projects/{p}/locations/{l}");
project_ = parts[1];
location_ = parts[3];
if (!project_ok(project_)) bad("location name: bad project");
if (location_.empty() || location_.size() > 64) bad("location name: bad location");
for (char c : location_)
if (!id_char(c)) bad("location name: bad location");
}
std::string LocationName::serving_profile(const std::string& profile_id) const {
Check::serving_profile_id(profile_id);
return full_ + "/servingProfiles/" + profile_id;
}
std::string EngineName::session(const std::string& session_id) const {
Check::session_id(session_id);
return full_ + "/sessions/" + session_id;
@@ -77,6 +106,14 @@ void Check::session_id(const std::string& id) {
if (!id_char(c)) bad("session id allows only a-z 0-9 -");
}
void Check::serving_profile_id(const std::string& id) {
if (id.empty() || id.size() > SessionsCaps::kMaxIdChars)
bad("serving profile id must be 1.." + std::to_string(SessionsCaps::kMaxIdChars) +
" characters");
for (char c : id)
if (!id_char(c)) bad("serving profile id allows only a-z 0-9 -");
}
void Check::memory_id(const std::string& id) {
if (id.empty() || id.size() > SessionsCaps::kMaxIdChars)
bad("memory id must be 1.." + std::to_string(SessionsCaps::kMaxIdChars) +
+19
View File
@@ -29,6 +29,22 @@ class EngineName {
std::string full_, project_, location_, engine_;
};
// "projects/{project}/locations/{location}": the root of location-level
// resources (serving profiles).
class LocationName {
public:
explicit LocationName(std::string full); // throws when malformed
const std::string& str() const { return full_; }
const std::string& project() const { return project_; }
const std::string& location() const { return location_; }
std::string serving_profile(const std::string& profile_id) const;
private:
std::string full_, project_, location_;
};
using StringMap = std::map<std::string, std::string>;
// Input validators.
@@ -36,6 +52,9 @@ class Check {
public:
// Session id: 1..63 of [a-z0-9-].
static void session_id(const std::string& id);
// Serving profile id: same charset as a session id (Google's exact rule is
// not published, see SPEC Unverified).
static void serving_profile_id(const std::string& id);
// Memory id: 1..63 of [a-z0-9-], starts with a letter, ends alphanumeric.
static void memory_id(const std::string& id);
static void text(const std::string& field, const std::string& value,
+92
View File
@@ -0,0 +1,92 @@
#include "google/sessions/operation_names.h"
#include <vector>
#include "google/errors.h"
#include "google/resource.h"
#include "google/sessions/caps.h"
namespace molo::google::sessions {
namespace {
[[noreturn]] void bad(const std::string& message) { throw GoogleError::invalid(message); }
std::vector<std::string> parts_of(const std::string& s) {
std::vector<std::string> out;
std::string cur;
for (char c : s) {
if (c == '/') {
out.push_back(cur);
cur.clear();
} else {
cur.push_back(c);
}
}
out.push_back(cur);
return out;
}
void check_root_prefix(const std::string& root, const std::string& name) {
if (name.size() > SessionsCaps::kMaxNameChars) bad("operation name too long");
if (name.size() <= root.size() + 1 || name.compare(0, root.size() + 1, root + "/") != 0)
bad("operation name must belong to " + root);
}
} // namespace
OperationName OperationName::classify(const std::string& root, const std::string& rest,
const std::string& full, bool want_operation) {
bool location_root = root.find("/reasoningEngines/") == std::string::npos;
std::vector<std::string> p;
if (!rest.empty()) p = parts_of(rest);
for (const std::string& seg : p)
if (!valid_segment(seg)) bad("operation name has an empty or invalid segment");
if (want_operation) {
std::size_t n = p.size();
if (n < 2 || p[n - 2] != "operations") bad("not an operation name");
p.resize(n - 2);
}
std::size_t n = p.size();
if (n == 0) {
if (location_root) bad("a location has no operations here; name a serving profile");
return OperationName(full, OperationOwner::kEngine);
}
if (n == 2 && !location_root && p[0] == "sessions")
return OperationName(full, OperationOwner::kSession);
if (n == 2 && !location_root && p[0] == "memories")
return OperationName(full, OperationOwner::kMemory);
if (n == 2 && location_root && p[0] == "servingProfiles")
return OperationName(full, OperationOwner::kServingProfile);
bad("operation parent must be the engine, a session, a memory or a serving profile");
}
OperationName OperationName::parse(const std::string& root, const std::string& name) {
check_root_prefix(root, name);
return classify(root, name.substr(root.size() + 1), name, true);
}
OperationName OperationName::parse_parent(const std::string& root,
const std::string& parent) {
if (parent == root) return classify(root, "", parent, false);
check_root_prefix(root, parent);
return classify(root, parent.substr(root.size() + 1), parent, false);
}
Call OperationName::call(OperationVerb verb) const {
static constexpr Call kTable[4][5] = {
{Call::kOperationGet, Call::kOperationCancel, Call::kOperationList,
Call::kOperationDelete, Call::kOperationWait},
{Call::kSessionOperationGet, Call::kSessionOperationCancel,
Call::kSessionOperationList, Call::kSessionOperationDelete,
Call::kSessionOperationWait},
{Call::kMemoryOperationGet, Call::kMemoryOperationCancel,
Call::kMemoryOperationList, Call::kMemoryOperationDelete,
Call::kMemoryOperationWait},
{Call::kServingProfileOperationGet, Call::kServingProfileOperationCancel,
Call::kServingProfileOperationList, Call::kServingProfileOperationDelete,
Call::kServingProfileOperationWait}};
return kTable[static_cast<int>(owner_)][static_cast<int>(verb)];
}
} // namespace molo::google::sessions
+44
View File
@@ -0,0 +1,44 @@
#pragma once
// A validated long-running operation name and the table row that serves each
// verb for it. Discovery lists the same five operations methods (get, list,
// cancel, delete, wait) under the Agent Engine, under each session, under
// each memory and under each serving profile; the owner is read from the
// name so a caller can never reach an operation outside the root it passed.
#include <string>
#include "google/sessions/calls.h"
namespace molo::google::sessions {
enum class OperationOwner { kEngine, kSession, kMemory, kServingProfile };
enum class OperationVerb { kGet, kCancel, kList, kDelete, kWait };
class OperationName {
public:
// `root` is an engine name (owners engine, session, memory) or a location
// name "projects/{p}/locations/{l}" (owner serving profile). `name` must be
// "{root}[/{sessions|memories|servingProfiles}/{id}]/operations/{op}".
// Throws GoogleError::invalid otherwise.
static OperationName parse(const std::string& root, const std::string& name);
// A list parent: "{root}", "{root}/sessions/{id}", "{root}/memories/{id}" or
// "{root}/servingProfiles/{id}". Same validation, no trailing operation.
static OperationName parse_parent(const std::string& root, const std::string& parent);
const std::string& str() const { return full_; }
OperationOwner owner() const { return owner_; }
// The table row serving a verb for this owner.
Call call(OperationVerb verb) const;
private:
OperationName(std::string full, OperationOwner owner)
: full_(std::move(full)), owner_(owner) {}
static OperationName classify(const std::string& root, const std::string& rest,
const std::string& full, bool want_operation);
std::string full_;
OperationOwner owner_;
};
} // namespace molo::google::sessions
+123
View File
@@ -0,0 +1,123 @@
#include "google/sessions/operation_service.h"
#include "clients/url.h"
#include "google/errors.h"
#include "google/sessions/caps.h"
#include "google/sessions/names.h"
namespace molo::google::sessions {
using clients::body::Json;
OperationService::OperationService(std::shared_ptr<GoogleClient> client,
ServiceEndpoint endpoint, std::string root,
Sleeper sleeper)
: Service(std::move(client), std::move(endpoint)),
root_(std::move(root)),
sleeper_(std::move(sleeper)) {}
Json OperationService::send(Call call, const std::string& resource, const Json* body,
const std::string& query) const {
const CallSpec& row = spec_of(call);
return client_->request(verb_of(row), endpoint_, expand(call, resource, query), body);
}
Operation OperationService::settle(const Json& reply) const {
Operation op = Operation::from_json(reply);
if (op.done) {
if (op.failed())
throw GoogleError(502, "OPERATION_FAILED", op.error_message, endpoint_.name);
return op;
}
if (op.name.empty())
throw GoogleError(502, "EMPTY_RESPONSE", "no operation returned", endpoint_.name);
return wait(op.name);
}
bool list_over_limit(std::size_t item_count, bool more_pages, std::size_t page_index,
std::size_t max_pages, std::size_t max_items) {
return item_count > max_items || (more_pages && page_index + 1 >= max_pages);
}
Json OperationService::operation(const std::string& operation_name) const {
OperationName name = OperationName::parse(root_, operation_name);
return send(name.call(OperationVerb::kGet), name.str());
}
void OperationService::cancel_operation(const std::string& operation_name) const {
OperationName name = OperationName::parse(root_, operation_name);
Json empty = Json::object();
send(name.call(OperationVerb::kCancel), name.str(), &empty);
}
void OperationService::delete_operation(const std::string& operation_name) const {
OperationName name = OperationName::parse(root_, operation_name);
send(name.call(OperationVerb::kDelete), name.str());
}
Operation OperationService::wait(const std::string& operation_name) const {
OperationName name = OperationName::parse(root_, operation_name);
return wait_operation(*client_, endpoint_, name.str(), sleeper_);
}
Operation OperationService::wait_server(const std::string& operation_name,
int timeout_seconds) const {
OperationName name = OperationName::parse(root_, operation_name);
if (timeout_seconds < 1 ||
timeout_seconds > static_cast<int>(SessionsCaps::kMaxServerWaitSeconds))
throw GoogleError::invalid("timeout_seconds must be 1.." +
std::to_string(SessionsCaps::kMaxServerWaitSeconds));
Json empty = Json::object();
Operation op = Operation::from_json(
send(name.call(OperationVerb::kWait), name.str(), &empty,
query_of({{"timeout", std::to_string(timeout_seconds) + "s"}})));
if (op.done && op.failed())
throw GoogleError(502, "OPERATION_FAILED", op.error_message, endpoint_.name);
return op;
}
std::vector<Operation> OperationService::list_operations(
const std::string& parent, const OperationListOptions& options) const {
OperationName where = OperationName::parse_parent(root_, parent.empty() ? root_ : parent);
Check::expression("filter", options.filter);
Check::page_size(options.page_size, SessionsCaps::kPageSize);
Json items = list_items(
where.call(OperationVerb::kList), where.str(),
query_of({{"filter", options.filter},
{"pageSize", options.page_size > 0 ? std::to_string(options.page_size) : ""}}),
"operations", SessionsCaps::kMaxListPages, SessionsCaps::kMaxListItems);
std::vector<Operation> out;
for (const Json& item : items.as_array()) out.push_back(Operation::from_json(item));
return out;
}
Json OperationService::list_items(Call call, const std::string& resource,
const std::string& query, const std::string& items_key,
std::size_t max_pages, std::size_t max_items) const {
// Own loop instead of list_all: list_all stops silently at max_pages, and a
// short page size would hide that. Anything left over is a loud error.
std::string path = expand(call, resource, query);
Json items = Json::array();
std::string token;
for (std::size_t page = 0;; ++page) {
std::string url = path;
if (!token.empty())
url += (url.find('?') == std::string::npos ? "?" : "&") +
std::string("pageToken=") + clients::Url::encode_component(token);
Json reply = client_->request(clients::Method::kGet, endpoint_, url, nullptr);
if (const Json* arr = reply.is_object() ? reply.find(items_key) : nullptr;
arr && arr->is_array())
for (const Json& item : arr->as_array()) items.push(item);
const Json* next = reply.is_object() ? reply.find("nextPageToken") : nullptr;
token = next && next->is_string() ? next->as_string() : "";
if (list_over_limit(items.as_array().size(), !token.empty(), page, max_pages,
max_items))
throw GoogleError(502, "RESULT_TOO_LARGE",
"more than " + std::to_string(max_items) + " items or " +
std::to_string(max_pages) + " pages; narrow the filter",
endpoint_.name);
if (token.empty()) return items;
}
}
} // namespace molo::google::sessions
+72
View File
@@ -0,0 +1,72 @@
#pragma once
// Table-driven requests and the whole operations surface (get, list, cancel,
// delete, wait on the server, wait by polling) for one validated root: an
// Agent Engine (Sessions, MemoryBank) or a location (ServingProfiles). The
// root bounds every operation name a caller can reach.
#include <memory>
#include <string>
#include <vector>
#include "google/operation.h"
#include "google/service.h"
#include "google/sessions/calls.h"
#include "google/sessions/operation_names.h"
namespace molo::google::sessions {
struct OperationListOptions {
std::string filter; // AIP-160 on name, done, ...
int page_size = 0; // 0: Google default
};
// True when a list must stop loudly: more items than max_items, or a further
// page exists after page `page_index` (0 based) used up max_pages. Lists never
// truncate silently; the caller narrows the filter instead.
bool list_over_limit(std::size_t item_count, bool more_pages, std::size_t page_index,
std::size_t max_pages, std::size_t max_items);
class OperationService : public Service {
public:
// Raw operation document (GET).
clients::body::Json operation(const std::string& operation_name) const;
// POST :cancel. Best effort at Google; the operation may still finish.
void cancel_operation(const std::string& operation_name) const;
// Destructive: removes the operation record (DELETE). Explicit method; it
// never cancels the work.
void delete_operation(const std::string& operation_name) const;
// Polls by GET until done (OperationCaps); throws on failure.
Operation wait(const std::string& operation_name) const;
// One server-side wait (POST :wait?timeout=Ns), 1..kMaxServerWaitSeconds.
// Returns the operation as Google answers it: done may still be false when
// the timeout passed first. A failed operation throws.
Operation wait_server(const std::string& operation_name, int timeout_seconds) const;
// Operations under `parent` (default: the root engine; for a location root
// a serving profile name is required). Capped by SessionsCaps list limits.
std::vector<Operation> list_operations(const std::string& parent = "",
const OperationListOptions& options = {}) const;
const std::string& root() const { return root_; }
protected:
OperationService(std::shared_ptr<GoogleClient> client, ServiceEndpoint endpoint,
std::string root, Sleeper sleeper);
// One table-driven request. `resource` fills the {parent} / {name} slot.
clients::body::Json send(Call call, const std::string& resource,
const clients::body::Json* body = nullptr,
const std::string& query = "") const;
// Follows an Operation reply to completion (done replies are checked).
Operation settle(const clients::body::Json& reply) const;
// Paged list through the table; caps pages and total items.
clients::body::Json list_items(Call call, const std::string& resource,
const std::string& query,
const std::string& items_key, std::size_t max_pages,
std::size_t max_items) const;
std::string root_;
Sleeper sleeper_;
};
} // namespace molo::google::sessions
+165
View File
@@ -0,0 +1,165 @@
#include "google/sessions/serving_profile.h"
#include "google/errors.h"
#include "google/resource.h"
#include "google/sessions/caps.h"
namespace molo::google::sessions {
using clients::body::Json;
const char* serving_scope_name(ServingScope scope) {
switch (scope) {
case ServingScope::kGeminiLive: return "GEMINI_LIVE";
case ServingScope::kInteractionsApi: return "INTERACTIONS_API";
case ServingScope::kResponseApi: return "RESPONSE_API";
}
return "GEMINI_LIVE";
}
ServingScope serving_scope_from(const std::string& name) {
for (ServingScope s : {ServingScope::kGeminiLive, ServingScope::kInteractionsApi,
ServingScope::kResponseApi})
if (name == serving_scope_name(s)) return s;
throw GoogleError::invalid(
"scope must be GEMINI_LIVE, INTERACTIONS_API or RESPONSE_API");
}
namespace {
void check_kms(const std::string& key) {
if (key.empty()) return;
Check::text("kms_key_name", key, SessionsCaps::kMaxKmsKeyChars);
if (key.rfind("projects/", 0) != 0 || key.find("/cryptoKeys/") == std::string::npos ||
key.find("..") != std::string::npos || key.find('?') != std::string::npos)
throw GoogleError::invalid(
"kms_key_name must be projects/{p}/locations/{l}/keyRings/{k}/cryptoKeys/{c}");
}
Json cmek(const std::string& key) {
Json spec = Json::object();
spec.set("kmsKeyName", Json(key));
Json out = Json::object();
out.set("encryptionSpec", spec);
return out;
}
} // namespace
void ServingProfileSpec::validate() const {
Check::serving_profile_id(profile_id);
Check::text("display_name", display_name, SessionsCaps::kMaxDisplayChars, true);
Check::text("description", description, SessionsCaps::kMaxDescriptionChars);
check_kms(kms_key_name);
}
Json ServingProfileSpec::to_json() const {
Json out = Json::object();
out.set("displayName", Json(display_name));
if (!description.empty()) out.set("description", Json(description));
out.set("scope", Json(serving_scope_name(scope)));
if (!kms_key_name.empty()) out.set("cmekConfig", cmek(kms_key_name));
return out;
}
void ServingProfilePatch::validate() const {
Check::serving_profile_id(profile_id);
Check::text("update_mask", update_mask, 256, true);
for (char c : update_mask) {
bool ok = (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == ',' || c == '.';
if (!ok) throw GoogleError::invalid("update_mask allows letters, comma, dot");
}
Check::text("display_name", display_name, SessionsCaps::kMaxDisplayChars);
Check::text("description", description, SessionsCaps::kMaxDescriptionChars);
check_kms(kms_key_name);
}
Json ServingProfilePatch::to_json() const {
Json out = Json::object();
if (!display_name.empty()) out.set("displayName", Json(display_name));
if (!description.empty()) out.set("description", Json(description));
if (!kms_key_name.empty()) out.set("cmekConfig", cmek(kms_key_name));
return out;
}
std::string ServingProfile::id() const {
std::size_t slash = name.rfind('/');
return slash == std::string::npos ? name : name.substr(slash + 1);
}
ServingProfile ServingProfile::from_json(const Json& doc) {
ServingProfile p;
p.name = str_at(doc, "name");
p.display_name = str_at(doc, "displayName");
p.description = str_at(doc, "description");
p.scope = str_at(doc, "scope");
p.create_time = str_at(doc, "createTime");
p.update_time = str_at(doc, "updateTime");
if (const Json* c = doc.is_object() ? doc.find("cmekConfig") : nullptr)
if (const Json* e = c->is_object() ? c->find("encryptionSpec") : nullptr)
p.kms_key_name = str_at(*e, "kmsKeyName");
return p;
}
Json ServingProfile::to_json() const {
Json out = Json::object();
out.set("name", Json(name));
out.set("display_name", Json(display_name));
out.set("description", Json(description));
out.set("scope", Json(scope));
out.set("kms_key_name", Json(kms_key_name));
out.set("create_time", Json(create_time));
out.set("update_time", Json(update_time));
return out;
}
ServingProfiles::ServingProfiles(std::shared_ptr<GoogleClient> client,
LocationName location, Sleeper sleeper)
: OperationService(std::move(client), endpoints::aiplatform_beta(location.location()),
location.str(), std::move(sleeper)),
location_(std::move(location)) {}
ServingProfile ServingProfiles::create(const ServingProfileSpec& spec) const {
spec.validate();
Json body = spec.to_json();
Operation op = settle(send(Call::kServingProfileCreate, location_.str(), &body,
query_of({{"servingProfileId", spec.profile_id}})));
if (op.response.is_object() && !str_at(op.response, "name").empty())
return ServingProfile::from_json(op.response);
return get(spec.profile_id);
}
ServingProfile ServingProfiles::get(const std::string& profile_id) const {
return ServingProfile::from_json(
send(Call::kServingProfileGet, location_.serving_profile(profile_id)));
}
std::vector<ServingProfile> ServingProfiles::list(int page_size) const {
Check::page_size(page_size, SessionsCaps::kPageSize);
Json items = list_items(
Call::kServingProfileList, location_.str(),
query_of({{"pageSize", page_size > 0 ? std::to_string(page_size) : ""}}),
"servingProfiles", SessionsCaps::kMaxListPages, SessionsCaps::kMaxListItems);
std::vector<ServingProfile> out;
for (const Json& item : items.as_array()) out.push_back(ServingProfile::from_json(item));
return out;
}
ServingProfile ServingProfiles::patch(const ServingProfilePatch& patch) const {
patch.validate();
Json body = patch.to_json();
return ServingProfile::from_json(
send(Call::kServingProfilePatch, location_.serving_profile(patch.profile_id), &body,
query_of({{"updateMask", patch.update_mask}})));
}
void ServingProfiles::remove(const std::string& profile_id) const {
send(Call::kServingProfileDelete, location_.serving_profile(profile_id));
}
std::vector<Operation> ServingProfiles::list_profile_operations(
const std::string& profile_id, const OperationListOptions& options) const {
return list_operations(location_.serving_profile(profile_id), options);
}
} // namespace molo::google::sessions
+82
View File
@@ -0,0 +1,82 @@
#pragma once
// Serving profiles (aiplatform v1beta1 projects.locations.servingProfiles):
// location-level settings for resource-less GenAI serving (Gemini Live,
// Interactions API, Response API). Not engine scoped, so ServingProfiles
// takes a location, not an Agent Engine.
#include <memory>
#include <string>
#include <vector>
#include "google/sessions/names.h"
#include "google/sessions/operation_service.h"
namespace molo::google::sessions {
// Discovery enum ServingProfile.scope (without the unused UNSPECIFIED).
enum class ServingScope { kGeminiLive, kInteractionsApi, kResponseApi };
const char* serving_scope_name(ServingScope scope);
// Throws GoogleError::invalid for any other string.
ServingScope serving_scope_from(const std::string& name);
struct ServingProfileSpec { // Input to create.
std::string profile_id; // Required, becomes the servingProfileId query.
std::string display_name; // Required, up to 128 characters.
std::string description;
ServingScope scope = ServingScope::kGeminiLive;
std::string kms_key_name; // Optional CMEK: projects/.../cryptoKeys/...
void validate() const;
clients::body::Json to_json() const;
};
// PATCH of one profile; `scope` is not patchable here (not in the patch row).
struct ServingProfilePatch {
std::string profile_id;
std::string display_name;
std::string description;
std::string kms_key_name;
std::string update_mask; // Required: displayName,description,cmekConfig
void validate() const;
clients::body::Json to_json() const;
};
struct ServingProfile {
std::string name;
std::string display_name;
std::string description;
std::string scope; // As Google sent it, kept even when unknown to the enum.
std::string kms_key_name;
std::string create_time, update_time;
std::string id() const; // Last component of name.
static ServingProfile from_json(const clients::body::Json& doc);
clients::body::Json to_json() const;
};
class ServingProfiles : public OperationService {
public:
ServingProfiles(std::shared_ptr<GoogleClient> client, LocationName location,
Sleeper sleeper = nullptr);
const LocationName& location() const { return location_; }
ServingProfile create(const ServingProfileSpec& spec) const; // waits
ServingProfile get(const std::string& profile_id) const;
std::vector<ServingProfile> list(int page_size = 0) const;
ServingProfile patch(const ServingProfilePatch& patch) const;
// Destructive: explicit method.
void remove(const std::string& profile_id) const;
// Operations of one serving profile (name from list_operations or create).
std::vector<Operation> list_profile_operations(const std::string& profile_id,
const OperationListOptions& o = {}) const;
private:
LocationName location_;
};
} // namespace molo::google::sessions
+5
View File
@@ -86,4 +86,9 @@ std::vector<SessionEvent> Sessions::list_events(const std::string& session_id,
return out;
}
std::vector<Operation> Sessions::list_session_operations(
const std::string& session_id, const OperationListOptions& options) const {
return list_operations(engine_name_.session(session_id), options);
}
} // namespace molo::google::sessions
+4
View File
@@ -30,6 +30,10 @@ class Sessions : public EngineService {
void append_event(const std::string& session_id, const SessionEvent& event) const;
std::vector<SessionEvent> list_events(const std::string& session_id,
const EventListOptions& options = {}) const;
// Operations that belong to one session (create, compact, delete runs).
std::vector<Operation> list_session_operations(
const std::string& session_id, const OperationListOptions& options = {}) const;
};
} // namespace molo::google::sessions
+47 -1
View File
@@ -34,6 +34,7 @@ ENUMS = [
("Memory", "memoryType", ["NATURAL_LANGUAGE_COLLECTION", "STRUCTURED_PROFILE"]),
("CompactionConfigLlmSummarizationConfig", "mode", ["AUTO"]),
("CompactionConfigEventEditingConfig", "mode", ["AUTO"]),
("ServingProfile", "scope", ["GEMINI_LIVE", "INTERACTIONS_API", "RESPONSE_API"]),
]
# (schema suffix, property) read by the response parsers.
@@ -51,6 +52,12 @@ RESPONSE_KEYS = [
("MemoryRevision", "fact"), ("MemoryRevision", "context"),
("MemoryRevision", "labels"), ("MemoryRevision", "createTime"),
("MemoryRevision", "expireTime"),
("ListServingProfilesResponse", "servingProfiles"),
("ListServingProfilesResponse", "nextPageToken"),
("ServingProfile", "name"), ("ServingProfile", "displayName"),
("ServingProfile", "description"), ("ServingProfile", "scope"),
("ServingProfile", "createTime"), ("ServingProfile", "updateTime"),
("ServingProfile", "cmekConfig"),
("Session", "name"), ("Session", "createTime"), ("Session", "updateTime"),
("Session", "expireTime"), ("Memory", "name"), ("Memory", "expireTime"),
]
@@ -73,12 +80,30 @@ NESTED = [
("MemoryFilter", "key op negate value"),
("MemoryMetadataValue", "stringValue doubleValue boolValue timestampValue"),
("MemoryTopicId", "customMemoryTopicLabel managedMemoryTopic"),
("ServingProfileCmekConfig", "encryptionSpec"),
("EncryptionSpec", "kmsKeyName"),
("CompactionConfig", "summarization eventEditing"),
("CompactionConfigLlmSummarizationConfig", "mode"),
("CompactionConfigEventEditingConfig", "mode"),
]
# Discovery methods this module owns: every one must be a table row.
OWNED_PREFIXES = [
"aiplatform.projects.locations.reasoningEngines.operations.",
"aiplatform.projects.locations.reasoningEngines.sessions.",
"aiplatform.projects.locations.reasoningEngines.memories.",
"aiplatform.projects.locations.servingProfiles.",
]
# method id -> reason it is not wrapped (none today).
EXCLUDED = {}
def collect_methods(res, out):
out.extend(res.get("methods", {}).values())
for r in res.get("resources", {}).values():
collect_methods(r, out)
def load(path):
if path:
with open(path, "r", encoding="utf-8") as f:
@@ -144,7 +169,7 @@ def main():
errors.append("calls.h: enum Call and table rows differ")
for row in rows:
mid = prefix + row["method"]
mid = row["method"] if row["method"].startswith("aiplatform.") else prefix + row["method"]
m = find_method(doc, mid)
if m is None:
errors.append("%s: method %s absent" % (row["call"], mid))
@@ -171,6 +196,25 @@ def main():
errors.append("%s: discovery has a request body %s the table omits" %
(row["call"], m["request"]["$ref"]))
# Coverage: every Discovery method of the resources this module owns must
# be a table row (or be listed, with a reason, in EXCLUDED).
declared_ids = set()
for row in rows:
declared_ids.add(row["method"] if row["method"].startswith("aiplatform.")
else prefix + row["method"])
owned = []
collect_methods(doc, owned)
covered = 0
for m in owned:
if not any(m["id"].startswith(p) for p in OWNED_PREFIXES):
continue
if m["id"] in declared_ids:
covered += 1
elif m["id"] in EXCLUDED:
continue
else:
errors.append("discovery method %s is not in the call table" % m["id"])
for suffix, prop, values in ENUMS:
s = schemas.get(schema_prefix + suffix, {}).get("properties", {}).get(prop)
if s is None:
@@ -182,6 +226,8 @@ def main():
for v in values:
if v not in allowed:
errors.append("enum value %s absent from %s.%s" % (v, suffix, prop))
if "operations" not in schemas.get("GoogleLongrunningListOperationsResponse", {}).get("properties", {}):
errors.append("response key GoogleLongrunningListOperationsResponse.operations absent")
for suffix, prop in RESPONSE_KEYS:
if prop not in schemas.get(schema_prefix + suffix, {}).get("properties", {}):
errors.append("response key %s.%s absent" % (suffix, prop))