mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-11-02 03:27:51 +00:00
Adding subscriber device search
This commit is contained in:
@@ -301,6 +301,20 @@ namespace OpenWifi::SecurityObjects {
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void UserInfoList::to_json(Poco::JSON::Object &Obj) const {
|
||||||
|
field_to_json(Obj,"users",users);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UserInfoList::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
|
try {
|
||||||
|
field_from_json(Obj,"users",users);
|
||||||
|
return true;
|
||||||
|
} catch (...) {
|
||||||
|
std::cout << "Cannot parse: InternalServiceInfo" << std::endl;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void InternalServiceInfo::to_json(Poco::JSON::Object &Obj) const {
|
void InternalServiceInfo::to_json(Poco::JSON::Object &Obj) const {
|
||||||
field_to_json(Obj,"privateURI",privateURI);
|
field_to_json(Obj,"privateURI",privateURI);
|
||||||
field_to_json(Obj,"publicURI",publicURI);
|
field_to_json(Obj,"publicURI",publicURI);
|
||||||
|
|||||||
@@ -146,6 +146,13 @@ namespace OpenWifi {
|
|||||||
};
|
};
|
||||||
typedef std::vector<UserInfo> UserInfoVec;
|
typedef std::vector<UserInfo> UserInfoVec;
|
||||||
|
|
||||||
|
struct UserInfoList {
|
||||||
|
std::vector<UserInfo> users;
|
||||||
|
|
||||||
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
|
};
|
||||||
|
|
||||||
// bool append_from_json(Poco::JSON::Object::Ptr Obj, const UserInfo &UInfo, NoteInfoVec & Notes);
|
// bool append_from_json(Poco::JSON::Object::Ptr Obj, const UserInfo &UInfo, NoteInfoVec & Notes);
|
||||||
bool MergeNotes(Poco::JSON::Object::Ptr Obj, const UserInfo &UInfo, NoteInfoVec & Notes);
|
bool MergeNotes(Poco::JSON::Object::Ptr Obj, const UserInfo &UInfo, NoteInfoVec & Notes);
|
||||||
bool MergeNotes(const NoteInfoVec & NewNotes, const UserInfo &UInfo, NoteInfoVec & ExistingNotes);
|
bool MergeNotes(const NoteInfoVec & NewNotes, const UserInfo &UInfo, NoteInfoVec & ExistingNotes);
|
||||||
|
|||||||
@@ -2,9 +2,11 @@
|
|||||||
// Created by stephane bourque on 2021-11-01.
|
// Created by stephane bourque on 2021-11-01.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include "framework/MicroService.h"
|
||||||
#include "WebSocketClientServer.h"
|
#include "WebSocketClientServer.h"
|
||||||
#include "SerialNumberCache.h"
|
#include "SerialNumberCache.h"
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
#include "sdks/SDK_sec.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
void WebSocketClientServer::run() {
|
void WebSocketClientServer::run() {
|
||||||
@@ -185,7 +187,26 @@ namespace OpenWifi {
|
|||||||
void WebSocketClient::ws_command_subuser_search( const Poco::JSON::Object::Ptr &O, bool &Done, std::string &Answer) {
|
void WebSocketClient::ws_command_subuser_search( const Poco::JSON::Object::Ptr &O, bool &Done, std::string &Answer) {
|
||||||
Done = false;
|
Done = false;
|
||||||
auto operatorId = O->get("operatorId").toString();
|
auto operatorId = O->get("operatorId").toString();
|
||||||
Answer = std::string{R"lit({ "error" : "not implemented" })lit"};
|
std::string nameSearch, emailSearch;
|
||||||
|
OpenWifi::RESTAPIHandler::AssignIfPresent(O,"nameSearch",nameSearch);
|
||||||
|
OpenWifi::RESTAPIHandler::AssignIfPresent(O,"emailSearch",emailSearch);
|
||||||
|
SecurityObjects::UserInfoList Users;
|
||||||
|
SDK::Sec::Subscriber::Search(nullptr,operatorId,nameSearch,emailSearch,Users);
|
||||||
|
|
||||||
|
Poco::JSON::Array Arr;
|
||||||
|
for(const auto &i:Users.users) {
|
||||||
|
Poco::JSON::Object OO;
|
||||||
|
OO.set("name", i.name);
|
||||||
|
OO.set("email", i.email);
|
||||||
|
OO.set("id", i.id);
|
||||||
|
i.to_json(OO);
|
||||||
|
Arr.add(OO);
|
||||||
|
}
|
||||||
|
Poco::JSON::Object ObjAnswer;
|
||||||
|
ObjAnswer.set("users", Arr);
|
||||||
|
std::ostringstream SS;
|
||||||
|
Poco::JSON::Stringifier::stringify(ObjAnswer, SS);
|
||||||
|
Answer = SS.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebSocketClient::ws_command_subdevice_search( const Poco::JSON::Object::Ptr &O, bool &Done, std::string &Answer) {
|
void WebSocketClient::ws_command_subdevice_search( const Poco::JSON::Object::Ptr &O, bool &Done, std::string &Answer) {
|
||||||
|
|||||||
@@ -79,6 +79,25 @@ namespace OpenWifi::SDK::Sec {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Search([[maybe_unused]] RESTAPIHandler *client, const std::string &OperatorId,
|
||||||
|
const std::string &Name, const std::string &EMail, SecurityObjects::UserInfoList &Users) {
|
||||||
|
OpenAPIRequestGet Req( uSERVICE_SECURITY,
|
||||||
|
"/api/v1/subusers",
|
||||||
|
{
|
||||||
|
{"operatorId", OperatorId} ,
|
||||||
|
{"nameSearch", Name} ,
|
||||||
|
{"emailSearch", EMail}
|
||||||
|
},
|
||||||
|
5000);
|
||||||
|
auto CallResponse = Poco::makeShared<Poco::JSON::Object>();
|
||||||
|
auto StatusCode = Req.Do(CallResponse);
|
||||||
|
if( StatusCode == Poco::Net::HTTPResponse::HTTP_OK) {
|
||||||
|
return Users.from_json(CallResponse);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ namespace OpenWifi::SDK::Sec {
|
|||||||
bool Exists(RESTAPIHandler *client, const Types::UUID_t & User);
|
bool Exists(RESTAPIHandler *client, const Types::UUID_t & User);
|
||||||
bool Get(RESTAPIHandler *client, const Types::UUID_t & User, SecurityObjects::UserInfo & UserInfo);
|
bool Get(RESTAPIHandler *client, const Types::UUID_t & User, SecurityObjects::UserInfo & UserInfo);
|
||||||
bool Delete(RESTAPIHandler *client, const Types::UUID_t & User);
|
bool Delete(RESTAPIHandler *client, const Types::UUID_t & User);
|
||||||
|
bool Search(RESTAPIHandler *client, const std::string &OperatorId, const std::string &Name,
|
||||||
|
const std::string &EMail, SecurityObjects::UserInfoList &Users);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user