feat(clients): registry: Agent Registry, Agent Gateway, Agent Identity from discovery call table
86-row call table checked against Google discovery documents, typed services, local approval ledger, live read-only tests, /agent/registry demo. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
#pragma once
|
||||
|
||||
// Executes a call from the table. All validation happens before any network
|
||||
// traffic: the call id, path variables, query parameters (only those the
|
||||
// discovery document lists for the call), and the top-level request fields
|
||||
// (only those declared in the table). Lists follow pages under the caps;
|
||||
// mutations wait for their long-running operation (capped).
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "google/operation.h"
|
||||
#include "google/registry/calls.h"
|
||||
|
||||
namespace molo::google::registry {
|
||||
|
||||
struct CallArgs {
|
||||
std::map<std::string, std::string> vars; // {+parent}, {+name}, ...
|
||||
std::map<std::string, std::string> query; // updateMask, filter, ...
|
||||
clients::body::Json body; // Null: no body.
|
||||
};
|
||||
|
||||
class CallRunner {
|
||||
public:
|
||||
CallRunner(std::shared_ptr<GoogleClient> client, std::string location);
|
||||
|
||||
// One request, one reply.
|
||||
clients::body::Json invoke(const std::string& call_id, const CallArgs& args) const;
|
||||
// Follows nextPageToken (RegistryCaps::kMaxPages pages of kPageSize) and
|
||||
// returns the concatenated `items_key` array.
|
||||
clients::body::Json list(const std::string& call_id, const std::string& items_key,
|
||||
const CallArgs& args) const;
|
||||
// invoke + wait for the operation the reply describes; returns
|
||||
// {"operation": name}.
|
||||
clients::body::Json mutate(const std::string& call_id, const CallArgs& args) const;
|
||||
|
||||
// The exact request that invoke() would send: "METHOD path?query". Pure,
|
||||
// no network. Used by tests to compare against the discovery paths.
|
||||
std::string describe(const std::string& call_id, const CallArgs& args) const;
|
||||
|
||||
// Validated updateMask value: non-empty, every root segment is a request
|
||||
// field declared for `call_id`. Throws GoogleError (invalid).
|
||||
static std::string update_mask(const std::string& call_id,
|
||||
const std::vector<std::string>& fields);
|
||||
|
||||
void set_sleeper(Sleeper sleeper) { sleeper_ = std::move(sleeper); }
|
||||
bool configured() const { return client_->configured(); }
|
||||
const std::shared_ptr<GoogleClient>& client() const { return client_; }
|
||||
const std::string& location() const { return location_; }
|
||||
|
||||
private:
|
||||
std::string build_path(const CallSpec& call, const CallArgs& args, bool default_page) const;
|
||||
void check_body(const CallSpec& call, const CallArgs& args) const;
|
||||
|
||||
std::shared_ptr<GoogleClient> client_;
|
||||
std::string location_;
|
||||
Sleeper sleeper_;
|
||||
};
|
||||
|
||||
} // namespace molo::google::registry
|
||||
Reference in New Issue
Block a user