& in) {
+ std::string s = field(in, "scope");
+ if (s != "registry" && s != "gateways" && s != "policies")
+ bad("scope must be registry, gateways or policies");
+ return s;
+ };
+ router.post("/agent/registry/operations/list", "agent-registry-operations", [demo, scope_of](fw::Request req) {
+ auto in = fw::parse_json_object_flat(req.body);
+ std::string scope = scope_of(in);
+ return guarded([&] {
+ reg::ListResult ops = scope == "registry" ? demo->registry().operations()
+ : scope == "gateways" ? demo->gateway().operations()
+ : demo->policies().operations();
+ Json j = list_answer(ops, "operations");
+ j.set("scope", Json(scope));
return json_reply(j);
});
});
+ router.post("/agent/registry/operations/cancel", "agent-registry-operation-cancel",
+ [demo, scope_of](fw::Request req) {
+ auto in = fw::parse_json_object_flat(req.body);
+ std::string scope = scope_of(in);
+ std::string id = field(in, "id");
+ if (!google::valid_segment(id)) bad("id is empty or has invalid characters");
+ return guarded([&] {
+ Json r = scope == "registry" ? demo->registry().cancel_operation(id)
+ : scope == "gateways" ? demo->gateway().cancel_operation(id)
+ : demo->policies().cancel_operation(id);
+ Json j = Json::object();
+ j.set("scope", Json(scope));
+ j.set("cancel_requested", Json(true));
+ j.set("reply", r);
+ return json_reply(j);
+ });
+ });
+
+ router.del("/agent/registry/operations", "agent-registry-operation-delete", [demo](fw::Request req) {
+ std::string scope = req.query_or("scope", "");
+ std::string id = req.query_or("id", "");
+ if (scope != "registry" && scope != "gateways" && scope != "policies")
+ bad("scope must be registry, gateways or policies");
+ if (!google::valid_segment(id)) bad("id is empty or has invalid characters");
+ return guarded([&] {
+ Json r = scope == "registry" ? demo->registry().delete_operation(id)
+ : scope == "gateways" ? demo->gateway().delete_operation(id)
+ : demo->policies().delete_operation(id);
+ Json j = Json::object();
+ j.set("deleted", Json(true));
+ j.set("reply", r);
+ return json_reply(j);
+ });
+ });
+
+ // ---- IAM deny policies (iam v2) and boundary bindings (iam v3).
+ router.post("/agent/registry/deny-policies/list", "agent-registry-deny-policies", [demo](fw::Request req) {
+ auto in = fw::parse_json_object_flat(req.body);
+ std::string number = field(in, "project_number");
+ if (number.empty() || number.size() > 20 || number.find_first_not_of("0123456789") != std::string::npos)
+ bad("project_number must be numeric");
+ return guarded([&] {
+ return json_reply(list_answer(
+ demo->identity().deny_policies(reg::AgentIdentity::attachment_for_project(number)),
+ "policies"));
+ });
+ });
+
+ router.post("/agent/registry/boundaries/bindings", "agent-registry-boundary-bindings",
+ [demo](fw::Request req) {
+ auto in = fw::parse_json_object_flat(req.body);
+ std::string org = field(in, "org_id");
+ std::string id = field(in, "id");
+ if (org.empty() || org.size() > 20 || org.find_first_not_of("0123456789") != std::string::npos)
+ bad("org_id must be numeric");
+ if (!google::valid_segment(id)) bad("id is empty or has invalid characters");
+ return guarded([&] {
+ return json_reply(list_answer(demo->identity().boundary_bindings(org, id), "bindings"));
+ });
+ });
+
// ---- Identity of one deployed agent (engine id).
router.post("/agent/registry/identity", "agent-registry-identity", [demo](fw::Request req) {
auto in = fw::parse_json_object_flat(req.body);
diff --git a/example/app/agent/SessionsDemo.cpp b/example/app/agent/SessionsDemo.cpp
index bf81883..68773aa 100644
--- a/example/app/agent/SessionsDemo.cpp
+++ b/example/app/agent/SessionsDemo.cpp
@@ -9,6 +9,7 @@
#include "google/sessions/caps.h"
#include "google/sessions/calls.h"
#include "google/sessions/memory_bank.h"
+#include "google/sessions/serving_profile.h"
#include "google/sessions/sessions.h"
namespace molo::example::app {
@@ -52,6 +53,15 @@ Every call below is a JSON POST (or DELETE) and answers 503
| DELETE /agent/sessions/memories/memory | query: engine, id |
| POST /agent/sessions/memories/profiles | engine, scope_key, scope_value |
| POST /agent/sessions/memories/purge | engine, filter, force?, confirm? (dry run by default) |
+| POST /agent/sessions/operations/list | engine, parent? (engine, session or memory name), filter? |
+| POST /agent/sessions/operations/get | engine, name |
+| POST /agent/sessions/operations/wait | engine, name, timeout_seconds (server-side wait, 1..60) |
+| POST /agent/sessions/operations/cancel | engine, name |
+| DELETE /agent/sessions/operations/operation | query: engine, name |
+| POST /agent/sessions/serving-profiles/list | location? (id or projects/P/locations/L) |
+| POST /agent/sessions/serving-profiles/get | location?, profile_id |
+| POST /agent/sessions/serving-profiles/create | location?, profile_id, display_name, scope, description? |
+| DELETE /agent/sessions/serving-profiles/profile | query: location?, id |