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

add NFStatusUnSubscribe operation

parent d3c88ee7
/**
* NRF NFManagement Service
* NRF NFManagement Service. © 2019, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
* NRF NFManagement 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.
* NOTE: This class is auto generated by OpenAPI Generator
* (https://openapi-generator.tech). https://openapi-generator.tech Do not edit
* the class manually.
*/
#include "SubscriptionIDDocumentApiImpl.h"
#include "3gpp_29.500.h"
namespace oai {
namespace nrf {
......@@ -22,16 +24,37 @@ using namespace oai::nrf::app;
SubscriptionIDDocumentApiImpl::SubscriptionIDDocumentApiImpl(
std::shared_ptr<Pistache::Rest::Router> rtr, nrf_app *nrf_app_inst,
std::string address)
:
SubscriptionIDDocumentApi(rtr),
m_nrf_app(nrf_app_inst),
m_address(address) {
}
: SubscriptionIDDocumentApi(rtr),
m_nrf_app(nrf_app_inst),
m_address(address) {}
void SubscriptionIDDocumentApiImpl::remove_subscription(
const std::string &subscriptionID,
Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
Logger::nrf_sbi().info(
"Got a request to remove an existing subscription, subscription ID %s",
subscriptionID.c_str());
int http_code = 0;
ProblemDetails problem_details = {};
m_nrf_app->handle_remove_subscription(subscriptionID, http_code, 1, problem_details);
nlohmann::json json_data = {};
std::string content_type = "application/json";
if (http_code != HTTP_STATUS_CODE_204_NO_CONTENT) {
to_json(json_data, problem_details);
content_type = "application/problem+json";
// content type
response.headers().add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType(content_type));
response.send(Pistache::Http::Code(http_code), json_data.dump().c_str());
} else {
// content type
response.headers().add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType(content_type));
response.send(Pistache::Http::Code(http_code));
}
}
void SubscriptionIDDocumentApiImpl::update_subscription(
const std::string &subscriptionID, const std::vector<PatchItem> &patchItem,
......@@ -39,7 +62,6 @@ void SubscriptionIDDocumentApiImpl::update_subscription(
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
}
}
}
}
} // namespace api
} // namespace nrf
} // namespace oai
This diff is collapsed.
......@@ -129,6 +129,7 @@ class nrf_app {
/*
* Handle a Register NF Instance request
* @param [SubscriptionData &] subscription_data: Subscription data
* @param [std::string &] sub_id: Subscription ID
* @param [int &] http_code: HTTP code used to return to the consumer
* @param [const uint8_t] http_version: HTTP version
* @param [ProblemDetails &] problem_details: Store details of the error
......@@ -139,6 +140,17 @@ class nrf_app {
const uint8_t http_version,
ProblemDetails &problem_details);
/*
* Handle a NFStatusUnSubscribe request (removes an existing subscription)
* @param [const std::string &] sub_id: Subscription ID
* @param [int &] http_code: HTTP code used to return to the consumer
* @param [const uint8_t] http_version: HTTP version
* @param [ProblemDetails &] problem_details: Store details of the error
* @return void
*/
void handle_remove_subscription(const std::string &sub_id, int &http_code,
const uint8_t http_version,
ProblemDetails &problem_details);
/*
* Insert a nrf profile
* @param [const std::string &] profile_id: Profile ID
......@@ -214,6 +226,12 @@ class nrf_app {
bool add_subscription(const std::string &sub_id,
const std::shared_ptr<nrf_subscription> &s);
/*
* Remove a subscription from the list
* @param [std::string &] sub_id: ID of the subscription to be removed
* @return true if successful, otherwise, return false
*/
bool remove_subscription(const std::string &sub_id);
/*
* Subscribe to the task tick event
* @param [uint64_t &] ms: Current time in ms
......
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