Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-NRF
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenXG
OpenXG-NRF
Commits
1f17cfcb
Commit
1f17cfcb
authored
Dec 25, 2020
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add RetrieveCompleteSearch and RetrieveStoredSearch operations
parent
463ea1a6
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
254 additions
and
85 deletions
+254
-85
src/api-server/impl/CompleteStoredSearchDocumentApiImpl.cpp
src/api-server/impl/CompleteStoredSearchDocumentApiImpl.cpp
+28
-1
src/api-server/impl/DiscNFInstancesStoreApiImpl.cpp
src/api-server/impl/DiscNFInstancesStoreApiImpl.cpp
+16
-2
src/api-server/impl/StoredSearchDocumentApiImpl.cpp
src/api-server/impl/StoredSearchDocumentApiImpl.cpp
+29
-1
src/nrf_app/nrf_app.cpp
src/nrf_app/nrf_app.cpp
+88
-64
src/nrf_app/nrf_app.hpp
src/nrf_app/nrf_app.hpp
+2
-1
src/nrf_app/nrf_search_result.cpp
src/nrf_app/nrf_search_result.cpp
+46
-10
src/nrf_app/nrf_search_result.hpp
src/nrf_app/nrf_search_result.hpp
+45
-6
No files found.
src/api-server/impl/CompleteStoredSearchDocumentApiImpl.cpp
View file @
1f17cfcb
...
...
@@ -11,6 +11,7 @@
*/
#include "CompleteStoredSearchDocumentApiImpl.h"
#include "3gpp_29.500.h"
namespace
oai
{
namespace
nrf
{
...
...
@@ -30,7 +31,33 @@ CompleteStoredSearchDocumentApiImpl::CompleteStoredSearchDocumentApiImpl(
void
CompleteStoredSearchDocumentApiImpl
::
retrieve_complete_search
(
const
std
::
string
&
searchId
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
response
.
send
(
Pistache
::
Http
::
Code
::
Ok
,
"Do some magic
\n
"
);
Logger
::
nrf_sbi
().
info
(
"Got a request to retrieve a complete search with ID %s"
,
searchId
.
c_str
());
nlohmann
::
json
sr_json
=
{
};
nlohmann
::
json
json_data
=
{
};
json_data
[
"nfInstances"
]
=
nlohmann
::
json
::
array
();
std
::
string
content_type
=
"application/json"
;
std
::
shared_ptr
<
nrf_search_result
>
search_result
=
{
};
m_nrf_app
->
find_search_result
(
searchId
,
search_result
);
// convert the profile to Json
if
(
search_result
!=
nullptr
)
{
search_result
.
get
()
->
to_json
(
sr_json
,
0
);
//with maximum number of NF profiles
json_data
[
"nfInstances"
]
=
sr_json
[
"nfInstances"
];
}
Logger
::
nrf_sbi
().
debug
(
"Json data: %s"
,
json_data
.
dump
().
c_str
());
// content type
response
.
headers
().
add
<
Pistache
::
Http
::
Header
::
ContentType
>
(
Pistache
::
Http
::
Mime
::
MediaType
(
content_type
));
response
.
send
(
Pistache
::
Http
::
Code
(
HTTP_STATUS_CODE_200_OK
),
json_data
.
dump
().
c_str
());
}
}
...
...
src/api-server/impl/DiscNFInstancesStoreApiImpl.cpp
View file @
1f17cfcb
...
...
@@ -102,13 +102,22 @@ void DiscNFInstancesStoreApiImpl::search_nf_instances(
Logger
::
nrf_sbi
().
debug
(
"
\t
Requested NF instance id: %s"
,
requester_nf_instance_id
.
c_str
());
}
uint32_t
limit_nfs
=
0
;
if
(
!
limit
.
isEmpty
())
{
limit_nfs
=
limit
.
get
();
Logger
::
nrf_sbi
().
debug
(
"
\t
Maximum number of NFProfiles to be returned in the response: %d"
,
limit_nfs
);
}
// TODO: other query parameters
int
http_code
=
0
;
ProblemDetails
problem_details
=
{};
std
::
string
search_id
=
{};
m_nrf_app
->
handle_search_nf_instances
(
target_nf_type
,
requester_nf_type
,
requester_nf_instance_id
,
search_id
,
requester_nf_instance_id
,
limit_nfs
,
search_id
,
http_code
,
1
,
problem_details
);
nlohmann
::
json
json_data
=
{};
...
...
@@ -122,14 +131,19 @@ void DiscNFInstancesStoreApiImpl::search_nf_instances(
content_type
=
"application/problem+json"
;
}
else
{
// convert the profile to Json
if
(
search_result
!=
nullptr
)
search_result
.
get
()
->
to_json
(
json_data
);
if
(
search_result
!=
nullptr
)
search_result
.
get
()
->
to_json
(
json_data
,
limit_nfs
);
}
//TODO: applying client restrictions in terms of the number of
//instances to be returned (i.e. "limit" or "max-
//payload-size" query parameters) .
Logger
::
nrf_sbi
().
debug
(
"Json data: %s"
,
json_data
.
dump
().
c_str
());
// content type
response
.
headers
().
add
<
Pistache
::
Http
::
Header
::
ContentType
>
(
Pistache
::
Http
::
Mime
::
MediaType
(
content_type
));
//TODO: add headers: Cache-Control, ETag
response
.
send
(
Pistache
::
Http
::
Code
(
http_code
),
json_data
.
dump
().
c_str
());
}
...
...
src/api-server/impl/StoredSearchDocumentApiImpl.cpp
View file @
1f17cfcb
...
...
@@ -11,6 +11,7 @@
*/
#include "StoredSearchDocumentApiImpl.h"
#include "3gpp_29.500.h"
namespace
oai
{
namespace
nrf
{
...
...
@@ -30,7 +31,34 @@ StoredSearchDocumentApiImpl::StoredSearchDocumentApiImpl(
void
StoredSearchDocumentApiImpl
::
retrieve_stored_search
(
const
std
::
string
&
searchId
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
response
.
send
(
Pistache
::
Http
::
Code
::
Ok
,
"Do some magic
\n
"
);
Logger
::
nrf_sbi
().
info
(
"Got a request to retrieve a stored search with ID %s"
,
searchId
.
c_str
());
nlohmann
::
json
sr_json
=
{
};
nlohmann
::
json
json_data
=
{
};
json_data
[
"nfInstances"
]
=
nlohmann
::
json
::
array
();
std
::
string
content_type
=
"application/json"
;
std
::
shared_ptr
<
nrf_search_result
>
search_result
=
{
};
m_nrf_app
->
find_search_result
(
searchId
,
search_result
);
// convert the profile to Json
if
(
search_result
!=
nullptr
)
{
search_result
.
get
()
->
to_json
(
sr_json
,
search_result
.
get
()
->
get_limit_nf_instances
());
json_data
[
"nfInstances"
]
=
sr_json
[
"nfInstances"
];
}
Logger
::
nrf_sbi
().
debug
(
"Json data: %s"
,
json_data
.
dump
().
c_str
());
// content type
response
.
headers
().
add
<
Pistache
::
Http
::
Header
::
ContentType
>
(
Pistache
::
Http
::
Mime
::
MediaType
(
content_type
));
//TODO: add headers: Cache-Control, ETag
response
.
send
(
Pistache
::
Http
::
Code
(
HTTP_STATUS_CODE_200_OK
),
json_data
.
dump
().
c_str
());
}
}
...
...
src/nrf_app/nrf_app.cpp
View file @
1f17cfcb
This diff is collapsed.
Click to expand it.
src/nrf_app/nrf_app.hpp
View file @
1f17cfcb
...
...
@@ -179,6 +179,7 @@ class nrf_app {
* @param [const std::string &] requester_nf_type: Requester NF type
* @param [const std::string &] requester_nf_instance_id: Requester NF
* instance id
* @param [uint32_t &] limit_nfs: Maximum number of NFProfiles to be returned in the response:
* @param [std::string &] search_id: Store search result ID
* @param [int &] http_code: HTTP code used to return to the consumer
* @param [const uint8_t] http_version: HTTP version
...
...
@@ -188,7 +189,7 @@ class nrf_app {
void
handle_search_nf_instances
(
const
std
::
string
&
target_nf_type
,
const
std
::
string
&
requester_nf_type
,
const
std
::
string
&
requester_nf_instance_id
,
std
::
string
&
search_id
,
uint32_t
&
limit_nfs
,
std
::
string
&
search_id
,
int
&
http_code
,
const
uint8_t
http_version
,
ProblemDetails
&
problem_details
);
...
...
src/nrf_app/nrf_search_result.cpp
View file @
1f17cfcb
...
...
@@ -36,13 +36,19 @@
using
namespace
oai
::
nrf
::
app
;
//------------------------------------------------------------------------------
void
nrf_search_result
::
set_search_id
(
const
std
::
string
&
id
)
{
search_id
=
id
;
}
void
nrf_search_result
::
set_search_id
(
const
std
::
string
&
id
)
{
search_id
=
id
;
}
//------------------------------------------------------------------------------
void
nrf_search_result
::
get_search_id
(
std
::
string
&
id
)
const
{
id
=
search_id
;
}
void
nrf_search_result
::
get_search_id
(
std
::
string
&
id
)
const
{
id
=
search_id
;
}
//------------------------------------------------------------------------------
std
::
string
nrf_search_result
::
get_search_id
()
const
{
return
search_id
;
}
std
::
string
nrf_search_result
::
get_search_id
()
const
{
return
search_id
;
}
//------------------------------------------------------------------------------
void
nrf_search_result
::
set_nf_instances
(
...
...
@@ -63,8 +69,7 @@ void nrf_search_result::get_nf_instances(
}
//------------------------------------------------------------------------------
std
::
vector
<
std
::
shared_ptr
<
nrf_profile
>>
nrf_search_result
::
get_nf_instances
()
const
{
std
::
vector
<
std
::
shared_ptr
<
nrf_profile
>>
nrf_search_result
::
get_nf_instances
()
const
{
return
nf_instances
;
}
...
...
@@ -83,6 +88,30 @@ uint64_t nrf_search_result::get_validity_period() const {
return
validity_period
;
}
//------------------------------------------------------------------------------
void
nrf_search_result
::
set_num_nf_inst_complete
(
const
uint32_t
&
n
)
{
num_nf_inst_complete
=
n
;
}
//------------------------------------------------------------------------------
void
nrf_search_result
::
get_num_nf_inst_complete
(
uint32_t
&
n
)
const
{
n
=
num_nf_inst_complete
;
}
//------------------------------------------------------------------------------
void
nrf_search_result
::
set_limit_nf_instances
(
const
uint32_t
&
l
)
{
limit_nf_instances
=
l
;
}
//------------------------------------------------------------------------------
void
nrf_search_result
::
get_limit_nf_instances
(
uint32_t
&
l
)
const
{
l
=
limit_nf_instances
;
}
//------------------------------------------------------------------------------
uint32_t
nrf_search_result
::
get_limit_nf_instances
()
const
{
return
limit_nf_instances
;
}
//------------------------------------------------------------------------------
void
nrf_search_result
::
display
()
{
Logger
::
nrf_app
().
debug
(
"Search result information"
);
...
...
@@ -97,15 +126,22 @@ void nrf_search_result::display() {
}
//------------------------------------------------------------------------------
void
nrf_search_result
::
to_json
(
nlohmann
::
json
&
data
)
const
{
data
=
{};
void
nrf_search_result
::
to_json
(
nlohmann
::
json
&
data
,
const
uint32_t
&
limit_nfs
)
const
{
data
=
{
};
data
[
"validityPeriod"
]
=
validity_period
;
data
[
"nfInstances"
]
=
nlohmann
::
json
::
array
();
uint32_t
limit
=
limit_nfs
>
0
?
limit_nfs
:
nf_instances
.
size
();
int
i
=
0
;
for
(
auto
instance
:
nf_instances
)
{
nlohmann
::
json
instance_json
=
{};
instance
.
get
()
->
to_json
(
instance_json
);
data
[
"nfInstances"
].
push_back
(
instance_json
);
if
(
i
<
limit
)
{
nlohmann
::
json
instance_json
=
{
};
instance
.
get
()
->
to_json
(
instance_json
);
data
[
"nfInstances"
].
push_back
(
instance_json
);
}
else
{
break
;
}
i
++
;
}
data
[
"searchId"
]
=
search_id
;
}
src/nrf_app/nrf_search_result.hpp
View file @
1f17cfcb
...
...
@@ -41,16 +41,17 @@ using namespace std;
class
nrf_search_result
{
public:
nrf_search_result
(){
};
nrf_search_result
(
nrf_search_result
const
&
)
=
delete
;
nrf_search_result
()
{
limit_nf_instances
=
10
;
//default value, TODO: to be removed
}
;
nrf_search_result
(
nrf_search_result
const
&
)
=
delete
;
virtual
~
nrf_search_result
()
{
Logger
::
nrf_app
().
debug
(
"Delete NRF Subscription instance..."
);
}
void
operator
=
(
nrf_search_result
const
&
)
=
delete
;
void
operator
=
(
nrf_search_result
const
&
)
=
delete
;
/*
* Set the search id
...
...
@@ -128,6 +129,41 @@ class nrf_search_result {
*/
uint64_t
get_validity_period
()
const
;
/*
* Set the the total number of NF Instances found by NRF
* @param [const uint32_t &] n: the total number of NF Instances found by NRF
* @return void
*/
void
set_num_nf_inst_complete
(
const
uint32_t
&
n
);
/*
* Get the the total number of NF Instances found by NRF
* @param [uint32_t &] n: the total number of NF Instances found by NRF
* @return void
*/
void
get_num_nf_inst_complete
(
uint32_t
&
n
)
const
;
/*
* Set the maximum number of NFProfiles to be returned in the response
* @param [const uint32_t &] l: the maximum number of NFProfiles to be returned in the response
* @return void
*/
void
set_limit_nf_instances
(
const
uint32_t
&
l
);
/*
* Get the maximum number of NFProfiles to be returned in the response
* @param [uint32_t &] l: the maximum number of NFProfiles to be returned in the response
* @return void
*/
void
get_limit_nf_instances
(
uint32_t
&
l
)
const
;
/*
* Get the maximum number of NFProfiles to be returned in the response
* @param [void]
* @return the maximum number of NFProfiles to be returned in the response
*/
uint32_t
get_limit_nf_instances
()
const
;
/*
* Display all the members of a subscription
* @param [void]
...
...
@@ -138,15 +174,18 @@ class nrf_search_result {
/*
* Represent NF profile as json object
* @param [nlohmann::json &] data: Json data
* @param [uint32_t &] limit_nfs: maximum number of NF profiles stored in the json data
* 0, means without any restriction
* @return void
*/
void
to_json
(
nlohmann
::
json
&
data
)
const
;
void
to_json
(
nlohmann
::
json
&
data
,
const
uint32_t
&
limit_nfs
)
const
;
private:
std
::
vector
<
std
::
shared_ptr
<
nrf_profile
>>
nf_instances
;
std
::
string
search_id
;
uint64_t
validity_period
;
uint32_t
num_nf_inst_complete
;
uint32_t
limit_nf_instances
;
std
::
string
nrf_supported_features
;
};
}
// namespace app
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment