Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #51

Merged
merged 3 commits into from
Jul 18, 2024
Merged

Dev #51

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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 <dependency>)

# 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
)
59 changes: 0 additions & 59 deletions cmake/CMakeLists.txt

This file was deleted.

14 changes: 14 additions & 0 deletions librender_cdk/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)
9 changes: 9 additions & 0 deletions librender_cdk/common/common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef _COMMON_H_
#define _COMMON_H_

#include <curl/curl.h>
#include <iostream>
#include <jsoncpp/json/json.h>
#include <string>

#endif
8 changes: 8 additions & 0 deletions librender_cdk/common/constants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef _CONSTANTS_H_
#define _CONSTANTS_H_

#include <iostream>

const std::string BASE_URL = "https://api.render.com/v1";

#endif
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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.";
Expand Down
20 changes: 20 additions & 0 deletions librender_cdk/lib.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "environment_manager.h"
#include <iostream>

/**
* @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(); }
6 changes: 0 additions & 6 deletions librender_cdk/librender_cdk/lib.cpp

This file was deleted.

File renamed without changes.
Empty file.
40 changes: 40 additions & 0 deletions librender_cdk/state_management.h
Original file line number Diff line number Diff line change
@@ -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 <memory>
#include <vector>

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<State> init() { return std::make_shared<State>(); }
};

struct Owner {
std::string id;
std::string name;
std::string email;
bool twoFactorAuthEnabled;
std::string type;

static std::vector<Owner> retrieveAuthorizedUsers(const std::string &email,
const std::string &limit);
};


#endif
2 changes: 1 addition & 1 deletion librender_cdk/tests/tests.cpp → librender_cdk/tests.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "../include/environment_manager.h"
#include "environment_manager.h"
#include <iostream>

int main() {
Expand Down
Loading