diff --git a/docs/api-app-support/.openapi-generator/FILES b/docs/api-app-support/.openapi-generator/FILES index bad5423266436bf338ea56110ab6d7dec7e3e914..bd7294d0cd8da26e16662fcd00d936628399b4f0 100644 --- a/docs/api-app-support/.openapi-generator/FILES +++ b/docs/api-app-support/.openapi-generator/FILES @@ -6,21 +6,31 @@ Models/AppTerminationConfirmation.md Models/AppTerminationNotification.md Models/AppTerminationNotificationLinks.md Models/AppTerminationNotificationSubscription.md -Models/AppTerminationNotificationSubscriptionLinks.md Models/CurrentTime.md Models/DestinationInterface.md +Models/DestinationInterfaceInterfaceType.md Models/DnsRule.md +Models/DnsRuleIpAddressType.md +Models/DnsRuleState.md Models/LinkType.md +Models/MecAppSuptApiSubscriptionLinkList.md +Models/MecAppSuptApiSubscriptionLinkListLinks.md +Models/MecAppSuptApiSubscriptionLinkListSubscription.md Models/OperationActionType.md Models/ProblemDetails.md -Models/SubscriptionLinkList.md -Models/SubscriptionLinkListLinks.md -Models/SubscriptionLinkListLinksSubscriptions.md +Models/Self.md +Models/TimeSourceStatus.md Models/TimingCaps.md Models/TimingCapsNtpServers.md +Models/TimingCapsNtpServersAuthenticationOption.md +Models/TimingCapsNtpServersNtpServerAddrType.md Models/TimingCapsPtpMasters.md Models/TimingCapsTimeStamp.md Models/TrafficFilter.md Models/TrafficRule.md +Models/TrafficRuleAction.md +Models/TrafficRuleFilterType.md +Models/TrafficRuleState.md Models/TunnelInfo.md +Models/TunnelInfoTunnelType.md README.md diff --git a/docs/api-app-support/Apis/MecAppSupportApi.md b/docs/api-app-support/Apis/MecAppSupportApi.md index 06d8d0093ee0faaa40f867ef46c5dc5d467806c8..0fb926b8a731dfea380c56c68ef99971ce5efc6b 100644 --- a/docs/api-app-support/Apis/MecAppSupportApi.md +++ b/docs/api-app-support/Apis/MecAppSupportApi.md @@ -27,7 +27,7 @@ Method | HTTP request | Description Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **appInstanceId** | **String**| Represents a MEC application instance. Note that the appInstanceId is allocated by the MEC platform manager. | [default to null] - **AppReadyConfirmation** | [**AppReadyConfirmation**](../Models/AppReadyConfirmation.md)| | + **AppReadyConfirmation** | [**AppReadyConfirmation**](../Models/AppReadyConfirmation.md)| | [optional] ### Return type @@ -40,7 +40,7 @@ No authorization required ### HTTP request headers - **Content-Type**: application/json -- **Accept**: application/problem+json +- **Accept**: application/problem+json, text/plain # **applicationsConfirmTerminationPOST** @@ -55,7 +55,7 @@ No authorization required Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **appInstanceId** | **String**| Represents a MEC application instance. Note that the appInstanceId is allocated by the MEC platform manager. | [default to null] - **AppTerminationConfirmation** | [**AppTerminationConfirmation**](../Models/AppTerminationConfirmation.md)| | + **AppTerminationConfirmation** | [**AppTerminationConfirmation**](../Models/AppTerminationConfirmation.md)| | [optional] ### Return type @@ -68,7 +68,7 @@ No authorization required ### HTTP request headers - **Content-Type**: application/json -- **Accept**: application/problem+json +- **Accept**: application/problem+json, text/plain # **applicationsSubscriptionDELETE** @@ -96,7 +96,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined -- **Accept**: application/problem+json +- **Accept**: application/problem+json, text/plain, # **applicationsSubscriptionGET** @@ -124,11 +124,11 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined -- **Accept**: application/json, application/problem+json +- **Accept**: application/json, application/problem+json, text/plain # **applicationsSubscriptionsGET** -> SubscriptionLinkList applicationsSubscriptionsGET(appInstanceId) +> MecAppSuptApiSubscriptionLinkList applicationsSubscriptionsGET(appInstanceId) @@ -142,7 +142,7 @@ Name | Type | Description | Notes ### Return type -[**SubscriptionLinkList**](../Models/SubscriptionLinkList.md) +[**MecAppSuptApiSubscriptionLinkList**](../Models/MecAppSuptApiSubscriptionLinkList.md) ### Authorization @@ -151,7 +151,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined -- **Accept**: application/json, application/problem+json +- **Accept**: application/json, application/problem+json, text/plain # **applicationsSubscriptionsPOST** @@ -179,7 +179,7 @@ No authorization required ### HTTP request headers - **Content-Type**: application/json -- **Accept**: application/json, application/problem+json +- **Accept**: application/json, application/problem+json, text/plain # **timingCapsGET** @@ -203,7 +203,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined -- **Accept**: application/json, application/problem+json +- **Accept**: application/json, application/problem+json, text/plain # **timingCurrentTimeGET** @@ -227,5 +227,5 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined -- **Accept**: application/json, application/problem+json +- **Accept**: application/json, application/problem+json, text/plain diff --git a/docs/api-app-support/Apis/UnsupportedApi.md b/docs/api-app-support/Apis/UnsupportedApi.md index ea134e2c739a0c64e9cd40146082ea834beb6e0a..3e59d26dce197d854081b0babe71f85d4b281182 100644 --- a/docs/api-app-support/Apis/UnsupportedApi.md +++ b/docs/api-app-support/Apis/UnsupportedApi.md @@ -38,7 +38,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined -- **Accept**: application/json, application/problem+json +- **Accept**: application/json, application/problem+json, text/plain # **applicationsDnsRulePUT** @@ -67,7 +67,7 @@ No authorization required ### HTTP request headers - **Content-Type**: application/json -- **Accept**: application/json, application/problem+json +- **Accept**: application/json, application/problem+json, text/plain # **applicationsDnsRulesGET** @@ -94,7 +94,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined -- **Accept**: application/json, application/problem+json +- **Accept**: application/json, application/problem+json, text/plain # **applicationsTrafficRuleGET** @@ -122,7 +122,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined -- **Accept**: application/json, application/problem+json +- **Accept**: application/json, application/problem+json, text/plain # **applicationsTrafficRulePUT** @@ -151,7 +151,7 @@ No authorization required ### HTTP request headers - **Content-Type**: application/json -- **Accept**: application/json, application/problem+json +- **Accept**: application/json, application/problem+json, text/plain # **applicationsTrafficRulesGET** @@ -178,5 +178,5 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined -- **Accept**: application/json, application/problem+json +- **Accept**: application/json, application/problem+json, text/plain diff --git a/docs/api-app-support/README.md b/docs/api-app-support/README.md index da5d891e5a25d8fd3e5beb56a969f707a0b8b614..2d90574b34ce614b9ffac9d27503ca649bb0dec5 100644 --- a/docs/api-app-support/README.md +++ b/docs/api-app-support/README.md @@ -31,23 +31,33 @@ Class | Method | HTTP request | Description - [AppTerminationNotification](./Models/AppTerminationNotification.md) - [AppTerminationNotificationLinks](./Models/AppTerminationNotificationLinks.md) - [AppTerminationNotificationSubscription](./Models/AppTerminationNotificationSubscription.md) - - [AppTerminationNotificationSubscriptionLinks](./Models/AppTerminationNotificationSubscriptionLinks.md) - [CurrentTime](./Models/CurrentTime.md) - [DestinationInterface](./Models/DestinationInterface.md) + - [DestinationInterfaceInterfaceType](./Models/DestinationInterfaceInterfaceType.md) - [DnsRule](./Models/DnsRule.md) + - [DnsRuleIpAddressType](./Models/DnsRuleIpAddressType.md) + - [DnsRuleState](./Models/DnsRuleState.md) - [LinkType](./Models/LinkType.md) + - [MecAppSuptApiSubscriptionLinkList](./Models/MecAppSuptApiSubscriptionLinkList.md) + - [MecAppSuptApiSubscriptionLinkListLinks](./Models/MecAppSuptApiSubscriptionLinkListLinks.md) + - [MecAppSuptApiSubscriptionLinkListSubscription](./Models/MecAppSuptApiSubscriptionLinkListSubscription.md) - [OperationActionType](./Models/OperationActionType.md) - [ProblemDetails](./Models/ProblemDetails.md) - - [SubscriptionLinkList](./Models/SubscriptionLinkList.md) - - [SubscriptionLinkListLinks](./Models/SubscriptionLinkListLinks.md) - - [SubscriptionLinkListLinksSubscriptions](./Models/SubscriptionLinkListLinksSubscriptions.md) + - [Self](./Models/Self.md) + - [TimeSourceStatus](./Models/TimeSourceStatus.md) - [TimingCaps](./Models/TimingCaps.md) - [TimingCapsNtpServers](./Models/TimingCapsNtpServers.md) + - [TimingCapsNtpServersAuthenticationOption](./Models/TimingCapsNtpServersAuthenticationOption.md) + - [TimingCapsNtpServersNtpServerAddrType](./Models/TimingCapsNtpServersNtpServerAddrType.md) - [TimingCapsPtpMasters](./Models/TimingCapsPtpMasters.md) - [TimingCapsTimeStamp](./Models/TimingCapsTimeStamp.md) - [TrafficFilter](./Models/TrafficFilter.md) - [TrafficRule](./Models/TrafficRule.md) + - [TrafficRuleAction](./Models/TrafficRuleAction.md) + - [TrafficRuleFilterType](./Models/TrafficRuleFilterType.md) + - [TrafficRuleState](./Models/TrafficRuleState.md) - [TunnelInfo](./Models/TunnelInfo.md) + - [TunnelInfoTunnelType](./Models/TunnelInfoTunnelType.md) diff --git a/go-apps/meep-app-enablement/api/app-support/swagger.yaml b/go-apps/meep-app-enablement/api/app-support/swagger.yaml index 7aae454485fd5a2a49184add097c090b08f3ef98..ab4aec4856d6f374f67f4d61ed4e7db7f75684d6 100644 --- a/go-apps/meep-app-enablement/api/app-support/swagger.yaml +++ b/go-apps/meep-app-enablement/api/app-support/swagger.yaml @@ -1402,6 +1402,9 @@ components: - TERMINATING ProblemDetails: title: ProblemDetails + required: + - status + - detail type: object properties: type: diff --git a/go-apps/meep-app-enablement/server/app-support/app-support.go b/go-apps/meep-app-enablement/server/app-support/app-support.go index 762c40e4dbfa583c4fbdf0ceb76068f1559716fb..28164ace35066a1991d5ae288c689abc0e291701 100644 --- a/go-apps/meep-app-enablement/server/app-support/app-support.go +++ b/go-apps/meep-app-enablement/server/app-support/app-support.go @@ -215,7 +215,7 @@ func applicationsConfirmReadyPOST(w http.ResponseWriter, r *http.Request) { // Make sure App instance exists appInfo, err := getApp(appId) if err != nil { - http.Error(w, err.Error(), http.StatusNotFound) + errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } @@ -225,21 +225,21 @@ func applicationsConfirmReadyPOST(w http.ResponseWriter, r *http.Request) { err = decoder.Decode(&confirmation) if err != nil { log.Error(err.Error()) - http.Error(w, err.Error(), http.StatusInternalServerError) + errHandlerProblemDetails(w, err.Error(), http.StatusInternalServerError) return } // Validate App Ready params if confirmation.Indication == "" { log.Error("Mandatory Indication not present") - http.Error(w, "Mandatory Indication not present", http.StatusBadRequest) + errHandlerProblemDetails(w, "Mandatory Indication not present", http.StatusBadRequest) return } switch confirmation.Indication { case "READY": default: log.Error("Mandatory OperationAction value not valid") - http.Error(w, "Mandatory OperationAction value not valid", http.StatusBadRequest) + errHandlerProblemDetails(w, "Mandatory OperationAction value not valid", http.StatusBadRequest) return } @@ -250,7 +250,7 @@ func applicationsConfirmReadyPOST(w http.ResponseWriter, r *http.Request) { err = setAppInfo(appInfo) if err != nil { log.Error(err.Error()) - http.Error(w, err.Error(), http.StatusInternalServerError) + errHandlerProblemDetails(w, err.Error(), http.StatusInternalServerError) return } @@ -270,7 +270,7 @@ func applicationsConfirmTerminationPOST(w http.ResponseWriter, r *http.Request) // Get App instance appInfo, err := getApp(appId) if err != nil { - http.Error(w, err.Error(), http.StatusNotFound) + errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } @@ -282,7 +282,7 @@ func applicationsConfirmTerminationPOST(w http.ResponseWriter, r *http.Request) w.WriteHeader(code) fmt.Fprintf(w, problemDetails) } else { - http.Error(w, err.Error(), code) + errHandlerProblemDetails(w, err.Error(), code) } return } @@ -291,7 +291,7 @@ func applicationsConfirmTerminationPOST(w http.ResponseWriter, r *http.Request) gracefulTerminateChannel, found := gracefulTerminateMap[appId] if !found { log.Error("Unexpected App Confirmation Termination Notification") - http.Error(w, "Unexpected App Confirmation Termination Notification", http.StatusBadRequest) + errHandlerProblemDetails(w, "Unexpected App Confirmation Termination Notification", http.StatusBadRequest) return } @@ -301,21 +301,21 @@ func applicationsConfirmTerminationPOST(w http.ResponseWriter, r *http.Request) err = decoder.Decode(&confirmation) if err != nil { log.Error(err.Error()) - http.Error(w, err.Error(), http.StatusInternalServerError) + errHandlerProblemDetails(w, err.Error(), http.StatusInternalServerError) return } // Validate Termination Confirmation params if confirmation.OperationAction == nil { log.Error("Mandatory OperationAction not present") - http.Error(w, "Mandatory OperationAction not present", http.StatusBadRequest) + errHandlerProblemDetails(w, "Mandatory OperationAction not present", http.StatusBadRequest) return } switch *confirmation.OperationAction { case STOPPING, TERMINATING: default: log.Error("Mandatory OperationAction value not valid") - http.Error(w, "Mandatory OperationAction value not valid", http.StatusBadRequest) + errHandlerProblemDetails(w, "Mandatory OperationAction value not valid", http.StatusBadRequest) return } @@ -337,7 +337,7 @@ func applicationsSubscriptionsPOST(w http.ResponseWriter, r *http.Request) { // Get App instance appInfo, err := getApp(appId) if err != nil { - http.Error(w, err.Error(), http.StatusNotFound) + errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } @@ -349,7 +349,7 @@ func applicationsSubscriptionsPOST(w http.ResponseWriter, r *http.Request) { w.WriteHeader(code) fmt.Fprintf(w, problemDetails) } else { - http.Error(w, err.Error(), code) + errHandlerProblemDetails(w, err.Error(), code) } return } @@ -360,29 +360,29 @@ func applicationsSubscriptionsPOST(w http.ResponseWriter, r *http.Request) { err = decoder.Decode(&appTermNotifSub) if err != nil { log.Error(err.Error()) - http.Error(w, err.Error(), http.StatusInternalServerError) + errHandlerProblemDetails(w, err.Error(), http.StatusInternalServerError) return } // Verify mandatory properties if appTermNotifSub.CallbackReference == "" { log.Error("Mandatory CallbackReference parameter not present") - http.Error(w, "Mandatory CallbackReference parameter not present", http.StatusBadRequest) + errHandlerProblemDetails(w, "Mandatory CallbackReference parameter not present", http.StatusBadRequest) return } if appTermNotifSub.SubscriptionType != APP_TERMINATION_NOTIF_SUB_TYPE { log.Error("SubscriptionType shall be AppTerminationNotificationSubscription") - http.Error(w, "SubscriptionType shall be AppTerminationNotificationSubscription", http.StatusBadRequest) + errHandlerProblemDetails(w, "SubscriptionType shall be AppTerminationNotificationSubscription", http.StatusBadRequest) return } if appTermNotifSub.AppInstanceId == "" { log.Error("Mandatory AppInstanceId parameter not present") - http.Error(w, "Mandatory AppInstanceId parameter not present", http.StatusBadRequest) + errHandlerProblemDetails(w, "Mandatory AppInstanceId parameter not present", http.StatusBadRequest) return } if appTermNotifSub.AppInstanceId != appId { log.Error("AppInstanceId in endpoint and in body not matching") - http.Error(w, "AppInstanceId in endpoint and in body not matching", http.StatusBadRequest) + errHandlerProblemDetails(w, "AppInstanceId in endpoint and in body not matching", http.StatusBadRequest) return } @@ -402,7 +402,7 @@ func applicationsSubscriptionsPOST(w http.ResponseWriter, r *http.Request) { _, err = subMgr.CreateSubscription(subCfg, jsonSub) if err != nil { log.Error("Failed to create subscription") - http.Error(w, "Failed to create subscription", http.StatusInternalServerError) + errHandlerProblemDetails(w, "Failed to create subscription", http.StatusInternalServerError) return } @@ -424,7 +424,7 @@ func applicationsSubscriptionGET(w http.ResponseWriter, r *http.Request) { // Get App instance info appInfo, err := getApp(appId) if err != nil { - http.Error(w, err.Error(), http.StatusNotFound) + errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } @@ -436,7 +436,7 @@ func applicationsSubscriptionGET(w http.ResponseWriter, r *http.Request) { w.WriteHeader(code) fmt.Fprintf(w, problemDetails) } else { - http.Error(w, err.Error(), code) + errHandlerProblemDetails(w, err.Error(), code) } return } @@ -445,7 +445,7 @@ func applicationsSubscriptionGET(w http.ResponseWriter, r *http.Request) { sub, err := subMgr.GetSubscription(subId) if err != nil { log.Error(err.Error()) - http.Error(w, err.Error(), http.StatusNotFound) + errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } @@ -453,7 +453,7 @@ func applicationsSubscriptionGET(w http.ResponseWriter, r *http.Request) { if sub.Cfg.AppId != appId || sub.Cfg.Type != APP_TERMINATION_NOTIF_SUB_TYPE { err = errors.New("Subscription not found") log.Error(err.Error()) - http.Error(w, err.Error(), http.StatusNotFound) + errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } @@ -474,7 +474,7 @@ func applicationsSubscriptionDELETE(w http.ResponseWriter, r *http.Request) { // Get App instance info appInfo, err := getApp(appId) if err != nil { - http.Error(w, err.Error(), http.StatusNotFound) + errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } @@ -486,7 +486,7 @@ func applicationsSubscriptionDELETE(w http.ResponseWriter, r *http.Request) { w.WriteHeader(code) fmt.Fprintf(w, problemDetails) } else { - http.Error(w, err.Error(), code) + errHandlerProblemDetails(w, err.Error(), code) } return } @@ -495,7 +495,7 @@ func applicationsSubscriptionDELETE(w http.ResponseWriter, r *http.Request) { sub, err := subMgr.GetSubscription(subId) if err != nil { log.Error(err.Error()) - http.Error(w, err.Error(), http.StatusNotFound) + errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } @@ -503,7 +503,7 @@ func applicationsSubscriptionDELETE(w http.ResponseWriter, r *http.Request) { if sub.Cfg.AppId != appId || sub.Cfg.Type != APP_TERMINATION_NOTIF_SUB_TYPE { err = errors.New("Subscription not found") log.Error(err.Error()) - http.Error(w, err.Error(), http.StatusNotFound) + errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } @@ -511,7 +511,7 @@ func applicationsSubscriptionDELETE(w http.ResponseWriter, r *http.Request) { err = subMgr.DeleteSubscription(sub) if err != nil { log.Error(err.Error()) - http.Error(w, err.Error(), http.StatusInternalServerError) + errHandlerProblemDetails(w, err.Error(), http.StatusInternalServerError) return } @@ -530,7 +530,7 @@ func applicationsSubscriptionsGET(w http.ResponseWriter, r *http.Request) { // Get App instance info appInfo, err := getApp(appId) if err != nil { - http.Error(w, err.Error(), http.StatusNotFound) + errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } @@ -542,7 +542,7 @@ func applicationsSubscriptionsGET(w http.ResponseWriter, r *http.Request) { w.WriteHeader(code) fmt.Fprintf(w, problemDetails) } else { - http.Error(w, err.Error(), code) + errHandlerProblemDetails(w, err.Error(), code) } return } @@ -594,7 +594,7 @@ func timingCapsGET(w http.ResponseWriter, r *http.Request) { jsonResponse, err := json.Marshal(timingCaps) if err != nil { log.Error(err.Error()) - http.Error(w, err.Error(), http.StatusInternalServerError) + errHandlerProblemDetails(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) @@ -616,7 +616,7 @@ func timingCurrentTimeGET(w http.ResponseWriter, r *http.Request) { jsonResponse, err := json.Marshal(currentTime) if err != nil { log.Error(err.Error()) - http.Error(w, err.Error(), http.StatusInternalServerError) + errHandlerProblemDetails(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) @@ -1011,3 +1011,14 @@ func sendAppRemoveCnf(id string) { return } } + +func errHandlerProblemDetails(w http.ResponseWriter, error string, code int) { + var pd ProblemDetails + pd.Detail = error + pd.Status = int32(code) + + jsonResponse := convertProblemDetailstoJson(&pd) + + w.WriteHeader(code) + fmt.Fprint(w, jsonResponse) +} \ No newline at end of file diff --git a/go-apps/meep-app-enablement/server/app-support/convert.go b/go-apps/meep-app-enablement/server/app-support/convert.go index ec0f536c988c22e4fe2687e1f0ba1e09b3a32bea..ca9683226635de92cec65f0779f3fee034352ce3 100644 --- a/go-apps/meep-app-enablement/server/app-support/convert.go +++ b/go-apps/meep-app-enablement/server/app-support/convert.go @@ -57,3 +57,12 @@ func convertMecAppSuptApiSubscriptionLinkListToJson(obj *MecAppSuptApiSubscripti } return string(jsonInfo) } + +func convertProblemDetailstoJson(probdetails *ProblemDetails) string { + jsonInfo, err := json.Marshal(*probdetails) + if err != nil { + log.Error(err.Error()) + return "" + } + return string(jsonInfo) +} \ No newline at end of file diff --git a/go-apps/meep-app-enablement/server/app-support/model_problem_details.go b/go-apps/meep-app-enablement/server/app-support/model_problem_details.go index ec66035d03459289bb9ca4830fca93a3dc11d865..1cb24a9e208bf8c6b6d4dbffec116e2ac0279455 100644 --- a/go-apps/meep-app-enablement/server/app-support/model_problem_details.go +++ b/go-apps/meep-app-enablement/server/app-support/model_problem_details.go @@ -29,9 +29,9 @@ type ProblemDetails struct { // A short, human-readable summary of the problem type Title string `json:"title,omitempty"` // The HTTP status code for this occurrence of the problem - Status int32 `json:"status,omitempty"` + Status int32 `json:"status"` // A human-readable explanation specific to this occurrence of the problem - Detail string `json:"detail,omitempty"` + Detail string `json:"detail"` // A URI reference that identifies the specific occurrence of the problem Instance string `json:"instance,omitempty"` }