Loading go-apps/meep-app-enablement/server/capif-mgmt/api_mec_service_mgmt.go +3 −1 Original line number Original line Diff line number Diff line Loading @@ -66,7 +66,9 @@ func ApplicationsSubscriptionsGET(w http.ResponseWriter, r *http.Request) { func ApplicationsSubscriptionsPOST(w http.ResponseWriter, r *http.Request) { func ApplicationsSubscriptionsPOST(w http.ResponseWriter, r *http.Request) { applicationsSubscriptionsPOST(w, r) applicationsSubscriptionsPOST(w, r) } } func ApplicationsSubscriptionsPUT(w http.ResponseWriter, r *http.Request) { applicationsSubscriptionsPUT(w, r) } func ServicesGET(w http.ResponseWriter, r *http.Request) { func ServicesGET(w http.ResponseWriter, r *http.Request) { servicesGET(w, r) servicesGET(w, r) } } Loading go-apps/meep-app-enablement/server/capif-mgmt/convert.go +17 −0 Original line number Original line Diff line number Diff line Loading @@ -87,6 +87,23 @@ func convertJsonToSerAvailabilityNotifSub(jsonData string) *SerAvailabilityNotif return &obj return &obj } } func convertEventFiltersToStrings(filters []CapifEventFilter) []string { var stringFilters []string for _, filter := range filters { stringFilters = append(stringFilters, filter.ApiIds...) } return stringFilters } func convertEventToStrings(events []CapifEvent) []string { var stringEvents []string if len(events) > 0 { // Directly convert CapifEvent to string and append stringEvents = append(stringEvents, string(events[0])) } return stringEvents } func convertJsonToSerAvailabilityNotifSub_1(jsonData string) *EventSubscription { func convertJsonToSerAvailabilityNotifSub_1(jsonData string) *EventSubscription { var obj EventSubscription var obj EventSubscription err := json.Unmarshal([]byte(jsonData), &obj) err := json.Unmarshal([]byte(jsonData), &obj) Loading go-apps/meep-app-enablement/server/capif-mgmt/service-mgmt.go +94 −0 Original line number Original line Diff line number Diff line Loading @@ -882,6 +882,92 @@ func servicesGET(w http.ResponseWriter, r *http.Request) { } } } } func applicationsSubscriptionsPUT(w http.ResponseWriter, r *http.Request) { log.Info("applicationsSubscriptionsPUT") w.Header().Set("Content-Type", "application/json; charset=UTF-8") vars := mux.Vars(r) subId := vars["subscriptionId"] appId := vars["subscriberId"] mutex.Lock() defer mutex.Unlock() // Get App instance appInfo, err := getAppInfo(appId) if err != nil { errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } // Validate App info code, problemDetails, err := validateAppInfo(appInfo) if err != nil { log.Error(err.Error()) if problemDetails != "" { w.WriteHeader(code) fmt.Fprint(w, problemDetails) } else { errHandlerProblemDetails(w, err.Error(), code) } return } sub, err := subMgr.GetSubscription(subId) if err != nil { log.Error("Subscription not found: ", err.Error()) errHandlerProblemDetails(w, "Subscription not found", http.StatusNotFound) return } // Retrieve the update request if r.Body == nil { err := errors.New("Request body is missing") errHandlerProblemDetails(w, err.Error(), http.StatusBadRequest) return } var updatedSub EventSubscription decoder := json.NewDecoder(r.Body) err = decoder.Decode(&updatedSub) if err != nil { log.Error(err.Error()) errHandlerProblemDetails(w, "Failed to decode request body", http.StatusInternalServerError) return } if updatedSub.NotificationDestination == "" { log.Error("Either NotificationDestination must be set") errHandlerProblemDetails(w, "Either NotificationDestination must be set", http.StatusBadRequest) return } // Update the subscription object if updatedSub.NotificationDestination != "" { sub.Cfg.NotifyUrl = updatedSub.NotificationDestination } if updatedSub.RequestTestNotification { sub.Cfg.RequestTestNotif = true } // if updatedSub.RequestWebsocketUri { // sub.Cfg.RequestWebsocketUri = true // } else { // sub.Cfg.RequestWebsocketUri = false // } // Update event filters if provided if updatedSub.EventFilters != nil { sub.Cfg.EventFilters = convertEventFiltersToStrings(updatedSub.EventFilters) } if updatedSub.Events != nil { sub.Cfg.CapifEvent = convertEventToStrings(updatedSub.Events) } // Update the subscription in the manager err = subMgr.UpdateSubscription(sub) if err != nil { log.Error("Failed to update subscription: ", err.Error()) errHandlerProblemDetails(w, "Failed to update subscription", http.StatusInternalServerError) return } jsonSub := convertSerAvailabilityNotifSubToJson_1(&updatedSub) // Send success response w.WriteHeader(http.StatusOK) fmt.Fprint(w, jsonSub) } func applicationsSubscriptionsPOST(w http.ResponseWriter, r *http.Request) { func applicationsSubscriptionsPOST(w http.ResponseWriter, r *http.Request) { log.Info("applicationsSubscriptionsPOST") log.Info("applicationsSubscriptionsPOST") Loading Loading @@ -2040,6 +2126,12 @@ func newSerAvailabilityNotifSubCfg(sub *SerAvailabilityNotificationSubscription, } } func newSerAvailabilityNotifSubCfg_1(sub *EventSubscription, subId string, appId string) *subs.SubscriptionCfg { func newSerAvailabilityNotifSubCfg_1(sub *EventSubscription, subId string, appId string) *subs.SubscriptionCfg { var eventFilters []string for _, filter := range sub.EventFilters { eventFilters = append(eventFilters, filter.ApiIds...) } var capifEvent []string capifEvent = append(capifEvent, string(sub.Events[0])) subCfg := &subs.SubscriptionCfg{ subCfg := &subs.SubscriptionCfg{ Id: subId, Id: subId, AppId: appId, AppId: appId, Loading @@ -2050,6 +2142,8 @@ func newSerAvailabilityNotifSubCfg_1(sub *EventSubscription, subId string, appId PeriodicInterval: 0, PeriodicInterval: 0, RequestTestNotif: false, RequestTestNotif: false, RequestWebsocketUri: false, RequestWebsocketUri: false, EventFilters: eventFilters, CapifEvent: capifEvent, } } return subCfg return subCfg } } Loading go-apps/meep-app-enablement/server/routers.go +7 −0 Original line number Original line Diff line number Diff line Loading @@ -392,6 +392,13 @@ var routes = Routes{ capifMgmt.ApplicationsSubscriptionsPOST, capifMgmt.ApplicationsSubscriptionsPOST, }, }, Route{ "ApplicationsSubscriptionsPUT", strings.ToUpper("Put"), "/capif-events/v1/{subscriberId}/subscriptions/{subscriptionId} ", capifMgmt.ApplicationsSubscriptionsPUT, }, Route{ Route{ "Index", "Index", "GET", "GET", Loading go-packages/meep-subscriptions/subscription.go +2 −0 Original line number Original line Diff line number Diff line Loading @@ -40,6 +40,8 @@ type SubscriptionCfg struct { PeriodicInterval int32 `json:"periodicInterval"` PeriodicInterval int32 `json:"periodicInterval"` RequestTestNotif bool `json:"reqTestNotif"` RequestTestNotif bool `json:"reqTestNotif"` RequestWebsocketUri bool `json:"reqWebsockUri"` RequestWebsocketUri bool `json:"reqWebsockUri"` EventFilters []string `json:"eventFilters"` CapifEvent []string `json:"capifEvent"` } } type Subscription struct { type Subscription struct { Loading Loading
go-apps/meep-app-enablement/server/capif-mgmt/api_mec_service_mgmt.go +3 −1 Original line number Original line Diff line number Diff line Loading @@ -66,7 +66,9 @@ func ApplicationsSubscriptionsGET(w http.ResponseWriter, r *http.Request) { func ApplicationsSubscriptionsPOST(w http.ResponseWriter, r *http.Request) { func ApplicationsSubscriptionsPOST(w http.ResponseWriter, r *http.Request) { applicationsSubscriptionsPOST(w, r) applicationsSubscriptionsPOST(w, r) } } func ApplicationsSubscriptionsPUT(w http.ResponseWriter, r *http.Request) { applicationsSubscriptionsPUT(w, r) } func ServicesGET(w http.ResponseWriter, r *http.Request) { func ServicesGET(w http.ResponseWriter, r *http.Request) { servicesGET(w, r) servicesGET(w, r) } } Loading
go-apps/meep-app-enablement/server/capif-mgmt/convert.go +17 −0 Original line number Original line Diff line number Diff line Loading @@ -87,6 +87,23 @@ func convertJsonToSerAvailabilityNotifSub(jsonData string) *SerAvailabilityNotif return &obj return &obj } } func convertEventFiltersToStrings(filters []CapifEventFilter) []string { var stringFilters []string for _, filter := range filters { stringFilters = append(stringFilters, filter.ApiIds...) } return stringFilters } func convertEventToStrings(events []CapifEvent) []string { var stringEvents []string if len(events) > 0 { // Directly convert CapifEvent to string and append stringEvents = append(stringEvents, string(events[0])) } return stringEvents } func convertJsonToSerAvailabilityNotifSub_1(jsonData string) *EventSubscription { func convertJsonToSerAvailabilityNotifSub_1(jsonData string) *EventSubscription { var obj EventSubscription var obj EventSubscription err := json.Unmarshal([]byte(jsonData), &obj) err := json.Unmarshal([]byte(jsonData), &obj) Loading
go-apps/meep-app-enablement/server/capif-mgmt/service-mgmt.go +94 −0 Original line number Original line Diff line number Diff line Loading @@ -882,6 +882,92 @@ func servicesGET(w http.ResponseWriter, r *http.Request) { } } } } func applicationsSubscriptionsPUT(w http.ResponseWriter, r *http.Request) { log.Info("applicationsSubscriptionsPUT") w.Header().Set("Content-Type", "application/json; charset=UTF-8") vars := mux.Vars(r) subId := vars["subscriptionId"] appId := vars["subscriberId"] mutex.Lock() defer mutex.Unlock() // Get App instance appInfo, err := getAppInfo(appId) if err != nil { errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } // Validate App info code, problemDetails, err := validateAppInfo(appInfo) if err != nil { log.Error(err.Error()) if problemDetails != "" { w.WriteHeader(code) fmt.Fprint(w, problemDetails) } else { errHandlerProblemDetails(w, err.Error(), code) } return } sub, err := subMgr.GetSubscription(subId) if err != nil { log.Error("Subscription not found: ", err.Error()) errHandlerProblemDetails(w, "Subscription not found", http.StatusNotFound) return } // Retrieve the update request if r.Body == nil { err := errors.New("Request body is missing") errHandlerProblemDetails(w, err.Error(), http.StatusBadRequest) return } var updatedSub EventSubscription decoder := json.NewDecoder(r.Body) err = decoder.Decode(&updatedSub) if err != nil { log.Error(err.Error()) errHandlerProblemDetails(w, "Failed to decode request body", http.StatusInternalServerError) return } if updatedSub.NotificationDestination == "" { log.Error("Either NotificationDestination must be set") errHandlerProblemDetails(w, "Either NotificationDestination must be set", http.StatusBadRequest) return } // Update the subscription object if updatedSub.NotificationDestination != "" { sub.Cfg.NotifyUrl = updatedSub.NotificationDestination } if updatedSub.RequestTestNotification { sub.Cfg.RequestTestNotif = true } // if updatedSub.RequestWebsocketUri { // sub.Cfg.RequestWebsocketUri = true // } else { // sub.Cfg.RequestWebsocketUri = false // } // Update event filters if provided if updatedSub.EventFilters != nil { sub.Cfg.EventFilters = convertEventFiltersToStrings(updatedSub.EventFilters) } if updatedSub.Events != nil { sub.Cfg.CapifEvent = convertEventToStrings(updatedSub.Events) } // Update the subscription in the manager err = subMgr.UpdateSubscription(sub) if err != nil { log.Error("Failed to update subscription: ", err.Error()) errHandlerProblemDetails(w, "Failed to update subscription", http.StatusInternalServerError) return } jsonSub := convertSerAvailabilityNotifSubToJson_1(&updatedSub) // Send success response w.WriteHeader(http.StatusOK) fmt.Fprint(w, jsonSub) } func applicationsSubscriptionsPOST(w http.ResponseWriter, r *http.Request) { func applicationsSubscriptionsPOST(w http.ResponseWriter, r *http.Request) { log.Info("applicationsSubscriptionsPOST") log.Info("applicationsSubscriptionsPOST") Loading Loading @@ -2040,6 +2126,12 @@ func newSerAvailabilityNotifSubCfg(sub *SerAvailabilityNotificationSubscription, } } func newSerAvailabilityNotifSubCfg_1(sub *EventSubscription, subId string, appId string) *subs.SubscriptionCfg { func newSerAvailabilityNotifSubCfg_1(sub *EventSubscription, subId string, appId string) *subs.SubscriptionCfg { var eventFilters []string for _, filter := range sub.EventFilters { eventFilters = append(eventFilters, filter.ApiIds...) } var capifEvent []string capifEvent = append(capifEvent, string(sub.Events[0])) subCfg := &subs.SubscriptionCfg{ subCfg := &subs.SubscriptionCfg{ Id: subId, Id: subId, AppId: appId, AppId: appId, Loading @@ -2050,6 +2142,8 @@ func newSerAvailabilityNotifSubCfg_1(sub *EventSubscription, subId string, appId PeriodicInterval: 0, PeriodicInterval: 0, RequestTestNotif: false, RequestTestNotif: false, RequestWebsocketUri: false, RequestWebsocketUri: false, EventFilters: eventFilters, CapifEvent: capifEvent, } } return subCfg return subCfg } } Loading
go-apps/meep-app-enablement/server/routers.go +7 −0 Original line number Original line Diff line number Diff line Loading @@ -392,6 +392,13 @@ var routes = Routes{ capifMgmt.ApplicationsSubscriptionsPOST, capifMgmt.ApplicationsSubscriptionsPOST, }, }, Route{ "ApplicationsSubscriptionsPUT", strings.ToUpper("Put"), "/capif-events/v1/{subscriberId}/subscriptions/{subscriptionId} ", capifMgmt.ApplicationsSubscriptionsPUT, }, Route{ Route{ "Index", "Index", "GET", "GET", Loading
go-packages/meep-subscriptions/subscription.go +2 −0 Original line number Original line Diff line number Diff line Loading @@ -40,6 +40,8 @@ type SubscriptionCfg struct { PeriodicInterval int32 `json:"periodicInterval"` PeriodicInterval int32 `json:"periodicInterval"` RequestTestNotif bool `json:"reqTestNotif"` RequestTestNotif bool `json:"reqTestNotif"` RequestWebsocketUri bool `json:"reqWebsockUri"` RequestWebsocketUri bool `json:"reqWebsockUri"` EventFilters []string `json:"eventFilters"` CapifEvent []string `json:"capifEvent"` } } type Subscription struct { type Subscription struct { Loading