ADD: added central kubernetes api class
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "kubecontrol/KubernetesAPI.hpp"
|
||||
#include "kubecontrol/PodInfo.hpp"
|
||||
#include "nlohmann/json_fwd.hpp"
|
||||
#include "yaml-cpp/node/node.h"
|
||||
@@ -45,16 +46,36 @@ namespace kubecontrol
|
||||
std::string getComponent();
|
||||
|
||||
|
||||
std::string createYAML();
|
||||
std::string start(std::string apiAddress,std::string token);
|
||||
|
||||
// [[deprecated("replace with start(KubernetesAPI APIInterface)")]]
|
||||
// std::string start(std::string apiAddress,std::string token,bool WaitTillRunning = true);
|
||||
|
||||
std::string start(KubernetesAPI APIInterface,bool WaitTillRunning = true);
|
||||
|
||||
[[deprecated("replace with stop(KubernetesAPI APIInterface)")]]
|
||||
std::string stop(std::string apiAddress,std::string token);
|
||||
std::string getInfo(std::string apiAddress,std::string token);
|
||||
|
||||
std::string stop(KubernetesAPI APIInterface);
|
||||
|
||||
// [[deprecated("replace with getInfo(KubernetesAPI APIInterface)")]]
|
||||
// std::string getInfo(std::string apiAddress,std::string token);
|
||||
|
||||
std::string getInfoForThisPod(KubernetesAPI APIInterface);
|
||||
|
||||
std::string getInfoForRelatedPods(KubernetesAPI APIInterface);
|
||||
|
||||
std::vector<std::string> getUUIDForRelatedPods(KubernetesAPI APIInterface);
|
||||
|
||||
|
||||
|
||||
PodInfo InfoPod;
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
std::string Owner_;
|
||||
std::string Uuid_;
|
||||
std::string Component_;
|
||||
@@ -63,6 +84,10 @@ namespace kubecontrol
|
||||
std::string PathToYaml_;
|
||||
std::string Namespace_;
|
||||
|
||||
std::string Ip_;
|
||||
std::string Status_;
|
||||
std::string PartOf_;
|
||||
std::vector<std::string> uuidsOfShildContainers;
|
||||
|
||||
std::string PodCommand_;
|
||||
|
||||
@@ -71,9 +96,12 @@ namespace kubecontrol
|
||||
std::map<std::string, std::string> EnvirmonentVars_;
|
||||
std::vector<std::string> Args_;
|
||||
|
||||
std::string createYAML();
|
||||
|
||||
// std::string read;
|
||||
|
||||
|
||||
std::string StopChilds(std::string apiAddress,std::string token,std::string uuid);
|
||||
std::string StopChilds(std::string apiAddress,std::string token,std::string uuid);
|
||||
|
||||
};
|
||||
}
|
||||
32
include/kubecontrol/KubernetesAPI.hpp
Normal file
32
include/kubecontrol/KubernetesAPI.hpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
#include <yaml-cpp/node/node.h>
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace kubecontrol
|
||||
{
|
||||
|
||||
class KubernetesAPI
|
||||
{
|
||||
public:
|
||||
KubernetesAPI();
|
||||
KubernetesAPI(YAML::Node config);
|
||||
|
||||
KubernetesAPI(std::string APIAddress, std::string Token);
|
||||
|
||||
std::string performRequest(std::string request,std::string Methode = "GET");
|
||||
|
||||
std::string performRequest(std::string request,std::string Methode,std::string PostFields);
|
||||
|
||||
void addAddress(std::string address);
|
||||
void addToken(std::string Token);
|
||||
void addYaml(YAML::Node config);
|
||||
private:
|
||||
std::string APIAddress_;
|
||||
std::string Token_;
|
||||
std::string Namespace_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#include "kubecontrol/KubernetesAPI.hpp"
|
||||
#include "kubecontrol/PodInfo.hpp"
|
||||
#include <cstddef>
|
||||
#include <kubecontrol/KubePod.hpp>
|
||||
@@ -16,13 +17,13 @@ namespace kubecontrol
|
||||
|
||||
std::string getServerAddress();
|
||||
|
||||
void startPod(KubePod Pod);
|
||||
void stopPod(std::string Label);
|
||||
void startPod(KubePod Pod,bool WaitTillRunning = true );
|
||||
void stopPod(std::string uuid);
|
||||
void stopAllPods();
|
||||
|
||||
std::string getPodsInfo();
|
||||
std::string getInfoForOwnPod();
|
||||
std::string getInfoForPod(std::string Label);
|
||||
std::string getInfoForAllPods();
|
||||
// std::string getInfoForOwnPod();
|
||||
std::string getInfoForPod(std::string uuid);
|
||||
size_t getListOfChildPods();
|
||||
|
||||
void checkPodsHierarchy();
|
||||
@@ -30,6 +31,7 @@ namespace kubecontrol
|
||||
std::string getPodsInfoForAll();
|
||||
std::shared_ptr<PodInfo> getPodsInfo(std::string uuid);
|
||||
private:
|
||||
KubernetesAPI APIInterface_;
|
||||
std::vector<KubePod> PodList_;
|
||||
|
||||
std::string performRequest(std::string url);
|
||||
|
||||
Reference in New Issue
Block a user