#pragma once // Typed request bodies. Every class validates in `to_json()` (ranges and // enums taken from the OpenAPI document, ceilings from AdminCaps) and throws // llm::ApiError::invalid before anything is sent. Optional fields that are // unset are left out of the body, never sent as null. #include #include #include #include #include #include "clients/body/json.h" namespace molo::openai::admin { using Json = clients::body::Json; // Longest expiry the API accepts for a key (1 year, spec maximum). constexpr std::int64_t kMaxKeyExpirySeconds = 31536000; struct ProjectGrant { std::string id; std::string role; // member | owner }; struct InviteRequest { std::string email; std::string role; // reader | owner std::vector projects; Json to_json() const; }; struct ProjectCreate { std::string name; std::string residency; // PublicProjectResidency value, optional std::string geography; // deprecated spelling, optional std::string external_key_id; // optional Json to_json() const; }; struct ProjectUpdate { std::string name; std::string external_key_id; std::string geography; Json to_json() const; // at least one field }; struct ProjectUserCreate { std::string user_id; // exactly one of user_id / email std::string email; std::string role; // owner | member Json to_json() const; }; struct UserUpdate { std::string role; // owner | reader std::string role_id; std::string technical_level; std::string developer_persona; Json to_json() const; // at least one field }; struct ServiceAccountCreate { std::string name; std::optional create_service_account_only; std::optional expires_in_seconds; Json to_json() const; }; struct ServiceAccountUpdate { std::string name; std::string role; // member | owner Json to_json() const; // at least one field }; struct ServiceAccountKeyCreate { std::string name; std::vector scopes; std::optional expires_in_seconds; Json to_json() const; }; struct ProjectApiKeyUpdate { std::optional expires_in_seconds; std::optional> scopes; // empty vector removes the restriction Json to_json() const; // at least one field }; struct RateLimitUpdate { std::optional max_requests_per_1_minute; std::optional max_tokens_per_1_minute; std::optional max_images_per_1_minute; std::optional max_audio_megabytes_per_1_minute; std::optional max_requests_per_1_day; std::optional batch_1_day_max_input_tokens; Json to_json() const; // at least one field }; struct CertificateUpload { std::string name; // optional std::string certificate; // PEM Json to_json() const; }; // Spend alert: USD per month, threshold in cents (spec: integer, minimum 1). struct SpendAlertSpec { std::int64_t threshold_amount = 0; std::vector recipients; // email channel, 1..10 std::string subject_prefix; // optional Json to_json() const; }; struct SpendLimitSpec { std::int64_t threshold_amount = 0; // cents, minimum 1 Json to_json() const; }; struct RoleSpec { std::string role_name; std::vector permissions; std::string description; // optional Json to_json() const; }; struct RoleUpdate { std::string role_name; std::optional> permissions; std::string description; Json to_json() const; // at least one field }; struct ModelPermissions { std::string mode; // allow_list | deny_list std::vector model_ids; Json to_json() const; }; // file_search, web_search, image_generation, mcp, code_interpreter -> enabled. struct HostedToolPermissions { std::map enabled; Json to_json() const; // at least one tool static const std::vector& tools(); }; // Retention types of the spec: organization and project enums differ. struct DataRetention { static Json organization(const std::string& retention_type); static Json project(const std::string& retention_type); }; struct ExternalStorageSpec { std::string project_id; std::string type; // aws | azure | gcp | oci std::map provider; // fields of that provider, see SPEC Json to_json() const; }; struct WebhookEndpointSpec { std::string name; std::string url; std::vector event_types; Json to_json(bool for_create) const; // update needs at least one field }; } // namespace molo::openai::admin