3d439974899c824b7f142ec41f5f923c4dfeb1f8
[ric-plt/xapp-frame-cpp.git] / src / rest / model / SubscriptionParams_ClientEndpoint.h
1 #ifndef XAPP_MODEL_SubscriptionParams_ClientEndpoint_H
2 #define XAPP_MODEL_SubscriptionParams_ClientEndpoint_H
3 #include "ModelBase.h"
4
5 namespace xapp {
6 namespace model {
7
8 struct SubscriptionParams_ClientEndpoint: ModelBase {
9     int HTTPPort;
10     std::string Host;
11     int RMRPort;
12     json validator_schema = R"(
13     {
14     "$schema": "http://json-schema.org/draft-07/schema#",
15     "title": "SubscriptionParams_ClientEndpoint",
16     "description": "xApp service address and port",
17     "properties": {
18         "HTTPPort": {
19             "description": "xApp HTTP service address port",
20             "type": "integer",
21             "minimum": 0,
22             "maximum": 65535
23         },
24         "Host": {
25             "description": "xApp service address name like service-ricxapp-xappname-http.ricxapp",
26             "type": "string"
27         },
28         "RMRPort": {
29             "description": "xApp RMR service address port",
30             "type": "integer",
31             "minimum": 0,
32             "maximum": 65535
33         }
34     },
35     "required": [
36                  "HTTPPort",
37                  "Host",
38                  "RMRPort"
39                  ],
40     "type": "object"
41     })"_json;
42
43     virtual json get_validator_schema() const { return validator_schema; }
44 };
45
46 void from_json(const json& j, SubscriptionParams_ClientEndpoint& ref) {
47
48     std::cout << __PRETTY_FUNCTION__ << std::endl;
49     ref.validate_json(j);
50     j.at("HTTPPort").get_to(ref.HTTPPort);
51     j.at("Host").get_to(ref.Host);
52     j.at("RMRPort").get_to(ref.RMRPort);
53 }
54
55 void to_json(json& j, const SubscriptionParams_ClientEndpoint& ref) {
56     j = json {
57         {"HTTPPort", ref.HTTPPort},
58         {"Host", ref.Host},
59         {"RMRPort", ref.RMRPort},
60     };
61 }
62
63 } /*namespace model*/
64 } /*namespace xapp*/
65 #endif /*XAPP_MODEL_SubscriptionParams_ClientEndpoint_H*/