45 lines
1.8 KiB
C++
45 lines
1.8 KiB
C++
#include "clickhouse/client.h"
|
|
#include "nlohmann/json_fwd.hpp"
|
|
#include "skwyward-api-utils.hpp"
|
|
#include "spdlog/spdlog.h"
|
|
#include <exception>
|
|
#include <memory>
|
|
#include <sodium.h>
|
|
#include <sodium/core.h>
|
|
#include <string_view>
|
|
#include <toml++/toml.h>
|
|
|
|
int main (int argc, char *argv[]) {
|
|
auto config = toml::parse_file("config.toml");
|
|
std::string base_uri = config["host"].value_or("");
|
|
std::string test_username = config["test_username"].value_or("");
|
|
std::string test_password = config["test_password"].value_or("");
|
|
|
|
// clickhouse creds
|
|
|
|
std::string clickhouse_host_name = config["clickhouse_host"].value_or("");
|
|
std::string clickhouse_username = config["clickhouse_username"].value_or("");
|
|
std::string clickhouse_schema = config["clickhouse_schema"].value_or("");
|
|
std::string clickhouse_password = config["clickhouse_password"].value_or("");
|
|
|
|
api_utils::StatusResponse health_check = api_methods::get_status(base_uri);
|
|
spdlog::info("Status response output: {}", health_check.status);
|
|
|
|
api_utils::ErrorResponse test_login = api_methods::get_auth_status(base_uri, test_username, test_password);
|
|
spdlog::info("Auth attempt response : {}", test_login.success);
|
|
|
|
api_utils::GradesResponse test_grades = api_methods::get_grades(base_uri, test_username, test_password);
|
|
spdlog::info("Grades: {}", nlohmann::json {test_grades}.dump());
|
|
|
|
if(sodium_init()==-1){
|
|
spdlog::error("Sodium, the crypto lib, cannot be inited. bailing");
|
|
std::terminate();
|
|
}
|
|
|
|
std::shared_ptr<clickhouse::Client> client_shared_ptr = std::make_shared<clickhouse::Client>(clickhouse::ClientOptions().SetHost(clickhouse_host_name).SetPassword(clickhouse_password).SetUser(clickhouse_username).SetDefaultDatabase(clickhouse_schema));
|
|
|
|
spdlog::info("Connected to the database");
|
|
|
|
return 0;
|
|
}
|