#pragma once

#include "kubecontrol/KubernetesAPI.hpp"
#include "nlohmann/json_fwd.hpp"
#include "yaml-cpp/node/node.h"
#include <map>
#include <string>
#include <vector>
#include <yaml-cpp/yaml.h>
#include <fstream>
#include <curlpp/Easy.hpp>
#include <curlpp/Options.hpp>
#include <loguru.hpp>
#include <nlohmann/json.hpp>

#include <curlpp/cURLpp.hpp>
#include <filesystem>
#include <map>
#include <vector>



namespace kubecontrol 
{
    class KubePod
    {
        public: 
            KubePod(std::string Owner, std::string Uuid, std::string ContainerImage,std::string Namespace = "simulator") ;
            KubePod(std::string Owner, std::string Uuid, std::string Component, std::string ContainerImage,std::string Namespace = "simulator");

            std::string getUUID();
            std::string getOwner();
            std::string getIp();
            std::string getStatus();

            void setEnvironmentVar(std::string key, std::string val);
            std::map<std::string, std::string> GetEnvironmentVars();
            std::string GetEnvironmentVar(std::string key);

            void setArgs(std::string args);
            std::vector<std::string> GetArgs();

            void setCommand(std::string command);
            std::string getCommand();

            void setComponent(std::string component);
            std::string getComponent();
           

            int start(KubernetesAPI APIInterface,bool WaitTillRunning = true);
            int stop(KubernetesAPI APIInterface);
            int stopChilds(KubernetesAPI APIInterface);
       
            int updateInfoForThisPod(KubernetesAPI APIInterface);

            std::vector<std::string> getUUIDsForChildPods(KubernetesAPI APIInterface);

            
        private:

            static const int MaxWaitTimeInSeconds;

            std::string Owner_;
            std::string Uuid_;
            std::string Component_;
            std::string ContainerImage_;
            std::string ContainerRegistry_;
            std::string PathToYaml_;
            std::string Namespace_;

            std::string Ip_;
            std::string Status_;
            std::string PartOf_; 
            std::vector<std::string> uuidsOfShildContainers;

            std::string PodCommand_;
            
            YAML::Node YAMLNode_;

            std::map<std::string, std::string> EnvirmonentVars_;
            std::vector<std::string> Args_;

            std::string createYAML();

            /**
             * @brief extracts the asked inforamtion from the kubernetes response
             * 
             * 
            */
            int extractInformationFromResopnse(std::string response);


    
    };
}