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,105 @@
|
||||
#pragma once
|
||||
|
||||
// Projects and everything that hangs off one: users, service accounts, API
|
||||
// keys, rate limits, groups, data retention, model and hosted tool
|
||||
// permissions, spend limit. Destructive methods take `confirm`, no default.
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "openai/admin/admin_service.h"
|
||||
#include "openai/admin/requests.h"
|
||||
|
||||
namespace molo::openai::admin {
|
||||
|
||||
class Projects : public AdminService {
|
||||
public:
|
||||
explicit Projects(std::shared_ptr<AdminApiClient> client) : AdminService(std::move(client)) {}
|
||||
Json list(const ListOptions& options = {}, bool include_archived = false);
|
||||
Json get(const std::string& project_id);
|
||||
Json create(const ProjectCreate& project);
|
||||
Json update(const std::string& project_id, const ProjectUpdate& update);
|
||||
// Archiving a project cannot be undone through the API.
|
||||
Json archive(const std::string& project_id, bool confirm);
|
||||
};
|
||||
|
||||
class ProjectUsers : public AdminService {
|
||||
public:
|
||||
explicit ProjectUsers(std::shared_ptr<AdminApiClient> client) : AdminService(std::move(client)) {}
|
||||
Json list(const std::string& project_id, const ListOptions& options = {});
|
||||
Json get(const std::string& project_id, const std::string& user_id);
|
||||
Json create(const std::string& project_id, const ProjectUserCreate& user);
|
||||
Json set_role(const std::string& project_id, const std::string& user_id, const std::string& role);
|
||||
Json destroy(const std::string& project_id, const std::string& user_id, bool confirm);
|
||||
};
|
||||
|
||||
class ServiceAccounts : public AdminService {
|
||||
public:
|
||||
explicit ServiceAccounts(std::shared_ptr<AdminApiClient> client) : AdminService(std::move(client)) {}
|
||||
Json list(const std::string& project_id, const ListOptions& options = {});
|
||||
Json get(const std::string& project_id, const std::string& service_account_id);
|
||||
// The response carries the API key value once, unless create_service_account_only.
|
||||
Json create(const std::string& project_id, const ServiceAccountCreate& account);
|
||||
Json update(const std::string& project_id, const std::string& service_account_id,
|
||||
const ServiceAccountUpdate& update);
|
||||
Json destroy(const std::string& project_id, const std::string& service_account_id, bool confirm);
|
||||
// Mints a new API key for the service account (value returned once).
|
||||
Json create_key(const std::string& project_id, const std::string& service_account_id,
|
||||
const ServiceAccountKeyCreate& key);
|
||||
};
|
||||
|
||||
class ProjectApiKeys : public AdminService {
|
||||
public:
|
||||
explicit ProjectApiKeys(std::shared_ptr<AdminApiClient> client) : AdminService(std::move(client)) {}
|
||||
// owner_project_access: active | inactive | any, or "" for the server default.
|
||||
Json list(const std::string& project_id, const ListOptions& options = {},
|
||||
const std::string& owner_project_access = "");
|
||||
Json get(const std::string& project_id, const std::string& api_key_id);
|
||||
Json update(const std::string& project_id, const std::string& api_key_id,
|
||||
const ProjectApiKeyUpdate& update);
|
||||
Json destroy(const std::string& project_id, const std::string& api_key_id, bool confirm);
|
||||
};
|
||||
|
||||
class RateLimits : public AdminService {
|
||||
public:
|
||||
explicit RateLimits(std::shared_ptr<AdminApiClient> client) : AdminService(std::move(client)) {}
|
||||
Json list(const std::string& project_id, const ListOptions& options = {});
|
||||
Json update(const std::string& project_id, const std::string& rate_limit_id,
|
||||
const RateLimitUpdate& update);
|
||||
};
|
||||
|
||||
class ProjectGroups : public AdminService {
|
||||
public:
|
||||
explicit ProjectGroups(std::shared_ptr<AdminApiClient> client) : AdminService(std::move(client)) {}
|
||||
Json list(const std::string& project_id, const ListOptions& options = {});
|
||||
Json add(const std::string& project_id, const std::string& group_id, const std::string& role);
|
||||
// group_type: group | tenant_group, or "" for the server default.
|
||||
Json get(const std::string& project_id, const std::string& group_id,
|
||||
const std::string& group_type = "");
|
||||
Json remove(const std::string& project_id, const std::string& group_id, bool confirm);
|
||||
};
|
||||
|
||||
// Per-project policy: data retention, model permissions, hosted tool
|
||||
// permissions, hard spend limit.
|
||||
class ProjectPolicies : public AdminService {
|
||||
public:
|
||||
explicit ProjectPolicies(std::shared_ptr<AdminApiClient> client) : AdminService(std::move(client)) {}
|
||||
|
||||
Json data_retention(const std::string& project_id);
|
||||
// Changes how OpenAI retains the project's data: needs confirm.
|
||||
Json set_data_retention(const std::string& project_id, const std::string& retention_type,
|
||||
bool confirm);
|
||||
|
||||
Json model_permissions(const std::string& project_id);
|
||||
Json set_model_permissions(const std::string& project_id, const ModelPermissions& permissions);
|
||||
Json clear_model_permissions(const std::string& project_id, bool confirm);
|
||||
|
||||
Json hosted_tool_permissions(const std::string& project_id);
|
||||
Json set_hosted_tool_permissions(const std::string& project_id,
|
||||
const HostedToolPermissions& permissions);
|
||||
|
||||
Json spend_limit(const std::string& project_id);
|
||||
Json set_spend_limit(const std::string& project_id, const SpendLimitSpec& limit);
|
||||
Json clear_spend_limit(const std::string& project_id, bool confirm);
|
||||
};
|
||||
|
||||
} // namespace molo::openai::admin
|
||||
Reference in New Issue
Block a user