ISSUE ID:- RICAPP-216
[ric-app/bouncer.git] / Bouncer / src / bouncer.cpp
1 #include"bouncer.h"
2 //using namespace xapp;
3
4 Bouncer::Bouncer(){
5         set_gnb();
6 }
7
8 void Bouncer::set_gnb(){
9         cpprestclient obj("http://service-ricplt-e2mgr-http.ricplt:3800");
10         response_t res;
11         res=obj.do_get("/v1/nodeb/states");
12         NodebListHandler handler;
13
14         if( res.status_code == 200 )
15         {
16                 //Reader reader;
17                 //StringStream ss( res.body.dump().c_str() );
18                 //reader.Parse( ss, handler );
19                 //std::cout << "[INFO] nodeb list is " << res.body.dump().c_str() << std::endl;
20                 std::cout << "[INFO] nodeb list is " << res.body<< std::endl;
21                 std::vector<std::string> inventoryNames;
22                 std::cout <<"pol"<<std::endl;
23                 for (const auto& item : res.body)
24                 {
25
26                         std::string inventoryName = item["inventoryName"];
27                         this->gnb_list.push_back(inventoryName);
28                 }
29
30         }
31
32         else
33         {
34                 if( res.body.empty() )
35                 {
36                         std::cout << "[ERROR] Unexpected HTTP code " << res.status_code <<  std::endl;
37                 }
38
39                 else
40                 {
41                         std::cout << "[ERROR] Unexpected HTTP code " << res.status_code <<" HTTP payload is " << res.body.dump().c_str() << std::endl;
42                 }
43         }
44
45         //this->gnb_list= handler.nodeb_list;
46
47 }
48