X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Frest%2Fmodel%2FSubscriptionInstance.h;fp=src%2Frest%2Fmodel%2FSubscriptionInstance.h;h=f427e791c31ca8fb9e89c42859bb8aca9479a525;hb=a0bada6bf7af92d281c381092e7d6881c67d905f;hp=0000000000000000000000000000000000000000;hpb=488447aed60cc52b06d71d50bee4ecf10025f7e1;p=ric-plt%2Fxapp-frame-cpp.git diff --git a/src/rest/model/SubscriptionInstance.h b/src/rest/model/SubscriptionInstance.h new file mode 100644 index 0000000..f427e79 --- /dev/null +++ b/src/rest/model/SubscriptionInstance.h @@ -0,0 +1,83 @@ +#ifndef XAPP_MODEL_SubscriptionInstance_H +#define XAPP_MODEL_SubscriptionInstance_H +#include "ModelBase.h" + +namespace xapp { +namespace model { + +struct SubscriptionInstance: ModelBase { + int E2EventInstanceID; + std::string ErrorCause; + std::string ErrorSource; + std::string TimeoutType; + int XappEventInstanceID; + + json validator_schema = R"( + { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "SubscriptionInstance", + "description": "xApp service address and port", + "properties": { + "XappEventInstanceId": { + "type": "integer", + "minimum": 0, + "maximum": 65535 + }, + "E2EventInstanceId": { + "type": "integer", + "minimum": 0, + "maximum": 65535 + }, + "ErrorCause": { + "description": "Descriptive error cause. Empty string when no error.", + "type": "string" + }, + "ErrorSource": { + "description": "Source of error cause.", + "type": "string", + "enum": ["SUBMGR", "RTMGR", "DBAAS", "ASN1", "E2Node"] + }, + "TimeoutType": { + "description": "Type timeout. xApp should retry if timeout occurs.", + "type": "string", + "enum": ["E2-Timeout", "RTMGR-Timeout", "DBAAS-Timeout"] + } + }, + "required": [ + "XappEventInstanceId", + "E2EventInstanceId" + ], + "type": "object" + })"_json; + + virtual json get_validator_schema() const { return validator_schema; } +}; + +void from_json(const json& j, SubscriptionInstance& ref) { + + std::cout << __PRETTY_FUNCTION__ << std::endl; + ref.validate_json(j); + + j.at("XappEventInstanceId").get_to(ref.XappEventInstanceID); + j.at("E2EventInstanceId").get_to(ref.E2EventInstanceID); + j.at("ErrorCause").get_to(ref.ErrorCause); + j.at("ErrorSource").get_to(ref.ErrorSource); + j.at("TimeoutType").get_to(ref.TimeoutType); +} + +void to_json(json& j, const SubscriptionInstance& ref) { + + j = json { + {"XappEventInstanceId", ref.XappEventInstanceID}, + {"E2EventInstanceId", ref.E2EventInstanceID}, + {"ErrorCause", ref.ErrorCause}, + {"ErrorSource", ref.ErrorSource}, + {"TimeoutType", ref.TimeoutType} + }; +} + +using SubscriptionInstances = std::vector; + +} /*namespace model*/ +} /*namespace xapp*/ +#endif /*XAPP_MODEL_SubscriptionInstance_H*/