Nhat Anh | a0bada6 | 2022-11-07 23:06:23 +0700 | [diff] [blame^] | 1 | #ifndef XAPP_MODEL_SubscriptionParams_H |
| 2 | #define XAPP_MODEL_SubscriptionParams_H |
| 3 | #include "ModelBase.h" |
| 4 | #include "SubscriptionDetail.h" |
| 5 | #include "SubscriptionParams_ClientEndpoint.h" |
| 6 | #include "SubscriptionParams_E2SubscriptionDirectives.h" |
| 7 | |
| 8 | namespace xapp { |
| 9 | namespace model { |
| 10 | |
| 11 | struct SubscriptionParams: public ModelBase { |
| 12 | |
| 13 | SubscriptionParams_ClientEndpoint ClientEndpoint; |
| 14 | SubscriptionParams_E2SubscriptionDirectives E2SubscriptionDirectives; |
| 15 | std::string Meid; |
| 16 | int RANFunctionID; |
| 17 | std::string SubscriptionID; |
| 18 | SubscriptionDetailsList m_SubscriptionDetailsList; |
| 19 | |
| 20 | json validator_schema = R"( |
| 21 | { |
| 22 | "$schema": "http://json-schema.org/draft-07/schema#", |
| 23 | "title": "SubscriptionParams", |
| 24 | "properties": { |
| 25 | "SubscriptionId": { |
| 26 | "description": "Optional subscription ID '(Submgr allocates if not given)'", |
| 27 | "type": "string" |
| 28 | }, |
| 29 | "Meid": { |
| 30 | "type": "string" |
| 31 | }, |
| 32 | "RANFunctionId": { |
| 33 | "type": "integer", |
| 34 | "minimum": 0, |
| 35 | "maximum": 4095 |
| 36 | } |
| 37 | }, |
| 38 | "required": [ |
| 39 | "ClientEndpoint", |
| 40 | "Meid", |
| 41 | "RANFunctionId", |
| 42 | "SubscriptionDetails" |
| 43 | ], |
| 44 | "type": "object" |
| 45 | })"_json; |
| 46 | |
| 47 | virtual json get_validator_schema() const { return validator_schema; } |
| 48 | |
| 49 | }; |
| 50 | |
| 51 | void from_json(const json& j, SubscriptionParams& ref) { |
| 52 | |
| 53 | std::cout << __PRETTY_FUNCTION__ << std::endl; |
| 54 | ref.validate_json(j); |
| 55 | j.at("ClientEndpoint").get_to(ref.ClientEndpoint); |
| 56 | |
| 57 | if (j.contains("E2SubscriptionDirectives")) |
| 58 | { |
| 59 | j.at("E2SubscriptionDirectives").get_to(ref.E2SubscriptionDirectives); |
| 60 | } |
| 61 | |
| 62 | if (j.contains("SubscriptionId")) |
| 63 | { |
| 64 | j.at("SubscriptionId").get_to(ref.SubscriptionID); |
| 65 | } |
| 66 | |
| 67 | j.at("Meid").get_to(ref.Meid); |
| 68 | j.at("RANFunctionId").get_to(ref.RANFunctionID); |
| 69 | j.at("SubscriptionDetails").get_to(ref.m_SubscriptionDetailsList); |
| 70 | } |
| 71 | |
| 72 | void to_json(json& j, const SubscriptionParams& ref) { |
| 73 | |
| 74 | j = json { |
| 75 | {"ClientEndpoint", ref.ClientEndpoint}, |
| 76 | {"E2SubscriptionDirectives", ref.E2SubscriptionDirectives}, |
| 77 | {"Meid", ref.Meid}, |
| 78 | {"RANFunctionId", ref.RANFunctionID}, |
| 79 | {"SubscriptionId", ref.SubscriptionID}, |
| 80 | {"SubscriptionDetails", ref.m_SubscriptionDetailsList}, |
| 81 | }; |
| 82 | } |
| 83 | |
| 84 | } /*namespace model*/ |
| 85 | } /*namespace xapp*/ |
| 86 | #endif /*XAPP_MODEL_SubscriptionParams_H*/ |