#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 #include #include #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 client); AdminService(std::shared_ptr 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& 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& ids, const Query& base, const std::string& cursor_param, const std::string& start_cursor = ""); static Json object_of(std::initializer_list> fields); private: AuthKind auth_; }; } // namespace molo::openai::admin