63 lines
2.4 KiB
C++
63 lines
2.4 KiB
C++
#pragma once
|
|
|
|
// The ONE table of REST calls this module makes. Every row is checked by
|
|
// tools/check_spec.py against xAI's OpenAPI document or the docs.x.ai REST
|
|
// reference pages. Code builds every path from this table, never a literal.
|
|
|
|
#include <cstddef>
|
|
#include <initializer_list>
|
|
#include <string>
|
|
|
|
#include "clients/request.h"
|
|
|
|
namespace molo::xai::platform {
|
|
|
|
enum class Call {
|
|
// Account (api.x.ai)
|
|
kApiKeyInfo, kMe,
|
|
// Files (api.x.ai)
|
|
kFileUpload, kFileList, kFileGet, kFileDelete, kFileContent, kPublicUrlCreate,
|
|
kPublicUrlRevoke,
|
|
// Document search (api.x.ai)
|
|
kDocumentsSearch,
|
|
// Voice REST (api.x.ai)
|
|
kClientSecret, kPhoneCreate, kPhoneList, kPhoneDelete, kCallRefer, kCallHangup, kTts,
|
|
kTtsVoices, kTtsVoiceGet, kStt, kCustomVoiceCreate, kCustomVoiceList, kCustomVoiceGet,
|
|
kCustomVoicePatch, kCustomVoiceDelete, kCustomVoiceAudio,
|
|
// Collections (management-api.x.ai)
|
|
kCollectionCreate, kCollectionList, kCollectionGet, kCollectionDelete, kCollectionUpdate,
|
|
kDocAdd, kDocUpload, kDocList, kDocGet, kDocReindex, kDocRemove, kDocBatchGet,
|
|
// Management keys (management-api.x.ai)
|
|
kKeyCreate, kKeyList, kKeyUpdate, kKeyRotate, kKeyDelete, kKeyPropagation, kTeamModels,
|
|
kTeamEndpoints, kKeyValidate,
|
|
// Billing and audit (management-api.x.ai)
|
|
kBillingInfoGet, kBillingInfoSet, kInvoices, kPaymentMethods, kPaymentDefault,
|
|
kInvoicePreview, kSpendingGet, kSpendingSet, kPrepaidBalance, kPrepaidTopUp, kUsage,
|
|
kAuditEvents,
|
|
};
|
|
|
|
enum class Host { kApi, kManagement };
|
|
|
|
struct CallSpec {
|
|
Call call;
|
|
const char* http_method; // GET POST PUT PATCH DELETE
|
|
const char* host; // "api" -> api.x.ai, "management" -> management-api.x.ai
|
|
const char* path; // exactly as the spec prints it
|
|
const char* source; // "openapi:<operationId>" | "docs:<page>" | "guide:<page>"
|
|
const char* body_fields; // comma list: top-level request body / form fields we send
|
|
const char* query_params; // comma list
|
|
const char* guide_fields; // comma list: fields only the prose guide documents
|
|
};
|
|
|
|
const CallSpec& spec_of(Call call);
|
|
clients::Method method_of(Call call);
|
|
Host host_of(Call call);
|
|
std::size_t call_count();
|
|
const CallSpec& spec_at(std::size_t index);
|
|
|
|
// Fills `{placeholders}` in order with `segments`. Each segment must pass
|
|
// llm::Service::valid_id; wrong count or bad id throws llm::ApiError::invalid.
|
|
std::string render(Call call, std::initializer_list<std::string> segments = {});
|
|
|
|
} // namespace molo::xai::platform
|