RIC-641 Add client/server model definitions
[ric-plt/xapp-frame-cpp.git] / src / rest / model / ConfigMetadata.h
1 #ifndef XAPP_MODEL_ConfigMetadata_H
2 #define XAPP_MODEL_ConfigMetadata_H
3
4 #include "ModelBase.h"
5
6 namespace xapp {
7 namespace model {
8
9 struct ConfigMetadata: ModelBase {
10     std::string ConfigType;
11     std::string XappName;
12     json validator_schema = R"(
13     {
14     "$schema": "http://json-schema.org/draft-07/schema#",
15     "title": "ConfigMetadata",
16     "properties": {
17         "ConfigType": {
18             "description": "Type of Config",
19             "type": "string",
20             "enum": ["json", "xml", "other"]
21         },
22         "XappName": {
23             "description": "Name of xApp",
24             "type": "string"
25         }
26     },
27     "required": [
28                  "ConfigType",
29                  "XappName"
30                  ],
31     "type": "object"
32     })"_json;
33
34     virtual json get_validator_schema() const { return validator_schema; }
35 };
36
37 void from_json(const json& j, ConfigMetadata& ref) {
38
39     std::cout << __func__ << " ConfigMetadata " << std::endl;
40     ref.validate_json(j);
41     j.at("ConfigType").get_to(ref.ConfigType);
42     j.at("XappName").get_to(ref.XappName);
43 }
44
45 void to_json(json& j, const ConfigMetadata& ref) {
46     j = json {
47         {"ConfigType",ref.ConfigType},
48         {"XappName", ref.XappName}
49     };
50 }
51
52 } /*namespace model*/
53 } /*namespace xapp*/
54 #endif /*XAPP_MODEL_ConfigMetadata_H*/