ISSUE ID:- RICAPP-216
[ric-app/bouncer.git] / Bouncer / src / bouncer.cpp
diff --git a/Bouncer/src/bouncer.cpp b/Bouncer/src/bouncer.cpp
new file mode 100644 (file)
index 0000000..bae5820
--- /dev/null
@@ -0,0 +1,48 @@
+#include"bouncer.h"
+//using namespace xapp;
+
+Bouncer::Bouncer(){
+        set_gnb();
+}
+
+void Bouncer::set_gnb(){
+        cpprestclient obj("http://service-ricplt-e2mgr-http.ricplt:3800");
+        response_t res;
+        res=obj.do_get("/v1/nodeb/states");
+        NodebListHandler handler;
+
+        if( res.status_code == 200 )
+        {
+                //Reader reader;
+                //StringStream ss( res.body.dump().c_str() );
+                //reader.Parse( ss, handler );
+                //std::cout << "[INFO] nodeb list is " << res.body.dump().c_str() << std::endl;
+                std::cout << "[INFO] nodeb list is " << res.body<< std::endl;
+                std::vector<std::string> inventoryNames;
+                std::cout <<"pol"<<std::endl;
+                for (const auto& item : res.body)
+                {
+
+                        std::string inventoryName = item["inventoryName"];
+                        this->gnb_list.push_back(inventoryName);
+                }
+
+        }
+
+        else
+        {
+                if( res.body.empty() )
+                {
+                        std::cout << "[ERROR] Unexpected HTTP code " << res.status_code <<  std::endl;
+                }
+
+                else
+                {
+                        std::cout << "[ERROR] Unexpected HTTP code " << res.status_code <<" HTTP payload is " << res.body.dump().c_str() << std::endl;
+                }
+        }
+
+        //this->gnb_list= handler.nodeb_list;
+
+}
+