diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..ce8c257 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,35 @@ +cmake_minimum_required(VERSION 3.10) +project(render_cloud_cdk) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +# Define source files. +file(GLOB_RECURSE LIB_SOURCES "librender_cdk/*.cpp") + +# Add C++ library target. +add_library(librender_cdk STATIC ${LIB_SOURCES}) + +# Include directories. +target_include_directories(librender_cdk PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/librender_cdk + ${CMAKE_CURRENT_SOURCE_DIR}/librender_cdk/common +) + +# Add a custom target to build the Rust project. +add_custom_target(render_cdk ALL + COMMAND cargo build --manifest-path ${CMAKE_CURRENT_SOURCE_DIR}/render_cdk/Cargo.toml + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/render_cdk + COMMENT "Runnig [cargo build] on specified manifest path.." +) + +# Link any additional dependencies for the C++ library. +# target_link_libraries(librender_cdk ) + +# Ensure C++ library is built before Rust project. +add_dependencies(render_cdk librender_cdk) + +# 'render_cdk' should ONLY be built when invoking 'make' +add_custom_target(build_all + DEPENDS librender_cdk render_cdk +) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt deleted file mode 100644 index c9a1140..0000000 --- a/cmake/CMakeLists.txt +++ /dev/null @@ -1,59 +0,0 @@ -cmake_minimum_required(VERSION 3.10) - -project(RenderCdk) - -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED True) - -add_subdirectory(librender_cdk) - -include_directories(${CMAKE_SOURCE_DIR}/librender_cdk/librender_cdk) - -find_package(jsoncpp QUIET) -if(NOT jsoncpp_FOUND) - message(STATUS "JsonCpp not found. Attempting to install...") - execute_process( - COMMAND sudo apt-get update - COMMAND sudo apt-get install -y libjsoncpp-dev - COMMAND_ERROR_IS_FATAL ANY - ) - find_package(jsoncpp REQUIRED) -endif() - -find_package(CURL QUIET) -if(NOT CURL_FOUND) - message(STATUS "cURL not found. Attempting to install...") - execute_process( - COMMAND sudo apt-get update - COMMAND sudo apt-get install -y libcurl4-openssl-dev - COMMAND_ERROR_IS_FATAL ANY - ) - find_package(CURL REQUIRED) -endif() - -add_executable(render_cdk librender_cdk/librender_cdk/main.cpp) - -# Include JsonCpp and cURL header directories. -include_directories(${JSONCPP_INCLUDE_DIRS}) -include_directories(${CURL_INCLUDE_DIRS}) - -# Link the libraries. -target_link_libraries(render_cdk ${CURL_LIBRARIES} ${JSONCPP_LIBRARIES}) - -############################################## -# Build docs: -# -# cmake_minimum_required: Specifies the minimum version of CMake required. -# project: : Defines the project name. -# set(CMAKE_CXX_STANDARD 11): Sets the C++ standard to C++11. -# add_subdirectory: Adds the subdirectory for the library. -# include_directories: Adds include directories for library and packages. -# find_package(jsoncpp REQUIRED): Finds the JsonCpp package. -# find_package(CURL REQUIRED): Finds the cURL package. -# add_executable: Defines the executable target. -# target_link_libraries: Links the found libraries (JsonCpp and cURL) to the executable. -# -# Building with the GNU compiler. -# > g++ lib.cpp environment_manager.cpp -o -# -############################################### \ No newline at end of file diff --git a/librender_cdk/CMakeLists.txt b/librender_cdk/CMakeLists.txt new file mode 100644 index 0000000..92e0f35 --- /dev/null +++ b/librender_cdk/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.10) +project(librender_cdk) + +# Define source files. +file(GLOB_RECURSE LIB_SOURCES "*.cpp") + +# Add the C++ library target. +add_library(librender_cdk STATIC ${LIB_SOURCES}) + +# Include directories. +target_include_directories(librender_cdk PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/common +) \ No newline at end of file diff --git a/librender_cdk/common/common.h b/librender_cdk/common/common.h new file mode 100644 index 0000000..ffe10ad --- /dev/null +++ b/librender_cdk/common/common.h @@ -0,0 +1,9 @@ +#ifndef _COMMON_H_ +#define _COMMON_H_ + +#include +#include +#include +#include + +#endif \ No newline at end of file diff --git a/librender_cdk/common/constants.h b/librender_cdk/common/constants.h new file mode 100644 index 0000000..8fa4a7b --- /dev/null +++ b/librender_cdk/common/constants.h @@ -0,0 +1,8 @@ +#ifndef _CONSTANTS_H_ +#define _CONSTANTS_H_ + +#include + +const std::string BASE_URL = "https://api.render.com/v1"; + +#endif \ No newline at end of file diff --git a/librender_cdk/librender_cdk/dotenv.h b/librender_cdk/dotenv.h similarity index 100% rename from librender_cdk/librender_cdk/dotenv.h rename to librender_cdk/dotenv.h diff --git a/librender_cdk/librender_cdk/environment_manager.cpp b/librender_cdk/environment_manager.cpp similarity index 84% rename from librender_cdk/librender_cdk/environment_manager.cpp rename to librender_cdk/environment_manager.cpp index 7eb8b05..d3e563c 100644 --- a/librender_cdk/librender_cdk/environment_manager.cpp +++ b/librender_cdk/environment_manager.cpp @@ -10,6 +10,7 @@ std::string EnvironmentManager::getApiKey() { const std::string apiKey = std::getenv("API_KEY"); if (!apiKey.empty()) { + std::cout << "[RUNNING] -> Retrieving [API_KEY]." << std::endl; return std::string(apiKey); } else { return "[API_KEY] must be set."; diff --git a/librender_cdk/librender_cdk/environment_manager.h b/librender_cdk/environment_manager.h similarity index 100% rename from librender_cdk/librender_cdk/environment_manager.h rename to librender_cdk/environment_manager.h diff --git a/librender_cdk/lib.cpp b/librender_cdk/lib.cpp new file mode 100644 index 0000000..eec8e92 --- /dev/null +++ b/librender_cdk/lib.cpp @@ -0,0 +1,20 @@ +#include "environment_manager.h" +#include + +/** + * @file lib.cpp + * @brief This file contains examples of how to use librender_cdk. + */ + +/** + * @brief Retrieves and prints the API key to the standard output. + * + * This example demonstrates how to retrieve the API key using the + * EnvironmentManager and print it to the console. + */ + +void retrieveApiKey() { + std::cout << EnvironmentManager::getApiKey() << std::endl; +} + +int main() { retrieveApiKey(); } \ No newline at end of file diff --git a/librender_cdk/librender_cdk/lib.cpp b/librender_cdk/librender_cdk/lib.cpp deleted file mode 100644 index ed1689a..0000000 --- a/librender_cdk/librender_cdk/lib.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "environment_manager.h" -#include - -int main() { - std::cout << "[API_KEY] -> " << EnvironmentManager::getApiKey() << std::endl; -} \ No newline at end of file diff --git a/librender_cdk/librender_cdk/main.cpp b/librender_cdk/main.cpp similarity index 100% rename from librender_cdk/librender_cdk/main.cpp rename to librender_cdk/main.cpp diff --git a/librender_cdk/state_management.cpp b/librender_cdk/state_management.cpp new file mode 100644 index 0000000..e69de29 diff --git a/librender_cdk/state_management.h b/librender_cdk/state_management.h new file mode 100644 index 0000000..87c8c5d --- /dev/null +++ b/librender_cdk/state_management.h @@ -0,0 +1,40 @@ +#ifndef _STATE_MANAGEMENT_H_ +#define _STATE_MANAGEMENT_H_ + +#include "common/common.h" +#include "common/constants.h" +#include "environment_manager.h" +#include +#include + +class State { +public: + CURL *client; + std::string apiKey; + + State() { + client = curl_easy_init(); + apiKey = EnvironmentManager::getApiKey(); + } + + ~State() { + if (client) + curl_easy_cleanup(client); + } + + static std::shared_ptr init() { return std::make_shared(); } +}; + +struct Owner { + std::string id; + std::string name; + std::string email; + bool twoFactorAuthEnabled; + std::string type; + + static std::vector retrieveAuthorizedUsers(const std::string &email, + const std::string &limit); +}; + + +#endif diff --git a/librender_cdk/tests/tests.cpp b/librender_cdk/tests.cpp similarity index 77% rename from librender_cdk/tests/tests.cpp rename to librender_cdk/tests.cpp index 0b4f558..baac75d 100644 --- a/librender_cdk/tests/tests.cpp +++ b/librender_cdk/tests.cpp @@ -1,4 +1,4 @@ -#include "../include/environment_manager.h" +#include "environment_manager.h" #include int main() {