Octane API Client
Loading...
Searching...
No Matches
api_client.h
Go to the documentation of this file.
1
11#ifndef OCTANE_API_CLIENT_API_CLIENT_H_
12#define OCTANE_API_CLIENT_API_CLIENT_H_
13
14#include "./api_result_types.h"
15#include "./config.h"
16#include "./error_response.h"
18#include "./internal/hash.h"
19#include "./result.h"
20namespace octane {
21 class ApiClient {
23 std::uint64_t lastCheckedTime;
24 HealthResult lastCheckedHealth;
25 struct ConnectionStatus {
26 bool isConnected;
31 std::uint64_t id;
36 std::string name;
37 };
38 ConnectionStatus connectionStatus{ .isConnected = false };
39
40 public:
48 ApiClient(std::string_view token = DEFAULT_API_TOKEN,
49 std::string_view origin = DEFAULT_API_ORIGIN,
50 std::string_view baseUrl = DEFAULT_API_BASE_URL);
55 ~ApiClient() noexcept;
56
93 Result<RoomId, ErrorResponse> createRoom(std::string_view name);
111 std::string_view name);
129 std::string_view name);
150 std::optional<std::uint64_t> id = std::nullopt);
166 Result<Response, ErrorResponse> deleteRoom(std::optional<std::uint64_t> id
167 = std::nullopt);
217
218 private:
262 std::vector<std::uint8_t> createBinary(
263 const std::variant<std::string,
264 std::vector<uint8_t>,
265 std::vector<FileInfo>>& input);
266 };
267} // namespace octane
268
269#endif // OCTANE_API_CLIENT_API_CLIENT_H_
APIclientとAPI一つ一つを結びつける。
Types which are used to return values in api client.
Definition: api_client.h:21
Result< Response, ErrorResponse > disconnectRoom(std::uint64_t id, std::string_view name)
Disconnects from the room.
Definition: api_client.cpp:117
Result< Response, ErrorResponse > uploadContent(const Content &content)
Uploads content to the room.
Definition: api_client.cpp:245
Result< Response, ErrorResponse > deleteContent()
Deletes the room's content.
Definition: api_client.cpp:226
Result< Content, ErrorResponse > getContent()
Gets the room's content.
Definition: api_client.cpp:181
Result< Response, ErrorResponse > deleteRoom(std::optional< std::uint64_t > id=std::nullopt)
Deletes the room.
Definition: api_client.cpp:159
Result< RoomStatus, ErrorResponse > getRoomStatus(std::optional< std::uint64_t > id=std::nullopt)
Gets the room's status.
Definition: api_client.cpp:137
~ApiClient() noexcept
Destroy the Api Client object.
Definition: api_client.cpp:28
Result< RoomId, ErrorResponse > createRoom(std::string_view name)
Creates a room.
Definition: api_client.cpp:83
Result< Response, ErrorResponse > init()
Run this method at first.(Since no exeptions are allowed in the constructor, we need this method to i...
Definition: api_client.cpp:34
Result< Response, ErrorResponse > connectRoom(std::uint64_t id, std::string_view name)
Connects to the room.
Definition: api_client.cpp:98
Wrapper class that bifurcates the values indicated by normal and quasi-normal states.
Definition: result.h:38
Definition: api_bridge.h:20
Define constants which are used on compiling.
Error response.
ハッシュアルゴリズムを提供する。
Definition: api_client.cpp:20
constexpr auto DEFAULT_API_TOKEN
Default API token.
Definition: config.h:26
constexpr auto DEFAULT_API_ORIGIN
Default API origin.
Definition: config.h:28
constexpr auto DEFAULT_API_BASE_URL
Default base URL.
Definition: config.h:30
Define type to represent the result, inspired by Rust's "Result".
Structure used as result for getContent, has data and ContentStatus and inherits Response.
Definition: api_result_types.h:132
Structure used as result for health, has the server's status and message.
Definition: api_result_types.h:41