Files
moloapp/src/clients/rest/resource.h
T
retoor 3c4334cec9 feat: implement MoloApp plans 01-15 with integration
Full C++23 framework tree: runtime, observability, security,
data, app, realtime, supervisor, clients, CLI, example plus
enterprise tenancy, audit, operability, governance,
supplychain. Postgres via docker compose for tests.
2026-10-23 18:20:04 +02:00

58 lines
1.8 KiB
C++

#pragma once
// Fluent CRUD helper over a plural-noun collection path.
#include <map>
#include <memory>
#include <string>
#include "clients/body/json.h"
#include "clients/client.h"
#include "clients/request.h"
#include "clients/response.h"
#include "clients/task.h"
namespace molo::clients::rest {
class IdempotencyStore;
class Resource {
public:
Resource(Client& client, std::string collection);
Resource(Client& client, std::string base_url, std::string collection);
Resource& idempotency(std::shared_ptr<IdempotencyStore> store);
const std::string& collection() const { return collection_; }
std::string member_url(const std::string& id) const;
std::string collection_url(
const std::map<std::string, std::string>& query = {}) const;
Task<ClientResponse> list(
const std::map<std::string, std::string>& query = {});
Task<ClientResponse> get(const std::string& id);
Task<ClientResponse> create(const body::Json& doc);
Task<ClientResponse> create(const std::string& body,
const std::string& content_type);
Task<ClientResponse> update(const std::string& id, const body::Json& doc);
Task<ClientResponse> patch(const std::string& id, const body::Json& doc);
Task<ClientResponse> remove(const std::string& id);
ClientResponse list_blocking(
const std::map<std::string, std::string>& query = {});
ClientResponse get_blocking(const std::string& id);
ClientResponse create_blocking(const body::Json& doc);
ClientResponse update_blocking(const std::string& id, const body::Json& doc);
ClientResponse patch_blocking(const std::string& id, const body::Json& doc);
ClientResponse remove_blocking(const std::string& id);
private:
Client& client_;
std::string base_url_;
std::string collection_;
std::shared_ptr<IdempotencyStore> idempotency_;
};
} // namespace molo::clients::rest