Updating RMR version to 4.8.5
[ric-plt/xapp-frame-cpp.git] / src / rest / model / SubscriptionDetail.h
1 #ifndef XAPP_MODEL_SubscriptionDetail_H
2 #define XAPP_MODEL_SubscriptionDetail_H
3 #include "ModelBase.h"
4 #include "ActionToBeSetup.h"
5
6 namespace xapp {
7 namespace model {
8
9 using EventTriggerDefinition = std::vector<int>;
10
11 struct SubscriptionDetail: ModelBase {
12     ActionsToBeSetup ActionToBeSetupList;
13     EventTriggerDefinition EventTriggers;
14     int XappEventInstanceID;
15     json validator_schema = R"(
16     {
17     "$schema": "http://json-schema.org/draft-07/schema#",
18     "title": "Subscription detail",
19     "properties": {
20         "XappEventInstanceId": {
21             "type": "integer",
22             "minimum": 0,
23             "maximum": 255
24         },
25         "EventTriggers": {
26             "description": "Identification of Action",
27             "type": "array",
28             "items": {
29                 "type": "integer"
30             }
31         },
32         "ActionToBeSetupList": {
33             "type": "array"
34         }
35     },
36     "required": [
37                  "XappEventInstanceId",
38                  "EventTriggers",
39                  "ActionToBeSetupList"
40                 ],
41     "type": "object"
42     })"_json;
43
44     virtual json get_validator_schema() const { return validator_schema; }
45
46 };
47
48 void from_json(const json& j, SubscriptionDetail& ref) {
49
50     std::cout << __PRETTY_FUNCTION__ << std::endl;
51     ref.validate_json(j);
52
53     j.at("XappEventInstanceId").get_to(ref.XappEventInstanceID);
54     j.at("EventTriggers").get_to(ref.EventTriggers);
55     j.at("ActionToBeSetupList").get_to(ref.ActionToBeSetupList);
56 }
57
58 void to_json(json& j, const SubscriptionDetail& ref) {
59
60     j = json {
61         {"XappEventInstanceId", ref.XappEventInstanceID},
62         {"EventTriggers", ref.EventTriggers},
63         {"ActionToBeSetupList", ref.ActionToBeSetupList},
64     };
65 }
66
67 using SubscriptionDetailsList = std::vector<SubscriptionDetail>;
68
69 } /*namespace model*/
70 } /*namespace xapp*/
71 #endif /*XAPP_MODEL_SubscriptionDetail_H*/