Commit ff4d54ef authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

add API version

parent f2a28bd2
......@@ -12,6 +12,9 @@
#include "CompleteStoredSearchDocumentApi.h"
#include "Helpers.h"
#include "nrf_config.hpp"
extern oai::nrf::nrf_config nrf_cfg;
namespace oai {
namespace nrf {
......@@ -31,7 +34,7 @@ void CompleteStoredSearchDocumentApi::init() {
void CompleteStoredSearchDocumentApi::setupRoutes() {
using namespace Pistache::Rest;
Routes::Get(*router, base + "/searches/:searchId/complete", Routes::bind(&CompleteStoredSearchDocumentApi::retrieve_complete_search_handler, this));
Routes::Get(*router, base + nrf_cfg.sbi_api_version + "/searches/:searchId/complete", Routes::bind(&CompleteStoredSearchDocumentApi::retrieve_complete_search_handler, this));
// Default handler, called when a route is not found
router->addCustomHandler(Routes::bind(&CompleteStoredSearchDocumentApi::complete_stored_search_document_api_default_handler, this));
......
......@@ -40,7 +40,7 @@ public:
virtual ~CompleteStoredSearchDocumentApi() {}
void init();
const std::string base = "/nnrf-disc/v1";
const std::string base = "/nnrf-disc/";
private:
void setupRoutes();
......
......@@ -12,6 +12,9 @@
#include "NFInstanceIDDocumentApi.h"
#include "Helpers.h"
#include "nrf_config.hpp"
extern oai::nrf::nrf_config nrf_cfg;
namespace oai {
namespace nrf {
......@@ -31,10 +34,10 @@ void NFInstanceIDDocumentApi::init() {
void NFInstanceIDDocumentApi::setupRoutes() {
using namespace Pistache::Rest;
Routes::Delete(*router, base + "/nf-instances/:nfInstanceID", Routes::bind(&NFInstanceIDDocumentApi::deregister_nf_instance_handler, this));
Routes::Get(*router, base + "/nf-instances/:nfInstanceID", Routes::bind(&NFInstanceIDDocumentApi::get_nf_instance_handler, this));
Routes::Put(*router, base + "/nf-instances/:nfInstanceID", Routes::bind(&NFInstanceIDDocumentApi::register_nf_instance_handler, this));
Routes::Patch(*router, base + "/nf-instances/:nfInstanceID", Routes::bind(&NFInstanceIDDocumentApi::update_nf_instance_handler, this));
Routes::Delete(*router, base + nrf_cfg.sbi_api_version + "/nf-instances/:nfInstanceID", Routes::bind(&NFInstanceIDDocumentApi::deregister_nf_instance_handler, this));
Routes::Get(*router, base + nrf_cfg.sbi_api_version + "/nf-instances/:nfInstanceID", Routes::bind(&NFInstanceIDDocumentApi::get_nf_instance_handler, this));
Routes::Put(*router, base + nrf_cfg.sbi_api_version + "/nf-instances/:nfInstanceID", Routes::bind(&NFInstanceIDDocumentApi::register_nf_instance_handler, this));
Routes::Patch(*router, base + nrf_cfg.sbi_api_version + "/nf-instances/:nfInstanceID", Routes::bind(&NFInstanceIDDocumentApi::update_nf_instance_handler, this));
// Default handler, called when a route is not found
router->addCustomHandler(Routes::bind(&NFInstanceIDDocumentApi::nf_instance_id_document_api_default_handler, this));
......
......@@ -43,7 +43,7 @@ public:
virtual ~NFInstanceIDDocumentApi() {}
void init();
const std::string base = "/nnrf-nfm/v1";
const std::string base = "/nnrf-nfm/";
private:
void setupRoutes();
......
......@@ -12,6 +12,9 @@
#include "NFInstancesStoreApi.h"
#include "Helpers.h"
#include "nrf_config.hpp"
extern oai::nrf::nrf_config nrf_cfg;
namespace oai {
namespace nrf {
......@@ -31,7 +34,7 @@ void NFInstancesStoreApi::init() {
void NFInstancesStoreApi::setupRoutes() {
using namespace Pistache::Rest;
Routes::Get(*router, base + "/nf-instances", Routes::bind(&NFInstancesStoreApi::search_nf_instances_handler, this));
Routes::Get(*router, base + nrf_cfg.sbi_api_version + "/nf-instances", Routes::bind(&NFInstancesStoreApi::search_nf_instances_handler, this));
// Default handler, called when a route is not found
router->addCustomHandler(Routes::bind(&NFInstancesStoreApi::nf_instances_store_api_default_handler, this));
......
......@@ -12,6 +12,9 @@
#include "StoredSearchDocumentApi.h"
#include "Helpers.h"
#include "nrf_config.hpp"
extern oai::nrf::nrf_config nrf_cfg;
namespace oai {
namespace nrf {
......@@ -31,7 +34,7 @@ void StoredSearchDocumentApi::init() {
void StoredSearchDocumentApi::setupRoutes() {
using namespace Pistache::Rest;
Routes::Get(*router, base + "/searches/:searchId", Routes::bind(&StoredSearchDocumentApi::retrieve_stored_search_handler, this));
Routes::Get(*router, base + nrf_cfg.sbi_api_version + "/searches/:searchId", Routes::bind(&StoredSearchDocumentApi::retrieve_stored_search_handler, this));
// Default handler, called when a route is not found
router->addCustomHandler(Routes::bind(&StoredSearchDocumentApi::stored_search_document_api_default_handler, this));
......
......@@ -12,6 +12,9 @@
#include "SubscriptionIDDocumentApi.h"
#include "Helpers.h"
#include "nrf_config.hpp"
extern oai::nrf::nrf_config nrf_cfg;
namespace oai {
namespace nrf {
......@@ -31,8 +34,8 @@ void SubscriptionIDDocumentApi::init() {
void SubscriptionIDDocumentApi::setupRoutes() {
using namespace Pistache::Rest;
Routes::Delete(*router, base + "/subscriptions/:subscriptionID", Routes::bind(&SubscriptionIDDocumentApi::remove_subscription_handler, this));
Routes::Patch(*router, base + "/subscriptions/:subscriptionID", Routes::bind(&SubscriptionIDDocumentApi::update_subscription_handler, this));
Routes::Delete(*router, base + nrf_cfg.sbi_api_version + "/subscriptions/:subscriptionID", Routes::bind(&SubscriptionIDDocumentApi::remove_subscription_handler, this));
Routes::Patch(*router, base + nrf_cfg.sbi_api_version + "/subscriptions/:subscriptionID", Routes::bind(&SubscriptionIDDocumentApi::update_subscription_handler, this));
// Default handler, called when a route is not found
router->addCustomHandler(Routes::bind(&SubscriptionIDDocumentApi::subscription_id_document_api_default_handler, this));
......
......@@ -12,6 +12,9 @@
#include "SubscriptionsCollectionApi.h"
#include "Helpers.h"
#include "nrf_config.hpp"
extern oai::nrf::nrf_config nrf_cfg;
namespace oai {
namespace nrf {
......@@ -31,7 +34,7 @@ void SubscriptionsCollectionApi::init() {
void SubscriptionsCollectionApi::setupRoutes() {
using namespace Pistache::Rest;
Routes::Post(*router, base + "/subscriptions", Routes::bind(&SubscriptionsCollectionApi::create_subscription_handler, this));
Routes::Post(*router, base + nrf_cfg.sbi_api_version + "/subscriptions", Routes::bind(&SubscriptionsCollectionApi::create_subscription_handler, this));
// Default handler, called when a route is not found
router->addCustomHandler(Routes::bind(&SubscriptionsCollectionApi::subscriptions_collection_api_default_handler, this));
......
/*
* Copyright (c) 2017 Sprint
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright (c) 2017 Sprint
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "nrf_app.hpp"
#include "nrf-api-server.h"
......@@ -35,63 +35,39 @@
using namespace oai::nrf;
using namespace util;
using namespace std;
//using namespace oai::nrf_server::api;
nrf_app *nrf_app_inst = nullptr;
nrf_config nrf_cfg;
void send_heartbeat_to_tasks(const uint32_t sequence);
NRFApiServer *api_server = nullptr;
//------------------------------------------------------------------------------
void send_heartbeat_to_tasks(const uint32_t sequence)
{
/* itti_msg_ping *itti_msg = new itti_msg_ping(TASK_SMF_APP, TASK_ALL, sequence);
std::shared_ptr<itti_msg_ping> i = std::shared_ptr<itti_msg_ping>(itti_msg);
int ret = itti_inst->send_broadcast_msg(i);
if (RETURNok != ret) {
Logger::nrf_app().error( "Could not send ITTI message %s to task TASK_ALL", i->get_msg_name());
}
*/
}
void my_app_signal_handler(int s) {
//------------------------------------------------------------------------------
void my_app_signal_handler(int s)
{
/*
std::cout << "Caught signal " << s << std::endl;
Logger::system().startup( "exiting" );
itti_inst->send_terminate_msg(TASK_SMF_APP);
itti_inst->wait_tasks_end();
Logger::system().startup("exiting");
std::cout << "Freeing Allocated memory..." << std::endl;
if (async_shell_cmd_inst) delete async_shell_cmd_inst; async_shell_cmd_inst = nullptr;
std::cout << "Async Shell CMD memory done." << std::endl;
if (nrf_api_server_1) {
nrf_api_server_1->shutdown();
delete nrf_api_server_1;
nrf_api_server_1 = nullptr;
}
if (nrf_api_server_2) {
nrf_api_server_2->stop();
delete nrf_api_server_2;
nrf_api_server_2 = nullptr;
if (api_server) {
api_server->shutdown();
delete api_server;
api_server = nullptr;
}
std::cout << "SMF API Server memory done." << std::endl;
if (itti_inst) delete itti_inst; itti_inst = nullptr;
std::cout << "ITTI memory done." << std::endl;
if (nrf_app_inst) delete nrf_app_inst; nrf_app_inst = nullptr;
std::cout << "SMF APP memory done." << std::endl;
std::cout << "NRF API Server memory done." << std::endl;
if (nrf_app_inst)
delete nrf_app_inst;
nrf_app_inst = nullptr;
std::cout << "NRF APP memory done." << std::endl;
std::cout << "Freeing Allocated memory done" << std::endl;
*/
exit(0);
}
//------------------------------------------------------------------------------
int main(int argc, char **argv)
{
int main(int argc, char **argv) {
srand (time(NULL));
// Command line options
if ( !Options::parse( argc, argv ) )
if ( !Options::parse( argc, argv ) )
{
std::cout << "Options::parse() failed" << std::endl;
return 1;
......@@ -99,7 +75,6 @@ int main(int argc, char **argv)
// Logger
Logger::init( "nrf" , Options::getlogStdout() , Options::getlogRotFilelog());
Logger::nrf_app().startup( "Options parsed" );
struct sigaction sigIntHandler;
......@@ -112,14 +87,7 @@ int main(int argc, char **argv)
nrf_cfg.load(Options::getlibconfigConfig());
nrf_cfg.display();
// Inter task Interface
// itti_inst = new itti_mw();
// itti_inst->start(nrf_cfg.itti.itti_timer_sched_params);
// system command
// async_shell_cmd_inst = new async_shell_cmd(nrf_cfg.itti.async_cmd_sched_params);
// SMF application layer
// NRF application layer
nrf_app_inst = new nrf_app(Options::getlibconfigConfig());
// PID file
......@@ -130,15 +98,12 @@ int main(int argc, char **argv)
exit (-EDEADLK);
}
/*
//SMF Pistache API server (HTTP1)
//NRF Pistache API server (HTTP1)
Pistache::Address addr(std::string(inet_ntoa (*((struct in_addr *)&nrf_cfg.sbi.addr4))) , Pistache::Port(nrf_cfg.sbi.port));
nrf_api_server_1 = new SMFApiServer(addr, nrf_app_inst);
nrf_api_server_1->init(2);
//nrf_api_server_1->start();
std::thread nrf_http1_manager(&SMFApiServer::start, nrf_api_server_1);
nrf_http1_manager.join();
*/
api_server = new NRFApiServer(addr, nrf_app_inst);
api_server->init(2);
std::thread nrf_manager(&NRFApiServer::start, api_server);
nrf_manager.join();
FILE *fp = NULL;
std::string filename = fmt::format("/tmp/nrf_{}.status", getpid());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment