feat(clients): openai admin: organization admin API, usage, costs, audit logs, webhooks
121-call table checked against the OpenAI OpenAPI document, admin-key-only client, destructive guards, WebhookVerifier (Standard Webhooks HMAC-SHA256), demo routes under /ai/openai/admin, local and opt-in live tests. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
// Base of every resource service. One `execute` runs one row of the call
|
||||
// table: it checks the credential kind of the call, refuses destructive calls
|
||||
// without confirm=true, renders the path from validated ids, checks query
|
||||
// names and body fields against the row, and sends the request. A service is
|
||||
// built for one credential kind; running a call of the other kind throws.
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "clients/body/json.h"
|
||||
#include "llm/api_client.h"
|
||||
#include "openai/admin/admin_client.h"
|
||||
#include "openai/admin/calls.h"
|
||||
#include "openai/admin/page.h"
|
||||
#include "openai/admin/query.h"
|
||||
|
||||
namespace molo::openai::admin {
|
||||
|
||||
class AdminService : public llm::Service {
|
||||
public:
|
||||
using Json = clients::body::Json;
|
||||
|
||||
AuthKind auth_kind() const { return auth_; }
|
||||
|
||||
protected:
|
||||
AdminService(std::shared_ptr<AdminApiClient> client);
|
||||
AdminService(std::shared_ptr<ProjectApiClient> client);
|
||||
|
||||
// Runs one table row. `ids` fill the {placeholders} in order. `body` must be
|
||||
// an object whose keys are allowed by the row and cover its required fields.
|
||||
Json execute(Call call, const std::vector<std::string>& ids = {}, const Query& query = {},
|
||||
const Json* body = nullptr, bool confirm = false);
|
||||
// A cursor list walked to the page / item ceilings (WalkResult::truncated).
|
||||
WalkResult walk(Call call, const std::vector<std::string>& ids, const Query& base,
|
||||
const std::string& cursor_param, const std::string& start_cursor = "");
|
||||
|
||||
static Json object_of(std::initializer_list<std::pair<const char*, Json>> fields);
|
||||
|
||||
private:
|
||||
AuthKind auth_;
|
||||
};
|
||||
|
||||
} // namespace molo::openai::admin
|
||||
Reference in New Issue
Block a user