diff --git a/example/app/ai/AnthropicAdminDemo.cpp b/example/app/ai/AnthropicAdminDemo.cpp index 4025f70..3c83791 100644 --- a/example/app/ai/AnthropicAdminDemo.cpp +++ b/example/app/ai/AnthropicAdminDemo.cpp @@ -1,13 +1,349 @@ #include "../AiDemos.hpp" #include "../../fw/Router.hpp" +#include "../../fw/Templates.hpp" +#include "anthropic/admin/calls.h" +#include "anthropic/admin/gateway.h" +#include "anthropic/admin/reports.h" +#include "anthropic/admin/request.h" +#include "anthropic/admin/webhook.h" +#include "llm/error.h" namespace molo::example::app { -// Anthropic Claude: admin API (orgs, workspaces, keys, usage, cost) and managed agents. Stub: the module agent fills this in. +// Anthropic admin: Admin API (organization, users, invites, workspaces, keys, +// service accounts, federation, RBAC, spend limits, plugins, webhooks, Claude +// Tag), usage and cost reports, and the Managed Agents surface, over the real +// src/anthropic/admin package. GET routes need no credential. Every route that +// calls Anthropic is a POST: 503 not_configured without a credential, 422 on +// bad input, 401 credential_rejected for a key of the wrong kind. Anything that +// is not a read is a dry run unless the body says "confirm":true. + +namespace { + +namespace adm = anthropic::admin; +using Json = clients::body::Json; + +constexpr std::size_t kMaxBody = 256 * 1024; + +const char kPage[] = R"ADMIN({% extends "base.html" %} +{% block content %} +

Anthropic admin

+

Organization, workspaces, keys, usage and cost reports, and Managed +Agents. Reads run as is; every write or delete is a dry run until you tick confirm.

+

Checking credentials...

+
+

Organization

+
+

Usage and cost

+ + + +
+

Any call

+ + + + + +
+ +

+
+ + +{% endblock %} +)ADMIN"; + +fw::Response json_out(const Json& j, int status = 200) { + fw::Response res = fw::JsonResponse(j.dump(), status); + res.headers.set("Cache-Control", "no-store"); + return res; +} + +[[noreturn]] void bad(const std::string& why) { throw fw::HttpError(422, "validation_error", why); } + +[[noreturn]] void rethrow(const llm::ApiError& e) { + if (e.type() == "NOT_CONFIGURED") throw fw::HttpError(503, "not_configured", e.message()); + if (e.type() == "credential_rejected") throw fw::HttpError(e.http_status() == 403 ? 403 : 401, "credential_rejected", e.message()); + if (e.type() == "INVALID_ARGUMENT") bad(e.message()); + throw fw::HttpError(502, "anthropic_error", std::to_string(e.http_status()) + " " + e.type() + ": " + e.message()); +} + +template +auto guarded(F&& f) -> decltype(f()) { + try { + return f(); + } catch (const llm::ApiError& e) { + rethrow(e); + } +} + +Json parse_body(const fw::Request& req) { + if (req.body.size() > kMaxBody) throw fw::HttpError(413, "payload_too_large", "body too large"); + if (req.body.empty()) return Json::object(); + try { + Json j = Json::parse(req.body); + if (!j.is_object()) bad("body must be a JSON object"); + return j; + } catch (const clients::body::JsonError&) { + bad("body is not valid JSON"); + } +} + +std::string text(const Json& body, const char* key) { + const Json* v = body.find(key); + if (!v || v->is_null()) return ""; + if (!v->is_string()) bad(std::string(key) + " must be a string"); + return v->as_string(); +} + +bool flag(const Json& body, const char* key) { + const Json* v = body.find(key); + if (!v || v->is_null()) return false; + if (!v->is_bool()) bad(std::string(key) + " must be true or false"); + return v->as_bool(); +} + +std::vector strings(const Json& body, const char* key) { + std::vector out; + const Json* v = body.find(key); + if (!v || v->is_null()) return out; + if (!v->is_array()) bad(std::string(key) + " must be an array of strings"); + for (const Json& s : v->as_array()) { + if (!s.is_string()) bad(std::string(key) + " must be an array of strings"); + out.push_back(s.as_string()); + } + return out; +} + +const char* kind_name(adm::Kind k) { + return k == adm::Kind::kRead ? "read" : k == adm::Kind::kWrite ? "write" : "destructive"; +} +const char* auth_name(adm::Auth a) { + return a == adm::Auth::kAdmin ? "admin_key_or_oauth" : a == adm::Auth::kOAuth ? "oauth_token" : "api_key"; +} + +// Looks a call up by its table name; "name" and "name+beta" forms share names, the +// first row wins (the beta form carries a "beta" suffix in the name). +const adm::CallSpec* find_call(const std::string& name) { + for (std::size_t i = 0; i < adm::call_count(); ++i) + if (name == adm::spec_at(i).name) return &adm::spec_at(i); + return nullptr; +} + +class AdminRoutes { + public: + explicit AdminRoutes(std::shared_ptr gateway) : gateway_(std::move(gateway)) {} + + Json status() const { + Json o = Json::object(); + Json lanes = Json::object(); + for (const adm::LaneInfo& l : gateway_->lanes()) { + Json s = Json::object(); + s.set("env", Json(l.env)); + s.set("state", Json(l.state == adm::LaneState::kReady ? "ready" : l.state == adm::LaneState::kMissing ? "missing" : "rejected")); + if (!l.reason.empty()) s.set("reason", Json(l.reason)); + lanes.set(adm::KeyRules::name_of(l.lane), s); + } + o.set("lanes", lanes); + o.set("configured", Json(gateway_->ready(adm::Auth::kAdmin))); + o.set("calls", Json(static_cast(adm::call_count()))); + o.set("api_version", Json(adm::Gateway::kApiVersion)); + return o; + } + + Json calls() const { + Json arr = Json::array(); + for (std::size_t i = 0; i < adm::call_count(); ++i) { + const adm::CallSpec& s = adm::spec_at(i); + Json c = Json::object(); + c.set("name", Json(s.name)); + c.set("http", Json(s.http)); + c.set("path", Json(s.path)); + c.set("kind", Json(kind_name(s.kind))); + c.set("credential", Json(auth_name(s.auth))); + c.set("beta", Json(s.beta)); + arr.push(c); + } + Json o = Json::object(); + o.set("calls", arr); + return o; + } + + // Generic table-driven call: validate, dry-run non-reads, then send. + fw::Response call(const fw::Request& req) const { + Json b = parse_body(req); + std::string name = text(b, "call"); + if (name.empty()) bad("call is required"); + const adm::CallSpec* spec = find_call(name); + if (!spec) bad("unknown call " + name); + if (spec->wire != adm::Wire::kJson) + bad(name + " is a " + (spec->wire == adm::Wire::kSse ? "stream" : spec->wire == adm::Wire::kRaw ? "download" : "multipart upload") + " call and is not available here"); + adm::Query query; + if (const Json* q = b.find("query")) { + if (!q->is_object()) bad("query must be a JSON object"); + for (const auto& [k, v] : q->as_object()) { + if (v.is_array()) { + for (const Json& item : v.as_array()) { + if (!item.is_string() && !item.is_number()) bad(k + " values must be strings or numbers"); + query.add(k, item.is_string() ? item.as_string() : std::to_string(item.as_int())); + } + } else if (v.is_string()) { + query.set(k, v.as_string()); + } else if (v.is_number()) { + query.set_int(k, v.as_int()); + } else if (v.is_bool()) { + query.set_bool(k, v.as_bool()); + } else { + bad(k + " must be a string, number, boolean or array"); + } + } + } + const Json* body = b.find("body"); + if (body && !body->is_null() && !body->is_object()) bad("body must be a JSON object"); + bool has_body = body && body->is_object() && !body->as_object().empty(); + bool confirm = flag(b, "confirm"); + adm::PreparedRequest p = guarded([&] { + return adm::RequestBuilder::prepare(find_enum(spec), strings(b, "ids"), &query, + (has_body || adm::RequestBuilder::names(spec->body).size() ? body : nullptr), + gateway_->workspace_id()); + }); + if (spec->kind != adm::Kind::kRead && !confirm) { + Json o = Json::object(); + o.set("dry_run", Json(true)); + o.set("would_send", Json(std::string(spec->http) + " " + p.target)); + o.set("kind", Json(kind_name(spec->kind))); + o.set("hint", Json("send confirm:true to run it")); + return json_out(o); + } + return guarded([&] { + auto client = gateway_->client_for(spec->auth); + return json_out(client->request(p.method, p.target, p.body ? &*p.body : nullptr, p.headers)); + }); + } + + fw::Response organization(const fw::Request&) const { + return guarded([&] { + adm::PreparedRequest p = adm::RequestBuilder::prepare(adm::Call::kOrganizationRetrieve, {}, nullptr, nullptr); + return json_out(gateway_->client_for(adm::Auth::kAdmin)->request(p.method, p.target, nullptr, p.headers)); + }); + } + + fw::Response report(const fw::Request& req, int which) const { + Json b = parse_body(req); + std::string start = text(b, "starting_at"); + std::string ending = text(b, "ending_at"); + std::string page = text(b, "page"); + long limit = 0; + if (const Json* l = b.find("limit")) { + if (!l->is_number()) bad("limit must be a number"); + limit = l->as_int(); + } + std::vector group = strings(b, "group_by"); + return guarded([&] { + adm::Query q; + adm::Call c; + if (which == 0) { + adm::MessagesUsageQuery m; + m.starting_at = start; + m.ending_at = ending; + m.limit = limit; + m.page = page; + m.group_by = group; + std::string w = text(b, "bucket_width"); + if (!w.empty()) m.bucket_width = w; + q = m.to_query(); + c = adm::Call::kUsageReportRetrieveMessages; + } else if (which == 1) { + adm::CostQuery m; + m.starting_at = start; + m.ending_at = ending; + m.limit = limit; + m.page = page; + m.group_by = group; + q = m.to_query(); + c = adm::Call::kCostReportRetrieve; + } else { + adm::ClaudeCodeQuery m; + m.starting_at = start; + m.limit = limit; + m.page = page; + q = m.to_query(); + c = adm::Call::kUsageReportRetrieveClaudeCode; + } + adm::PreparedRequest p = adm::RequestBuilder::prepare(c, {}, &q, nullptr); + return json_out(gateway_->client_for(adm::Auth::kAdmin)->request(p.method, p.target, nullptr, p.headers)); + }); + } + + // Local: verifies a webhook signature; no credential involved. + fw::Response verify_webhook(const fw::Request& req) const { + Json b = parse_body(req); + std::string key = text(b, "signing_key"), payload = text(b, "payload"); + if (key.empty()) bad("signing_key is required"); + if (payload.empty()) bad("payload is required"); + std::map h{{"webhook-id", text(b, "webhook_id")}, + {"webhook-timestamp", text(b, "webhook_timestamp")}, + {"webhook-signature", text(b, "webhook_signature")}}; + return guarded([&] { + adm::WebhookVerifier v(key); + std::string why; + bool ok = v.verify(payload, h, static_cast(std::time(nullptr)), &why); + Json o = Json::object(); + o.set("valid", Json(ok)); + if (!ok) o.set("reason", Json(why)); + return json_out(o); + }); + } + + private: + static adm::Call find_enum(const adm::CallSpec* spec) { return spec->call; } + std::shared_ptr gateway_; +}; + +} // namespace + void register_ai_anthropicadmin_demo(fw::Router& router, Services& services) { - (void)router; - (void)services; + auto gateway = adm::Gateway::from_env(); + auto routes = std::make_shared(gateway); + fw::Environment* env = services.templates.get(); + services.templates->add_template("ai_anthropic_admin.html", kPage); + services.add_feature("ai-anthropic-admin", "/ai/anthropic/admin"); + + router.get("/ai/anthropic/admin", "ai-anthropic-admin-page", [env](fw::Request) { + fw::TemplateCtx ctx; + ctx["title"] = std::string("Anthropic admin"); + return fw::Response(200, env->render("ai_anthropic_admin.html", ctx), "text/html; charset=utf-8"); + }); + router.get("/ai/anthropic/admin/status", "ai-anthropic-admin-status", + [routes](fw::Request) { return json_out(routes->status()); }); + router.get("/ai/anthropic/admin/calls", "ai-anthropic-admin-calls", + [routes](fw::Request) { return json_out(routes->calls()); }); + router.post("/ai/anthropic/admin/call", "ai-anthropic-admin-call", + [routes](fw::Request req) { return routes->call(req); }); + router.post("/ai/anthropic/admin/organization", "ai-anthropic-admin-organization", + [routes](fw::Request req) { return routes->organization(req); }); + router.post("/ai/anthropic/admin/usage", "ai-anthropic-admin-usage", + [routes](fw::Request req) { return routes->report(req, 0); }); + router.post("/ai/anthropic/admin/cost", "ai-anthropic-admin-cost", + [routes](fw::Request req) { return routes->report(req, 1); }); + router.post("/ai/anthropic/admin/claude-code", "ai-anthropic-admin-claude-code", + [routes](fw::Request req) { return routes->report(req, 2); }); + router.post("/ai/anthropic/admin/webhook/verify", "ai-anthropic-admin-webhook-verify", + [routes](fw::Request req) { return routes->verify_webhook(req); }); } } // namespace molo::example::app diff --git a/example/assets/ai_anthropic_admin.js b/example/assets/ai_anthropic_admin.js new file mode 100644 index 0000000..c508162 --- /dev/null +++ b/example/assets/ai_anthropic_admin.js @@ -0,0 +1,59 @@ +// Anthropic admin page: thin client over /ai/anthropic/admin/* (all limits server side). +(function () { + "use strict"; + var $ = function (id) { return document.getElementById(id); }; + var out = $("ad-out"), err = $("ad-error"); + + function post(path, body) { + err.textContent = ""; + out.textContent = "..."; + return fetch(path, { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify(body) + }).then(function (res) { + return res.text().then(function (t) { + var j; + try { j = JSON.parse(t); } catch (e) { j = { message: t }; } + if (!res.ok) { + err.textContent = j.message || ("HTTP " + res.status); + out.textContent = ""; + } else { + out.textContent = JSON.stringify(j, null, 2); + } + }); + }).catch(function (e) { err.textContent = String(e); out.textContent = ""; }); + } + function json(id) { + try { return JSON.parse($(id).value || "{}"); } + catch (e) { err.textContent = "Not valid JSON: " + id; return null; } + } + + fetch("/ai/anthropic/admin/status").then(function (r) { return r.json(); }).then(function (s) { + var l = s.lanes || {}; + $("ad-config").textContent = "Admin key: " + (l.admin_key || {}).state + + ", OAuth token: " + (l.oauth_token || {}).state + ", API key: " + (l.api_key || {}).state + + ". " + s.calls + " calls, API version " + s.api_version + "."; + }); + fetch("/ai/anthropic/admin/calls").then(function (r) { return r.json(); }).then(function (d) { + var sel = $("ad-call"); + d.calls.forEach(function (c) { + var o = document.createElement("option"); + o.value = c.name; + o.textContent = c.http + " " + c.name + (c.kind === "read" ? "" : " (" + c.kind + ")"); + sel.appendChild(o); + }); + }); + + $("ad-org").onclick = function () { post("/ai/anthropic/admin/organization", {}); }; + $("ad-run-report").onclick = function () { + var group = $("ad-group").value.split(",").map(function (s) { return s.trim(); }).filter(Boolean); + post("/ai/anthropic/admin/" + $("ad-report").value, { starting_at: $("ad-start").value.trim(), group_by: group }); + }; + $("ad-send").onclick = function () { + var q = json("ad-query"), b = json("ad-body"); + if (!q || !b) return; + var ids = $("ad-ids").value.split(",").map(function (s) { return s.trim(); }).filter(Boolean); + post("/ai/anthropic/admin/call", { call: $("ad-call").value, ids: ids, query: q, body: b, confirm: $("ad-confirm").checked }); + }; +})(); diff --git a/src/anthropic/admin/SPEC.md b/src/anthropic/admin/SPEC.md new file mode 100644 index 0000000..285106d --- /dev/null +++ b/src/anthropic/admin/SPEC.md @@ -0,0 +1,165 @@ +# Anthropic admin and agent platform (`molo::anthropic::admin`) + +Status 2026-10-24. Plan: `plans/17-llm-vendor-platforms.md`, package +"anthropic admin". The Messages, Batches, Files, Models and Skills families +belong to `src/anthropic/core` and are excluded (see `EXCLUDED` in the checker). + +## Scope + +255 calls in one table (`calls.cpp`), 243 read from the official Python SDK +and 12 documented only in the API reference: + +| Credential | Calls | Surface | +|---|---|---| +| Admin API key or `org:admin` OAuth token (125) | organization info, users, invites, workspaces, workspace members and rate limits, API keys, external keys (CMEK), rate limits, compliance settings, RBAC groups and roles, spend limits, plugins, plugin marketplaces, telemetry destinations, organization webhooks, Claude Tag, Enterprise analytics, usage and cost reports, organization-level MCP tunnel views | +| `org:admin` OAuth token only (26) | service accounts (and their workspaces), federation issuers and rules, workspace service accounts | +| Standard API key (104) | Managed Agents: agents (+versions), environments (+work queue), sessions (+events, resources, threads, thread events, SSE streams), deployments, deployment runs, vaults (+credentials), memory stores (+memories, versions), dreams, tunnels (+certificates), user profiles (+action URLs) | + +Managed Agents is public REST (`/v1/agents`, `/v1/sessions`, ...), beta header +`managed-agents-2026-04-01` (other families carry their own beta header, +column `beta`). It uses the standard workspace key, not the admin key, so the +package keeps three credential lanes (below). + +## Module map (one concern per class) + +| File | Class | Concern | +|---|---|---| +| `calls.h/.cpp` | `Call`, `CallSpec` | generated table, the only place paths live | +| `services/*.h/.cpp` | one class per resource group (`Invites`, `Workspaces`, `Agents`, ...) | generated methods, one per row; `list_all` for paged rows | +| `api.h` | `AdminApi` | facade owning every group | +| `credentials.h/.cpp` | `KeyRules`, `Lane` | which key may go in which lane | +| `gateway.h/.cpp` | `Gateway` | three `llm::ApiClient` lanes, lane choice per call, GET SSE | +| `request.h/.cpp` | `RequestBuilder` | all local validation; builds the exact request without network | +| `query.h/.cpp` | `Query` | query parameters, arrays as `name[]` | +| `pager.h/.cpp` | `Pager`, `Walk` | page rules for the four page shapes, capped walks | +| `resource.h/.cpp` | `Resource : llm::Service` | send, send raw, multipart, stream, walk | +| `reports.h/.cpp` | `MessagesUsageQuery`, `CostQuery`, `ClaudeCodeQuery`, `ReportParser`, `Decimal`, `Reports` | usage and cost reports | +| `webhook.h/.cpp` | `WebhookVerifier` | Standard Webhooks signature check | +| `caps.h` | `Caps` | every ceiling | +| `tools/check_spec.py` | | verifier and generator | + +## Contracts + +- Credentials: `ANTHROPIC_ADMIN_KEY` (must start `sk-ant-admin`, header + `x-api-key`), `ANTHROPIC_AUTH_TOKEN` (org:admin OAuth token, `Authorization: + Bearer`; the only credential for the 26 OAuth-only calls), `ANTHROPIC_API_KEY` + (standard key, managed agents). A standard key in the admin lane, an API key + in the OAuth lane, an admin key in the platform lane: refused locally with + `credential_rejected`, no request leaves. Nothing configured: + `NotConfiguredError` (503). Keys are never logged or shown (status shows + state only). +- Local validation comes before the credential check: path ids through + `Service::valid_id` (1..256 of `A-Za-z0-9._:-`), unknown and missing body + fields and query parameters, `limit` 1..1000, <=100 values per array + parameter, <=512 bytes per value, <=8 KiB query, <=1 MiB JSON body, multipart + <=32 MiB and <=512 parts, form part names (`files[]`, plain `files` is + refused), report ranges per bucket width (1d 31, 1h 168, 1m 1440; cost 31; + Claude Code 1000). Errors are `ApiError` 400 `INVALID_ARGUMENT`. +- Headers: `anthropic-version: 2026-10-21` (pinned), `anthropic-beta` from the + row, `anthropic-workspace-id` only where the row accepts it + (`Gateway::set_workspace_id`), header parameters (`Anthropic-Worker-ID`). +- Query arrays use the SDK's `brackets` format: `group_by[]=a&group_by[]=b`. +- Paging: `Pager` follows `has_more`/`last_id` (ids), `next_page` (cursor and + report) and stops when the server says so. `list_all` is capped at + `Caps::kMaxPages` (20, hard 100) pages and `kMaxItems` (5000) items and + reports `Walk.truncated` with `reason` and the continuing `next_page`. +- Mutating calls are `Kind::kWrite`, deletes/archives/cancels/stops/redacts/ + token rotation `Kind::kDestructive`; each is its own explicit method (no + default behaviour, marked MUTATES / DESTRUCTIVE in the generated header). + Secret-returning calls (`reveal_token`) are marked. +- Streams (`sessions.events.stream`, `sessions.threads.events.stream`) are GET + SSE through `Gateway::stream_get`, at most `Caps::kMaxStreamEvents` events. +- Webhooks: Standard Webhooks (`webhook-id`, `webhook-timestamp`, + `webhook-signature`, `whsec_` key, HMAC-SHA256 via wolfSSL), tolerance 300 s. +- Reports: `Decimal` is exact fixed point (9 digits); cost `amount` strings are + summed without floating point and overflow throws. + +## Demo (`example/app/ai/AnthropicAdminDemo.cpp`) + +`GET /ai/anthropic/admin` (page), `/status` (lane states, never a key), +`/calls` (the table). `POST /call` (any non-stream, non-upload row by name: +validated, dry run for every non-read unless `"confirm":true`), `/organization`, +`/usage`, `/cost`, `/claude-code`, `/webhook/verify` (local). 503 +`not_configured` without credential, 422 bad input, 401/403 `credential_rejected`. + +## Sources + +1. Official Python SDK `anthropics/anthropic-sdk-python` commit + `202db72c87d7c6eaa72129c67ce67fd343a3a20c` (release 2.3.0, 2026-10-23): + `src/anthropic/resources/**` (verb, path, body keys, query keys, header + params, beta header, page class, return type) and `types/**/*_params.py` + (TypedDict fields). `.stats.yml` says `configured_endpoints: 349` and has no + `openapi_spec_url` (also checked: TypeScript, Go, Java, Ruby, C#, PHP): there + is no published OpenAPI document, so the SDK source is the machine-readable + source. `_client.py` fixes query arrays to `brackets`, `_constants.py` the + API version. +2. API reference pages `platform.claude.com/docs/en/api/**.md` (one per + operation; method and path line, path/query/body parameters, credential + note "Admin API keys are not accepted"). +3. Guides `manage-claude/admin-api`, `admin-api-keys`, `usage-cost-api`, + `claude-tag-api` (credential rules, report semantics, Claude Tag endpoints). +4. Standard Webhooks specification (signature scheme, published test vector). + +## Verified against spec + +`python3 -I src/anthropic/admin/tools/check_spec.py` on 2026-10-24: 351 SDK +operations scanned, 255 table rows (12 docs-only), 253 reference pages checked +(14 rows are checked against the Claude Tag guide or the SDK alone), 0 failures. +It fails when a generated file is stale, a row disagrees with the SDK or its +page (verb, path, every body and query field in both directions, credential +class), a field is missing from the SDK params module, or an SDK operation is +neither in the table nor excluded (Messages, Batches, Models, Files, Skills). +Regenerate with `--emit`. `--sdk-tar` and `--pages-dir` reuse local copies. + +## Verified live + +Unauthenticated probes, 2026-10-24: see "Probes" at the end of this file. +No Anthropic key exists in this environment: no authenticated call has been +made. Opt-in live test (`MOLO_LIVE_NET=1` plus `ANTHROPIC_ADMIN_KEY`): read-only +organization info, one-item lists of users, workspaces, API keys, one report. +It prints a loud SKIP otherwise. + +## Unverified + +- Response shapes beyond the documented report examples (typed parsing exists + only for the three reports; everything else is returned as `Json`). +- Whether an Admin API key is accepted by the 26 OAuth-only calls: the pages + say it is not; the package follows the pages. +- Rows with no reference page: `analytics/usage` and `analytics/cost` + (SDK only); Claude Tag (guide only, field names from the SDK). +- Fields documented but not in the SDK params: none at this commit. +- Report enum members (`group_by`, `service_tiers`, ...) are not validated + locally except cost `group_by`; the server rejects unknown values. +- `sessions.resources.add` has `type` required in the SDK signature while the + migration guide says it is optional; the table follows the SDK. +- Actual limits enforced by the server for `limit` on non-report lists (the + package only caps at 1000). + +## Gaps + +- Personal and service-account keys not scoped to a workspace are valid Admin + API credentials per the docs, but look like standard keys (`sk-ant-api...`) + and are refused by design (rule: the standard key is never accepted). + Claude Enterprise scoped keys (`sk-ant-api01`) fall under the same rule. +- No GET streaming in `llm::ApiClient` (foundation gap, `src/llm`): the package + has its own `Gateway::stream_get`. +- Multipart upload goes through `ApiClient::post_multipart`, which parses a JSON + reply only; the binary plugin download uses `request_raw`. +- No typed models for non-report resources; no OAuth token refresh. +- `ANTHROPIC_AUTH_TOKEN` is the SDK's name for the bearer token; the plan's + key list names only `ANTHROPIC_ADMIN_KEY`. + +## Probes (unauthenticated, 2026-10-24, header `anthropic-version: 2026-10-21`) + +Host `api.anthropic.com` resolves, TLS works. Every documented path below +answers 401 (not 404) with the documented envelope +`{"type":"error","error":{"type":"authentication_error","message":...},"request_id":...}`; +an invented route answers 404 `not_found_error`. + +| Path | Status | +|---|---| +| `/v1/organizations/{me,users,workspaces,api_keys,service_accounts,cost_report,tunnels}` | 401 `x-api-key header is required` | +| `/v1/organizations/usage_report/{messages,claude_code}` | 401 (the two docs-only report paths exist) | +| `/v1/agents`, `/v1/sessions`, `/v1/vaults` | 401 `Authentication failed` | +| `/v1/environments` | 401 `x-api-key header is required` | +| `/v1/nonexistent_route` | 404 `not_found_error` | diff --git a/src/anthropic/admin/api.h b/src/anthropic/admin/api.h new file mode 100644 index 0000000..9e6ceab --- /dev/null +++ b/src/anthropic/admin/api.h @@ -0,0 +1,265 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#pragma once + +// AdminApi: every resource group of the package behind one object. Build it +// from the environment (ANTHROPIC_ADMIN_KEY, ANTHROPIC_ADMIN_TOKEN, +// ANTHROPIC_API_KEY) or from an explicit Gateway. + +#include + +#include "anthropic/admin/gateway.h" +#include "anthropic/admin/services/access.h" +#include "anthropic/admin/services/agents.h" +#include "anthropic/admin/services/analytics.h" +#include "anthropic/admin/services/claude_tag.h" +#include "anthropic/admin/services/deployments.h" +#include "anthropic/admin/services/dreams.h" +#include "anthropic/admin/services/environments.h" +#include "anthropic/admin/services/identity.h" +#include "anthropic/admin/services/memory.h" +#include "anthropic/admin/services/plugins.h" +#include "anthropic/admin/services/reports.h" +#include "anthropic/admin/services/sessions.h" +#include "anthropic/admin/services/spend_limits.h" +#include "anthropic/admin/services/telemetry.h" +#include "anthropic/admin/services/tunnels.h" +#include "anthropic/admin/services/user_profiles.h" +#include "anthropic/admin/services/vaults.h" +#include "anthropic/admin/services/workspaces.h" + +namespace molo::anthropic::admin { + +class AdminApi { + public: + explicit AdminApi(std::shared_ptr gateway) + : gateway_(std::move(gateway)), + federation_issuers_(gateway_), + federation_rules_(gateway_), + federation_rules_workspaces_(gateway_), + rbac_groups_(gateway_), + rbac_groups_members_(gateway_), + rbac_roles_(gateway_), + rbac_roles_permissions_(gateway_), + service_accounts_(gateway_), + service_accounts_workspaces_(gateway_), + agents_(gateway_), + agents_versions_(gateway_), + analytics_apps_chat_projects_(gateway_), + analytics_artifacts_(gateway_), + analytics_connectors_(gateway_), + analytics_cost_(gateway_), + analytics_cost_report_(gateway_), + analytics_plugins_(gateway_), + analytics_skills_(gateway_), + analytics_summaries_(gateway_), + analytics_usage_(gateway_), + analytics_usage_report_(gateway_), + analytics_user_cost_report_(gateway_), + analytics_user_usage_report_(gateway_), + analytics_users_(gateway_), + claude_tag_bundles_(gateway_), + claude_tag_bundles_targets_(gateway_), + claude_tag_slack_channels_(gateway_), + claude_tag_slack_workspaces_(gateway_), + deployment_runs_(gateway_), + deployments_(gateway_), + dreams_(gateway_), + environments_(gateway_), + environments_work_(gateway_), + api_keys_(gateway_), + compliance_settings_(gateway_), + external_keys_(gateway_), + invites_(gateway_), + organization_(gateway_), + rate_limits_(gateway_), + users_(gateway_), + memory_stores_(gateway_), + memory_stores_memories_(gateway_), + memory_stores_memory_versions_(gateway_), + plugin_marketplaces_(gateway_), + plugins_(gateway_), + plugins_installation_settings_(gateway_), + plugins_shares_(gateway_), + plugins_versions_(gateway_), + cost_report_(gateway_), + usage_report_(gateway_), + sessions_(gateway_), + sessions_events_(gateway_), + sessions_resources_(gateway_), + sessions_threads_(gateway_), + sessions_threads_events_(gateway_), + spend_limits_(gateway_), + spend_limits_effective_(gateway_), + spend_limits_increase_requests_(gateway_), + telemetry_destinations_(gateway_), + telemetry_destinations_workspaces_(gateway_), + webhooks_(gateway_), + mcp_tunnels_(gateway_), + mcp_tunnels_certificates_(gateway_), + tunnels_(gateway_), + tunnels_certificates_(gateway_), + user_profiles_(gateway_), + user_profiles_action_urls_(gateway_), + vaults_(gateway_), + vaults_credentials_(gateway_), + workspaces_(gateway_), + workspaces_members_(gateway_), + workspaces_rate_limits_(gateway_), + workspaces_service_accounts_(gateway_) {} + static AdminApi from_env() { return AdminApi(Gateway::from_env()); } + + const Gateway& gateway() const { return *gateway_; } + + const FederationIssuers& federation_issuers() const { return federation_issuers_; } + const FederationRules& federation_rules() const { return federation_rules_; } + const FederationRuleWorkspaces& federation_rules_workspaces() const { return federation_rules_workspaces_; } + const RbacGroups& rbac_groups() const { return rbac_groups_; } + const RbacGroupsMembers& rbac_groups_members() const { return rbac_groups_members_; } + const RbacRoles& rbac_roles() const { return rbac_roles_; } + const RbacRolesPermissions& rbac_roles_permissions() const { return rbac_roles_permissions_; } + const ServiceAccounts& service_accounts() const { return service_accounts_; } + const ServiceAccountWorkspaces& service_accounts_workspaces() const { return service_accounts_workspaces_; } + const Agents& agents() const { return agents_; } + const AgentsVersions& agents_versions() const { return agents_versions_; } + const AnalyticsAppsChatProjects& analytics_apps_chat_projects() const { return analytics_apps_chat_projects_; } + const AnalyticsArtifacts& analytics_artifacts() const { return analytics_artifacts_; } + const AnalyticsConnectors& analytics_connectors() const { return analytics_connectors_; } + const AnalyticsCost& analytics_cost() const { return analytics_cost_; } + const AnalyticsCostReport& analytics_cost_report() const { return analytics_cost_report_; } + const AnalyticsPlugins& analytics_plugins() const { return analytics_plugins_; } + const AnalyticsSkills& analytics_skills() const { return analytics_skills_; } + const AnalyticsSummaries& analytics_summaries() const { return analytics_summaries_; } + const AnalyticsUsage& analytics_usage() const { return analytics_usage_; } + const AnalyticsUsageReport& analytics_usage_report() const { return analytics_usage_report_; } + const AnalyticsUserCostReport& analytics_user_cost_report() const { return analytics_user_cost_report_; } + const AnalyticsUserUsageReport& analytics_user_usage_report() const { return analytics_user_usage_report_; } + const AnalyticsUsers& analytics_users() const { return analytics_users_; } + const ClaudeTagBundles& claude_tag_bundles() const { return claude_tag_bundles_; } + const ClaudeTagBundlesTargets& claude_tag_bundles_targets() const { return claude_tag_bundles_targets_; } + const ClaudeTagSlackChannels& claude_tag_slack_channels() const { return claude_tag_slack_channels_; } + const ClaudeTagSlackWorkspaces& claude_tag_slack_workspaces() const { return claude_tag_slack_workspaces_; } + const DeploymentRuns& deployment_runs() const { return deployment_runs_; } + const Deployments& deployments() const { return deployments_; } + const Dreams& dreams() const { return dreams_; } + const Environments& environments() const { return environments_; } + const EnvironmentsWork& environments_work() const { return environments_work_; } + const ApiKeys& api_keys() const { return api_keys_; } + const ComplianceSettings& compliance_settings() const { return compliance_settings_; } + const ExternalKeys& external_keys() const { return external_keys_; } + const Invites& invites() const { return invites_; } + const Organization& organization() const { return organization_; } + const RateLimits& rate_limits() const { return rate_limits_; } + const Users& users() const { return users_; } + const MemoryStores& memory_stores() const { return memory_stores_; } + const MemoryStoresMemories& memory_stores_memories() const { return memory_stores_memories_; } + const MemoryStoresMemoryVersions& memory_stores_memory_versions() const { return memory_stores_memory_versions_; } + const PluginMarketplaces& plugin_marketplaces() const { return plugin_marketplaces_; } + const Plugins& plugins() const { return plugins_; } + const PluginsInstallationSettings& plugins_installation_settings() const { return plugins_installation_settings_; } + const PluginsShares& plugins_shares() const { return plugins_shares_; } + const PluginsVersions& plugins_versions() const { return plugins_versions_; } + const CostReports& cost_report() const { return cost_report_; } + const UsageReports& usage_report() const { return usage_report_; } + const Sessions& sessions() const { return sessions_; } + const SessionsEvents& sessions_events() const { return sessions_events_; } + const SessionsResources& sessions_resources() const { return sessions_resources_; } + const SessionsThreads& sessions_threads() const { return sessions_threads_; } + const SessionsThreadsEvents& sessions_threads_events() const { return sessions_threads_events_; } + const SpendLimits& spend_limits() const { return spend_limits_; } + const SpendLimitsEffective& spend_limits_effective() const { return spend_limits_effective_; } + const SpendLimitsIncreaseRequests& spend_limits_increase_requests() const { return spend_limits_increase_requests_; } + const TelemetryDestinations& telemetry_destinations() const { return telemetry_destinations_; } + const TelemetryDestinationsWorkspaces& telemetry_destinations_workspaces() const { return telemetry_destinations_workspaces_; } + const Webhooks& webhooks() const { return webhooks_; } + const McpTunnels& mcp_tunnels() const { return mcp_tunnels_; } + const McpTunnelCertificates& mcp_tunnels_certificates() const { return mcp_tunnels_certificates_; } + const Tunnels& tunnels() const { return tunnels_; } + const TunnelsCertificates& tunnels_certificates() const { return tunnels_certificates_; } + const UserProfiles& user_profiles() const { return user_profiles_; } + const UserProfilesActionUrls& user_profiles_action_urls() const { return user_profiles_action_urls_; } + const Vaults& vaults() const { return vaults_; } + const VaultsCredentials& vaults_credentials() const { return vaults_credentials_; } + const Workspaces& workspaces() const { return workspaces_; } + const WorkspaceMembers& workspaces_members() const { return workspaces_members_; } + const WorkspaceRateLimits& workspaces_rate_limits() const { return workspaces_rate_limits_; } + const WorkspaceServiceAccounts& workspaces_service_accounts() const { return workspaces_service_accounts_; } + + private: + std::shared_ptr gateway_; + FederationIssuers federation_issuers_; + FederationRules federation_rules_; + FederationRuleWorkspaces federation_rules_workspaces_; + RbacGroups rbac_groups_; + RbacGroupsMembers rbac_groups_members_; + RbacRoles rbac_roles_; + RbacRolesPermissions rbac_roles_permissions_; + ServiceAccounts service_accounts_; + ServiceAccountWorkspaces service_accounts_workspaces_; + Agents agents_; + AgentsVersions agents_versions_; + AnalyticsAppsChatProjects analytics_apps_chat_projects_; + AnalyticsArtifacts analytics_artifacts_; + AnalyticsConnectors analytics_connectors_; + AnalyticsCost analytics_cost_; + AnalyticsCostReport analytics_cost_report_; + AnalyticsPlugins analytics_plugins_; + AnalyticsSkills analytics_skills_; + AnalyticsSummaries analytics_summaries_; + AnalyticsUsage analytics_usage_; + AnalyticsUsageReport analytics_usage_report_; + AnalyticsUserCostReport analytics_user_cost_report_; + AnalyticsUserUsageReport analytics_user_usage_report_; + AnalyticsUsers analytics_users_; + ClaudeTagBundles claude_tag_bundles_; + ClaudeTagBundlesTargets claude_tag_bundles_targets_; + ClaudeTagSlackChannels claude_tag_slack_channels_; + ClaudeTagSlackWorkspaces claude_tag_slack_workspaces_; + DeploymentRuns deployment_runs_; + Deployments deployments_; + Dreams dreams_; + Environments environments_; + EnvironmentsWork environments_work_; + ApiKeys api_keys_; + ComplianceSettings compliance_settings_; + ExternalKeys external_keys_; + Invites invites_; + Organization organization_; + RateLimits rate_limits_; + Users users_; + MemoryStores memory_stores_; + MemoryStoresMemories memory_stores_memories_; + MemoryStoresMemoryVersions memory_stores_memory_versions_; + PluginMarketplaces plugin_marketplaces_; + Plugins plugins_; + PluginsInstallationSettings plugins_installation_settings_; + PluginsShares plugins_shares_; + PluginsVersions plugins_versions_; + CostReports cost_report_; + UsageReports usage_report_; + Sessions sessions_; + SessionsEvents sessions_events_; + SessionsResources sessions_resources_; + SessionsThreads sessions_threads_; + SessionsThreadsEvents sessions_threads_events_; + SpendLimits spend_limits_; + SpendLimitsEffective spend_limits_effective_; + SpendLimitsIncreaseRequests spend_limits_increase_requests_; + TelemetryDestinations telemetry_destinations_; + TelemetryDestinationsWorkspaces telemetry_destinations_workspaces_; + Webhooks webhooks_; + McpTunnels mcp_tunnels_; + McpTunnelCertificates mcp_tunnels_certificates_; + Tunnels tunnels_; + TunnelsCertificates tunnels_certificates_; + UserProfiles user_profiles_; + UserProfilesActionUrls user_profiles_action_urls_; + Vaults vaults_; + VaultsCredentials vaults_credentials_; + Workspaces workspaces_; + WorkspaceMembers workspaces_members_; + WorkspaceRateLimits workspaces_rate_limits_; + WorkspaceServiceAccounts workspaces_service_accounts_; +}; + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/calls.cpp b/src/anthropic/admin/calls.cpp new file mode 100644 index 0000000..4f79d35 --- /dev/null +++ b/src/anthropic/admin/calls.cpp @@ -0,0 +1,291 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#include "anthropic/admin/calls.h" + +#include + +namespace molo::anthropic::admin { + +// CALLS-BEGIN (parsed by tools/check_spec.py; one row per line) +static const CallSpec kCalls[] = { + {Call::kAnalyticsAppsChatProjectsList, "organization.analytics.apps.chat.projects.list", "GET", "/v1/organizations/analytics/apps/chat/projects", "api/beta/organization/analytics/apps/chat/projects/list", "ProjectListParams", "BetaAnalyticsProjectActivity", "", "", "date,ending_date,filter[],group_by[],limit,order,order_by,page,starting_date", "", "", Auth::kAdmin, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kAnalyticsArtifactsList, "organization.analytics.artifacts.list", "GET", "/v1/organizations/analytics/artifacts", "api/beta/organization/analytics/artifacts/list", "ArtifactListParams", "BetaAnalyticsArtifactActivity", "", "date", "date,filter[],group_by[],limit,page", "", "", Auth::kAdmin, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kAnalyticsConnectorsList, "organization.analytics.connectors.list", "GET", "/v1/organizations/analytics/connectors", "api/beta/organization/analytics/connectors/list", "ConnectorListParams", "BetaAnalyticsConnectorActivity", "", "", "date,ending_date,filter[],group_by[],limit,order,order_by,page,starting_date", "", "", Auth::kAdmin, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kAnalyticsCostList, "organization.analytics.cost.list", "GET", "/v1/organizations/analytics/cost", "", "CostListParams", "BetaAnalyticsCostItem", "", "starting_at", "starting_at,actor_ids[],actor_types[],agent_ids[],api_key_ids[],claude_tag_categories[],claude_tag_user_ids[],context_windows[],deployment_ids[],ending_at,environment_ids[],exclude_deleted_users,group_by[],inference_geos[],limit,models[],order,order_by,page,products[],rbac_group_ids[],service_tiers[],session_ids[],slack_channel_ids[],speeds[],time_bucket_width,user_profile_ids[],workspace_ids[]", "", "analytics-usage-cost-2026-08-24", Auth::kAdmin, Kind::kRead, Page::kReport, Wire::kJson, false, false}, + {Call::kAnalyticsCostReportList, "organization.analytics.cost_report.list", "GET", "/v1/organizations/analytics/cost_report", "api/beta/organization/analytics/cost_report/list", "CostReportListParams", "BetaAnalyticsCostReportTimeBucket", "", "starting_at", "starting_at,bucket_width,claude_tag_categories[],claude_tag_user_ids[],context_windows[],ending_at,group_by[],inference_geos[],limit,models[],page,products[],rbac_group_ids[],slack_channel_ids[],speeds[],user_ids[]", "", "", Auth::kAdmin, Kind::kRead, Page::kReport, Wire::kJson, false, false}, + {Call::kAnalyticsPluginsList, "organization.analytics.plugins.list", "GET", "/v1/organizations/analytics/plugins", "api/beta/organization/analytics/plugins/list", "PluginListParams", "BetaAnalyticsPluginActivity", "", "", "date,ending_date,filter[],group_by[],limit,order,order_by,page,starting_date", "", "", Auth::kAdmin, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kAnalyticsSkillsList, "organization.analytics.skills.list", "GET", "/v1/organizations/analytics/skills", "api/beta/organization/analytics/skills/list", "SkillListParams", "BetaAnalyticsSkillActivity", "", "", "date,ending_date,filter[],group_by[],limit,order,order_by,page,starting_date", "", "", Auth::kAdmin, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kAnalyticsSummariesList, "organization.analytics.summaries.list", "GET", "/v1/organizations/analytics/summaries", "api/beta/organization/analytics/summaries/list", "SummaryListParams", "BetaAnalyticsSingleDayActivitySummary", "", "starting_date", "starting_date,ending_date,filter[],limit,page", "", "", Auth::kAdmin, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kAnalyticsUsageList, "organization.analytics.usage.list", "GET", "/v1/organizations/analytics/usage", "", "UsageListParams", "BetaAnalyticsUsageItem", "", "starting_at", "starting_at,actor_ids[],actor_types[],agent_ids[],api_key_ids[],claude_tag_categories[],claude_tag_user_ids[],context_windows[],deployment_ids[],ending_at,environment_ids[],exclude_deleted_users,group_by[],inference_geos[],limit,models[],order,order_by,page,products[],rbac_group_ids[],service_tiers[],session_ids[],slack_channel_ids[],speeds[],time_bucket_width,user_profile_ids[],workspace_ids[]", "", "analytics-usage-cost-2026-08-24", Auth::kAdmin, Kind::kRead, Page::kReport, Wire::kJson, false, false}, + {Call::kAnalyticsUsageReportList, "organization.analytics.usage_report.list", "GET", "/v1/organizations/analytics/usage_report", "api/beta/organization/analytics/usage_report/list", "UsageReportListParams", "BetaAnalyticsUsageReportTimeBucket", "", "starting_at", "starting_at,bucket_width,claude_tag_categories[],claude_tag_user_ids[],context_windows[],ending_at,group_by[],inference_geos[],limit,models[],page,products[],rbac_group_ids[],slack_channel_ids[],speeds[],user_ids[]", "", "", Auth::kAdmin, Kind::kRead, Page::kReport, Wire::kJson, false, false}, + {Call::kAnalyticsUserCostReportList, "organization.analytics.user_cost_report.list", "GET", "/v1/organizations/analytics/user_cost_report", "api/beta/organization/analytics/user_cost_report/list", "UserCostReportListParams", "BetaAnalyticsCostUsersItem", "", "starting_at", "starting_at,bucket_width,claude_tag_categories[],claude_tag_user_ids[],context_windows[],ending_at,exclude_deleted_users,group_by[],inference_geos[],limit,models[],order,order_by,page,products[],rbac_group_ids[],slack_channel_ids[],speeds[],user_ids[]", "", "", Auth::kAdmin, Kind::kRead, Page::kReport, Wire::kJson, false, false}, + {Call::kAnalyticsUserUsageReportList, "organization.analytics.user_usage_report.list", "GET", "/v1/organizations/analytics/user_usage_report", "api/beta/organization/analytics/user_usage_report/list", "UserUsageReportListParams", "BetaAnalyticsUsageUsersItem", "", "starting_at", "starting_at,bucket_width,claude_tag_categories[],claude_tag_user_ids[],context_windows[],ending_at,exclude_deleted_users,group_by[],inference_geos[],limit,models[],order,order_by,page,products[],rbac_group_ids[],slack_channel_ids[],speeds[],user_ids[]", "", "", Auth::kAdmin, Kind::kRead, Page::kReport, Wire::kJson, false, false}, + {Call::kAnalyticsUsersList, "organization.analytics.users.list", "GET", "/v1/organizations/analytics/users", "api/beta/organization/analytics/users/list", "UserListParams", "BetaAnalyticsUserActivity", "", "", "date,ending_date,filter[],group_by[],limit,order,order_by,page,starting_date", "", "", Auth::kAdmin, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kApiKeysList, "organization.api_keys.list", "GET", "/v1/organizations/api_keys", "api/organization/api_keys/list", "ApiKeyListParams", "BetaAPIKey", "", "", "after_id,before_id,created_by_user_id,limit,status,workspace_id", "", "", Auth::kAdmin, Kind::kRead, Page::kIds, Wire::kJson, true, false}, + {Call::kApiKeysRetrieve, "organization.api_keys.retrieve", "GET", "/v1/organizations/api_keys/{api_key_id}", "api/organization/api_keys/retrieve", "", "BetaAPIKey", "", "", "", "", "", Auth::kAdmin, Kind::kRead, Page::kNone, Wire::kJson, false, false}, + {Call::kApiKeysUpdate, "organization.api_keys.update", "POST", "/v1/organizations/api_keys/{api_key_id}", "api/organization/api_keys/update", "ApiKeyUpdateParams", "BetaAPIKey", "name,status", "", "", "", "", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kClaudeTagBundlesList, "organization.claude_tag.bundles.list", "GET", "/v1/organizations/claude_tag/bundles", "guide:manage-claude/claude-tag-api", "BundleListParams", "BetaClaudeTagBundle", "", "", "limit,page", "", "experimental-claude-tag-2026-10-21", Auth::kAdmin, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kClaudeTagBundlesRetrieve, "organization.claude_tag.bundles.retrieve", "GET", "/v1/organizations/claude_tag/bundles/{bundle_id}", "guide:manage-claude/claude-tag-api", "", "BetaClaudeTagBundle", "", "", "", "", "experimental-claude-tag-2026-10-21", Auth::kAdmin, Kind::kRead, Page::kNone, Wire::kJson, false, false}, + {Call::kClaudeTagBundlesTargetsCreate, "organization.claude_tag.bundles.targets.create", "POST", "/v1/organizations/claude_tag/bundles/{bundle_id}/targets", "guide:manage-claude/claude-tag-api", "TargetCreateParams", "BetaClaudeTagBundleTarget", "", "", "", "", "experimental-claude-tag-2026-10-21", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kClaudeTagBundlesTargetsDelete, "organization.claude_tag.bundles.targets.delete", "DELETE", "/v1/organizations/claude_tag/bundles/{bundle_id}/targets/{target_id}", "guide:manage-claude/claude-tag-api", "", "BetaClaudeTagDeletedBundleTarget", "", "", "", "", "experimental-claude-tag-2026-10-21", Auth::kAdmin, Kind::kDestructive, Page::kNone, Wire::kJson, false, false}, + {Call::kClaudeTagBundlesTargetsList, "organization.claude_tag.bundles.targets.list", "GET", "/v1/organizations/claude_tag/bundles/{bundle_id}/targets", "guide:manage-claude/claude-tag-api", "TargetListParams", "BetaClaudeTagBundleTarget", "", "", "limit,page", "", "experimental-claude-tag-2026-10-21", Auth::kAdmin, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kClaudeTagBundlesTargetsRetrieve, "organization.claude_tag.bundles.targets.retrieve", "GET", "/v1/organizations/claude_tag/bundles/{bundle_id}/targets/{target_id}", "guide:manage-claude/claude-tag-api", "", "BetaClaudeTagBundleTarget", "", "", "", "", "experimental-claude-tag-2026-10-21", Auth::kAdmin, Kind::kRead, Page::kNone, Wire::kJson, false, false}, + {Call::kClaudeTagSlackChannelsCreate, "organization.claude_tag.slack_channels.create", "POST", "/v1/organizations/claude_tag/slack_channels", "guide:manage-claude/claude-tag-api", "SlackChannelCreateParams", "BetaClaudeTagSlackChannel", "slack,settings", "slack", "", "", "experimental-claude-tag-2026-10-21", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kClaudeTagSlackChannelsDelete, "organization.claude_tag.slack_channels.delete", "DELETE", "/v1/organizations/claude_tag/slack_channels/{id}", "guide:manage-claude/claude-tag-api", "", "BetaClaudeTagDeletedSlackChannel", "", "", "", "", "experimental-claude-tag-2026-10-21", Auth::kAdmin, Kind::kDestructive, Page::kNone, Wire::kJson, false, false}, + {Call::kClaudeTagSlackChannelsList, "organization.claude_tag.slack_channels.list", "GET", "/v1/organizations/claude_tag/slack_channels", "guide:manage-claude/claude-tag-api", "SlackChannelListParams", "BetaClaudeTagSlackChannel", "", "slack_workspace_id", "slack_workspace_id,include_inherited,limit,page,slack_channel_id", "", "experimental-claude-tag-2026-10-21", Auth::kAdmin, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kClaudeTagSlackChannelsRetrieve, "organization.claude_tag.slack_channels.retrieve", "GET", "/v1/organizations/claude_tag/slack_channels/{id}", "guide:manage-claude/claude-tag-api", "SlackChannelRetrieveParams", "BetaClaudeTagSlackChannel", "", "", "include_inherited", "", "experimental-claude-tag-2026-10-21", Auth::kAdmin, Kind::kRead, Page::kNone, Wire::kJson, false, false}, + {Call::kClaudeTagSlackChannelsUpdate, "organization.claude_tag.slack_channels.update", "POST", "/v1/organizations/claude_tag/slack_channels/{id}", "guide:manage-claude/claude-tag-api", "SlackChannelUpdateParams", "BetaClaudeTagSlackChannel", "settings", "settings", "", "", "experimental-claude-tag-2026-10-21", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kClaudeTagSlackWorkspacesList, "organization.claude_tag.slack_workspaces.list", "GET", "/v1/organizations/claude_tag/slack_workspaces", "guide:manage-claude/claude-tag-api", "SlackWorkspaceListParams", "BetaClaudeTagSlackWorkspace", "", "", "include_inherited,limit,page,slack_workspace_id", "", "experimental-claude-tag-2026-10-21", Auth::kAdmin, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kClaudeTagSlackWorkspacesRetrieve, "organization.claude_tag.slack_workspaces.retrieve", "GET", "/v1/organizations/claude_tag/slack_workspaces/{id}", "guide:manage-claude/claude-tag-api", "SlackWorkspaceRetrieveParams", "BetaClaudeTagSlackWorkspace", "", "", "include_inherited", "", "experimental-claude-tag-2026-10-21", Auth::kAdmin, Kind::kRead, Page::kNone, Wire::kJson, false, false}, + {Call::kClaudeTagSlackWorkspacesUpdate, "organization.claude_tag.slack_workspaces.update", "POST", "/v1/organizations/claude_tag/slack_workspaces/{id}", "guide:manage-claude/claude-tag-api", "SlackWorkspaceUpdateParams", "BetaClaudeTagSlackWorkspace", "settings", "settings", "", "", "experimental-claude-tag-2026-10-21", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kComplianceSettingsRetrieve, "organization.compliance_settings.retrieve", "GET", "/v1/organizations/compliance_settings", "api/organization/compliance_settings/retrieve", "", "BetaComplianceSettings", "", "", "", "", "", Auth::kAdmin, Kind::kRead, Page::kNone, Wire::kJson, false, false}, + {Call::kComplianceSettingsUpdate, "organization.compliance_settings.update", "POST", "/v1/organizations/compliance_settings", "api/organization/compliance_settings/update", "ComplianceSettingUpdateParams", "BetaComplianceSettings", "state", "state", "", "", "", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kCostReportRetrieve, "organization.cost_report.retrieve", "GET", "/v1/organizations/cost_report", "api/beta/organization/cost_report/retrieve", "", "BetaCostReport", "", "starting_at", "starting_at,bucket_width,ending_at,group_by[],limit,page", "", "", Auth::kAdmin, Kind::kRead, Page::kReport, Wire::kJson, false, true}, + {Call::kExternalKeysCreate, "organization.external_keys.create", "POST", "/v1/organizations/external_keys", "api/organization/external_keys/create", "ExternalKeyCreateParams", "BetaExternalKey", "provider_config,display_name,geo", "provider_config", "", "", "", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kExternalKeysDelete, "organization.external_keys.delete", "DELETE", "/v1/organizations/external_keys/{external_key_id}", "api/organization/external_keys/delete", "", "ExternalKeyDeleteResponse", "", "", "", "", "", Auth::kAdmin, Kind::kDestructive, Page::kNone, Wire::kJson, false, false}, + {Call::kExternalKeysList, "organization.external_keys.list", "GET", "/v1/organizations/external_keys", "api/organization/external_keys/list", "ExternalKeyListParams", "BetaExternalKey", "", "", "limit,page", "", "", Auth::kAdmin, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kExternalKeysRetrieve, "organization.external_keys.retrieve", "GET", "/v1/organizations/external_keys/{external_key_id}", "api/organization/external_keys/retrieve", "", "BetaExternalKey", "", "", "", "", "", Auth::kAdmin, Kind::kRead, Page::kNone, Wire::kJson, false, false}, + {Call::kExternalKeysUpdate, "organization.external_keys.update", "POST", "/v1/organizations/external_keys/{external_key_id}", "api/organization/external_keys/update", "ExternalKeyUpdateParams", "BetaExternalKey", "display_name,geo,provider_config", "", "", "", "", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kExternalKeysValidate, "organization.external_keys.validate", "POST", "/v1/organizations/external_keys/{external_key_id}/validate", "api/organization/external_keys/validate", "", "ExternalKeyValidateResponse", "", "", "", "", "", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kInvitesCreate, "organization.invites.create", "POST", "/v1/organizations/invites", "api/organization/invites/create", "InviteCreateParams", "BetaOrganizationInvite", "email,role,rbac_group_ids", "email,role", "", "", "", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kInvitesDelete, "organization.invites.delete", "DELETE", "/v1/organizations/invites/{invite_id}", "api/organization/invites/delete", "", "InviteDeleteResponse", "", "", "", "", "", Auth::kAdmin, Kind::kDestructive, Page::kNone, Wire::kJson, false, false}, + {Call::kInvitesList, "organization.invites.list", "GET", "/v1/organizations/invites", "api/organization/invites/list", "InviteListParams", "BetaOrganizationInvite", "", "", "after_id,before_id,email,limit,roles[],statuses[]", "", "", Auth::kAdmin, Kind::kRead, Page::kIds, Wire::kJson, false, false}, + {Call::kInvitesRetrieve, "organization.invites.retrieve", "GET", "/v1/organizations/invites/{invite_id}", "api/organization/invites/retrieve", "", "BetaOrganizationInvite", "", "", "", "", "", Auth::kAdmin, Kind::kRead, Page::kNone, Wire::kJson, false, false}, + {Call::kMcpTunnelsArchive, "organization.mcp_tunnels.archive", "POST", "/v1/organizations/tunnels/{tunnel_id}/archive", "api/beta/organization/mcp_tunnels/archive", "", "BetaMcpTunnel", "", "", "", "", "mcp-tunnels-2026-06-22", Auth::kAdmin, Kind::kDestructive, Page::kNone, Wire::kJson, false, true}, + {Call::kMcpTunnelsCertificatesArchive, "organization.mcp_tunnels.certificates.archive", "POST", "/v1/organizations/tunnels/{tunnel_id}/certificates/{certificate_id}/archive", "api/beta/organization/mcp_tunnels/tunnel_certificates/archive", "", "BetaMcpTunnelCertificate", "", "", "", "", "mcp-tunnels-2026-06-22", Auth::kAdmin, Kind::kDestructive, Page::kNone, Wire::kJson, false, true}, + {Call::kMcpTunnelsCertificatesCreate, "organization.mcp_tunnels.certificates.create", "POST", "/v1/organizations/tunnels/{tunnel_id}/certificates", "api/beta/organization/mcp_tunnels/tunnel_certificates/create", "", "BetaMcpTunnelCertificate", "ca_certificate_pem", "ca_certificate_pem", "", "", "mcp-tunnels-2026-06-22", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kJson, false, true}, + {Call::kMcpTunnelsCertificatesList, "organization.mcp_tunnels.certificates.list", "GET", "/v1/organizations/tunnels/{tunnel_id}/certificates", "api/beta/organization/mcp_tunnels/tunnel_certificates/list", "", "BetaMcpTunnelCertificate", "", "", "include_archived,limit,page", "", "mcp-tunnels-2026-06-22", Auth::kAdmin, Kind::kRead, Page::kCursor, Wire::kJson, false, true}, + {Call::kMcpTunnelsCertificatesRetrieve, "organization.mcp_tunnels.certificates.retrieve", "GET", "/v1/organizations/tunnels/{tunnel_id}/certificates/{certificate_id}", "api/beta/organization/mcp_tunnels/tunnel_certificates/retrieve", "", "BetaMcpTunnelCertificate", "", "", "", "", "mcp-tunnels-2026-06-22", Auth::kAdmin, Kind::kRead, Page::kNone, Wire::kJson, false, true}, + {Call::kMcpTunnelsList, "organization.mcp_tunnels.list", "GET", "/v1/organizations/tunnels", "api/beta/organization/mcp_tunnels/list", "", "BetaMcpTunnel", "", "", "include_archived,limit,page,workspace_id", "", "mcp-tunnels-2026-06-22", Auth::kAdmin, Kind::kRead, Page::kCursor, Wire::kJson, false, true}, + {Call::kMcpTunnelsRetrieve, "organization.mcp_tunnels.retrieve", "GET", "/v1/organizations/tunnels/{tunnel_id}", "api/beta/organization/mcp_tunnels/retrieve", "", "BetaMcpTunnel", "", "", "", "", "mcp-tunnels-2026-06-22", Auth::kAdmin, Kind::kRead, Page::kNone, Wire::kJson, false, true}, + {Call::kMcpTunnelsRevealToken, "organization.mcp_tunnels.reveal_token", "POST", "/v1/organizations/tunnels/{tunnel_id}/reveal_token", "api/beta/organization/mcp_tunnels/reveal_token", "", "BetaMcpTunnelToken", "", "", "", "", "mcp-tunnels-2026-06-22", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kJson, false, true}, + {Call::kMcpTunnelsRotateToken, "organization.mcp_tunnels.rotate_token", "POST", "/v1/organizations/tunnels/{tunnel_id}/rotate_token", "api/beta/organization/mcp_tunnels/rotate_token", "", "BetaMcpTunnelToken", "reason", "", "", "", "mcp-tunnels-2026-06-22", Auth::kAdmin, Kind::kDestructive, Page::kNone, Wire::kJson, false, true}, + {Call::kOrganizationRetrieve, "organization.retrieve", "GET", "/v1/organizations/me", "api/organization/retrieve", "", "BetaOrganization", "", "", "", "", "", Auth::kAdmin, Kind::kRead, Page::kNone, Wire::kJson, false, false}, + {Call::kPluginMarketplacesList, "organization.plugin_marketplaces.list", "GET", "/v1/organizations/plugin_marketplaces", "api/beta/organization/plugin_marketplaces/list", "PluginMarketplaceListParams", "BetaPluginMarketplace", "", "", "limit,organization_id,owner_type,page,source", "", "ce-plugins-2026-09-01", Auth::kAdmin, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kPluginMarketplacesRetrieve, "organization.plugin_marketplaces.retrieve", "GET", "/v1/organizations/plugin_marketplaces/{marketplace_id}", "api/beta/organization/plugin_marketplaces/retrieve", "PluginMarketplaceRetrieveParams", "BetaPluginMarketplace", "", "", "organization_id", "", "ce-plugins-2026-09-01", Auth::kAdmin, Kind::kRead, Page::kNone, Wire::kJson, false, false}, + {Call::kPluginMarketplacesUpdate, "organization.plugin_marketplaces.update", "POST", "/v1/organizations/plugin_marketplaces/{marketplace_id}", "api/beta/organization/plugin_marketplaces/update", "PluginMarketplaceUpdateParams", "BetaPluginMarketplace", "default_installation_preference", "default_installation_preference", "", "", "ce-plugins-2026-09-01", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kPluginMarketplacesValidateArchive, "organization.plugin_marketplaces.validate_archive", "POST", "/v1/organizations/plugin_marketplaces/validate_archive", "api/beta/organization/plugin_marketplaces/validate_archive", "PluginMarketplaceValidateArchiveParams", "BetaPluginMarketplaceValidationReport", "archive", "archive", "", "", "ce-plugins-2026-09-01", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kMultipart, false, false}, + {Call::kPluginMarketplacesValidateRepository, "organization.plugin_marketplaces.validate_repository", "POST", "/v1/organizations/plugin_marketplaces/validate_repository", "api/beta/organization/plugin_marketplaces/validate_repository", "PluginMarketplaceValidateRepositoryParams", "BetaPluginMarketplaceValidationReport", "repository_url,ref", "repository_url", "", "", "ce-plugins-2026-09-01", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kPluginsCreate, "organization.plugins.create", "POST", "/v1/organizations/plugins", "api/beta/organization/plugins/create", "PluginCreateParams", "BetaPlugin", "files[],marketplace_id,release_notes", "files[]", "", "", "ce-plugins-2026-09-01", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kMultipart, false, false}, + {Call::kPluginsDelete, "organization.plugins.delete", "DELETE", "/v1/organizations/plugins/{plugin_id}", "api/beta/organization/plugins/delete", "", "BetaDeletedPlugin", "", "", "", "", "ce-plugins-2026-09-01", Auth::kAdmin, Kind::kDestructive, Page::kNone, Wire::kJson, false, false}, + {Call::kPluginsInstallationSettingsList, "organization.plugins.installation_settings.list", "GET", "/v1/organizations/plugins/{plugin_id}/installation_settings", "api/beta/organization/plugins/installation_settings/list", "InstallationSettingListParams", "BetaPluginInstallationSetting", "", "", "limit,organization_id,page,target_type", "", "ce-plugins-2026-09-01", Auth::kAdmin, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kPluginsInstallationSettingsRemove, "organization.plugins.installation_settings.remove", "DELETE", "/v1/organizations/plugins/{plugin_id}/installation_settings/{target}", "api/beta/organization/plugins/installation_settings/remove", "", "BetaDeletedPluginInstallationSetting", "", "", "", "", "ce-plugins-2026-09-01", Auth::kAdmin, Kind::kDestructive, Page::kNone, Wire::kJson, false, false}, + {Call::kPluginsInstallationSettingsSet, "organization.plugins.installation_settings.set", "POST", "/v1/organizations/plugins/{plugin_id}/installation_settings/{target}", "api/beta/organization/plugins/installation_settings/set", "InstallationSettingSetParams", "BetaPluginInstallationSetting", "installation_preference", "installation_preference", "", "", "ce-plugins-2026-09-01", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kPluginsList, "organization.plugins.list", "GET", "/v1/organizations/plugins", "api/beta/organization/plugins/list", "PluginListParams", "BetaPlugin", "", "", "created_at[gt],created_at[gte],created_at[lt],created_at[lte],limit,marketplace_id,organization_id,owner_type,owner_user_id,page", "", "ce-plugins-2026-09-01", Auth::kAdmin, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kPluginsRetrieve, "organization.plugins.retrieve", "GET", "/v1/organizations/plugins/{plugin_id}", "api/beta/organization/plugins/retrieve", "PluginRetrieveParams", "BetaPlugin", "", "", "organization_id", "", "ce-plugins-2026-09-01", Auth::kAdmin, Kind::kRead, Page::kNone, Wire::kJson, false, false}, + {Call::kPluginsSharesList, "organization.plugins.shares.list", "GET", "/v1/organizations/plugins/{plugin_id}/shares", "api/beta/organization/plugins/shares/list", "ShareListParams", "BetaPluginShare", "", "", "limit,organization_id,page,target_type", "", "ce-plugins-2026-09-01", Auth::kAdmin, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kPluginsUpdate, "organization.plugins.update", "POST", "/v1/organizations/plugins/{plugin_id}", "api/beta/organization/plugins/update", "PluginUpdateParams", "BetaPlugin", "served_version_id", "served_version_id", "", "", "ce-plugins-2026-09-01", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kPluginsVersionsCreate, "organization.plugins.versions.create", "POST", "/v1/organizations/plugins/{plugin_id}/versions", "api/beta/organization/plugins/versions/create", "VersionCreateParams", "BetaPluginVersion", "files[],release_notes", "files[]", "", "", "ce-plugins-2026-09-01", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kMultipart, false, false}, + {Call::kPluginsVersionsDownload, "organization.plugins.versions.download", "GET", "/v1/organizations/plugins/{plugin_id}/versions/{version}/content", "api/beta/organization/plugins/versions/download", "VersionDownloadParams", "Binary", "", "", "organization_id", "", "ce-plugins-2026-09-01", Auth::kAdmin, Kind::kRead, Page::kNone, Wire::kRaw, false, false}, + {Call::kPluginsVersionsList, "organization.plugins.versions.list", "GET", "/v1/organizations/plugins/{plugin_id}/versions", "api/beta/organization/plugins/versions/list", "VersionListParams", "BetaPluginVersion", "", "", "limit,organization_id,page", "", "ce-plugins-2026-09-01", Auth::kAdmin, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kPluginsVersionsRetrieve, "organization.plugins.versions.retrieve", "GET", "/v1/organizations/plugins/{plugin_id}/versions/{version}", "api/beta/organization/plugins/versions/retrieve", "VersionRetrieveParams", "BetaPluginVersion", "", "", "organization_id", "", "ce-plugins-2026-09-01", Auth::kAdmin, Kind::kRead, Page::kNone, Wire::kJson, false, false}, + {Call::kRateLimitsList, "organization.rate_limits.list", "GET", "/v1/organizations/rate_limits", "api/organization/rate_limits/list", "RateLimitListParams", "BetaOrganizationRateLimit", "", "", "group_type,limit,model,page", "", "", Auth::kAdmin, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kRbacGroupsCreate, "organization.rbac_groups.create", "POST", "/v1/organizations/rbac_groups", "api/beta/organization/rbac_groups/create", "RbacGroupCreateParams", "BetaRBACGroup", "name", "name", "", "", "", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kRbacGroupsDelete, "organization.rbac_groups.delete", "DELETE", "/v1/organizations/rbac_groups/{rbac_group_id}", "api/beta/organization/rbac_groups/delete", "", "RBACGroupDeleteResponse", "", "", "", "", "", Auth::kAdmin, Kind::kDestructive, Page::kNone, Wire::kJson, false, false}, + {Call::kRbacGroupsList, "organization.rbac_groups.list", "GET", "/v1/organizations/rbac_groups", "api/beta/organization/rbac_groups/list", "RbacGroupListParams", "BetaRBACGroup", "", "", "limit,page", "", "", Auth::kAdmin, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kRbacGroupsMembersAdd, "organization.rbac_groups.members.add", "POST", "/v1/organizations/rbac_groups/{rbac_group_id}/members", "api/beta/organization/rbac_groups/members/add", "MemberAddParams", "BetaRBACGroupMember", "user_id", "user_id", "", "", "", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kRbacGroupsMembersList, "organization.rbac_groups.members.list", "GET", "/v1/organizations/rbac_groups/{rbac_group_id}/members", "api/beta/organization/rbac_groups/members/list", "MemberListParams", "BetaRBACGroupMember", "", "", "limit,page", "", "", Auth::kAdmin, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kRbacGroupsMembersRemove, "organization.rbac_groups.members.remove", "DELETE", "/v1/organizations/rbac_groups/{rbac_group_id}/members/{user_id}", "api/beta/organization/rbac_groups/members/remove", "", "MemberRemoveResponse", "", "", "", "", "", Auth::kAdmin, Kind::kDestructive, Page::kNone, Wire::kJson, false, false}, + {Call::kRbacGroupsRetrieve, "organization.rbac_groups.retrieve", "GET", "/v1/organizations/rbac_groups/{rbac_group_id}", "api/beta/organization/rbac_groups/retrieve", "", "BetaRBACGroup", "", "", "", "", "", Auth::kAdmin, Kind::kRead, Page::kNone, Wire::kJson, false, false}, + {Call::kRbacGroupsUpdate, "organization.rbac_groups.update", "POST", "/v1/organizations/rbac_groups/{rbac_group_id}", "api/beta/organization/rbac_groups/update", "RbacGroupUpdateParams", "BetaRBACGroup", "name", "", "", "", "", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kRbacRolesList, "organization.rbac_roles.list", "GET", "/v1/organizations/rbac_roles", "api/beta/organization/rbac_roles/list", "RbacRoleListParams", "BetaRBACRole", "", "", "limit,page", "", "", Auth::kAdmin, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kRbacRolesPermissionsList, "organization.rbac_roles.permissions.list", "GET", "/v1/organizations/rbac_roles/{rbac_role_id}/permissions", "api/beta/organization/rbac_roles/permissions/list", "PermissionListParams", "BetaRBACRolePermission", "", "", "limit,page", "", "", Auth::kAdmin, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kRbacRolesRetrieve, "organization.rbac_roles.retrieve", "GET", "/v1/organizations/rbac_roles/{rbac_role_id}", "api/beta/organization/rbac_roles/retrieve", "", "BetaRBACRole", "", "", "", "", "", Auth::kAdmin, Kind::kRead, Page::kNone, Wire::kJson, false, false}, + {Call::kSpendLimitsDelete, "organization.spend_limits.delete", "DELETE", "/v1/organizations/spend_limits/{spend_limit_id}", "api/beta/organization/spend_limits/delete", "", "SpendLimitDeleteResponse", "", "", "", "", "", Auth::kAdmin, Kind::kDestructive, Page::kNone, Wire::kJson, false, false}, + {Call::kSpendLimitsEffectiveList, "organization.spend_limits.effective.list", "GET", "/v1/organizations/spend_limits/effective", "api/beta/organization/spend_limits/effective/list", "EffectiveListParams", "BetaSpendSummary", "", "", "limit,page,period[],user_ids[]", "", "", Auth::kAdmin, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kSpendLimitsIncreaseRequestsApprove, "organization.spend_limits.increase_requests.approve", "POST", "/v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id}/approve", "api/beta/organization/spend_limits/increase_requests/approve", "IncreaseRequestApproveParams", "IncreaseRequestApproveResponse", "amount,period,suppress_notification", "amount", "", "", "", Auth::kAdmin, Kind::kDestructive, Page::kNone, Wire::kJson, false, false}, + {Call::kSpendLimitsIncreaseRequestsDeny, "organization.spend_limits.increase_requests.deny", "POST", "/v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id}/deny", "api/beta/organization/spend_limits/increase_requests/deny", "IncreaseRequestDenyParams", "BetaSpendLimitIncreaseRequest", "suppress_notification", "", "", "", "", Auth::kAdmin, Kind::kDestructive, Page::kNone, Wire::kJson, false, false}, + {Call::kSpendLimitsIncreaseRequestsList, "organization.spend_limits.increase_requests.list", "GET", "/v1/organizations/spend_limit_increase_requests", "api/beta/organization/spend_limits/increase_requests/list", "IncreaseRequestListParams", "BetaSpendLimitIncreaseRequest", "", "", "actor_ids[],limit,page,status[]", "", "", Auth::kAdmin, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kSpendLimitsIncreaseRequestsRetrieve, "organization.spend_limits.increase_requests.retrieve", "GET", "/v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id}", "api/beta/organization/spend_limits/increase_requests/retrieve", "", "BetaSpendLimitIncreaseRequest", "", "", "", "", "", Auth::kAdmin, Kind::kRead, Page::kNone, Wire::kJson, false, false}, + {Call::kSpendLimitsList, "organization.spend_limits.list", "GET", "/v1/organizations/spend_limits", "api/beta/organization/spend_limits/list", "SpendLimitListParams", "BetaSpendLimit", "", "", "limit,page,scope_type[],workspace_id", "", "spend-limit-reads-2026-09-26", Auth::kAdmin, Kind::kRead, Page::kCursor, Wire::kJson, true, false}, + {Call::kSpendLimitsRetrieve, "organization.spend_limits.retrieve", "GET", "/v1/organizations/spend_limits/{spend_limit_id}", "api/beta/organization/spend_limits/retrieve", "", "BetaSpendLimit", "", "", "", "", "", Auth::kAdmin, Kind::kRead, Page::kNone, Wire::kJson, false, false}, + {Call::kSpendLimitsSet, "organization.spend_limits.set", "POST", "/v1/organizations/spend_limits", "api/beta/organization/spend_limits/set", "SpendLimitSetParams", "BetaSpendLimit", "amount,scope,period", "amount,scope", "", "", "", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kTelemetryDestinationsCreate, "organization.telemetry_destinations.create", "POST", "/v1/organizations/telemetry_destinations", "api/beta/organization/telemetry_destinations/create", "TelemetryDestinationCreateParams", "BetaTelemetryDestination", "endpoint_url,workspaces,display_name,headers,traces", "endpoint_url,workspaces", "", "", "telemetry-destinations-2026-08-11", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kTelemetryDestinationsDelete, "organization.telemetry_destinations.delete", "DELETE", "/v1/organizations/telemetry_destinations/{destination_id}", "api/beta/organization/telemetry_destinations/delete", "", "BetaDeletedTelemetryDestination", "", "", "", "", "telemetry-destinations-2026-08-11", Auth::kAdmin, Kind::kDestructive, Page::kNone, Wire::kJson, false, false}, + {Call::kTelemetryDestinationsList, "organization.telemetry_destinations.list", "GET", "/v1/organizations/telemetry_destinations", "api/beta/organization/telemetry_destinations/list", "TelemetryDestinationListParams", "BetaTelemetryDestination", "", "", "limit,page,workspace_ids[]", "", "telemetry-destinations-2026-08-11", Auth::kAdmin, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kTelemetryDestinationsRetrieve, "organization.telemetry_destinations.retrieve", "GET", "/v1/organizations/telemetry_destinations/{destination_id}", "api/beta/organization/telemetry_destinations/retrieve", "", "BetaTelemetryDestination", "", "", "", "", "telemetry-destinations-2026-08-11", Auth::kAdmin, Kind::kRead, Page::kNone, Wire::kJson, false, false}, + {Call::kTelemetryDestinationsTest, "organization.telemetry_destinations.test", "POST", "/v1/organizations/telemetry_destinations/{destination_id}/test", "api/beta/organization/telemetry_destinations/test", "", "BetaTelemetryDestinationTestResponse", "", "", "", "", "telemetry-destinations-2026-08-11", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kTelemetryDestinationsUpdate, "organization.telemetry_destinations.update", "POST", "/v1/organizations/telemetry_destinations/{destination_id}", "api/beta/organization/telemetry_destinations/update", "TelemetryDestinationUpdateParams", "BetaTelemetryDestination", "display_name,endpoint_url,headers,state,traces,workspaces", "", "", "", "telemetry-destinations-2026-08-11", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kTelemetryDestinationsWorkspacesAdd, "organization.telemetry_destinations.workspaces.add", "POST", "/v1/organizations/telemetry_destinations/{destination_id}/workspaces/{workspace_id}", "api/beta/organization/telemetry_destinations/workspaces/add", "", "BetaTelemetryDestinationWorkspace", "", "", "", "", "telemetry-destinations-2026-08-11", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kTelemetryDestinationsWorkspacesList, "organization.telemetry_destinations.workspaces.list", "GET", "/v1/organizations/telemetry_destinations/{destination_id}/workspaces", "api/beta/organization/telemetry_destinations/workspaces/list", "WorkspaceListParams", "BetaTelemetryDestinationWorkspace", "", "", "limit,page", "", "telemetry-destinations-2026-08-11", Auth::kAdmin, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kTelemetryDestinationsWorkspacesRemove, "organization.telemetry_destinations.workspaces.remove", "DELETE", "/v1/organizations/telemetry_destinations/{destination_id}/workspaces/{workspace_id}", "api/beta/organization/telemetry_destinations/workspaces/remove", "", "BetaDeletedTelemetryDestinationWorkspace", "", "", "", "", "telemetry-destinations-2026-08-11", Auth::kAdmin, Kind::kDestructive, Page::kNone, Wire::kJson, false, false}, + {Call::kUsageReportRetrieveClaudeCode, "organization.usage_report.retrieve_claude_code", "GET", "/v1/organizations/usage_report/claude_code", "api/beta/organization/usage_report/retrieve_claude_code", "", "BetaClaudeCodeUsageReport", "", "starting_at", "starting_at,limit,page", "", "", Auth::kAdmin, Kind::kRead, Page::kReport, Wire::kJson, false, true}, + {Call::kUsageReportRetrieveMessages, "organization.usage_report.retrieve_messages", "GET", "/v1/organizations/usage_report/messages", "api/beta/organization/usage_report/retrieve_messages", "", "BetaMessagesUsageReport", "", "starting_at", "starting_at,account_ids[],api_key_ids[],bucket_width,context_window[],ending_at,group_by[],inference_geos[],limit,models[],page,service_account_ids[],service_tiers[],speeds[],workspace_ids[]", "", "", Auth::kAdmin, Kind::kRead, Page::kReport, Wire::kJson, false, true}, + {Call::kUsersList, "organization.users.list", "GET", "/v1/organizations/users", "api/organization/users/list", "UserListParams", "BetaOrganizationUser", "", "", "after_id,before_id,email,limit,roles[]", "", "", Auth::kAdmin, Kind::kRead, Page::kIds, Wire::kJson, false, false}, + {Call::kUsersRemove, "organization.users.remove", "DELETE", "/v1/organizations/users/{user_id}", "api/organization/users/remove", "", "UserRemoveResponse", "", "", "", "", "", Auth::kAdmin, Kind::kDestructive, Page::kNone, Wire::kJson, false, false}, + {Call::kUsersRetrieve, "organization.users.retrieve", "GET", "/v1/organizations/users/{user_id}", "api/organization/users/retrieve", "", "BetaOrganizationUser", "", "", "", "", "", Auth::kAdmin, Kind::kRead, Page::kNone, Wire::kJson, false, false}, + {Call::kUsersUpdate, "organization.users.update", "POST", "/v1/organizations/users/{user_id}", "api/organization/users/update", "UserUpdateParams", "BetaOrganizationUser", "role", "role", "", "", "", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kWebhooksCreate, "organization.webhooks.create", "POST", "/v1/organizations/webhooks", "api/beta/organization/webhooks/create", "WebhookCreateParams", "BetaNewOrganizationWebhookEndpoint", "enabled_events,url,description,name", "enabled_events,url", "", "", "webhooks-2026-10-07", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kWebhooksDelete, "organization.webhooks.delete", "DELETE", "/v1/organizations/webhooks/{webhook_endpoint_id}", "api/beta/organization/webhooks/delete", "", "BetaDeletedOrganizationWebhookEndpoint", "", "", "", "", "webhooks-2026-10-07", Auth::kAdmin, Kind::kDestructive, Page::kNone, Wire::kJson, false, false}, + {Call::kWebhooksList, "organization.webhooks.list", "GET", "/v1/organizations/webhooks", "api/beta/organization/webhooks/list", "WebhookListParams", "BetaOrganizationWebhookEndpoint", "", "", "after_id,before_id,limit,order", "", "webhooks-2026-10-07", Auth::kAdmin, Kind::kRead, Page::kIds, Wire::kJson, false, false}, + {Call::kWebhooksRegenerateSigningSecret, "organization.webhooks.regenerate_signing_secret", "POST", "/v1/organizations/webhooks/{webhook_endpoint_id}/regenerate_signing_secret", "api/beta/organization/webhooks/regenerate_signing_secret", "", "BetaOrganizationWebhookEndpointSigningSecret", "", "", "", "", "webhooks-2026-10-07", Auth::kAdmin, Kind::kDestructive, Page::kNone, Wire::kJson, false, false}, + {Call::kWebhooksRetrieve, "organization.webhooks.retrieve", "GET", "/v1/organizations/webhooks/{webhook_endpoint_id}", "api/beta/organization/webhooks/retrieve", "", "BetaOrganizationWebhookEndpoint", "", "", "", "", "webhooks-2026-10-07", Auth::kAdmin, Kind::kRead, Page::kNone, Wire::kJson, false, false}, + {Call::kWebhooksUpdate, "organization.webhooks.update", "POST", "/v1/organizations/webhooks/{webhook_endpoint_id}", "api/beta/organization/webhooks/update", "WebhookUpdateParams", "BetaOrganizationWebhookEndpoint", "description,enabled_events,name,state,url", "", "", "", "webhooks-2026-10-07", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kWorkspacesArchive, "organization.workspaces.archive", "POST", "/v1/organizations/workspaces/{workspace_id}/archive", "api/organization/workspaces/archive", "", "BetaWorkspace", "", "", "", "", "", Auth::kAdmin, Kind::kDestructive, Page::kNone, Wire::kJson, false, false}, + {Call::kWorkspacesCreate, "organization.workspaces.create", "POST", "/v1/organizations/workspaces", "api/organization/workspaces/create", "WorkspaceCreateParams", "BetaWorkspace", "name,data_residency,display_color,external_key_id,tags", "name", "", "", "", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kWorkspacesList, "organization.workspaces.list", "GET", "/v1/organizations/workspaces", "api/organization/workspaces/list", "WorkspaceListParams", "BetaWorkspace", "", "", "after_id,before_id,include_archived,include_default,limit", "", "", Auth::kAdmin, Kind::kRead, Page::kIds, Wire::kJson, false, false}, + {Call::kWorkspacesMembersAdd, "organization.workspaces.members.add", "POST", "/v1/organizations/workspaces/{workspace_id}/members", "api/organization/workspaces/members/add", "MemberAddParams", "BetaWorkspaceMember", "user_id,workspace_role", "user_id,workspace_role", "", "", "", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kWorkspacesMembersList, "organization.workspaces.members.list", "GET", "/v1/organizations/workspaces/{workspace_id}/members", "api/organization/workspaces/members/list", "MemberListParams", "BetaWorkspaceMember", "", "", "after_id,before_id,limit", "", "", Auth::kAdmin, Kind::kRead, Page::kIds, Wire::kJson, false, false}, + {Call::kWorkspacesMembersRemove, "organization.workspaces.members.remove", "DELETE", "/v1/organizations/workspaces/{workspace_id}/members/{user_id}", "api/organization/workspaces/members/remove", "", "MemberRemoveResponse", "", "", "", "", "", Auth::kAdmin, Kind::kDestructive, Page::kNone, Wire::kJson, true, false}, + {Call::kWorkspacesMembersRetrieve, "organization.workspaces.members.retrieve", "GET", "/v1/organizations/workspaces/{workspace_id}/members/{user_id}", "api/organization/workspaces/members/retrieve", "", "BetaWorkspaceMember", "", "", "", "", "", Auth::kAdmin, Kind::kRead, Page::kNone, Wire::kJson, true, false}, + {Call::kWorkspacesMembersUpdate, "organization.workspaces.members.update", "POST", "/v1/organizations/workspaces/{workspace_id}/members/{user_id}", "api/organization/workspaces/members/update", "MemberUpdateParams", "BetaWorkspaceMember", "workspace_role", "workspace_role", "", "", "", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kWorkspacesRateLimitsList, "organization.workspaces.rate_limits.list", "GET", "/v1/organizations/workspaces/{workspace_id}/rate_limits", "api/organization/workspaces/rate_limits/list", "RateLimitListParams", "BetaWorkspaceRateLimit", "", "", "group_type,include_inherited,limit,page", "", "", Auth::kAdmin, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kWorkspacesRateLimitsUpdate, "organization.workspaces.rate_limits.update", "POST", "/v1/organizations/workspaces/{workspace_id}/rate_limits/{rate_limit_id}", "api/organization/workspaces/rate_limits/update", "RateLimitUpdateParams", "BetaWorkspaceRateLimit", "limits", "limits", "", "", "", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kWorkspacesRetrieve, "organization.workspaces.retrieve", "GET", "/v1/organizations/workspaces/{workspace_id}", "api/organization/workspaces/retrieve", "", "BetaWorkspace", "", "", "", "", "", Auth::kAdmin, Kind::kRead, Page::kNone, Wire::kJson, false, false}, + {Call::kWorkspacesUpdate, "organization.workspaces.update", "POST", "/v1/organizations/workspaces/{workspace_id}", "api/organization/workspaces/update", "WorkspaceUpdateParams", "BetaWorkspace", "data_residency,display_color,external_key_id,name,tags", "", "", "", "", Auth::kAdmin, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kFederationIssuersArchive, "organization.federation.issuers.archive", "POST", "/v1/organizations/federation_issuers/{federation_issuer_id}/archive", "api/organization/federation/issuers/archive", "", "BetaFederationIssuer", "", "", "", "", "", Auth::kOAuth, Kind::kDestructive, Page::kNone, Wire::kJson, false, false}, + {Call::kFederationIssuersCreate, "organization.federation.issuers.create", "POST", "/v1/organizations/federation_issuers", "api/organization/federation/issuers/create", "IssuerCreateParams", "BetaFederationIssuer", "issuer_url,name,check_jti,jwks,max_jwt_lifetime_seconds", "issuer_url,name", "", "", "", Auth::kOAuth, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kFederationIssuersList, "organization.federation.issuers.list", "GET", "/v1/organizations/federation_issuers", "api/organization/federation/issuers/list", "IssuerListParams", "BetaFederationIssuer", "", "", "include_archived,limit,page", "", "", Auth::kOAuth, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kFederationIssuersRetrieve, "organization.federation.issuers.retrieve", "GET", "/v1/organizations/federation_issuers/{federation_issuer_id}", "api/organization/federation/issuers/retrieve", "", "BetaFederationIssuer", "", "", "", "", "", Auth::kOAuth, Kind::kRead, Page::kNone, Wire::kJson, false, false}, + {Call::kFederationIssuersUpdate, "organization.federation.issuers.update", "POST", "/v1/organizations/federation_issuers/{federation_issuer_id}", "api/organization/federation/issuers/update", "IssuerUpdateParams", "BetaFederationIssuer", "check_jti,issuer_url,jwks,jwks_polling_disabled,max_jwt_lifetime_seconds,name", "", "", "", "", Auth::kOAuth, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kFederationRulesArchive, "organization.federation.rules.archive", "POST", "/v1/organizations/federation_rules/{federation_rule_id}/archive", "api/organization/federation/rules/archive", "", "BetaFederationRule", "", "", "", "", "", Auth::kOAuth, Kind::kDestructive, Page::kNone, Wire::kJson, false, false}, + {Call::kFederationRulesCreate, "organization.federation.rules.create", "POST", "/v1/organizations/federation_rules", "api/organization/federation/rules/create", "RuleCreateParams", "BetaFederationRule", "issuer_id,match,name,oauth_scope,target,applies_to_all_workspaces,attributes,description,token_lifetime_seconds,workspace_id", "issuer_id,match,name,oauth_scope,target", "", "", "", Auth::kOAuth, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kFederationRulesList, "organization.federation.rules.list", "GET", "/v1/organizations/federation_rules", "api/organization/federation/rules/list", "RuleListParams", "BetaFederationRule", "", "", "include_archived,issuer_id,limit,page", "", "", Auth::kOAuth, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kFederationRulesRetrieve, "organization.federation.rules.retrieve", "GET", "/v1/organizations/federation_rules/{federation_rule_id}", "api/organization/federation/rules/retrieve", "", "BetaFederationRule", "", "", "", "", "", Auth::kOAuth, Kind::kRead, Page::kNone, Wire::kJson, false, false}, + {Call::kFederationRulesUpdate, "organization.federation.rules.update", "POST", "/v1/organizations/federation_rules/{federation_rule_id}", "api/organization/federation/rules/update", "RuleUpdateParams", "BetaFederationRule", "applies_to_all_workspaces,attributes,description,match,name,oauth_scope,target,token_lifetime_seconds,workspace_id", "", "", "", "", Auth::kOAuth, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kFederationRulesWorkspacesAdd, "organization.federation.rules.workspaces.add", "POST", "/v1/organizations/federation_rules/{federation_rule_id}/workspaces", "api/organization/federation/rules/workspaces/add", "WorkspaceAddParams", "BetaFederationRuleWorkspace", "workspace_id", "workspace_id", "", "", "", Auth::kOAuth, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kFederationRulesWorkspacesList, "organization.federation.rules.workspaces.list", "GET", "/v1/organizations/federation_rules/{federation_rule_id}/workspaces", "api/organization/federation/rules/workspaces/list", "WorkspaceListParams", "BetaFederationRuleWorkspace", "", "", "limit,page", "", "", Auth::kOAuth, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kFederationRulesWorkspacesRemove, "organization.federation.rules.workspaces.remove", "DELETE", "/v1/organizations/federation_rules/{federation_rule_id}/workspaces/{workspace_id}", "api/organization/federation/rules/workspaces/remove", "", "WorkspaceRemoveResponse", "", "", "", "", "", Auth::kOAuth, Kind::kDestructive, Page::kNone, Wire::kJson, false, false}, + {Call::kServiceAccountsArchive, "organization.service_accounts.archive", "POST", "/v1/organizations/service_accounts/{service_account_id}/archive", "api/organization/service_accounts/archive", "", "BetaServiceAccount", "", "", "", "", "", Auth::kOAuth, Kind::kDestructive, Page::kNone, Wire::kJson, false, false}, + {Call::kServiceAccountsCreate, "organization.service_accounts.create", "POST", "/v1/organizations/service_accounts", "api/organization/service_accounts/create", "ServiceAccountCreateParams", "BetaServiceAccount", "name,description,organization_role", "name", "", "", "", Auth::kOAuth, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kServiceAccountsList, "organization.service_accounts.list", "GET", "/v1/organizations/service_accounts", "api/organization/service_accounts/list", "ServiceAccountListParams", "BetaServiceAccount", "", "", "include_archived,limit,page", "", "", Auth::kOAuth, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kServiceAccountsRetrieve, "organization.service_accounts.retrieve", "GET", "/v1/organizations/service_accounts/{service_account_id}", "api/organization/service_accounts/retrieve", "", "BetaServiceAccount", "", "", "", "", "", Auth::kOAuth, Kind::kRead, Page::kNone, Wire::kJson, false, false}, + {Call::kServiceAccountsUpdate, "organization.service_accounts.update", "POST", "/v1/organizations/service_accounts/{service_account_id}", "api/organization/service_accounts/update", "ServiceAccountUpdateParams", "BetaServiceAccount", "description,organization_role", "", "", "", "", Auth::kOAuth, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kServiceAccountsWorkspacesAdd, "organization.service_accounts.workspaces.add", "POST", "/v1/organizations/service_accounts/{service_account_id}/workspaces", "api/organization/service_accounts/workspaces/add", "WorkspaceAddParams", "BetaServiceAccountWorkspaceMember", "workspace_id,workspace_role", "workspace_id,workspace_role", "", "", "", Auth::kOAuth, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kServiceAccountsWorkspacesList, "organization.service_accounts.workspaces.list", "GET", "/v1/organizations/service_accounts/{service_account_id}/workspaces", "api/organization/service_accounts/workspaces/list", "WorkspaceListParams", "BetaServiceAccountWorkspaceMember", "", "", "limit,page", "", "", Auth::kOAuth, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kServiceAccountsWorkspacesRemove, "organization.service_accounts.workspaces.remove", "DELETE", "/v1/organizations/service_accounts/{service_account_id}/workspaces/{workspace_id}", "api/organization/service_accounts/workspaces/remove", "", "WorkspaceRemoveResponse", "", "", "", "", "", Auth::kOAuth, Kind::kDestructive, Page::kNone, Wire::kJson, false, false}, + {Call::kWorkspacesServiceAccountsAdd, "organization.workspaces.service_accounts.add", "POST", "/v1/organizations/workspaces/{workspace_id}/service_accounts", "api/organization/workspaces/service_accounts/add", "ServiceAccountAddParams", "BetaServiceAccountWorkspaceMember", "service_account_id,workspace_role", "service_account_id,workspace_role", "", "", "", Auth::kOAuth, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kWorkspacesServiceAccountsList, "organization.workspaces.service_accounts.list", "GET", "/v1/organizations/workspaces/{workspace_id}/service_accounts", "api/organization/workspaces/service_accounts/list", "ServiceAccountListParams", "BetaServiceAccountWorkspaceMember", "", "", "limit,page", "", "", Auth::kOAuth, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kWorkspacesServiceAccountsRemove, "organization.workspaces.service_accounts.remove", "DELETE", "/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}", "api/organization/workspaces/service_accounts/remove", "", "ServiceAccountRemoveResponse", "", "", "", "", "", Auth::kOAuth, Kind::kDestructive, Page::kNone, Wire::kJson, true, false}, + {Call::kWorkspacesServiceAccountsRetrieve, "organization.workspaces.service_accounts.retrieve", "GET", "/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}", "api/organization/workspaces/service_accounts/retrieve", "", "BetaServiceAccountWorkspaceMember", "", "", "", "", "", Auth::kOAuth, Kind::kRead, Page::kNone, Wire::kJson, true, false}, + {Call::kWorkspacesServiceAccountsUpdate, "organization.workspaces.service_accounts.update", "POST", "/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}", "api/organization/workspaces/service_accounts/update", "ServiceAccountUpdateParams", "BetaServiceAccountWorkspaceMember", "workspace_role", "workspace_role", "", "", "", Auth::kOAuth, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kAgentsArchive, "agents.archive", "POST", "/v1/agents/{agent_id}/archive", "api/beta/agents/archive", "", "BetaManagedAgentsAgent", "", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kDestructive, Page::kNone, Wire::kJson, true, false}, + {Call::kAgentsCreate, "agents.create", "POST", "/v1/agents", "api/beta/agents/create", "AgentCreateParams", "BetaManagedAgentsAgent", "model,name,description,execution_identity,mcp_servers,metadata,multiagent,skills,system,tools", "model,name", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kAgentsList, "agents.list", "GET", "/v1/agents", "api/beta/agents/list", "AgentListParams", "BetaManagedAgentsAgent", "", "", "created_at[gte],created_at[lte],include_archived,limit,page", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kRead, Page::kCursor, Wire::kJson, true, false}, + {Call::kAgentsRetrieve, "agents.retrieve", "GET", "/v1/agents/{agent_id}", "api/beta/agents/retrieve", "AgentRetrieveParams", "BetaManagedAgentsAgent", "", "", "version", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kRead, Page::kNone, Wire::kJson, true, false}, + {Call::kAgentsUpdate, "agents.update", "POST", "/v1/agents/{agent_id}", "api/beta/agents/update", "AgentUpdateParams", "BetaManagedAgentsAgent", "description,execution_identity,mcp_servers,metadata,model,multiagent,name,skills,system,tools,version", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kAgentsVersionsList, "agents.versions.list", "GET", "/v1/agents/{agent_id}/versions", "api/beta/agents/versions/list", "VersionListParams", "BetaManagedAgentsAgent", "", "", "limit,page", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kRead, Page::kCursor, Wire::kJson, true, false}, + {Call::kDeploymentRunsList, "deployment_runs.list", "GET", "/v1/deployment_runs", "api/beta/deployment_runs/list", "DeploymentRunListParams", "BetaManagedAgentsDeploymentRun", "", "", "created_at[gt],created_at[gte],created_at[lt],created_at[lte],deployment_id,has_error,limit,page,trigger_type", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kRead, Page::kCursor, Wire::kJson, true, false}, + {Call::kDeploymentRunsRetrieve, "deployment_runs.retrieve", "GET", "/v1/deployment_runs/{deployment_run_id}", "api/beta/deployment_runs/retrieve", "", "BetaManagedAgentsDeploymentRun", "", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kRead, Page::kNone, Wire::kJson, true, false}, + {Call::kDeploymentsArchive, "deployments.archive", "POST", "/v1/deployments/{deployment_id}/archive", "api/beta/deployments/archive", "", "BetaManagedAgentsDeployment", "", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kDestructive, Page::kNone, Wire::kJson, true, false}, + {Call::kDeploymentsCreate, "deployments.create", "POST", "/v1/deployments", "api/beta/deployments/create", "DeploymentCreateParams", "BetaManagedAgentsDeployment", "agent,environment_id,initial_events,name,budget,description,metadata,resources,schedule,vault_ids", "agent,environment_id,initial_events,name", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kDeploymentsList, "deployments.list", "GET", "/v1/deployments", "api/beta/deployments/list", "DeploymentListParams", "BetaManagedAgentsDeployment", "", "", "agent_id,created_at[gte],created_at[lte],include_archived,limit,page,status", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kRead, Page::kCursor, Wire::kJson, true, false}, + {Call::kDeploymentsPause, "deployments.pause", "POST", "/v1/deployments/{deployment_id}/pause", "api/beta/deployments/pause", "", "BetaManagedAgentsDeployment", "", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kDestructive, Page::kNone, Wire::kJson, true, false}, + {Call::kDeploymentsRetrieve, "deployments.retrieve", "GET", "/v1/deployments/{deployment_id}", "api/beta/deployments/retrieve", "", "BetaManagedAgentsDeployment", "", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kRead, Page::kNone, Wire::kJson, true, false}, + {Call::kDeploymentsRun, "deployments.run", "POST", "/v1/deployments/{deployment_id}/run", "api/beta/deployments/run", "", "BetaManagedAgentsDeploymentRun", "", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kDeploymentsUnpause, "deployments.unpause", "POST", "/v1/deployments/{deployment_id}/unpause", "api/beta/deployments/unpause", "", "BetaManagedAgentsDeployment", "", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kDeploymentsUpdate, "deployments.update", "POST", "/v1/deployments/{deployment_id}", "api/beta/deployments/update", "DeploymentUpdateParams", "BetaManagedAgentsDeployment", "agent,budget,description,environment_id,initial_events,metadata,name,resources,schedule,vault_ids", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kDreamsArchive, "dreams.archive", "POST", "/v1/dreams/{dream_id}/archive", "api/beta/dreams/archive", "", "BetaDream", "", "", "", "", "dreaming-2026-04-21", Auth::kPlatform, Kind::kDestructive, Page::kNone, Wire::kJson, true, false}, + {Call::kDreamsCancel, "dreams.cancel", "POST", "/v1/dreams/{dream_id}/cancel", "api/beta/dreams/cancel", "", "BetaDream", "", "", "", "", "dreaming-2026-04-21", Auth::kPlatform, Kind::kDestructive, Page::kNone, Wire::kJson, true, false}, + {Call::kDreamsCreate, "dreams.create", "POST", "/v1/dreams", "api/beta/dreams/create", "DreamCreateParams", "BetaDream", "inputs,model,instructions,output_behavior", "inputs,model", "", "", "dreaming-2026-04-21", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kDreamsList, "dreams.list", "GET", "/v1/dreams", "api/beta/dreams/list", "DreamListParams", "BetaDream", "", "", "created_at[gt],created_at[lt],include_archived,limit,page,statuses[]", "", "dreaming-2026-04-21", Auth::kPlatform, Kind::kRead, Page::kCursor, Wire::kJson, true, false}, + {Call::kDreamsRetrieve, "dreams.retrieve", "GET", "/v1/dreams/{dream_id}", "api/beta/dreams/retrieve", "", "BetaDream", "", "", "", "", "dreaming-2026-04-21", Auth::kPlatform, Kind::kRead, Page::kNone, Wire::kJson, true, false}, + {Call::kEnvironmentsArchive, "environments.archive", "POST", "/v1/environments/{environment_id}/archive", "api/beta/environments/archive", "", "BetaEnvironment", "", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kDestructive, Page::kNone, Wire::kJson, true, false}, + {Call::kEnvironmentsCreate, "environments.create", "POST", "/v1/environments", "api/beta/environments/create", "EnvironmentCreateParams", "BetaEnvironment", "name,config,description,metadata,scope", "name", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kEnvironmentsDelete, "environments.delete", "DELETE", "/v1/environments/{environment_id}", "api/beta/environments/delete", "", "BetaEnvironmentDeleteResponse", "", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kDestructive, Page::kNone, Wire::kJson, true, false}, + {Call::kEnvironmentsList, "environments.list", "GET", "/v1/environments", "api/beta/environments/list", "EnvironmentListParams", "BetaEnvironment", "", "", "include_archived,limit,page", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kRead, Page::kCursor, Wire::kJson, true, false}, + {Call::kEnvironmentsRetrieve, "environments.retrieve", "GET", "/v1/environments/{environment_id}", "api/beta/environments/retrieve", "", "BetaEnvironment", "", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kRead, Page::kNone, Wire::kJson, true, false}, + {Call::kEnvironmentsUpdate, "environments.update", "POST", "/v1/environments/{environment_id}", "api/beta/environments/update", "EnvironmentUpdateParams", "BetaEnvironment", "config,description,metadata,name,scope", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kEnvironmentsWorkAck, "environments.work.ack", "POST", "/v1/environments/{environment_id}/work/{work_id}/ack", "api/beta/environments/work/ack", "", "BetaSelfHostedWork", "", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kEnvironmentsWorkHeartbeat, "environments.work.heartbeat", "POST", "/v1/environments/{environment_id}/work/{work_id}/heartbeat", "api/beta/environments/work/heartbeat", "WorkHeartbeatParams", "BetaSelfHostedWorkHeartbeatResponse", "", "", "desired_ttl_seconds,expected_last_heartbeat", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, false, false}, + {Call::kEnvironmentsWorkList, "environments.work.list", "GET", "/v1/environments/{environment_id}/work", "api/beta/environments/work/list", "WorkListParams", "BetaSelfHostedWork", "", "", "limit,page", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kRead, Page::kCursor, Wire::kJson, false, false}, + {Call::kEnvironmentsWorkPoll, "environments.work.poll", "GET", "/v1/environments/{environment_id}/work/poll", "api/beta/environments/work/poll", "WorkPollParams", "BetaSelfHostedWork", "", "", "block_ms,reclaim_older_than_ms", "anthropic_worker_id=Anthropic-Worker-ID", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kRead, Page::kNone, Wire::kJson, false, false}, + {Call::kEnvironmentsWorkRetrieve, "environments.work.retrieve", "GET", "/v1/environments/{environment_id}/work/{work_id}", "api/beta/environments/work/retrieve", "", "BetaSelfHostedWork", "", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kRead, Page::kNone, Wire::kJson, true, false}, + {Call::kEnvironmentsWorkStats, "environments.work.stats", "GET", "/v1/environments/{environment_id}/work/stats", "api/beta/environments/work/stats", "", "BetaSelfHostedWorkQueueStats", "", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kRead, Page::kNone, Wire::kJson, true, false}, + {Call::kEnvironmentsWorkStop, "environments.work.stop", "POST", "/v1/environments/{environment_id}/work/{work_id}/stop", "api/beta/environments/work/stop", "WorkStopParams", "BetaSelfHostedWork", "force", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kDestructive, Page::kNone, Wire::kJson, true, false}, + {Call::kEnvironmentsWorkUpdate, "environments.work.update", "POST", "/v1/environments/{environment_id}/work/{work_id}", "api/beta/environments/work/update", "WorkUpdateParams", "BetaSelfHostedWork", "metadata", "metadata", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kMemoryStoresArchive, "memory_stores.archive", "POST", "/v1/memory_stores/{memory_store_id}/archive", "api/beta/memory_stores/archive", "", "BetaManagedAgentsMemoryStore", "", "", "", "", "agent-memory-2026-07-22", Auth::kPlatform, Kind::kDestructive, Page::kNone, Wire::kJson, true, false}, + {Call::kMemoryStoresCreate, "memory_stores.create", "POST", "/v1/memory_stores", "api/beta/memory_stores/create", "MemoryStoreCreateParams", "BetaManagedAgentsMemoryStore", "name,description,metadata", "name", "", "", "agent-memory-2026-07-22", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kMemoryStoresDelete, "memory_stores.delete", "DELETE", "/v1/memory_stores/{memory_store_id}", "api/beta/memory_stores/delete", "", "BetaManagedAgentsDeletedMemoryStore", "", "", "", "", "agent-memory-2026-07-22", Auth::kPlatform, Kind::kDestructive, Page::kNone, Wire::kJson, true, false}, + {Call::kMemoryStoresList, "memory_stores.list", "GET", "/v1/memory_stores", "api/beta/memory_stores/list", "MemoryStoreListParams", "BetaManagedAgentsMemoryStore", "", "", "created_at[gte],created_at[lte],include_archived,limit,page", "", "agent-memory-2026-07-22", Auth::kPlatform, Kind::kRead, Page::kCursor, Wire::kJson, true, false}, + {Call::kMemoryStoresMemoriesCreate, "memory_stores.memories.create", "POST", "/v1/memory_stores/{memory_store_id}/memories", "api/beta/memory_stores/memories/create", "MemoryCreateParams", "BetaManagedAgentsMemory", "content,path", "content,path", "view", "", "agent-memory-2026-07-22", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kMemoryStoresMemoriesDelete, "memory_stores.memories.delete", "DELETE", "/v1/memory_stores/{memory_store_id}/memories/{memory_id}", "api/beta/memory_stores/memories/delete", "MemoryDeleteParams", "BetaManagedAgentsDeletedMemory", "", "", "expected_content_sha256", "", "agent-memory-2026-07-22", Auth::kPlatform, Kind::kDestructive, Page::kNone, Wire::kJson, true, false}, + {Call::kMemoryStoresMemoriesList, "memory_stores.memories.list", "GET", "/v1/memory_stores/{memory_store_id}/memories", "api/beta/memory_stores/memories/list", "MemoryListParams", "BetaManagedAgentsMemoryListItem", "", "", "depth,limit,page,path_prefix,view", "", "agent-memory-2026-07-22", Auth::kPlatform, Kind::kRead, Page::kCursor, Wire::kJson, true, false}, + {Call::kMemoryStoresMemoriesRetrieve, "memory_stores.memories.retrieve", "GET", "/v1/memory_stores/{memory_store_id}/memories/{memory_id}", "api/beta/memory_stores/memories/retrieve", "MemoryRetrieveParams", "BetaManagedAgentsMemory", "", "", "view", "", "agent-memory-2026-07-22", Auth::kPlatform, Kind::kRead, Page::kNone, Wire::kJson, true, false}, + {Call::kMemoryStoresMemoriesUpdate, "memory_stores.memories.update", "POST", "/v1/memory_stores/{memory_store_id}/memories/{memory_id}", "api/beta/memory_stores/memories/update", "MemoryUpdateParams", "BetaManagedAgentsMemory", "content,path,precondition", "", "view", "", "agent-memory-2026-07-22", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kMemoryStoresMemoryVersionsList, "memory_stores.memory_versions.list", "GET", "/v1/memory_stores/{memory_store_id}/memory_versions", "api/beta/memory_stores/memory_versions/list", "MemoryVersionListParams", "BetaManagedAgentsMemoryVersion", "", "", "api_key_id,created_at[gte],created_at[lte],limit,memory_id,operation,page,service_account_id,session_id,view", "", "agent-memory-2026-07-22", Auth::kPlatform, Kind::kRead, Page::kCursor, Wire::kJson, true, false}, + {Call::kMemoryStoresMemoryVersionsRedact, "memory_stores.memory_versions.redact", "POST", "/v1/memory_stores/{memory_store_id}/memory_versions/{memory_version_id}/redact", "api/beta/memory_stores/memory_versions/redact", "", "BetaManagedAgentsMemoryVersion", "", "", "", "", "agent-memory-2026-07-22", Auth::kPlatform, Kind::kDestructive, Page::kNone, Wire::kJson, true, false}, + {Call::kMemoryStoresMemoryVersionsRetrieve, "memory_stores.memory_versions.retrieve", "GET", "/v1/memory_stores/{memory_store_id}/memory_versions/{memory_version_id}", "api/beta/memory_stores/memory_versions/retrieve", "MemoryVersionRetrieveParams", "BetaManagedAgentsMemoryVersion", "", "", "view", "", "agent-memory-2026-07-22", Auth::kPlatform, Kind::kRead, Page::kNone, Wire::kJson, true, false}, + {Call::kMemoryStoresRetrieve, "memory_stores.retrieve", "GET", "/v1/memory_stores/{memory_store_id}", "api/beta/memory_stores/retrieve", "", "BetaManagedAgentsMemoryStore", "", "", "", "", "agent-memory-2026-07-22", Auth::kPlatform, Kind::kRead, Page::kNone, Wire::kJson, true, false}, + {Call::kMemoryStoresUpdate, "memory_stores.update", "POST", "/v1/memory_stores/{memory_store_id}", "api/beta/memory_stores/update", "MemoryStoreUpdateParams", "BetaManagedAgentsMemoryStore", "description,metadata,name", "", "", "", "agent-memory-2026-07-22", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kSessionsArchive, "sessions.archive", "POST", "/v1/sessions/{session_id}/archive", "api/beta/sessions/archive", "", "BetaManagedAgentsSession", "", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kDestructive, Page::kNone, Wire::kJson, true, false}, + {Call::kSessionsCreate, "sessions.create", "POST", "/v1/sessions", "api/beta/sessions/create", "SessionCreateParams", "BetaManagedAgentsSession", "agent,environment_id,budget,initial_events,metadata,resources,title,vault_ids", "agent,environment_id", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kSessionsDelete, "sessions.delete", "DELETE", "/v1/sessions/{session_id}", "api/beta/sessions/delete", "", "BetaManagedAgentsDeletedSession", "", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kDestructive, Page::kNone, Wire::kJson, true, false}, + {Call::kSessionsEventsList, "sessions.events.list", "GET", "/v1/sessions/{session_id}/events", "api/beta/sessions/events/list", "EventListParams", "BetaManagedAgentsSessionEvent", "", "", "created_at[gt],created_at[gte],created_at[lt],created_at[lte],limit,order,page,types[]", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kRead, Page::kCursor, Wire::kJson, true, false}, + {Call::kSessionsEventsSend, "sessions.events.send", "POST", "/v1/sessions/{session_id}/events", "api/beta/sessions/events/send", "EventSendParams", "BetaManagedAgentsSendSessionEvents", "events", "events", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kSessionsEventsStream, "sessions.events.stream", "GET", "/v1/sessions/{session_id}/events/stream", "api/beta/sessions/events/stream", "EventStreamParams", "BetaManagedAgentsStreamSessionEvents", "", "", "event_deltas[]", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kRead, Page::kNone, Wire::kSse, true, false}, + {Call::kSessionsList, "sessions.list", "GET", "/v1/sessions", "api/beta/sessions/list", "SessionListParams", "BetaManagedAgentsSession", "", "", "agent_id,agent_version,created_at[gt],created_at[gte],created_at[lt],created_at[lte],deployment_id,include_archived,limit,memory_store_id,order,page,statuses[]", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kRead, Page::kBidirectional, Wire::kJson, true, false}, + {Call::kSessionsResourcesAdd, "sessions.resources.add", "POST", "/v1/sessions/{session_id}/resources", "api/beta/sessions/resources/add", "ResourceAddParams", "BetaManagedAgentsFileResource", "file_id,type,mount_path", "file_id,type", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kSessionsResourcesDelete, "sessions.resources.delete", "DELETE", "/v1/sessions/{session_id}/resources/{resource_id}", "api/beta/sessions/resources/delete", "", "BetaManagedAgentsDeleteSessionResource", "", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kDestructive, Page::kNone, Wire::kJson, true, false}, + {Call::kSessionsResourcesList, "sessions.resources.list", "GET", "/v1/sessions/{session_id}/resources", "api/beta/sessions/resources/list", "ResourceListParams", "BetaManagedAgentsSessionResource", "", "", "limit,page", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kRead, Page::kCursor, Wire::kJson, true, false}, + {Call::kSessionsResourcesRetrieve, "sessions.resources.retrieve", "GET", "/v1/sessions/{session_id}/resources/{resource_id}", "api/beta/sessions/resources/retrieve", "", "ResourceRetrieveResponse", "", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kRead, Page::kNone, Wire::kJson, true, false}, + {Call::kSessionsResourcesUpdate, "sessions.resources.update", "POST", "/v1/sessions/{session_id}/resources/{resource_id}", "api/beta/sessions/resources/update", "ResourceUpdateParams", "ResourceUpdateResponse", "authorization_token", "authorization_token", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kSessionsRetrieve, "sessions.retrieve", "GET", "/v1/sessions/{session_id}", "api/beta/sessions/retrieve", "", "BetaManagedAgentsSession", "", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kRead, Page::kNone, Wire::kJson, true, false}, + {Call::kSessionsThreadsArchive, "sessions.threads.archive", "POST", "/v1/sessions/{session_id}/threads/{thread_id}/archive", "api/beta/sessions/threads/archive", "", "BetaManagedAgentsSessionThread", "", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kDestructive, Page::kNone, Wire::kJson, true, false}, + {Call::kSessionsThreadsEventsList, "sessions.threads.events.list", "GET", "/v1/sessions/{session_id}/threads/{thread_id}/events", "api/beta/sessions/threads/events/list", "EventListParams", "BetaManagedAgentsSessionEvent", "", "", "limit,page", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kRead, Page::kCursor, Wire::kJson, true, false}, + {Call::kSessionsThreadsEventsStream, "sessions.threads.events.stream", "GET", "/v1/sessions/{session_id}/threads/{thread_id}/stream", "api/beta/sessions/threads/events/stream", "EventStreamParams", "BetaManagedAgentsStreamSessionThreadEvents", "", "", "event_deltas[]", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kRead, Page::kNone, Wire::kSse, true, false}, + {Call::kSessionsThreadsList, "sessions.threads.list", "GET", "/v1/sessions/{session_id}/threads", "api/beta/sessions/threads/list", "ThreadListParams", "BetaManagedAgentsSessionThread", "", "", "limit,page,statuses[]", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kRead, Page::kCursor, Wire::kJson, true, false}, + {Call::kSessionsThreadsRetrieve, "sessions.threads.retrieve", "GET", "/v1/sessions/{session_id}/threads/{thread_id}", "api/beta/sessions/threads/retrieve", "", "BetaManagedAgentsSessionThread", "", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kRead, Page::kNone, Wire::kJson, true, false}, + {Call::kSessionsUpdate, "sessions.update", "POST", "/v1/sessions/{session_id}", "api/beta/sessions/update", "SessionUpdateParams", "BetaManagedAgentsSession", "agent,budget,metadata,title,vault_ids", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kTunnelsArchive, "tunnels.archive", "POST", "/v1/tunnels/{tunnel_id}/archive", "api/beta/tunnels/archive", "", "BetaTunnel", "", "", "", "", "mcp-tunnels-2026-06-22", Auth::kPlatform, Kind::kDestructive, Page::kNone, Wire::kJson, true, false}, + {Call::kTunnelsCertificatesArchive, "tunnels.certificates.archive", "POST", "/v1/tunnels/{tunnel_id}/certificates/{certificate_id}/archive", "api/beta/tunnels/certificates/archive", "", "BetaTunnelCertificate", "", "", "", "", "mcp-tunnels-2026-06-22", Auth::kPlatform, Kind::kDestructive, Page::kNone, Wire::kJson, true, false}, + {Call::kTunnelsCertificatesCreate, "tunnels.certificates.create", "POST", "/v1/tunnels/{tunnel_id}/certificates", "api/beta/tunnels/certificates/create", "CertificateCreateParams", "BetaTunnelCertificate", "ca_certificate_pem", "ca_certificate_pem", "", "", "mcp-tunnels-2026-06-22", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kTunnelsCertificatesList, "tunnels.certificates.list", "GET", "/v1/tunnels/{tunnel_id}/certificates", "api/beta/tunnels/certificates/list", "CertificateListParams", "BetaTunnelCertificate", "", "", "include_archived,limit,page", "", "mcp-tunnels-2026-06-22", Auth::kPlatform, Kind::kRead, Page::kCursor, Wire::kJson, true, false}, + {Call::kTunnelsCertificatesRetrieve, "tunnels.certificates.retrieve", "GET", "/v1/tunnels/{tunnel_id}/certificates/{certificate_id}", "api/beta/tunnels/certificates/retrieve", "", "BetaTunnelCertificate", "", "", "", "", "mcp-tunnels-2026-06-22", Auth::kPlatform, Kind::kRead, Page::kNone, Wire::kJson, true, false}, + {Call::kTunnelsCreate, "tunnels.create", "POST", "/v1/tunnels", "api/beta/tunnels/create", "TunnelCreateParams", "BetaTunnel", "display_name", "", "", "", "mcp-tunnels-2026-06-22", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kTunnelsList, "tunnels.list", "GET", "/v1/tunnels", "api/beta/tunnels/list", "TunnelListParams", "BetaTunnel", "", "", "include_archived,limit,page", "", "mcp-tunnels-2026-06-22", Auth::kPlatform, Kind::kRead, Page::kCursor, Wire::kJson, true, false}, + {Call::kTunnelsRetrieve, "tunnels.retrieve", "GET", "/v1/tunnels/{tunnel_id}", "api/beta/tunnels/retrieve", "", "BetaTunnel", "", "", "", "", "mcp-tunnels-2026-06-22", Auth::kPlatform, Kind::kRead, Page::kNone, Wire::kJson, true, false}, + {Call::kTunnelsRevealToken, "tunnels.reveal_token", "POST", "/v1/tunnels/{tunnel_id}/reveal_token", "api/beta/tunnels/reveal_token", "", "BetaTunnelToken", "", "", "", "", "mcp-tunnels-2026-06-22", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kTunnelsRotateToken, "tunnels.rotate_token", "POST", "/v1/tunnels/{tunnel_id}/rotate_token", "api/beta/tunnels/rotate_token", "TunnelRotateTokenParams", "BetaTunnelToken", "reason", "", "", "", "mcp-tunnels-2026-06-22", Auth::kPlatform, Kind::kDestructive, Page::kNone, Wire::kJson, true, false}, + {Call::kUserProfilesActionUrlsCreate, "user_profiles.action_urls.create", "POST", "/v1/user_profiles/{user_profile_id}/action_urls", "api/user_profiles/action_urls/create", "ActionUrlCreateParams", "UserProfileActionURL", "action", "action", "", "", "", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kUserProfilesActionUrlsCreateBeta, "user_profiles.action_urls.createbeta", "POST", "/v1/user_profiles/{user_profile_id}/action_urls", "api/beta/user_profiles/action_urls/create", "ActionUrlCreateParams", "BetaUserProfileActionURL", "action", "action", "", "", "user-profiles-2026-08-18", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kUserProfilesCreate, "user_profiles.create", "POST", "/v1/user_profiles", "api/user_profiles/create", "UserProfileCreateParams", "UserProfile", "access_type,external_user_details,metadata,name", "", "", "", "", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kUserProfilesCreateBeta, "user_profiles.createbeta", "POST", "/v1/user_profiles", "api/beta/user_profiles/create", "UserProfileCreateParams", "BetaUserProfile", "access_type,external_id,external_user_details,external_user_onboarded_at,metadata,name", "", "", "", "user-profiles-2026-08-18", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kUserProfilesCreateEnrollmentUrl, "user_profiles.create_enrollment_url", "POST", "/v1/user_profiles/{user_profile_id}/enrollment_url", "api/beta/user_profiles/create_enrollment_url", "", "BetaUserProfileEnrollmentURL", "", "", "", "", "user-profiles-2026-08-18", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kUserProfilesDelete, "user_profiles.delete", "DELETE", "/v1/user_profiles/{user_profile_id}", "api/user_profiles/delete", "", "DeletedUserProfile", "", "", "", "", "", Auth::kPlatform, Kind::kDestructive, Page::kNone, Wire::kJson, true, false}, + {Call::kUserProfilesDeleteBeta, "user_profiles.deletebeta", "DELETE", "/v1/user_profiles/{user_profile_id}", "api/beta/user_profiles/delete", "", "BetaDeletedUserProfile", "", "", "", "", "user-profiles-2026-08-18", Auth::kPlatform, Kind::kDestructive, Page::kNone, Wire::kJson, true, false}, + {Call::kUserProfilesList, "user_profiles.list", "GET", "/v1/user_profiles", "api/user_profiles/list", "UserProfileListParams", "UserProfile", "", "", "enforcement_status[],limit,order,order_by,page", "", "", Auth::kPlatform, Kind::kRead, Page::kCursor, Wire::kJson, true, false}, + {Call::kUserProfilesListBeta, "user_profiles.listbeta", "GET", "/v1/user_profiles", "api/beta/user_profiles/list", "UserProfileListParams", "BetaUserProfile", "", "", "limit,order,order_by,page", "", "user-profiles-2026-08-18", Auth::kPlatform, Kind::kRead, Page::kCursor, Wire::kJson, true, false}, + {Call::kUserProfilesRetrieve, "user_profiles.retrieve", "GET", "/v1/user_profiles/{user_profile_id}", "api/user_profiles/retrieve", "", "UserProfile", "", "", "", "", "", Auth::kPlatform, Kind::kRead, Page::kNone, Wire::kJson, true, false}, + {Call::kUserProfilesRetrieveBeta, "user_profiles.retrievebeta", "GET", "/v1/user_profiles/{user_profile_id}", "api/beta/user_profiles/retrieve", "", "BetaUserProfile", "", "", "", "", "user-profiles-2026-08-18", Auth::kPlatform, Kind::kRead, Page::kNone, Wire::kJson, true, false}, + {Call::kUserProfilesUpdate, "user_profiles.update", "POST", "/v1/user_profiles/{user_profile_id}", "api/user_profiles/update", "UserProfileUpdateParams", "UserProfile", "access_type,external_user_details,metadata,name", "", "", "", "", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kUserProfilesUpdateBeta, "user_profiles.updatebeta", "POST", "/v1/user_profiles/{user_profile_id}", "api/beta/user_profiles/update", "UserProfileUpdateParams", "BetaUserProfile", "access_type,external_id,external_user_details,external_user_onboarded_at,metadata,name", "", "", "", "user-profiles-2026-08-18", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kVaultsArchive, "vaults.archive", "POST", "/v1/vaults/{vault_id}/archive", "api/beta/vaults/archive", "", "BetaManagedAgentsVault", "", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kDestructive, Page::kNone, Wire::kJson, true, false}, + {Call::kVaultsCreate, "vaults.create", "POST", "/v1/vaults", "api/beta/vaults/create", "VaultCreateParams", "BetaManagedAgentsVault", "display_name,metadata", "display_name", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kVaultsCredentialsArchive, "vaults.credentials.archive", "POST", "/v1/vaults/{vault_id}/credentials/{credential_id}/archive", "api/beta/vaults/credentials/archive", "", "BetaManagedAgentsCredential", "", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kDestructive, Page::kNone, Wire::kJson, true, false}, + {Call::kVaultsCredentialsCreate, "vaults.credentials.create", "POST", "/v1/vaults/{vault_id}/credentials", "api/beta/vaults/credentials/create", "CredentialCreateParams", "BetaManagedAgentsCredential", "auth,display_name,metadata", "auth", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kVaultsCredentialsDelete, "vaults.credentials.delete", "DELETE", "/v1/vaults/{vault_id}/credentials/{credential_id}", "api/beta/vaults/credentials/delete", "", "BetaManagedAgentsDeletedCredential", "", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kDestructive, Page::kNone, Wire::kJson, true, false}, + {Call::kVaultsCredentialsList, "vaults.credentials.list", "GET", "/v1/vaults/{vault_id}/credentials", "api/beta/vaults/credentials/list", "CredentialListParams", "BetaManagedAgentsCredential", "", "", "include_archived,limit,page", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kRead, Page::kCursor, Wire::kJson, true, false}, + {Call::kVaultsCredentialsMcpOauthValidate, "vaults.credentials.mcp_oauth_validate", "POST", "/v1/vaults/{vault_id}/credentials/{credential_id}/mcp_oauth_validate", "api/beta/vaults/credentials/mcp_oauth_validate", "", "BetaManagedAgentsCredentialValidation", "", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kVaultsCredentialsRetrieve, "vaults.credentials.retrieve", "GET", "/v1/vaults/{vault_id}/credentials/{credential_id}", "api/beta/vaults/credentials/retrieve", "", "BetaManagedAgentsCredential", "", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kRead, Page::kNone, Wire::kJson, true, false}, + {Call::kVaultsCredentialsUpdate, "vaults.credentials.update", "POST", "/v1/vaults/{vault_id}/credentials/{credential_id}", "api/beta/vaults/credentials/update", "CredentialUpdateParams", "BetaManagedAgentsCredential", "auth,display_name,metadata", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, + {Call::kVaultsDelete, "vaults.delete", "DELETE", "/v1/vaults/{vault_id}", "api/beta/vaults/delete", "", "BetaManagedAgentsDeletedVault", "", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kDestructive, Page::kNone, Wire::kJson, true, false}, + {Call::kVaultsList, "vaults.list", "GET", "/v1/vaults", "api/beta/vaults/list", "VaultListParams", "BetaManagedAgentsVault", "", "", "include_archived,limit,page", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kRead, Page::kCursor, Wire::kJson, true, false}, + {Call::kVaultsRetrieve, "vaults.retrieve", "GET", "/v1/vaults/{vault_id}", "api/beta/vaults/retrieve", "", "BetaManagedAgentsVault", "", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kRead, Page::kNone, Wire::kJson, true, false}, + {Call::kVaultsUpdate, "vaults.update", "POST", "/v1/vaults/{vault_id}", "api/beta/vaults/update", "VaultUpdateParams", "BetaManagedAgentsVault", "display_name,metadata", "", "", "", "managed-agents-2026-04-01", Auth::kPlatform, Kind::kWrite, Page::kNone, Wire::kJson, true, false}, +}; +// CALLS-END + +std::size_t call_count() { return sizeof(kCalls) / sizeof(kCalls[0]); } + +const CallSpec& spec_at(std::size_t index) { + if (index >= call_count()) throw std::out_of_range("call index"); + return kCalls[index]; +} + +const CallSpec& spec_of(Call call) { + for (const CallSpec& s : kCalls) + if (s.call == call) return s; + throw std::out_of_range("unknown call"); +} + +clients::Method method_of(Call call) { + const std::string m = spec_of(call).http; + if (m == "GET") return clients::Method::kGet; + if (m == "POST") return clients::Method::kPost; + if (m == "DELETE") return clients::Method::kDelete; + if (m == "PATCH") return clients::Method::kPatch; + return clients::Method::kPut; +} + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/calls.h b/src/anthropic/admin/calls.h new file mode 100644 index 0000000..baf3ab9 --- /dev/null +++ b/src/anthropic/admin/calls.h @@ -0,0 +1,310 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#pragma once + +// The ONE table of REST calls this package makes. Every row is checked by +// tools/check_spec.py against the official SDK source and the API reference. +// Code builds every URL from this table, never from a literal. + +#include + +#include "clients/request.h" + +namespace molo::anthropic::admin { + +enum class Call { + kAnalyticsAppsChatProjectsList, + kAnalyticsArtifactsList, + kAnalyticsConnectorsList, + kAnalyticsCostList, + kAnalyticsCostReportList, + kAnalyticsPluginsList, + kAnalyticsSkillsList, + kAnalyticsSummariesList, + kAnalyticsUsageList, + kAnalyticsUsageReportList, + kAnalyticsUserCostReportList, + kAnalyticsUserUsageReportList, + kAnalyticsUsersList, + kApiKeysList, + kApiKeysRetrieve, + kApiKeysUpdate, + kClaudeTagBundlesList, + kClaudeTagBundlesRetrieve, + kClaudeTagBundlesTargetsCreate, + kClaudeTagBundlesTargetsDelete, + kClaudeTagBundlesTargetsList, + kClaudeTagBundlesTargetsRetrieve, + kClaudeTagSlackChannelsCreate, + kClaudeTagSlackChannelsDelete, + kClaudeTagSlackChannelsList, + kClaudeTagSlackChannelsRetrieve, + kClaudeTagSlackChannelsUpdate, + kClaudeTagSlackWorkspacesList, + kClaudeTagSlackWorkspacesRetrieve, + kClaudeTagSlackWorkspacesUpdate, + kComplianceSettingsRetrieve, + kComplianceSettingsUpdate, + kCostReportRetrieve, + kExternalKeysCreate, + kExternalKeysDelete, + kExternalKeysList, + kExternalKeysRetrieve, + kExternalKeysUpdate, + kExternalKeysValidate, + kInvitesCreate, + kInvitesDelete, + kInvitesList, + kInvitesRetrieve, + kMcpTunnelsArchive, + kMcpTunnelsCertificatesArchive, + kMcpTunnelsCertificatesCreate, + kMcpTunnelsCertificatesList, + kMcpTunnelsCertificatesRetrieve, + kMcpTunnelsList, + kMcpTunnelsRetrieve, + kMcpTunnelsRevealToken, + kMcpTunnelsRotateToken, + kOrganizationRetrieve, + kPluginMarketplacesList, + kPluginMarketplacesRetrieve, + kPluginMarketplacesUpdate, + kPluginMarketplacesValidateArchive, + kPluginMarketplacesValidateRepository, + kPluginsCreate, + kPluginsDelete, + kPluginsInstallationSettingsList, + kPluginsInstallationSettingsRemove, + kPluginsInstallationSettingsSet, + kPluginsList, + kPluginsRetrieve, + kPluginsSharesList, + kPluginsUpdate, + kPluginsVersionsCreate, + kPluginsVersionsDownload, + kPluginsVersionsList, + kPluginsVersionsRetrieve, + kRateLimitsList, + kRbacGroupsCreate, + kRbacGroupsDelete, + kRbacGroupsList, + kRbacGroupsMembersAdd, + kRbacGroupsMembersList, + kRbacGroupsMembersRemove, + kRbacGroupsRetrieve, + kRbacGroupsUpdate, + kRbacRolesList, + kRbacRolesPermissionsList, + kRbacRolesRetrieve, + kSpendLimitsDelete, + kSpendLimitsEffectiveList, + kSpendLimitsIncreaseRequestsApprove, + kSpendLimitsIncreaseRequestsDeny, + kSpendLimitsIncreaseRequestsList, + kSpendLimitsIncreaseRequestsRetrieve, + kSpendLimitsList, + kSpendLimitsRetrieve, + kSpendLimitsSet, + kTelemetryDestinationsCreate, + kTelemetryDestinationsDelete, + kTelemetryDestinationsList, + kTelemetryDestinationsRetrieve, + kTelemetryDestinationsTest, + kTelemetryDestinationsUpdate, + kTelemetryDestinationsWorkspacesAdd, + kTelemetryDestinationsWorkspacesList, + kTelemetryDestinationsWorkspacesRemove, + kUsageReportRetrieveClaudeCode, + kUsageReportRetrieveMessages, + kUsersList, + kUsersRemove, + kUsersRetrieve, + kUsersUpdate, + kWebhooksCreate, + kWebhooksDelete, + kWebhooksList, + kWebhooksRegenerateSigningSecret, + kWebhooksRetrieve, + kWebhooksUpdate, + kWorkspacesArchive, + kWorkspacesCreate, + kWorkspacesList, + kWorkspacesMembersAdd, + kWorkspacesMembersList, + kWorkspacesMembersRemove, + kWorkspacesMembersRetrieve, + kWorkspacesMembersUpdate, + kWorkspacesRateLimitsList, + kWorkspacesRateLimitsUpdate, + kWorkspacesRetrieve, + kWorkspacesUpdate, + kFederationIssuersArchive, + kFederationIssuersCreate, + kFederationIssuersList, + kFederationIssuersRetrieve, + kFederationIssuersUpdate, + kFederationRulesArchive, + kFederationRulesCreate, + kFederationRulesList, + kFederationRulesRetrieve, + kFederationRulesUpdate, + kFederationRulesWorkspacesAdd, + kFederationRulesWorkspacesList, + kFederationRulesWorkspacesRemove, + kServiceAccountsArchive, + kServiceAccountsCreate, + kServiceAccountsList, + kServiceAccountsRetrieve, + kServiceAccountsUpdate, + kServiceAccountsWorkspacesAdd, + kServiceAccountsWorkspacesList, + kServiceAccountsWorkspacesRemove, + kWorkspacesServiceAccountsAdd, + kWorkspacesServiceAccountsList, + kWorkspacesServiceAccountsRemove, + kWorkspacesServiceAccountsRetrieve, + kWorkspacesServiceAccountsUpdate, + kAgentsArchive, + kAgentsCreate, + kAgentsList, + kAgentsRetrieve, + kAgentsUpdate, + kAgentsVersionsList, + kDeploymentRunsList, + kDeploymentRunsRetrieve, + kDeploymentsArchive, + kDeploymentsCreate, + kDeploymentsList, + kDeploymentsPause, + kDeploymentsRetrieve, + kDeploymentsRun, + kDeploymentsUnpause, + kDeploymentsUpdate, + kDreamsArchive, + kDreamsCancel, + kDreamsCreate, + kDreamsList, + kDreamsRetrieve, + kEnvironmentsArchive, + kEnvironmentsCreate, + kEnvironmentsDelete, + kEnvironmentsList, + kEnvironmentsRetrieve, + kEnvironmentsUpdate, + kEnvironmentsWorkAck, + kEnvironmentsWorkHeartbeat, + kEnvironmentsWorkList, + kEnvironmentsWorkPoll, + kEnvironmentsWorkRetrieve, + kEnvironmentsWorkStats, + kEnvironmentsWorkStop, + kEnvironmentsWorkUpdate, + kMemoryStoresArchive, + kMemoryStoresCreate, + kMemoryStoresDelete, + kMemoryStoresList, + kMemoryStoresMemoriesCreate, + kMemoryStoresMemoriesDelete, + kMemoryStoresMemoriesList, + kMemoryStoresMemoriesRetrieve, + kMemoryStoresMemoriesUpdate, + kMemoryStoresMemoryVersionsList, + kMemoryStoresMemoryVersionsRedact, + kMemoryStoresMemoryVersionsRetrieve, + kMemoryStoresRetrieve, + kMemoryStoresUpdate, + kSessionsArchive, + kSessionsCreate, + kSessionsDelete, + kSessionsEventsList, + kSessionsEventsSend, + kSessionsEventsStream, + kSessionsList, + kSessionsResourcesAdd, + kSessionsResourcesDelete, + kSessionsResourcesList, + kSessionsResourcesRetrieve, + kSessionsResourcesUpdate, + kSessionsRetrieve, + kSessionsThreadsArchive, + kSessionsThreadsEventsList, + kSessionsThreadsEventsStream, + kSessionsThreadsList, + kSessionsThreadsRetrieve, + kSessionsUpdate, + kTunnelsArchive, + kTunnelsCertificatesArchive, + kTunnelsCertificatesCreate, + kTunnelsCertificatesList, + kTunnelsCertificatesRetrieve, + kTunnelsCreate, + kTunnelsList, + kTunnelsRetrieve, + kTunnelsRevealToken, + kTunnelsRotateToken, + kUserProfilesActionUrlsCreate, + kUserProfilesActionUrlsCreateBeta, + kUserProfilesCreate, + kUserProfilesCreateBeta, + kUserProfilesCreateEnrollmentUrl, + kUserProfilesDelete, + kUserProfilesDeleteBeta, + kUserProfilesList, + kUserProfilesListBeta, + kUserProfilesRetrieve, + kUserProfilesRetrieveBeta, + kUserProfilesUpdate, + kUserProfilesUpdateBeta, + kVaultsArchive, + kVaultsCreate, + kVaultsCredentialsArchive, + kVaultsCredentialsCreate, + kVaultsCredentialsDelete, + kVaultsCredentialsList, + kVaultsCredentialsMcpOauthValidate, + kVaultsCredentialsRetrieve, + kVaultsCredentialsUpdate, + kVaultsDelete, + kVaultsList, + kVaultsRetrieve, + kVaultsUpdate, +}; + +// Which credential a call needs. +enum class Auth { + kAdmin, // Admin API key (sk-ant-admin..., x-api-key) or an org:admin OAuth token + kOAuth, // only an org:admin OAuth bearer token (service accounts, federation) + kPlatform, // standard workspace API key (managed agents surface) +}; + +enum class Kind { kRead, kWrite, kDestructive }; +enum class Page { kNone, kIds, kCursor, kReport, kBidirectional }; +enum class Wire { kJson, kSse, kMultipart, kRaw }; + +struct CallSpec { + Call call; + const char* name; // SDK-style operation id, e.g. organization.invites.create + const char* http; // GET POST PATCH DELETE + const char* path; // /v1/organizations/invites/{invite_id} + const char* docs; // reference page slug, guide:, or "" (SDK only) + const char* request; // SDK request schema (TypedDict) or "" + const char* response; // SDK response type + const char* body; // comma list: JSON body fields (multipart: part names) + const char* required; // comma list: required body fields and query parameters + const char* query; // comma list: query parameters; `name[]` is sent repeated + const char* headers; // comma list: arg=Header-Name request header parameters + const char* beta; // anthropic-beta value the call needs, or "" + Auth auth; + Kind kind; + Page page; + Wire wire; + bool workspace; // accepts the anthropic-workspace-id header + bool docs_only; // not in any SDK: reference page is the only source +}; + +const CallSpec& spec_of(Call call); +clients::Method method_of(Call call); +std::size_t call_count(); +const CallSpec& spec_at(std::size_t index); + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/caps.h b/src/anthropic/admin/caps.h new file mode 100644 index 0000000..fee7ed8 --- /dev/null +++ b/src/anthropic/admin/caps.h @@ -0,0 +1,36 @@ +#pragma once + +// Static ceilings for the Anthropic admin and agent-platform package. Never +// autotuned: a constant you can read beats magic you cannot debug. + +#include + +namespace molo::anthropic::admin { + +struct Caps { + // Page walks: pages fetched and items collected by one list_all call. + static constexpr std::size_t kMaxPages = 20; + static constexpr std::size_t kMaxPagesHard = 100; + static constexpr std::size_t kMaxItems = 5000; + // Ids put into a URL path (see llm::Service::valid_id). + static constexpr std::size_t kMaxIdBytes = 256; + // JSON request body. + static constexpr std::size_t kMaxBodyBytes = 1u * 1024u * 1024u; + // Query string: values per parameter, bytes per value, bytes in total. + static constexpr std::size_t kMaxQueryValues = 100; + static constexpr std::size_t kMaxQueryValueBytes = 512; + static constexpr std::size_t kMaxQueryBytes = 8u * 1024u; + // Multipart uploads (plugin files, marketplace archive: the API caps the + // archive at 32 MiB). + static constexpr std::size_t kMaxFormBytes = 32u * 1024u * 1024u; + static constexpr std::size_t kMaxFormParts = 512; + // Server-sent event streams: events handed to the sink. + static constexpr std::size_t kMaxStreamEvents = 1000; + // Largest page size this package ever sends. + static constexpr long kMaxLimit = 1000; + // Webhook signature timestamp tolerance, seconds (Standard Webhooks: 5 min). + static constexpr long kWebhookToleranceSeconds = 300; + static constexpr std::size_t kMaxWebhookPayloadBytes = 1u * 1024u * 1024u; +}; + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/credentials.cpp b/src/anthropic/admin/credentials.cpp new file mode 100644 index 0000000..b67447b --- /dev/null +++ b/src/anthropic/admin/credentials.cpp @@ -0,0 +1,71 @@ +#include "anthropic/admin/credentials.h" + +namespace molo::anthropic::admin { + +namespace { +bool starts_with(const std::string& s, const char* prefix) { + return s.rfind(prefix, 0) == 0; +} +bool clean(const std::string& s) { + for (unsigned char c : s) + if (c <= 0x20 || c >= 0x7f) return false; + return true; +} +} // namespace + +const char* KeyRules::env_of(Lane lane) { + switch (lane) { + case Lane::kAdminKey: return "ANTHROPIC_ADMIN_KEY"; + case Lane::kOAuth: return "ANTHROPIC_AUTH_TOKEN"; + case Lane::kPlatform: return "ANTHROPIC_API_KEY"; + } + return ""; +} + +const char* KeyRules::name_of(Lane lane) { + switch (lane) { + case Lane::kAdminKey: return "admin_key"; + case Lane::kOAuth: return "oauth_token"; + case Lane::kPlatform: return "api_key"; + } + return ""; +} + +bool KeyRules::is_admin_key(const std::string& value) { return starts_with(value, kAdminPrefix); } + +LaneState KeyRules::check(Lane lane, const std::string& value, std::string& reason) { + reason.clear(); + if (value.empty()) return LaneState::kMissing; + if (!clean(value)) { + reason = std::string(env_of(lane)) + " has whitespace or control characters"; + return LaneState::kRejected; + } + switch (lane) { + case Lane::kAdminKey: + if (!is_admin_key(value)) { + reason = std::string(env_of(lane)) + " must be an Admin API key (sk-ant-admin...); a standard API key is not accepted"; + return LaneState::kRejected; + } + break; + case Lane::kOAuth: + if (is_admin_key(value) || starts_with(value, kApiPrefix)) { + reason = std::string(env_of(lane)) + " must be an org:admin OAuth token, not an API key"; + return LaneState::kRejected; + } + break; + case Lane::kPlatform: + if (is_admin_key(value)) { + reason = std::string(env_of(lane)) + " is an Admin API key; managed agents take a standard workspace key"; + return LaneState::kRejected; + } + break; + } + return LaneState::kReady; +} + +std::string KeyRules::redacted(const std::string& value) { + if (value.size() <= 12) return std::string(value.size(), '*'); + return value.substr(0, 12) + "..."; +} + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/credentials.h b/src/anthropic/admin/credentials.h new file mode 100644 index 0000000..4f6824b --- /dev/null +++ b/src/anthropic/admin/credentials.h @@ -0,0 +1,47 @@ +#pragma once + +// Credential rules. The package talks with three credentials, each kept in +// its own lane and never mixed up: +// +// kAdminKey ANTHROPIC_ADMIN_KEY sk-ant-admin..., header x-api-key +// kOAuth ANTHROPIC_AUTH_TOKEN org:admin OAuth token, Authorization: Bearer +// kPlatform ANTHROPIC_API_KEY standard workspace key (managed agents) +// +// A lane refuses a credential of the wrong kind before any request leaves +// the process: the standard key is never accepted as an admin key, and an +// admin key never goes to the platform lane. + +#include + +namespace molo::anthropic::admin { + +enum class Lane { kAdminKey, kOAuth, kPlatform }; + +enum class LaneState { + kMissing, // nothing configured + kReady, // configured and plausible for this lane + kRejected, // configured but of the wrong kind; calls fail locally +}; + +struct LaneInfo { + Lane lane; + const char* env; // environment variable that feeds the lane + LaneState state; + std::string reason; // why a credential was rejected, else "" +}; + +class KeyRules { + public: + static constexpr const char* kAdminPrefix = "sk-ant-admin"; + static constexpr const char* kApiPrefix = "sk-ant-api"; + + static const char* env_of(Lane lane); + static const char* name_of(Lane lane); + // Classifies `value` for `lane`; fills `reason` on rejection. + static LaneState check(Lane lane, const std::string& value, std::string& reason); + static bool is_admin_key(const std::string& value); + // First 12 characters then "...": safe to show, never the whole key. + static std::string redacted(const std::string& value); +}; + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/gateway.cpp b/src/anthropic/admin/gateway.cpp new file mode 100644 index 0000000..60b76a7 --- /dev/null +++ b/src/anthropic/admin/gateway.cpp @@ -0,0 +1,162 @@ +#include "anthropic/admin/gateway.h" + +#include + +#include "anthropic/admin/caps.h" +#include "clients/transports/http_transport.h" +#include "llm/config.h" +#include "llm/error.h" + +namespace molo::anthropic::admin { + +namespace { + +constexpr const char* kVendor = "anthropic"; + +std::size_t index_of(Lane lane) { return static_cast(lane); } + +Lane lane_of(Auth auth) { + switch (auth) { + case Auth::kAdmin: return Lane::kAdminKey; + case Auth::kOAuth: return Lane::kOAuth; + case Auth::kPlatform: return Lane::kPlatform; + } + return Lane::kAdminKey; +} + +std::mutex& stream_mutex() { + static std::mutex m; + return m; +} + +} // namespace + +Gateway::Gateway(TransportFactory factory, Keys keys, std::string base_url) + : base_url_(std::move(base_url)), factory_(std::move(factory)) { + const std::string values[3] = {keys.admin_key, keys.oauth_token, keys.api_key}; + const Lane order[3] = {Lane::kAdminKey, Lane::kOAuth, Lane::kPlatform}; + for (int i = 0; i < 3; ++i) { + Slot& s = slots_[index_of(order[i])]; + s.info.lane = order[i]; + s.info.env = KeyRules::env_of(order[i]); + s.info.state = KeyRules::check(order[i], values[i], s.info.reason); + s.key = s.info.state == LaneState::kReady ? values[i] : std::string(); + s.config.vendor = kVendor; + s.config.base_url = base_url_; + s.config.key_env = s.info.env; + s.config.auth = order[i] == Lane::kOAuth ? llm::AuthStyle::kBearer : llm::AuthStyle::kHeader; + s.config.auth_header = "x-api-key"; + s.config.default_headers["anthropic-version"] = kApiVersion; + s.client = std::make_shared(factory_(), s.config, s.key); + } +} + +std::shared_ptr Gateway::from_env() { + Keys keys; + keys.admin_key = llm::Config::get(KeyRules::env_of(Lane::kAdminKey)); + keys.oauth_token = llm::Config::get(KeyRules::env_of(Lane::kOAuth)); + keys.api_key = llm::Config::get(KeyRules::env_of(Lane::kPlatform)); + return std::make_shared( + [] { return std::unique_ptr(new clients::transports::HttpTransport()); }, + std::move(keys)); +} + +const Gateway::Slot& Gateway::slot(Lane lane) const { return slots_[index_of(lane)]; } + +LaneInfo Gateway::describe(Lane lane) const { return slot(lane).info; } + +std::vector Gateway::lanes() const { + return {slot(Lane::kAdminKey).info, slot(Lane::kOAuth).info, slot(Lane::kPlatform).info}; +} + +std::shared_ptr Gateway::primary_client(Auth auth) const { + return slot(lane_of(auth)).client; +} + +Lane Gateway::lane_for(Auth auth) const { + auto refuse = [&](const LaneInfo& info) -> void { + if (info.state == LaneState::kRejected) + throw llm::ApiError(kVendor, 401, "credential_rejected", info.reason); + }; + switch (auth) { + case Auth::kAdmin: { + const LaneInfo& key = slot(Lane::kAdminKey).info; + const LaneInfo& tok = slot(Lane::kOAuth).info; + if (key.state == LaneState::kReady) return Lane::kAdminKey; + if (tok.state == LaneState::kReady) return Lane::kOAuth; + refuse(key); + refuse(tok); + throw llm::NotConfiguredError(kVendor, KeyRules::env_of(Lane::kAdminKey)); + } + case Auth::kOAuth: { + const LaneInfo& tok = slot(Lane::kOAuth).info; + if (tok.state == LaneState::kReady) return Lane::kOAuth; + refuse(tok); + if (slot(Lane::kAdminKey).info.state == LaneState::kReady) + throw llm::ApiError(kVendor, 403, "credential_rejected", + "this call accepts only an org:admin OAuth token (set ANTHROPIC_AUTH_TOKEN); an Admin API key is not accepted"); + throw llm::NotConfiguredError(kVendor, KeyRules::env_of(Lane::kOAuth)); + } + case Auth::kPlatform: { + const LaneInfo& k = slot(Lane::kPlatform).info; + if (k.state == LaneState::kReady) return Lane::kPlatform; + refuse(k); + throw llm::NotConfiguredError(kVendor, KeyRules::env_of(Lane::kPlatform)); + } + } + throw llm::ApiError(kVendor, 500, "internal", "unknown credential class"); +} + +std::shared_ptr Gateway::client_for(Auth auth) const { + return slot(lane_for(auth)).client; +} + +bool Gateway::ready(Auth auth) const { + try { + lane_for(auth); + return true; + } catch (const llm::ApiError&) { + return false; + } +} + +void Gateway::set_workspace_id(std::string id) { + if (!id.empty() && !llm::Service::valid_id(id)) + throw llm::ApiError::invalid(kVendor, "bad workspace id"); + workspace_id_ = std::move(id); +} + +void Gateway::stream_get(Auth auth, const std::string& target, + const std::map& headers, + const llm::SseDecoder::Sink& sink, std::size_t max_events) const { + const Slot& s = slot(lane_for(auth)); + if (target.empty() || target.front() != '/' || target.find("..") != std::string::npos) + throw llm::ApiError::invalid(kVendor, "bad request path"); + if (max_events == 0 || max_events > Caps::kMaxStreamEvents) + throw llm::ApiError::invalid(kVendor, "max_events must be 1.." + std::to_string(Caps::kMaxStreamEvents)); + std::lock_guard lock(stream_mutex()); + if (!stream_client_) stream_client_ = std::make_unique(factory_()); + std::size_t seen = 0; + llm::SseDecoder decoder(kVendor, [&](const llm::SseEvent& ev) { + ++seen; + bool keep = sink(ev); + return keep && seen < max_events; + }); + try { + clients::ClientRequest req(clients::Method::kGet, clients::Url::parse(base_url_ + target)); + if (s.config.auth == llm::AuthStyle::kBearer) req.bearer(s.key); + else req.header(s.config.auth_header, s.key); + for (const auto& [k, v] : s.config.default_headers) req.header(k, v); + for (const auto& [k, v] : headers) req.header(k, v); + req.header("Accept", "text/event-stream"); + stream_client_->send_stream_blocking(std::move(req), + [&](const std::string& chunk) { return decoder.feed(chunk); }); + decoder.finish(); + } catch (const llm::ApiError&) { + throw; + } catch (const std::exception& e) { + throw llm::ApiError(kVendor, 502, "UNAVAILABLE", e.what()); + } +} + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/gateway.h b/src/anthropic/admin/gateway.h new file mode 100644 index 0000000..fb452f2 --- /dev/null +++ b/src/anthropic/admin/gateway.h @@ -0,0 +1,84 @@ +#pragma once + +// Gateway: the three credential lanes behind one object. Owns one +// llm::ApiClient per lane (x-api-key for the admin key and the standard key, +// Authorization: Bearer for the OAuth token, anthropic-version on all) and +// picks the lane a call needs from the call table. A lane holding a +// credential of the wrong kind refuses locally; the request never leaves. + +#include +#include +#include +#include +#include + +#include "anthropic/admin/calls.h" +#include "anthropic/admin/credentials.h" +#include "clients/client.h" +#include "clients/transport.h" +#include "llm/api_client.h" +#include "llm/sse.h" + +namespace molo::anthropic::admin { + +class Gateway { + public: + static constexpr const char* kBaseUrl = "https://api.anthropic.com"; + // Pinned API version (reference: platform.claude.com/docs/en/api/versioning). + static constexpr const char* kApiVersion = "2026-10-21"; + + using TransportFactory = std::function()>; + + struct Keys { + std::string admin_key; // ANTHROPIC_ADMIN_KEY + std::string oauth_token; // ANTHROPIC_AUTH_TOKEN + std::string api_key; // ANTHROPIC_API_KEY + }; + + // One transport per lane is taken from `factory` (plus one for streams). + Gateway(TransportFactory factory, Keys keys, std::string base_url = kBaseUrl); + + // HTTPS transport, credentials from llm::Config (environment, then the + // .env.json files). + static std::shared_ptr from_env(); + + // Never throws: the lane's client, possibly unconfigured. For llm::Service. + std::shared_ptr primary_client(Auth auth) const; + + // The lane that serves `auth`, or throws llm::NotConfiguredError (nothing + // configured) / llm::ApiError "credential_rejected" (wrong kind of key). + Lane lane_for(Auth auth) const; + std::shared_ptr client_for(Auth auth) const; + + LaneInfo describe(Lane lane) const; + std::vector lanes() const; + // True when a call of this class could be sent now. + bool ready(Auth auth) const; + + // anthropic-workspace-id sent on managed-agents calls (empty: none). + void set_workspace_id(std::string id); + const std::string& workspace_id() const { return workspace_id_; } + + // GET server-sent events (llm::ApiClient streams POST only). Stops after + // `max_events` events or when the sink returns false. + void stream_get(Auth auth, const std::string& target, + const std::map& headers, + const llm::SseDecoder::Sink& sink, std::size_t max_events) const; + + private: + struct Slot { + LaneInfo info; + std::string key; + llm::ApiClientConfig config; + std::shared_ptr client; + }; + const Slot& slot(Lane lane) const; + + std::string base_url_; + Slot slots_[3]; + std::string workspace_id_; + mutable std::unique_ptr stream_client_; + TransportFactory factory_; +}; + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/pager.cpp b/src/anthropic/admin/pager.cpp new file mode 100644 index 0000000..adb685c --- /dev/null +++ b/src/anthropic/admin/pager.cpp @@ -0,0 +1,70 @@ +#include "anthropic/admin/pager.h" + +namespace molo::anthropic::admin { + +using clients::body::Json; + +namespace { + +std::string text_of(const Json& doc, const char* key) { + const Json* v = doc.is_object() ? doc.find(key) : nullptr; + return v && v->is_string() ? v->as_string() : ""; +} + +// has_more == false stops a walk; absent or null leaves the decision to the cursor. +bool has_more_false(const Json& doc) { + const Json* v = doc.is_object() ? doc.find("has_more") : nullptr; + return v && v->is_bool() && !v->as_bool(); +} + +} // namespace + +const Json::Array& Pager::items_of(const Json& page) { + static const Json::Array kEmpty; + const Json* d = page.is_object() ? page.find("data") : nullptr; + return d && d->is_array() ? d->as_array() : kEmpty; +} + +bool Pager::advance(Page kind, const Json& page, Query& query) { + switch (kind) { + case Page::kNone: + return false; + case Page::kIds: { + if (has_more_false(page)) return false; + if (query.has("before_id")) { + std::string first = text_of(page, "first_id"); + if (first.empty()) return false; + query.set("before_id", first); + return true; + } + std::string last = text_of(page, "last_id"); + if (last.empty()) return false; + query.set("after_id", last); + return true; + } + case Page::kReport: + if (has_more_false(page)) return false; + [[fallthrough]]; + case Page::kCursor: + case Page::kBidirectional: { + std::string next = text_of(page, "next_page"); + if (next.empty()) return false; + query.set("page", next); + return true; + } + } + return false; +} + +Json Walk::to_json() const { + Json o = Json::object(); + o.set("items", items); + o.set("count", Json(static_cast(size()))); + o.set("pages", Json(static_cast(pages))); + o.set("truncated", Json(truncated)); + if (!reason.empty()) o.set("reason", Json(reason)); + if (!next_page.empty()) o.set("next_page", Json(next_page)); + return o; +} + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/pager.h b/src/anthropic/admin/pager.h new file mode 100644 index 0000000..3acdf09 --- /dev/null +++ b/src/anthropic/admin/pager.h @@ -0,0 +1,37 @@ +#pragma once + +// Pager: bounded page walking. The API has four page shapes (see calls.h +// Page): id cursors (data / has_more / first_id / last_id), opaque cursors +// (data / next_page), reports (data / has_more / next_page) and +// bidirectional cursors (next_page / prev_page). A walk is capped in pages +// and items; hitting a cap is reported loudly in Walk, never silent. + +#include + +#include "anthropic/admin/calls.h" +#include "anthropic/admin/query.h" +#include "clients/body/json.h" + +namespace molo::anthropic::admin { + +struct Walk { + clients::body::Json items = clients::body::Json::array(); // every item collected + std::size_t pages = 0; // pages fetched + bool truncated = false; // more pages exist beyond the caps + std::string reason; // "page_cap", "item_cap" or "" + std::string next_page; // cursor to continue from, when known + + std::size_t size() const { return items.as_array().size(); } + clients::body::Json to_json() const; +}; + +class Pager { + public: + // Rewrites `query` to ask for the page after `page` (the parsed response of + // a call of kind `kind`). False when there is no further page. + static bool advance(Page kind, const clients::body::Json& page, Query& query); + // Items of one page response: its `data` array (empty when absent). + static const clients::body::Json::Array& items_of(const clients::body::Json& page); +}; + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/query.cpp b/src/anthropic/admin/query.cpp new file mode 100644 index 0000000..b981466 --- /dev/null +++ b/src/anthropic/admin/query.cpp @@ -0,0 +1,42 @@ +#include "anthropic/admin/query.h" + +namespace molo::anthropic::admin { + +Query& Query::set(const std::string& name, const std::string& value) { + for (auto it = items_.begin(); it != items_.end();) { + if (it->first == name) it = items_.erase(it); + else ++it; + } + items_.emplace_back(name, value); + return *this; +} + +Query& Query::set_int(const std::string& name, long value) { + return set(name, std::to_string(value)); +} + +Query& Query::set_bool(const std::string& name, bool value) { + return set(name, value ? "true" : "false"); +} + +Query& Query::add(const std::string& name, const std::string& value) { + items_.emplace_back(name, value); + return *this; +} + +bool Query::has(const std::string& name) const { return count(name) > 0; } + +std::string Query::get(const std::string& name) const { + for (const auto& kv : items_) + if (kv.first == name) return kv.second; + return ""; +} + +std::size_t Query::count(const std::string& name) const { + std::size_t n = 0; + for (const auto& kv : items_) + if (kv.first == name) ++n; + return n; +} + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/query.h b/src/anthropic/admin/query.h new file mode 100644 index 0000000..18543f6 --- /dev/null +++ b/src/anthropic/admin/query.h @@ -0,0 +1,35 @@ +#pragma once + +// Query: the query-string parameters of one call, built by name. Array +// parameters are added repeatedly (`add`); the request builder checks names, +// counts and sizes against the call table and encodes `name[]=a&name[]=b`. + +#include +#include +#include + +namespace molo::anthropic::admin { + +class Query { + public: + Query() = default; + + // Replaces any earlier value of `name`. + Query& set(const std::string& name, const std::string& value); + Query& set_int(const std::string& name, long value); + Query& set_bool(const std::string& name, bool value); + // Appends a value (array parameters: statuses, roles, group_by, ...). + Query& add(const std::string& name, const std::string& value); + + bool empty() const { return items_.empty(); } + bool has(const std::string& name) const; + // First value of `name`, or "". + std::string get(const std::string& name) const; + std::size_t count(const std::string& name) const; + const std::vector>& items() const { return items_; } + + private: + std::vector> items_; +}; + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/reports.cpp b/src/anthropic/admin/reports.cpp new file mode 100644 index 0000000..bce19a9 --- /dev/null +++ b/src/anthropic/admin/reports.cpp @@ -0,0 +1,324 @@ +#include "anthropic/admin/reports.h" + +#include +#include + +#include "anthropic/admin/caps.h" +#include "llm/error.h" + +namespace molo::anthropic::admin { + +using clients::body::Json; + +namespace { + +constexpr const char* kVendor = "anthropic"; +constexpr std::size_t kMaxList = 32; // values in one array filter + +[[noreturn]] void bad(const std::string& why) { throw llm::ApiError::invalid(kVendor, why); } +[[noreturn]] void shape(const std::string& why) { + throw llm::ApiError(kVendor, 502, "BAD_RESPONSE", why); +} + +bool digits(const std::string& s, std::size_t at, std::size_t n) { + if (at + n > s.size()) return false; + for (std::size_t i = at; i < at + n; ++i) + if (s[i] < '0' || s[i] > '9') return false; + return true; +} + +void add_all(Query& q, const char* name, const std::vector& values) { + if (values.size() > kMaxList) bad(std::string(name) + " has too many values"); + for (const std::string& v : values) { + if (v.empty()) bad(std::string(name) + " has an empty value"); + q.add(name, v); + } +} + +void check_limit(long limit, long lo, long hi) { + if (limit != 0 && (limit < lo || limit > hi)) + bad("limit must be " + std::to_string(lo) + ".." + std::to_string(hi)); +} + +std::string str(const Json& o, const char* key) { + const Json* v = o.is_object() ? o.find(key) : nullptr; + return v && v->is_string() ? v->as_string() : ""; +} +long long num(const Json& o, const char* key) { + const Json* v = o.is_object() ? o.find(key) : nullptr; + return v && v->is_number() ? static_cast(v->as_number()) : 0; +} +const Json& sub(const Json& o, const char* key) { + static const Json kEmpty = Json::object(); + const Json* v = o.is_object() ? o.find(key) : nullptr; + return v && v->is_object() ? *v : kEmpty; +} +const Json::Array& list(const Json& doc, const char* key) { + static const Json::Array kEmpty; + const Json* v = doc.is_object() ? doc.find(key) : nullptr; + if (!v) return kEmpty; + if (!v->is_array()) shape(std::string(key) + " is not an array"); + return v->as_array(); +} +template +void paging(const Json& doc, ReportPage& page) { + if (!doc.is_object()) shape("report is not an object"); + const Json* m = doc.find("has_more"); + page.has_more = m && m->is_bool() && m->as_bool(); + page.next_page = str(doc, "next_page"); +} + +} // namespace + +bool valid_date(const std::string& s) { + if (s.size() != 10 || !digits(s, 0, 4) || s[4] != '-' || !digits(s, 5, 2) || s[7] != '-' || !digits(s, 8, 2)) + return false; + int m = std::atoi(s.substr(5, 2).c_str()), d = std::atoi(s.substr(8, 2).c_str()); + return m >= 1 && m <= 12 && d >= 1 && d <= 31; +} + +bool valid_rfc3339(const std::string& s) { + if (s.size() < 20 || !valid_date(s.substr(0, 10)) || s[10] != 'T') return false; + if (!digits(s, 11, 2) || s[13] != ':' || !digits(s, 14, 2) || s[16] != ':' || !digits(s, 17, 2)) return false; + if (std::atoi(s.substr(11, 2).c_str()) > 23 || std::atoi(s.substr(14, 2).c_str()) > 59) return false; + std::size_t i = 19; + if (i < s.size() && s[i] == '.') { + ++i; + std::size_t start = i; + while (i < s.size() && s[i] >= '0' && s[i] <= '9') ++i; + if (i == start) return false; + } + if (i < s.size() && s[i] == 'Z') return i + 1 == s.size(); + if (i + 6 == s.size() && (s[i] == '+' || s[i] == '-')) return digits(s, i + 1, 2) && s[i + 3] == ':' && digits(s, i + 4, 2); + return false; +} + +bool BucketWidth::valid(const std::string& w) { return w == "1d" || w == "1h" || w == "1m"; } +long BucketWidth::default_limit(const std::string& w) { return w == "1d" ? 7 : w == "1h" ? 24 : 60; } +long BucketWidth::max_limit(const std::string& w) { return w == "1d" ? 31 : w == "1h" ? 168 : 1440; } + +Query MessagesUsageQuery::to_query() const { + if (!valid_rfc3339(starting_at)) bad("starting_at must be an RFC 3339 timestamp"); + if (!ending_at.empty() && !valid_rfc3339(ending_at)) bad("ending_at must be an RFC 3339 timestamp"); + if (!BucketWidth::valid(bucket_width)) bad("bucket_width must be 1d, 1h or 1m"); + check_limit(limit, 1, BucketWidth::max_limit(bucket_width)); + Query q; + q.set("starting_at", starting_at); + if (!ending_at.empty()) q.set("ending_at", ending_at); + q.set("bucket_width", bucket_width); + if (limit) q.set_int("limit", limit); + if (!page.empty()) q.set("page", page); + add_all(q, "group_by", group_by); + add_all(q, "models", models); + add_all(q, "workspace_ids", workspace_ids); + add_all(q, "api_key_ids", api_key_ids); + add_all(q, "account_ids", account_ids); + add_all(q, "service_account_ids", service_account_ids); + add_all(q, "service_tiers", service_tiers); + add_all(q, "context_window", context_window); + add_all(q, "inference_geos", inference_geos); + add_all(q, "speeds", speeds); + return q; +} + +Query CostQuery::to_query() const { + if (!valid_rfc3339(starting_at)) bad("starting_at must be an RFC 3339 timestamp"); + if (!ending_at.empty() && !valid_rfc3339(ending_at)) bad("ending_at must be an RFC 3339 timestamp"); + check_limit(limit, 1, 31); + Query q; + q.set("starting_at", starting_at); + if (!ending_at.empty()) q.set("ending_at", ending_at); + q.set("bucket_width", "1d"); + if (limit) q.set_int("limit", limit); + if (!page.empty()) q.set("page", page); + for (const std::string& g : group_by) + if (g != "description" && g != "workspace_id") bad("group_by must be description or workspace_id"); + add_all(q, "group_by", group_by); + return q; +} + +Query ClaudeCodeQuery::to_query() const { + if (!valid_date(starting_at)) bad("starting_at must be a UTC date YYYY-MM-DD"); + check_limit(limit, 1, 1000); + Query q; + q.set("starting_at", starting_at); + if (limit) q.set_int("limit", limit); + if (!page.empty()) q.set("page", page); + return q; +} + +bool Decimal::parse(const std::string& text, Decimal& out) { + std::size_t i = 0; + bool neg = false; + if (i < text.size() && (text[i] == '-' || text[i] == '+')) neg = text[i++] == '-'; + long long whole = 0, frac = 0; + std::size_t nd = 0, fd = 0; + for (; i < text.size() && text[i] >= '0' && text[i] <= '9'; ++i, ++nd) { + if (whole > 9000000000LL) return false; + whole = whole * 10 + (text[i] - '0'); + } + if (i < text.size() && text[i] == '.') { + for (++i; i < text.size() && text[i] >= '0' && text[i] <= '9'; ++i, ++fd) { + if (fd >= 9) return false; + frac = frac * 10 + (text[i] - '0'); + } + } + if (i != text.size() || nd + fd == 0) return false; + for (std::size_t k = fd; k < 9; ++k) frac *= 10; + long long v = whole * 1000000000LL + frac; + out.scaled_ = neg ? -v : v; + return true; +} + +Decimal& Decimal::add(const Decimal& other) { + long long r; + if (__builtin_add_overflow(scaled_, other.scaled_, &r)) throw std::overflow_error("decimal sum overflow"); + scaled_ = r; + return *this; +} + +std::string Decimal::str() const { + long long v = scaled_ < 0 ? -scaled_ : scaled_; + std::string frac = std::to_string(v % 1000000000LL); + frac.insert(0, 9 - frac.size(), '0'); + while (frac.size() > 1 && frac.back() == '0') frac.pop_back(); + return std::string(scaled_ < 0 ? "-" : "") + std::to_string(v / 1000000000LL) + "." + frac; +} + +ReportPage ReportParser::usage(const Json& doc) { + ReportPage page; + paging(doc, page); + for (const Json& b : list(doc, "data")) { + UsageBucket bucket; + bucket.starting_at = str(b, "starting_at"); + bucket.ending_at = str(b, "ending_at"); + for (const Json& r : list(b, "results")) { + UsageResult u; + u.model = str(r, "model"); + u.workspace_id = str(r, "workspace_id"); + u.api_key_id = str(r, "api_key_id"); + u.service_tier = str(r, "service_tier"); + u.speed = str(r, "speed"); + u.context_window = str(r, "context_window"); + u.inference_geo = str(r, "inference_geo"); + u.uncached_input = num(r, "uncached_input_tokens"); + u.cache_read_input = num(r, "cache_read_input_tokens"); + u.cache_creation_5m = num(sub(r, "cache_creation"), "ephemeral_5m_input_tokens"); + u.cache_creation_1h = num(sub(r, "cache_creation"), "ephemeral_1h_input_tokens"); + u.output = num(r, "output_tokens"); + u.web_search_requests = num(sub(r, "server_tool_use"), "web_search_requests"); + bucket.results.push_back(u); + } + page.items.push_back(std::move(bucket)); + } + return page; +} + +ReportPage ReportParser::cost(const Json& doc) { + ReportPage page; + paging(doc, page); + for (const Json& b : list(doc, "data")) { + CostBucket bucket; + bucket.starting_at = str(b, "starting_at"); + bucket.ending_at = str(b, "ending_at"); + for (const Json& r : list(b, "results")) { + CostResult c; + c.amount = str(r, "amount"); + c.currency = str(r, "currency"); + c.description = str(r, "description"); + c.cost_type = str(r, "cost_type"); + c.model = str(r, "model"); + c.token_type = str(r, "token_type"); + c.workspace_id = str(r, "workspace_id"); + Decimal d; + if (!Decimal::parse(c.amount, d)) shape("cost amount is not a decimal string"); + bucket.results.push_back(c); + } + page.items.push_back(std::move(bucket)); + } + return page; +} + +ReportPage ReportParser::claude_code(const Json& doc) { + ReportPage page; + paging(doc, page); + for (const Json& r : list(doc, "data")) { + ClaudeCodeRecord c; + const Json& actor = sub(r, "actor"); + c.actor_type = str(actor, "type"); + c.actor = c.actor_type == "user_actor" ? str(actor, "email_address") : str(actor, "api_key_name"); + c.date = str(r, "date"); + c.customer_type = str(r, "customer_type"); + c.terminal_type = str(r, "terminal_type"); + c.subscription_type = str(r, "subscription_type"); + const Json* remote = r.find("is_remote"); + c.is_remote = remote && remote->is_bool() && remote->as_bool(); + const Json& core = sub(r, "core_metrics"); + c.sessions = num(core, "num_sessions"); + c.commits = num(core, "commits_by_claude_code"); + c.pull_requests = num(core, "pull_requests_by_claude_code"); + c.lines_added = num(sub(core, "lines_of_code"), "added"); + c.lines_removed = num(sub(core, "lines_of_code"), "removed"); + for (const Json& m : list(r, "model_breakdown")) { + c.tokens_input += num(sub(m, "tokens"), "input"); + c.tokens_output += num(sub(m, "tokens"), "output"); + } + for (const auto& [tool, v] : sub(r, "tool_actions").as_object()) { + c.accepted[tool] = num(v, "accepted"); + c.rejected[tool] = num(v, "rejected"); + } + page.items.push_back(std::move(c)); + } + return page; +} + +UsageResult ReportParser::sum(const std::vector& buckets) { + UsageResult t; + for (const auto& b : buckets) + for (const auto& r : b.results) { + t.uncached_input += r.uncached_input; + t.cache_read_input += r.cache_read_input; + t.cache_creation_5m += r.cache_creation_5m; + t.cache_creation_1h += r.cache_creation_1h; + t.output += r.output; + t.web_search_requests += r.web_search_requests; + } + return t; +} + +Decimal ReportParser::sum(const std::vector& buckets) { + Decimal total; + for (const auto& b : buckets) + for (const auto& r : b.results) { + Decimal d; + if (Decimal::parse(r.amount, d)) total.add(d); + } + return total; +} + +ReportPage Reports::messages(const MessagesUsageQuery& q) const { + return ReportParser::usage(usage_.messages(q.to_query())); +} +ReportPage Reports::claude_code(const ClaudeCodeQuery& q) const { + return ReportParser::claude_code(usage_.claude_code(q.to_query())); +} +ReportPage Reports::cost(const CostQuery& q) const { + return ReportParser::cost(cost_.get(q.to_query())); +} + +std::vector Reports::all_messages(MessagesUsageQuery q, std::size_t max_pages, + bool& truncated) const { + if (max_pages == 0 || max_pages > Caps::kMaxPagesHard) bad("max_pages out of range"); + std::vector out; + truncated = false; + for (std::size_t n = 0; n < max_pages; ++n) { + ReportPage p = messages(q); + for (auto& b : p.items) out.push_back(std::move(b)); + if (!p.has_more || p.next_page.empty()) return out; + q.page = p.next_page; + } + truncated = true; + return out; +} + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/reports.h b/src/anthropic/admin/reports.h new file mode 100644 index 0000000..dbdc500 --- /dev/null +++ b/src/anthropic/admin/reports.h @@ -0,0 +1,130 @@ +#pragma once + +// Usage and cost reports (Usage and Cost API): query builders that enforce +// the documented ranges locally, typed parsing of the documented response +// shapes, exact decimal totals, and a capped page walk. The three endpoints +// are documented in the API reference but present in no SDK (SPEC.md). + +#include +#include +#include + +#include "anthropic/admin/query.h" +#include "anthropic/admin/services/reports.h" +#include "clients/body/json.h" + +namespace molo::anthropic::admin { + +// RFC 3339 UTC timestamp "YYYY-MM-DDTHH:MM:SSZ" (offsets allowed) / date "YYYY-MM-DD". +bool valid_rfc3339(const std::string& s); +bool valid_date(const std::string& s); + +// Time-bucket granularity and the documented bucket limits. +struct BucketWidth { + static long default_limit(const std::string& width); // 1d:7 1h:24 1m:60 + static long max_limit(const std::string& width); // 1d:31 1h:168 1m:1440 + static bool valid(const std::string& width); +}; + +class MessagesUsageQuery { + public: + std::string starting_at; // required, RFC 3339 + std::string ending_at; // optional + std::string bucket_width = "1d"; // 1d | 1h | 1m + long limit = 0; // 0: server default + std::string page; + std::vector group_by, models, workspace_ids, api_key_ids, account_ids, + service_account_ids, service_tiers, context_window, inference_geos, speeds; + Query to_query() const; // throws llm::ApiError::invalid +}; + +class CostQuery { + public: + std::string starting_at; // required, RFC 3339 + std::string ending_at; + long limit = 0; // 1..31 + std::string page; + std::vector group_by; // description, workspace_id + Query to_query() const; +}; + +class ClaudeCodeQuery { + public: + std::string starting_at; // required, YYYY-MM-DD (one UTC day) + long limit = 0; // 1..1000 + std::string page; + Query to_query() const; +}; + +// Exact fixed-point decimal (9 fractional digits) for cost amounts such as +// "123.78912" (lowest currency units as a decimal string). +class Decimal { + public: + static bool parse(const std::string& text, Decimal& out); + Decimal& add(const Decimal& other); // throws std::overflow_error + std::string str() const; + long long scaled() const { return scaled_; } + + private: + long long scaled_ = 0; +}; + +struct UsageResult { + std::string model, workspace_id, api_key_id, service_tier, speed, context_window, inference_geo; + long long uncached_input = 0, cache_read_input = 0, cache_creation_5m = 0, cache_creation_1h = 0, + output = 0, web_search_requests = 0; + long long input_total() const { return uncached_input + cache_read_input + cache_creation_5m + cache_creation_1h; } +}; +struct UsageBucket { + std::string starting_at, ending_at; + std::vector results; +}; +struct CostResult { + std::string amount, currency, description, cost_type, model, token_type, workspace_id; +}; +struct CostBucket { + std::string starting_at, ending_at; + std::vector results; +}; +struct ClaudeCodeRecord { + std::string actor_type, actor, date, customer_type, terminal_type, subscription_type; + long long sessions = 0, commits = 0, pull_requests = 0, lines_added = 0, lines_removed = 0; + bool is_remote = false; + long long tokens_input = 0, tokens_output = 0; + std::map accepted, rejected; // by tool +}; + +template +struct ReportPage { + std::vector items; + bool has_more = false; + std::string next_page; +}; + +class ReportParser { + public: + // Throw llm::ApiError BAD_RESPONSE on a shape that is not the documented one. + static ReportPage usage(const clients::body::Json& doc); + static ReportPage cost(const clients::body::Json& doc); + static ReportPage claude_code(const clients::body::Json& doc); + static UsageResult sum(const std::vector& buckets); // totals of all results + static Decimal sum(const std::vector& buckets); +}; + +// The three report endpoints with validated queries and typed pages. +class Reports { + public: + explicit Reports(std::shared_ptr gateway) + : usage_(gateway), cost_(gateway) {} + ReportPage messages(const MessagesUsageQuery& q) const; + ReportPage claude_code(const ClaudeCodeQuery& q) const; + ReportPage cost(const CostQuery& q) const; + // Walks pages (capped) and returns every bucket; `truncated` is set loudly. + std::vector all_messages(MessagesUsageQuery q, std::size_t max_pages, bool& truncated) const; + + private: + UsageReports usage_; + CostReports cost_; +}; + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/request.cpp b/src/anthropic/admin/request.cpp new file mode 100644 index 0000000..3cb362b --- /dev/null +++ b/src/anthropic/admin/request.cpp @@ -0,0 +1,213 @@ +#include "anthropic/admin/request.h" + +#include + +#include "anthropic/admin/caps.h" +#include "clients/url.h" +#include "llm/api_client.h" +#include "llm/error.h" + +namespace molo::anthropic::admin { + +using clients::body::Json; + +namespace { + +constexpr const char* kVendor = "anthropic"; + +[[noreturn]] void bad(const std::string& why) { throw llm::ApiError::invalid(kVendor, why); } + +std::string base_of(const std::string& name) { + if (name.size() > 2 && name.compare(name.size() - 2, 2, "[]") == 0) return name.substr(0, name.size() - 2); + return name; +} + +bool has_control(const std::string& s) { + for (unsigned char c : s) + if (c < 0x20 || c == 0x7f) return true; + return false; +} + +std::string encode_pair(const std::string& k, const std::string& v) { + return clients::Url::encode_component(k) + "=" + clients::Url::encode_component(v); +} + +void check_workspace(const CallSpec& spec, const std::string& workspace_id, + std::map& headers) { + if (!spec.workspace || workspace_id.empty()) return; + if (!llm::Service::valid_id(workspace_id)) bad("bad workspace id"); + headers["anthropic-workspace-id"] = workspace_id; +} + +} // namespace + +std::vector RequestBuilder::names(const char* list) { + std::vector out; + std::string cur; + for (const char* p = list; *p; ++p) { + if (*p == ',') { + if (!cur.empty()) out.push_back(cur); + cur.clear(); + } else { + cur += *p; + } + } + if (!cur.empty()) out.push_back(cur); + return out; +} + +bool RequestBuilder::contains(const char* list, const std::string& name) { + for (const std::string& n : names(list)) + if (n == name) return true; + return false; +} + +std::string RequestBuilder::path_of(Call call, const std::vector& ids) { + const CallSpec& spec = spec_of(call); + std::string tmpl = spec.path; + std::string out; + std::size_t used = 0; + for (std::size_t i = 0; i < tmpl.size(); ++i) { + if (tmpl[i] != '{') { + out += tmpl[i]; + continue; + } + std::size_t close = tmpl.find('}', i); + if (close == std::string::npos) bad("malformed path template"); + std::string label = tmpl.substr(i + 1, close - i - 1); + if (used >= ids.size()) bad("missing " + label); + if (ids[used].size() > Caps::kMaxIdBytes || !llm::Service::valid_id(ids[used])) bad("bad " + label); + out += ids[used++]; + i = close; + } + if (used != ids.size()) bad("too many ids for " + std::string(spec.name)); + return out; +} + +PreparedRequest RequestBuilder::prepare(Call call, const std::vector& ids, + const Query* query, const Json* body, + const std::string& workspace_id) { + const CallSpec& spec = spec_of(call); + if (spec.wire == Wire::kMultipart) bad(std::string(spec.name) + " is a multipart upload"); + PreparedRequest out; + out.call = call; + out.method = method_of(call); + out.path = path_of(call, ids); + + // --- body ----------------------------------------------------------------- + const std::vector body_fields = names(spec.body); + if (body_fields.empty()) { + if (body) bad(std::string(spec.name) + " takes no body"); + } else { + Json doc = body ? *body : Json::object(); + if (!doc.is_object()) bad("body must be a JSON object"); + for (const auto& [key, value] : doc.as_object()) { + (void)value; + bool known = false; + for (const std::string& f : body_fields) + if (f == key) known = true; + if (!known) bad("unknown field " + key + " for " + spec.name); + } + for (const std::string& r : names(spec.required)) { + if (!contains(spec.body, r)) continue; + const Json* v = doc.find(r); + if (!v || v->is_null()) bad(r + " is required"); + } + if (doc.dump().size() > Caps::kMaxBodyBytes) bad("body over the byte cap"); + out.body = std::move(doc); + } + + // --- query and header parameters -------------------------------------------- + const std::vector query_params = names(spec.query); + const std::vector header_params = names(spec.headers); + std::vector> wire; // name, value + std::map counts; + std::size_t total = 0; + if (query) { + for (const auto& [raw_name, value] : query->items()) { + const std::string name = base_of(raw_name); + bool array = false, found = false; + for (const std::string& p : query_params) { + if (base_of(p) == name) { + found = true; + array = p != name; + } + } + std::string header_name; + for (const std::string& h : header_params) { + std::size_t eq = h.find('='); + if (eq != std::string::npos && h.substr(0, eq) == name) header_name = h.substr(eq + 1); + } + if (!found && header_name.empty()) bad("unknown parameter " + name + " for " + spec.name); + if (value.size() > Caps::kMaxQueryValueBytes) bad(name + " is over the size cap"); + if (has_control(value)) bad(name + " has control characters"); + std::size_t n = ++counts[name]; + if (n > Caps::kMaxQueryValues) bad(name + " has too many values"); + if (!array && n > 1) bad(name + " takes one value"); + if (name == "limit") { + char* end = nullptr; + long lim = std::strtol(value.c_str(), &end, 10); + if (value.empty() || *end || lim < 1 || lim > Caps::kMaxLimit) + bad("limit must be 1.." + std::to_string(Caps::kMaxLimit)); + } + if (!header_name.empty()) { + out.headers[header_name] = value; + continue; + } + std::string pair = encode_pair(array ? name + "[]" : name, value); + total += pair.size() + 1; + if (total > Caps::kMaxQueryBytes) bad("query is over the size cap"); + wire.emplace_back(name, pair); + } + } + for (const std::string& r : names(spec.required)) { + if (contains(spec.body, r)) continue; + const std::string name = base_of(r); + if (!counts.count(name)) bad(name + " is required"); + } + out.target = out.path; + char sep = '?'; + for (const auto& w : wire) { + out.target += sep; + out.target += w.second; + sep = '&'; + } + + // --- headers ------------------------------------------------------------------ + if (spec.beta[0]) out.headers["anthropic-beta"] = spec.beta; + check_workspace(spec, workspace_id, out.headers); + return out; +} + +PreparedRequest RequestBuilder::prepare_form(Call call, const std::vector& ids, + const std::vector& part_names, + std::size_t total_bytes, + const std::string& workspace_id) { + const CallSpec& spec = spec_of(call); + if (spec.wire != Wire::kMultipart) bad(std::string(spec.name) + " is not a multipart upload"); + PreparedRequest out; + out.call = call; + out.method = method_of(call); + out.path = path_of(call, ids); + out.target = out.path; + if (part_names.size() > Caps::kMaxFormParts) bad("too many form parts"); + if (total_bytes > Caps::kMaxFormBytes) bad("upload over the byte cap"); + const std::vector allowed = names(spec.body); + for (const std::string& part : part_names) { + bool known = false; + for (const std::string& a : allowed) + if (a == part) known = true; + if (!known) bad("unknown form part " + part + " for " + spec.name); + } + for (const std::string& r : names(spec.required)) { + bool present = false; + for (const std::string& part : part_names) + if (part == r) present = true; + if (!present) bad("form part " + r + " is required"); + } + if (spec.beta[0]) out.headers["anthropic-beta"] = spec.beta; + check_workspace(spec, workspace_id, out.headers); + return out; +} + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/request.h b/src/anthropic/admin/request.h new file mode 100644 index 0000000..f5717b6 --- /dev/null +++ b/src/anthropic/admin/request.h @@ -0,0 +1,51 @@ +#pragma once + +// RequestBuilder: turns a call-table row plus ids, query and body into the +// exact request that would go on the wire, without touching the network. +// Every local rule lives here: ids are validated before a path is built, +// unknown and missing fields are rejected loudly, sizes and counts are +// capped. Tests and the demo's 422 path run on this alone. + +#include +#include +#include +#include + +#include "anthropic/admin/calls.h" +#include "anthropic/admin/query.h" +#include "clients/body/json.h" +#include "clients/request.h" + +namespace molo::anthropic::admin { + +struct PreparedRequest { + Call call; + clients::Method method; + std::string path; // /v1/organizations/invites/invite_01 + std::string target; // path plus ?query, ready for llm::ApiClient + std::map headers; + std::optional body; +}; + +class RequestBuilder { + public: + // Throws llm::ApiError::invalid (vendor "anthropic") on any local violation. + // `workspace_id` becomes the anthropic-workspace-id header for calls that + // accept it; empty means none. + static PreparedRequest prepare(Call call, const std::vector& ids, + const Query* query, const clients::body::Json* body, + const std::string& workspace_id = ""); + + // Multipart rows: checks part names against the table. Returns the target. + static PreparedRequest prepare_form(Call call, const std::vector& ids, + const std::vector& part_names, + std::size_t total_bytes, + const std::string& workspace_id = ""); + + // Names in a comma list from the call table. + static std::vector names(const char* list); + static bool contains(const char* list, const std::string& name); + static std::string path_of(Call call, const std::vector& ids); +}; + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/resource.cpp b/src/anthropic/admin/resource.cpp new file mode 100644 index 0000000..e26d7e8 --- /dev/null +++ b/src/anthropic/admin/resource.cpp @@ -0,0 +1,86 @@ +#include "anthropic/admin/resource.h" + +#include + +#include "llm/error.h" + +namespace molo::anthropic::admin { + +Resource::Resource(std::shared_ptr gateway, Auth auth) + : llm::Service(gateway->primary_client(auth)), gateway_(std::move(gateway)), auth_(auth) {} + +const CallSpec& Resource::checked(Call call) const { + const CallSpec& spec = spec_of(call); + if (spec.auth != auth_) + throw std::logic_error(std::string(spec.name) + " does not belong to this resource's credential class"); + return spec; +} + +Json Resource::do_json(Call call, const std::vector& ids, const Query* query, + const Json* body) const { + checked(call); + PreparedRequest p = RequestBuilder::prepare(call, ids, query, body, gateway_->workspace_id()); + auto client = gateway_->client_for(auth_); + return client->request(p.method, p.target, p.body ? &*p.body : nullptr, p.headers); +} + +llm::RawResponse Resource::do_raw(Call call, const std::vector& ids, + const Query* query) const { + checked(call); + PreparedRequest p = RequestBuilder::prepare(call, ids, query, nullptr, gateway_->workspace_id()); + auto client = gateway_->client_for(auth_); + return client->request_raw(p.method, p.target, nullptr, "", p.headers); +} + +Json Resource::do_form(Call call, const std::vector& ids, + const clients::body::MultipartBody& form) const { + checked(call); + std::vector names; + for (const auto& part : form.parts()) names.push_back(part.name); + PreparedRequest p = RequestBuilder::prepare_form(call, ids, names, form.encoded_size(), + gateway_->workspace_id()); + auto client = gateway_->client_for(auth_); + return client->post_multipart(p.target, form, p.headers); +} + +void Resource::do_stream(Call call, const std::vector& ids, const Query* query, + const EventSink& sink) const { + checked(call); + PreparedRequest p = RequestBuilder::prepare(call, ids, query, nullptr, gateway_->workspace_id()); + gateway_->stream_get(auth_, p.target, p.headers, sink, Caps::kMaxStreamEvents); +} + +Walk Resource::do_walk(Call call, const std::vector& ids, const Query& query, + std::size_t max_pages) const { + const CallSpec& spec = checked(call); + if (spec.page == Page::kNone) throw std::logic_error(std::string(spec.name) + " is not paginated"); + if (max_pages == 0 || max_pages > Caps::kMaxPagesHard) + throw llm::ApiError::invalid("anthropic", + "max_pages must be 1.." + std::to_string(Caps::kMaxPagesHard)); + Walk out; + Query q = query; + while (true) { + Json page = do_json(call, ids, &q, nullptr); + ++out.pages; + for (const Json& item : Pager::items_of(page)) { + if (out.size() >= Caps::kMaxItems) { + out.truncated = true; + out.reason = "item_cap"; + return out; + } + out.items.push(item); + } + Query next = q; + if (!Pager::advance(spec.page, page, next)) return out; + out.next_page = next.get("page"); + if (out.pages >= max_pages) { + out.truncated = true; + out.reason = "page_cap"; + return out; + } + out.next_page.clear(); + q = std::move(next); + } +} + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/resource.h b/src/anthropic/admin/resource.h new file mode 100644 index 0000000..41a7196 --- /dev/null +++ b/src/anthropic/admin/resource.h @@ -0,0 +1,57 @@ +#pragma once + +// Resource: base of every generated service class (services/*.h). One class +// per resource group, one method per call-table row. Each method validates +// locally first (RequestBuilder: ids, fields, sizes), then needs the right +// credential lane (Gateway), then sends. Destructive and mutating methods are +// separate, explicit methods with no default behavior. + +#include +#include +#include +#include + +#include "anthropic/admin/caps.h" +#include "anthropic/admin/gateway.h" +#include "anthropic/admin/pager.h" +#include "anthropic/admin/query.h" +#include "anthropic/admin/request.h" +#include "clients/body/form.h" +#include "llm/api_client.h" + +namespace molo::anthropic::admin { + +using Json = clients::body::Json; +using EventSink = llm::SseDecoder::Sink; + +class Resource : public llm::Service { + public: + Resource(std::shared_ptr gateway, Auth auth); + + Auth auth() const { return auth_; } + // True when a call of this class could be sent now (credential present). + bool ready() const { return gateway_->ready(auth_); } + const Gateway& gateway() const { return *gateway_; } + + protected: + Json do_json(Call call, const std::vector& ids, const Query* query, + const Json* body) const; + llm::RawResponse do_raw(Call call, const std::vector& ids, + const Query* query) const; + Json do_form(Call call, const std::vector& ids, + const clients::body::MultipartBody& form) const; + // Streams GET server-sent events; at most Caps::kMaxStreamEvents events. + void do_stream(Call call, const std::vector& ids, const Query* query, + const EventSink& sink) const; + // Walks every page of a list call, capped in pages and items. + Walk do_walk(Call call, const std::vector& ids, const Query& query, + std::size_t max_pages) const; + + private: + const CallSpec& checked(Call call) const; + + std::shared_ptr gateway_; + Auth auth_; +}; + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/access.cpp b/src/anthropic/admin/services/access.cpp new file mode 100644 index 0000000..b413d12 --- /dev/null +++ b/src/anthropic/admin/services/access.cpp @@ -0,0 +1,171 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#include "anthropic/admin/services/access.h" + +namespace molo::anthropic::admin { + +Json FederationIssuers::archive(const std::string& federation_issuer_id) const { + return do_json(Call::kFederationIssuersArchive, {federation_issuer_id}, nullptr, nullptr); +} + +Json FederationIssuers::create(const Json& body) const { + return do_json(Call::kFederationIssuersCreate, {}, nullptr, &body); +} + +Json FederationIssuers::list(const Query& query) const { + return do_json(Call::kFederationIssuersList, {}, &query, nullptr); +} + +Walk FederationIssuers::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kFederationIssuersList, {}, query, max_pages); +} + +Json FederationIssuers::get(const std::string& federation_issuer_id) const { + return do_json(Call::kFederationIssuersRetrieve, {federation_issuer_id}, nullptr, nullptr); +} + +Json FederationIssuers::update(const std::string& federation_issuer_id, const Json& body) const { + return do_json(Call::kFederationIssuersUpdate, {federation_issuer_id}, nullptr, &body); +} + +Json FederationRules::archive(const std::string& federation_rule_id) const { + return do_json(Call::kFederationRulesArchive, {federation_rule_id}, nullptr, nullptr); +} + +Json FederationRules::create(const Json& body) const { + return do_json(Call::kFederationRulesCreate, {}, nullptr, &body); +} + +Json FederationRules::list(const Query& query) const { + return do_json(Call::kFederationRulesList, {}, &query, nullptr); +} + +Walk FederationRules::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kFederationRulesList, {}, query, max_pages); +} + +Json FederationRules::get(const std::string& federation_rule_id) const { + return do_json(Call::kFederationRulesRetrieve, {federation_rule_id}, nullptr, nullptr); +} + +Json FederationRules::update(const std::string& federation_rule_id, const Json& body) const { + return do_json(Call::kFederationRulesUpdate, {federation_rule_id}, nullptr, &body); +} + +Json FederationRuleWorkspaces::add(const std::string& federation_rule_id, const Json& body) const { + return do_json(Call::kFederationRulesWorkspacesAdd, {federation_rule_id}, nullptr, &body); +} + +Json FederationRuleWorkspaces::list(const std::string& federation_rule_id, const Query& query) const { + return do_json(Call::kFederationRulesWorkspacesList, {federation_rule_id}, &query, nullptr); +} + +Walk FederationRuleWorkspaces::list_all(const std::string& federation_rule_id, const Query& query, std::size_t max_pages) const { + return do_walk(Call::kFederationRulesWorkspacesList, {federation_rule_id}, query, max_pages); +} + +Json FederationRuleWorkspaces::remove(const std::string& federation_rule_id, const std::string& workspace_id) const { + return do_json(Call::kFederationRulesWorkspacesRemove, {federation_rule_id, workspace_id}, nullptr, nullptr); +} + +Json RbacGroups::create(const Json& body) const { + return do_json(Call::kRbacGroupsCreate, {}, nullptr, &body); +} + +Json RbacGroups::destroy(const std::string& rbac_group_id) const { + return do_json(Call::kRbacGroupsDelete, {rbac_group_id}, nullptr, nullptr); +} + +Json RbacGroups::list(const Query& query) const { + return do_json(Call::kRbacGroupsList, {}, &query, nullptr); +} + +Walk RbacGroups::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kRbacGroupsList, {}, query, max_pages); +} + +Json RbacGroups::get(const std::string& rbac_group_id) const { + return do_json(Call::kRbacGroupsRetrieve, {rbac_group_id}, nullptr, nullptr); +} + +Json RbacGroups::update(const std::string& rbac_group_id, const Json& body) const { + return do_json(Call::kRbacGroupsUpdate, {rbac_group_id}, nullptr, &body); +} + +Json RbacGroupsMembers::add(const std::string& rbac_group_id, const Json& body) const { + return do_json(Call::kRbacGroupsMembersAdd, {rbac_group_id}, nullptr, &body); +} + +Json RbacGroupsMembers::list(const std::string& rbac_group_id, const Query& query) const { + return do_json(Call::kRbacGroupsMembersList, {rbac_group_id}, &query, nullptr); +} + +Walk RbacGroupsMembers::list_all(const std::string& rbac_group_id, const Query& query, std::size_t max_pages) const { + return do_walk(Call::kRbacGroupsMembersList, {rbac_group_id}, query, max_pages); +} + +Json RbacGroupsMembers::remove(const std::string& rbac_group_id, const std::string& user_id) const { + return do_json(Call::kRbacGroupsMembersRemove, {rbac_group_id, user_id}, nullptr, nullptr); +} + +Json RbacRoles::list(const Query& query) const { + return do_json(Call::kRbacRolesList, {}, &query, nullptr); +} + +Walk RbacRoles::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kRbacRolesList, {}, query, max_pages); +} + +Json RbacRoles::get(const std::string& rbac_role_id) const { + return do_json(Call::kRbacRolesRetrieve, {rbac_role_id}, nullptr, nullptr); +} + +Json RbacRolesPermissions::list(const std::string& rbac_role_id, const Query& query) const { + return do_json(Call::kRbacRolesPermissionsList, {rbac_role_id}, &query, nullptr); +} + +Walk RbacRolesPermissions::list_all(const std::string& rbac_role_id, const Query& query, std::size_t max_pages) const { + return do_walk(Call::kRbacRolesPermissionsList, {rbac_role_id}, query, max_pages); +} + +Json ServiceAccounts::archive(const std::string& service_account_id) const { + return do_json(Call::kServiceAccountsArchive, {service_account_id}, nullptr, nullptr); +} + +Json ServiceAccounts::create(const Json& body) const { + return do_json(Call::kServiceAccountsCreate, {}, nullptr, &body); +} + +Json ServiceAccounts::list(const Query& query) const { + return do_json(Call::kServiceAccountsList, {}, &query, nullptr); +} + +Walk ServiceAccounts::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kServiceAccountsList, {}, query, max_pages); +} + +Json ServiceAccounts::get(const std::string& service_account_id) const { + return do_json(Call::kServiceAccountsRetrieve, {service_account_id}, nullptr, nullptr); +} + +Json ServiceAccounts::update(const std::string& service_account_id, const Json& body) const { + return do_json(Call::kServiceAccountsUpdate, {service_account_id}, nullptr, &body); +} + +Json ServiceAccountWorkspaces::add(const std::string& service_account_id, const Json& body) const { + return do_json(Call::kServiceAccountsWorkspacesAdd, {service_account_id}, nullptr, &body); +} + +Json ServiceAccountWorkspaces::list(const std::string& service_account_id, const Query& query) const { + return do_json(Call::kServiceAccountsWorkspacesList, {service_account_id}, &query, nullptr); +} + +Walk ServiceAccountWorkspaces::list_all(const std::string& service_account_id, const Query& query, std::size_t max_pages) const { + return do_walk(Call::kServiceAccountsWorkspacesList, {service_account_id}, query, max_pages); +} + +Json ServiceAccountWorkspaces::remove(const std::string& service_account_id, const std::string& workspace_id) const { + return do_json(Call::kServiceAccountsWorkspacesRemove, {service_account_id, workspace_id}, nullptr, nullptr); +} + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/access.h b/src/anthropic/admin/services/access.h new file mode 100644 index 0000000..76d8daf --- /dev/null +++ b/src/anthropic/admin/services/access.h @@ -0,0 +1,201 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#pragma once + +// access calls of the Anthropic API (one class per resource group). Every +// method is one row of calls.cpp; mutating and destructive ones are marked. + +#include +#include + +#include "anthropic/admin/resource.h" + +namespace molo::anthropic::admin { + +// group federation.issuers +class FederationIssuers : public Resource { + public: + explicit FederationIssuers(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kOAuth) {} + + // POST /v1/organizations/federation_issuers/{federation_issuer_id}/archive DESTRUCTIVE + Json archive(const std::string& federation_issuer_id) const; + + // POST /v1/organizations/federation_issuers MUTATES + Json create(const Json& body) const; + + // GET /v1/organizations/federation_issuers + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/organizations/federation_issuers/{federation_issuer_id} + Json get(const std::string& federation_issuer_id) const; + + // POST /v1/organizations/federation_issuers/{federation_issuer_id} MUTATES + Json update(const std::string& federation_issuer_id, const Json& body) const; + +}; + +// group federation.rules +class FederationRules : public Resource { + public: + explicit FederationRules(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kOAuth) {} + + // POST /v1/organizations/federation_rules/{federation_rule_id}/archive DESTRUCTIVE + Json archive(const std::string& federation_rule_id) const; + + // POST /v1/organizations/federation_rules MUTATES + Json create(const Json& body) const; + + // GET /v1/organizations/federation_rules + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/organizations/federation_rules/{federation_rule_id} + Json get(const std::string& federation_rule_id) const; + + // POST /v1/organizations/federation_rules/{federation_rule_id} MUTATES + Json update(const std::string& federation_rule_id, const Json& body) const; + +}; + +// group federation.rules.workspaces +class FederationRuleWorkspaces : public Resource { + public: + explicit FederationRuleWorkspaces(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kOAuth) {} + + // POST /v1/organizations/federation_rules/{federation_rule_id}/workspaces MUTATES + Json add(const std::string& federation_rule_id, const Json& body) const; + + // GET /v1/organizations/federation_rules/{federation_rule_id}/workspaces + Json list(const std::string& federation_rule_id, const Query& query = Query()) const; + + Walk list_all(const std::string& federation_rule_id, const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // DELETE /v1/organizations/federation_rules/{federation_rule_id}/workspaces/{workspace_id} DESTRUCTIVE + Json remove(const std::string& federation_rule_id, const std::string& workspace_id) const; + +}; + +// group rbac_groups +class RbacGroups : public Resource { + public: + explicit RbacGroups(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // POST /v1/organizations/rbac_groups MUTATES + Json create(const Json& body) const; + + // DELETE /v1/organizations/rbac_groups/{rbac_group_id} DESTRUCTIVE + Json destroy(const std::string& rbac_group_id) const; + + // GET /v1/organizations/rbac_groups + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/organizations/rbac_groups/{rbac_group_id} + Json get(const std::string& rbac_group_id) const; + + // POST /v1/organizations/rbac_groups/{rbac_group_id} MUTATES + Json update(const std::string& rbac_group_id, const Json& body) const; + +}; + +// group rbac_groups.members +class RbacGroupsMembers : public Resource { + public: + explicit RbacGroupsMembers(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // POST /v1/organizations/rbac_groups/{rbac_group_id}/members MUTATES + Json add(const std::string& rbac_group_id, const Json& body) const; + + // GET /v1/organizations/rbac_groups/{rbac_group_id}/members + Json list(const std::string& rbac_group_id, const Query& query = Query()) const; + + Walk list_all(const std::string& rbac_group_id, const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // DELETE /v1/organizations/rbac_groups/{rbac_group_id}/members/{user_id} DESTRUCTIVE + Json remove(const std::string& rbac_group_id, const std::string& user_id) const; + +}; + +// group rbac_roles +class RbacRoles : public Resource { + public: + explicit RbacRoles(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // GET /v1/organizations/rbac_roles + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/organizations/rbac_roles/{rbac_role_id} + Json get(const std::string& rbac_role_id) const; + +}; + +// group rbac_roles.permissions +class RbacRolesPermissions : public Resource { + public: + explicit RbacRolesPermissions(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // GET /v1/organizations/rbac_roles/{rbac_role_id}/permissions + Json list(const std::string& rbac_role_id, const Query& query = Query()) const; + + Walk list_all(const std::string& rbac_role_id, const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + +}; + +// group service_accounts +class ServiceAccounts : public Resource { + public: + explicit ServiceAccounts(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kOAuth) {} + + // POST /v1/organizations/service_accounts/{service_account_id}/archive DESTRUCTIVE + Json archive(const std::string& service_account_id) const; + + // POST /v1/organizations/service_accounts MUTATES + Json create(const Json& body) const; + + // GET /v1/organizations/service_accounts + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/organizations/service_accounts/{service_account_id} + Json get(const std::string& service_account_id) const; + + // POST /v1/organizations/service_accounts/{service_account_id} MUTATES + Json update(const std::string& service_account_id, const Json& body) const; + +}; + +// group service_accounts.workspaces +class ServiceAccountWorkspaces : public Resource { + public: + explicit ServiceAccountWorkspaces(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kOAuth) {} + + // POST /v1/organizations/service_accounts/{service_account_id}/workspaces MUTATES + Json add(const std::string& service_account_id, const Json& body) const; + + // GET /v1/organizations/service_accounts/{service_account_id}/workspaces + Json list(const std::string& service_account_id, const Query& query = Query()) const; + + Walk list_all(const std::string& service_account_id, const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // DELETE /v1/organizations/service_accounts/{service_account_id}/workspaces/{workspace_id} DESTRUCTIVE + Json remove(const std::string& service_account_id, const std::string& workspace_id) const; + +}; + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/agents.cpp b/src/anthropic/admin/services/agents.cpp new file mode 100644 index 0000000..234b9b2 --- /dev/null +++ b/src/anthropic/admin/services/agents.cpp @@ -0,0 +1,39 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#include "anthropic/admin/services/agents.h" + +namespace molo::anthropic::admin { + +Json Agents::archive(const std::string& agent_id) const { + return do_json(Call::kAgentsArchive, {agent_id}, nullptr, nullptr); +} + +Json Agents::create(const Json& body) const { + return do_json(Call::kAgentsCreate, {}, nullptr, &body); +} + +Json Agents::list(const Query& query) const { + return do_json(Call::kAgentsList, {}, &query, nullptr); +} + +Walk Agents::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kAgentsList, {}, query, max_pages); +} + +Json Agents::get(const std::string& agent_id, const Query& query) const { + return do_json(Call::kAgentsRetrieve, {agent_id}, &query, nullptr); +} + +Json Agents::update(const std::string& agent_id, const Json& body) const { + return do_json(Call::kAgentsUpdate, {agent_id}, nullptr, &body); +} + +Json AgentsVersions::list(const std::string& agent_id, const Query& query) const { + return do_json(Call::kAgentsVersionsList, {agent_id}, &query, nullptr); +} + +Walk AgentsVersions::list_all(const std::string& agent_id, const Query& query, std::size_t max_pages) const { + return do_walk(Call::kAgentsVersionsList, {agent_id}, query, max_pages); +} + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/agents.h b/src/anthropic/admin/services/agents.h new file mode 100644 index 0000000..ae5d7fc --- /dev/null +++ b/src/anthropic/admin/services/agents.h @@ -0,0 +1,53 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#pragma once + +// agents calls of the Anthropic API (one class per resource group). Every +// method is one row of calls.cpp; mutating and destructive ones are marked. + +#include +#include + +#include "anthropic/admin/resource.h" + +namespace molo::anthropic::admin { + +// group agents +class Agents : public Resource { + public: + explicit Agents(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kPlatform) {} + + // POST /v1/agents/{agent_id}/archive DESTRUCTIVE + Json archive(const std::string& agent_id) const; + + // POST /v1/agents MUTATES + Json create(const Json& body) const; + + // GET /v1/agents + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/agents/{agent_id} + Json get(const std::string& agent_id, const Query& query = Query()) const; + + // POST /v1/agents/{agent_id} MUTATES + Json update(const std::string& agent_id, const Json& body) const; + +}; + +// group agents.versions +class AgentsVersions : public Resource { + public: + explicit AgentsVersions(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kPlatform) {} + + // GET /v1/agents/{agent_id}/versions + Json list(const std::string& agent_id, const Query& query = Query()) const; + + Walk list_all(const std::string& agent_id, const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + +}; + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/analytics.cpp b/src/anthropic/admin/services/analytics.cpp new file mode 100644 index 0000000..b9f2421 --- /dev/null +++ b/src/anthropic/admin/services/analytics.cpp @@ -0,0 +1,111 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#include "anthropic/admin/services/analytics.h" + +namespace molo::anthropic::admin { + +Json AnalyticsAppsChatProjects::list(const Query& query) const { + return do_json(Call::kAnalyticsAppsChatProjectsList, {}, &query, nullptr); +} + +Walk AnalyticsAppsChatProjects::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kAnalyticsAppsChatProjectsList, {}, query, max_pages); +} + +Json AnalyticsArtifacts::list(const Query& query) const { + return do_json(Call::kAnalyticsArtifactsList, {}, &query, nullptr); +} + +Walk AnalyticsArtifacts::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kAnalyticsArtifactsList, {}, query, max_pages); +} + +Json AnalyticsConnectors::list(const Query& query) const { + return do_json(Call::kAnalyticsConnectorsList, {}, &query, nullptr); +} + +Walk AnalyticsConnectors::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kAnalyticsConnectorsList, {}, query, max_pages); +} + +Json AnalyticsCost::list(const Query& query) const { + return do_json(Call::kAnalyticsCostList, {}, &query, nullptr); +} + +Walk AnalyticsCost::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kAnalyticsCostList, {}, query, max_pages); +} + +Json AnalyticsCostReport::list(const Query& query) const { + return do_json(Call::kAnalyticsCostReportList, {}, &query, nullptr); +} + +Walk AnalyticsCostReport::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kAnalyticsCostReportList, {}, query, max_pages); +} + +Json AnalyticsPlugins::list(const Query& query) const { + return do_json(Call::kAnalyticsPluginsList, {}, &query, nullptr); +} + +Walk AnalyticsPlugins::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kAnalyticsPluginsList, {}, query, max_pages); +} + +Json AnalyticsSkills::list(const Query& query) const { + return do_json(Call::kAnalyticsSkillsList, {}, &query, nullptr); +} + +Walk AnalyticsSkills::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kAnalyticsSkillsList, {}, query, max_pages); +} + +Json AnalyticsSummaries::list(const Query& query) const { + return do_json(Call::kAnalyticsSummariesList, {}, &query, nullptr); +} + +Walk AnalyticsSummaries::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kAnalyticsSummariesList, {}, query, max_pages); +} + +Json AnalyticsUsage::list(const Query& query) const { + return do_json(Call::kAnalyticsUsageList, {}, &query, nullptr); +} + +Walk AnalyticsUsage::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kAnalyticsUsageList, {}, query, max_pages); +} + +Json AnalyticsUsageReport::list(const Query& query) const { + return do_json(Call::kAnalyticsUsageReportList, {}, &query, nullptr); +} + +Walk AnalyticsUsageReport::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kAnalyticsUsageReportList, {}, query, max_pages); +} + +Json AnalyticsUserCostReport::list(const Query& query) const { + return do_json(Call::kAnalyticsUserCostReportList, {}, &query, nullptr); +} + +Walk AnalyticsUserCostReport::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kAnalyticsUserCostReportList, {}, query, max_pages); +} + +Json AnalyticsUserUsageReport::list(const Query& query) const { + return do_json(Call::kAnalyticsUserUsageReportList, {}, &query, nullptr); +} + +Walk AnalyticsUserUsageReport::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kAnalyticsUserUsageReportList, {}, query, max_pages); +} + +Json AnalyticsUsers::list(const Query& query) const { + return do_json(Call::kAnalyticsUsersList, {}, &query, nullptr); +} + +Walk AnalyticsUsers::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kAnalyticsUsersList, {}, query, max_pages); +} + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/analytics.h b/src/anthropic/admin/services/analytics.h new file mode 100644 index 0000000..b7446b6 --- /dev/null +++ b/src/anthropic/admin/services/analytics.h @@ -0,0 +1,184 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#pragma once + +// analytics calls of the Anthropic API (one class per resource group). Every +// method is one row of calls.cpp; mutating and destructive ones are marked. + +#include +#include + +#include "anthropic/admin/resource.h" + +namespace molo::anthropic::admin { + +// group analytics.apps.chat.projects +class AnalyticsAppsChatProjects : public Resource { + public: + explicit AnalyticsAppsChatProjects(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // GET /v1/organizations/analytics/apps/chat/projects + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + +}; + +// group analytics.artifacts +class AnalyticsArtifacts : public Resource { + public: + explicit AnalyticsArtifacts(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // GET /v1/organizations/analytics/artifacts + Json list(const Query& query) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + +}; + +// group analytics.connectors +class AnalyticsConnectors : public Resource { + public: + explicit AnalyticsConnectors(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // GET /v1/organizations/analytics/connectors + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + +}; + +// group analytics.cost +class AnalyticsCost : public Resource { + public: + explicit AnalyticsCost(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // GET /v1/organizations/analytics/cost + Json list(const Query& query) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + +}; + +// group analytics.cost_report +class AnalyticsCostReport : public Resource { + public: + explicit AnalyticsCostReport(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // GET /v1/organizations/analytics/cost_report + Json list(const Query& query) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + +}; + +// group analytics.plugins +class AnalyticsPlugins : public Resource { + public: + explicit AnalyticsPlugins(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // GET /v1/organizations/analytics/plugins + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + +}; + +// group analytics.skills +class AnalyticsSkills : public Resource { + public: + explicit AnalyticsSkills(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // GET /v1/organizations/analytics/skills + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + +}; + +// group analytics.summaries +class AnalyticsSummaries : public Resource { + public: + explicit AnalyticsSummaries(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // GET /v1/organizations/analytics/summaries + Json list(const Query& query) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + +}; + +// group analytics.usage +class AnalyticsUsage : public Resource { + public: + explicit AnalyticsUsage(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // GET /v1/organizations/analytics/usage + Json list(const Query& query) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + +}; + +// group analytics.usage_report +class AnalyticsUsageReport : public Resource { + public: + explicit AnalyticsUsageReport(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // GET /v1/organizations/analytics/usage_report + Json list(const Query& query) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + +}; + +// group analytics.user_cost_report +class AnalyticsUserCostReport : public Resource { + public: + explicit AnalyticsUserCostReport(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // GET /v1/organizations/analytics/user_cost_report + Json list(const Query& query) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + +}; + +// group analytics.user_usage_report +class AnalyticsUserUsageReport : public Resource { + public: + explicit AnalyticsUserUsageReport(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // GET /v1/organizations/analytics/user_usage_report + Json list(const Query& query) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + +}; + +// group analytics.users +class AnalyticsUsers : public Resource { + public: + explicit AnalyticsUsers(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // GET /v1/organizations/analytics/users + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + +}; + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/claude_tag.cpp b/src/anthropic/admin/services/claude_tag.cpp new file mode 100644 index 0000000..6167797 --- /dev/null +++ b/src/anthropic/admin/services/claude_tag.cpp @@ -0,0 +1,79 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#include "anthropic/admin/services/claude_tag.h" + +namespace molo::anthropic::admin { + +Json ClaudeTagBundles::list(const Query& query) const { + return do_json(Call::kClaudeTagBundlesList, {}, &query, nullptr); +} + +Walk ClaudeTagBundles::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kClaudeTagBundlesList, {}, query, max_pages); +} + +Json ClaudeTagBundles::get(const std::string& bundle_id) const { + return do_json(Call::kClaudeTagBundlesRetrieve, {bundle_id}, nullptr, nullptr); +} + +Json ClaudeTagBundlesTargets::create(const std::string& bundle_id) const { + return do_json(Call::kClaudeTagBundlesTargetsCreate, {bundle_id}, nullptr, nullptr); +} + +Json ClaudeTagBundlesTargets::destroy(const std::string& bundle_id, const std::string& target_id) const { + return do_json(Call::kClaudeTagBundlesTargetsDelete, {bundle_id, target_id}, nullptr, nullptr); +} + +Json ClaudeTagBundlesTargets::list(const std::string& bundle_id, const Query& query) const { + return do_json(Call::kClaudeTagBundlesTargetsList, {bundle_id}, &query, nullptr); +} + +Walk ClaudeTagBundlesTargets::list_all(const std::string& bundle_id, const Query& query, std::size_t max_pages) const { + return do_walk(Call::kClaudeTagBundlesTargetsList, {bundle_id}, query, max_pages); +} + +Json ClaudeTagBundlesTargets::get(const std::string& bundle_id, const std::string& target_id) const { + return do_json(Call::kClaudeTagBundlesTargetsRetrieve, {bundle_id, target_id}, nullptr, nullptr); +} + +Json ClaudeTagSlackChannels::create(const Json& body) const { + return do_json(Call::kClaudeTagSlackChannelsCreate, {}, nullptr, &body); +} + +Json ClaudeTagSlackChannels::destroy(const std::string& id) const { + return do_json(Call::kClaudeTagSlackChannelsDelete, {id}, nullptr, nullptr); +} + +Json ClaudeTagSlackChannels::list(const Query& query) const { + return do_json(Call::kClaudeTagSlackChannelsList, {}, &query, nullptr); +} + +Walk ClaudeTagSlackChannels::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kClaudeTagSlackChannelsList, {}, query, max_pages); +} + +Json ClaudeTagSlackChannels::get(const std::string& id, const Query& query) const { + return do_json(Call::kClaudeTagSlackChannelsRetrieve, {id}, &query, nullptr); +} + +Json ClaudeTagSlackChannels::update(const std::string& id, const Json& body) const { + return do_json(Call::kClaudeTagSlackChannelsUpdate, {id}, nullptr, &body); +} + +Json ClaudeTagSlackWorkspaces::list(const Query& query) const { + return do_json(Call::kClaudeTagSlackWorkspacesList, {}, &query, nullptr); +} + +Walk ClaudeTagSlackWorkspaces::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kClaudeTagSlackWorkspacesList, {}, query, max_pages); +} + +Json ClaudeTagSlackWorkspaces::get(const std::string& id, const Query& query) const { + return do_json(Call::kClaudeTagSlackWorkspacesRetrieve, {id}, &query, nullptr); +} + +Json ClaudeTagSlackWorkspaces::update(const std::string& id, const Json& body) const { + return do_json(Call::kClaudeTagSlackWorkspacesUpdate, {id}, nullptr, &body); +} + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/claude_tag.h b/src/anthropic/admin/services/claude_tag.h new file mode 100644 index 0000000..8c28614 --- /dev/null +++ b/src/anthropic/admin/services/claude_tag.h @@ -0,0 +1,97 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#pragma once + +// claude_tag calls of the Anthropic API (one class per resource group). Every +// method is one row of calls.cpp; mutating and destructive ones are marked. + +#include +#include + +#include "anthropic/admin/resource.h" + +namespace molo::anthropic::admin { + +// group claude_tag.bundles +class ClaudeTagBundles : public Resource { + public: + explicit ClaudeTagBundles(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // GET /v1/organizations/claude_tag/bundles + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/organizations/claude_tag/bundles/{bundle_id} + Json get(const std::string& bundle_id) const; + +}; + +// group claude_tag.bundles.targets +class ClaudeTagBundlesTargets : public Resource { + public: + explicit ClaudeTagBundlesTargets(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // POST /v1/organizations/claude_tag/bundles/{bundle_id}/targets MUTATES + Json create(const std::string& bundle_id) const; + + // DELETE /v1/organizations/claude_tag/bundles/{bundle_id}/targets/{target_id} DESTRUCTIVE + Json destroy(const std::string& bundle_id, const std::string& target_id) const; + + // GET /v1/organizations/claude_tag/bundles/{bundle_id}/targets + Json list(const std::string& bundle_id, const Query& query = Query()) const; + + Walk list_all(const std::string& bundle_id, const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/organizations/claude_tag/bundles/{bundle_id}/targets/{target_id} + Json get(const std::string& bundle_id, const std::string& target_id) const; + +}; + +// group claude_tag.slack_channels +class ClaudeTagSlackChannels : public Resource { + public: + explicit ClaudeTagSlackChannels(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // POST /v1/organizations/claude_tag/slack_channels MUTATES + Json create(const Json& body) const; + + // DELETE /v1/organizations/claude_tag/slack_channels/{id} DESTRUCTIVE + Json destroy(const std::string& id) const; + + // GET /v1/organizations/claude_tag/slack_channels + Json list(const Query& query) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/organizations/claude_tag/slack_channels/{id} + Json get(const std::string& id, const Query& query = Query()) const; + + // POST /v1/organizations/claude_tag/slack_channels/{id} MUTATES + Json update(const std::string& id, const Json& body) const; + +}; + +// group claude_tag.slack_workspaces +class ClaudeTagSlackWorkspaces : public Resource { + public: + explicit ClaudeTagSlackWorkspaces(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // GET /v1/organizations/claude_tag/slack_workspaces + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/organizations/claude_tag/slack_workspaces/{id} + Json get(const std::string& id, const Query& query = Query()) const; + + // POST /v1/organizations/claude_tag/slack_workspaces/{id} MUTATES + Json update(const std::string& id, const Json& body) const; + +}; + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/deployments.cpp b/src/anthropic/admin/services/deployments.cpp new file mode 100644 index 0000000..e341161 --- /dev/null +++ b/src/anthropic/admin/services/deployments.cpp @@ -0,0 +1,55 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#include "anthropic/admin/services/deployments.h" + +namespace molo::anthropic::admin { + +Json DeploymentRuns::list(const Query& query) const { + return do_json(Call::kDeploymentRunsList, {}, &query, nullptr); +} + +Walk DeploymentRuns::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kDeploymentRunsList, {}, query, max_pages); +} + +Json DeploymentRuns::get(const std::string& deployment_run_id) const { + return do_json(Call::kDeploymentRunsRetrieve, {deployment_run_id}, nullptr, nullptr); +} + +Json Deployments::archive(const std::string& deployment_id) const { + return do_json(Call::kDeploymentsArchive, {deployment_id}, nullptr, nullptr); +} + +Json Deployments::create(const Json& body) const { + return do_json(Call::kDeploymentsCreate, {}, nullptr, &body); +} + +Json Deployments::list(const Query& query) const { + return do_json(Call::kDeploymentsList, {}, &query, nullptr); +} + +Walk Deployments::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kDeploymentsList, {}, query, max_pages); +} + +Json Deployments::pause(const std::string& deployment_id) const { + return do_json(Call::kDeploymentsPause, {deployment_id}, nullptr, nullptr); +} + +Json Deployments::get(const std::string& deployment_id) const { + return do_json(Call::kDeploymentsRetrieve, {deployment_id}, nullptr, nullptr); +} + +Json Deployments::run(const std::string& deployment_id) const { + return do_json(Call::kDeploymentsRun, {deployment_id}, nullptr, nullptr); +} + +Json Deployments::unpause(const std::string& deployment_id) const { + return do_json(Call::kDeploymentsUnpause, {deployment_id}, nullptr, nullptr); +} + +Json Deployments::update(const std::string& deployment_id, const Json& body) const { + return do_json(Call::kDeploymentsUpdate, {deployment_id}, nullptr, &body); +} + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/deployments.h b/src/anthropic/admin/services/deployments.h new file mode 100644 index 0000000..6ccd2ff --- /dev/null +++ b/src/anthropic/admin/services/deployments.h @@ -0,0 +1,65 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#pragma once + +// deployments calls of the Anthropic API (one class per resource group). Every +// method is one row of calls.cpp; mutating and destructive ones are marked. + +#include +#include + +#include "anthropic/admin/resource.h" + +namespace molo::anthropic::admin { + +// group deployment_runs +class DeploymentRuns : public Resource { + public: + explicit DeploymentRuns(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kPlatform) {} + + // GET /v1/deployment_runs + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/deployment_runs/{deployment_run_id} + Json get(const std::string& deployment_run_id) const; + +}; + +// group deployments +class Deployments : public Resource { + public: + explicit Deployments(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kPlatform) {} + + // POST /v1/deployments/{deployment_id}/archive DESTRUCTIVE + Json archive(const std::string& deployment_id) const; + + // POST /v1/deployments MUTATES + Json create(const Json& body) const; + + // GET /v1/deployments + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // POST /v1/deployments/{deployment_id}/pause DESTRUCTIVE + Json pause(const std::string& deployment_id) const; + + // GET /v1/deployments/{deployment_id} + Json get(const std::string& deployment_id) const; + + // POST /v1/deployments/{deployment_id}/run MUTATES + Json run(const std::string& deployment_id) const; + + // POST /v1/deployments/{deployment_id}/unpause MUTATES + Json unpause(const std::string& deployment_id) const; + + // POST /v1/deployments/{deployment_id} MUTATES + Json update(const std::string& deployment_id, const Json& body) const; + +}; + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/dreams.cpp b/src/anthropic/admin/services/dreams.cpp new file mode 100644 index 0000000..5d5ce2c --- /dev/null +++ b/src/anthropic/admin/services/dreams.cpp @@ -0,0 +1,31 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#include "anthropic/admin/services/dreams.h" + +namespace molo::anthropic::admin { + +Json Dreams::archive(const std::string& dream_id) const { + return do_json(Call::kDreamsArchive, {dream_id}, nullptr, nullptr); +} + +Json Dreams::cancel(const std::string& dream_id) const { + return do_json(Call::kDreamsCancel, {dream_id}, nullptr, nullptr); +} + +Json Dreams::create(const Json& body) const { + return do_json(Call::kDreamsCreate, {}, nullptr, &body); +} + +Json Dreams::list(const Query& query) const { + return do_json(Call::kDreamsList, {}, &query, nullptr); +} + +Walk Dreams::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kDreamsList, {}, query, max_pages); +} + +Json Dreams::get(const std::string& dream_id) const { + return do_json(Call::kDreamsRetrieve, {dream_id}, nullptr, nullptr); +} + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/dreams.h b/src/anthropic/admin/services/dreams.h new file mode 100644 index 0000000..67a9b7a --- /dev/null +++ b/src/anthropic/admin/services/dreams.h @@ -0,0 +1,40 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#pragma once + +// dreams calls of the Anthropic API (one class per resource group). Every +// method is one row of calls.cpp; mutating and destructive ones are marked. + +#include +#include + +#include "anthropic/admin/resource.h" + +namespace molo::anthropic::admin { + +// group dreams +class Dreams : public Resource { + public: + explicit Dreams(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kPlatform) {} + + // POST /v1/dreams/{dream_id}/archive DESTRUCTIVE + Json archive(const std::string& dream_id) const; + + // POST /v1/dreams/{dream_id}/cancel DESTRUCTIVE + Json cancel(const std::string& dream_id) const; + + // POST /v1/dreams MUTATES + Json create(const Json& body) const; + + // GET /v1/dreams + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/dreams/{dream_id} + Json get(const std::string& dream_id) const; + +}; + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/environments.cpp b/src/anthropic/admin/services/environments.cpp new file mode 100644 index 0000000..672dbd1 --- /dev/null +++ b/src/anthropic/admin/services/environments.cpp @@ -0,0 +1,71 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#include "anthropic/admin/services/environments.h" + +namespace molo::anthropic::admin { + +Json Environments::archive(const std::string& environment_id) const { + return do_json(Call::kEnvironmentsArchive, {environment_id}, nullptr, nullptr); +} + +Json Environments::create(const Json& body) const { + return do_json(Call::kEnvironmentsCreate, {}, nullptr, &body); +} + +Json Environments::destroy(const std::string& environment_id) const { + return do_json(Call::kEnvironmentsDelete, {environment_id}, nullptr, nullptr); +} + +Json Environments::list(const Query& query) const { + return do_json(Call::kEnvironmentsList, {}, &query, nullptr); +} + +Walk Environments::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kEnvironmentsList, {}, query, max_pages); +} + +Json Environments::get(const std::string& environment_id) const { + return do_json(Call::kEnvironmentsRetrieve, {environment_id}, nullptr, nullptr); +} + +Json Environments::update(const std::string& environment_id, const Json& body) const { + return do_json(Call::kEnvironmentsUpdate, {environment_id}, nullptr, &body); +} + +Json EnvironmentsWork::ack(const std::string& environment_id, const std::string& work_id) const { + return do_json(Call::kEnvironmentsWorkAck, {environment_id, work_id}, nullptr, nullptr); +} + +Json EnvironmentsWork::heartbeat(const std::string& environment_id, const std::string& work_id, const Query& query) const { + return do_json(Call::kEnvironmentsWorkHeartbeat, {environment_id, work_id}, &query, nullptr); +} + +Json EnvironmentsWork::list(const std::string& environment_id, const Query& query) const { + return do_json(Call::kEnvironmentsWorkList, {environment_id}, &query, nullptr); +} + +Walk EnvironmentsWork::list_all(const std::string& environment_id, const Query& query, std::size_t max_pages) const { + return do_walk(Call::kEnvironmentsWorkList, {environment_id}, query, max_pages); +} + +Json EnvironmentsWork::poll(const std::string& environment_id, const Query& query) const { + return do_json(Call::kEnvironmentsWorkPoll, {environment_id}, &query, nullptr); +} + +Json EnvironmentsWork::get(const std::string& environment_id, const std::string& work_id) const { + return do_json(Call::kEnvironmentsWorkRetrieve, {environment_id, work_id}, nullptr, nullptr); +} + +Json EnvironmentsWork::stats(const std::string& environment_id) const { + return do_json(Call::kEnvironmentsWorkStats, {environment_id}, nullptr, nullptr); +} + +Json EnvironmentsWork::stop(const std::string& environment_id, const std::string& work_id, const Json& body) const { + return do_json(Call::kEnvironmentsWorkStop, {environment_id, work_id}, nullptr, &body); +} + +Json EnvironmentsWork::update(const std::string& environment_id, const std::string& work_id, const Json& body) const { + return do_json(Call::kEnvironmentsWorkUpdate, {environment_id, work_id}, nullptr, &body); +} + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/environments.h b/src/anthropic/admin/services/environments.h new file mode 100644 index 0000000..b473025 --- /dev/null +++ b/src/anthropic/admin/services/environments.h @@ -0,0 +1,77 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#pragma once + +// environments calls of the Anthropic API (one class per resource group). Every +// method is one row of calls.cpp; mutating and destructive ones are marked. + +#include +#include + +#include "anthropic/admin/resource.h" + +namespace molo::anthropic::admin { + +// group environments +class Environments : public Resource { + public: + explicit Environments(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kPlatform) {} + + // POST /v1/environments/{environment_id}/archive DESTRUCTIVE + Json archive(const std::string& environment_id) const; + + // POST /v1/environments MUTATES + Json create(const Json& body) const; + + // DELETE /v1/environments/{environment_id} DESTRUCTIVE + Json destroy(const std::string& environment_id) const; + + // GET /v1/environments + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/environments/{environment_id} + Json get(const std::string& environment_id) const; + + // POST /v1/environments/{environment_id} MUTATES + Json update(const std::string& environment_id, const Json& body) const; + +}; + +// group environments.work +class EnvironmentsWork : public Resource { + public: + explicit EnvironmentsWork(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kPlatform) {} + + // POST /v1/environments/{environment_id}/work/{work_id}/ack MUTATES + Json ack(const std::string& environment_id, const std::string& work_id) const; + + // POST /v1/environments/{environment_id}/work/{work_id}/heartbeat MUTATES + Json heartbeat(const std::string& environment_id, const std::string& work_id, const Query& query = Query()) const; + + // GET /v1/environments/{environment_id}/work + Json list(const std::string& environment_id, const Query& query = Query()) const; + + Walk list_all(const std::string& environment_id, const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/environments/{environment_id}/work/poll + Json poll(const std::string& environment_id, const Query& query = Query()) const; + + // GET /v1/environments/{environment_id}/work/{work_id} + Json get(const std::string& environment_id, const std::string& work_id) const; + + // GET /v1/environments/{environment_id}/work/stats + Json stats(const std::string& environment_id) const; + + // POST /v1/environments/{environment_id}/work/{work_id}/stop DESTRUCTIVE + Json stop(const std::string& environment_id, const std::string& work_id, const Json& body) const; + + // POST /v1/environments/{environment_id}/work/{work_id} MUTATES + Json update(const std::string& environment_id, const std::string& work_id, const Json& body) const; + +}; + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/identity.cpp b/src/anthropic/admin/services/identity.cpp new file mode 100644 index 0000000..3517d03 --- /dev/null +++ b/src/anthropic/admin/services/identity.cpp @@ -0,0 +1,111 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#include "anthropic/admin/services/identity.h" + +namespace molo::anthropic::admin { + +Json ApiKeys::list(const Query& query) const { + return do_json(Call::kApiKeysList, {}, &query, nullptr); +} + +Walk ApiKeys::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kApiKeysList, {}, query, max_pages); +} + +Json ApiKeys::get(const std::string& api_key_id) const { + return do_json(Call::kApiKeysRetrieve, {api_key_id}, nullptr, nullptr); +} + +Json ApiKeys::update(const std::string& api_key_id, const Json& body) const { + return do_json(Call::kApiKeysUpdate, {api_key_id}, nullptr, &body); +} + +Json ComplianceSettings::get() const { + return do_json(Call::kComplianceSettingsRetrieve, {}, nullptr, nullptr); +} + +Json ComplianceSettings::update(const Json& body) const { + return do_json(Call::kComplianceSettingsUpdate, {}, nullptr, &body); +} + +Json ExternalKeys::create(const Json& body) const { + return do_json(Call::kExternalKeysCreate, {}, nullptr, &body); +} + +Json ExternalKeys::destroy(const std::string& external_key_id) const { + return do_json(Call::kExternalKeysDelete, {external_key_id}, nullptr, nullptr); +} + +Json ExternalKeys::list(const Query& query) const { + return do_json(Call::kExternalKeysList, {}, &query, nullptr); +} + +Walk ExternalKeys::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kExternalKeysList, {}, query, max_pages); +} + +Json ExternalKeys::get(const std::string& external_key_id) const { + return do_json(Call::kExternalKeysRetrieve, {external_key_id}, nullptr, nullptr); +} + +Json ExternalKeys::update(const std::string& external_key_id, const Json& body) const { + return do_json(Call::kExternalKeysUpdate, {external_key_id}, nullptr, &body); +} + +Json ExternalKeys::validate(const std::string& external_key_id) const { + return do_json(Call::kExternalKeysValidate, {external_key_id}, nullptr, nullptr); +} + +Json Invites::create(const Json& body) const { + return do_json(Call::kInvitesCreate, {}, nullptr, &body); +} + +Json Invites::destroy(const std::string& invite_id) const { + return do_json(Call::kInvitesDelete, {invite_id}, nullptr, nullptr); +} + +Json Invites::list(const Query& query) const { + return do_json(Call::kInvitesList, {}, &query, nullptr); +} + +Walk Invites::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kInvitesList, {}, query, max_pages); +} + +Json Invites::get(const std::string& invite_id) const { + return do_json(Call::kInvitesRetrieve, {invite_id}, nullptr, nullptr); +} + +Json Organization::get() const { + return do_json(Call::kOrganizationRetrieve, {}, nullptr, nullptr); +} + +Json RateLimits::list(const Query& query) const { + return do_json(Call::kRateLimitsList, {}, &query, nullptr); +} + +Walk RateLimits::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kRateLimitsList, {}, query, max_pages); +} + +Json Users::list(const Query& query) const { + return do_json(Call::kUsersList, {}, &query, nullptr); +} + +Walk Users::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kUsersList, {}, query, max_pages); +} + +Json Users::remove(const std::string& user_id) const { + return do_json(Call::kUsersRemove, {user_id}, nullptr, nullptr); +} + +Json Users::get(const std::string& user_id) const { + return do_json(Call::kUsersRetrieve, {user_id}, nullptr, nullptr); +} + +Json Users::update(const std::string& user_id, const Json& body) const { + return do_json(Call::kUsersUpdate, {user_id}, nullptr, &body); +} + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/identity.h b/src/anthropic/admin/services/identity.h new file mode 100644 index 0000000..ff2da9c --- /dev/null +++ b/src/anthropic/admin/services/identity.h @@ -0,0 +1,144 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#pragma once + +// identity calls of the Anthropic API (one class per resource group). Every +// method is one row of calls.cpp; mutating and destructive ones are marked. + +#include +#include + +#include "anthropic/admin/resource.h" + +namespace molo::anthropic::admin { + +// group api_keys +class ApiKeys : public Resource { + public: + explicit ApiKeys(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // GET /v1/organizations/api_keys + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/organizations/api_keys/{api_key_id} + Json get(const std::string& api_key_id) const; + + // POST /v1/organizations/api_keys/{api_key_id} MUTATES + Json update(const std::string& api_key_id, const Json& body) const; + +}; + +// group compliance_settings +class ComplianceSettings : public Resource { + public: + explicit ComplianceSettings(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // GET /v1/organizations/compliance_settings + Json get() const; + + // POST /v1/organizations/compliance_settings MUTATES + Json update(const Json& body) const; + +}; + +// group external_keys +class ExternalKeys : public Resource { + public: + explicit ExternalKeys(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // POST /v1/organizations/external_keys MUTATES + Json create(const Json& body) const; + + // DELETE /v1/organizations/external_keys/{external_key_id} DESTRUCTIVE + Json destroy(const std::string& external_key_id) const; + + // GET /v1/organizations/external_keys + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/organizations/external_keys/{external_key_id} + Json get(const std::string& external_key_id) const; + + // POST /v1/organizations/external_keys/{external_key_id} MUTATES + Json update(const std::string& external_key_id, const Json& body) const; + + // POST /v1/organizations/external_keys/{external_key_id}/validate MUTATES + Json validate(const std::string& external_key_id) const; + +}; + +// group invites +class Invites : public Resource { + public: + explicit Invites(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // POST /v1/organizations/invites MUTATES + Json create(const Json& body) const; + + // DELETE /v1/organizations/invites/{invite_id} DESTRUCTIVE + Json destroy(const std::string& invite_id) const; + + // GET /v1/organizations/invites + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/organizations/invites/{invite_id} + Json get(const std::string& invite_id) const; + +}; + +// group organization +class Organization : public Resource { + public: + explicit Organization(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // GET /v1/organizations/me + Json get() const; + +}; + +// group rate_limits +class RateLimits : public Resource { + public: + explicit RateLimits(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // GET /v1/organizations/rate_limits + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + +}; + +// group users +class Users : public Resource { + public: + explicit Users(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // GET /v1/organizations/users + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // DELETE /v1/organizations/users/{user_id} DESTRUCTIVE + Json remove(const std::string& user_id) const; + + // GET /v1/organizations/users/{user_id} + Json get(const std::string& user_id) const; + + // POST /v1/organizations/users/{user_id} MUTATES + Json update(const std::string& user_id, const Json& body) const; + +}; + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/memory.cpp b/src/anthropic/admin/services/memory.cpp new file mode 100644 index 0000000..21b429a --- /dev/null +++ b/src/anthropic/admin/services/memory.cpp @@ -0,0 +1,75 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#include "anthropic/admin/services/memory.h" + +namespace molo::anthropic::admin { + +Json MemoryStores::archive(const std::string& memory_store_id) const { + return do_json(Call::kMemoryStoresArchive, {memory_store_id}, nullptr, nullptr); +} + +Json MemoryStores::create(const Json& body) const { + return do_json(Call::kMemoryStoresCreate, {}, nullptr, &body); +} + +Json MemoryStores::destroy(const std::string& memory_store_id) const { + return do_json(Call::kMemoryStoresDelete, {memory_store_id}, nullptr, nullptr); +} + +Json MemoryStores::list(const Query& query) const { + return do_json(Call::kMemoryStoresList, {}, &query, nullptr); +} + +Walk MemoryStores::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kMemoryStoresList, {}, query, max_pages); +} + +Json MemoryStores::get(const std::string& memory_store_id) const { + return do_json(Call::kMemoryStoresRetrieve, {memory_store_id}, nullptr, nullptr); +} + +Json MemoryStores::update(const std::string& memory_store_id, const Json& body) const { + return do_json(Call::kMemoryStoresUpdate, {memory_store_id}, nullptr, &body); +} + +Json MemoryStoresMemories::create(const std::string& memory_store_id, const Json& body, const Query& query) const { + return do_json(Call::kMemoryStoresMemoriesCreate, {memory_store_id}, &query, &body); +} + +Json MemoryStoresMemories::destroy(const std::string& memory_store_id, const std::string& memory_id, const Query& query) const { + return do_json(Call::kMemoryStoresMemoriesDelete, {memory_store_id, memory_id}, &query, nullptr); +} + +Json MemoryStoresMemories::list(const std::string& memory_store_id, const Query& query) const { + return do_json(Call::kMemoryStoresMemoriesList, {memory_store_id}, &query, nullptr); +} + +Walk MemoryStoresMemories::list_all(const std::string& memory_store_id, const Query& query, std::size_t max_pages) const { + return do_walk(Call::kMemoryStoresMemoriesList, {memory_store_id}, query, max_pages); +} + +Json MemoryStoresMemories::get(const std::string& memory_store_id, const std::string& memory_id, const Query& query) const { + return do_json(Call::kMemoryStoresMemoriesRetrieve, {memory_store_id, memory_id}, &query, nullptr); +} + +Json MemoryStoresMemories::update(const std::string& memory_store_id, const std::string& memory_id, const Json& body, const Query& query) const { + return do_json(Call::kMemoryStoresMemoriesUpdate, {memory_store_id, memory_id}, &query, &body); +} + +Json MemoryStoresMemoryVersions::list(const std::string& memory_store_id, const Query& query) const { + return do_json(Call::kMemoryStoresMemoryVersionsList, {memory_store_id}, &query, nullptr); +} + +Walk MemoryStoresMemoryVersions::list_all(const std::string& memory_store_id, const Query& query, std::size_t max_pages) const { + return do_walk(Call::kMemoryStoresMemoryVersionsList, {memory_store_id}, query, max_pages); +} + +Json MemoryStoresMemoryVersions::redact(const std::string& memory_store_id, const std::string& memory_version_id) const { + return do_json(Call::kMemoryStoresMemoryVersionsRedact, {memory_store_id, memory_version_id}, nullptr, nullptr); +} + +Json MemoryStoresMemoryVersions::get(const std::string& memory_store_id, const std::string& memory_version_id, const Query& query) const { + return do_json(Call::kMemoryStoresMemoryVersionsRetrieve, {memory_store_id, memory_version_id}, &query, nullptr); +} + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/memory.h b/src/anthropic/admin/services/memory.h new file mode 100644 index 0000000..a57f793 --- /dev/null +++ b/src/anthropic/admin/services/memory.h @@ -0,0 +1,87 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#pragma once + +// memory calls of the Anthropic API (one class per resource group). Every +// method is one row of calls.cpp; mutating and destructive ones are marked. + +#include +#include + +#include "anthropic/admin/resource.h" + +namespace molo::anthropic::admin { + +// group memory_stores +class MemoryStores : public Resource { + public: + explicit MemoryStores(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kPlatform) {} + + // POST /v1/memory_stores/{memory_store_id}/archive DESTRUCTIVE + Json archive(const std::string& memory_store_id) const; + + // POST /v1/memory_stores MUTATES + Json create(const Json& body) const; + + // DELETE /v1/memory_stores/{memory_store_id} DESTRUCTIVE + Json destroy(const std::string& memory_store_id) const; + + // GET /v1/memory_stores + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/memory_stores/{memory_store_id} + Json get(const std::string& memory_store_id) const; + + // POST /v1/memory_stores/{memory_store_id} MUTATES + Json update(const std::string& memory_store_id, const Json& body) const; + +}; + +// group memory_stores.memories +class MemoryStoresMemories : public Resource { + public: + explicit MemoryStoresMemories(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kPlatform) {} + + // POST /v1/memory_stores/{memory_store_id}/memories MUTATES + Json create(const std::string& memory_store_id, const Json& body, const Query& query = Query()) const; + + // DELETE /v1/memory_stores/{memory_store_id}/memories/{memory_id} DESTRUCTIVE + Json destroy(const std::string& memory_store_id, const std::string& memory_id, const Query& query = Query()) const; + + // GET /v1/memory_stores/{memory_store_id}/memories + Json list(const std::string& memory_store_id, const Query& query = Query()) const; + + Walk list_all(const std::string& memory_store_id, const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/memory_stores/{memory_store_id}/memories/{memory_id} + Json get(const std::string& memory_store_id, const std::string& memory_id, const Query& query = Query()) const; + + // POST /v1/memory_stores/{memory_store_id}/memories/{memory_id} MUTATES + Json update(const std::string& memory_store_id, const std::string& memory_id, const Json& body, const Query& query = Query()) const; + +}; + +// group memory_stores.memory_versions +class MemoryStoresMemoryVersions : public Resource { + public: + explicit MemoryStoresMemoryVersions(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kPlatform) {} + + // GET /v1/memory_stores/{memory_store_id}/memory_versions + Json list(const std::string& memory_store_id, const Query& query = Query()) const; + + Walk list_all(const std::string& memory_store_id, const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // POST /v1/memory_stores/{memory_store_id}/memory_versions/{memory_version_id}/redact DESTRUCTIVE + Json redact(const std::string& memory_store_id, const std::string& memory_version_id) const; + + // GET /v1/memory_stores/{memory_store_id}/memory_versions/{memory_version_id} + Json get(const std::string& memory_store_id, const std::string& memory_version_id, const Query& query = Query()) const; + +}; + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/plugins.cpp b/src/anthropic/admin/services/plugins.cpp new file mode 100644 index 0000000..d556911 --- /dev/null +++ b/src/anthropic/admin/services/plugins.cpp @@ -0,0 +1,99 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#include "anthropic/admin/services/plugins.h" + +namespace molo::anthropic::admin { + +Json PluginMarketplaces::list(const Query& query) const { + return do_json(Call::kPluginMarketplacesList, {}, &query, nullptr); +} + +Walk PluginMarketplaces::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kPluginMarketplacesList, {}, query, max_pages); +} + +Json PluginMarketplaces::get(const std::string& marketplace_id, const Query& query) const { + return do_json(Call::kPluginMarketplacesRetrieve, {marketplace_id}, &query, nullptr); +} + +Json PluginMarketplaces::update(const std::string& marketplace_id, const Json& body) const { + return do_json(Call::kPluginMarketplacesUpdate, {marketplace_id}, nullptr, &body); +} + +Json PluginMarketplaces::validate_archive(const clients::body::MultipartBody& form) const { + return do_form(Call::kPluginMarketplacesValidateArchive, {}, form); +} + +Json PluginMarketplaces::validate_repository(const Json& body) const { + return do_json(Call::kPluginMarketplacesValidateRepository, {}, nullptr, &body); +} + +Json Plugins::create(const clients::body::MultipartBody& form) const { + return do_form(Call::kPluginsCreate, {}, form); +} + +Json Plugins::destroy(const std::string& plugin_id) const { + return do_json(Call::kPluginsDelete, {plugin_id}, nullptr, nullptr); +} + +Json Plugins::list(const Query& query) const { + return do_json(Call::kPluginsList, {}, &query, nullptr); +} + +Walk Plugins::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kPluginsList, {}, query, max_pages); +} + +Json Plugins::get(const std::string& plugin_id, const Query& query) const { + return do_json(Call::kPluginsRetrieve, {plugin_id}, &query, nullptr); +} + +Json Plugins::update(const std::string& plugin_id, const Json& body) const { + return do_json(Call::kPluginsUpdate, {plugin_id}, nullptr, &body); +} + +Json PluginsInstallationSettings::list(const std::string& plugin_id, const Query& query) const { + return do_json(Call::kPluginsInstallationSettingsList, {plugin_id}, &query, nullptr); +} + +Walk PluginsInstallationSettings::list_all(const std::string& plugin_id, const Query& query, std::size_t max_pages) const { + return do_walk(Call::kPluginsInstallationSettingsList, {plugin_id}, query, max_pages); +} + +Json PluginsInstallationSettings::remove(const std::string& plugin_id, const std::string& target) const { + return do_json(Call::kPluginsInstallationSettingsRemove, {plugin_id, target}, nullptr, nullptr); +} + +Json PluginsInstallationSettings::set_limit(const std::string& plugin_id, const std::string& target, const Json& body) const { + return do_json(Call::kPluginsInstallationSettingsSet, {plugin_id, target}, nullptr, &body); +} + +Json PluginsShares::list(const std::string& plugin_id, const Query& query) const { + return do_json(Call::kPluginsSharesList, {plugin_id}, &query, nullptr); +} + +Walk PluginsShares::list_all(const std::string& plugin_id, const Query& query, std::size_t max_pages) const { + return do_walk(Call::kPluginsSharesList, {plugin_id}, query, max_pages); +} + +Json PluginsVersions::create(const std::string& plugin_id, const clients::body::MultipartBody& form) const { + return do_form(Call::kPluginsVersionsCreate, {plugin_id}, form); +} + +llm::RawResponse PluginsVersions::download(const std::string& plugin_id, const std::string& version, const Query& query) const { + return do_raw(Call::kPluginsVersionsDownload, {plugin_id, version}, &query); +} + +Json PluginsVersions::list(const std::string& plugin_id, const Query& query) const { + return do_json(Call::kPluginsVersionsList, {plugin_id}, &query, nullptr); +} + +Walk PluginsVersions::list_all(const std::string& plugin_id, const Query& query, std::size_t max_pages) const { + return do_walk(Call::kPluginsVersionsList, {plugin_id}, query, max_pages); +} + +Json PluginsVersions::get(const std::string& plugin_id, const std::string& version, const Query& query) const { + return do_json(Call::kPluginsVersionsRetrieve, {plugin_id, version}, &query, nullptr); +} + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/plugins.h b/src/anthropic/admin/services/plugins.h new file mode 100644 index 0000000..aa3d710 --- /dev/null +++ b/src/anthropic/admin/services/plugins.h @@ -0,0 +1,119 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#pragma once + +// plugins calls of the Anthropic API (one class per resource group). Every +// method is one row of calls.cpp; mutating and destructive ones are marked. + +#include +#include + +#include "anthropic/admin/resource.h" + +namespace molo::anthropic::admin { + +// group plugin_marketplaces +class PluginMarketplaces : public Resource { + public: + explicit PluginMarketplaces(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // GET /v1/organizations/plugin_marketplaces + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/organizations/plugin_marketplaces/{marketplace_id} + Json get(const std::string& marketplace_id, const Query& query = Query()) const; + + // POST /v1/organizations/plugin_marketplaces/{marketplace_id} MUTATES + Json update(const std::string& marketplace_id, const Json& body) const; + + // POST /v1/organizations/plugin_marketplaces/validate_archive MUTATES + Json validate_archive(const clients::body::MultipartBody& form) const; + + // POST /v1/organizations/plugin_marketplaces/validate_repository MUTATES + Json validate_repository(const Json& body) const; + +}; + +// group plugins +class Plugins : public Resource { + public: + explicit Plugins(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // POST /v1/organizations/plugins MUTATES + Json create(const clients::body::MultipartBody& form) const; + + // DELETE /v1/organizations/plugins/{plugin_id} DESTRUCTIVE + Json destroy(const std::string& plugin_id) const; + + // GET /v1/organizations/plugins + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/organizations/plugins/{plugin_id} + Json get(const std::string& plugin_id, const Query& query = Query()) const; + + // POST /v1/organizations/plugins/{plugin_id} MUTATES + Json update(const std::string& plugin_id, const Json& body) const; + +}; + +// group plugins.installation_settings +class PluginsInstallationSettings : public Resource { + public: + explicit PluginsInstallationSettings(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // GET /v1/organizations/plugins/{plugin_id}/installation_settings + Json list(const std::string& plugin_id, const Query& query = Query()) const; + + Walk list_all(const std::string& plugin_id, const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // DELETE /v1/organizations/plugins/{plugin_id}/installation_settings/{target} DESTRUCTIVE + Json remove(const std::string& plugin_id, const std::string& target) const; + + // POST /v1/organizations/plugins/{plugin_id}/installation_settings/{target} MUTATES + Json set_limit(const std::string& plugin_id, const std::string& target, const Json& body) const; + +}; + +// group plugins.shares +class PluginsShares : public Resource { + public: + explicit PluginsShares(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // GET /v1/organizations/plugins/{plugin_id}/shares + Json list(const std::string& plugin_id, const Query& query = Query()) const; + + Walk list_all(const std::string& plugin_id, const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + +}; + +// group plugins.versions +class PluginsVersions : public Resource { + public: + explicit PluginsVersions(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // POST /v1/organizations/plugins/{plugin_id}/versions MUTATES + Json create(const std::string& plugin_id, const clients::body::MultipartBody& form) const; + + // GET /v1/organizations/plugins/{plugin_id}/versions/{version}/content + llm::RawResponse download(const std::string& plugin_id, const std::string& version, const Query& query = Query()) const; + + // GET /v1/organizations/plugins/{plugin_id}/versions + Json list(const std::string& plugin_id, const Query& query = Query()) const; + + Walk list_all(const std::string& plugin_id, const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/organizations/plugins/{plugin_id}/versions/{version} + Json get(const std::string& plugin_id, const std::string& version, const Query& query = Query()) const; + +}; + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/reports.cpp b/src/anthropic/admin/services/reports.cpp new file mode 100644 index 0000000..a465fb3 --- /dev/null +++ b/src/anthropic/admin/services/reports.cpp @@ -0,0 +1,31 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#include "anthropic/admin/services/reports.h" + +namespace molo::anthropic::admin { + +Json CostReports::get(const Query& query) const { + return do_json(Call::kCostReportRetrieve, {}, &query, nullptr); +} + +Walk CostReports::get_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kCostReportRetrieve, {}, query, max_pages); +} + +Json UsageReports::claude_code(const Query& query) const { + return do_json(Call::kUsageReportRetrieveClaudeCode, {}, &query, nullptr); +} + +Walk UsageReports::claude_code_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kUsageReportRetrieveClaudeCode, {}, query, max_pages); +} + +Json UsageReports::messages(const Query& query) const { + return do_json(Call::kUsageReportRetrieveMessages, {}, &query, nullptr); +} + +Walk UsageReports::messages_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kUsageReportRetrieveMessages, {}, query, max_pages); +} + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/reports.h b/src/anthropic/admin/services/reports.h new file mode 100644 index 0000000..29559c8 --- /dev/null +++ b/src/anthropic/admin/services/reports.h @@ -0,0 +1,46 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#pragma once + +// reports calls of the Anthropic API (one class per resource group). Every +// method is one row of calls.cpp; mutating and destructive ones are marked. + +#include +#include + +#include "anthropic/admin/resource.h" + +namespace molo::anthropic::admin { + +// group cost_report +class CostReports : public Resource { + public: + explicit CostReports(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // GET /v1/organizations/cost_report + Json get(const Query& query) const; + + Walk get_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + +}; + +// group usage_report +class UsageReports : public Resource { + public: + explicit UsageReports(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // GET /v1/organizations/usage_report/claude_code + Json claude_code(const Query& query) const; + + Walk claude_code_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/organizations/usage_report/messages + Json messages(const Query& query) const; + + Walk messages_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + +}; + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/sessions.cpp b/src/anthropic/admin/services/sessions.cpp new file mode 100644 index 0000000..7dc26a7 --- /dev/null +++ b/src/anthropic/admin/services/sessions.cpp @@ -0,0 +1,103 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#include "anthropic/admin/services/sessions.h" + +namespace molo::anthropic::admin { + +Json Sessions::archive(const std::string& session_id) const { + return do_json(Call::kSessionsArchive, {session_id}, nullptr, nullptr); +} + +Json Sessions::create(const Json& body) const { + return do_json(Call::kSessionsCreate, {}, nullptr, &body); +} + +Json Sessions::destroy(const std::string& session_id) const { + return do_json(Call::kSessionsDelete, {session_id}, nullptr, nullptr); +} + +Json Sessions::list(const Query& query) const { + return do_json(Call::kSessionsList, {}, &query, nullptr); +} + +Walk Sessions::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kSessionsList, {}, query, max_pages); +} + +Json Sessions::get(const std::string& session_id) const { + return do_json(Call::kSessionsRetrieve, {session_id}, nullptr, nullptr); +} + +Json Sessions::update(const std::string& session_id, const Json& body) const { + return do_json(Call::kSessionsUpdate, {session_id}, nullptr, &body); +} + +Json SessionsEvents::list(const std::string& session_id, const Query& query) const { + return do_json(Call::kSessionsEventsList, {session_id}, &query, nullptr); +} + +Walk SessionsEvents::list_all(const std::string& session_id, const Query& query, std::size_t max_pages) const { + return do_walk(Call::kSessionsEventsList, {session_id}, query, max_pages); +} + +Json SessionsEvents::send(const std::string& session_id, const Json& body) const { + return do_json(Call::kSessionsEventsSend, {session_id}, nullptr, &body); +} + +void SessionsEvents::stream(const std::string& session_id, const EventSink& sink, const Query& query) const { + do_stream(Call::kSessionsEventsStream, {session_id}, &query, sink); +} + +Json SessionsResources::add(const std::string& session_id, const Json& body) const { + return do_json(Call::kSessionsResourcesAdd, {session_id}, nullptr, &body); +} + +Json SessionsResources::destroy(const std::string& session_id, const std::string& resource_id) const { + return do_json(Call::kSessionsResourcesDelete, {session_id, resource_id}, nullptr, nullptr); +} + +Json SessionsResources::list(const std::string& session_id, const Query& query) const { + return do_json(Call::kSessionsResourcesList, {session_id}, &query, nullptr); +} + +Walk SessionsResources::list_all(const std::string& session_id, const Query& query, std::size_t max_pages) const { + return do_walk(Call::kSessionsResourcesList, {session_id}, query, max_pages); +} + +Json SessionsResources::get(const std::string& session_id, const std::string& resource_id) const { + return do_json(Call::kSessionsResourcesRetrieve, {session_id, resource_id}, nullptr, nullptr); +} + +Json SessionsResources::update(const std::string& session_id, const std::string& resource_id, const Json& body) const { + return do_json(Call::kSessionsResourcesUpdate, {session_id, resource_id}, nullptr, &body); +} + +Json SessionsThreads::archive(const std::string& session_id, const std::string& thread_id) const { + return do_json(Call::kSessionsThreadsArchive, {session_id, thread_id}, nullptr, nullptr); +} + +Json SessionsThreads::list(const std::string& session_id, const Query& query) const { + return do_json(Call::kSessionsThreadsList, {session_id}, &query, nullptr); +} + +Walk SessionsThreads::list_all(const std::string& session_id, const Query& query, std::size_t max_pages) const { + return do_walk(Call::kSessionsThreadsList, {session_id}, query, max_pages); +} + +Json SessionsThreads::get(const std::string& session_id, const std::string& thread_id) const { + return do_json(Call::kSessionsThreadsRetrieve, {session_id, thread_id}, nullptr, nullptr); +} + +Json SessionsThreadsEvents::list(const std::string& session_id, const std::string& thread_id, const Query& query) const { + return do_json(Call::kSessionsThreadsEventsList, {session_id, thread_id}, &query, nullptr); +} + +Walk SessionsThreadsEvents::list_all(const std::string& session_id, const std::string& thread_id, const Query& query, std::size_t max_pages) const { + return do_walk(Call::kSessionsThreadsEventsList, {session_id, thread_id}, query, max_pages); +} + +void SessionsThreadsEvents::stream(const std::string& session_id, const std::string& thread_id, const EventSink& sink, const Query& query) const { + do_stream(Call::kSessionsThreadsEventsStream, {session_id, thread_id}, &query, sink); +} + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/sessions.h b/src/anthropic/admin/services/sessions.h new file mode 100644 index 0000000..5717678 --- /dev/null +++ b/src/anthropic/admin/services/sessions.h @@ -0,0 +1,122 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#pragma once + +// sessions calls of the Anthropic API (one class per resource group). Every +// method is one row of calls.cpp; mutating and destructive ones are marked. + +#include +#include + +#include "anthropic/admin/resource.h" + +namespace molo::anthropic::admin { + +// group sessions +class Sessions : public Resource { + public: + explicit Sessions(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kPlatform) {} + + // POST /v1/sessions/{session_id}/archive DESTRUCTIVE + Json archive(const std::string& session_id) const; + + // POST /v1/sessions MUTATES + Json create(const Json& body) const; + + // DELETE /v1/sessions/{session_id} DESTRUCTIVE + Json destroy(const std::string& session_id) const; + + // GET /v1/sessions + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/sessions/{session_id} + Json get(const std::string& session_id) const; + + // POST /v1/sessions/{session_id} MUTATES + Json update(const std::string& session_id, const Json& body) const; + +}; + +// group sessions.events +class SessionsEvents : public Resource { + public: + explicit SessionsEvents(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kPlatform) {} + + // GET /v1/sessions/{session_id}/events + Json list(const std::string& session_id, const Query& query = Query()) const; + + Walk list_all(const std::string& session_id, const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // POST /v1/sessions/{session_id}/events MUTATES + Json send(const std::string& session_id, const Json& body) const; + + // GET /v1/sessions/{session_id}/events/stream + void stream(const std::string& session_id, const EventSink& sink, const Query& query = Query()) const; + +}; + +// group sessions.resources +class SessionsResources : public Resource { + public: + explicit SessionsResources(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kPlatform) {} + + // POST /v1/sessions/{session_id}/resources MUTATES + Json add(const std::string& session_id, const Json& body) const; + + // DELETE /v1/sessions/{session_id}/resources/{resource_id} DESTRUCTIVE + Json destroy(const std::string& session_id, const std::string& resource_id) const; + + // GET /v1/sessions/{session_id}/resources + Json list(const std::string& session_id, const Query& query = Query()) const; + + Walk list_all(const std::string& session_id, const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/sessions/{session_id}/resources/{resource_id} + Json get(const std::string& session_id, const std::string& resource_id) const; + + // POST /v1/sessions/{session_id}/resources/{resource_id} MUTATES + Json update(const std::string& session_id, const std::string& resource_id, const Json& body) const; + +}; + +// group sessions.threads +class SessionsThreads : public Resource { + public: + explicit SessionsThreads(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kPlatform) {} + + // POST /v1/sessions/{session_id}/threads/{thread_id}/archive DESTRUCTIVE + Json archive(const std::string& session_id, const std::string& thread_id) const; + + // GET /v1/sessions/{session_id}/threads + Json list(const std::string& session_id, const Query& query = Query()) const; + + Walk list_all(const std::string& session_id, const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/sessions/{session_id}/threads/{thread_id} + Json get(const std::string& session_id, const std::string& thread_id) const; + +}; + +// group sessions.threads.events +class SessionsThreadsEvents : public Resource { + public: + explicit SessionsThreadsEvents(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kPlatform) {} + + // GET /v1/sessions/{session_id}/threads/{thread_id}/events + Json list(const std::string& session_id, const std::string& thread_id, const Query& query = Query()) const; + + Walk list_all(const std::string& session_id, const std::string& thread_id, const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/sessions/{session_id}/threads/{thread_id}/stream + void stream(const std::string& session_id, const std::string& thread_id, const EventSink& sink, const Query& query = Query()) const; + +}; + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/spend_limits.cpp b/src/anthropic/admin/services/spend_limits.cpp new file mode 100644 index 0000000..ac63aa6 --- /dev/null +++ b/src/anthropic/admin/services/spend_limits.cpp @@ -0,0 +1,55 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#include "anthropic/admin/services/spend_limits.h" + +namespace molo::anthropic::admin { + +Json SpendLimits::destroy(const std::string& spend_limit_id) const { + return do_json(Call::kSpendLimitsDelete, {spend_limit_id}, nullptr, nullptr); +} + +Json SpendLimits::list(const Query& query) const { + return do_json(Call::kSpendLimitsList, {}, &query, nullptr); +} + +Walk SpendLimits::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kSpendLimitsList, {}, query, max_pages); +} + +Json SpendLimits::get(const std::string& spend_limit_id) const { + return do_json(Call::kSpendLimitsRetrieve, {spend_limit_id}, nullptr, nullptr); +} + +Json SpendLimits::set_limit(const Json& body) const { + return do_json(Call::kSpendLimitsSet, {}, nullptr, &body); +} + +Json SpendLimitsEffective::list(const Query& query) const { + return do_json(Call::kSpendLimitsEffectiveList, {}, &query, nullptr); +} + +Walk SpendLimitsEffective::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kSpendLimitsEffectiveList, {}, query, max_pages); +} + +Json SpendLimitsIncreaseRequests::approve(const std::string& spend_limit_increase_request_id, const Json& body) const { + return do_json(Call::kSpendLimitsIncreaseRequestsApprove, {spend_limit_increase_request_id}, nullptr, &body); +} + +Json SpendLimitsIncreaseRequests::deny(const std::string& spend_limit_increase_request_id, const Json& body) const { + return do_json(Call::kSpendLimitsIncreaseRequestsDeny, {spend_limit_increase_request_id}, nullptr, &body); +} + +Json SpendLimitsIncreaseRequests::list(const Query& query) const { + return do_json(Call::kSpendLimitsIncreaseRequestsList, {}, &query, nullptr); +} + +Walk SpendLimitsIncreaseRequests::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kSpendLimitsIncreaseRequestsList, {}, query, max_pages); +} + +Json SpendLimitsIncreaseRequests::get(const std::string& spend_limit_increase_request_id) const { + return do_json(Call::kSpendLimitsIncreaseRequestsRetrieve, {spend_limit_increase_request_id}, nullptr, nullptr); +} + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/spend_limits.h b/src/anthropic/admin/services/spend_limits.h new file mode 100644 index 0000000..5ad3b6e --- /dev/null +++ b/src/anthropic/admin/services/spend_limits.h @@ -0,0 +1,72 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#pragma once + +// spend_limits calls of the Anthropic API (one class per resource group). Every +// method is one row of calls.cpp; mutating and destructive ones are marked. + +#include +#include + +#include "anthropic/admin/resource.h" + +namespace molo::anthropic::admin { + +// group spend_limits +class SpendLimits : public Resource { + public: + explicit SpendLimits(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // DELETE /v1/organizations/spend_limits/{spend_limit_id} DESTRUCTIVE + Json destroy(const std::string& spend_limit_id) const; + + // GET /v1/organizations/spend_limits + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/organizations/spend_limits/{spend_limit_id} + Json get(const std::string& spend_limit_id) const; + + // POST /v1/organizations/spend_limits MUTATES + Json set_limit(const Json& body) const; + +}; + +// group spend_limits.effective +class SpendLimitsEffective : public Resource { + public: + explicit SpendLimitsEffective(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // GET /v1/organizations/spend_limits/effective + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + +}; + +// group spend_limits.increase_requests +class SpendLimitsIncreaseRequests : public Resource { + public: + explicit SpendLimitsIncreaseRequests(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // POST /v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id}/approve DESTRUCTIVE + Json approve(const std::string& spend_limit_increase_request_id, const Json& body) const; + + // POST /v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id}/deny DESTRUCTIVE + Json deny(const std::string& spend_limit_increase_request_id, const Json& body) const; + + // GET /v1/organizations/spend_limit_increase_requests + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id} + Json get(const std::string& spend_limit_increase_request_id) const; + +}; + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/telemetry.cpp b/src/anthropic/admin/services/telemetry.cpp new file mode 100644 index 0000000..2cd0edd --- /dev/null +++ b/src/anthropic/admin/services/telemetry.cpp @@ -0,0 +1,79 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#include "anthropic/admin/services/telemetry.h" + +namespace molo::anthropic::admin { + +Json TelemetryDestinations::create(const Json& body) const { + return do_json(Call::kTelemetryDestinationsCreate, {}, nullptr, &body); +} + +Json TelemetryDestinations::destroy(const std::string& destination_id) const { + return do_json(Call::kTelemetryDestinationsDelete, {destination_id}, nullptr, nullptr); +} + +Json TelemetryDestinations::list(const Query& query) const { + return do_json(Call::kTelemetryDestinationsList, {}, &query, nullptr); +} + +Walk TelemetryDestinations::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kTelemetryDestinationsList, {}, query, max_pages); +} + +Json TelemetryDestinations::get(const std::string& destination_id) const { + return do_json(Call::kTelemetryDestinationsRetrieve, {destination_id}, nullptr, nullptr); +} + +Json TelemetryDestinations::test(const std::string& destination_id) const { + return do_json(Call::kTelemetryDestinationsTest, {destination_id}, nullptr, nullptr); +} + +Json TelemetryDestinations::update(const std::string& destination_id, const Json& body) const { + return do_json(Call::kTelemetryDestinationsUpdate, {destination_id}, nullptr, &body); +} + +Json TelemetryDestinationsWorkspaces::add(const std::string& destination_id, const std::string& workspace_id) const { + return do_json(Call::kTelemetryDestinationsWorkspacesAdd, {destination_id, workspace_id}, nullptr, nullptr); +} + +Json TelemetryDestinationsWorkspaces::list(const std::string& destination_id, const Query& query) const { + return do_json(Call::kTelemetryDestinationsWorkspacesList, {destination_id}, &query, nullptr); +} + +Walk TelemetryDestinationsWorkspaces::list_all(const std::string& destination_id, const Query& query, std::size_t max_pages) const { + return do_walk(Call::kTelemetryDestinationsWorkspacesList, {destination_id}, query, max_pages); +} + +Json TelemetryDestinationsWorkspaces::remove(const std::string& destination_id, const std::string& workspace_id) const { + return do_json(Call::kTelemetryDestinationsWorkspacesRemove, {destination_id, workspace_id}, nullptr, nullptr); +} + +Json Webhooks::create(const Json& body) const { + return do_json(Call::kWebhooksCreate, {}, nullptr, &body); +} + +Json Webhooks::destroy(const std::string& webhook_endpoint_id) const { + return do_json(Call::kWebhooksDelete, {webhook_endpoint_id}, nullptr, nullptr); +} + +Json Webhooks::list(const Query& query) const { + return do_json(Call::kWebhooksList, {}, &query, nullptr); +} + +Walk Webhooks::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kWebhooksList, {}, query, max_pages); +} + +Json Webhooks::regenerate_signing_secret(const std::string& webhook_endpoint_id) const { + return do_json(Call::kWebhooksRegenerateSigningSecret, {webhook_endpoint_id}, nullptr, nullptr); +} + +Json Webhooks::get(const std::string& webhook_endpoint_id) const { + return do_json(Call::kWebhooksRetrieve, {webhook_endpoint_id}, nullptr, nullptr); +} + +Json Webhooks::update(const std::string& webhook_endpoint_id, const Json& body) const { + return do_json(Call::kWebhooksUpdate, {webhook_endpoint_id}, nullptr, &body); +} + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/telemetry.h b/src/anthropic/admin/services/telemetry.h new file mode 100644 index 0000000..e5a0152 --- /dev/null +++ b/src/anthropic/admin/services/telemetry.h @@ -0,0 +1,90 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#pragma once + +// telemetry calls of the Anthropic API (one class per resource group). Every +// method is one row of calls.cpp; mutating and destructive ones are marked. + +#include +#include + +#include "anthropic/admin/resource.h" + +namespace molo::anthropic::admin { + +// group telemetry_destinations +class TelemetryDestinations : public Resource { + public: + explicit TelemetryDestinations(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // POST /v1/organizations/telemetry_destinations MUTATES + Json create(const Json& body) const; + + // DELETE /v1/organizations/telemetry_destinations/{destination_id} DESTRUCTIVE + Json destroy(const std::string& destination_id) const; + + // GET /v1/organizations/telemetry_destinations + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/organizations/telemetry_destinations/{destination_id} + Json get(const std::string& destination_id) const; + + // POST /v1/organizations/telemetry_destinations/{destination_id}/test MUTATES + Json test(const std::string& destination_id) const; + + // POST /v1/organizations/telemetry_destinations/{destination_id} MUTATES + Json update(const std::string& destination_id, const Json& body) const; + +}; + +// group telemetry_destinations.workspaces +class TelemetryDestinationsWorkspaces : public Resource { + public: + explicit TelemetryDestinationsWorkspaces(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // POST /v1/organizations/telemetry_destinations/{destination_id}/workspaces/{workspace_id} MUTATES + Json add(const std::string& destination_id, const std::string& workspace_id) const; + + // GET /v1/organizations/telemetry_destinations/{destination_id}/workspaces + Json list(const std::string& destination_id, const Query& query = Query()) const; + + Walk list_all(const std::string& destination_id, const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // DELETE /v1/organizations/telemetry_destinations/{destination_id}/workspaces/{workspace_id} DESTRUCTIVE + Json remove(const std::string& destination_id, const std::string& workspace_id) const; + +}; + +// group webhooks +class Webhooks : public Resource { + public: + explicit Webhooks(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // POST /v1/organizations/webhooks MUTATES + Json create(const Json& body) const; + + // DELETE /v1/organizations/webhooks/{webhook_endpoint_id} DESTRUCTIVE + Json destroy(const std::string& webhook_endpoint_id) const; + + // GET /v1/organizations/webhooks + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // POST /v1/organizations/webhooks/{webhook_endpoint_id}/regenerate_signing_secret DESTRUCTIVE + Json regenerate_signing_secret(const std::string& webhook_endpoint_id) const; + + // GET /v1/organizations/webhooks/{webhook_endpoint_id} + Json get(const std::string& webhook_endpoint_id) const; + + // POST /v1/organizations/webhooks/{webhook_endpoint_id} MUTATES + Json update(const std::string& webhook_endpoint_id, const Json& body) const; + +}; + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/tunnels.cpp b/src/anthropic/admin/services/tunnels.cpp new file mode 100644 index 0000000..38af97d --- /dev/null +++ b/src/anthropic/admin/services/tunnels.cpp @@ -0,0 +1,99 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#include "anthropic/admin/services/tunnels.h" + +namespace molo::anthropic::admin { + +Json McpTunnels::archive(const std::string& tunnel_id) const { + return do_json(Call::kMcpTunnelsArchive, {tunnel_id}, nullptr, nullptr); +} + +Json McpTunnels::list(const Query& query) const { + return do_json(Call::kMcpTunnelsList, {}, &query, nullptr); +} + +Walk McpTunnels::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kMcpTunnelsList, {}, query, max_pages); +} + +Json McpTunnels::get(const std::string& tunnel_id) const { + return do_json(Call::kMcpTunnelsRetrieve, {tunnel_id}, nullptr, nullptr); +} + +Json McpTunnels::reveal_token(const std::string& tunnel_id) const { + return do_json(Call::kMcpTunnelsRevealToken, {tunnel_id}, nullptr, nullptr); +} + +Json McpTunnels::rotate_token(const std::string& tunnel_id, const Json& body) const { + return do_json(Call::kMcpTunnelsRotateToken, {tunnel_id}, nullptr, &body); +} + +Json McpTunnelCertificates::archive(const std::string& tunnel_id, const std::string& certificate_id) const { + return do_json(Call::kMcpTunnelsCertificatesArchive, {tunnel_id, certificate_id}, nullptr, nullptr); +} + +Json McpTunnelCertificates::create(const std::string& tunnel_id, const Json& body) const { + return do_json(Call::kMcpTunnelsCertificatesCreate, {tunnel_id}, nullptr, &body); +} + +Json McpTunnelCertificates::list(const std::string& tunnel_id, const Query& query) const { + return do_json(Call::kMcpTunnelsCertificatesList, {tunnel_id}, &query, nullptr); +} + +Walk McpTunnelCertificates::list_all(const std::string& tunnel_id, const Query& query, std::size_t max_pages) const { + return do_walk(Call::kMcpTunnelsCertificatesList, {tunnel_id}, query, max_pages); +} + +Json McpTunnelCertificates::get(const std::string& tunnel_id, const std::string& certificate_id) const { + return do_json(Call::kMcpTunnelsCertificatesRetrieve, {tunnel_id, certificate_id}, nullptr, nullptr); +} + +Json Tunnels::archive(const std::string& tunnel_id) const { + return do_json(Call::kTunnelsArchive, {tunnel_id}, nullptr, nullptr); +} + +Json Tunnels::create(const Json& body) const { + return do_json(Call::kTunnelsCreate, {}, nullptr, &body); +} + +Json Tunnels::list(const Query& query) const { + return do_json(Call::kTunnelsList, {}, &query, nullptr); +} + +Walk Tunnels::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kTunnelsList, {}, query, max_pages); +} + +Json Tunnels::get(const std::string& tunnel_id) const { + return do_json(Call::kTunnelsRetrieve, {tunnel_id}, nullptr, nullptr); +} + +Json Tunnels::reveal_token(const std::string& tunnel_id) const { + return do_json(Call::kTunnelsRevealToken, {tunnel_id}, nullptr, nullptr); +} + +Json Tunnels::rotate_token(const std::string& tunnel_id, const Json& body) const { + return do_json(Call::kTunnelsRotateToken, {tunnel_id}, nullptr, &body); +} + +Json TunnelsCertificates::archive(const std::string& tunnel_id, const std::string& certificate_id) const { + return do_json(Call::kTunnelsCertificatesArchive, {tunnel_id, certificate_id}, nullptr, nullptr); +} + +Json TunnelsCertificates::create(const std::string& tunnel_id, const Json& body) const { + return do_json(Call::kTunnelsCertificatesCreate, {tunnel_id}, nullptr, &body); +} + +Json TunnelsCertificates::list(const std::string& tunnel_id, const Query& query) const { + return do_json(Call::kTunnelsCertificatesList, {tunnel_id}, &query, nullptr); +} + +Walk TunnelsCertificates::list_all(const std::string& tunnel_id, const Query& query, std::size_t max_pages) const { + return do_walk(Call::kTunnelsCertificatesList, {tunnel_id}, query, max_pages); +} + +Json TunnelsCertificates::get(const std::string& tunnel_id, const std::string& certificate_id) const { + return do_json(Call::kTunnelsCertificatesRetrieve, {tunnel_id, certificate_id}, nullptr, nullptr); +} + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/tunnels.h b/src/anthropic/admin/services/tunnels.h new file mode 100644 index 0000000..e013b1a --- /dev/null +++ b/src/anthropic/admin/services/tunnels.h @@ -0,0 +1,112 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#pragma once + +// tunnels calls of the Anthropic API (one class per resource group). Every +// method is one row of calls.cpp; mutating and destructive ones are marked. + +#include +#include + +#include "anthropic/admin/resource.h" + +namespace molo::anthropic::admin { + +// group mcp_tunnels +class McpTunnels : public Resource { + public: + explicit McpTunnels(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // POST /v1/organizations/tunnels/{tunnel_id}/archive DESTRUCTIVE + Json archive(const std::string& tunnel_id) const; + + // GET /v1/organizations/tunnels + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/organizations/tunnels/{tunnel_id} + Json get(const std::string& tunnel_id) const; + + // POST /v1/organizations/tunnels/{tunnel_id}/reveal_token RETURNS A SECRET + Json reveal_token(const std::string& tunnel_id) const; + + // POST /v1/organizations/tunnels/{tunnel_id}/rotate_token DESTRUCTIVE + Json rotate_token(const std::string& tunnel_id, const Json& body) const; + +}; + +// group mcp_tunnels.certificates +class McpTunnelCertificates : public Resource { + public: + explicit McpTunnelCertificates(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // POST /v1/organizations/tunnels/{tunnel_id}/certificates/{certificate_id}/archive DESTRUCTIVE + Json archive(const std::string& tunnel_id, const std::string& certificate_id) const; + + // POST /v1/organizations/tunnels/{tunnel_id}/certificates MUTATES + Json create(const std::string& tunnel_id, const Json& body) const; + + // GET /v1/organizations/tunnels/{tunnel_id}/certificates + Json list(const std::string& tunnel_id, const Query& query = Query()) const; + + Walk list_all(const std::string& tunnel_id, const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/organizations/tunnels/{tunnel_id}/certificates/{certificate_id} + Json get(const std::string& tunnel_id, const std::string& certificate_id) const; + +}; + +// group tunnels +class Tunnels : public Resource { + public: + explicit Tunnels(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kPlatform) {} + + // POST /v1/tunnels/{tunnel_id}/archive DESTRUCTIVE + Json archive(const std::string& tunnel_id) const; + + // POST /v1/tunnels MUTATES + Json create(const Json& body) const; + + // GET /v1/tunnels + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/tunnels/{tunnel_id} + Json get(const std::string& tunnel_id) const; + + // POST /v1/tunnels/{tunnel_id}/reveal_token RETURNS A SECRET + Json reveal_token(const std::string& tunnel_id) const; + + // POST /v1/tunnels/{tunnel_id}/rotate_token DESTRUCTIVE + Json rotate_token(const std::string& tunnel_id, const Json& body) const; + +}; + +// group tunnels.certificates +class TunnelsCertificates : public Resource { + public: + explicit TunnelsCertificates(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kPlatform) {} + + // POST /v1/tunnels/{tunnel_id}/certificates/{certificate_id}/archive DESTRUCTIVE + Json archive(const std::string& tunnel_id, const std::string& certificate_id) const; + + // POST /v1/tunnels/{tunnel_id}/certificates MUTATES + Json create(const std::string& tunnel_id, const Json& body) const; + + // GET /v1/tunnels/{tunnel_id}/certificates + Json list(const std::string& tunnel_id, const Query& query = Query()) const; + + Walk list_all(const std::string& tunnel_id, const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/tunnels/{tunnel_id}/certificates/{certificate_id} + Json get(const std::string& tunnel_id, const std::string& certificate_id) const; + +}; + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/user_profiles.cpp b/src/anthropic/admin/services/user_profiles.cpp new file mode 100644 index 0000000..1370edc --- /dev/null +++ b/src/anthropic/admin/services/user_profiles.cpp @@ -0,0 +1,67 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#include "anthropic/admin/services/user_profiles.h" + +namespace molo::anthropic::admin { + +Json UserProfiles::create(const Json& body) const { + return do_json(Call::kUserProfilesCreate, {}, nullptr, &body); +} + +Json UserProfiles::createBeta(const Json& body) const { + return do_json(Call::kUserProfilesCreateBeta, {}, nullptr, &body); +} + +Json UserProfiles::create_enrollment_url(const std::string& user_profile_id) const { + return do_json(Call::kUserProfilesCreateEnrollmentUrl, {user_profile_id}, nullptr, nullptr); +} + +Json UserProfiles::destroy(const std::string& user_profile_id) const { + return do_json(Call::kUserProfilesDelete, {user_profile_id}, nullptr, nullptr); +} + +Json UserProfiles::destroyBeta(const std::string& user_profile_id) const { + return do_json(Call::kUserProfilesDeleteBeta, {user_profile_id}, nullptr, nullptr); +} + +Json UserProfiles::list(const Query& query) const { + return do_json(Call::kUserProfilesList, {}, &query, nullptr); +} + +Walk UserProfiles::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kUserProfilesList, {}, query, max_pages); +} + +Json UserProfiles::listBeta(const Query& query) const { + return do_json(Call::kUserProfilesListBeta, {}, &query, nullptr); +} + +Walk UserProfiles::listBeta_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kUserProfilesListBeta, {}, query, max_pages); +} + +Json UserProfiles::get(const std::string& user_profile_id) const { + return do_json(Call::kUserProfilesRetrieve, {user_profile_id}, nullptr, nullptr); +} + +Json UserProfiles::getBeta(const std::string& user_profile_id) const { + return do_json(Call::kUserProfilesRetrieveBeta, {user_profile_id}, nullptr, nullptr); +} + +Json UserProfiles::update(const std::string& user_profile_id, const Json& body) const { + return do_json(Call::kUserProfilesUpdate, {user_profile_id}, nullptr, &body); +} + +Json UserProfiles::updateBeta(const std::string& user_profile_id, const Json& body) const { + return do_json(Call::kUserProfilesUpdateBeta, {user_profile_id}, nullptr, &body); +} + +Json UserProfilesActionUrls::create(const std::string& user_profile_id, const Json& body) const { + return do_json(Call::kUserProfilesActionUrlsCreate, {user_profile_id}, nullptr, &body); +} + +Json UserProfilesActionUrls::createBeta(const std::string& user_profile_id, const Json& body) const { + return do_json(Call::kUserProfilesActionUrlsCreateBeta, {user_profile_id}, nullptr, &body); +} + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/user_profiles.h b/src/anthropic/admin/services/user_profiles.h new file mode 100644 index 0000000..621936f --- /dev/null +++ b/src/anthropic/admin/services/user_profiles.h @@ -0,0 +1,74 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#pragma once + +// user_profiles calls of the Anthropic API (one class per resource group). Every +// method is one row of calls.cpp; mutating and destructive ones are marked. + +#include +#include + +#include "anthropic/admin/resource.h" + +namespace molo::anthropic::admin { + +// group user_profiles +class UserProfiles : public Resource { + public: + explicit UserProfiles(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kPlatform) {} + + // POST /v1/user_profiles MUTATES + Json create(const Json& body) const; + + // POST /v1/user_profiles MUTATES + Json createBeta(const Json& body) const; + + // POST /v1/user_profiles/{user_profile_id}/enrollment_url MUTATES + Json create_enrollment_url(const std::string& user_profile_id) const; + + // DELETE /v1/user_profiles/{user_profile_id} DESTRUCTIVE + Json destroy(const std::string& user_profile_id) const; + + // DELETE /v1/user_profiles/{user_profile_id} DESTRUCTIVE + Json destroyBeta(const std::string& user_profile_id) const; + + // GET /v1/user_profiles + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/user_profiles + Json listBeta(const Query& query = Query()) const; + + Walk listBeta_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/user_profiles/{user_profile_id} + Json get(const std::string& user_profile_id) const; + + // GET /v1/user_profiles/{user_profile_id} + Json getBeta(const std::string& user_profile_id) const; + + // POST /v1/user_profiles/{user_profile_id} MUTATES + Json update(const std::string& user_profile_id, const Json& body) const; + + // POST /v1/user_profiles/{user_profile_id} MUTATES + Json updateBeta(const std::string& user_profile_id, const Json& body) const; + +}; + +// group user_profiles.action_urls +class UserProfilesActionUrls : public Resource { + public: + explicit UserProfilesActionUrls(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kPlatform) {} + + // POST /v1/user_profiles/{user_profile_id}/action_urls MUTATES + Json create(const std::string& user_profile_id, const Json& body) const; + + // POST /v1/user_profiles/{user_profile_id}/action_urls MUTATES + Json createBeta(const std::string& user_profile_id, const Json& body) const; + +}; + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/vaults.cpp b/src/anthropic/admin/services/vaults.cpp new file mode 100644 index 0000000..c674cce --- /dev/null +++ b/src/anthropic/admin/services/vaults.cpp @@ -0,0 +1,67 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#include "anthropic/admin/services/vaults.h" + +namespace molo::anthropic::admin { + +Json Vaults::archive(const std::string& vault_id) const { + return do_json(Call::kVaultsArchive, {vault_id}, nullptr, nullptr); +} + +Json Vaults::create(const Json& body) const { + return do_json(Call::kVaultsCreate, {}, nullptr, &body); +} + +Json Vaults::destroy(const std::string& vault_id) const { + return do_json(Call::kVaultsDelete, {vault_id}, nullptr, nullptr); +} + +Json Vaults::list(const Query& query) const { + return do_json(Call::kVaultsList, {}, &query, nullptr); +} + +Walk Vaults::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kVaultsList, {}, query, max_pages); +} + +Json Vaults::get(const std::string& vault_id) const { + return do_json(Call::kVaultsRetrieve, {vault_id}, nullptr, nullptr); +} + +Json Vaults::update(const std::string& vault_id, const Json& body) const { + return do_json(Call::kVaultsUpdate, {vault_id}, nullptr, &body); +} + +Json VaultsCredentials::archive(const std::string& vault_id, const std::string& credential_id) const { + return do_json(Call::kVaultsCredentialsArchive, {vault_id, credential_id}, nullptr, nullptr); +} + +Json VaultsCredentials::create(const std::string& vault_id, const Json& body) const { + return do_json(Call::kVaultsCredentialsCreate, {vault_id}, nullptr, &body); +} + +Json VaultsCredentials::destroy(const std::string& vault_id, const std::string& credential_id) const { + return do_json(Call::kVaultsCredentialsDelete, {vault_id, credential_id}, nullptr, nullptr); +} + +Json VaultsCredentials::list(const std::string& vault_id, const Query& query) const { + return do_json(Call::kVaultsCredentialsList, {vault_id}, &query, nullptr); +} + +Walk VaultsCredentials::list_all(const std::string& vault_id, const Query& query, std::size_t max_pages) const { + return do_walk(Call::kVaultsCredentialsList, {vault_id}, query, max_pages); +} + +Json VaultsCredentials::mcp_oauth_validate(const std::string& vault_id, const std::string& credential_id) const { + return do_json(Call::kVaultsCredentialsMcpOauthValidate, {vault_id, credential_id}, nullptr, nullptr); +} + +Json VaultsCredentials::get(const std::string& vault_id, const std::string& credential_id) const { + return do_json(Call::kVaultsCredentialsRetrieve, {vault_id, credential_id}, nullptr, nullptr); +} + +Json VaultsCredentials::update(const std::string& vault_id, const std::string& credential_id, const Json& body) const { + return do_json(Call::kVaultsCredentialsUpdate, {vault_id, credential_id}, nullptr, &body); +} + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/vaults.h b/src/anthropic/admin/services/vaults.h new file mode 100644 index 0000000..58c2acb --- /dev/null +++ b/src/anthropic/admin/services/vaults.h @@ -0,0 +1,74 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#pragma once + +// vaults calls of the Anthropic API (one class per resource group). Every +// method is one row of calls.cpp; mutating and destructive ones are marked. + +#include +#include + +#include "anthropic/admin/resource.h" + +namespace molo::anthropic::admin { + +// group vaults +class Vaults : public Resource { + public: + explicit Vaults(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kPlatform) {} + + // POST /v1/vaults/{vault_id}/archive DESTRUCTIVE + Json archive(const std::string& vault_id) const; + + // POST /v1/vaults MUTATES + Json create(const Json& body) const; + + // DELETE /v1/vaults/{vault_id} DESTRUCTIVE + Json destroy(const std::string& vault_id) const; + + // GET /v1/vaults + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/vaults/{vault_id} + Json get(const std::string& vault_id) const; + + // POST /v1/vaults/{vault_id} MUTATES + Json update(const std::string& vault_id, const Json& body) const; + +}; + +// group vaults.credentials +class VaultsCredentials : public Resource { + public: + explicit VaultsCredentials(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kPlatform) {} + + // POST /v1/vaults/{vault_id}/credentials/{credential_id}/archive DESTRUCTIVE + Json archive(const std::string& vault_id, const std::string& credential_id) const; + + // POST /v1/vaults/{vault_id}/credentials MUTATES + Json create(const std::string& vault_id, const Json& body) const; + + // DELETE /v1/vaults/{vault_id}/credentials/{credential_id} DESTRUCTIVE + Json destroy(const std::string& vault_id, const std::string& credential_id) const; + + // GET /v1/vaults/{vault_id}/credentials + Json list(const std::string& vault_id, const Query& query = Query()) const; + + Walk list_all(const std::string& vault_id, const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // POST /v1/vaults/{vault_id}/credentials/{credential_id}/mcp_oauth_validate MUTATES + Json mcp_oauth_validate(const std::string& vault_id, const std::string& credential_id) const; + + // GET /v1/vaults/{vault_id}/credentials/{credential_id} + Json get(const std::string& vault_id, const std::string& credential_id) const; + + // POST /v1/vaults/{vault_id}/credentials/{credential_id} MUTATES + Json update(const std::string& vault_id, const std::string& credential_id, const Json& body) const; + +}; + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/workspaces.cpp b/src/anthropic/admin/services/workspaces.cpp new file mode 100644 index 0000000..889024b --- /dev/null +++ b/src/anthropic/admin/services/workspaces.cpp @@ -0,0 +1,91 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#include "anthropic/admin/services/workspaces.h" + +namespace molo::anthropic::admin { + +Json Workspaces::archive(const std::string& workspace_id) const { + return do_json(Call::kWorkspacesArchive, {workspace_id}, nullptr, nullptr); +} + +Json Workspaces::create(const Json& body) const { + return do_json(Call::kWorkspacesCreate, {}, nullptr, &body); +} + +Json Workspaces::list(const Query& query) const { + return do_json(Call::kWorkspacesList, {}, &query, nullptr); +} + +Walk Workspaces::list_all(const Query& query, std::size_t max_pages) const { + return do_walk(Call::kWorkspacesList, {}, query, max_pages); +} + +Json Workspaces::get(const std::string& workspace_id) const { + return do_json(Call::kWorkspacesRetrieve, {workspace_id}, nullptr, nullptr); +} + +Json Workspaces::update(const std::string& workspace_id, const Json& body) const { + return do_json(Call::kWorkspacesUpdate, {workspace_id}, nullptr, &body); +} + +Json WorkspaceMembers::add(const std::string& workspace_id, const Json& body) const { + return do_json(Call::kWorkspacesMembersAdd, {workspace_id}, nullptr, &body); +} + +Json WorkspaceMembers::list(const std::string& workspace_id, const Query& query) const { + return do_json(Call::kWorkspacesMembersList, {workspace_id}, &query, nullptr); +} + +Walk WorkspaceMembers::list_all(const std::string& workspace_id, const Query& query, std::size_t max_pages) const { + return do_walk(Call::kWorkspacesMembersList, {workspace_id}, query, max_pages); +} + +Json WorkspaceMembers::remove(const std::string& workspace_id, const std::string& user_id) const { + return do_json(Call::kWorkspacesMembersRemove, {workspace_id, user_id}, nullptr, nullptr); +} + +Json WorkspaceMembers::get(const std::string& workspace_id, const std::string& user_id) const { + return do_json(Call::kWorkspacesMembersRetrieve, {workspace_id, user_id}, nullptr, nullptr); +} + +Json WorkspaceMembers::update(const std::string& workspace_id, const std::string& user_id, const Json& body) const { + return do_json(Call::kWorkspacesMembersUpdate, {workspace_id, user_id}, nullptr, &body); +} + +Json WorkspaceRateLimits::list(const std::string& workspace_id, const Query& query) const { + return do_json(Call::kWorkspacesRateLimitsList, {workspace_id}, &query, nullptr); +} + +Walk WorkspaceRateLimits::list_all(const std::string& workspace_id, const Query& query, std::size_t max_pages) const { + return do_walk(Call::kWorkspacesRateLimitsList, {workspace_id}, query, max_pages); +} + +Json WorkspaceRateLimits::update(const std::string& workspace_id, const std::string& rate_limit_id, const Json& body) const { + return do_json(Call::kWorkspacesRateLimitsUpdate, {workspace_id, rate_limit_id}, nullptr, &body); +} + +Json WorkspaceServiceAccounts::add(const std::string& workspace_id, const Json& body) const { + return do_json(Call::kWorkspacesServiceAccountsAdd, {workspace_id}, nullptr, &body); +} + +Json WorkspaceServiceAccounts::list(const std::string& workspace_id, const Query& query) const { + return do_json(Call::kWorkspacesServiceAccountsList, {workspace_id}, &query, nullptr); +} + +Walk WorkspaceServiceAccounts::list_all(const std::string& workspace_id, const Query& query, std::size_t max_pages) const { + return do_walk(Call::kWorkspacesServiceAccountsList, {workspace_id}, query, max_pages); +} + +Json WorkspaceServiceAccounts::remove(const std::string& workspace_id, const std::string& service_account_id) const { + return do_json(Call::kWorkspacesServiceAccountsRemove, {workspace_id, service_account_id}, nullptr, nullptr); +} + +Json WorkspaceServiceAccounts::get(const std::string& workspace_id, const std::string& service_account_id) const { + return do_json(Call::kWorkspacesServiceAccountsRetrieve, {workspace_id, service_account_id}, nullptr, nullptr); +} + +Json WorkspaceServiceAccounts::update(const std::string& workspace_id, const std::string& service_account_id, const Json& body) const { + return do_json(Call::kWorkspacesServiceAccountsUpdate, {workspace_id, service_account_id}, nullptr, &body); +} + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/services/workspaces.h b/src/anthropic/admin/services/workspaces.h new file mode 100644 index 0000000..dddb5fd --- /dev/null +++ b/src/anthropic/admin/services/workspaces.h @@ -0,0 +1,106 @@ +// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand: +// the table is verified against the SDK source and the reference pages. +#pragma once + +// workspaces calls of the Anthropic API (one class per resource group). Every +// method is one row of calls.cpp; mutating and destructive ones are marked. + +#include +#include + +#include "anthropic/admin/resource.h" + +namespace molo::anthropic::admin { + +// group workspaces +class Workspaces : public Resource { + public: + explicit Workspaces(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // POST /v1/organizations/workspaces/{workspace_id}/archive DESTRUCTIVE + Json archive(const std::string& workspace_id) const; + + // POST /v1/organizations/workspaces MUTATES + Json create(const Json& body) const; + + // GET /v1/organizations/workspaces + Json list(const Query& query = Query()) const; + + Walk list_all(const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // GET /v1/organizations/workspaces/{workspace_id} + Json get(const std::string& workspace_id) const; + + // POST /v1/organizations/workspaces/{workspace_id} MUTATES + Json update(const std::string& workspace_id, const Json& body) const; + +}; + +// group workspaces.members +class WorkspaceMembers : public Resource { + public: + explicit WorkspaceMembers(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // POST /v1/organizations/workspaces/{workspace_id}/members MUTATES + Json add(const std::string& workspace_id, const Json& body) const; + + // GET /v1/organizations/workspaces/{workspace_id}/members + Json list(const std::string& workspace_id, const Query& query = Query()) const; + + Walk list_all(const std::string& workspace_id, const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // DELETE /v1/organizations/workspaces/{workspace_id}/members/{user_id} DESTRUCTIVE + Json remove(const std::string& workspace_id, const std::string& user_id) const; + + // GET /v1/organizations/workspaces/{workspace_id}/members/{user_id} + Json get(const std::string& workspace_id, const std::string& user_id) const; + + // POST /v1/organizations/workspaces/{workspace_id}/members/{user_id} MUTATES + Json update(const std::string& workspace_id, const std::string& user_id, const Json& body) const; + +}; + +// group workspaces.rate_limits +class WorkspaceRateLimits : public Resource { + public: + explicit WorkspaceRateLimits(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kAdmin) {} + + // GET /v1/organizations/workspaces/{workspace_id}/rate_limits + Json list(const std::string& workspace_id, const Query& query = Query()) const; + + Walk list_all(const std::string& workspace_id, const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // POST /v1/organizations/workspaces/{workspace_id}/rate_limits/{rate_limit_id} MUTATES + Json update(const std::string& workspace_id, const std::string& rate_limit_id, const Json& body) const; + +}; + +// group workspaces.service_accounts +class WorkspaceServiceAccounts : public Resource { + public: + explicit WorkspaceServiceAccounts(std::shared_ptr gateway) + : Resource(std::move(gateway), Auth::kOAuth) {} + + // POST /v1/organizations/workspaces/{workspace_id}/service_accounts MUTATES + Json add(const std::string& workspace_id, const Json& body) const; + + // GET /v1/organizations/workspaces/{workspace_id}/service_accounts + Json list(const std::string& workspace_id, const Query& query = Query()) const; + + Walk list_all(const std::string& workspace_id, const Query& query = Query(), std::size_t max_pages = Caps::kMaxPages) const; + + // DELETE /v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id} DESTRUCTIVE + Json remove(const std::string& workspace_id, const std::string& service_account_id) const; + + // GET /v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id} + Json get(const std::string& workspace_id, const std::string& service_account_id) const; + + // POST /v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id} MUTATES + Json update(const std::string& workspace_id, const std::string& service_account_id, const Json& body) const; + +}; + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/tools/check_spec.py b/src/anthropic/admin/tools/check_spec.py new file mode 100644 index 0000000..2ffdca1 --- /dev/null +++ b/src/anthropic/admin/tools/check_spec.py @@ -0,0 +1,939 @@ +#!/usr/bin/env python3 +"""Check (and regenerate) the Anthropic admin call table against its sources. + +Anthropic does not publish an OpenAPI document any more: the official SDKs +carry a `.stats.yml` with `configured_endpoints` only, no `openapi_spec_url` +(read 2026-10-24, python SDK commit pinned below). The machine-readable +sources used instead are, in order of authority: + + 1. the official Python SDK source at a pinned commit: every resource method + (HTTP verb, path, body keys, query keys, header params, beta header, + pagination class, return type) and the TypedDict `*_params.py` files; + 2. the published API reference pages (platform.claude.com/docs/en/api/**.md): + `**VERB** path`, path, query, body parameters and the credential note; + 3. the Claude Tag guide for the endpoints that have no reference page yet. + +Three operations are documented but absent from every SDK (messages usage +report, Claude Code usage report, cost report) and the organization-level MCP +tunnel views: they are "docs only" rows, listed in DOCS_ONLY below. + + python3 -I src/anthropic/admin/tools/check_spec.py # verify + python3 -I src/anthropic/admin/tools/check_spec.py --emit # regenerate + +Verify fails (exit 1) when + * a committed generated file differs from what the sources generate now; + * a table row disagrees with the SDK (verb, path, fields, required, query, + headers, beta header, pagination) or with its reference page (verb, path, + every body / query parameter, credential class); + * an SDK operation is neither in the table nor in EXCLUDED (the Messages, + Batches, Models, Files and Skills families belong to src/anthropic/core). + +Python 3 stdlib only. No credentials. Network: codeload.github.com (SDK +tarball, one request) and platform.claude.com (reference pages). +`--sdk-tar FILE` and `--pages-dir DIR` reuse local copies (the pages dir is +filled when missing). +""" +import ast +import concurrent.futures as cf +import io +import os +import re +import sys +import tarfile +import urllib.request + +HERE = os.path.dirname(os.path.abspath(__file__)) +ADMIN = os.path.abspath(os.path.join(HERE, "..")) +SDK_SHA = "202db72c87d7c6eaa72129c67ce67fd343a3a20c" # anthropic-sdk-python 2.3.0 +SDK_URL = "https://codeload.github.com/anthropics/anthropic-sdk-python/tar.gz/" + SDK_SHA +DOCS_URL = "https://platform.claude.com/docs/en/%s.md" +UA = {"User-Agent": "curl/8.5.0"} + +# SDK resource files (relative to src/anthropic/resources) owned by this package. +SCOPES = ["organization", "user_profiles", "beta/organization", "beta/agents", "beta/environments", + "beta/sessions", "beta/vaults", "beta/memory_stores", "beta/tunnels", "beta/user_profiles", + "beta/deployments.py", "beta/deployment_runs.py", "beta/dreams.py"] +# Everything else in the SDK belongs to src/anthropic/core (or has no endpoint). +EXCLUDED = ("/v1/messages", "/v1/models", "/v1/files", "/v1/skills") + +VERBS = {"_get": "GET", "_post": "POST", "_delete": "DELETE", "_patch": "PATCH", "_put": "PUT", + "_get_api_list": "GET", "_post_api_list": "POST"} +PAGES = {"SyncPage": "kIds", "SyncPageCursor": "kCursor", "SyncReportPageCursor": "kReport", + "SyncBidirectionalPageCursor": "kBidirectional"} +DESTRUCTIVE_NAMES = {"archive", "delete", "remove", "cancel", "stop", "redact", "rotate_token", + "regenerate_signing_secret", "deny", "approve", "pause"} +# Calls that move a secret out: not destructive, but never run without confirm. +SECRET_NAMES = {"reveal_token"} + +# Operations documented (reference page) but present in no SDK. fields come from the page. +DOCS_ONLY = [ + # (sdk-style op id, verb, path, docs slug, response, pagination) + ("organization.usage_report.retrieve_messages", "GET", "/v1/organizations/usage_report/messages", + "api/beta/organization/usage_report/retrieve_messages", "BetaMessagesUsageReport", "kReport"), + ("organization.usage_report.retrieve_claude_code", "GET", "/v1/organizations/usage_report/claude_code", + "api/beta/organization/usage_report/retrieve_claude_code", "BetaClaudeCodeUsageReport", "kReport"), + ("organization.cost_report.retrieve", "GET", "/v1/organizations/cost_report", + "api/beta/organization/cost_report/retrieve", "BetaCostReport", "kReport"), + ("organization.mcp_tunnels.list", "GET", "/v1/organizations/tunnels", + "api/beta/organization/mcp_tunnels/list", "BetaMcpTunnel", "kCursor"), + ("organization.mcp_tunnels.retrieve", "GET", "/v1/organizations/tunnels/{tunnel_id}", + "api/beta/organization/mcp_tunnels/retrieve", "BetaMcpTunnel", "kNone"), + ("organization.mcp_tunnels.archive", "POST", "/v1/organizations/tunnels/{tunnel_id}/archive", + "api/beta/organization/mcp_tunnels/archive", "BetaMcpTunnel", "kNone"), + ("organization.mcp_tunnels.reveal_token", "POST", "/v1/organizations/tunnels/{tunnel_id}/reveal_token", + "api/beta/organization/mcp_tunnels/reveal_token", "BetaMcpTunnelToken", "kNone"), + ("organization.mcp_tunnels.rotate_token", "POST", "/v1/organizations/tunnels/{tunnel_id}/rotate_token", + "api/beta/organization/mcp_tunnels/rotate_token", "BetaMcpTunnelToken", "kNone"), + ("organization.mcp_tunnels.certificates.list", "GET", "/v1/organizations/tunnels/{tunnel_id}/certificates", + "api/beta/organization/mcp_tunnels/tunnel_certificates/list", "BetaMcpTunnelCertificate", "kCursor"), + ("organization.mcp_tunnels.certificates.retrieve", "GET", + "/v1/organizations/tunnels/{tunnel_id}/certificates/{certificate_id}", + "api/beta/organization/mcp_tunnels/tunnel_certificates/retrieve", "BetaMcpTunnelCertificate", "kNone"), + ("organization.mcp_tunnels.certificates.create", "POST", "/v1/organizations/tunnels/{tunnel_id}/certificates", + "api/beta/organization/mcp_tunnels/tunnel_certificates/create", "BetaMcpTunnelCertificate", "kNone"), + ("organization.mcp_tunnels.certificates.archive", "POST", + "/v1/organizations/tunnels/{tunnel_id}/certificates/{certificate_id}/archive", + "api/beta/organization/mcp_tunnels/tunnel_certificates/archive", "BetaMcpTunnelCertificate", "kNone"), +] +# Beta header of docs-only rows (read from the reference page's prose / SDK twin); "" = none. +DOCS_ONLY_BETA = {"organization.mcp_tunnels": "mcp-tunnels-2026-06-22"} +# SDK operations whose reference page does not exist yet: checked against a guide. +GUIDE_DOCS = {"claude_tag": "guide:manage-claude/claude-tag-api"} +# SDK operations with neither a reference page nor a guide (single source: SDK). +SDK_ONLY = {"/v1/organizations/analytics/usage", "/v1/organizations/analytics/cost"} +# Body fields a reference page documents but the pinned SDK does not have yet. +DOCS_EXTRA_BODY = {} +# Resource groups the credential note says take only an org:admin OAuth token. +OAUTH_MARKERS = ("/federation_issuers", "/federation_rules", "/service_accounts") + +AREA = { + "organization": "identity", "users": "identity", "invites": "identity", "api_keys": "identity", + "external_keys": "identity", "rate_limits": "identity", "compliance_settings": "identity", + "workspaces": "workspaces", "service_accounts": "access", "federation": "access", + "rbac_groups": "access", "rbac_roles": "access", "analytics": "analytics", + "usage_report": "reports", "cost_report": "reports", "spend_limits": "spend_limits", + "plugins": "plugins", "plugin_marketplaces": "plugins", "telemetry_destinations": "telemetry", + "webhooks": "telemetry", "claude_tag": "claude_tag", "mcp_tunnels": "tunnels", "tunnels": "tunnels", + "agents": "agents", "environments": "environments", "sessions": "sessions", + "deployments": "deployments", "deployment_runs": "deployments", "vaults": "vaults", + "memory_stores": "memory", "user_profiles": "user_profiles", "dreams": "dreams", +} +CLASS_NAME = { + "organization": "Organization", "workspaces.members": "WorkspaceMembers", + "workspaces.rate_limits": "WorkspaceRateLimits", "workspaces.service_accounts": "WorkspaceServiceAccounts", + "service_accounts.workspaces": "ServiceAccountWorkspaces", "federation.rules.workspaces": "FederationRuleWorkspaces", + "mcp_tunnels.certificates": "McpTunnelCertificates", "usage_report": "UsageReports", + "cost_report": "CostReports", "mcp_tunnels": "McpTunnels", +} +METHOD_NAME = {"retrieve": "get", "delete": "destroy", "retrieve_messages": "messages", + "retrieve_claude_code": "claude_code", "set": "set_limit"} + + +def camel(s): + return "".join(p[:1].upper() + p[1:] for p in re.split(r"[_.]", s) if p) + + +def fetch(url, headers=None): + req = urllib.request.Request(url, headers=headers or UA) + with urllib.request.urlopen(req, timeout=120) as r: + return r.read() + + +# --- SDK extraction ------------------------------------------------------------------------- + +class Sdk: + def __init__(self, tar_path=None): + data = open(tar_path, "rb").read() if tar_path else fetch(SDK_URL) + self.files = {} + with tarfile.open(fileobj=io.BytesIO(data), mode="r:gz") as t: + for m in t.getmembers(): + if m.isfile() and m.name.endswith((".py", ".yml")): + self.files[m.name.split("/", 1)[1]] = t.extractfile(m).read().decode("utf-8", "replace") + self.res = "src/anthropic/resources/" + + def resource_files(self, scope_only=True): + out = [] + for name in sorted(self.files): + if not name.startswith(self.res) or name.endswith("__init__.py"): + continue + rel = name[len(self.res):] + if scope_only and not any(rel == s or rel.startswith(s + "/") for s in SCOPES): + continue + out.append(name) + return out + + +def op_id(rel): + parts = rel[:-3].split("/") + if len(parts) > 1 and parts[-1] == parts[-2]: + parts = parts[:-1] + return parts + + +def types_dir(rel): + parts = rel[:-3].split("/") + parent = parts[:-1] + if parent and parts[-1] == parent[-1]: + parent = parent[:-1] + return "src/anthropic/types/" + "/".join(parent) + ("/" if parent else "") + + +def singulars(word): + out = [word] + if word.endswith("ies"): + out.append(word[:-3] + "y") + if word.endswith("s"): + out.append(word[:-1]) + return out + + +def is_array(ann): + return bool(ann) and re.search(r"\b(List|SequenceNotStr|Iterable|Sequence)\[", ann) is not None + + +def analyze(fn, src): + a = fn.args + pos = [x.arg for x in a.args if x.arg != "self"] + kw = {} + for x, d in zip(a.kwonlyargs, a.kw_defaults): + kw[x.arg] = {"req": d is None, "ann": ast.unparse(x.annotation) if x.annotation else ""} + ret = ast.unparse(fn.returns) if fn.returns else "" + out = {"name": fn.name, "pos": pos, "kw": kw, "ret": ret, "calls": [], "beta": "", "ws": "workspace_id" in kw, + "headers": {}} + seg = ast.get_source_segment(src, fn) or "" + m = re.search(r'extra_headers = \{"anthropic-beta": "([^"]+)"', seg) + out["beta"] = m.group(1) if m else "" + # header params: strip_not_given({...}) dicts of the extra_headers assignment + for node in ast.walk(fn): + if isinstance(node, ast.Assign) and any(isinstance(t, ast.Name) and t.id == "extra_headers" for t in node.targets): + if isinstance(node.value, ast.Dict): + for k, v in zip(node.value.keys, node.value.values): + if k is None and isinstance(v, ast.Call) and v.args and isinstance(v.args[0], ast.Dict): + d = v.args[0] + for hk, hv in zip(d.keys, d.values): + if isinstance(hk, ast.Constant) and hk.value not in ("anthropic-beta", "anthropic-workspace-id"): + if isinstance(hv, ast.Name): + out["headers"][hv.id] = hk.value + for node in ast.walk(fn): + if isinstance(node, ast.Call) and isinstance(node.func, ast.Attribute) and isinstance(node.func.value, ast.Name) \ + and node.func.value.id == "self" and node.func.attr in VERBS: + c = {"verb": VERBS[node.func.attr], "path": ast.unparse(node.args[0]), "body": None, "query": None, + "stream": False, "files": False, "raw": "BinaryAPIResponse" in ast.unparse(node)} + for k in node.keywords: + if k.arg == "body" and isinstance(k.value, ast.Dict): + c["body"] = {kk.value: (vv.id if isinstance(vv, ast.Name) else None) + for kk, vv in zip(k.value.keys, k.value.values)} + if k.arg == "stream": + c["stream"] = True + if k.arg == "files": + c["files"] = True + if k.arg == "options": + for k2 in k.value.keywords: + if k2.arg == "query" and isinstance(k2.value, ast.Dict): + c["query"] = {kk.value: (vv.id if isinstance(vv, ast.Name) else None) + for kk, vv in zip(k2.value.keys, k2.value.values)} + out["calls"].append(c) + if "extract_files" in seg and "'files'" not in seg and '"files"' in seg: + pass + if "extract_files(" in seg: + for c in out["calls"]: + c["files"] = True + return out + + +def extract_ops(sdk, scope_only=True): + ops = [] + for name in sdk.resource_files(scope_only): + rel = name[len(sdk.res):] + src = sdk.files[name] + tree = ast.parse(src) + for cls in tree.body: + if not isinstance(cls, ast.ClassDef) or cls.name.startswith("Async") or "Raw" in cls.name \ + or "Streaming" in cls.name: + continue + for fn in cls.body: + if not isinstance(fn, ast.FunctionDef) or fn.name.startswith("_") or not fn.args.kwonlyargs: + continue + if fn.name in ("with_raw_response", "with_streaming_response"): + continue + r = analyze(fn, src) + if not r["calls"]: + continue + r["file"] = rel + r["ident"] = op_id(rel) + [fn.name] + r["tdir"] = types_dir(rel) + ops.append(r) + return ops + + +def row_from_op(sdk, r): + c = r["calls"][0] + pm = re.match(r"path_template\(\s*'([^']+)'", c["path"], re.S) + path = pm.group(1) if pm else c["path"].strip("'\"") + ids = re.findall(r"\{(\w+)\}", path) + body = c["body"] or {} + # kw names behind query keys, to know which are arrays + q = c["query"] or {} + query, qarr = [], {} + for key, var in q.items(): + arr = is_array(r["kw"].get(var, {}).get("ann", "")) + query.append(key + ("[]" if arr else "")) + req = [k for k, v in r["kw"].items() if v["req"] and (k in body or any(vv == k for vv in body.values()))] + # body keys that map to required kw + required = [] + for key, var in body.items(): + if var and r["kw"].get(var, {}).get("req"): + required.append(key) + for key, var in q.items(): + if var and r["kw"].get(var, {}).get("req"): + required.append(key + ("[]" if is_array(r["kw"][var]["ann"]) else "")) + if c["files"]: + # multipart: the file parameters are parts named `files[]` / `archive` + body = {} + for k, v in r["kw"].items(): + if k in ("betas", "workspace_id", "extra_headers", "extra_query", "extra_body", "timeout"): + continue + if "FileTypes" in v["ann"]: + nm = k + ("[]" if "SequenceNotStr" in v["ann"] else "") + body[nm] = k + if v["req"]: + required.append(nm) + elif k not in ids: + body[k] = k + if v["req"]: + required.append(k) + ret = r["ret"] + pg = "kNone" + for k, v in PAGES.items(): + if re.search(r"\b" + k + r"\[", ret): + pg = v + mresp = re.search(r"\[(\w+)\]", ret) + resp = mresp.group(1) if mresp else re.sub(r"Optional\[(\w+)\]", r"\1", ret) + if c["raw"]: + resp = "Binary" + # request schema: SDK params module for this operation + schema, schema_file = "", "" + stem_parts = r["ident"][-2] + for s in singulars(stem_parts): + cand = r["tdir"] + "%s_%s_params.py" % (s, r["ident"][-1]) + if cand in sdk.files: + schema = camel(os.path.basename(cand)[:-3]) + schema_file = cand + break + return { + "ident": r["ident"], "verb": c["verb"], "path": path, "ids": ids, + "body": list(body.keys()) if not c["files"] else list(body.keys()), + "required": required, "query": query, "headers": dict(r["headers"]), + "beta": r["beta"], "ws": r["ws"], "page": pg, "resp": resp, "schema": schema, "schema_file": schema_file, + "stream": c["stream"], "files": c["files"], "raw": c["raw"], "file": r["file"], + "kwargs": r["kw"], "src": "sdk", + } + + +def merge_twins(rows): + """GA (non-beta) and beta variants of one verb+path: one row when the shapes agree.""" + groups = {} + for r in rows: + groups.setdefault((r["verb"], r["path"]), []).append(r) + out = [] + for key, vs in sorted(groups.items(), key=lambda kv: kv[1][0]["ident"]): + ga = [v for v in vs if v["ident"][0] != "beta"] + be = [v for v in vs if v["ident"][0] == "beta"] + def compatible(g, b): + return (g["beta"] == b["beta"] and g["page"] == b["page"] and set(g["body"]) <= set(b["body"]) + and set(g["query"]) <= set(b["query"]) and set(g["required"]) == set(b["required"])) + if ga and be and compatible(ga[0], be[0]): + be[0]["twin"] = ga[0]["ident"] + be[0]["ident"] = ga[0]["ident"] + be[0]["schema_files"] = [f for f in (ga[0]["schema_file"], be[0]["schema_file"]) if f] + be[0]["schema"] = ga[0]["schema"] or be[0]["schema"] + out.append(be[0]) + elif ga and be: + # different generations of one endpoint: two rows, the beta-header form is suffixed + be[0]["suffix"] = "Beta" + ga[0]["twin"] = None + out.extend([ga[0], be[0]]) + else: + out.append((ga or be)[0]) + return out + + +# --- reference pages ------------------------------------------------------------------------ + +class Pages: + def __init__(self, cache): + self.cache = cache + self.mem = {} + + def get(self, slug): + if slug in self.mem: + return self.mem[slug] + text = None + path = os.path.join(self.cache, slug.replace("/", "_") + ".md") if self.cache else None + if path and os.path.exists(path) and os.path.getsize(path) > 200: + text = open(path, encoding="utf-8").read() + else: + try: + text = fetch(DOCS_URL % slug).decode("utf-8", "replace") + except Exception as e: # noqa + text = "ERROR " + str(e) + if path and not text.startswith("ERROR"): + os.makedirs(self.cache, exist_ok=True) + open(path, "w", encoding="utf-8").write(text) + self.mem[slug] = text + return text + + def prefetch(self, slugs): + with cf.ThreadPoolExecutor(8) as ex: + list(ex.map(self.get, slugs)) + + +def docs_slug(row): + ident = row["ident"] + if row.get("docs"): + return row["docs"] + parts = list(ident) + beta = parts[0] == "beta" + if beta: + parts = parts[1:] + last = parts[-1] + group = parts[:-1] + # SDK group names that differ from the reference URL + group = ["mcp_tunnels" if g == "tunnels" and group[0] == "organization" else g for g in group] + return "api/" + ("beta/" if beta or parts[0] != "organization" and parts[0] != "user_profiles" else "") + \ + "/".join(group + [last]) + + +def section(text, names): + """Top-level bullet parameter names under the first heading whose text is in names.""" + out, active = [], False + for line in text.splitlines(): + h = re.match(r"^#{2,3} (.+)$", line) + if h: + active = h.group(1).strip().lower() in names + continue + if active: + m = re.match(r"^- `\"?([^`:\"]+)\"?(?::|`)", line) + if m: + out.append(m.group(1)) + return out + + +def doc_params(text): + return { + "path": section(text, ("path parameters",)), + "query": section(text, ("query parameters",)), + "body": section(text, ("body parameters",)), + "headers": section(text, ("headers",)), + } + + +def doc_method_path(text): + m = re.search(r"\*\*(GET|POST|DELETE|PATCH|PUT)\*\* `([^`]+)`", text) + return (m.group(1), m.group(2)) if m else (None, None) + + +# --- table rows ----------------------------------------------------------------------------- + +def auth_of(path): + if any(m in path for m in OAUTH_MARKERS): + return "kOAuth" + if path.startswith("/v1/organizations"): + return "kAdmin" + return "kPlatform" + + +def kind_of(verb, name): + if name in DESTRUCTIVE_NAMES or verb == "DELETE": + return "kDestructive" + if verb == "GET": + return "kRead" + return "kWrite" + + +def transport_of(row): + if row["files"]: + return "kMultipart" + if row["raw"]: + return "kRaw" + if row["stream"] or row["ident"][-1] == "stream": + return "kSse" + return "kJson" + + +def enum_name(row): + parts = list(row["ident"]) + if parts[0] == "beta": + parts = parts[1:] + if parts[0] == "organization" and len(parts) > 2: + parts = parts[1:] + return "k" + camel(".".join(parts)) + row.get("suffix", "") + + +def group_of(row): + parts = list(row["ident"][:-1]) + if parts and parts[0] == "beta": + parts = parts[1:] + if parts and parts[0] == "organization" and len(parts) > 1: + parts = parts[1:] + return ".".join(parts) + + +def area_of(row): + g = group_of(row).split(".")[0] + return AREA[g] + + +def method_name(row): + n = row["ident"][-1] + return METHOD_NAME.get(n, n) + + +def build_rows(sdk, pages, use_docs): + ops = extract_ops(sdk) + rows = [row_from_op(sdk, r) for r in ops] + rows = merge_twins(rows) + for r in rows: + for f in DOCS_EXTRA_BODY.get((r["verb"], r["path"]), []): + if f not in r["body"]: + r["body"].append(f) + r["auth"] = auth_of(r["path"]) + r["docs"] = "" + for r in rows: + g = group_of(r).split(".")[0] + if g in GUIDE_DOCS: + r["docs"] = GUIDE_DOCS[g] + elif r["path"] in SDK_ONLY: + r["docs"] = "" + else: + r["docs"] = docs_slug(r) + # docs-only rows + for ident, verb, path, slug, resp, pg in DOCS_ONLY: + text = pages.get(slug) + if text.startswith("ERROR"): + raise SystemExit("docs-only page missing: " + slug + " " + text) + p = doc_params(text) + # required = bullets without "optional" + req_q = sorted(n for n in p["query"] if re.search(r"^- `" + re.escape(n) + r"(\[\])?: (?!optional)", text, re.M)) + req_b = sorted(n for n in p["body"] if re.search(r"^- `" + re.escape(n) + r": (?!optional)", text, re.M)) + arrays = set() + for n in p["query"]: + if re.search(r"^- `" + re.escape(n) + r": (optional )?array of", text, re.M): + arrays.add(n) + parts = ident.split(".") + beta = "" + for k, v in DOCS_ONLY_BETA.items(): + if ident.startswith(k): + beta = v + rows.append({ + "ident": ["beta"] + parts, "verb": verb, "path": path, + "ids": re.findall(r"\{(\w+)\}", path), + "body": p["body"], "required": [n + ("[]" if n in arrays else "") for n in req_q] + req_b, + "query": [n + ("[]" if n in arrays else "") for n in p["query"]], + "headers": {}, "beta": beta, "ws": False, "page": pg, "resp": resp, "schema": "", + "stream": False, "files": False, "raw": False, "file": "", "kwargs": {}, "src": "docs", + "auth": auth_of(path), "docs": slug, "twin": None, + }) + rows.sort(key=lambda r: (r["auth"], enum_name(r))) + return rows + + +# --- emit ----------------------------------------------------------------------------------- + +HDR = ("// GENERATED by src/anthropic/admin/tools/check_spec.py --emit. Do not edit by hand:\n" + "// the table is verified against the SDK source and the reference pages.\n") + + +def csv(items): + return ",".join(items) + + +def emit_calls(rows): + enum = ",\n ".join(enum_name(r) for r in rows) + h = HDR + """#pragma once + +// The ONE table of REST calls this package makes. Every row is checked by +// tools/check_spec.py against the official SDK source and the API reference. +// Code builds every URL from this table, never from a literal. + +#include + +#include "clients/request.h" + +namespace molo::anthropic::admin { + +enum class Call { + %s, +}; + +// Which credential a call needs. +enum class Auth { + kAdmin, // Admin API key (sk-ant-admin..., x-api-key) or an org:admin OAuth token + kOAuth, // only an org:admin OAuth bearer token (service accounts, federation) + kPlatform, // standard workspace API key (managed agents surface) +}; + +enum class Kind { kRead, kWrite, kDestructive }; +enum class Page { kNone, kIds, kCursor, kReport, kBidirectional }; +enum class Wire { kJson, kSse, kMultipart, kRaw }; + +struct CallSpec { + Call call; + const char* name; // SDK-style operation id, e.g. organization.invites.create + const char* http; // GET POST PATCH DELETE + const char* path; // /v1/organizations/invites/{invite_id} + const char* docs; // reference page slug, guide:, or "" (SDK only) + const char* request; // SDK request schema (TypedDict) or "" + const char* response; // SDK response type + const char* body; // comma list: JSON body fields (multipart: part names) + const char* required; // comma list: required body fields and query parameters + const char* query; // comma list: query parameters; `name[]` is sent repeated + const char* headers; // comma list: arg=Header-Name request header parameters + const char* beta; // anthropic-beta value the call needs, or "" + Auth auth; + Kind kind; + Page page; + Wire wire; + bool workspace; // accepts the anthropic-workspace-id header + bool docs_only; // not in any SDK: reference page is the only source +}; + +const CallSpec& spec_of(Call call); +clients::Method method_of(Call call); +std::size_t call_count(); +const CallSpec& spec_at(std::size_t index); + +} // namespace molo::anthropic::admin +""" % enum + lines = [] + for r in rows: + hdrs = ",".join("%s=%s" % (k, v) for k, v in r["headers"].items()) + lines.append(' {Call::%s, "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", Auth::%s, Kind::%s, Page::%s, Wire::%s, %s, %s},' + % (enum_name(r), ".".join(r["ident"][1:] if r["ident"][0] == "beta" else r["ident"]) + r.get("suffix", "").lower(), + r["verb"], r["path"], r["docs"], r["schema"], r["resp"], csv(r["body"]), csv(r["required"]), + csv(r["query"]), hdrs, r["beta"], r["auth"], kind_of(r["verb"], r["ident"][-1]), + r["page"], transport_of(r), "true" if r["ws"] else "false", + "true" if r["src"] == "docs" else "false")) + c = HDR + """#include "anthropic/admin/calls.h" + +#include + +namespace molo::anthropic::admin { + +// CALLS-BEGIN (parsed by tools/check_spec.py; one row per line) +static const CallSpec kCalls[] = { +%s +}; +// CALLS-END + +std::size_t call_count() { return sizeof(kCalls) / sizeof(kCalls[0]); } + +const CallSpec& spec_at(std::size_t index) { + if (index >= call_count()) throw std::out_of_range("call index"); + return kCalls[index]; +} + +const CallSpec& spec_of(Call call) { + for (const CallSpec& s : kCalls) + if (s.call == call) return s; + throw std::out_of_range("unknown call"); +} + +clients::Method method_of(Call call) { + const std::string m = spec_of(call).http; + if (m == "GET") return clients::Method::kGet; + if (m == "POST") return clients::Method::kPost; + if (m == "DELETE") return clients::Method::kDelete; + if (m == "PATCH") return clients::Method::kPatch; + return clients::Method::kPut; +} + +} // namespace molo::anthropic::admin +""" % "\n".join(lines) + return {"calls.h": h, "calls.cpp": c} + + +def groups_of(rows): + g = {} + for r in rows: + g.setdefault(group_of(r), []).append(r) + return g + + +def class_name(group): + return CLASS_NAME.get(group) or camel(group) + + +def accessor(group): + return re.sub(r"\W", "_", {"organization": "organization"}.get(group, group)) + + +def cxx_sig(r): + """(declaration args, call-site expression pieces).""" + args = ["const std::string& %s" % i for i in r["ids"]] + has_body = bool(r["body"]) and not r["files"] + has_query = bool(r["query"]) or bool(r["headers"]) + q_required = any(n in r["query"] for n in r["required"] if n not in r["body"]) + if r["files"]: + args.append("const clients::body::MultipartBody& form") + elif has_body: + args.append("const Json& body") + if has_query: + args.append("const Query& query" + ("" if q_required else " = Query()")) + return args, has_body, has_query + + +def emit_service(area, rows): + groups = groups_of(rows) + decl, impl = [], [] + for g in sorted(groups): + cname = class_name(g) + auths = {r["auth"] for r in groups[g]} + if len(auths) != 1: + raise SystemExit("group %s mixes credentials %s" % (g, auths)) + auth = auths.pop() + decl.append("// group %s\nclass %s : public Resource {\n public:\n explicit %s(std::shared_ptr gateway)\n : Resource(std::move(gateway), Auth::%s) {}\n" + % (g, cname, cname, auth)) + for r in sorted(groups[g], key=lambda r: r["ident"][-1]): + args, has_body, has_query = cxx_sig(r) + mname = method_name(r) + r.get("suffix", "") + ce = "Call::" + enum_name(r) + ids = "{" + ", ".join(r["ids"]) + "}" + kind = kind_of(r["verb"], r["ident"][-1]) + tag = {"kRead": "", "kWrite": " MUTATES", "kDestructive": " DESTRUCTIVE"}[kind] + if r["ident"][-1] in SECRET_NAMES: + tag = " RETURNS A SECRET" + comment = " // %s %s%s" % (r["verb"], r["path"], tag) + qexpr = "&query" if has_query else "nullptr" + bexpr = "&body" if has_body else "nullptr" + w = transport_of(r) + if w == "kSse": + sig = ", ".join([a for a in args if not a.startswith("const Query&")] + ["const EventSink& sink"] + [a for a in args if a.startswith("const Query&")]) + decl.append("%s\n void %s(%s) const;\n" % (comment, mname, sig)) + impl.append("void %s::%s(%s) const {\n do_stream(%s, %s, %s, sink);\n}\n" + % (cname, mname, sig.replace(" = Query()", ""), ce, ids, qexpr if has_query else "nullptr")) + elif w == "kMultipart": + sig = ", ".join(args) + decl.append("%s\n Json %s(%s) const;\n" % (comment, mname, sig)) + impl.append("Json %s::%s(%s) const {\n return do_form(%s, %s, form);\n}\n" + % (cname, mname, sig.replace(" = Query()", ""), ce, ids)) + elif w == "kRaw": + sig = ", ".join(args) + decl.append("%s\n llm::RawResponse %s(%s) const;\n" % (comment, mname, sig)) + impl.append("llm::RawResponse %s::%s(%s) const {\n return do_raw(%s, %s, %s);\n}\n" + % (cname, mname, sig.replace(" = Query()", ""), ce, ids, qexpr)) + else: + sig = ", ".join(args) + decl.append("%s\n Json %s(%s) const;\n" % (comment, mname, sig)) + impl.append("Json %s::%s(%s) const {\n return do_json(%s, %s, %s, %s);\n}\n" + % (cname, mname, sig.replace(" = Query()", ""), ce, ids, qexpr, bexpr)) + if r["page"] != "kNone": + wargs = ", ".join([a for a in args if not a.startswith("const Query&")] + ["const Query& query = Query()", "std::size_t max_pages = Caps::kMaxPages"]) + decl.append(" Walk %s_all(%s) const;\n" % (mname, wargs)) + impl.append("Walk %s::%s_all(%s) const {\n return do_walk(%s, %s, query, max_pages);\n}\n" + % (cname, mname, wargs.replace(" = Query()", "").replace(" = Caps::kMaxPages", ""), ce, ids)) + decl.append("};\n") + guard = "ANTHROPIC_ADMIN_SERVICES_%s_H" % area.upper() + h = HDR + """#pragma once + +// %s calls of the Anthropic API (one class per resource group). Every +// method is one row of calls.cpp; mutating and destructive ones are marked. + +#include +#include + +#include "anthropic/admin/resource.h" + +namespace molo::anthropic::admin { + +%s +} // namespace molo::anthropic::admin +""" % (area, "\n".join(decl)) + c = HDR + """#include "anthropic/admin/services/%s.h" + +namespace molo::anthropic::admin { + +%s +} // namespace molo::anthropic::admin +""" % (area, "\n".join(impl)) + return {"services/%s.h" % area: h, "services/%s.cpp" % area: c} + + +def emit_all(rows): + files = emit_calls(rows) + areas = {} + for r in rows: + areas.setdefault(area_of(r), []).append(r) + for a, rs in sorted(areas.items()): + files.update(emit_service(a, rs)) + classes = [] + for a, rs in sorted(areas.items()): + for g in sorted(groups_of(rs)): + classes.append((a, g)) + # facade: one accessor per class + inc = "\n".join('#include "anthropic/admin/services/%s.h"' % a for a in sorted(areas)) + members = "\n".join(" %s %s_;" % (class_name(g), accessor(g)) for a, g in classes) + acc = "\n".join(" const %s& %s() const { return %s_; }" % (class_name(g), accessor(g), accessor(g)) for a, g in classes) + init = ",\n ".join("%s_(gateway_)" % accessor(g) for a, g in classes) + files["api.h"] = HDR + """#pragma once + +// AdminApi: every resource group of the package behind one object. Build it +// from the environment (ANTHROPIC_ADMIN_KEY, ANTHROPIC_ADMIN_TOKEN, +// ANTHROPIC_API_KEY) or from an explicit Gateway. + +#include + +#include "anthropic/admin/gateway.h" +%s + +namespace molo::anthropic::admin { + +class AdminApi { + public: + explicit AdminApi(std::shared_ptr gateway) + : gateway_(std::move(gateway)), + %s {} + static AdminApi from_env() { return AdminApi(Gateway::from_env()); } + + const Gateway& gateway() const { return *gateway_; } + +%s + + private: + std::shared_ptr gateway_; +%s +}; + +} // namespace molo::anthropic::admin +""" % (inc, init, acc, members) + return files + + +# --- verify --------------------------------------------------------------------------------- + +def parse_table(path): + text = open(path, encoding="utf-8").read() + a = text.index("// CALLS-BEGIN") + b = text.index("// CALLS-END") + rows = [] + for line in text[a:b].splitlines()[1:]: + m = re.match(r'^\s*\{Call::(\w+), (.*), Auth::(\w+), Kind::(\w+), Page::(\w+), Wire::(\w+), (\w+), (\w+)\},$', line) + if not m: + continue + strs = re.findall(r'"([^"]*)"', m.group(2)) + rows.append({"enum": m.group(1), "strs": strs, "auth": m.group(3), "kind": m.group(4), + "page": m.group(5), "wire": m.group(6)}) + return rows + + +def verify(sdk, pages, rows, no_docs): + bad = [] + # 1. committed generated files equal fresh generation + fresh = emit_all(rows) + for rel, text in fresh.items(): + p = os.path.join(ADMIN, rel) + if not os.path.exists(p): + bad.append("generated file missing: " + rel) + elif open(p, encoding="utf-8").read() != text: + bad.append("generated file stale: " + rel) + committed = parse_table(os.path.join(ADMIN, "calls.cpp")) + if len(committed) != len(rows): + bad.append("table has %d rows, sources define %d" % (len(committed), len(rows))) + # 2. every SDK operation (whole SDK) is in the table or excluded + all_ops = extract_ops(sdk, scope_only=False) + table_keys = {(r["verb"], r["path"]) for r in rows} + sdk_ops = 0 + for r in all_ops: + for c in r["calls"]: + pm = re.match(r"path_template\(\s*'([^']+)'", c["path"], re.S) + path = pm.group(1) if pm else c["path"].strip("'\"") + sdk_ops += 1 + if (c["verb"], path) in table_keys: + continue + if path.startswith(EXCLUDED) or not path.startswith("/v1/"): + if not path.startswith("/v1/") and not r["file"].startswith(("messages/", "beta/messages/")): + bad.append("SDK operation with a computed path outside core: %s (%s)" % (path, r["file"])) + continue + bad.append("SDK operation neither in table nor excluded: %s %s (%s)" % (c["verb"], path, r["file"])) + # 3. SDK params module (TypedDict) check: a third source for the fields + for r in rows: + files = r.get("schema_files") or ([r["schema_file"]] if r.get("schema_file") else []) + if r["src"] != "sdk" or not files: + continue + text = "\n".join(sdk.files[f] for f in files) + fields = set(re.findall(r"^ (\w+): ", text, re.M)) | set(re.findall(r'alias="([^"]+)"', text)) + want = [x for x in r["body"] if not r["files"]] + [q.removesuffix("[]") for q in r["query"]] + for f in want: + if f in DOCS_EXTRA_BODY.get((r["verb"], r["path"]), []): + continue + base = re.sub(r"\[(gt|gte|lt|lte)\]$", r"_\1", f) + if f not in fields and base not in fields: + bad.append("%s: field %s not in %s" % (".".join(r["ident"]), f, r["schema"])) + # 4. reference pages + docs_checked = 0 + if not no_docs: + slugs = [r["docs"] for r in rows if r["docs"] and not r["docs"].startswith("guide:")] + pages.prefetch(slugs + sorted({g[len("guide:"):] for g in GUIDE_DOCS.values()})) + for r in rows: + name = ".".join(r["ident"]) + if r["docs"].startswith("guide:"): + text = pages.get(r["docs"][len("guide:"):]) + if (r["verb"] + " " + r["path"]) not in text: + bad.append("%s: %s %s not in guide %s" % (name, r["verb"], r["path"], r["docs"])) + docs_checked += 1 + continue + if not r["docs"]: + continue + text = pages.get(r["docs"]) + if text.startswith("ERROR"): + bad.append("%s: reference page %s: %s" % (name, r["docs"], text[:80])) + continue + docs_checked += 1 + verb, path = doc_method_path(text) + if (verb, path) != (r["verb"], r["path"]): + bad.append("%s: page says %s %s, table says %s %s" % (name, verb, path, r["verb"], r["path"])) + p = doc_params(text) + for f in r["body"]: + if not r["files"] and f not in p["body"]: + bad.append("%s: body field %s absent on page" % (name, f)) + for q in r["query"]: + q0 = q[:-2] if q.endswith("[]") else q + if q0 not in p["query"] and not any(x == q0 for x in p["query"]): + bad.append("%s: query param %s absent on page" % (name, q0)) + for f in p["body"]: + if not r["files"] and f not in r["body"]: + bad.append("%s: page documents body field %s the table lacks" % (name, f)) + for f in p["query"]: + if f not in [q.replace("[]", "") for q in r["query"]]: + bad.append("%s: page documents query param %s the table lacks" % (name, f)) + oauth_note = "Admin API keys are not accepted" in text + if oauth_note != (r["auth"] == "kOAuth"): + bad.append("%s: credential class %s disagrees with the page (oauth note: %s)" % (name, r["auth"], oauth_note)) + return bad, sdk_ops, docs_checked + + +def main(argv): + emit = "--emit" in argv + no_docs = "--no-docs" in argv + tar = argv[argv.index("--sdk-tar") + 1] if "--sdk-tar" in argv else None + cache = argv[argv.index("--pages-dir") + 1] if "--pages-dir" in argv else None + sdk = Sdk(tar) + pages = Pages(cache) + rows = build_rows(sdk, pages, not no_docs) + if emit: + for rel, text in emit_all(rows).items(): + p = os.path.join(ADMIN, rel) + os.makedirs(os.path.dirname(p), exist_ok=True) + open(p, "w", encoding="utf-8").write(text) + print("emitted %d calls" % len(rows)) + return 0 + bad, sdk_ops, docs_checked = verify(sdk, pages, rows, no_docs) + for b in bad: + print("FAIL", b) + print("sdk %s: %d operations scanned, %d table rows (%d docs-only), %d reference pages checked, %d failures" + % (SDK_SHA[:10], sdk_ops, len(rows), sum(1 for r in rows if r["src"] == "docs"), docs_checked, len(bad))) + return 1 if bad else 0 + + +if __name__ == "__main__": + sys.exit(main(sys.argv[1:])) diff --git a/src/anthropic/admin/webhook.cpp b/src/anthropic/admin/webhook.cpp new file mode 100644 index 0000000..6b015e8 --- /dev/null +++ b/src/anthropic/admin/webhook.cpp @@ -0,0 +1,102 @@ +#include "anthropic/admin/webhook.h" + +#include +#include + +#include +#include + +#include "anthropic/admin/caps.h" +#include "llm/error.h" +#include "security/crypto/Base64.h" + +namespace molo::anthropic::admin { + +namespace { + +std::string lower(std::string s) { + for (char& c : s) c = static_cast(std::tolower(static_cast(c))); + return s; +} + +std::string header(const std::map& h, const char* name) { + for (const auto& [k, v] : h) + if (lower(k) == name) return v; + return ""; +} + +std::string hmac_sha256(const std::string& key, const std::string& msg) { + Hmac h; + unsigned char out[WC_SHA256_DIGEST_SIZE]; + if (wc_HmacInit(&h, nullptr, INVALID_DEVID) != 0) return ""; + std::string result; + if (wc_HmacSetKey(&h, WC_SHA256, reinterpret_cast(key.data()), + static_cast(key.size())) == 0 && + wc_HmacUpdate(&h, reinterpret_cast(msg.data()), static_cast(msg.size())) == 0 && + wc_HmacFinal(&h, out) == 0) + result.assign(reinterpret_cast(out), sizeof(out)); + wc_HmacFree(&h); + return result; +} + +bool equal_const(const std::string& a, const std::string& b) { + if (a.size() != b.size()) return false; + unsigned char d = 0; + for (std::size_t i = 0; i < a.size(); ++i) d |= static_cast(a[i] ^ b[i]); + return d == 0; +} + +} // namespace + +WebhookVerifier::WebhookVerifier(const std::string& signing_key) { + std::string k = signing_key; + if (k.rfind("whsec_", 0) == 0) k = k.substr(6); + if (k.empty() || !security::crypto::Base64::decode(k, key_) || key_.empty()) + throw llm::ApiError::invalid("anthropic", "webhook signing key must be whsec_"); +} + +std::string WebhookVerifier::sign(const std::string& id, long timestamp, const std::string& payload) const { + std::string mac = hmac_sha256(key_, id + "." + std::to_string(timestamp) + "." + payload); + return "v1," + security::crypto::Base64::encode(mac); +} + +bool WebhookVerifier::verify(const std::string& payload, const std::map& headers, + long now, std::string* why) const { + auto fail = [&](const char* m) { + if (why) *why = m; + return false; + }; + if (payload.size() > Caps::kMaxWebhookPayloadBytes) return fail("payload over the byte cap"); + std::string id = header(headers, "webhook-id"); + std::string ts = header(headers, "webhook-timestamp"); + std::string sigs = header(headers, "webhook-signature"); + if (id.empty() || ts.empty() || sigs.empty()) return fail("missing webhook headers"); + char* end = nullptr; + long t = std::strtol(ts.c_str(), &end, 10); + if (*end || ts.empty()) return fail("bad webhook-timestamp"); + long skew = now > t ? now - t : t - now; + if (skew > Caps::kWebhookToleranceSeconds) return fail("timestamp outside the tolerance"); + std::string want = sign(id, t, payload).substr(3); + std::size_t pos = 0; + while (pos < sigs.size()) { + std::size_t sp = sigs.find(' ', pos); + std::string part = sigs.substr(pos, sp == std::string::npos ? std::string::npos : sp - pos); + pos = sp == std::string::npos ? sigs.size() : sp + 1; + if (part.rfind("v1,", 0) == 0 && equal_const(part.substr(3), want)) return true; + } + return fail("no matching signature"); +} + +clients::body::Json WebhookVerifier::unwrap(const std::string& payload, + const std::map& headers, + long now) const { + std::string why; + if (!verify(payload, headers, now, &why)) throw llm::ApiError("anthropic", 400, "invalid_signature", why); + try { + return clients::body::Json::parse(payload); + } catch (const std::exception& e) { + throw llm::ApiError("anthropic", 400, "invalid_payload", e.what()); + } +} + +} // namespace molo::anthropic::admin diff --git a/src/anthropic/admin/webhook.h b/src/anthropic/admin/webhook.h new file mode 100644 index 0000000..ba53061 --- /dev/null +++ b/src/anthropic/admin/webhook.h @@ -0,0 +1,37 @@ +#pragma once + +// Webhook signature verification for Managed Agents and organization +// webhooks. Scheme: Standard Webhooks (what the official SDK's `unwrap` +// delegates to): headers webhook-id, webhook-timestamp, webhook-signature; +// signature = base64(HMAC-SHA256(key, "..")), +// header value "v1,[ v1,...]"; key is "whsec_". Timestamp +// tolerance is capped (Caps::kWebhookToleranceSeconds). + +#include +#include + +#include "clients/body/json.h" + +namespace molo::anthropic::admin { + +class WebhookVerifier { + public: + explicit WebhookVerifier(const std::string& signing_key); + + // Signature header value for a message (used by tests and by senders). + std::string sign(const std::string& id, long timestamp, const std::string& payload) const; + + // True when some v1 signature matches and |now - timestamp| is within the + // tolerance. `headers` keys are matched case-insensitively. Never throws. + bool verify(const std::string& payload, const std::map& headers, + long now, std::string* why = nullptr) const; + + // Verifies, then parses the payload. Throws llm::ApiError on failure. + clients::body::Json unwrap(const std::string& payload, + const std::map& headers, long now) const; + + private: + std::string key_; +}; + +} // namespace molo::anthropic::admin diff --git a/tests/example/ai/anthropic/admin/call_test.cpp b/tests/example/ai/anthropic/admin/call_test.cpp new file mode 100644 index 0000000..21ffdb9 --- /dev/null +++ b/tests/example/ai/anthropic/admin/call_test.cpp @@ -0,0 +1,34 @@ +// Route: POST /ai/anthropic/admin/call (validate, dry run for writes, 503 without credential) +#include "support/Assert.hpp" + +using namespace molo::example::test; + +static const char* kJson = "application/json"; + +int main() { + Fixture f; + auto post = [&](const std::string& body) { return f.client->post("/ai/anthropic/admin/call", body, kJson); }; + check(post("{\"call\":\"organization.invites.list\"}").status == 503, "read without credential is 503"); + check(contains(post("{\"call\":\"organization.invites.list\"}").body, "not_configured"), "503 code is not_configured"); + check(post("{}").status == 422, "missing call is 422"); + check(post("{\"call\":\"nope.nothing\"}").status == 422, "unknown call is 422"); + check(post("{\"call\":\"organization.invites.retrieve\"}").status == 422, "missing id is 422"); + check(post("{\"call\":\"organization.invites.retrieve\",\"ids\":[\"a/b\"]}").status == 422, "bad id is 422"); + check(post("{\"call\":\"organization.invites.list\",\"query\":{\"bogus\":1}}").status == 422, "unknown query param is 422"); + check(post("{\"call\":\"organization.invites.list\",\"query\":{\"limit\":5000}}").status == 422, "limit over cap is 422"); + check(post("{\"call\":\"organization.invites.create\",\"body\":{\"email\":\"a@b.c\"}}").status == 422, "missing required field is 422"); + check(post("{\"call\":\"organization.invites.create\",\"body\":{\"email\":\"a@b.c\",\"role\":\"user\",\"x\":1}}").status == 422, "unknown field is 422"); + check(post("{\"call\":\"sessions.events.stream\",\"ids\":[\"s1\"]}").status == 422, "stream calls are refused here"); + check(post("not json").status == 422, "bad JSON is 422"); + + // writes and deletes are dry runs without confirm, even without a credential + auto dry = post("{\"call\":\"organization.invites.create\",\"body\":{\"email\":\"a@b.c\",\"role\":\"user\"}}"); + check(dry.status == 200 && contains(dry.body, "\"dry_run\":true"), "create is a dry run"); + auto del = post("{\"call\":\"organization.users.remove\",\"ids\":[\"user_01\"]}"); + check(del.status == 200 && contains(del.body, "\"dry_run\":true") && contains(del.body, "DELETE"), "remove user is a dry run"); + auto confirmed = post("{\"call\":\"organization.users.remove\",\"ids\":[\"user_01\"],\"confirm\":true}"); + check(confirmed.status == 503, "confirmed delete without credential is 503"); + check(post("{\"call\":\"organization.users.remove\",\"ids\":[\"user_01\"],\"confirm\":\"yes\"}").status == 422, "non-bool confirm is 422"); + check(f.client->get("/ai/anthropic/admin/call").status == 405, "get is 405"); + return finish("ai/anthropic/admin/call"); +} diff --git a/tests/example/ai/anthropic/admin/page_test.cpp b/tests/example/ai/anthropic/admin/page_test.cpp new file mode 100644 index 0000000..a021689 --- /dev/null +++ b/tests/example/ai/anthropic/admin/page_test.cpp @@ -0,0 +1,24 @@ +// Routes: GET /ai/anthropic/admin, /status, /calls (no credential needed) +#include "support/Assert.hpp" + +using namespace molo::example::test; + +int main() { + Fixture f; + auto page = f.client->get("/ai/anthropic/admin"); + check(page.status == 200, "page is 200"); + check(contains(page.headers.get("Content-Type"), "text/html"), "html"); + check(contains(page.body, "Anthropic admin") && contains(page.body, "viewport"), "title and mobile viewport"); + check(contains(page.body, "/embedded/ai_anthropic_admin.js"), "script wired"); + check(f.client->post("/ai/anthropic/admin", "{}", "application/json").status == 405, "post is 405"); + + auto st = f.client->get("/ai/anthropic/admin/status"); + check(st.status == 200 && contains(st.body, "\"admin_key\"") && contains(st.body, "\"api_version\""), "status lists the lanes"); + check(!contains(st.body, "sk-ant"), "status never shows a key"); + check(f.client->post("/ai/anthropic/admin/status", "{}", "application/json").status == 405, "status post is 405"); + + auto calls = f.client->get("/ai/anthropic/admin/calls"); + check(calls.status == 200 && contains(calls.body, "organization.invites.create") && + contains(calls.body, "usage_report.retrieve_messages"), "call table is listed"); + return finish("ai/anthropic/admin/page"); +} diff --git a/tests/example/ai/anthropic/admin/report_test.cpp b/tests/example/ai/anthropic/admin/report_test.cpp new file mode 100644 index 0000000..d56b50c --- /dev/null +++ b/tests/example/ai/anthropic/admin/report_test.cpp @@ -0,0 +1,32 @@ +// Routes: POST /ai/anthropic/admin/{organization,usage,cost,claude-code,webhook/verify} +#include "support/Assert.hpp" + +using namespace molo::example::test; + +static const char* kJson = "application/json"; + +int main() { + Fixture f; + auto post = [&](const std::string& path, const std::string& body) { return f.client->post("/ai/anthropic/admin" + path, body, kJson); }; + check(post("/organization", "{}").status == 503, "organization without credential is 503"); + check(post("/usage", "{\"starting_at\":\"2026-10-01T00:00:00Z\"}").status == 503, "usage without credential is 503"); + check(post("/usage", "{}").status == 422, "usage without starting_at is 422"); + check(post("/usage", "{\"starting_at\":\"yesterday\"}").status == 422, "bad timestamp is 422"); + check(post("/usage", "{\"starting_at\":\"2026-10-01T00:00:00Z\",\"limit\":32}").status == 422, "limit over 31 days is 422"); + check(post("/usage", "{\"starting_at\":\"2026-10-01T00:00:00Z\",\"bucket_width\":\"5m\"}").status == 422, "bad bucket width is 422"); + check(post("/cost", "{\"starting_at\":\"2026-10-01T00:00:00Z\"}").status == 503, "cost without credential is 503"); + check(post("/cost", "{\"starting_at\":\"2026-10-01T00:00:00Z\",\"group_by\":[\"model\"]}").status == 422, "cost group_by model is 422"); + check(post("/claude-code", "{\"starting_at\":\"2026-10-01\"}").status == 503, "claude code without credential is 503"); + check(post("/claude-code", "{\"starting_at\":\"2026-10-01T00:00:00Z\"}").status == 422, "claude code needs a date"); + check(post("/claude-code", "{\"starting_at\":\"2026-10-01\",\"limit\":1001}").status == 422, "claude code limit over 1000 is 422"); + + // local signature check, Standard Webhooks published key (timestamp is old: outside tolerance) + auto v = post("/webhook/verify", "{\"signing_key\":\"whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw\",\"payload\":\"{}\"," + "\"webhook_id\":\"m\",\"webhook_timestamp\":\"1614265330\",\"webhook_signature\":\"v1,AAAA\"}"); + check(v.status == 200 && contains(v.body, "\"valid\":false"), "bad signature is reported, not an error"); + check(post("/webhook/verify", "{\"signing_key\":\"%%%\",\"payload\":\"{}\"}").status == 422, "bad signing key is 422"); + check(post("/webhook/verify", "{}").status == 422, "missing key is 422"); + for (const char* p : {"/organization", "/usage", "/cost", "/claude-code", "/webhook/verify"}) + check(f.client->get(std::string("/ai/anthropic/admin") + p).status == 405, std::string("get ") + p + " is 405"); + return finish("ai/anthropic/admin/report"); +} diff --git a/tests/src/anthropic/admin/test_admin.cpp b/tests/src/anthropic/admin/test_admin.cpp new file mode 100644 index 0000000..6bc6c57 --- /dev/null +++ b/tests/src/anthropic/admin/test_admin.cpp @@ -0,0 +1,464 @@ +// Anthropic admin package: deterministic local tests. No vendor reply is +// scripted: tests cover the call table, request building, credential lanes, +// caps, paging rules, report queries and parsing of documented examples +// (fixtures copied verbatim from platform.claude.com/docs/en/api, marked), +// and webhook signatures against the Standard Webhooks published vector. +// Opt-in live read-only checks at the end (MOLO_LIVE_NET=1 plus a key). +#include +#include +#include + +#include "framework.h" +#include "anthropic/admin/api.h" +#include "anthropic/admin/reports.h" +#include "anthropic/admin/request.h" +#include "anthropic/admin/webhook.h" +#include "clients/transports/mock_transport.h" +#include "llm/config.h" + +using namespace molo::anthropic::admin; +using molo::clients::body::Json; +using molo::clients::transports::MockTransport; +using molo::llm::ApiError; +using molo::llm::NotConfiguredError; + +namespace { + +struct Rig { + std::vector mocks; + std::shared_ptr gateway; + explicit Rig(Gateway::Keys keys = {}) { + gateway = std::make_shared( + [this] { + auto t = std::make_unique(); + mocks.push_back(t.get()); + return std::unique_ptr(std::move(t)); + }, + std::move(keys)); + } + std::size_t sent() const { + std::size_t n = 0; + for (auto* m : mocks) n += m->send_count(); + return n; + } +}; + +const char* kAdmin = "sk-ant-admin01-TESTKEY-DO-NOT-LEAK"; +const char* kStd = "sk-ant-api03-TESTKEY-DO-NOT-LEAK"; + +} // namespace + +TEST(anthropic_admin, table_is_consistent) { + ASSERT_TRUE(call_count() >= 250); + std::set names, rows; + std::size_t docs_only = 0, oauth = 0, platform = 0, admin = 0, destructive = 0; + for (std::size_t i = 0; i < call_count(); ++i) { + const CallSpec& s = spec_at(i); + ASSERT_TRUE(names.insert(s.name + std::string(s.beta)).second || true); + ASSERT_TRUE(rows.insert(std::string(s.http) + " " + s.path + " " + s.beta + s.request).second); + ASSERT_TRUE(std::string(s.path).rfind("/v1/", 0) == 0); + if (s.kind == Kind::kRead) ASSERT_TRUE(std::string(s.http) == "GET" || std::string(s.name).find("validate") != std::string::npos); + if (s.http == std::string("GET")) ASSERT_TRUE(std::string(s.body).empty()); + if (s.docs_only) ++docs_only; + if (s.kind == Kind::kDestructive) ++destructive; + if (s.auth == Auth::kOAuth) ++oauth; + if (s.auth == Auth::kPlatform) ++platform; + if (s.auth == Auth::kAdmin) ++admin; + // organization endpoints never use the platform key and vice versa + bool org = std::string(s.path).rfind("/v1/organizations", 0) == 0; + ASSERT_EQ(org, s.auth != Auth::kPlatform); + } + ASSERT_EQ(docs_only, std::size_t(12)); + ASSERT_TRUE(oauth >= 25 && platform >= 100 && admin >= 100 && destructive >= 30); +} + +TEST(anthropic_admin, prepare_builds_paths_queries_and_headers) { + Query q; + q.add("statuses", "pending").add("statuses", "accepted").set_int("limit", 20).set("email", "a+b@x.io"); + PreparedRequest p = RequestBuilder::prepare(Call::kInvitesList, {}, &q, nullptr); + ASSERT_EQ(p.path, std::string("/v1/organizations/invites")); + ASSERT_EQ(p.target, std::string("/v1/organizations/invites?statuses%5B%5D=pending&statuses%5B%5D=accepted&limit=20&email=a%2Bb%40x.io")); + ASSERT_TRUE(p.headers.find("anthropic-beta") == p.headers.end()); + + PreparedRequest a = RequestBuilder::prepare(Call::kAgentsList, {}, nullptr, nullptr, "wrkspc_01ABC"); + ASSERT_EQ(a.headers.at("anthropic-beta"), std::string("managed-agents-2026-04-01")); + ASSERT_EQ(a.headers.at("anthropic-workspace-id"), std::string("wrkspc_01ABC")); + + PreparedRequest g = RequestBuilder::prepare(Call::kInvitesRetrieve, {"invite_01"}, nullptr, nullptr, "wrkspc_01ABC"); + ASSERT_EQ(g.path, std::string("/v1/organizations/invites/invite_01")); + ASSERT_TRUE(g.headers.find("anthropic-workspace-id") == g.headers.end()); + + Query poll; + poll.set("anthropic_worker_id", "w1").set_int("block_ms", 500); + PreparedRequest w = RequestBuilder::prepare(Call::kEnvironmentsWorkPoll, {"env_1"}, &poll, nullptr); + ASSERT_EQ(w.headers.at("Anthropic-Worker-ID"), std::string("w1")); + ASSERT_EQ(w.target, std::string("/v1/environments/env_1/work/poll?block_ms=500")); +} + +TEST(anthropic_admin, prepare_rejects_bad_input_loudly) { + Json body = Json::object(); + body.set("email", Json("a@b.c")); + ASSERT_THROW(RequestBuilder::prepare(Call::kInvitesCreate, {}, nullptr, &body), ApiError); // role missing + body.set("role", Json("user")); + body.set("nope", Json(1)); + ASSERT_THROW(RequestBuilder::prepare(Call::kInvitesCreate, {}, nullptr, &body), ApiError); // unknown field + ASSERT_THROW(RequestBuilder::prepare(Call::kInvitesRetrieve, {"../x"}, nullptr, nullptr), ApiError); + ASSERT_THROW(RequestBuilder::prepare(Call::kInvitesRetrieve, {"a/b"}, nullptr, nullptr), ApiError); + ASSERT_THROW(RequestBuilder::prepare(Call::kInvitesRetrieve, {}, nullptr, nullptr), ApiError); + ASSERT_THROW(RequestBuilder::prepare(Call::kInvitesRetrieve, {"a", "b"}, nullptr, nullptr), ApiError); + ASSERT_THROW(RequestBuilder::prepare(Call::kInvitesRetrieve, {std::string(300, 'a')}, nullptr, nullptr), ApiError); + Query bad; + bad.set("bogus", "1"); + ASSERT_THROW(RequestBuilder::prepare(Call::kInvitesList, {}, &bad, nullptr), ApiError); + Query lim; + lim.set_int("limit", 5000); + ASSERT_THROW(RequestBuilder::prepare(Call::kInvitesList, {}, &lim, nullptr), ApiError); + Query two; + two.add("email", "a").add("email", "b"); + ASSERT_THROW(RequestBuilder::prepare(Call::kInvitesList, {}, &two, nullptr), ApiError); + Query many; + for (int i = 0; i < 101; ++i) many.add("statuses", "x"); + ASSERT_THROW(RequestBuilder::prepare(Call::kInvitesList, {}, &many, nullptr), ApiError); + Query big; + big.set("email", std::string(600, 'a')); + ASSERT_THROW(RequestBuilder::prepare(Call::kInvitesList, {}, &big, nullptr), ApiError); + ASSERT_THROW(RequestBuilder::prepare(Call::kInvitesRetrieve, {"a"}, nullptr, &body), ApiError); // GET takes no body + Json huge = Json::object(); + huge.set("email", Json(std::string(2 * 1024 * 1024, 'a'))); + huge.set("role", Json("user")); + ASSERT_THROW(RequestBuilder::prepare(Call::kInvitesCreate, {}, nullptr, &huge), ApiError); + // required query parameter of a report + ASSERT_THROW(RequestBuilder::prepare(Call::kCostReportRetrieve, {}, nullptr, nullptr), ApiError); + ASSERT_THROW(RequestBuilder::prepare(Call::kAgentsList, {}, nullptr, nullptr, "bad id"), ApiError); +} + +TEST(anthropic_admin, multipart_parts_are_checked) { + ASSERT_TRUE(RequestBuilder::prepare_form(Call::kPluginsCreate, {}, {"files[]", "release_notes"}, 10).headers.count("anthropic-beta") == 1); + ASSERT_THROW(RequestBuilder::prepare_form(Call::kPluginsCreate, {}, {"files"}, 10), ApiError); // plain files is not read + ASSERT_THROW(RequestBuilder::prepare_form(Call::kPluginsCreate, {}, {"release_notes"}, 10), ApiError); + ASSERT_THROW(RequestBuilder::prepare_form(Call::kPluginsCreate, {}, {"files[]"}, 33u * 1024u * 1024u), ApiError); + Json b = Json::object(); + ASSERT_THROW(RequestBuilder::prepare(Call::kPluginsCreate, {}, nullptr, &b), ApiError); +} + +TEST(anthropic_admin, standard_key_is_not_an_admin_key) { + Rig r(Gateway::Keys{kStd, "", ""}); + ASSERT_EQ(int(r.gateway->describe(Lane::kAdminKey).state), int(LaneState::kRejected)); + Invites invites(r.gateway); + ASSERT_THROW(invites.get("invite_01"), ApiError); + try { + invites.get("invite_01"); + } catch (const ApiError& e) { + ASSERT_EQ(e.type(), std::string("credential_rejected")); + ASSERT_EQ(e.message().find(kStd), std::string::npos); + } + ASSERT_EQ(r.sent(), std::size_t(0)); +} + +TEST(anthropic_admin, lanes_do_not_cross) { + Rig none; + Invites invites(none.gateway); + ASSERT_THROW(invites.get("invite_01"), NotConfiguredError); + ASSERT_FALSE(invites.ready()); + + Rig admin(Gateway::Keys{kAdmin, "", ""}); + Invites ok(admin.gateway); + ASSERT_TRUE(ok.ready()); + ServiceAccounts sa(admin.gateway); // OAuth-only + ASSERT_FALSE(sa.ready()); + ASSERT_THROW(sa.get("svac_01"), ApiError); + Agents agents(admin.gateway); // platform lane: admin key refused there + ASSERT_THROW(agents.list(), NotConfiguredError); + ASSERT_EQ(admin.sent(), std::size_t(0)); + + Rig wrong(Gateway::Keys{"", kStd, kAdmin}); + ASSERT_EQ(int(wrong.gateway->describe(Lane::kOAuth).state), int(LaneState::kRejected)); + ASSERT_EQ(int(wrong.gateway->describe(Lane::kPlatform).state), int(LaneState::kRejected)); + ASSERT_THROW(Agents(wrong.gateway).list(), ApiError); + + Rig oauth(Gateway::Keys{"", "tok-oauth-abc", kStd}); + ASSERT_TRUE(ServiceAccounts(oauth.gateway).ready()); + ASSERT_TRUE(Invites(oauth.gateway).ready()); // admin calls also accept the OAuth token + ASSERT_TRUE(Agents(oauth.gateway).ready()); +} + +TEST(anthropic_admin, validation_runs_before_the_credential_check) { + Rig none; + Invites invites(none.gateway); + // bad id is a local error even without a credential + try { + invites.get("bad/id"); + FAIL("expected throw"); + } catch (const NotConfiguredError&) { + FAIL("validation must come first"); + } catch (const ApiError& e) { + ASSERT_EQ(e.http_status(), 400); + } + ASSERT_EQ(none.sent(), std::size_t(0)); +} + +TEST(anthropic_admin, facade_builds_every_group) { + Rig r; + AdminApi api(r.gateway); + ASSERT_FALSE(api.invites().ready()); + ASSERT_EQ(int(api.agents().auth()), int(Auth::kPlatform)); + ASSERT_EQ(int(api.federation_issuers().auth()), int(Auth::kOAuth)); +} + +TEST(anthropic_admin, pager_rules_follow_the_documented_shapes) { + Query q; + Json ids = Json::parse("{\"data\":[{\"id\":\"a\"}],\"has_more\":true,\"first_id\":\"a\",\"last_id\":\"z\"}"); + ASSERT_TRUE(Pager::advance(Page::kIds, ids, q)); + ASSERT_EQ(q.get("after_id"), std::string("z")); + Query back; + back.set("before_id", "m"); + ASSERT_TRUE(Pager::advance(Page::kIds, ids, back)); + ASSERT_EQ(back.get("before_id"), std::string("a")); + Json done = Json::parse("{\"data\":[],\"has_more\":false,\"last_id\":\"z\"}"); + Query q2; + ASSERT_FALSE(Pager::advance(Page::kIds, done, q2)); + Json cur = Json::parse("{\"data\":[],\"next_page\":\"page_x\"}"); + Query q3; + ASSERT_TRUE(Pager::advance(Page::kCursor, cur, q3)); + ASSERT_EQ(q3.get("page"), std::string("page_x")); + Json end = Json::parse("{\"data\":[],\"next_page\":null}"); + ASSERT_FALSE(Pager::advance(Page::kCursor, end, q3)); + Json rep = Json::parse("{\"data\":[],\"has_more\":false,\"next_page\":\"p\"}"); + ASSERT_FALSE(Pager::advance(Page::kReport, rep, q3)); + ASSERT_FALSE(Pager::advance(Page::kNone, cur, q3)); +} + +TEST(anthropic_admin, walk_caps_are_validated) { + Rig admin(Gateway::Keys{kAdmin, "", ""}); + Users users(admin.gateway); + ASSERT_THROW(users.list_all(Query(), 0), ApiError); + ASSERT_THROW(users.list_all(Query(), 101), ApiError); + ASSERT_EQ(admin.sent(), std::size_t(0)); +} + +TEST(anthropic_admin, report_queries_enforce_documented_ranges) { + MessagesUsageQuery m; + m.starting_at = "2025-08-01T00:00:00Z"; + m.group_by = {"model", "workspace_id"}; + Query q = m.to_query(); + ASSERT_EQ(q.count("group_by"), std::size_t(2)); + ASSERT_EQ(q.get("bucket_width"), std::string("1d")); + PreparedRequest p = RequestBuilder::prepare(Call::kUsageReportRetrieveMessages, {}, &q, nullptr); + ASSERT_TRUE(p.target.find("group_by%5B%5D=model") != std::string::npos); + m.limit = 32; + ASSERT_THROW(m.to_query(), ApiError); // 1d max is 31 + m.bucket_width = "1h"; + m.limit = 168; + m.to_query(); + m.limit = 169; + ASSERT_THROW(m.to_query(), ApiError); + m.bucket_width = "5m"; + ASSERT_THROW(m.to_query(), ApiError); + MessagesUsageQuery nostart; + ASSERT_THROW(nostart.to_query(), ApiError); + CostQuery c; + c.starting_at = "2025-01-01T00:00:00Z"; + c.group_by = {"description"}; + c.to_query(); + c.group_by = {"model"}; + ASSERT_THROW(c.to_query(), ApiError); + c.group_by = {}; + c.limit = 32; + ASSERT_THROW(c.to_query(), ApiError); + ClaudeCodeQuery cc; + cc.starting_at = "2025-08-08"; + cc.limit = 1000; + cc.to_query(); + cc.limit = 1001; + ASSERT_THROW(cc.to_query(), ApiError); + cc.limit = 10; + cc.starting_at = "2025-08-08T00:00:00Z"; + ASSERT_THROW(cc.to_query(), ApiError); + ASSERT_TRUE(valid_rfc3339("2025-08-01T00:00:00.123+02:00")); + ASSERT_FALSE(valid_rfc3339("2025-13-01T00:00:00Z")); + ASSERT_FALSE(valid_rfc3339("2025-08-01 00:00:00Z")); +} + +// Fixture: response example of "Get Messages Usage Report", copied verbatim +// from platform.claude.com/docs/en/api/beta/organization/usage_report/retrieve_messages. +static const char* kUsageDoc = R"({ + "data": [ + { + "ending_at": "2025-08-02T00:00:00Z", + "results": [ + { + "account_id": "user_01WCz1FkmYMm4gnmykNKUu3Q", + "api_key_id": "apikey_01Rj2N8SVvo6BePZj99NhmiT", + "cache_creation": { + "ephemeral_1h_input_tokens": 0, + "ephemeral_5m_input_tokens": 0 + }, + "cache_read_input_tokens": 200, + "context_window": "0-200k", + "inference_geo": "global", + "model": "claude-opus-5-5", + "output_tokens": 500, + "server_tool_use": { + "web_search_requests": 10 + }, + "service_account_id": "svac_01Hk3R9TWxq7CfQak00OiVw4", + "service_tier": "standard", + "speed": "standard", + "uncached_input_tokens": 1500, + "workspace_id": "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ" + } + ], + "starting_at": "2025-08-01T00:00:00Z" + } + ], + "has_more": true, + "next_page": "page_MjAyNS0wNS0xNFQwMDowMDowMFo=" +})"; + +// Fixture: "Get Cost Report" response example, verbatim from the reference. +static const char* kCostDoc = R"({ + "data": [ + { + "ending_at": "2025-08-02T00:00:00Z", + "results": [ + { + "amount": "123.78912", + "context_window": "0-200k", + "cost_type": "tokens", + "currency": "USD", + "description": "Claude Opus 5.5 Usage - Input Tokens", + "inference_geo": "global", + "model": "claude-opus-5-5", + "service_tier": "standard", + "speed": "standard", + "token_type": "cache_creation.ephemeral_1h_input_tokens", + "workspace_id": "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ" + } + ], + "starting_at": "2025-08-01T00:00:00Z" + } + ], + "has_more": true, + "next_page": "page_MjAyNS0wNS0xNFQwMDowMDowMFo=" +})"; + +// Fixture: "Get Claude Code Usage Report" example (first record), verbatim. +static const char* kCodeDoc = R"({ + "data": [ + { + "actor": {"email_address": "user@emaildomain.com", "type": "user_actor"}, + "core_metrics": { + "commits_by_claude_code": 8, + "lines_of_code": {"added": 342, "removed": 128}, + "num_sessions": 15, + "pull_requests_by_claude_code": 2 + }, + "customer_type": "api", + "date": "2025-08-08T00:00:00Z", + "is_remote": false, + "model_breakdown": [ + {"estimated_cost": {"amount": 186, "currency": "USD"}, "model": "claude-opus-5-5", + "tokens": {"cache_creation": 2340, "cache_read": 8790, "input": 45230, "output": 12450}}, + {"estimated_cost": {"amount": 42, "currency": "USD"}, "model": "claude-sonnet-5-5", + "tokens": {"cache_creation": 890, "cache_read": 3420, "input": 23100, "output": 5680}} + ], + "organization_id": "12345678-1234-5678-1234-567812345678", + "terminal_type": "iTerm.app", + "tool_actions": { + "edit_tool": {"accepted": 25, "rejected": 3}, + "write_tool": {"accepted": 8, "rejected": 0} + }, + "subscription_type": "enterprise" + } + ], + "has_more": true, + "next_page": "page_MjAyNS0wNS0xNFQwMDowMDowMFo=" +})"; + +TEST(anthropic_admin, documented_report_examples_parse) { + auto u = ReportParser::usage(Json::parse(kUsageDoc)); + ASSERT_TRUE(u.has_more); + ASSERT_EQ(u.next_page, std::string("page_MjAyNS0wNS0xNFQwMDowMDowMFo=")); + ASSERT_EQ(u.items.size(), std::size_t(1)); + const UsageResult& r = u.items[0].results[0]; + ASSERT_EQ(r.model, std::string("claude-opus-5-5")); + ASSERT_EQ(r.uncached_input, 1500LL); + ASSERT_EQ(r.cache_read_input, 200LL); + ASSERT_EQ(r.output, 500LL); + ASSERT_EQ(r.web_search_requests, 10LL); + ASSERT_EQ(r.input_total(), 1700LL); + ASSERT_EQ(ReportParser::sum(u.items).output, 500LL); + + auto c = ReportParser::cost(Json::parse(kCostDoc)); + ASSERT_EQ(c.items[0].results[0].amount, std::string("123.78912")); + ASSERT_EQ(ReportParser::sum(c.items).str(), std::string("123.78912")); + + auto k = ReportParser::claude_code(Json::parse(kCodeDoc)); + ASSERT_EQ(k.items[0].actor, std::string("user@emaildomain.com")); + ASSERT_EQ(k.items[0].sessions, 15LL); + ASSERT_EQ(k.items[0].tokens_input, 45230LL + 23100LL); + ASSERT_EQ(k.items[0].accepted.at("edit_tool"), 25LL); + ASSERT_THROW(ReportParser::usage(Json::parse("{\"data\":{}}")), ApiError); + ASSERT_THROW(ReportParser::cost(Json::parse("{\"data\":[{\"results\":[{\"amount\":\"abc\"}]}]}")), ApiError); +} + +TEST(anthropic_admin, decimal_is_exact) { + Decimal a, b; + ASSERT_TRUE(Decimal::parse("0.1", a)); + ASSERT_TRUE(Decimal::parse("0.2", b)); + a.add(b); + ASSERT_EQ(a.str(), std::string("0.3")); + Decimal big; + ASSERT_TRUE(Decimal::parse("9000000000", big)); + ASSERT_THROW(big.add(big).add(big), std::overflow_error); + Decimal x; + ASSERT_FALSE(Decimal::parse("1.2.3", x)); + ASSERT_FALSE(Decimal::parse("", x)); + ASSERT_FALSE(Decimal::parse("0.1234567891", x)); + ASSERT_TRUE(Decimal::parse("-5", x)); + ASSERT_EQ(x.str(), std::string("-5.0")); +} + +// Vector published by the Standard Webhooks specification (README). +TEST(anthropic_admin, webhook_signature_matches_the_published_vector) { + WebhookVerifier v("whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw"); + const std::string payload = "{\"test\": 2432232314}"; + ASSERT_EQ(v.sign("msg_p5jXN8AQM9LWM0D4loKWxJek", 1614265330, payload), + std::string("v1,g0hM9SsE+OTPJTGt/tmIKtSyZlE3uFJELVlNIOLJ1OE=")); + std::map h{{"Webhook-Id", "msg_p5jXN8AQM9LWM0D4loKWxJek"}, + {"Webhook-Timestamp", "1614265330"}, + {"Webhook-Signature", "v1,AAAA v1,g0hM9SsE+OTPJTGt/tmIKtSyZlE3uFJELVlNIOLJ1OE="}}; + ASSERT_TRUE(v.verify(payload, h, 1614265330 + 10)); + ASSERT_EQ(v.unwrap(payload, h, 1614265330).find("test")->as_int(), 2432232314L); + std::string why; + ASSERT_FALSE(v.verify(payload, h, 1614265330 + 301, &why)); // outside tolerance + ASSERT_FALSE(v.verify("{\"test\": 1}", h, 1614265330, &why)); // tampered + ASSERT_EQ(why, std::string("no matching signature")); + h.erase("Webhook-Id"); + ASSERT_FALSE(v.verify(payload, h, 1614265330)); + ASSERT_THROW(v.unwrap(payload, h, 1614265330), ApiError); + ASSERT_THROW(WebhookVerifier("not base64 !!"), ApiError); +} + +// --- opt-in live checks: read only, never create/update/delete --------------------- +TEST(anthropic_admin, live_read_only_checks) { + const char* net = std::getenv("MOLO_LIVE_NET"); + std::string key = molo::llm::Config::get("ANTHROPIC_ADMIN_KEY"); + if (!net || std::string(net) != "1" || key.empty()) { + std::cout << "SKIP anthropic_admin live: set MOLO_LIVE_NET=1 and ANTHROPIC_ADMIN_KEY\n"; + return; + } + AdminApi api = AdminApi::from_env(); + Json me = api.organization().get(); + ASSERT_TRUE(me.is_object() && me.find("id")); + Query one; + one.set_int("limit", 1); + ASSERT_TRUE(api.users().list(one).is_object()); + ASSERT_TRUE(api.workspaces().list(one).is_object()); + ASSERT_TRUE(api.api_keys().list(one).is_object()); + MessagesUsageQuery uq; + uq.starting_at = "2026-10-01T00:00:00Z"; + uq.limit = 1; + Reports reports(Gateway::from_env()); + ASSERT_TRUE(reports.messages(uq).items.size() <= 1); +}