blob: 6bb8d55808e275498bcaf65eb28e553a8848a317 [file] [log] [blame]
Nhat Anha0bada62022-11-07 23:06:23 +07001#ifndef XAPP_MODEL_ActionToBeSetup_H
2#define XAPP_MODEL_ActionToBeSetup_H
3#include "ModelBase.h"
4#include "SubsequentAction.h"
5
6namespace xapp {
7namespace model {
8
9using namespace xapp::model;
10using ActionDefinition = std::vector<int>;
11
12struct ActionToBeSetup: ModelBase {
13 ActionDefinition m_ActionDefinition;
14 int ActionID;
15 std::string ActionType;
16 SubsequentAction m_SubsequentAction;
17
18 json validator_schema = R"(
19 {
20 "$schema": "http://json-schema.org/draft-07/schema#",
21 "title": "SubsequentAction",
22 "properties": {
23 "ActionDefinition": {
24 "description": "Action Definition",
25 "type": "array",
26 "items": {
27 "type": "integer"
28 }
29 },
30 "ActionID": {
31 "description": "Identification of Action",
32 "type": "integer",
33 "minimum": 0,
34 "maximum": 255
35 },
36 "ActionType": {
37 "description": "Type of Action",
38 "type": "string",
39 "enum": ["policy", "insert", "report"]
40 },
41 "SubsequentAction": {
42 "description": "Subsequent Action",
43 "type": "object"
44 }
45 },
46 "required": [
47 "ActionDefinition",
48 "ActionID",
49 "ActionType",
50 "SubsequentAction"
51 ],
52 "type": "object"
53 })"_json;
54
55 virtual json get_validator_schema() const { return validator_schema; }
56};
57
58void from_json(const json& j, ActionToBeSetup& ref) {
59
60 std::cout << __PRETTY_FUNCTION__ << std::endl;
61 ref.validate_json(j);
62 j.at("ActionDefinition").get_to(ref.m_ActionDefinition);
63 j.at("ActionID").get_to(ref.ActionID);
64 j.at("ActionType").get_to(ref.ActionType);
65 j.at("SubsequentAction").get_to(ref.m_SubsequentAction);
66
67}
68
69void to_json(json& j, const ActionToBeSetup& ref) {
70
71 j = json {
72 {"ActionDefinition", ref.m_ActionDefinition},
73 {"ActionID", ref.ActionID},
74 {"ActionType", ref.ActionType},
75 {"SubsequentAction", ref.m_SubsequentAction}
76 };
77}
78
79using ActionsToBeSetup = std::vector<ActionToBeSetup>;
80
81} /*namespace model*/
82} /*namespace xapp*/
83
84#endif /* XAPP_MODEL_ActionToBeSetup_H */
85