Commit 03470f22 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Delete unecessary files from SMF

parent 68d63bf6
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include "NFStatusNotifyApi.h"
//#include "Helpers.h"
#include "amf_config.hpp"
extern config::amf_config amf_cfg;
namespace oai {
namespace amf {
namespace api {
// using namespace oai::amf::helpers;
using namespace oai::amf::model;
NFStatusNotifyApi::NFStatusNotifyApi(
std::shared_ptr<Pistache::Rest::Router> rtr) {
router = rtr;
}
void NFStatusNotifyApi::init() {
setupRoutes();
}
void NFStatusNotifyApi::setupRoutes() {
using namespace Pistache::Rest;
Routes::Post(
*router, base + amf_cfg.sbi_api_version + "/subscriptions",
Routes::bind(&NFStatusNotifyApi::notify_nf_status_handler, this));
// Default handler, called when a route is not found
router->addCustomHandler(
Routes::bind(&NFStatusNotifyApi::notify_nf_status_default_handler, this));
}
void NFStatusNotifyApi::notify_nf_status_handler(
const Pistache::Rest::Request& request,
Pistache::Http::ResponseWriter response) {
// Getting the body param
NotificationData notificationData;
try {
nlohmann::json::parse(request.body()).get_to(notificationData);
this->receive_nf_status_notification(notificationData, response);
} catch (nlohmann::detail::exception& e) {
// send a 400 error
response.send(Pistache::Http::Code::Bad_Request, e.what());
return;
} catch (Pistache::Http::HttpError& e) {
response.send(static_cast<Pistache::Http::Code>(e.code()), e.what());
return;
} catch (std::exception& e) {
// send a 500 error
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
return;
}
}
void NFStatusNotifyApi::notify_nf_status_default_handler(
const Pistache::Rest::Request&, Pistache::Http::ResponseWriter response) {
response.send(
Pistache::Http::Code::Not_Found, "The requested method does not exist");
}
} // namespace api
} // namespace amf
} // namespace oai
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*
* NFStatusNotifyApi.h
*
*
*/
#ifndef NFStatusNotifyApi_H_
#define NFStatusNotifyApi_H_
#include <pistache/http.h>
#include <pistache/router.h>
#include <pistache/http_headers.h>
#include <pistache/optional.h>
#include "NotificationData.h"
//#include "ProblemDetails.h"
namespace oai {
namespace amf {
namespace api {
using namespace oai::amf::model;
class NFStatusNotifyApi {
public:
NFStatusNotifyApi(std::shared_ptr<Pistache::Rest::Router>);
virtual ~NFStatusNotifyApi() {}
void init();
const std::string base = "/namf-nfstatus-notify/";
private:
void setupRoutes();
void notify_nf_status_handler(
const Pistache::Rest::Request& request,
Pistache::Http::ResponseWriter response);
void notify_nf_status_default_handler(
const Pistache::Rest::Request& request,
Pistache::Http::ResponseWriter response);
std::shared_ptr<Pistache::Rest::Router> router;
/// <summary>
///
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="NotificationData"></param>
virtual void receive_nf_status_notification(
const NotificationData& notificationData,
Pistache::Http::ResponseWriter& response) = 0;
};
} // namespace api
} // namespace amf
} // namespace oai
#endif /* NFStatusNotifyApi_H_ */
/**
* Namf_EventExposure
* Session Management Event Exposure Service. 2019, 3GPP Organizational
* Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 1.1.0.alpha-1
*
*/
#include "SubscriptionsCollectionApi.h"
#include "Helpers.h"
#include "amf_config.hpp"
extern config::amf_config amf_cfg;
namespace oai {
namespace amf {
namespace api {
// using namespace oai::amf::helpers;
using namespace oai::amf::model;
SubscriptionsCollectionApi::SubscriptionsCollectionApi(
std::shared_ptr<Pistache::Rest::Router> rtr) {
router = rtr;
}
void SubscriptionsCollectionApi::init() {
setupRoutes();
}
void SubscriptionsCollectionApi::setupRoutes() {
using namespace Pistache::Rest;
Routes::Post(
*router, base + amf_cfg.sbi_api_version + "/subscriptions",
Routes::bind(
&SubscriptionsCollectionApi::create_individual_subcription_handler,
this));
// Default handler, called when a route is not found
router->addCustomHandler(Routes::bind(
&SubscriptionsCollectionApi::subscriptions_collection_api_default_handler,
this));
}
void SubscriptionsCollectionApi::create_individual_subcription_handler(
const Pistache::Rest::Request& request,
Pistache::Http::ResponseWriter response) {
// Getting the body param
NamfEventExposure namfEventExposure;
try {
nlohmann::json::parse(request.body()).get_to(namfEventExposure);
this->create_individual_subcription(namfEventExposure, response);
} catch (nlohmann::detail::exception& e) {
// send a 400 error
response.send(Pistache::Http::Code::Bad_Request, e.what());
return;
} catch (Pistache::Http::HttpError& e) {
response.send(static_cast<Pistache::Http::Code>(e.code()), e.what());
return;
} catch (std::exception& e) {
// send a 500 error
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
return;
}
}
void SubscriptionsCollectionApi::subscriptions_collection_api_default_handler(
const Pistache::Rest::Request&, Pistache::Http::ResponseWriter response) {
response.send(
Pistache::Http::Code::Not_Found, "The requested method does not exist");
}
} // namespace api
} // namespace amf
} // namespace oai
/**
* Namf_EventExposure
* Session Management Event Exposure Service. 2019, 3GPP Organizational
* Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 1.1.0.alpha-1
*
*/
/*
* SubscriptionsCollectionApi.h
*
*
*/
#ifndef SubscriptionsCollectionApi_H_
#define SubscriptionsCollectionApi_H_
#include <pistache/http.h>
#include <pistache/router.h>
#include <pistache/http_headers.h>
#include <pistache/optional.h>
#include "NamfEventExposure.h"
#include "ProblemDetails.h"
namespace oai {
namespace amf {
namespace api {
using namespace oai::amf::model;
class SubscriptionsCollectionApi {
public:
SubscriptionsCollectionApi(std::shared_ptr<Pistache::Rest::Router>);
virtual ~SubscriptionsCollectionApi() {}
void init();
const std::string base = "/namf_event-exposure/";
private:
void setupRoutes();
void create_individual_subcription_handler(
const Pistache::Rest::Request& request,
Pistache::Http::ResponseWriter response);
void subscriptions_collection_api_default_handler(
const Pistache::Rest::Request& request,
Pistache::Http::ResponseWriter response);
std::shared_ptr<Pistache::Rest::Router> router;
/// <summary>
/// Create an individual subscription for event notifications from the AMF
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="namfEventExposure"></param>
virtual void create_individual_subcription(
const NamfEventExposure& namfEventExposure,
Pistache::Http::ResponseWriter& response) = 0;
};
} // namespace api
} // namespace amf
} // namespace oai
#endif /* SubscriptionsCollectionApi_H_ */
/**
* Namf_EventExposure
* Session Management Event Exposure Service. 2019, 3GPP Organizational
* Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 1.1.0.alpha-1
*
*
* NOTE: This class is auto generated by OpenAPI Generator
* (https://openapi-generator.tech). https://openapi-generator.tech Do not edit
* the class manually.
*/
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include "NFStatusNotifyApiImpl.h"
#include "logger.hpp"
#include "amf_msg.hpp"
#include "itti_msg_sbi.hpp"
#include "amf_config.hpp"
#include "3gpp_conversions.hpp"
extern config::amf_config amf_cfg;
namespace oai {
namespace amf {
namespace api {
using namespace oai::amf::model;
using namespace amf_application;
using namespace amf;
NFStatusNotifyApiImpl::NFStatusNotifyApiImpl(
std::shared_ptr<Pistache::Rest::Router> rtr, amf_app* amf_app_inst,
std::string address)
: NFStatusNotifyApi(rtr), m_amf_app(amf_app_inst), m_address(address) {}
void NFStatusNotifyApiImpl::receive_nf_status_notification(
const NotificationData& notificationData,
Pistache::Http::ResponseWriter& response) {
Logger::amf_server().info(
"NFStatusNotifyApiImpl, received a NF status notification...");
data_notification_msg notification_msg = {};
// convert from NotificationData to data_notification_msg
xgpp_conv::data_notification_from_openapi(notificationData, notification_msg);
// Handle the message in amf_app
std::shared_ptr<itti_sbi_notification_data> itti_msg =
std::make_shared<itti_sbi_notification_data>(TASK_AMF_SBI, TASK_AMF_APP);
itti_msg->notification_msg = notification_msg;
itti_msg->http_version = 1;
ProblemDetails problem_details = {};
uint8_t http_code = 0;
if (m_amf_app->handle_nf_status_notification(
itti_msg, problem_details, http_code)) {
response.send(Pistache::Http::Code(204));
} else {
nlohmann::json json_data = {};
to_json(json_data, problem_details);
// content type
response.headers().add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType("application/problem+json"));
response.send(Pistache::Http::Code(http_code), json_data.dump().c_str());
}
}
} // namespace api
} // namespace amf
} // namespace oai
/**
* Namf_EventExposure
* Session Management Event Exposure Service. 2019, 3GPP Organizational
* Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 1.1.0.alpha-1
*
*
* NOTE: This class is auto generated by OpenAPI Generator
* (https://openapi-generator.tech). https://openapi-generator.tech Do not edit
* the class manually.
*/
/*
* NFStatusNotifyApiImpl.h
*
*
*/
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef NF_STATUS_NOTIFY_API_IMPL_H_
#define NF_STATUS_NOTIFY_API_IMPL_H_
#include <pistache/endpoint.h>
#include <pistache/http.h>
#include <pistache/router.h>
#include <memory>
#include <NFStatusNotifyApi.h>
#include <pistache/optional.h>
#include "NotificationData.h"
//#include "ProblemDetails.h"
#include "amf_app.hpp"
namespace oai {
namespace amf {
namespace api {
using namespace oai::amf::model;
using namespace amf_application;
class NFStatusNotifyApiImpl : public oai::amf::api::NFStatusNotifyApi {
public:
NFStatusNotifyApiImpl(
std::shared_ptr<Pistache::Rest::Router>, amf_app* amf_app_inst,
std::string address);
~NFStatusNotifyApiImpl() {}
void receive_nf_status_notification(
const NotificationData& notificationData,
Pistache::Http::ResponseWriter& response);
private:
amf_app* m_amf_app;
std::string m_address;
};
} // namespace api
} // namespace amf
} // namespace oai
#endif
/**
* Namf_EventExposure
* Session Management Event Exposure Service. � 2019, 3GPP Organizational
* Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 1.1.0.alpha-1
*
*
* NOTE: This class is auto generated by OpenAPI Generator
* (https://openapi-generator.tech). https://openapi-generator.tech Do not edit
* the class manually.
*/
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include "SubscriptionsCollectionApiImpl.h"
#include "logger.hpp"
#include "amf_msg.hpp"
#include "3gpp_29.518.h"
#include "itti_msg_sbi.hpp"
#include "amf_config.hpp"
#include "3gpp_conversions.hpp"
extern config::amf_config amf_cfg;
namespace oai {
namespace amf {
namespace api {
using namespace oai::amf::model;
using namespace amf_application;
using namespace amf;
SubscriptionsCollectionApiImpl::SubscriptionsCollectionApiImpl(
std::shared_ptr<Pistache::Rest::Router> rtr, amf_app* amf_app_inst,
std::string address)
: SubscriptionsCollectionApi(rtr),
m_amf_app(amf_app_inst),
m_address(address) {}
void SubscriptionsCollectionApiImpl::create_individual_subcription(
const NamfEventExposure& namfEventExposure,
Pistache::Http::ResponseWriter& response) {
Logger::amf_server().info(
"SubscriptionsCollectionApiImpl::create_individual_subcription...");
// Create a message and store the necessary information
Logger::amf_server().debug(
"Create a Event Exposure message and store the necessary information");
event_exposure_msg event_exposure = {};
// Convert from NamfEventExposure to event_exposure_msg
xgpp_conv::amf_event_exposure_notification_from_openapi(
namfEventExposure, event_exposure);
// Handle the message in amf_app
std::shared_ptr<itti_sbi_event_exposure_request> itti_msg =
std::make_shared<itti_sbi_event_exposure_request>(
TASK_AMF_SBI, TASK_AMF_APP);
itti_msg->event_exposure = event_exposure;
itti_msg->http_version = 1;
evsub_id_t sub_id = m_amf_app->handle_event_exposure_subscription(itti_msg);
// Send response
nlohmann::json json_data = {};
to_json(json_data, namfEventExposure);
if (sub_id != -1) {
json_data["subId"] = std::to_string(sub_id);
response.headers().add<Pistache::Http::Header::Location>(
m_address + base + amf_cfg.sbi_api_version + "/namf_event-exposure/" +
std::to_string(sub_id)); // Location header
}
response.headers().add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType("application/json"));
response.send(Pistache::Http::Code(201), json_data.dump().c_str());
}
} // namespace api
} // namespace amf
} // namespace oai
/**
* Namf_EventExposure
* Session Management Event Exposure Service. 2019, 3GPP Organizational
* Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 1.1.0.alpha-1
*
*/
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*
* SubscriptionsCollectionApiImpl.h
*
*
*/
#ifndef SUBSCRIPTIONS_COLLECTION_API_IMPL_H_
#define SUBSCRIPTIONS_COLLECTION_API_IMPL_H_
#include <pistache/endpoint.h>
#include <pistache/http.h>
#include <pistache/router.h>
#include <memory>
#include <SubscriptionsCollectionApi.h>
#include <pistache/optional.h>
#include "NamfEventExposure.h"
#include "ProblemDetails.h"
#include "amf_app.hpp"
namespace oai {
namespace amf {
namespace api {
using namespace oai::amf::model;
using namespace amf_application;
class SubscriptionsCollectionApiImpl
: public oai::amf::api::SubscriptionsCollectionApi {
public:
SubscriptionsCollectionApiImpl(
std::shared_ptr<Pistache::Rest::Router>, amf_app* amf_app_inst,
std::string address);
~SubscriptionsCollectionApiImpl() {}
void create_individual_subcription(
const NamfEventExposure& namfEventExposure,
Pistache::Http::ResponseWriter& response);
private:
amf_app* m_amf_app;
std::string m_address;
protected:
static uint64_t generate_promise_id() {
return util::uint_uid_generator<uint64_t>::get_instance().get_uid();
}
};
} // namespace api
} // namespace amf
} // namespace oai
#endif
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