diff --git a/datarepository/api_access_and_mobility_subscription_data_document.go b/datarepository/api_access_and_mobility_subscription_data_document.go index 9374170..6c98401 100644 --- a/datarepository/api_access_and_mobility_subscription_data_document.go +++ b/datarepository/api_access_and_mobility_subscription_data_document.go @@ -15,6 +15,7 @@ package datarepository import ( + "github.com/omec-project/util/mongoapi" "net/http" "github.com/gin-gonic/gin" @@ -27,23 +28,25 @@ import ( ) // HTTPQueryAmData - Retrieves the access and mobility subscription data of a UE -func HTTPQueryAmData(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["ueId"] = c.Params.ByName("ueId") - req.Params["servingPlmnId"] = c.Params.ByName("servingPlmnId") - - rsp := producer.HandleQueryAmData(req) - - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), +func HTTPQueryAmData(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["ueId"] = c.Params.ByName("ueId") + req.Params["servingPlmnId"] = c.Params.ByName("servingPlmnId") + + rsp := producer.HandleQueryAmData(req, m) + + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } diff --git a/datarepository/api_amf3_gpp_access_registration_document.go b/datarepository/api_amf3_gpp_access_registration_document.go index 28901a3..95e3228 100644 --- a/datarepository/api_amf3_gpp_access_registration_document.go +++ b/datarepository/api_amf3_gpp_access_registration_document.go @@ -15,6 +15,7 @@ package datarepository import ( + "github.com/omec-project/util/mongoapi" "net/http" "github.com/gin-gonic/gin" @@ -27,120 +28,126 @@ import ( ) // HTTPAmfContext3gpp - To modify the AMF context data of a UE using 3gpp access in the UDR -func HTTPAmfContext3gpp(c *gin.Context) { - var patchItemArray []models.PatchItem - - requestBody, err := c.GetRawData() - if err != nil { - problemDetail := models.ProblemDetails{ - Title: "System failure", - Status: http.StatusInternalServerError, - Detail: err.Error(), - Cause: "SYSTEM_FAILURE", +func HTTPAmfContext3gpp(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + var patchItemArray []models.PatchItem + + requestBody, err := c.GetRawData() + if err != nil { + problemDetail := models.ProblemDetails{ + Title: "System failure", + Status: http.StatusInternalServerError, + Detail: err.Error(), + Cause: "SYSTEM_FAILURE", + } + logger.DataRepoLog.Errorf("Get Request Body error: %+v", err) + c.JSON(http.StatusInternalServerError, problemDetail) + return } - logger.DataRepoLog.Errorf("Get Request Body error: %+v", err) - c.JSON(http.StatusInternalServerError, problemDetail) - return - } - err = openapi.Deserialize(&patchItemArray, requestBody, "application/json") - if err != nil { - problemDetail := "[Request Body] " + err.Error() - rsp := models.ProblemDetails{ - Title: "Malformed request syntax", - Status: http.StatusBadRequest, - Detail: problemDetail, + err = openapi.Deserialize(&patchItemArray, requestBody, "application/json") + if err != nil { + problemDetail := "[Request Body] " + err.Error() + rsp := models.ProblemDetails{ + Title: "Malformed request syntax", + Status: http.StatusBadRequest, + Detail: problemDetail, + } + logger.DataRepoLog.Errorln(problemDetail) + c.JSON(http.StatusBadRequest, rsp) + return } - logger.DataRepoLog.Errorln(problemDetail) - c.JSON(http.StatusBadRequest, rsp) - return - } - - req := http_wrapper.NewRequest(c.Request, patchItemArray) - req.Params["ueId"] = c.Params.ByName("ueId") - - rsp := producer.HandleAmfContext3gpp(req) - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), + req := http_wrapper.NewRequest(c.Request, patchItemArray) + req.Params["ueId"] = c.Params.ByName("ueId") + + rsp := producer.HandleAmfContext3gpp(req, m) + + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } // HTTPCreateAmfContext3gpp - To store the AMF context data of a UE using 3gpp access in the UDR -func HTTPCreateAmfContext3gpp(c *gin.Context) { - var amf3GppAccessRegistration models.Amf3GppAccessRegistration - - requestBody, err := c.GetRawData() - if err != nil { - problemDetail := models.ProblemDetails{ - Title: "System failure", - Status: http.StatusInternalServerError, - Detail: err.Error(), - Cause: "SYSTEM_FAILURE", +func HTTPCreateAmfContext3gpp(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + var amf3GppAccessRegistration models.Amf3GppAccessRegistration + + requestBody, err := c.GetRawData() + if err != nil { + problemDetail := models.ProblemDetails{ + Title: "System failure", + Status: http.StatusInternalServerError, + Detail: err.Error(), + Cause: "SYSTEM_FAILURE", + } + logger.DataRepoLog.Errorf("Get Request Body error: %+v", err) + c.JSON(http.StatusInternalServerError, problemDetail) + return } - logger.DataRepoLog.Errorf("Get Request Body error: %+v", err) - c.JSON(http.StatusInternalServerError, problemDetail) - return - } - err = openapi.Deserialize(&amf3GppAccessRegistration, requestBody, "application/json") - if err != nil { - problemDetail := "[Request Body] " + err.Error() - rsp := models.ProblemDetails{ - Title: "Malformed request syntax", - Status: http.StatusBadRequest, - Detail: problemDetail, + err = openapi.Deserialize(&amf3GppAccessRegistration, requestBody, "application/json") + if err != nil { + problemDetail := "[Request Body] " + err.Error() + rsp := models.ProblemDetails{ + Title: "Malformed request syntax", + Status: http.StatusBadRequest, + Detail: problemDetail, + } + logger.DataRepoLog.Errorln(problemDetail) + c.JSON(http.StatusBadRequest, rsp) + return } - logger.DataRepoLog.Errorln(problemDetail) - c.JSON(http.StatusBadRequest, rsp) - return - } - - req := http_wrapper.NewRequest(c.Request, amf3GppAccessRegistration) - req.Params["ueId"] = c.Params.ByName("ueId") - - rsp := producer.HandleCreateAmfContext3gpp(req) - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), + req := http_wrapper.NewRequest(c.Request, amf3GppAccessRegistration) + req.Params["ueId"] = c.Params.ByName("ueId") + + rsp := producer.HandleCreateAmfContext3gpp(req, m) + + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } // HTTPQueryAmfContext3gpp - Retrieves the AMF context data of a UE using 3gpp access -func HTTPQueryAmfContext3gpp(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["ueId"] = c.Params.ByName("ueId") - - rsp := producer.HandleQueryAmfContext3gpp(req) - - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), +func HTTPQueryAmfContext3gpp(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["ueId"] = c.Params.ByName("ueId") + + rsp := producer.HandleQueryAmfContext3gpp(req, m) + + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } diff --git a/datarepository/api_amf_non3_gpp_access_registration_document.go b/datarepository/api_amf_non3_gpp_access_registration_document.go index e9445d6..7996279 100644 --- a/datarepository/api_amf_non3_gpp_access_registration_document.go +++ b/datarepository/api_amf_non3_gpp_access_registration_document.go @@ -15,6 +15,7 @@ package datarepository import ( + "github.com/omec-project/util/mongoapi" "net/http" "github.com/gin-gonic/gin" @@ -27,120 +28,126 @@ import ( ) // HTTPAmfContextNon3gpp - To modify the AMF context data of a UE using non 3gpp access in the UDR -func HTTPAmfContextNon3gpp(c *gin.Context) { - var patchItemArray []models.PatchItem - - requestBody, err := c.GetRawData() - if err != nil { - problemDetail := models.ProblemDetails{ - Title: "System failure", - Status: http.StatusInternalServerError, - Detail: err.Error(), - Cause: "SYSTEM_FAILURE", +func HTTPAmfContextNon3gpp(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + var patchItemArray []models.PatchItem + + requestBody, err := c.GetRawData() + if err != nil { + problemDetail := models.ProblemDetails{ + Title: "System failure", + Status: http.StatusInternalServerError, + Detail: err.Error(), + Cause: "SYSTEM_FAILURE", + } + logger.DataRepoLog.Errorf("Get Request Body error: %+v", err) + c.JSON(http.StatusInternalServerError, problemDetail) + return } - logger.DataRepoLog.Errorf("Get Request Body error: %+v", err) - c.JSON(http.StatusInternalServerError, problemDetail) - return - } - err = openapi.Deserialize(&patchItemArray, requestBody, "application/json") - if err != nil { - problemDetail := "[Request Body] " + err.Error() - rsp := models.ProblemDetails{ - Title: "Malformed request syntax", - Status: http.StatusBadRequest, - Detail: problemDetail, + err = openapi.Deserialize(&patchItemArray, requestBody, "application/json") + if err != nil { + problemDetail := "[Request Body] " + err.Error() + rsp := models.ProblemDetails{ + Title: "Malformed request syntax", + Status: http.StatusBadRequest, + Detail: problemDetail, + } + logger.DataRepoLog.Errorln(problemDetail) + c.JSON(http.StatusBadRequest, rsp) + return } - logger.DataRepoLog.Errorln(problemDetail) - c.JSON(http.StatusBadRequest, rsp) - return - } - - req := http_wrapper.NewRequest(c.Request, patchItemArray) - req.Params["ueId"] = c.Params.ByName("ueId") - - rsp := producer.HandleAmfContextNon3gpp(req) - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), + req := http_wrapper.NewRequest(c.Request, patchItemArray) + req.Params["ueId"] = c.Params.ByName("ueId") + + rsp := producer.HandleAmfContextNon3gpp(req, m) + + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } // HTTPCreateAmfContextNon3gpp - To store the AMF context data of a UE using non-3gpp access in the UDR -func HTTPCreateAmfContextNon3gpp(c *gin.Context) { - var amfNon3GppAccessRegistration models.AmfNon3GppAccessRegistration - - requestBody, err := c.GetRawData() - if err != nil { - problemDetail := models.ProblemDetails{ - Title: "System failure", - Status: http.StatusInternalServerError, - Detail: err.Error(), - Cause: "SYSTEM_FAILURE", +func HTTPCreateAmfContextNon3gpp(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + var amfNon3GppAccessRegistration models.AmfNon3GppAccessRegistration + + requestBody, err := c.GetRawData() + if err != nil { + problemDetail := models.ProblemDetails{ + Title: "System failure", + Status: http.StatusInternalServerError, + Detail: err.Error(), + Cause: "SYSTEM_FAILURE", + } + logger.DataRepoLog.Errorf("Get Request Body error: %+v", err) + c.JSON(http.StatusInternalServerError, problemDetail) + return } - logger.DataRepoLog.Errorf("Get Request Body error: %+v", err) - c.JSON(http.StatusInternalServerError, problemDetail) - return - } - err = openapi.Deserialize(&amfNon3GppAccessRegistration, requestBody, "application/json") - if err != nil { - problemDetail := "[Request Body] " + err.Error() - rsp := models.ProblemDetails{ - Title: "Malformed request syntax", - Status: http.StatusBadRequest, - Detail: problemDetail, + err = openapi.Deserialize(&amfNon3GppAccessRegistration, requestBody, "application/json") + if err != nil { + problemDetail := "[Request Body] " + err.Error() + rsp := models.ProblemDetails{ + Title: "Malformed request syntax", + Status: http.StatusBadRequest, + Detail: problemDetail, + } + logger.DataRepoLog.Errorln(problemDetail) + c.JSON(http.StatusBadRequest, rsp) + return } - logger.DataRepoLog.Errorln(problemDetail) - c.JSON(http.StatusBadRequest, rsp) - return - } - - req := http_wrapper.NewRequest(c.Request, amfNon3GppAccessRegistration) - req.Params["ueId"] = c.Params.ByName("ueId") - - rsp := producer.HandleCreateAmfContextNon3gpp(req) - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), + req := http_wrapper.NewRequest(c.Request, amfNon3GppAccessRegistration) + req.Params["ueId"] = c.Params.ByName("ueId") + + rsp := producer.HandleCreateAmfContextNon3gpp(req, m) + + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } // HTTPQueryAmfContextNon3gpp - Retrieves the AMF context data of a UE using non-3gpp access -func HTTPQueryAmfContextNon3gpp(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["ueId"] = c.Params.ByName("ueId") - - rsp := producer.HandleQueryAmfContextNon3gpp(req) - - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), +func HTTPQueryAmfContextNon3gpp(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["ueId"] = c.Params.ByName("ueId") + + rsp := producer.HandleQueryAmfContextNon3gpp(req, m) + + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } diff --git a/datarepository/api_authentication_data_document.go b/datarepository/api_authentication_data_document.go index c413eac..b47f725 100644 --- a/datarepository/api_authentication_data_document.go +++ b/datarepository/api_authentication_data_document.go @@ -15,6 +15,7 @@ package datarepository import ( + "github.com/omec-project/util/mongoapi" "net/http" "github.com/gin-gonic/gin" @@ -27,71 +28,75 @@ import ( ) // HTTPModifyAuthentication - modify the authentication subscription data of a UE -func HTTPModifyAuthentication(c *gin.Context) { - var patchItemArray []models.PatchItem +func HTTPModifyAuthentication(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + var patchItemArray []models.PatchItem - requestBody, err := c.GetRawData() - if err != nil { - problemDetail := models.ProblemDetails{ - Title: "System failure", - Status: http.StatusInternalServerError, - Detail: err.Error(), - Cause: "SYSTEM_FAILURE", + requestBody, err := c.GetRawData() + if err != nil { + problemDetail := models.ProblemDetails{ + Title: "System failure", + Status: http.StatusInternalServerError, + Detail: err.Error(), + Cause: "SYSTEM_FAILURE", + } + logger.DataRepoLog.Errorf("Get Request Body error: %+v", err) + c.JSON(http.StatusInternalServerError, problemDetail) + return } - logger.DataRepoLog.Errorf("Get Request Body error: %+v", err) - c.JSON(http.StatusInternalServerError, problemDetail) - return - } - err = openapi.Deserialize(&patchItemArray, requestBody, "application/json") - if err != nil { - problemDetail := "[Request Body] " + err.Error() - rsp := models.ProblemDetails{ - Title: "Malformed request syntax", - Status: http.StatusBadRequest, - Detail: problemDetail, + err = openapi.Deserialize(&patchItemArray, requestBody, "application/json") + if err != nil { + problemDetail := "[Request Body] " + err.Error() + rsp := models.ProblemDetails{ + Title: "Malformed request syntax", + Status: http.StatusBadRequest, + Detail: problemDetail, + } + logger.DataRepoLog.Errorln(problemDetail) + c.JSON(http.StatusBadRequest, rsp) + return } - logger.DataRepoLog.Errorln(problemDetail) - c.JSON(http.StatusBadRequest, rsp) - return - } - req := http_wrapper.NewRequest(c.Request, patchItemArray) - req.Params["ueId"] = c.Params.ByName("ueId") + req := http_wrapper.NewRequest(c.Request, patchItemArray) + req.Params["ueId"] = c.Params.ByName("ueId") - rsp := producer.HandleModifyAuthentication(req) + rsp := producer.HandleModifyAuthentication(req, m) - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } // HTTPQueryAuthSubsData - Retrieves the authentication subscription data of a UE -func HTTPQueryAuthSubsData(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["ueId"] = c.Params.ByName("ueId") +func HTTPQueryAuthSubsData(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["ueId"] = c.Params.ByName("ueId") - rsp := producer.HandleQueryAuthSubsData(req) + rsp := producer.HandleQueryAuthSubsData(req, m) - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } diff --git a/datarepository/api_authentication_so_r_document.go b/datarepository/api_authentication_so_r_document.go index 1bf022c..c5ce9ab 100644 --- a/datarepository/api_authentication_so_r_document.go +++ b/datarepository/api_authentication_so_r_document.go @@ -15,6 +15,7 @@ package datarepository import ( + "github.com/omec-project/util/mongoapi" "net/http" "github.com/gin-gonic/gin" @@ -27,71 +28,75 @@ import ( ) // HTTPCreateAuthenticationSoR - To store the SoR acknowledgement information of a UE -func HTTPCreateAuthenticationSoR(c *gin.Context) { - var sorData models.SorData +func HTTPCreateAuthenticationSoR(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + var sorData models.SorData - requestBody, err := c.GetRawData() - if err != nil { - problemDetail := models.ProblemDetails{ - Title: "System failure", - Status: http.StatusInternalServerError, - Detail: err.Error(), - Cause: "SYSTEM_FAILURE", + requestBody, err := c.GetRawData() + if err != nil { + problemDetail := models.ProblemDetails{ + Title: "System failure", + Status: http.StatusInternalServerError, + Detail: err.Error(), + Cause: "SYSTEM_FAILURE", + } + logger.DataRepoLog.Errorf("Get Request Body error: %+v", err) + c.JSON(http.StatusInternalServerError, problemDetail) + return } - logger.DataRepoLog.Errorf("Get Request Body error: %+v", err) - c.JSON(http.StatusInternalServerError, problemDetail) - return - } - err = openapi.Deserialize(&sorData, requestBody, "application/json") - if err != nil { - problemDetail := "[Request Body] " + err.Error() - rsp := models.ProblemDetails{ - Title: "Malformed request syntax", - Status: http.StatusBadRequest, - Detail: problemDetail, + err = openapi.Deserialize(&sorData, requestBody, "application/json") + if err != nil { + problemDetail := "[Request Body] " + err.Error() + rsp := models.ProblemDetails{ + Title: "Malformed request syntax", + Status: http.StatusBadRequest, + Detail: problemDetail, + } + logger.DataRepoLog.Errorln(problemDetail) + c.JSON(http.StatusBadRequest, rsp) + return } - logger.DataRepoLog.Errorln(problemDetail) - c.JSON(http.StatusBadRequest, rsp) - return - } - req := http_wrapper.NewRequest(c.Request, sorData) - req.Params["ueId"] = c.Params.ByName("ueId") + req := http_wrapper.NewRequest(c.Request, sorData) + req.Params["ueId"] = c.Params.ByName("ueId") - rsp := producer.HandleCreateAuthenticationSoR(req) + rsp := producer.HandleCreateAuthenticationSoR(req, m) - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } // HTTPQueryAuthSoR - Retrieves the SoR acknowledgement information of a UE -func HTTPQueryAuthSoR(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["ueId"] = c.Params.ByName("ueId") +func HTTPQueryAuthSoR(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["ueId"] = c.Params.ByName("ueId") - rsp := producer.HandleQueryAuthSoR(req) + rsp := producer.HandleQueryAuthSoR(req, m) - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } diff --git a/datarepository/api_authentication_status_document.go b/datarepository/api_authentication_status_document.go index 8ec9852..39c0264 100644 --- a/datarepository/api_authentication_status_document.go +++ b/datarepository/api_authentication_status_document.go @@ -15,6 +15,7 @@ package datarepository import ( + "github.com/omec-project/util/mongoapi" "net/http" "github.com/gin-gonic/gin" @@ -27,71 +28,75 @@ import ( ) // HTTPCreateAuthenticationStatus - To store the Authentication Status data of a UE -func HTTPCreateAuthenticationStatus(c *gin.Context) { - var authEvent models.AuthEvent +func HTTPCreateAuthenticationStatus(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + var authEvent models.AuthEvent - requestBody, err := c.GetRawData() - if err != nil { - problemDetail := models.ProblemDetails{ - Title: "System failure", - Status: http.StatusInternalServerError, - Detail: err.Error(), - Cause: "SYSTEM_FAILURE", + requestBody, err := c.GetRawData() + if err != nil { + problemDetail := models.ProblemDetails{ + Title: "System failure", + Status: http.StatusInternalServerError, + Detail: err.Error(), + Cause: "SYSTEM_FAILURE", + } + logger.DataRepoLog.Errorf("Get Request Body error: %+v", err) + c.JSON(http.StatusInternalServerError, problemDetail) + return } - logger.DataRepoLog.Errorf("Get Request Body error: %+v", err) - c.JSON(http.StatusInternalServerError, problemDetail) - return - } - err = openapi.Deserialize(&authEvent, requestBody, "application/json") - if err != nil { - problemDetail := "[Request Body] " + err.Error() - rsp := models.ProblemDetails{ - Title: "Malformed request syntax", - Status: http.StatusBadRequest, - Detail: problemDetail, + err = openapi.Deserialize(&authEvent, requestBody, "application/json") + if err != nil { + problemDetail := "[Request Body] " + err.Error() + rsp := models.ProblemDetails{ + Title: "Malformed request syntax", + Status: http.StatusBadRequest, + Detail: problemDetail, + } + logger.DataRepoLog.Errorln(problemDetail) + c.JSON(http.StatusBadRequest, rsp) + return } - logger.DataRepoLog.Errorln(problemDetail) - c.JSON(http.StatusBadRequest, rsp) - return - } - req := http_wrapper.NewRequest(c.Request, authEvent) - req.Params["ueId"] = c.Params.ByName("ueId") + req := http_wrapper.NewRequest(c.Request, authEvent) + req.Params["ueId"] = c.Params.ByName("ueId") - rsp := producer.HandleCreateAuthenticationStatus(req) + rsp := producer.HandleCreateAuthenticationStatus(req, m) - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } // HTTPQueryAuthenticationStatus - Retrieves the Authentication Status of a UE -func HTTPQueryAuthenticationStatus(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["ueId"] = c.Params.ByName("ueId") +func HTTPQueryAuthenticationStatus(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["ueId"] = c.Params.ByName("ueId") - rsp := producer.HandleQueryAuthenticationStatus(req) + rsp := producer.HandleQueryAuthenticationStatus(req, m) - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } diff --git a/datarepository/api_default.go b/datarepository/api_default.go index 580cebf..5d4e098 100644 --- a/datarepository/api_default.go +++ b/datarepository/api_default.go @@ -15,6 +15,7 @@ package datarepository import ( + "github.com/omec-project/util/mongoapi" "net/http" "github.com/gin-gonic/gin" @@ -62,123 +63,149 @@ func getDataFromRequestBody(c *gin.Context, data interface{}) error { } // HTTPApplicationDataInfluenceDataGet - -func HTTPApplicationDataInfluenceDataGet(c *gin.Context) { - queryParams := c.Request.URL.Query() - rsp := producer.HandleApplicationDataInfluenceDataGet(queryParams) - sendResponse(c, rsp) +func HTTPApplicationDataInfluenceDataGet(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + queryParams := c.Request.URL.Query() + rsp := producer.HandleApplicationDataInfluenceDataGet(queryParams, m) + sendResponse(c, rsp) + } } // HTTPApplicationDataInfluenceDataInfluenceIdDelete - -func HTTPApplicationDataInfluenceDataInfluenceIdDelete(c *gin.Context) { - rsp := producer.HandleApplicationDataInfluenceDataInfluenceIdDelete(c.Params.ByName("influenceId")) - sendResponse(c, rsp) +func HTTPApplicationDataInfluenceDataInfluenceIdDelete(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + rsp := producer.HandleApplicationDataInfluenceDataInfluenceIdDelete(c.Params.ByName("influenceId"), m) + sendResponse(c, rsp) + } } // HTTPApplicationDataInfluenceDataInfluenceIdPatch - -func HTTPApplicationDataInfluenceDataInfluenceIdPatch(c *gin.Context) { - var trInfluDataPatch models.TrafficInfluDataPatch +func HTTPApplicationDataInfluenceDataInfluenceIdPatch(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + var trInfluDataPatch models.TrafficInfluDataPatch - if err := getDataFromRequestBody(c, &trInfluDataPatch); err != nil { - return - } + if err := getDataFromRequestBody(c, &trInfluDataPatch); err != nil { + return + } - rsp := producer.HandleApplicationDataInfluenceDataInfluenceIdPatch(c.Params.ByName("influenceId"), - &trInfluDataPatch) + rsp := producer.HandleApplicationDataInfluenceDataInfluenceIdPatch(c.Params.ByName("influenceId"), + &trInfluDataPatch, m) - sendResponse(c, rsp) + sendResponse(c, rsp) + } } // HTTPApplicationDataInfluenceDataInfluenceIdPut - -func HTTPApplicationDataInfluenceDataInfluenceIdPut(c *gin.Context) { - var trInfluData models.TrafficInfluData +func HTTPApplicationDataInfluenceDataInfluenceIdPut(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + var trInfluData models.TrafficInfluData - if err := getDataFromRequestBody(c, &trInfluData); err != nil { - return - } + if err := getDataFromRequestBody(c, &trInfluData); err != nil { + return + } - rsp := producer.HandleApplicationDataInfluenceDataInfluenceIdPut(c.Params.ByName("influenceId"), &trInfluData) + rsp := producer.HandleApplicationDataInfluenceDataInfluenceIdPut(c.Params.ByName("influenceId"), &trInfluData, m) - sendResponse(c, rsp) + sendResponse(c, rsp) + } } // HTTPApplicationDataInfluenceDataSubsToNotifyGet - -func HTTPApplicationDataInfluenceDataSubsToNotifyGet(c *gin.Context) { - queryParams := c.Request.URL.Query() - rsp := producer.HandleApplicationDataInfluenceDataSubsToNotifyGet(queryParams) - sendResponse(c, rsp) +func HTTPApplicationDataInfluenceDataSubsToNotifyGet(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + queryParams := c.Request.URL.Query() + rsp := producer.HandleApplicationDataInfluenceDataSubsToNotifyGet(queryParams, m) + sendResponse(c, rsp) + } } // HTTPApplicationDataInfluenceDataSubsToNotifyPost - -func HTTPApplicationDataInfluenceDataSubsToNotifyPost(c *gin.Context) { - var trInfluSub models.TrafficInfluSub +func HTTPApplicationDataInfluenceDataSubsToNotifyPost(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + var trInfluSub models.TrafficInfluSub - if err := getDataFromRequestBody(c, &trInfluSub); err != nil { - return - } + if err := getDataFromRequestBody(c, &trInfluSub); err != nil { + return + } - rsp := producer.HandleApplicationDataInfluenceDataSubsToNotifyPost(&trInfluSub) + rsp := producer.HandleApplicationDataInfluenceDataSubsToNotifyPost(&trInfluSub, m) - sendResponse(c, rsp) + sendResponse(c, rsp) + } } // HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdDelete - -func HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdDelete(c *gin.Context) { - rsp := producer.HandleApplicationDataInfluenceDataSubsToNotifySubscriptionIdDelete( - c.Params.ByName("subscriptionId")) - sendResponse(c, rsp) +func HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdDelete(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + rsp := producer.HandleApplicationDataInfluenceDataSubsToNotifySubscriptionIdDelete( + c.Params.ByName("subscriptionId"), m) + sendResponse(c, rsp) + } } // HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdGet - -func HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdGet(c *gin.Context) { - rsp := producer.HandleApplicationDataInfluenceDataSubsToNotifySubscriptionIdGet( - c.Params.ByName("subscriptionId")) - sendResponse(c, rsp) +func HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdGet(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + rsp := producer.HandleApplicationDataInfluenceDataSubsToNotifySubscriptionIdGet( + c.Params.ByName("subscriptionId"), m) + sendResponse(c, rsp) + } } // HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdPut - -func HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdPut(c *gin.Context) { - var trInfluSub models.TrafficInfluSub +func HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdPut(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + var trInfluSub models.TrafficInfluSub - if err := getDataFromRequestBody(c, &trInfluSub); err != nil { - return - } + if err := getDataFromRequestBody(c, &trInfluSub); err != nil { + return + } - rsp := producer.HandleApplicationDataInfluenceDataSubsToNotifySubscriptionIdPut( - c.Params.ByName("subscriptionId"), &trInfluSub) + rsp := producer.HandleApplicationDataInfluenceDataSubsToNotifySubscriptionIdPut( + c.Params.ByName("subscriptionId"), &trInfluSub, m) - sendResponse(c, rsp) + sendResponse(c, rsp) + } } // HTTPApplicationDataPfdsAppIdDelete - -func HTTPApplicationDataPfdsAppIdDelete(c *gin.Context) { - rsp := producer.HandleApplicationDataPfdsAppIdDelete(c.Params.ByName("appId")) - sendResponse(c, rsp) +func HTTPApplicationDataPfdsAppIdDelete(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + rsp := producer.HandleApplicationDataPfdsAppIdDelete(c.Params.ByName("appId"), m) + sendResponse(c, rsp) + } } // HTTPApplicationDataPfdsAppIdGet - -func HTTPApplicationDataPfdsAppIdGet(c *gin.Context) { - rsp := producer.HandleApplicationDataPfdsAppIdGet(c.Params.ByName("appId")) - sendResponse(c, rsp) +func HTTPApplicationDataPfdsAppIdGet(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + rsp := producer.HandleApplicationDataPfdsAppIdGet(c.Params.ByName("appId"), m) + sendResponse(c, rsp) + } } // HTTPApplicationDataPfdsAppIdPut - -func HTTPApplicationDataPfdsAppIdPut(c *gin.Context) { - var pfdDataforApp models.PfdDataForApp +func HTTPApplicationDataPfdsAppIdPut(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + var pfdDataforApp models.PfdDataForApp - if err := getDataFromRequestBody(c, &pfdDataforApp); err != nil { - return - } + if err := getDataFromRequestBody(c, &pfdDataforApp); err != nil { + return + } - rsp := producer.HandleApplicationDataPfdsAppIdPut(c.Params.ByName("appId"), &pfdDataforApp) + rsp := producer.HandleApplicationDataPfdsAppIdPut(c.Params.ByName("appId"), &pfdDataforApp, m) - sendResponse(c, rsp) + sendResponse(c, rsp) + } } // HTTPApplicationDataPfdsGet - -func HTTPApplicationDataPfdsGet(c *gin.Context) { - query := c.Request.URL.Query() - rsp := producer.HandleApplicationDataPfdsGet(query["appId"]) - sendResponse(c, rsp) +func HTTPApplicationDataPfdsGet(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + query := c.Request.URL.Query() + rsp := producer.HandleApplicationDataPfdsGet(query["appId"], m) + sendResponse(c, rsp) + } } // HTTPExposureDataSubsToNotifyPost - @@ -197,68 +224,80 @@ func HTTPExposureDataSubsToNotifySubIdPut(c *gin.Context) { } // HTTPPolicyDataBdtDataBdtReferenceIdDelete - -func HTTPPolicyDataBdtDataBdtReferenceIdDelete(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["bdtReferenceId"] = c.Params.ByName("bdtReferenceId") +func HTTPPolicyDataBdtDataBdtReferenceIdDelete(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["bdtReferenceId"] = c.Params.ByName("bdtReferenceId") - rsp := producer.HandlePolicyDataBdtDataBdtReferenceIdDelete(req) + rsp := producer.HandlePolicyDataBdtDataBdtReferenceIdDelete(req, m) - sendResponse(c, rsp) + sendResponse(c, rsp) + } } // HTTPPolicyDataBdtDataBdtReferenceIdGet - -func HTTPPolicyDataBdtDataBdtReferenceIdGet(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["bdtReferenceId"] = c.Params.ByName("bdtReferenceId") +func HTTPPolicyDataBdtDataBdtReferenceIdGet(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["bdtReferenceId"] = c.Params.ByName("bdtReferenceId") - rsp := producer.HandlePolicyDataBdtDataBdtReferenceIdGet(req) + rsp := producer.HandlePolicyDataBdtDataBdtReferenceIdGet(req, m) - sendResponse(c, rsp) + sendResponse(c, rsp) + } } // HTTPPolicyDataBdtDataBdtReferenceIdPut - -func HTTPPolicyDataBdtDataBdtReferenceIdPut(c *gin.Context) { - var bdtData models.BdtData +func HTTPPolicyDataBdtDataBdtReferenceIdPut(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + var bdtData models.BdtData - if err := getDataFromRequestBody(c, &bdtData); err != nil { - return - } + if err := getDataFromRequestBody(c, &bdtData); err != nil { + return + } - req := http_wrapper.NewRequest(c.Request, bdtData) - req.Params["bdtReferenceId"] = c.Params.ByName("bdtReferenceId") + req := http_wrapper.NewRequest(c.Request, bdtData) + req.Params["bdtReferenceId"] = c.Params.ByName("bdtReferenceId") - rsp := producer.HandlePolicyDataBdtDataBdtReferenceIdPut(req) + rsp := producer.HandlePolicyDataBdtDataBdtReferenceIdPut(req, m) - sendResponse(c, rsp) + sendResponse(c, rsp) + } } // HTTPPolicyDataBdtDataGet - -func HTTPPolicyDataBdtDataGet(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) +func HTTPPolicyDataBdtDataGet(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) - rsp := producer.HandlePolicyDataBdtDataGet(req) + rsp := producer.HandlePolicyDataBdtDataGet(req, m) - sendResponse(c, rsp) + sendResponse(c, rsp) + } } // HTTPPolicyDataPlmnsPlmnIdUePolicySetGet - -func HTTPPolicyDataPlmnsPlmnIdUePolicySetGet(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["plmnId"] = c.Params.ByName("plmnId") +func HTTPPolicyDataPlmnsPlmnIdUePolicySetGet(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["plmnId"] = c.Params.ByName("plmnId") - rsp := producer.HandlePolicyDataPlmnsPlmnIdUePolicySetGet(req) + rsp := producer.HandlePolicyDataPlmnsPlmnIdUePolicySetGet(req, m) - sendResponse(c, rsp) + sendResponse(c, rsp) + } } // HTTPPolicyDataSponsorConnectivityDataSponsorIdGet - -func HTTPPolicyDataSponsorConnectivityDataSponsorIdGet(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["sponsorId"] = c.Params.ByName("sponsorId") +func HTTPPolicyDataSponsorConnectivityDataSponsorIdGet(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["sponsorId"] = c.Params.ByName("sponsorId") - rsp := producer.HandlePolicyDataSponsorConnectivityDataSponsorIdGet(req) + rsp := producer.HandlePolicyDataSponsorConnectivityDataSponsorIdGet(req, m) - sendResponse(c, rsp) + sendResponse(c, rsp) + } } // HTTPPolicyDataSubsToNotifyPost - @@ -308,160 +347,184 @@ func HTTPPolicyDataSubsToNotifySubsIdPut(c *gin.Context) { } // HTTPPolicyDataUesUeIdAmDataGet - -func HTTPPolicyDataUesUeIdAmDataGet(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["ueId"] = c.Params.ByName("ueId") +func HTTPPolicyDataUesUeIdAmDataGet(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["ueId"] = c.Params.ByName("ueId") - rsp := producer.HandlePolicyDataUesUeIdAmDataGet(req) + rsp := producer.HandlePolicyDataUesUeIdAmDataGet(req, m) - sendResponse(c, rsp) + sendResponse(c, rsp) + } } // HTTPPolicyDataUesUeIdOperatorSpecificDataGet - -func HTTPPolicyDataUesUeIdOperatorSpecificDataGet(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["ueId"] = c.Params.ByName("ueId") +func HTTPPolicyDataUesUeIdOperatorSpecificDataGet(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["ueId"] = c.Params.ByName("ueId") - rsp := producer.HandlePolicyDataUesUeIdOperatorSpecificDataGet(req) + rsp := producer.HandlePolicyDataUesUeIdOperatorSpecificDataGet(req, m) - sendResponse(c, rsp) + sendResponse(c, rsp) + } } // HTTPPolicyDataUesUeIdOperatorSpecificDataPatch - Need to be fixed -func HTTPPolicyDataUesUeIdOperatorSpecificDataPatch(c *gin.Context) { - var patchItemArray []models.PatchItem +func HTTPPolicyDataUesUeIdOperatorSpecificDataPatch(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + var patchItemArray []models.PatchItem - if err := getDataFromRequestBody(c, &patchItemArray); err != nil { - return - } + if err := getDataFromRequestBody(c, &patchItemArray); err != nil { + return + } - req := http_wrapper.NewRequest(c.Request, patchItemArray) - req.Params["ueId"] = c.Params.ByName("ueId") + req := http_wrapper.NewRequest(c.Request, patchItemArray) + req.Params["ueId"] = c.Params.ByName("ueId") - rsp := producer.HandlePolicyDataUesUeIdOperatorSpecificDataPatch(req) + rsp := producer.HandlePolicyDataUesUeIdOperatorSpecificDataPatch(req, m) - sendResponse(c, rsp) + sendResponse(c, rsp) + } } // HTTPPolicyDataUesUeIdOperatorSpecificDataPut - -func HTTPPolicyDataUesUeIdOperatorSpecificDataPut(c *gin.Context) { - var operatorSpecificDataContainerMap map[string]models.OperatorSpecificDataContainer +func HTTPPolicyDataUesUeIdOperatorSpecificDataPut(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + var operatorSpecificDataContainerMap map[string]models.OperatorSpecificDataContainer - if err := getDataFromRequestBody(c, &operatorSpecificDataContainerMap); err != nil { - return - } + if err := getDataFromRequestBody(c, &operatorSpecificDataContainerMap); err != nil { + return + } - req := http_wrapper.NewRequest(c.Request, operatorSpecificDataContainerMap) - req.Params["ueId"] = c.Params.ByName("ueId") + req := http_wrapper.NewRequest(c.Request, operatorSpecificDataContainerMap) + req.Params["ueId"] = c.Params.ByName("ueId") - rsp := producer.HandlePolicyDataUesUeIdOperatorSpecificDataPut(req) + rsp := producer.HandlePolicyDataUesUeIdOperatorSpecificDataPut(req, m) - sendResponse(c, rsp) + sendResponse(c, rsp) + } } // HTTPPolicyDataUesUeIdSmDataGet - -func HTTPPolicyDataUesUeIdSmDataGet(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["ueId"] = c.Params.ByName("ueId") +func HTTPPolicyDataUesUeIdSmDataGet(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["ueId"] = c.Params.ByName("ueId") - rsp := producer.HandlePolicyDataUesUeIdSmDataGet(req) + rsp := producer.HandlePolicyDataUesUeIdSmDataGet(req, m) - sendResponse(c, rsp) + sendResponse(c, rsp) + } } // HTTPPolicyDataUesUeIdSmDataPatch - Need to be fixed -func HTTPPolicyDataUesUeIdSmDataPatch(c *gin.Context) { - var usageMonDataMap map[string]models.UsageMonData +func HTTPPolicyDataUesUeIdSmDataPatch(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + var usageMonDataMap map[string]models.UsageMonData - if err := getDataFromRequestBody(c, &usageMonDataMap); err != nil { - return - } + if err := getDataFromRequestBody(c, &usageMonDataMap); err != nil { + return + } - req := http_wrapper.NewRequest(c.Request, usageMonDataMap) - req.Params["ueId"] = c.Params.ByName("ueId") + req := http_wrapper.NewRequest(c.Request, usageMonDataMap) + req.Params["ueId"] = c.Params.ByName("ueId") - rsp := producer.HandlePolicyDataUesUeIdSmDataPatch(req) + rsp := producer.HandlePolicyDataUesUeIdSmDataPatch(req, m) - sendResponse(c, rsp) + sendResponse(c, rsp) + } } // HTTPPolicyDataUesUeIdSmDataUsageMonIdDelete - -func HTTPPolicyDataUesUeIdSmDataUsageMonIdDelete(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["ueId"] = c.Params.ByName("ueId") - req.Params["usageMonId"] = c.Params.ByName("usageMonId") +func HTTPPolicyDataUesUeIdSmDataUsageMonIdDelete(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["ueId"] = c.Params.ByName("ueId") + req.Params["usageMonId"] = c.Params.ByName("usageMonId") - rsp := producer.HandlePolicyDataUesUeIdSmDataUsageMonIdDelete(req) + rsp := producer.HandlePolicyDataUesUeIdSmDataUsageMonIdDelete(req, m) - sendResponse(c, rsp) + sendResponse(c, rsp) + } } // HTTPPolicyDataUesUeIdSmDataUsageMonIdGet - -func HTTPPolicyDataUesUeIdSmDataUsageMonIdGet(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["ueId"] = c.Params.ByName("ueId") - req.Params["usageMonId"] = c.Params.ByName("usageMonId") +func HTTPPolicyDataUesUeIdSmDataUsageMonIdGet(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["ueId"] = c.Params.ByName("ueId") + req.Params["usageMonId"] = c.Params.ByName("usageMonId") - rsp := producer.HandlePolicyDataUesUeIdSmDataUsageMonIdGet(req) + rsp := producer.HandlePolicyDataUesUeIdSmDataUsageMonIdGet(req, m) - sendResponse(c, rsp) + sendResponse(c, rsp) + } } // HTTPPolicyDataUesUeIdSmDataUsageMonIdPut - -func HTTPPolicyDataUesUeIdSmDataUsageMonIdPut(c *gin.Context) { - var usageMonData models.UsageMonData +func HTTPPolicyDataUesUeIdSmDataUsageMonIdPut(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + var usageMonData models.UsageMonData - if err := getDataFromRequestBody(c, &usageMonData); err != nil { - return - } + if err := getDataFromRequestBody(c, &usageMonData); err != nil { + return + } - req := http_wrapper.NewRequest(c.Request, usageMonData) - req.Params["ueId"] = c.Params.ByName("ueId") - req.Params["usageMonId"] = c.Params.ByName("usageMonId") + req := http_wrapper.NewRequest(c.Request, usageMonData) + req.Params["ueId"] = c.Params.ByName("ueId") + req.Params["usageMonId"] = c.Params.ByName("usageMonId") - rsp := producer.HandlePolicyDataUesUeIdSmDataUsageMonIdPut(req) + rsp := producer.HandlePolicyDataUesUeIdSmDataUsageMonIdPut(req, m) - sendResponse(c, rsp) + sendResponse(c, rsp) + } } // HTTPPolicyDataUesUeIdUePolicySetGet - -func HTTPPolicyDataUesUeIdUePolicySetGet(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["ueId"] = c.Params.ByName("ueId") +func HTTPPolicyDataUesUeIdUePolicySetGet(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["ueId"] = c.Params.ByName("ueId") - rsp := producer.HandlePolicyDataUesUeIdUePolicySetGet(req) + rsp := producer.HandlePolicyDataUesUeIdUePolicySetGet(req, m) - sendResponse(c, rsp) + sendResponse(c, rsp) + } } // HTTPPolicyDataUesUeIdUePolicySetPatch - -func HTTPPolicyDataUesUeIdUePolicySetPatch(c *gin.Context) { - var uePolicySet models.UePolicySet +func HTTPPolicyDataUesUeIdUePolicySetPatch(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + var uePolicySet models.UePolicySet - if err := getDataFromRequestBody(c, &uePolicySet); err != nil { - return - } + if err := getDataFromRequestBody(c, &uePolicySet); err != nil { + return + } - req := http_wrapper.NewRequest(c.Request, uePolicySet) - req.Params["ueId"] = c.Params.ByName("ueId") + req := http_wrapper.NewRequest(c.Request, uePolicySet) + req.Params["ueId"] = c.Params.ByName("ueId") - rsp := producer.HandlePolicyDataUesUeIdUePolicySetPatch(req) + rsp := producer.HandlePolicyDataUesUeIdUePolicySetPatch(req, m) - sendResponse(c, rsp) + sendResponse(c, rsp) + } } // HTTPPolicyDataUesUeIdUePolicySetPut - -func HTTPPolicyDataUesUeIdUePolicySetPut(c *gin.Context) { - var uePolicySet models.UePolicySet +func HTTPPolicyDataUesUeIdUePolicySetPut(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + var uePolicySet models.UePolicySet - if err := getDataFromRequestBody(c, &uePolicySet); err != nil { - return - } + if err := getDataFromRequestBody(c, &uePolicySet); err != nil { + return + } - req := http_wrapper.NewRequest(c.Request, uePolicySet) - req.Params["ueId"] = c.Params.ByName("ueId") + req := http_wrapper.NewRequest(c.Request, uePolicySet) + req.Params["ueId"] = c.Params.ByName("ueId") - rsp := producer.HandlePolicyDataUesUeIdUePolicySetPut(req) + rsp := producer.HandlePolicyDataUesUeIdUePolicySetPut(req, m) - sendResponse(c, rsp) + sendResponse(c, rsp) + } } diff --git a/datarepository/api_event_exposure_data_document.go b/datarepository/api_event_exposure_data_document.go index 5d559f3..6721e18 100644 --- a/datarepository/api_event_exposure_data_document.go +++ b/datarepository/api_event_exposure_data_document.go @@ -15,6 +15,7 @@ package datarepository import ( + "github.com/omec-project/util/mongoapi" "net/http" "github.com/gin-gonic/gin" @@ -27,22 +28,24 @@ import ( ) // HTTPQueryEEData - Retrieves the ee profile data of a UE -func HTTPQueryEEData(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["ueId"] = c.Params.ByName("ueId") - - rsp := producer.HandleQueryEEData(req) - - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), +func HTTPQueryEEData(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["ueId"] = c.Params.ByName("ueId") + + rsp := producer.HandleQueryEEData(req, m) + + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } diff --git a/datarepository/api_operator_specific_data_container_document.go b/datarepository/api_operator_specific_data_container_document.go index 34feb95..5d7c97d 100644 --- a/datarepository/api_operator_specific_data_container_document.go +++ b/datarepository/api_operator_specific_data_container_document.go @@ -15,6 +15,7 @@ package datarepository import ( + "github.com/omec-project/util/mongoapi" "net/http" "github.com/gin-gonic/gin" @@ -27,71 +28,75 @@ import ( ) // HTTPAmfContext3gpp - To modify operator specific data of a UE -func HTTPPatchOperSpecData(c *gin.Context) { - var patchItemArray []models.PatchItem +func HTTPPatchOperSpecData(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + var patchItemArray []models.PatchItem - requestBody, err := c.GetRawData() - if err != nil { - problemDetail := models.ProblemDetails{ - Title: "System failure", - Status: http.StatusInternalServerError, - Detail: err.Error(), - Cause: "SYSTEM_FAILURE", + requestBody, err := c.GetRawData() + if err != nil { + problemDetail := models.ProblemDetails{ + Title: "System failure", + Status: http.StatusInternalServerError, + Detail: err.Error(), + Cause: "SYSTEM_FAILURE", + } + logger.DataRepoLog.Errorf("Get Request Body error: %+v", err) + c.JSON(http.StatusInternalServerError, problemDetail) + return } - logger.DataRepoLog.Errorf("Get Request Body error: %+v", err) - c.JSON(http.StatusInternalServerError, problemDetail) - return - } - err = openapi.Deserialize(&patchItemArray, requestBody, "application/json") - if err != nil { - problemDetail := "[Request Body] " + err.Error() - rsp := models.ProblemDetails{ - Title: "Malformed request syntax", - Status: http.StatusBadRequest, - Detail: problemDetail, + err = openapi.Deserialize(&patchItemArray, requestBody, "application/json") + if err != nil { + problemDetail := "[Request Body] " + err.Error() + rsp := models.ProblemDetails{ + Title: "Malformed request syntax", + Status: http.StatusBadRequest, + Detail: problemDetail, + } + logger.DataRepoLog.Errorln(problemDetail) + c.JSON(http.StatusBadRequest, rsp) + return } - logger.DataRepoLog.Errorln(problemDetail) - c.JSON(http.StatusBadRequest, rsp) - return - } - req := http_wrapper.NewRequest(c.Request, patchItemArray) - req.Params["ueId"] = c.Params.ByName("ueId") + req := http_wrapper.NewRequest(c.Request, patchItemArray) + req.Params["ueId"] = c.Params.ByName("ueId") - rsp := producer.HandlePatchOperSpecData(req) + rsp := producer.HandlePatchOperSpecData(req, m) - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } // HTTPQueryOperSpecData - Retrieves the operator specific data of a UE -func HTTPQueryOperSpecData(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["ueId"] = c.Params.ByName("ueId") +func HTTPQueryOperSpecData(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["ueId"] = c.Params.ByName("ueId") - rsp := producer.HandleQueryOperSpecData(req) + rsp := producer.HandleQueryOperSpecData(req, m) - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } diff --git a/datarepository/api_parameter_provision_document.go b/datarepository/api_parameter_provision_document.go index 7d065e4..3054663 100644 --- a/datarepository/api_parameter_provision_document.go +++ b/datarepository/api_parameter_provision_document.go @@ -15,6 +15,7 @@ package datarepository import ( + "github.com/omec-project/util/mongoapi" "net/http" "github.com/gin-gonic/gin" @@ -27,22 +28,24 @@ import ( ) // HTTPGetppData - Read the profile of a given UE -func HTTPGetppData(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["ueId"] = c.Params.ByName("ueId") - - rsp := producer.HandleGetppData(req) - - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), +func HTTPGetppData(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["ueId"] = c.Params.ByName("ueId") + + rsp := producer.HandleGetppData(req, m) + + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } diff --git a/datarepository/api_provisioned_data_document.go b/datarepository/api_provisioned_data_document.go index f94b8f3..6c81cd6 100644 --- a/datarepository/api_provisioned_data_document.go +++ b/datarepository/api_provisioned_data_document.go @@ -15,6 +15,7 @@ package datarepository import ( + "github.com/omec-project/util/mongoapi" "net/http" "github.com/gin-gonic/gin" @@ -27,23 +28,25 @@ import ( ) // HTTPQueryProvisionedData - Retrieve multiple provisioned data sets of a UE -func HTTPQueryProvisionedData(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["ueId"] = c.Params.ByName("ueId") - req.Params["servingPlmnId"] = c.Params.ByName("servingPlmnId") - - rsp := producer.HandleQueryProvisionedData(req) - - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), +func HTTPQueryProvisionedData(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["ueId"] = c.Params.ByName("ueId") + req.Params["servingPlmnId"] = c.Params.ByName("servingPlmnId") + + rsp := producer.HandleQueryProvisionedData(req, m) + + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } diff --git a/datarepository/api_provisioned_parameter_data_document.go b/datarepository/api_provisioned_parameter_data_document.go index fa9af4d..d7ae95a 100644 --- a/datarepository/api_provisioned_parameter_data_document.go +++ b/datarepository/api_provisioned_parameter_data_document.go @@ -15,6 +15,7 @@ package datarepository import ( + "github.com/omec-project/util/mongoapi" "net/http" "github.com/gin-gonic/gin" @@ -27,50 +28,52 @@ import ( ) // HTTPModifyPpData - modify the provisioned parameter data -func HTTPModifyPpData(c *gin.Context) { - var patchItemArray []models.PatchItem +func HTTPModifyPpData(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + var patchItemArray []models.PatchItem - requestBody, err := c.GetRawData() - if err != nil { - problemDetail := models.ProblemDetails{ - Title: "System failure", - Status: http.StatusInternalServerError, - Detail: err.Error(), - Cause: "SYSTEM_FAILURE", + requestBody, err := c.GetRawData() + if err != nil { + problemDetail := models.ProblemDetails{ + Title: "System failure", + Status: http.StatusInternalServerError, + Detail: err.Error(), + Cause: "SYSTEM_FAILURE", + } + logger.DataRepoLog.Errorf("Get Request Body error: %+v", err) + c.JSON(http.StatusInternalServerError, problemDetail) + return } - logger.DataRepoLog.Errorf("Get Request Body error: %+v", err) - c.JSON(http.StatusInternalServerError, problemDetail) - return - } - err = openapi.Deserialize(&patchItemArray, requestBody, "application/json") - if err != nil { - problemDetail := "[Request Body] " + err.Error() - rsp := models.ProblemDetails{ - Title: "Malformed request syntax", - Status: http.StatusBadRequest, - Detail: problemDetail, + err = openapi.Deserialize(&patchItemArray, requestBody, "application/json") + if err != nil { + problemDetail := "[Request Body] " + err.Error() + rsp := models.ProblemDetails{ + Title: "Malformed request syntax", + Status: http.StatusBadRequest, + Detail: problemDetail, + } + logger.DataRepoLog.Errorln(problemDetail) + c.JSON(http.StatusBadRequest, rsp) + return } - logger.DataRepoLog.Errorln(problemDetail) - c.JSON(http.StatusBadRequest, rsp) - return - } - req := http_wrapper.NewRequest(c.Request, patchItemArray) - req.Params["ueId"] = c.Params.ByName("ueId") + req := http_wrapper.NewRequest(c.Request, patchItemArray) + req.Params["ueId"] = c.Params.ByName("ueId") - rsp := producer.HandleModifyPpData(req) + rsp := producer.HandleModifyPpData(req, m) - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } diff --git a/datarepository/api_query_identity_data_by_supi_or_gpsi_document.go b/datarepository/api_query_identity_data_by_supi_or_gpsi_document.go index 3669e2f..208e0c1 100644 --- a/datarepository/api_query_identity_data_by_supi_or_gpsi_document.go +++ b/datarepository/api_query_identity_data_by_supi_or_gpsi_document.go @@ -15,6 +15,7 @@ package datarepository import ( + "github.com/omec-project/util/mongoapi" "net/http" "github.com/gin-gonic/gin" @@ -27,22 +28,24 @@ import ( ) // HTTPGetIdentityData - Retrieve identity data by SUPI or GPSI -func HTTPGetIdentityData(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["ueId"] = c.Params.ByName("ueId") - - rsp := producer.HandleGetIdentityData(req) - - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), +func HTTPGetIdentityData(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["ueId"] = c.Params.ByName("ueId") + + rsp := producer.HandleGetIdentityData(req, m) + + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } diff --git a/datarepository/api_query_odb_data_by_supi_or_gpsi_document.go b/datarepository/api_query_odb_data_by_supi_or_gpsi_document.go index 04c66a7..4fa374f 100644 --- a/datarepository/api_query_odb_data_by_supi_or_gpsi_document.go +++ b/datarepository/api_query_odb_data_by_supi_or_gpsi_document.go @@ -15,6 +15,7 @@ package datarepository import ( + "github.com/omec-project/util/mongoapi" "net/http" "github.com/gin-gonic/gin" @@ -27,22 +28,24 @@ import ( ) // HTTPGetOdbData - Retrieve ODB Data data by SUPI or GPSI -func HTTPGetOdbData(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["ueId"] = c.Params.ByName("ueId") - - rsp := producer.HandleGetOdbData(req) - - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), +func HTTPGetOdbData(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["ueId"] = c.Params.ByName("ueId") + + rsp := producer.HandleGetOdbData(req, m) + + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } diff --git a/datarepository/api_retrieval_of_shared_data.go b/datarepository/api_retrieval_of_shared_data.go index 1f16515..5eb9362 100644 --- a/datarepository/api_retrieval_of_shared_data.go +++ b/datarepository/api_retrieval_of_shared_data.go @@ -15,6 +15,7 @@ package datarepository import ( + "github.com/omec-project/util/mongoapi" "net/http" "github.com/gin-gonic/gin" @@ -27,23 +28,25 @@ import ( ) // HTTPGetSharedData - retrieve shared data -func HTTPGetSharedData(c *gin.Context) { - sharedDataIdArray := c.QueryArray("shared-data-ids") - req := http_wrapper.NewRequest(c.Request, nil) - req.Query["sharedDataIds"] = sharedDataIdArray - - rsp := producer.HandleGetSharedData(req) - - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), +func HTTPGetSharedData(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + sharedDataIdArray := c.QueryArray("shared-data-ids") + req := http_wrapper.NewRequest(c.Request, nil) + req.Query["sharedDataIds"] = sharedDataIdArray + + rsp := producer.HandleGetSharedData(req, m) + + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } diff --git a/datarepository/api_session_management_subscription_data.go b/datarepository/api_session_management_subscription_data.go index 951ac60..71c4ad4 100644 --- a/datarepository/api_session_management_subscription_data.go +++ b/datarepository/api_session_management_subscription_data.go @@ -15,6 +15,7 @@ package datarepository import ( + "github.com/omec-project/util/mongoapi" "net/http" "github.com/gin-gonic/gin" @@ -27,23 +28,25 @@ import ( ) // HTTPQuerySmData - Retrieves the Session Management subscription data of a UE -func HTTPQuerySmData(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["ueId"] = c.Params.ByName("ueId") - req.Params["servingPlmnId"] = c.Params.ByName("servingPlmnId") - - rsp := producer.HandleQuerySmData(req) - - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), +func HTTPQuerySmData(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["ueId"] = c.Params.ByName("ueId") + req.Params["servingPlmnId"] = c.Params.ByName("servingPlmnId") + + rsp := producer.HandleQuerySmData(req, m) + + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } diff --git a/datarepository/api_smf_registration_document.go b/datarepository/api_smf_registration_document.go index 3423d5d..2adc8b6 100644 --- a/datarepository/api_smf_registration_document.go +++ b/datarepository/api_smf_registration_document.go @@ -15,6 +15,7 @@ package datarepository import ( + "github.com/omec-project/util/mongoapi" "net/http" "github.com/gin-gonic/gin" @@ -27,94 +28,100 @@ import ( ) // HTTPCreateSmfContextNon3gpp - To create an individual SMF context data of a UE in the UDR -func HTTPCreateSmfContextNon3gpp(c *gin.Context) { - var smfRegistration models.SmfRegistration - - requestBody, err := c.GetRawData() - if err != nil { - problemDetail := models.ProblemDetails{ - Title: "System failure", - Status: http.StatusInternalServerError, - Detail: err.Error(), - Cause: "SYSTEM_FAILURE", +func HTTPCreateSmfContextNon3gpp(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + var smfRegistration models.SmfRegistration + + requestBody, err := c.GetRawData() + if err != nil { + problemDetail := models.ProblemDetails{ + Title: "System failure", + Status: http.StatusInternalServerError, + Detail: err.Error(), + Cause: "SYSTEM_FAILURE", + } + logger.DataRepoLog.Errorf("Get Request Body error: %+v", err) + c.JSON(http.StatusInternalServerError, problemDetail) + return } - logger.DataRepoLog.Errorf("Get Request Body error: %+v", err) - c.JSON(http.StatusInternalServerError, problemDetail) - return - } - err = openapi.Deserialize(&smfRegistration, requestBody, "application/json") - if err != nil { - problemDetail := "[Request Body] " + err.Error() - rsp := models.ProblemDetails{ - Title: "Malformed request syntax", - Status: http.StatusBadRequest, - Detail: problemDetail, + err = openapi.Deserialize(&smfRegistration, requestBody, "application/json") + if err != nil { + problemDetail := "[Request Body] " + err.Error() + rsp := models.ProblemDetails{ + Title: "Malformed request syntax", + Status: http.StatusBadRequest, + Detail: problemDetail, + } + logger.DataRepoLog.Errorln(problemDetail) + c.JSON(http.StatusBadRequest, rsp) + return } - logger.DataRepoLog.Errorln(problemDetail) - c.JSON(http.StatusBadRequest, rsp) - return - } - - req := http_wrapper.NewRequest(c.Request, smfRegistration) - req.Params["ueId"] = c.Params.ByName("ueId") - - rsp := producer.HandleCreateSmfContextNon3gpp(req) - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), + req := http_wrapper.NewRequest(c.Request, smfRegistration) + req.Params["ueId"] = c.Params.ByName("ueId") + + rsp := producer.HandleCreateSmfContextNon3gpp(req, m) + + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } // HTTPDeleteSmfContext - To remove an individual SMF context data of a UE the UDR -func HTTPDeleteSmfContext(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["ueId"] = c.Params.ByName("ueId") - req.Params["pduSessionId"] = c.Params.ByName("pduSessionId") - - rsp := producer.HandleDeleteSmfContext(req) - - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), +func HTTPDeleteSmfContext(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["ueId"] = c.Params.ByName("ueId") + req.Params["pduSessionId"] = c.Params.ByName("pduSessionId") + + rsp := producer.HandleDeleteSmfContext(req, m) + + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } // HTTPQuerySmfRegistration - Retrieves the individual SMF registration of a UE -func HTTPQuerySmfRegistration(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["ueId"] = c.Params.ByName("ueId") - req.Params["pduSessionId"] = c.Params.ByName("pduSessionId") - - rsp := producer.HandleQuerySmfRegistration(req) - - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), +func HTTPQuerySmfRegistration(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["ueId"] = c.Params.ByName("ueId") + req.Params["pduSessionId"] = c.Params.ByName("pduSessionId") + + rsp := producer.HandleQuerySmfRegistration(req, m) + + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } diff --git a/datarepository/api_smf_registrations_collection.go b/datarepository/api_smf_registrations_collection.go index 7aac6af..fe04a2d 100644 --- a/datarepository/api_smf_registrations_collection.go +++ b/datarepository/api_smf_registrations_collection.go @@ -15,6 +15,7 @@ package datarepository import ( + "github.com/omec-project/util/mongoapi" "net/http" "github.com/gin-gonic/gin" @@ -27,22 +28,24 @@ import ( ) // HTTPQuerySmfRegList - Retrieves the SMF registration list of a UE -func HTTPQuerySmfRegList(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["ueId"] = c.Params.ByName("ueId") - - rsp := producer.HandleQuerySmfRegList(req) - - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), +func HTTPQuerySmfRegList(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["ueId"] = c.Params.ByName("ueId") + + rsp := producer.HandleQuerySmfRegList(req, m) + + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } diff --git a/datarepository/api_smf_selection_subscription_data_document.go b/datarepository/api_smf_selection_subscription_data_document.go index 1fccf07..0975ec2 100644 --- a/datarepository/api_smf_selection_subscription_data_document.go +++ b/datarepository/api_smf_selection_subscription_data_document.go @@ -15,6 +15,7 @@ package datarepository import ( + "github.com/omec-project/util/mongoapi" "net/http" "github.com/gin-gonic/gin" @@ -27,23 +28,25 @@ import ( ) // HTTPQuerySmfSelectData - Retrieves the SMF selection subscription data of a UE -func HTTPQuerySmfSelectData(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["ueId"] = c.Params.ByName("ueId") - req.Params["servingPlmnId"] = c.Params.ByName("servingPlmnId") - - rsp := producer.HandleQuerySmfSelectData(req) - - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), +func HTTPQuerySmfSelectData(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["ueId"] = c.Params.ByName("ueId") + req.Params["servingPlmnId"] = c.Params.ByName("servingPlmnId") + + rsp := producer.HandleQuerySmfSelectData(req, m) + + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } diff --git a/datarepository/api_sms_management_subscription_data_document.go b/datarepository/api_sms_management_subscription_data_document.go index 241396e..5196f5d 100644 --- a/datarepository/api_sms_management_subscription_data_document.go +++ b/datarepository/api_sms_management_subscription_data_document.go @@ -15,6 +15,7 @@ package datarepository import ( + "github.com/omec-project/util/mongoapi" "net/http" "github.com/gin-gonic/gin" @@ -27,23 +28,25 @@ import ( ) // HTTPQuerySmsMngData - Retrieves the SMS management subscription data of a UE -func HTTPQuerySmsMngData(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["ueId"] = c.Params.ByName("ueId") - req.Params["servingPlmnId"] = c.Params.ByName("servingPlmnId") - - rsp := producer.HandleQuerySmsMngData(req) - - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), +func HTTPQuerySmsMngData(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["ueId"] = c.Params.ByName("ueId") + req.Params["servingPlmnId"] = c.Params.ByName("servingPlmnId") + + rsp := producer.HandleQuerySmsMngData(req, m) + + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } diff --git a/datarepository/api_sms_subscription_data_document.go b/datarepository/api_sms_subscription_data_document.go index 4edfadb..1c7ead7 100644 --- a/datarepository/api_sms_subscription_data_document.go +++ b/datarepository/api_sms_subscription_data_document.go @@ -15,6 +15,7 @@ package datarepository import ( + "github.com/omec-project/util/mongoapi" "net/http" "github.com/gin-gonic/gin" @@ -27,23 +28,25 @@ import ( ) // HTTPQuerySmsData - Retrieves the SMS subscription data of a UE -func HTTPQuerySmsData(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["ueId"] = c.Params.ByName("ueId") - req.Params["servingPlmnId"] = c.Params.ByName("servingPlmnId") - - rsp := producer.HandleQuerySmsData(req) - - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), +func HTTPQuerySmsData(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["ueId"] = c.Params.ByName("ueId") + req.Params["servingPlmnId"] = c.Params.ByName("servingPlmnId") + + rsp := producer.HandleQuerySmsData(req, m) + + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } diff --git a/datarepository/api_smsf3_gpp_registration_document.go b/datarepository/api_smsf3_gpp_registration_document.go index 7dbb137..7896134 100644 --- a/datarepository/api_smsf3_gpp_registration_document.go +++ b/datarepository/api_smsf3_gpp_registration_document.go @@ -15,6 +15,7 @@ package datarepository import ( + "github.com/omec-project/util/mongoapi" "net/http" "github.com/gin-gonic/gin" @@ -27,92 +28,98 @@ import ( ) // HTTPCreateSmsfContext3gpp - Create the SMSF context data of a UE via 3GPP access -func HTTPCreateSmsfContext3gpp(c *gin.Context) { - var smsfRegistration models.SmsfRegistration - - requestBody, err := c.GetRawData() - if err != nil { - problemDetail := models.ProblemDetails{ - Title: "System failure", - Status: http.StatusInternalServerError, - Detail: err.Error(), - Cause: "SYSTEM_FAILURE", +func HTTPCreateSmsfContext3gpp(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + var smsfRegistration models.SmsfRegistration + + requestBody, err := c.GetRawData() + if err != nil { + problemDetail := models.ProblemDetails{ + Title: "System failure", + Status: http.StatusInternalServerError, + Detail: err.Error(), + Cause: "SYSTEM_FAILURE", + } + logger.DataRepoLog.Errorf("Get Request Body error: %+v", err) + c.JSON(http.StatusInternalServerError, problemDetail) + return } - logger.DataRepoLog.Errorf("Get Request Body error: %+v", err) - c.JSON(http.StatusInternalServerError, problemDetail) - return - } - err = openapi.Deserialize(&smsfRegistration, requestBody, "application/json") - if err != nil { - problemDetail := "[Request Body] " + err.Error() - rsp := models.ProblemDetails{ - Title: "Malformed request syntax", - Status: http.StatusBadRequest, - Detail: problemDetail, + err = openapi.Deserialize(&smsfRegistration, requestBody, "application/json") + if err != nil { + problemDetail := "[Request Body] " + err.Error() + rsp := models.ProblemDetails{ + Title: "Malformed request syntax", + Status: http.StatusBadRequest, + Detail: problemDetail, + } + logger.DataRepoLog.Errorln(problemDetail) + c.JSON(http.StatusBadRequest, rsp) + return } - logger.DataRepoLog.Errorln(problemDetail) - c.JSON(http.StatusBadRequest, rsp) - return - } - - req := http_wrapper.NewRequest(c.Request, smsfRegistration) - req.Params["ueId"] = c.Params.ByName("ueId") - - rsp := producer.HandleCreateSmsfContext3gpp(req) - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), + req := http_wrapper.NewRequest(c.Request, smsfRegistration) + req.Params["ueId"] = c.Params.ByName("ueId") + + rsp := producer.HandleCreateSmsfContext3gpp(req, m) + + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } // HTTPDeleteSmsfContext3gpp - To remove the SMSF context data of a UE via 3GPP access -func HTTPDeleteSmsfContext3gpp(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["ueId"] = c.Params.ByName("ueId") - - rsp := producer.HandleDeleteSmsfContext3gpp(req) - - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), +func HTTPDeleteSmsfContext3gpp(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["ueId"] = c.Params.ByName("ueId") + + rsp := producer.HandleDeleteSmsfContext3gpp(req, m) + + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } // HTTPQuerySmsfContext3gpp - Retrieves the SMSF context data of a UE using 3gpp access -func HTTPQuerySmsfContext3gpp(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["ueId"] = c.Params.ByName("ueId") - - rsp := producer.HandleQuerySmsfContext3gpp(req) - - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), +func HTTPQuerySmsfContext3gpp(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["ueId"] = c.Params.ByName("ueId") + + rsp := producer.HandleQuerySmsfContext3gpp(req, m) + + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } diff --git a/datarepository/api_smsf_non3_gpp_registration_document.go b/datarepository/api_smsf_non3_gpp_registration_document.go index 791fa3d..789ed99 100644 --- a/datarepository/api_smsf_non3_gpp_registration_document.go +++ b/datarepository/api_smsf_non3_gpp_registration_document.go @@ -15,6 +15,7 @@ package datarepository import ( + "github.com/omec-project/util/mongoapi" "net/http" "github.com/gin-gonic/gin" @@ -27,92 +28,98 @@ import ( ) // HTTPCreateSmsfContextNon3gpp - Create the SMSF context data of a UE via non-3GPP access -func HTTPCreateSmsfContextNon3gpp(c *gin.Context) { - var smsfRegistration models.SmsfRegistration - - requestBody, err := c.GetRawData() - if err != nil { - problemDetail := models.ProblemDetails{ - Title: "System failure", - Status: http.StatusInternalServerError, - Detail: err.Error(), - Cause: "SYSTEM_FAILURE", +func HTTPCreateSmsfContextNon3gpp(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + var smsfRegistration models.SmsfRegistration + + requestBody, err := c.GetRawData() + if err != nil { + problemDetail := models.ProblemDetails{ + Title: "System failure", + Status: http.StatusInternalServerError, + Detail: err.Error(), + Cause: "SYSTEM_FAILURE", + } + logger.DataRepoLog.Errorf("Get Request Body error: %+v", err) + c.JSON(http.StatusInternalServerError, problemDetail) + return } - logger.DataRepoLog.Errorf("Get Request Body error: %+v", err) - c.JSON(http.StatusInternalServerError, problemDetail) - return - } - err = openapi.Deserialize(&smsfRegistration, requestBody, "application/json") - if err != nil { - problemDetail := "[Request Body] " + err.Error() - rsp := models.ProblemDetails{ - Title: "Malformed request syntax", - Status: http.StatusBadRequest, - Detail: problemDetail, + err = openapi.Deserialize(&smsfRegistration, requestBody, "application/json") + if err != nil { + problemDetail := "[Request Body] " + err.Error() + rsp := models.ProblemDetails{ + Title: "Malformed request syntax", + Status: http.StatusBadRequest, + Detail: problemDetail, + } + logger.DataRepoLog.Errorln(problemDetail) + c.JSON(http.StatusBadRequest, rsp) + return } - logger.DataRepoLog.Errorln(problemDetail) - c.JSON(http.StatusBadRequest, rsp) - return - } - - req := http_wrapper.NewRequest(c.Request, smsfRegistration) - req.Params["ueId"] = c.Params.ByName("ueId") - - rsp := producer.HandleCreateSmsfContextNon3gpp(req) - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), + req := http_wrapper.NewRequest(c.Request, smsfRegistration) + req.Params["ueId"] = c.Params.ByName("ueId") + + rsp := producer.HandleCreateSmsfContextNon3gpp(req, m) + + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } // HTTPDeleteSmsfContextNon3gpp - To remove the SMSF context data of a UE via non-3GPP access -func HTTPDeleteSmsfContextNon3gpp(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["ueId"] = c.Params.ByName("ueId") - - rsp := producer.HandleDeleteSmsfContextNon3gpp(req) - - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), +func HTTPDeleteSmsfContextNon3gpp(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["ueId"] = c.Params.ByName("ueId") + + rsp := producer.HandleDeleteSmsfContextNon3gpp(req, m) + + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } // HTTPQuerySmsfContextNon3gpp - Retrieves the SMSF context data of a UE using non-3gpp access -func HTTPQuerySmsfContextNon3gpp(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["ueId"] = c.Params.ByName("ueId") - - rsp := producer.HandleQuerySmsfContextNon3gpp(req) - - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), +func HTTPQuerySmsfContextNon3gpp(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["ueId"] = c.Params.ByName("ueId") + + rsp := producer.HandleQuerySmsfContextNon3gpp(req, m) + + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } diff --git a/datarepository/api_trace_data_document.go b/datarepository/api_trace_data_document.go index 8c08a79..0d010c4 100644 --- a/datarepository/api_trace_data_document.go +++ b/datarepository/api_trace_data_document.go @@ -15,6 +15,7 @@ package datarepository import ( + "github.com/omec-project/util/mongoapi" "net/http" "github.com/gin-gonic/gin" @@ -27,23 +28,25 @@ import ( ) // HTTPQueryTraceData - Retrieves the trace configuration data of a UE -func HTTPQueryTraceData(c *gin.Context) { - req := http_wrapper.NewRequest(c.Request, nil) - req.Params["ueId"] = c.Params.ByName("ueId") - req.Params["servingPlmnId"] = c.Params.ByName("servingPlmnId") - - rsp := producer.HandleQueryTraceData(req) - - responseBody, err := openapi.Serialize(rsp.Body, "application/json") - if err != nil { - logger.DataRepoLog.Errorln(err) - problemDetails := models.ProblemDetails{ - Status: http.StatusInternalServerError, - Cause: "SYSTEM_FAILURE", - Detail: err.Error(), +func HTTPQueryTraceData(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + req := http_wrapper.NewRequest(c.Request, nil) + req.Params["ueId"] = c.Params.ByName("ueId") + req.Params["servingPlmnId"] = c.Params.ByName("servingPlmnId") + + rsp := producer.HandleQueryTraceData(req, m) + + responseBody, err := openapi.Serialize(rsp.Body, "application/json") + if err != nil { + logger.DataRepoLog.Errorln(err) + problemDetails := models.ProblemDetails{ + Status: http.StatusInternalServerError, + Cause: "SYSTEM_FAILURE", + Detail: err.Error(), + } + c.JSON(http.StatusInternalServerError, problemDetails) + } else { + c.Data(rsp.Status, "application/json", responseBody) } - c.JSON(http.StatusInternalServerError, problemDetails) - } else { - c.Data(rsp.Status, "application/json", responseBody) } } diff --git a/datarepository/routers.go b/datarepository/routers.go index 8c7d88e..26719ba 100644 --- a/datarepository/routers.go +++ b/datarepository/routers.go @@ -15,6 +15,7 @@ package datarepository import ( + "github.com/omec-project/util/mongoapi" "net/http" "strings" @@ -40,56 +41,65 @@ type Route struct { type Routes []Route // NewRouter returns a new router. -func NewRouter() *gin.Engine { +func NewRouter(m mongoapi.MongoClient) *gin.Engine { router := logger_util.NewGinWithLogrus(logger.GinLog) - AddService(router) + AddService(router, m) return router } -func subMsgShortDispatchHandlerFunc(c *gin.Context) { - op := c.Param("ueId") - for _, route := range subShortRoutes { - if strings.Contains(route.Pattern, op) && route.Method == c.Request.Method { - route.HandlerFunc(c) - return +func subMsgShortDispatchHandlerFunc(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + op := c.Param("ueId") + var subShortRoutes = GetsubShortRoutes(m) + for _, route := range subShortRoutes { + if strings.Contains(route.Pattern, op) && route.Method == c.Request.Method { + route.HandlerFunc(c) + return + } } + c.String(http.StatusMethodNotAllowed, "Method Not Allowed") } - c.String(http.StatusMethodNotAllowed, "Method Not Allowed") } -func subMsgDispatchHandlerFunc(c *gin.Context) { - op := c.Param("servingPlmnId") - subsToNotify := c.Param("ueId") - for _, route := range subRoutes { - if strings.Contains(route.Pattern, op) && route.Method == c.Request.Method { - route.HandlerFunc(c) - return - } - // Sepcial case - if subsToNotify == "subs-to-notify" && strings.Contains(route.Pattern, "subs-to-notify") && route.Method == c.Request.Method { - c.Params = append(c.Params, gin.Param{Key: "subsId", Value: c.Param("servingPlmnId")}) - route.HandlerFunc(c) - return +func subMsgDispatchHandlerFunc(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + op := c.Param("servingPlmnId") + subsToNotify := c.Param("ueId") + var subRoutes = GetSubRoutes(m) + for _, route := range subRoutes { + if strings.Contains(route.Pattern, op) && route.Method == c.Request.Method { + route.HandlerFunc(c) + return + } + // Sepcial case + if subsToNotify == "subs-to-notify" && strings.Contains(route.Pattern, "subs-to-notify") && route.Method == c.Request.Method { + c.Params = append(c.Params, gin.Param{Key: "subsId", Value: c.Param("servingPlmnId")}) + route.HandlerFunc(c) + return + } } + c.String(http.StatusMethodNotAllowed, "Method Not Allowed") } - c.String(http.StatusMethodNotAllowed, "Method Not Allowed") } -func eeMsgShortDispatchHandlerFunc(c *gin.Context) { - groupData := c.Param("ueId") - contextData := c.Param("servingPlmnId") - for _, route := range eeShortRoutes { - if strings.Contains(route.Pattern, groupData) && route.Method == c.Request.Method { - c.Params = append(c.Params, gin.Param{Key: "ueGroupId", Value: c.Param("servingPlmnId")}) - route.HandlerFunc(c) - return - } - if strings.Contains(route.Pattern, contextData) && route.Method == c.Request.Method { - route.HandlerFunc(c) - return +func eeMsgShortDispatchHandlerFunc(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + groupData := c.Param("ueId") + contextData := c.Param("servingPlmnId") + var eeShortRoutes = GetEeShortRoutes(m) + for _, route := range eeShortRoutes { + if strings.Contains(route.Pattern, groupData) && route.Method == c.Request.Method { + c.Params = append(c.Params, gin.Param{Key: "ueGroupId", Value: c.Param("servingPlmnId")}) + route.HandlerFunc(c) + return + } + if strings.Contains(route.Pattern, contextData) && route.Method == c.Request.Method { + route.HandlerFunc(c) + return + } } + c.String(http.StatusMethodNotAllowed, "Method Not Allowed") } - c.String(http.StatusMethodNotAllowed, "Method Not Allowed") } func eeMsgDispatchHandlerFunc(c *gin.Context) { @@ -110,24 +120,27 @@ func eeMsgDispatchHandlerFunc(c *gin.Context) { } // Handler to distinguish "subs-to-notify" from ":influenceId". -func appInfluDataMsgDispatchHandlerFunc(c *gin.Context) { - influID := c.Param("influenceId") - for _, route := range appInfluDataRoutes { - if route.Method == c.Request.Method { - if influID == "subs-to-notify" { - if strings.Contains(route.Pattern, "subs-to-notify") { - route.HandlerFunc(c) - return - } - } else { - if !strings.Contains(route.Pattern, "subs-to-notify") { - route.HandlerFunc(c) - return +func appInfluDataMsgDispatchHandlerFunc(m mongoapi.MongoClient) gin.HandlerFunc { + return func(c *gin.Context) { + influID := c.Param("influenceId") + var appInfluDataRoutes = GetAppInfluDataRoutes(m) + for _, route := range appInfluDataRoutes { + if route.Method == c.Request.Method { + if influID == "subs-to-notify" { + if strings.Contains(route.Pattern, "subs-to-notify") { + route.HandlerFunc(c) + return + } + } else { + if !strings.Contains(route.Pattern, "subs-to-notify") { + route.HandlerFunc(c) + return + } } } } + c.String(http.StatusMethodNotAllowed, "Method Not Allowed") } - c.String(http.StatusMethodNotAllowed, "Method Not Allowed") } func expoMsgDispatchHandlerFunc(c *gin.Context) { @@ -146,9 +159,9 @@ func expoMsgDispatchHandlerFunc(c *gin.Context) { c.String(http.StatusMethodNotAllowed, "Method Not Allowed") } -func AddService(engine *gin.Engine) *gin.RouterGroup { +func AddService(engine *gin.Engine, m mongoapi.MongoClient) *gin.RouterGroup { group := engine.Group("/nudr-dr/v1") - + var routes = GetRoutes(m) for _, route := range routes { switch route.Method { case "GET": @@ -165,13 +178,13 @@ func AddService(engine *gin.Engine) *gin.RouterGroup { } subPatternShort := "/subscription-data/:ueId" - group.Any(subPatternShort, subMsgShortDispatchHandlerFunc) + group.Any(subPatternShort, subMsgShortDispatchHandlerFunc(m)) subPattern := "/subscription-data/:ueId/:servingPlmnId" - group.Any(subPattern, subMsgDispatchHandlerFunc) + group.Any(subPattern, subMsgDispatchHandlerFunc(m)) eePatternShort := "/subscription-data/:ueId/:servingPlmnId/ee-subscriptions" - group.Any(eePatternShort, eeMsgShortDispatchHandlerFunc) + group.Any(eePatternShort, eeMsgShortDispatchHandlerFunc(m)) eePattern := "/subscription-data/:ueId/:servingPlmnId/ee-subscriptions/:subsId" group.Any(eePattern, eeMsgDispatchHandlerFunc) @@ -184,7 +197,7 @@ func AddService(engine *gin.Engine) *gin.RouterGroup { * use a dispatch handler to distinguish "subs-to-notify" from ":influenceId". */ appInfluDataPattern := "/application-data/influenceData/:influenceId" - group.Any(appInfluDataPattern, appInfluDataMsgDispatchHandlerFunc) + group.Any(appInfluDataPattern, appInfluDataMsgDispatchHandlerFunc(m)) expoPatternShort := "/exposure-data/:ueId/:subId" group.Any(expoPatternShort, expoMsgDispatchHandlerFunc) @@ -200,587 +213,595 @@ func Index(c *gin.Context) { c.String(http.StatusOK, "Hello World!") } -var routes = Routes{ - { - "Index", - "GET", - "/", - Index, - }, - - { - "HTTPAmfContext3gpp", - strings.ToUpper("Patch"), - "/subscription-data/:ueId/:servingPlmnId/amf-3gpp-access", - HTTPAmfContext3gpp, - }, - - { - "HTTPCreateAmfContext3gpp", - strings.ToUpper("Put"), - "/subscription-data/:ueId/:servingPlmnId/amf-3gpp-access", - HTTPCreateAmfContext3gpp, - }, - - { - "HTTPQueryAmfContext3gpp", - strings.ToUpper("Get"), - "/subscription-data/:ueId/:servingPlmnId/amf-3gpp-access", - HTTPQueryAmfContext3gpp, - }, - - { - "HTTPAmfContextNon3gpp", - strings.ToUpper("Patch"), - "/subscription-data/:ueId/:servingPlmnId/amf-non-3gpp-access", - HTTPAmfContextNon3gpp, - }, - - { - "HTTPCreateAmfContextNon3gpp", - strings.ToUpper("Put"), - "/subscription-data/:ueId/:servingPlmnId/amf-non-3gpp-access", - HTTPCreateAmfContextNon3gpp, - }, - - { - "HTTPQueryAmfContextNon3gpp", - strings.ToUpper("Get"), - "/subscription-data/:ueId/:servingPlmnId/amf-non-3gpp-access", - HTTPQueryAmfContextNon3gpp, - }, - - { - "HTTPQueryAmData", - strings.ToUpper("Get"), - "/subscription-data/:ueId/:servingPlmnId/provisioned-data/am-data", - HTTPQueryAmData, - }, - - { - "HTTPQueryAuthenticationStatus", - strings.ToUpper("Get"), - "/subscription-data/:ueId/:servingPlmnId/authentication-status", - HTTPQueryAuthenticationStatus, - }, - - { - "HTTPModifyAuthentication", - strings.ToUpper("Patch"), - "/subscription-data/:ueId/:servingPlmnId/authentication-subscription", - HTTPModifyAuthentication, - }, - - { - "HTTPQueryAuthSubsData", - strings.ToUpper("Get"), - "/subscription-data/:ueId/:servingPlmnId/authentication-subscription", - HTTPQueryAuthSubsData, - }, - - { - "HTTPCreateAuthenticationSoR", - strings.ToUpper("Put"), - "/subscription-data/:ueId/:servingPlmnId/sor-data", - HTTPCreateAuthenticationSoR, - }, - - { - "HTTPQueryAuthSoR", - strings.ToUpper("Get"), - "/subscription-data/:ueId/:servingPlmnId/sor-data", - HTTPQueryAuthSoR, - }, - - { - "HTTPCreateAuthenticationStatus", - strings.ToUpper("Put"), - "/subscription-data/:ueId/:servingPlmnId/authentication-status", - HTTPCreateAuthenticationStatus, - }, - - { - "HTTPApplicationDataInfluenceDataGet", - strings.ToUpper("Get"), - "/application-data/influenceData", - HTTPApplicationDataInfluenceDataGet, - }, - - /* - * GIN wildcard issue: - * '/application-data/influenceData/:influenceId' and - * '/application-data/influenceData/subs-to-notify' patterns will be conflicted. - * Only can use '/application-data/influenceData/:influenceId' pattern. - * Here ":influenceId" value should be "subs-to-notify". - */ - { - "HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdDelete", - strings.ToUpper("Delete"), - "/application-data/influenceData/:influenceId/:subscriptionId", - HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdDelete, - }, - - { - "HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdGet", - strings.ToUpper("Get"), - "/application-data/influenceData/:influenceId/:subscriptionId", - HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdGet, - }, - - { - "HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdPut", - strings.ToUpper("Put"), - "/application-data/influenceData/:influenceId/:subscriptionId", - HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdPut, - }, - - { - "HTTPApplicationDataPfdsAppIdDelete", - strings.ToUpper("Delete"), - "/application-data/pfds/:appId", - HTTPApplicationDataPfdsAppIdDelete, - }, - - { - "HTTPApplicationDataPfdsAppIdGet", - strings.ToUpper("Get"), - "/application-data/pfds/:appId", - HTTPApplicationDataPfdsAppIdGet, - }, - - { - "HTTPApplicationDataPfdsAppIdPut", - strings.ToUpper("Put"), - "/application-data/pfds/:appId", - HTTPApplicationDataPfdsAppIdPut, - }, - - { - "HTTPApplicationDataPfdsGet", - strings.ToUpper("Get"), - "/application-data/pfds", - HTTPApplicationDataPfdsGet, - }, - - { - "HTTPPolicyDataBdtDataBdtReferenceIdDelete", - strings.ToUpper("Delete"), - "/policy-data/bdt-data/:bdtReferenceId", - HTTPPolicyDataBdtDataBdtReferenceIdDelete, - }, - - { - "HTTPPolicyDataBdtDataBdtReferenceIdGet", - strings.ToUpper("Get"), - "/policy-data/bdt-data/:bdtReferenceId", - HTTPPolicyDataBdtDataBdtReferenceIdGet, - }, - - { - "HTTPPolicyDataBdtDataBdtReferenceIdPut", - strings.ToUpper("Put"), - "/policy-data/bdt-data/:bdtReferenceId", - HTTPPolicyDataBdtDataBdtReferenceIdPut, - }, - - { - "HTTPPolicyDataBdtDataGet", - strings.ToUpper("Get"), - "/policy-data/bdt-data", - HTTPPolicyDataBdtDataGet, - }, - - { - "HTTPPolicyDataPlmnsPlmnIdUePolicySetGet", - strings.ToUpper("Get"), - "/policy-data/plmns/:plmnId/ue-policy-set", - HTTPPolicyDataPlmnsPlmnIdUePolicySetGet, - }, - - { - "HTTPPolicyDataSponsorConnectivityDataSponsorIdGet", - strings.ToUpper("Get"), - "/policy-data/sponsor-connectivity-data/:sponsorId", - HTTPPolicyDataSponsorConnectivityDataSponsorIdGet, - }, - - { - "HTTPPolicyDataSubsToNotifyPost", - strings.ToUpper("Post"), - "/policy-data/subs-to-notify", - HTTPPolicyDataSubsToNotifyPost, - }, - - { - "HTTPPolicyDataSubsToNotifySubsIdDelete", - strings.ToUpper("Delete"), - "/policy-data/subs-to-notify/:subsId", - HTTPPolicyDataSubsToNotifySubsIdDelete, - }, - - { - "HTTPPolicyDataSubsToNotifySubsIdPut", - strings.ToUpper("Put"), - "/policy-data/subs-to-notify/:subsId", - HTTPPolicyDataSubsToNotifySubsIdPut, - }, - - { - "HTTPPolicyDataUesUeIdAmDataGet", - strings.ToUpper("Get"), - "/policy-data/ues/:ueId/am-data", - HTTPPolicyDataUesUeIdAmDataGet, - }, - - { - "HTTPPolicyDataUesUeIdOperatorSpecificDataGet", - strings.ToUpper("Get"), - "/policy-data/ues/:ueId/operator-specific-data", - HTTPPolicyDataUesUeIdOperatorSpecificDataGet, - }, - - { - "HTTPPolicyDataUesUeIdOperatorSpecificDataPatch", - strings.ToUpper("Patch"), - "/policy-data/ues/:ueId/operator-specific-data", - HTTPPolicyDataUesUeIdOperatorSpecificDataPatch, - }, - - { - "HTTPPolicyDataUesUeIdOperatorSpecificDataPut", - strings.ToUpper("Put"), - "/policy-data/ues/:ueId/operator-specific-data", - HTTPPolicyDataUesUeIdOperatorSpecificDataPut, - }, - - { - "HTTPPolicyDataUesUeIdSmDataGet", - strings.ToUpper("Get"), - "/policy-data/ues/:ueId/sm-data", - HTTPPolicyDataUesUeIdSmDataGet, - }, - - { - "HTTPPolicyDataUesUeIdSmDataPatch", - strings.ToUpper("Patch"), - "/policy-data/ues/:ueId/sm-data", - HTTPPolicyDataUesUeIdSmDataPatch, - }, - - { - "HTTPPolicyDataUesUeIdSmDataUsageMonIdDelete", - strings.ToUpper("Delete"), - "/policy-data/ues/:ueId/sm-data/:usageMonId", - HTTPPolicyDataUesUeIdSmDataUsageMonIdDelete, - }, - - { - "HTTPPolicyDataUesUeIdSmDataUsageMonIdGet", - strings.ToUpper("Get"), - "/policy-data/ues/:ueId/sm-data/:usageMonId", - HTTPPolicyDataUesUeIdSmDataUsageMonIdGet, - }, - - { - "HTTPPolicyDataUesUeIdSmDataUsageMonIdPut", - strings.ToUpper("Put"), - "/policy-data/ues/:ueId/sm-data/:usageMonId", - HTTPPolicyDataUesUeIdSmDataUsageMonIdPut, - }, - - { - "HTTPPolicyDataUesUeIdUePolicySetGet", - strings.ToUpper("Get"), - "/policy-data/ues/:ueId/ue-policy-set", - HTTPPolicyDataUesUeIdUePolicySetGet, - }, - - { - "HTTPPolicyDataUesUeIdUePolicySetPatch", - strings.ToUpper("Patch"), - "/policy-data/ues/:ueId/ue-policy-set", - HTTPPolicyDataUesUeIdUePolicySetPatch, - }, - - { - "HTTPPolicyDataUesUeIdUePolicySetPut", - strings.ToUpper("Put"), - "/policy-data/ues/:ueId/ue-policy-set", - HTTPPolicyDataUesUeIdUePolicySetPut, - }, - - { - "HTTPQueryProvisionedData", - strings.ToUpper("Get"), - "/subscription-data/:ueId/:servingPlmnId/provisioned-data", - HTTPQueryProvisionedData, - }, - - { - "HTTPRemovesdmSubscriptions", - strings.ToUpper("Delete"), - "/subscription-data/:ueId/:servingPlmnId/sdm-subscriptions/:subsId", - HTTPRemovesdmSubscriptions, - }, - - { - "HTTPUpdatesdmsubscriptions", - strings.ToUpper("Put"), - "/subscription-data/:ueId/:servingPlmnId/sdm-subscriptions/:subsId", - HTTPUpdatesdmsubscriptions, - }, - - { - "HTTPCreateSdmSubscriptions", - strings.ToUpper("Post"), - "/subscription-data/:ueId/:servingPlmnId/sdm-subscriptions", - HTTPCreateSdmSubscriptions, - }, - - { - "HTTPQuerysdmsubscriptions", - strings.ToUpper("Get"), - "/subscription-data/:ueId/:servingPlmnId/sdm-subscriptions", - HTTPQuerysdmsubscriptions, - }, - - { - "HTTPCreateSmfContextNon3gpp", - strings.ToUpper("Put"), - "/subscription-data/:ueId/:servingPlmnId/smf-registrations/:pduSessionId", - HTTPCreateSmfContextNon3gpp, - }, - - { - "HTTPDeleteSmfContext", - strings.ToUpper("Delete"), - "/subscription-data/:ueId/:servingPlmnId/smf-registrations/:pduSessionId", - HTTPDeleteSmfContext, - }, - - { - "HTTPQuerySmfRegistration", - strings.ToUpper("Get"), - "/subscription-data/:ueId/:servingPlmnId/smf-registrations/:pduSessionId", - HTTPQuerySmfRegistration, - }, - - { - "HTTPQuerySmfRegList", - strings.ToUpper("Get"), - "/subscription-data/:ueId/:servingPlmnId/smf-registrations", - HTTPQuerySmfRegList, - }, - - { - "HTTPQuerySmfSelectData", - strings.ToUpper("Get"), - "/subscription-data/:ueId/:servingPlmnId/provisioned-data/smf-selection-subscription-data", - HTTPQuerySmfSelectData, - }, - - { - "HTTPCreateSmsfContext3gpp", - strings.ToUpper("Put"), - "/subscription-data/:ueId/:servingPlmnId/smsf-3gpp-access", - HTTPCreateSmsfContext3gpp, - }, - - { - "HTTPDeleteSmsfContext3gpp", - strings.ToUpper("Delete"), - "/subscription-data/:ueId/:servingPlmnId/smsf-3gpp-access", - HTTPDeleteSmsfContext3gpp, - }, - - { - "HTTPQuerySmsfContext3gpp", - strings.ToUpper("Get"), - "/subscription-data/:ueId/:servingPlmnId/smsf-3gpp-access", - HTTPQuerySmsfContext3gpp, - }, - - { - "HTTPCreateSmsfContextNon3gpp", - strings.ToUpper("Put"), - "/subscription-data/:ueId/:servingPlmnId/smsf-non-3gpp-access", - HTTPCreateSmsfContextNon3gpp, - }, - - { - "HTTPDeleteSmsfContextNon3gpp", - strings.ToUpper("Delete"), - "/subscription-data/:ueId/:servingPlmnId/smsf-non-3gpp-access", - HTTPDeleteSmsfContextNon3gpp, - }, - - { - "HTTPQuerySmsfContextNon3gpp", - strings.ToUpper("Get"), - "/subscription-data/:ueId/:servingPlmnId/smsf-non-3gpp-access", - HTTPQuerySmsfContextNon3gpp, - }, - - { - "HTTPQuerySmsMngData", - strings.ToUpper("Get"), - "/subscription-data/:ueId/:servingPlmnId/provisioned-data/sms-mng-data", - HTTPQuerySmsMngData, - }, - - { - "HTTPQuerySmsData", - strings.ToUpper("Get"), - "/subscription-data/:ueId/:servingPlmnId/provisioned-data/sms-data", - HTTPQuerySmsData, - }, - - { - "HTTPQuerySmData", - strings.ToUpper("Get"), - "/subscription-data/:ueId/:servingPlmnId/provisioned-data/sm-data", - HTTPQuerySmData, - }, - - { - "HTTPQueryTraceData", - strings.ToUpper("Get"), - "/subscription-data/:ueId/:servingPlmnId/provisioned-data/trace-data", - HTTPQueryTraceData, - }, - - { - "HTTPCreateAMFSubscriptions", - strings.ToUpper("Put"), - "/subscription-data/:ueId/:servingPlmnId/ee-subscriptions/:subsId/amf-subscriptions", - HTTPCreateAMFSubscriptions, - }, - - { - "HTTPModifyAmfSubscriptionInfo", - strings.ToUpper("Patch"), - "/subscription-data/:ueId/:servingPlmnId/ee-subscriptions/:subsId/amf-subscriptions", - HTTPModifyAmfSubscriptionInfo, - }, - - { - "HTTPRemoveAmfSubscriptionsInfo", - strings.ToUpper("Delete"), - "/subscription-data/:ueId/:servingPlmnId/ee-subscriptions/:subsId/amf-subscriptions", - HTTPRemoveAmfSubscriptionsInfo, - }, - - { - "HTTPGetAmfSubscriptionInfo", - strings.ToUpper("Get"), - "/subscription-data/:ueId/:servingPlmnId/ee-subscriptions/:subsId/amf-subscriptions", - HTTPGetAmfSubscriptionInfo, - }, +func GetRoutes(m mongoapi.MongoClient) Routes { + return Routes{ + { + "Index", + "GET", + "/", + Index, + }, + + { + "HTTPAmfContext3gpp", + strings.ToUpper("Patch"), + "/subscription-data/:ueId/:servingPlmnId/amf-3gpp-access", + HTTPAmfContext3gpp(m), + }, + + { + "HTTPCreateAmfContext3gpp", + strings.ToUpper("Put"), + "/subscription-data/:ueId/:servingPlmnId/amf-3gpp-access", + HTTPCreateAmfContext3gpp(m), + }, + + { + "HTTPQueryAmfContext3gpp", + strings.ToUpper("Get"), + "/subscription-data/:ueId/:servingPlmnId/amf-3gpp-access", + HTTPQueryAmfContext3gpp(m), + }, + + { + "HTTPAmfContextNon3gpp", + strings.ToUpper("Patch"), + "/subscription-data/:ueId/:servingPlmnId/amf-non-3gpp-access", + HTTPAmfContextNon3gpp(m), + }, + + { + "HTTPCreateAmfContextNon3gpp", + strings.ToUpper("Put"), + "/subscription-data/:ueId/:servingPlmnId/amf-non-3gpp-access", + HTTPCreateAmfContextNon3gpp(m), + }, + + { + "HTTPQueryAmfContextNon3gpp", + strings.ToUpper("Get"), + "/subscription-data/:ueId/:servingPlmnId/amf-non-3gpp-access", + HTTPQueryAmfContextNon3gpp(m), + }, + + { + "HTTPQueryAmData", + strings.ToUpper("Get"), + "/subscription-data/:ueId/:servingPlmnId/provisioned-data/am-data", + HTTPQueryAmData(m), + }, + + { + "HTTPQueryAuthenticationStatus", + strings.ToUpper("Get"), + "/subscription-data/:ueId/:servingPlmnId/authentication-status", + HTTPQueryAuthenticationStatus(m), + }, + + { + "HTTPModifyAuthentication", + strings.ToUpper("Patch"), + "/subscription-data/:ueId/:servingPlmnId/authentication-subscription", + HTTPModifyAuthentication(m), + }, + + { + "HTTPQueryAuthSubsData", + strings.ToUpper("Get"), + "/subscription-data/:ueId/:servingPlmnId/authentication-subscription", + HTTPQueryAuthSubsData(m), + }, + + { + "HTTPCreateAuthenticationSoR", + strings.ToUpper("Put"), + "/subscription-data/:ueId/:servingPlmnId/sor-data", + HTTPCreateAuthenticationSoR(m), + }, + + { + "HTTPQueryAuthSoR", + strings.ToUpper("Get"), + "/subscription-data/:ueId/:servingPlmnId/sor-data", + HTTPQueryAuthSoR(m), + }, + + { + "HTTPCreateAuthenticationStatus", + strings.ToUpper("Put"), + "/subscription-data/:ueId/:servingPlmnId/authentication-status", + HTTPCreateAuthenticationStatus(m), + }, + + { + "HTTPApplicationDataInfluenceDataGet", + strings.ToUpper("Get"), + "/application-data/influenceData", + HTTPApplicationDataInfluenceDataGet(m), + }, + + /* + * GIN wildcard issue: + * '/application-data/influenceData/:influenceId' and + * '/application-data/influenceData/subs-to-notify' patterns will be conflicted. + * Only can use '/application-data/influenceData/:influenceId' pattern. + * Here ":influenceId" value should be "subs-to-notify". + */ + { + "HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdDelete", + strings.ToUpper("Delete"), + "/application-data/influenceData/:influenceId/:subscriptionId", + HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdDelete(m), + }, + + { + "HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdGet", + strings.ToUpper("Get"), + "/application-data/influenceData/:influenceId/:subscriptionId", + HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdGet(m), + }, + + { + "HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdPut", + strings.ToUpper("Put"), + "/application-data/influenceData/:influenceId/:subscriptionId", + HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdPut(m), + }, + + { + "HTTPApplicationDataPfdsAppIdDelete", + strings.ToUpper("Delete"), + "/application-data/pfds/:appId", + HTTPApplicationDataPfdsAppIdDelete(m), + }, + + { + "HTTPApplicationDataPfdsAppIdGet", + strings.ToUpper("Get"), + "/application-data/pfds/:appId", + HTTPApplicationDataPfdsAppIdGet(m), + }, + + { + "HTTPApplicationDataPfdsAppIdPut", + strings.ToUpper("Put"), + "/application-data/pfds/:appId", + HTTPApplicationDataPfdsAppIdPut(m), + }, + + { + "HTTPApplicationDataPfdsGet", + strings.ToUpper("Get"), + "/application-data/pfds", + HTTPApplicationDataPfdsGet(m), + }, + + { + "HTTPPolicyDataBdtDataBdtReferenceIdDelete", + strings.ToUpper("Delete"), + "/policy-data/bdt-data/:bdtReferenceId", + HTTPPolicyDataBdtDataBdtReferenceIdDelete(m), + }, + + { + "HTTPPolicyDataBdtDataBdtReferenceIdGet", + strings.ToUpper("Get"), + "/policy-data/bdt-data/:bdtReferenceId", + HTTPPolicyDataBdtDataBdtReferenceIdGet(m), + }, + + { + "HTTPPolicyDataBdtDataBdtReferenceIdPut", + strings.ToUpper("Put"), + "/policy-data/bdt-data/:bdtReferenceId", + HTTPPolicyDataBdtDataBdtReferenceIdPut(m), + }, + + { + "HTTPPolicyDataBdtDataGet", + strings.ToUpper("Get"), + "/policy-data/bdt-data", + HTTPPolicyDataBdtDataGet(m), + }, + + { + "HTTPPolicyDataPlmnsPlmnIdUePolicySetGet", + strings.ToUpper("Get"), + "/policy-data/plmns/:plmnId/ue-policy-set", + HTTPPolicyDataPlmnsPlmnIdUePolicySetGet(m), + }, + + { + "HTTPPolicyDataSponsorConnectivityDataSponsorIdGet", + strings.ToUpper("Get"), + "/policy-data/sponsor-connectivity-data/:sponsorId", + HTTPPolicyDataSponsorConnectivityDataSponsorIdGet(m), + }, + + { + "HTTPPolicyDataSubsToNotifyPost", + strings.ToUpper("Post"), + "/policy-data/subs-to-notify", + HTTPPolicyDataSubsToNotifyPost, + }, + + { + "HTTPPolicyDataSubsToNotifySubsIdDelete", + strings.ToUpper("Delete"), + "/policy-data/subs-to-notify/:subsId", + HTTPPolicyDataSubsToNotifySubsIdDelete, + }, + + { + "HTTPPolicyDataSubsToNotifySubsIdPut", + strings.ToUpper("Put"), + "/policy-data/subs-to-notify/:subsId", + HTTPPolicyDataSubsToNotifySubsIdPut, + }, + + { + "HTTPPolicyDataUesUeIdAmDataGet", + strings.ToUpper("Get"), + "/policy-data/ues/:ueId/am-data", + HTTPPolicyDataUesUeIdAmDataGet(m), + }, + + { + "HTTPPolicyDataUesUeIdOperatorSpecificDataGet", + strings.ToUpper("Get"), + "/policy-data/ues/:ueId/operator-specific-data", + HTTPPolicyDataUesUeIdOperatorSpecificDataGet(m), + }, + + { + "HTTPPolicyDataUesUeIdOperatorSpecificDataPatch", + strings.ToUpper("Patch"), + "/policy-data/ues/:ueId/operator-specific-data", + HTTPPolicyDataUesUeIdOperatorSpecificDataPatch(m), + }, + + { + "HTTPPolicyDataUesUeIdOperatorSpecificDataPut", + strings.ToUpper("Put"), + "/policy-data/ues/:ueId/operator-specific-data", + HTTPPolicyDataUesUeIdOperatorSpecificDataPut(m), + }, + + { + "HTTPPolicyDataUesUeIdSmDataGet", + strings.ToUpper("Get"), + "/policy-data/ues/:ueId/sm-data", + HTTPPolicyDataUesUeIdSmDataGet(m), + }, + + { + "HTTPPolicyDataUesUeIdSmDataPatch", + strings.ToUpper("Patch"), + "/policy-data/ues/:ueId/sm-data", + HTTPPolicyDataUesUeIdSmDataPatch(m), + }, + + { + "HTTPPolicyDataUesUeIdSmDataUsageMonIdDelete", + strings.ToUpper("Delete"), + "/policy-data/ues/:ueId/sm-data/:usageMonId", + HTTPPolicyDataUesUeIdSmDataUsageMonIdDelete(m), + }, + + { + "HTTPPolicyDataUesUeIdSmDataUsageMonIdGet", + strings.ToUpper("Get"), + "/policy-data/ues/:ueId/sm-data/:usageMonId", + HTTPPolicyDataUesUeIdSmDataUsageMonIdGet(m), + }, + + { + "HTTPPolicyDataUesUeIdSmDataUsageMonIdPut", + strings.ToUpper("Put"), + "/policy-data/ues/:ueId/sm-data/:usageMonId", + HTTPPolicyDataUesUeIdSmDataUsageMonIdPut(m), + }, + + { + "HTTPPolicyDataUesUeIdUePolicySetGet", + strings.ToUpper("Get"), + "/policy-data/ues/:ueId/ue-policy-set", + HTTPPolicyDataUesUeIdUePolicySetGet(m), + }, + + { + "HTTPPolicyDataUesUeIdUePolicySetPatch", + strings.ToUpper("Patch"), + "/policy-data/ues/:ueId/ue-policy-set", + HTTPPolicyDataUesUeIdUePolicySetPatch(m), + }, + + { + "HTTPPolicyDataUesUeIdUePolicySetPut", + strings.ToUpper("Put"), + "/policy-data/ues/:ueId/ue-policy-set", + HTTPPolicyDataUesUeIdUePolicySetPut(m), + }, + + { + "HTTPQueryProvisionedData", + strings.ToUpper("Get"), + "/subscription-data/:ueId/:servingPlmnId/provisioned-data", + HTTPQueryProvisionedData(m), + }, + + { + "HTTPRemovesdmSubscriptions", + strings.ToUpper("Delete"), + "/subscription-data/:ueId/:servingPlmnId/sdm-subscriptions/:subsId", + HTTPRemovesdmSubscriptions, + }, + + { + "HTTPUpdatesdmsubscriptions", + strings.ToUpper("Put"), + "/subscription-data/:ueId/:servingPlmnId/sdm-subscriptions/:subsId", + HTTPUpdatesdmsubscriptions, + }, + + { + "HTTPCreateSdmSubscriptions", + strings.ToUpper("Post"), + "/subscription-data/:ueId/:servingPlmnId/sdm-subscriptions", + HTTPCreateSdmSubscriptions, + }, + + { + "HTTPQuerysdmsubscriptions", + strings.ToUpper("Get"), + "/subscription-data/:ueId/:servingPlmnId/sdm-subscriptions", + HTTPQuerysdmsubscriptions, + }, + + { + "HTTPCreateSmfContextNon3gpp", + strings.ToUpper("Put"), + "/subscription-data/:ueId/:servingPlmnId/smf-registrations/:pduSessionId", + HTTPCreateSmfContextNon3gpp(m), + }, + + { + "HTTPDeleteSmfContext", + strings.ToUpper("Delete"), + "/subscription-data/:ueId/:servingPlmnId/smf-registrations/:pduSessionId", + HTTPDeleteSmfContext(m), + }, + + { + "HTTPQuerySmfRegistration", + strings.ToUpper("Get"), + "/subscription-data/:ueId/:servingPlmnId/smf-registrations/:pduSessionId", + HTTPQuerySmfRegistration(m), + }, + + { + "HTTPQuerySmfRegList", + strings.ToUpper("Get"), + "/subscription-data/:ueId/:servingPlmnId/smf-registrations", + HTTPQuerySmfRegList(m), + }, + + { + "HTTPQuerySmfSelectData", + strings.ToUpper("Get"), + "/subscription-data/:ueId/:servingPlmnId/provisioned-data/smf-selection-subscription-data", + HTTPQuerySmfSelectData(m), + }, + + { + "HTTPCreateSmsfContext3gpp", + strings.ToUpper("Put"), + "/subscription-data/:ueId/:servingPlmnId/smsf-3gpp-access", + HTTPCreateSmsfContext3gpp(m), + }, + + { + "HTTPDeleteSmsfContext3gpp", + strings.ToUpper("Delete"), + "/subscription-data/:ueId/:servingPlmnId/smsf-3gpp-access", + HTTPDeleteSmsfContext3gpp(m), + }, + + { + "HTTPQuerySmsfContext3gpp", + strings.ToUpper("Get"), + "/subscription-data/:ueId/:servingPlmnId/smsf-3gpp-access", + HTTPQuerySmsfContext3gpp(m), + }, + + { + "HTTPCreateSmsfContextNon3gpp", + strings.ToUpper("Put"), + "/subscription-data/:ueId/:servingPlmnId/smsf-non-3gpp-access", + HTTPCreateSmsfContextNon3gpp(m), + }, + + { + "HTTPDeleteSmsfContextNon3gpp", + strings.ToUpper("Delete"), + "/subscription-data/:ueId/:servingPlmnId/smsf-non-3gpp-access", + HTTPDeleteSmsfContextNon3gpp(m), + }, + + { + "HTTPQuerySmsfContextNon3gpp", + strings.ToUpper("Get"), + "/subscription-data/:ueId/:servingPlmnId/smsf-non-3gpp-access", + HTTPQuerySmsfContextNon3gpp(m), + }, + + { + "HTTPQuerySmsMngData", + strings.ToUpper("Get"), + "/subscription-data/:ueId/:servingPlmnId/provisioned-data/sms-mng-data", + HTTPQuerySmsMngData(m), + }, + + { + "HTTPQuerySmsData", + strings.ToUpper("Get"), + "/subscription-data/:ueId/:servingPlmnId/provisioned-data/sms-data", + HTTPQuerySmsData(m), + }, + + { + "HTTPQuerySmData", + strings.ToUpper("Get"), + "/subscription-data/:ueId/:servingPlmnId/provisioned-data/sm-data", + HTTPQuerySmData(m), + }, + + { + "HTTPQueryTraceData", + strings.ToUpper("Get"), + "/subscription-data/:ueId/:servingPlmnId/provisioned-data/trace-data", + HTTPQueryTraceData(m), + }, + + { + "HTTPCreateAMFSubscriptions", + strings.ToUpper("Put"), + "/subscription-data/:ueId/:servingPlmnId/ee-subscriptions/:subsId/amf-subscriptions", + HTTPCreateAMFSubscriptions, + }, + + { + "HTTPModifyAmfSubscriptionInfo", + strings.ToUpper("Patch"), + "/subscription-data/:ueId/:servingPlmnId/ee-subscriptions/:subsId/amf-subscriptions", + HTTPModifyAmfSubscriptionInfo, + }, + + { + "HTTPRemoveAmfSubscriptionsInfo", + strings.ToUpper("Delete"), + "/subscription-data/:ueId/:servingPlmnId/ee-subscriptions/:subsId/amf-subscriptions", + HTTPRemoveAmfSubscriptionsInfo, + }, + + { + "HTTPGetAmfSubscriptionInfo", + strings.ToUpper("Get"), + "/subscription-data/:ueId/:servingPlmnId/ee-subscriptions/:subsId/amf-subscriptions", + HTTPGetAmfSubscriptionInfo, + }, + } } -var subRoutes = Routes{ - { - "HTTPQueryEEData", - strings.ToUpper("Get"), - "/subscription-data/:ueId/ee-profile-data", - HTTPQueryEEData, - }, - - { - "HTTPPatchOperSpecData", - strings.ToUpper("Patch"), - "/subscription-data/:ueId/operator-specific-data", - HTTPPatchOperSpecData, - }, - - { - "HTTPQueryOperSpecData", - strings.ToUpper("Get"), - "/subscription-data/:ueId/operator-specific-data", - HTTPQueryOperSpecData, - }, +func GetSubRoutes(m mongoapi.MongoClient) Routes { + return Routes{ + { + "HTTPQueryEEData", + strings.ToUpper("Get"), + "/subscription-data/:ueId/ee-profile-data", + HTTPQueryEEData(m), + }, + + { + "HTTPPatchOperSpecData", + strings.ToUpper("Patch"), + "/subscription-data/:ueId/operator-specific-data", + HTTPPatchOperSpecData(m), + }, + + { + "HTTPQueryOperSpecData", + strings.ToUpper("Get"), + "/subscription-data/:ueId/operator-specific-data", + HTTPQueryOperSpecData(m), + }, + + { + "HTTPGetppData", + strings.ToUpper("Get"), + "/subscription-data/:ueId/pp-data", + HTTPGetppData(m), + }, + + { + "HTTPModifyPpData", + strings.ToUpper("Patch"), + "/subscription-data/:ueId/pp-data", + HTTPModifyPpData(m), + }, + + { + "HTTPGetIdentityData", + strings.ToUpper("Get"), + "/subscription-data/:ueId/identity-data", + HTTPGetIdentityData(m), + }, + + { + "HTTPGetOdbData", + strings.ToUpper("Get"), + "/subscription-data/:ueId/operator-determined-barring-data", + HTTPGetOdbData(m), + }, - { - "HTTPGetppData", - strings.ToUpper("Get"), - "/subscription-data/:ueId/pp-data", - HTTPGetppData, - }, - - { - "HTTPModifyPpData", - strings.ToUpper("Patch"), - "/subscription-data/:ueId/pp-data", - HTTPModifyPpData, - }, - - { - "HTTPGetIdentityData", - strings.ToUpper("Get"), - "/subscription-data/:ueId/identity-data", - HTTPGetIdentityData, - }, - - { - "HTTPGetOdbData", - strings.ToUpper("Get"), - "/subscription-data/:ueId/operator-determined-barring-data", - HTTPGetOdbData, - }, - - // Sepcial case - { - "HTTPRemovesubscriptionDataSubscriptions", - strings.ToUpper("Delete"), - "/subscription-data/subs-to-notify/:subsId", - HTTPRemovesubscriptionDataSubscriptions, - }, + // Sepcial case + { + "HTTPRemovesubscriptionDataSubscriptions", + strings.ToUpper("Delete"), + "/subscription-data/subs-to-notify/:subsId", + HTTPRemovesubscriptionDataSubscriptions, + }, + } } -var subShortRoutes = Routes{ - { - "HTTPGetSharedData", - strings.ToUpper("Get"), - "/subscription-data/shared-data", - HTTPGetSharedData, - }, - - { - "HTTPPostSubscriptionDataSubscriptions", - strings.ToUpper("Post"), - "/subscription-data/subs-to-notify", - HTTPPostSubscriptionDataSubscriptions, - }, +func GetsubShortRoutes(m mongoapi.MongoClient) Routes { + return Routes{ + { + "HTTPGetSharedData", + strings.ToUpper("Get"), + "/subscription-data/shared-data", + HTTPGetSharedData(m), + }, + + { + "HTTPPostSubscriptionDataSubscriptions", + strings.ToUpper("Post"), + "/subscription-data/subs-to-notify", + HTTPPostSubscriptionDataSubscriptions, + }, + } } -var eeShortRoutes = Routes{ - { - "HTTPCreateEeGroupSubscriptions", - strings.ToUpper("Post"), - "/subscription-data/group-data/:ueGroupId/ee-subscriptions", - HTTPCreateEeGroupSubscriptions, - }, - - { - "HTTPQueryEeGroupSubscriptions", - strings.ToUpper("Get"), - "/subscription-data/group-data/:ueGroupId/ee-subscriptions", - HTTPQueryEeGroupSubscriptions, - }, - - { - "HTTPCreateEeSubscriptions", - strings.ToUpper("Post"), - "/subscription-data/:ueId/context-data/ee-subscriptions", - HTTPCreateEeSubscriptions, - }, - - { - "HTTPQueryeesubscriptions", - strings.ToUpper("Get"), - "/subscription-data/:ueId/context-data/ee-subscriptions", - HTTPQueryeesubscriptions, - }, +func GetEeShortRoutes(m mongoapi.MongoClient) Routes { + return Routes{ + { + "HTTPCreateEeGroupSubscriptions", + strings.ToUpper("Post"), + "/subscription-data/group-data/:ueGroupId/ee-subscriptions", + HTTPCreateEeGroupSubscriptions, + }, + + { + "HTTPQueryEeGroupSubscriptions", + strings.ToUpper("Get"), + "/subscription-data/group-data/:ueGroupId/ee-subscriptions", + HTTPQueryEeGroupSubscriptions, + }, + + { + "HTTPCreateEeSubscriptions", + strings.ToUpper("Post"), + "/subscription-data/:ueId/context-data/ee-subscriptions", + HTTPCreateEeSubscriptions, + }, + + { + "HTTPQueryeesubscriptions", + strings.ToUpper("Get"), + "/subscription-data/:ueId/context-data/ee-subscriptions", + HTTPQueryeesubscriptions, + }, + } } var eeRoutes = Routes{ @@ -878,53 +899,55 @@ var expoRoutes = Routes{ }, } -var appInfluDataRoutes = Routes{ - { - "HTTPApplicationDataInfluenceDataSubsToNotifyGet", - strings.ToUpper("Get"), - "/application-data/influenceData/subs-to-notify", - HTTPApplicationDataInfluenceDataSubsToNotifyGet, - }, - - { - "HTTPApplicationDataInfluenceDataSubsToNotifyPost", - strings.ToUpper("Post"), - "/application-data/influenceData/subs-to-notify", - HTTPApplicationDataInfluenceDataSubsToNotifyPost, - }, - - { - "HTTPApplicationDataInfluenceDataInfluenceIdDelete", - strings.ToUpper("Delete"), - "/application-data/influenceData/:influenceId", - HTTPApplicationDataInfluenceDataInfluenceIdDelete, - }, - - { - "HTTPApplicationDataInfluenceDataInfluenceIdPatch", - strings.ToUpper("Patch"), - "/application-data/influenceData/:influenceId", - HTTPApplicationDataInfluenceDataInfluenceIdPatch, - }, - - { - "HTTPApplicationDataInfluenceDataInfluenceIdPut", - strings.ToUpper("Put"), - "/application-data/influenceData/:influenceId", - HTTPApplicationDataInfluenceDataInfluenceIdPut, - }, - - { - "HTTPApplicationDataInfluenceDataSubsToNotifyGet", - strings.ToUpper("Get"), - "/application-data/influenceData/:influenceId", - HTTPApplicationDataInfluenceDataSubsToNotifyGet, - }, - - { - "HTTPApplicationDataInfluenceDataSubsToNotifyPost", - strings.ToUpper("Post"), - "/application-data/influenceData/:influenceId", - HTTPApplicationDataInfluenceDataSubsToNotifyPost, - }, +func GetAppInfluDataRoutes(m mongoapi.MongoClient) Routes { + return Routes{ + { + "HTTPApplicationDataInfluenceDataSubsToNotifyGet", + strings.ToUpper("Get"), + "/application-data/influenceData/subs-to-notify", + HTTPApplicationDataInfluenceDataSubsToNotifyGet(m), + }, + + { + "HTTPApplicationDataInfluenceDataSubsToNotifyPost", + strings.ToUpper("Post"), + "/application-data/influenceData/subs-to-notify", + HTTPApplicationDataInfluenceDataSubsToNotifyPost(m), + }, + + { + "HTTPApplicationDataInfluenceDataInfluenceIdDelete", + strings.ToUpper("Delete"), + "/application-data/influenceData/:influenceId", + HTTPApplicationDataInfluenceDataInfluenceIdDelete(m), + }, + + { + "HTTPApplicationDataInfluenceDataInfluenceIdPatch", + strings.ToUpper("Patch"), + "/application-data/influenceData/:influenceId", + HTTPApplicationDataInfluenceDataInfluenceIdPatch(m), + }, + + { + "HTTPApplicationDataInfluenceDataInfluenceIdPut", + strings.ToUpper("Put"), + "/application-data/influenceData/:influenceId", + HTTPApplicationDataInfluenceDataInfluenceIdPut(m), + }, + + { + "HTTPApplicationDataInfluenceDataSubsToNotifyGet", + strings.ToUpper("Get"), + "/application-data/influenceData/:influenceId", + HTTPApplicationDataInfluenceDataSubsToNotifyGet(m), + }, + + { + "HTTPApplicationDataInfluenceDataSubsToNotifyPost", + strings.ToUpper("Post"), + "/application-data/influenceData/:influenceId", + HTTPApplicationDataInfluenceDataSubsToNotifyPost(m), + }, + } } diff --git a/go.mod b/go.mod index 9da179f..23e8af4 100644 --- a/go.mod +++ b/go.mod @@ -8,22 +8,22 @@ require ( github.com/gin-gonic/gin v1.9.1 github.com/google/uuid v1.5.0 github.com/mitchellh/mapstructure v1.5.0 - github.com/omec-project/MongoDBLibrary v1.1.3 github.com/omec-project/config5g v1.2.0 github.com/omec-project/http2_util v1.1.0 github.com/omec-project/http_wrapper v1.1.0 github.com/omec-project/logger_util v1.1.0 github.com/omec-project/openapi v1.1.0 github.com/omec-project/path_util v1.1.0 + github.com/omec-project/util v1.0.12 github.com/sirupsen/logrus v1.9.3 github.com/urfave/cli v1.22.14 - go.mongodb.org/mongo-driver v1.7.3 + go.mongodb.org/mongo-driver v1.10.1 gopkg.in/yaml.v2 v2.4.0 ) require ( github.com/antihax/optional v1.0.0 // indirect - github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef // indirect + github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect github.com/bytedance/sonic v1.9.1 // indirect github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect @@ -32,19 +32,19 @@ require ( github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/validator/v10 v10.14.0 // indirect - github.com/go-stack/stack v1.8.0 // indirect github.com/goccy/go-json v0.10.2 // indirect github.com/golang-jwt/jwt v3.2.1+incompatible // indirect github.com/golang/protobuf v1.5.3 // indirect - github.com/golang/snappy v0.0.1 // indirect + github.com/golang/snappy v0.0.4 // indirect github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/compress v1.13.6 // indirect + github.com/klauspost/compress v1.15.9 // indirect github.com/klauspost/cpuid/v2 v2.2.4 // indirect github.com/leodido/go-urn v1.2.4 // indirect github.com/mattn/go-isatty v0.0.19 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/montanaflynn/stats v0.6.6 // indirect github.com/omec-project/logger_conf v1.1.0 // indirect github.com/pelletier/go-toml/v2 v2.0.8 // indirect github.com/pkg/errors v0.9.1 // indirect @@ -52,14 +52,14 @@ require ( github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.11 // indirect github.com/xdg-go/pbkdf2 v1.0.0 // indirect - github.com/xdg-go/scram v1.0.2 // indirect - github.com/xdg-go/stringprep v1.0.2 // indirect - github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect + github.com/xdg-go/scram v1.1.1 // indirect + github.com/xdg-go/stringprep v1.0.3 // indirect + github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect golang.org/x/arch v0.3.0 // indirect golang.org/x/crypto v0.17.0 // indirect golang.org/x/net v0.17.0 // indirect golang.org/x/oauth2 v0.7.0 // indirect - golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 // indirect + golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/appengine v1.6.7 // indirect diff --git a/go.sum b/go.sum index a11886b..b0cd01f 100644 --- a/go.sum +++ b/go.sum @@ -39,8 +39,9 @@ github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kd github.com/antonfisher/nested-logrus-formatter v1.3.0/go.mod h1:6WTfyWFkBc9+zyBaKIqRrg/KwMqBbodBjgbHjDz7zjA= github.com/antonfisher/nested-logrus-formatter v1.3.1 h1:NFJIr+pzwv5QLHTPyKz9UMEoHck02Q9L0FP13b/xSbQ= github.com/antonfisher/nested-logrus-formatter v1.3.1/go.mod h1:6WTfyWFkBc9+zyBaKIqRrg/KwMqBbodBjgbHjDz7zjA= -github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef h1:46PFijGLmAjMPwCCCo7Jf0W6f9slllCkkv7vyc1yOSg= github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= +github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d h1:Byv0BzEl3/e6D5CLfI0j/7hiIEtvGVFPCZ7Ei2oq8iQ= +github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s= github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= @@ -66,7 +67,6 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch v5.8.1+incompatible h1:2toJaoe7/rNa1zpeQx0UnVEjqk6z2ecyA20V/zg8vTU= github.com/evanphx/json-patch v5.8.1+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= @@ -92,32 +92,6 @@ github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91 github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js= github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= -github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0= -github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3/go.mod h1:3STtPUQYuzV0gBVOY3vy6CfMm/ljR4pABfrTeHNLHUY= -github.com/gobuffalo/depgen v0.1.0/go.mod h1:+ifsuy7fhi15RWncXQQKjWS9JPkdah5sZvtHc2RXGlg= -github.com/gobuffalo/envy v1.6.15/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= -github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= -github.com/gobuffalo/flect v0.1.0/go.mod h1:d2ehjJqGOH/Kjqcoz+F7jHTBbmDb38yXA598Hb50EGs= -github.com/gobuffalo/flect v0.1.1/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= -github.com/gobuffalo/flect v0.1.3/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= -github.com/gobuffalo/genny v0.0.0-20190329151137-27723ad26ef9/go.mod h1:rWs4Z12d1Zbf19rlsn0nurr75KqhYp52EAGGxTbBhNk= -github.com/gobuffalo/genny v0.0.0-20190403191548-3ca520ef0d9e/go.mod h1:80lIj3kVJWwOrXWWMRzzdhW3DsrdjILVil/SFKBzF28= -github.com/gobuffalo/genny v0.1.0/go.mod h1:XidbUqzak3lHdS//TPu2OgiFB+51Ur5f7CSnXZ/JDvo= -github.com/gobuffalo/genny v0.1.1/go.mod h1:5TExbEyY48pfunL4QSXxlDOmdsD44RRq4mVZ0Ex28Xk= -github.com/gobuffalo/gitgen v0.0.0-20190315122116-cc086187d211/go.mod h1:vEHJk/E9DmhejeLeNt7UVvlSGv3ziL+djtTr3yyzcOw= -github.com/gobuffalo/gogen v0.0.0-20190315121717-8f38393713f5/go.mod h1:V9QVDIxsgKNZs6L2IYiGR8datgMhB577vzTDqypH360= -github.com/gobuffalo/gogen v0.1.0/go.mod h1:8NTelM5qd8RZ15VjQTFkAW6qOMx5wBbW4dSCS3BY8gg= -github.com/gobuffalo/gogen v0.1.1/go.mod h1:y8iBtmHmGc4qa3urIyo1shvOD8JftTtfcKi+71xfDNE= -github.com/gobuffalo/logger v0.0.0-20190315122211-86e12af44bc2/go.mod h1:QdxcLw541hSGtBnhUc4gaNIXRjiDppFGaDqzbrBd3v8= -github.com/gobuffalo/mapi v1.0.1/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc= -github.com/gobuffalo/mapi v1.0.2/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc= -github.com/gobuffalo/packd v0.0.0-20190315124812-a385830c7fc0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4= -github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4= -github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ= -github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0= -github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= @@ -150,8 +124,9 @@ github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= +github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -187,24 +162,19 @@ github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplb github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4= -github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= +github.com/klauspost/compress v1.15.9 h1:wKRjX6JRtDdrE9qwa4b/Cip7ACOshUI4smpCQanqjSY= +github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk= github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -213,8 +183,6 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= -github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE= -github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= @@ -229,10 +197,10 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= +github.com/montanaflynn/stats v0.6.6 h1:Duep6KMIDpY4Yo11iFsvyqJDyfzLF9+sndUKT+v64GQ= +github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 h1:W6apQkHrMkS0Muv8G/TipAy/FJl/rCYT0+EuS8+Z0z4= github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms= -github.com/omec-project/MongoDBLibrary v1.1.3 h1:3/2Luxl4YBe9cP2cRNtPruroBGonmiQbnCviYby1fo4= -github.com/omec-project/MongoDBLibrary v1.1.3/go.mod h1:bchS8sexPvTzgcA+fGzGeMyQk2Ji2xyAYgXDg6wOg1I= github.com/omec-project/config5g v1.2.0 h1:fyIg+1LZ9jn8DTkVUbD4jyxA4FgMICdIBwZVnzCyMd4= github.com/omec-project/config5g v1.2.0/go.mod h1:AWFzCbbgCBx/iJwt+zWbpDGLHRpFzg24OYHqIkdcMVA= github.com/omec-project/http2_util v1.1.0 h1:8H2NME/V8iONth8TlyK/3w4pguAzaeUnEv9pmeAocwQ= @@ -247,33 +215,24 @@ github.com/omec-project/openapi v1.1.0 h1:N3v59+FM2V/eCv2Au10kbyeTf1DsScJkEdkDEc github.com/omec-project/openapi v1.1.0/go.mod h1:Fv9ajWROYypcNER+ZwWXPhLCdV4pBz75KqFp/R/2gCw= github.com/omec-project/path_util v1.1.0 h1:vzzLsay8+uexyYEqS06th8lMcwp+N+CXcaHhaypZn1Q= github.com/omec-project/path_util v1.1.0/go.mod h1:O1ch35al6+FXKmg6+5vOpKusl4fiB0u36oYjxwI4QK4= -github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= +github.com/omec-project/util v1.0.12 h1:fmeeUxexHdi4nipAJumaq4lcx9l83FPaNfGH2fRmTTw= +github.com/omec-project/util v1.0.12/go.mod h1:Cn9P57qYFiEu0ZXti8imODsJIXVGqnqhP40MwbVbo3g= github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= -github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -303,17 +262,18 @@ github.com/urfave/cli v1.22.14 h1:ebbhrRiGK2i4naQJr+1Xj92HXZCrK7MsyTS/ob3HnAk= github.com/urfave/cli v1.22.14/go.mod h1:X0eDS6pD6Exaclxm99NJ3FiCDRED7vIHpx2mDOHLvkA= github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= -github.com/xdg-go/scram v1.0.2 h1:akYIkZ28e6A96dkWNJQu3nmCzH3YfwMPQExUYDaRv7w= -github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= -github.com/xdg-go/stringprep v1.0.2 h1:6iq84/ryjjeRmMJwxutI51F2GIPlP5BfTvXHeYjyhBc= -github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM= -github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA= +github.com/xdg-go/scram v1.1.1 h1:VOMT+81stJgXW3CpHyqHN3AXDYIMsx56mEFrB37Mb/E= +github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g= +github.com/xdg-go/stringprep v1.0.3 h1:kdwGpVNwPFtjs98xCGkHjQtGKh86rDcRZN17QEMCOIs= +github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= +github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a h1:fZHgsYlfvtyqToslyjUt3VOPF4J7aK/3MPcK7xp3PDk= +github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a/go.mod h1:ul22v+Nro/R083muKhosV54bj5niojjWZvU8xrevuH4= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.mongodb.org/mongo-driver v1.7.3 h1:G4l/eYY9VrQAK/AUgkV0koQKzQnyddnWxrd/Etf0jIs= -go.mongodb.org/mongo-driver v1.7.3/go.mod h1:NqaYOwnXWr5Pm7AOpO5QFxKJ503nbMse/R79oO62zWg= +go.mongodb.org/mongo-driver v1.10.1 h1:NujsPveKwHaWuKUer/ceo9DzEe7HIj1SlJ6uvXZG0S4= +go.mongodb.org/mongo-driver v1.10.1/go.mod h1:z4XpeoU6w+9Vht+jAFyLgVrD+jGSQQe0+CBWFHNiHt8= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= @@ -323,15 +283,14 @@ go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqe golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= +golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -392,6 +351,7 @@ golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -406,23 +366,19 @@ golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde h1:ejfdSekXMDxDLbRrJMwUk6KnSLZ2McaUCVcIKM+N6jc= +golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -447,6 +403,7 @@ golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201211090839-8ad439b19e0f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -460,8 +417,8 @@ golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3 golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -473,13 +430,9 @@ golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3 golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= diff --git a/producer/data_repository.go b/producer/data_repository.go index 2d53564..2e5976d 100644 --- a/producer/data_repository.go +++ b/producer/data_repository.go @@ -19,13 +19,13 @@ import ( "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" - "github.com/omec-project/MongoDBLibrary" protos "github.com/omec-project/config5g/proto/sdcoreConfig" "github.com/omec-project/http_wrapper" "github.com/omec-project/openapi/models" udr_context "github.com/omec-project/udr/context" "github.com/omec-project/udr/logger" "github.com/omec-project/udr/util" + "github.com/omec-project/util/mongoapi" ) const ( @@ -36,8 +36,12 @@ const ( var CurrentResourceUri string -func getDataFromDB(collName string, filter bson.M) (map[string]interface{}, *models.ProblemDetails) { - data := MongoDBLibrary.RestfulAPIGetOne(collName, filter) +func getDataFromDB(collName string, filter bson.M, m mongoapi.MongoClient) (map[string]interface{}, *models.ProblemDetails) { + data, err := m.RestfulAPIGetOne(collName, filter) + if err != nil { + logger.DataRepoLog.Errorln(err) + } + if data == nil { return nil, util.ProblemDetailsNotFound("DATA_NOT_FOUND") } @@ -47,8 +51,11 @@ func getDataFromDB(collName string, filter bson.M) (map[string]interface{}, *mod return data, nil } -func deleteDataFromDB(collName string, filter bson.M) { - MongoDBLibrary.RestfulAPIDeleteOne(collName, filter) +func deleteDataFromDB(collName string, filter bson.M, m mongoapi.MongoClient) { + err := m.RestfulAPIDeleteOne(collName, filter) + if err != nil { + logger.DataRepoLog.Errorln(err) + } } func HandleCreateAccessAndMobilityData(request *http_wrapper.Request) *http_wrapper.Response { @@ -69,7 +76,7 @@ func toBsonM(data interface{}) (ret bson.M) { } // AddEntrySmPolicyTable ... write table entries into policyData.ues.smData -func AddEntrySmPolicyTable(imsi string, dnn string, snssai *protos.NSSAI) error { +func AddEntrySmPolicyTable(imsi string, dnn string, snssai *protos.NSSAI, m mongoapi.MongoClient) error { logger.CfgLog.Infoln("AddEntrySmPolicyTable") collName := "policyData.ues.smData" var addUeId bool @@ -87,11 +94,14 @@ func AddEntrySmPolicyTable(imsi string, dnn string, snssai *protos.NSSAI) error Sd: snssai.Sd, Sst: int32(sval), } - smPolicyData := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + smPolicyData, err := m.RestfulAPIGetOne(collName, filter) + if err != nil { + logger.DataRepoLog.Errorln(err) + } var smPolicyDataWrite models.SmPolicyData if smPolicyData != nil { - err := json.Unmarshal(util.MapToByte(smPolicyData), &smPolicyDataWrite) - if err != nil { + errUnmarshal := json.Unmarshal(util.MapToByte(smPolicyData), &smPolicyDataWrite) + if errUnmarshal != nil { logger.DataRepoLog.Warnln(err) return err } @@ -118,7 +128,10 @@ func AddEntrySmPolicyTable(imsi string, dnn string, snssai *protos.NSSAI) error if addUeId { smPolicyDataBsonM["ueId"] = ueID } - MongoDBLibrary.RestfulAPIPost(collName, filter, smPolicyDataBsonM) + _, err = m.RestfulAPIPost(collName, filter, smPolicyDataBsonM) + if err != nil { + logger.DataRepoLog.Errorln(err) + } return nil } @@ -130,13 +143,13 @@ func HandleQueryAccessAndMobilityData(request *http_wrapper.Request) *http_wrapp return http_wrapper.NewResponse(http.StatusOK, nil, map[string]interface{}{}) } -func HandleQueryAmData(request *http_wrapper.Request) *http_wrapper.Response { +func HandleQueryAmData(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle QueryAmData") collName := "subscriptionData.provisionedData.amData" ueId := request.Params["ueId"] servingPlmnId := request.Params["servingPlmnId"] - response, problemDetails := QueryAmDataProcedure(collName, ueId, servingPlmnId) + response, problemDetails := QueryAmDataProcedure(collName, ueId, servingPlmnId, m) if problemDetails == nil { return http_wrapper.NewResponse(http.StatusOK, nil, response) @@ -145,10 +158,13 @@ func HandleQueryAmData(request *http_wrapper.Request) *http_wrapper.Response { } } -func QueryAmDataProcedure(collName string, ueId string, servingPlmnId string) (*map[string]interface{}, +func QueryAmDataProcedure(collName string, ueId string, servingPlmnId string, m mongoapi.MongoClient) (*map[string]interface{}, *models.ProblemDetails) { filter := bson.M{"ueId": ueId, "servingPlmnId": servingPlmnId} - accessAndMobilitySubscriptionData := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + accessAndMobilitySubscriptionData, err := m.RestfulAPIGetOne(collName, filter) + if err != nil { + logger.DataRepoLog.Errorln(err) + } if accessAndMobilitySubscriptionData != nil { return &accessAndMobilitySubscriptionData, nil } else { @@ -156,13 +172,13 @@ func QueryAmDataProcedure(collName string, ueId string, servingPlmnId string) (* } } -func HandleAmfContext3gpp(request *http_wrapper.Request) *http_wrapper.Response { +func HandleAmfContext3gpp(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle AmfContext3gpp") collName := "subscriptionData.contextData.amf3gppAccess" patchItem := request.Body.([]models.PatchItem) ueId := request.Params["ueId"] - problemDetails := AmfContext3gppProcedure(collName, ueId, patchItem) + problemDetails := AmfContext3gppProcedure(collName, ueId, patchItem, m) if problemDetails == nil { return http_wrapper.NewResponse(http.StatusNoContent, nil, map[string]interface{}{}) } else { @@ -170,18 +186,23 @@ func HandleAmfContext3gpp(request *http_wrapper.Request) *http_wrapper.Response } } -func AmfContext3gppProcedure(collName string, ueId string, patchItem []models.PatchItem) *models.ProblemDetails { +func AmfContext3gppProcedure(collName string, ueId string, patchItem []models.PatchItem, m mongoapi.MongoClient) *models.ProblemDetails { filter := bson.M{"ueId": ueId} - origValue := MongoDBLibrary.RestfulAPIGetOne(collName, filter) - + origValue, err := m.RestfulAPIGetOne(collName, filter) + if err != nil { + logger.DataRepoLog.Errorln(err) + } patchJSON, err := json.Marshal(patchItem) if err != nil { - logger.DataRepoLog.Error(err) + logger.DataRepoLog.Errorln(err) } - success := MongoDBLibrary.RestfulAPIJSONPatch(collName, filter, patchJSON) + failure := m.RestfulAPIJSONPatch(collName, filter, patchJSON) - if success { - newValue := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + if failure == nil { + newValue, err := m.RestfulAPIGetOne(collName, filter) + if err != nil { + logger.DataRepoLog.Errorln(err) + } PreHandleOnDataChangeNotify(ueId, CurrentResourceUri, patchItem, origValue, newValue) return nil } else { @@ -189,34 +210,37 @@ func AmfContext3gppProcedure(collName string, ueId string, patchItem []models.Pa } } -func HandleCreateAmfContext3gpp(request *http_wrapper.Request) *http_wrapper.Response { +func HandleCreateAmfContext3gpp(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle CreateAmfContext3gpp") Amf3GppAccessRegistration := request.Body.(models.Amf3GppAccessRegistration) ueId := request.Params["ueId"] collName := "subscriptionData.contextData.amf3gppAccess" - CreateAmfContext3gppProcedure(collName, ueId, Amf3GppAccessRegistration) + CreateAmfContext3gppProcedure(collName, ueId, Amf3GppAccessRegistration, m) return http_wrapper.NewResponse(http.StatusNoContent, nil, map[string]interface{}{}) } func CreateAmfContext3gppProcedure(collName string, ueId string, - Amf3GppAccessRegistration models.Amf3GppAccessRegistration) { + Amf3GppAccessRegistration models.Amf3GppAccessRegistration, m mongoapi.MongoClient) { filter := bson.M{"ueId": ueId} putData := util.ToBsonM(Amf3GppAccessRegistration) putData["ueId"] = ueId - MongoDBLibrary.RestfulAPIPutOne(collName, filter, putData) + _, err := m.RestfulAPIPutOne(collName, filter, putData) + if err != nil { + logger.DataRepoLog.Errorln(err) + } } -func HandleQueryAmfContext3gpp(request *http_wrapper.Request) *http_wrapper.Response { +func HandleQueryAmfContext3gpp(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle QueryAmfContext3gpp") ueId := request.Params["ueId"] collName := "subscriptionData.contextData.amf3gppAccess" - response, problemDetails := QueryAmfContext3gppProcedure(collName, ueId) + response, problemDetails := QueryAmfContext3gppProcedure(collName, ueId, m) if response != nil { return http_wrapper.NewResponse(http.StatusOK, nil, response) @@ -228,9 +252,12 @@ func HandleQueryAmfContext3gpp(request *http_wrapper.Request) *http_wrapper.Resp return http_wrapper.NewResponse(int(pd.Status), nil, pd) } -func QueryAmfContext3gppProcedure(collName string, ueId string) (*map[string]interface{}, *models.ProblemDetails) { +func QueryAmfContext3gppProcedure(collName string, ueId string, m mongoapi.MongoClient) (*map[string]interface{}, *models.ProblemDetails) { filter := bson.M{"ueId": ueId} - amf3GppAccessRegistration := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + amf3GppAccessRegistration, err := m.RestfulAPIGetOne(collName, filter) + if err != nil { + logger.DataRepoLog.Errorln(err) + } if amf3GppAccessRegistration != nil { return &amf3GppAccessRegistration, nil @@ -239,7 +266,7 @@ func QueryAmfContext3gppProcedure(collName string, ueId string) (*map[string]int } } -func HandleAmfContextNon3gpp(request *http_wrapper.Request) *http_wrapper.Response { +func HandleAmfContextNon3gpp(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle AmfContextNon3gpp") ueId := request.Params["ueId"] @@ -247,7 +274,7 @@ func HandleAmfContextNon3gpp(request *http_wrapper.Request) *http_wrapper.Respon patchItem := request.Body.([]models.PatchItem) filter := bson.M{"ueId": ueId} - problemDetails := AmfContextNon3gppProcedure(ueId, collName, patchItem, filter) + problemDetails := AmfContextNon3gppProcedure(ueId, collName, patchItem, filter, m) if problemDetails == nil { return http_wrapper.NewResponse(http.StatusNoContent, nil, map[string]interface{}{}) @@ -257,16 +284,21 @@ func HandleAmfContextNon3gpp(request *http_wrapper.Request) *http_wrapper.Respon } func AmfContextNon3gppProcedure(ueId string, collName string, patchItem []models.PatchItem, - filter bson.M) *models.ProblemDetails { - origValue := MongoDBLibrary.RestfulAPIGetOne(collName, filter) - + filter bson.M, m mongoapi.MongoClient) *models.ProblemDetails { + origValue, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } patchJSON, err := json.Marshal(patchItem) if err != nil { - logger.DataRepoLog.Error(err) + logger.DataRepoLog.Errorln(err) } - success := MongoDBLibrary.RestfulAPIJSONPatch(collName, filter, patchJSON) - if success { - newValue := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + failure := m.RestfulAPIJSONPatch(collName, filter, patchJSON) + if failure == nil { + newValue, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } PreHandleOnDataChangeNotify(ueId, CurrentResourceUri, patchItem, origValue, newValue) return nil } else { @@ -274,34 +306,37 @@ func AmfContextNon3gppProcedure(ueId string, collName string, patchItem []models } } -func HandleCreateAmfContextNon3gpp(request *http_wrapper.Request) *http_wrapper.Response { +func HandleCreateAmfContextNon3gpp(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle CreateAmfContextNon3gpp") AmfNon3GppAccessRegistration := request.Body.(models.AmfNon3GppAccessRegistration) collName := "subscriptionData.contextData.amfNon3gppAccess" ueId := request.Params["ueId"] - CreateAmfContextNon3gppProcedure(AmfNon3GppAccessRegistration, collName, ueId) + CreateAmfContextNon3gppProcedure(AmfNon3GppAccessRegistration, collName, ueId, m) return http_wrapper.NewResponse(http.StatusNoContent, nil, map[string]interface{}{}) } func CreateAmfContextNon3gppProcedure(AmfNon3GppAccessRegistration models.AmfNon3GppAccessRegistration, - collName string, ueId string) { + collName string, ueId string, m mongoapi.MongoClient) { putData := util.ToBsonM(AmfNon3GppAccessRegistration) putData["ueId"] = ueId filter := bson.M{"ueId": ueId} - MongoDBLibrary.RestfulAPIPutOne(collName, filter, putData) + _, err := m.RestfulAPIPutOne(collName, filter, putData) + if err != nil { + logger.DataRepoLog.Errorln(err) + } } -func HandleQueryAmfContextNon3gpp(request *http_wrapper.Request) *http_wrapper.Response { +func HandleQueryAmfContextNon3gpp(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle QueryAmfContextNon3gpp") collName := "subscriptionData.contextData.amfNon3gppAccess" ueId := request.Params["ueId"] - response, problemDetails := QueryAmfContextNon3gppProcedure(collName, ueId) + response, problemDetails := QueryAmfContextNon3gppProcedure(collName, ueId, m) if response != nil { return http_wrapper.NewResponse(http.StatusOK, nil, response) @@ -313,9 +348,12 @@ func HandleQueryAmfContextNon3gpp(request *http_wrapper.Request) *http_wrapper.R return http_wrapper.NewResponse(int(pd.Status), nil, pd) } -func QueryAmfContextNon3gppProcedure(collName string, ueId string) (*map[string]interface{}, *models.ProblemDetails) { +func QueryAmfContextNon3gppProcedure(collName string, ueId string, m mongoapi.MongoClient) (*map[string]interface{}, *models.ProblemDetails) { filter := bson.M{"ueId": ueId} - response := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + response, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } if response != nil { return &response, nil @@ -324,14 +362,14 @@ func QueryAmfContextNon3gppProcedure(collName string, ueId string) (*map[string] } } -func HandleModifyAuthentication(request *http_wrapper.Request) *http_wrapper.Response { +func HandleModifyAuthentication(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle ModifyAuthentication") collName := "subscriptionData.authenticationData.authenticationSubscription" ueId := request.Params["ueId"] patchItem := request.Body.([]models.PatchItem) - problemDetails := ModifyAuthenticationProcedure(collName, ueId, patchItem) + problemDetails := ModifyAuthenticationProcedure(collName, ueId, patchItem, m) if problemDetails == nil { return http_wrapper.NewResponse(http.StatusNoContent, nil, map[string]interface{}{}) @@ -340,18 +378,23 @@ func HandleModifyAuthentication(request *http_wrapper.Request) *http_wrapper.Res } } -func ModifyAuthenticationProcedure(collName string, ueId string, patchItem []models.PatchItem) *models.ProblemDetails { +func ModifyAuthenticationProcedure(collName string, ueId string, patchItem []models.PatchItem, m mongoapi.MongoClient) *models.ProblemDetails { filter := bson.M{"ueId": ueId} - origValue := MongoDBLibrary.RestfulAPIGetOne(collName, filter) - + origValue, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } patchJSON, err := json.Marshal(patchItem) if err != nil { - logger.DataRepoLog.Error(err) + logger.DataRepoLog.Errorln(err) } - success := MongoDBLibrary.RestfulAPIJSONPatch(collName, filter, patchJSON) + failure := m.RestfulAPIJSONPatch(collName, filter, patchJSON) - if success { - newValue := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + if failure == nil { + newValue, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } PreHandleOnDataChangeNotify(ueId, CurrentResourceUri, patchItem, origValue, newValue) return nil } else { @@ -359,13 +402,13 @@ func ModifyAuthenticationProcedure(collName string, ueId string, patchItem []mod } } -func HandleQueryAuthSubsData(request *http_wrapper.Request) *http_wrapper.Response { +func HandleQueryAuthSubsData(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle QueryAuthSubsData") collName := "subscriptionData.authenticationData.authenticationSubscription" ueId := request.Params["ueId"] - response, problemDetails := QueryAuthSubsDataProcedure(collName, ueId) + response, problemDetails := QueryAuthSubsDataProcedure(collName, ueId, m) if response != nil { return http_wrapper.NewResponse(http.StatusOK, nil, response) @@ -377,11 +420,13 @@ func HandleQueryAuthSubsData(request *http_wrapper.Request) *http_wrapper.Respon return http_wrapper.NewResponse(int(pd.Status), nil, pd) } -func QueryAuthSubsDataProcedure(collName string, ueId string) (map[string]interface{}, *models.ProblemDetails) { +func QueryAuthSubsDataProcedure(collName string, ueId string, m mongoapi.MongoClient) (map[string]interface{}, *models.ProblemDetails) { filter := bson.M{"ueId": ueId} - authenticationSubscription := MongoDBLibrary.RestfulAPIGetOne(collName, filter) - + authenticationSubscription, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } if authenticationSubscription != nil { return authenticationSubscription, nil } else { @@ -389,31 +434,34 @@ func QueryAuthSubsDataProcedure(collName string, ueId string) (map[string]interf } } -func HandleCreateAuthenticationSoR(request *http_wrapper.Request) *http_wrapper.Response { +func HandleCreateAuthenticationSoR(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle CreateAuthenticationSoR") putData := util.ToBsonM(request.Body) ueId := request.Params["ueId"] collName := "subscriptionData.ueUpdateConfirmationData.sorData" - CreateAuthenticationSoRProcedure(collName, ueId, putData) + CreateAuthenticationSoRProcedure(collName, ueId, putData, m) return http_wrapper.NewResponse(http.StatusNoContent, nil, map[string]interface{}{}) } -func CreateAuthenticationSoRProcedure(collName string, ueId string, putData bson.M) { +func CreateAuthenticationSoRProcedure(collName string, ueId string, putData bson.M, m mongoapi.MongoClient) { filter := bson.M{"ueId": ueId} putData["ueId"] = ueId - MongoDBLibrary.RestfulAPIPutOne(collName, filter, putData) + _, err := m.RestfulAPIPutOne(collName, filter, putData) + if err != nil { + logger.DataRepoLog.Errorln(err) + } } -func HandleQueryAuthSoR(request *http_wrapper.Request) *http_wrapper.Response { +func HandleQueryAuthSoR(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle QueryAuthSoR") ueId := request.Params["ueId"] collName := "subscriptionData.ueUpdateConfirmationData.sorData" - response, problemDetails := QueryAuthSoRProcedure(collName, ueId) + response, problemDetails := QueryAuthSoRProcedure(collName, ueId, m) if response != nil { return http_wrapper.NewResponse(http.StatusOK, nil, response) @@ -425,11 +473,13 @@ func HandleQueryAuthSoR(request *http_wrapper.Request) *http_wrapper.Response { return http_wrapper.NewResponse(int(pd.Status), nil, pd) } -func QueryAuthSoRProcedure(collName string, ueId string) (map[string]interface{}, *models.ProblemDetails) { +func QueryAuthSoRProcedure(collName string, ueId string, m mongoapi.MongoClient) (map[string]interface{}, *models.ProblemDetails) { filter := bson.M{"ueId": ueId} - sorData := MongoDBLibrary.RestfulAPIGetOne(collName, filter) - + sorData, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } if sorData != nil { return sorData, nil } else { @@ -437,32 +487,35 @@ func QueryAuthSoRProcedure(collName string, ueId string) (map[string]interface{} } } -func HandleCreateAuthenticationStatus(request *http_wrapper.Request) *http_wrapper.Response { +func HandleCreateAuthenticationStatus(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle CreateAuthenticationStatus") putData := util.ToBsonM(request.Body) ueId := request.Params["ueId"] collName := "subscriptionData.authenticationData.authenticationStatus" - CreateAuthenticationStatusProcedure(collName, ueId, putData) + CreateAuthenticationStatusProcedure(collName, ueId, putData, m) return http_wrapper.NewResponse(http.StatusNoContent, nil, map[string]interface{}{}) } -func CreateAuthenticationStatusProcedure(collName string, ueId string, putData bson.M) { +func CreateAuthenticationStatusProcedure(collName string, ueId string, putData bson.M, m mongoapi.MongoClient) { filter := bson.M{"ueId": ueId} putData["ueId"] = ueId - MongoDBLibrary.RestfulAPIPutOne(collName, filter, putData) + _, err := m.RestfulAPIPutOne(collName, filter, putData) + if err != nil { + logger.DataRepoLog.Errorln(err) + } } -func HandleQueryAuthenticationStatus(request *http_wrapper.Request) *http_wrapper.Response { +func HandleQueryAuthenticationStatus(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle QueryAuthenticationStatus") ueId := request.Params["ueId"] collName := "subscriptionData.authenticationData.authenticationStatus" - response, problemDetails := QueryAuthenticationStatusProcedure(collName, ueId) + response, problemDetails := QueryAuthenticationStatusProcedure(collName, ueId, m) if response != nil { return http_wrapper.NewResponse(http.StatusOK, nil, response) @@ -474,12 +527,14 @@ func HandleQueryAuthenticationStatus(request *http_wrapper.Request) *http_wrappe return http_wrapper.NewResponse(int(pd.Status), nil, pd) } -func QueryAuthenticationStatusProcedure(collName string, ueId string) (*map[string]interface{}, +func QueryAuthenticationStatusProcedure(collName string, ueId string, m mongoapi.MongoClient) (*map[string]interface{}, *models.ProblemDetails) { filter := bson.M{"ueId": ueId} - authEvent := MongoDBLibrary.RestfulAPIGetOne(collName, filter) - + authEvent, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } if authEvent != nil { return &authEvent, nil } else { @@ -487,7 +542,7 @@ func QueryAuthenticationStatusProcedure(collName string, ueId string) (*map[stri } } -func HandleApplicationDataInfluenceDataGet(queryParams map[string][]string) *http_wrapper.Response { +func HandleApplicationDataInfluenceDataGet(queryParams map[string][]string, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle ApplicationDataInfluenceDataGet: queryParams=%#v", queryParams) influIDs := queryParams["influence-Ids"] @@ -500,15 +555,18 @@ func HandleApplicationDataInfluenceDataGet(queryParams map[string][]string) *htt return http_wrapper.NewResponse(int(pd.Status), nil, pd) } - response := getApplicationDataInfluenceDatafromDB(influIDs, dnns, snssais, intGroupIDs, supis) + response := getApplicationDataInfluenceDatafromDB(influIDs, dnns, snssais, intGroupIDs, supis, m) return http_wrapper.NewResponse(http.StatusOK, nil, response) } func getApplicationDataInfluenceDatafromDB(influIDs, dnns, snssais, - intGroupIDs, supis []string) []map[string]interface{} { + intGroupIDs, supis []string, m mongoapi.MongoClient) []map[string]interface{} { filter := bson.M{} - allInfluDatas := MongoDBLibrary.RestfulAPIGetMany(APPDATA_INFLUDATA_DB_COLLECTION_NAME, filter) + allInfluDatas, err := m.RestfulAPIGetMany(APPDATA_INFLUDATA_DB_COLLECTION_NAME, filter) + if err != nil { + logger.DataRepoLog.Errorln(err) + } var matchedInfluDatas []map[string]interface{} matchedInfluDatas = filterDataByString("influenceId", influIDs, allInfluDatas) matchedInfluDatas = filterDataByString("dnn", dnns, matchedInfluDatas) @@ -571,33 +629,36 @@ func filterDataBySnssai(snssaiValues []string, return matchedDatas } -func HandleApplicationDataInfluenceDataInfluenceIdDelete(influId string) *http_wrapper.Response { +func HandleApplicationDataInfluenceDataInfluenceIdDelete(influId string, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle ApplicationDataInfluenceDataInfluenceIdDelete: influId=%q", influId) - deleteApplicationDataIndividualInfluenceDataFromDB(influId) + deleteApplicationDataIndividualInfluenceDataFromDB(influId, m) return http_wrapper.NewResponse(http.StatusNoContent, nil, map[string]interface{}{}) } -func deleteApplicationDataIndividualInfluenceDataFromDB(influId string) { +func deleteApplicationDataIndividualInfluenceDataFromDB(influId string, m mongoapi.MongoClient) { filter := bson.M{"influenceId": influId} - deleteDataFromDB(APPDATA_INFLUDATA_DB_COLLECTION_NAME, filter) + deleteDataFromDB(APPDATA_INFLUDATA_DB_COLLECTION_NAME, filter, m) } func HandleApplicationDataInfluenceDataInfluenceIdPatch(influID string, - trInfluDataPatch *models.TrafficInfluDataPatch) *http_wrapper.Response { + trInfluDataPatch *models.TrafficInfluDataPatch, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle ApplicationDataInfluenceDataInfluenceIdPatch: influID=%q", influID) - response, status := patchApplicationDataIndividualInfluenceDataToDB(influID, trInfluDataPatch) + response, status := patchApplicationDataIndividualInfluenceDataToDB(influID, trInfluDataPatch, m) return http_wrapper.NewResponse(status, nil, response) } func patchApplicationDataIndividualInfluenceDataToDB(influID string, - trInfluDataPatch *models.TrafficInfluDataPatch) (bson.M, int) { + trInfluDataPatch *models.TrafficInfluDataPatch, m mongoapi.MongoClient) (bson.M, int) { filter := bson.M{"influenceId": influID} - oldData := MongoDBLibrary.RestfulAPIGetOne(APPDATA_INFLUDATA_DB_COLLECTION_NAME, filter) + oldData, errGetOne := m.RestfulAPIGetOne(APPDATA_INFLUDATA_DB_COLLECTION_NAME, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } if oldData == nil { return nil, http.StatusNotFound } @@ -622,7 +683,10 @@ func patchApplicationDataIndividualInfluenceDataToDB(influID string, // Add "influenceId" entry to DB newData["influenceId"] = influID - MongoDBLibrary.RestfulAPIPutOne(APPDATA_INFLUDATA_DB_COLLECTION_NAME, filter, newData) + _, err := m.RestfulAPIPutOne(APPDATA_INFLUDATA_DB_COLLECTION_NAME, filter, newData) + if err != nil { + logger.DataRepoLog.Errorln(err) + } // Roll back to origin data before return delete(newData, "influenceId") @@ -630,22 +694,25 @@ func patchApplicationDataIndividualInfluenceDataToDB(influID string, } func HandleApplicationDataInfluenceDataInfluenceIdPut(influID string, - trInfluData *models.TrafficInfluData) *http_wrapper.Response { + trInfluData *models.TrafficInfluData, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle ApplicationDataInfluenceDataInfluenceIdPut: influID=%q", influID) - response, status := putApplicationDataIndividualInfluenceDataToDB(influID, trInfluData) + response, status := putApplicationDataIndividualInfluenceDataToDB(influID, trInfluData, m) return http_wrapper.NewResponse(status, nil, response) } func putApplicationDataIndividualInfluenceDataToDB(influID string, - trInfluData *models.TrafficInfluData) (bson.M, int) { + trInfluData *models.TrafficInfluData, m mongoapi.MongoClient) (bson.M, int) { filter := bson.M{"influenceId": influID} data := util.ToBsonM(*trInfluData) // Add "influenceId" entry to DB data["influenceId"] = influID - isExisted := MongoDBLibrary.RestfulAPIPutOne(APPDATA_INFLUDATA_DB_COLLECTION_NAME, filter, data) + isExisted, err := m.RestfulAPIPutOne(APPDATA_INFLUDATA_DB_COLLECTION_NAME, filter, data) + if err != nil { + logger.DataRepoLog.Errorln(err) + } // Roll back to origin data before return delete(data, "influenceId") @@ -655,7 +722,7 @@ func putApplicationDataIndividualInfluenceDataToDB(influID string, return data, http.StatusCreated } -func HandleApplicationDataInfluenceDataSubsToNotifyGet(queryParams map[string][]string) *http_wrapper.Response { +func HandleApplicationDataInfluenceDataSubsToNotifyGet(queryParams map[string][]string, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle ApplicationDataInfluenceDataSubsToNotifyGet: queryParams=%#v", queryParams) dnn := queryParams["dnn"] @@ -683,13 +750,13 @@ func HandleApplicationDataInfluenceDataSubsToNotifyGet(queryParams map[string][] return http_wrapper.NewResponse(int(pd.Status), nil, pd) } - response := getApplicationDataInfluenceDataSubsToNotifyfromDB(dnn, snssai, intGroupID, supi) + response := getApplicationDataInfluenceDataSubsToNotifyfromDB(dnn, snssai, intGroupID, supi, m) return http_wrapper.NewResponse(http.StatusOK, nil, response) } func getApplicationDataInfluenceDataSubsToNotifyfromDB(dnn, snssai, intGroupID, - supi []string) []map[string]interface{} { + supi []string, m mongoapi.MongoClient) []map[string]interface{} { filter := bson.M{} if len(dnn) != 0 { filter["dnns"] = dnn[0] @@ -700,7 +767,10 @@ func getApplicationDataInfluenceDataSubsToNotifyfromDB(dnn, snssai, intGroupID, if len(supi) != 0 { filter["supis"] = supi[0] } - matchedSubs := MongoDBLibrary.RestfulAPIGetMany(APPDATA_INFLUDATA_SUBSC_DB_COLLECTION_NAME, filter) + matchedSubs, err := m.RestfulAPIGetMany(APPDATA_INFLUDATA_SUBSC_DB_COLLECTION_NAME, filter) + if err != nil { + logger.DataRepoLog.Errorln(err) + } if len(snssai) != 0 { matchedSubs = filterDataBySnssais(snssai[0], matchedSubs) } @@ -739,12 +809,12 @@ func filterDataBySnssais(snssaiValue string, return matchedDatas } -func HandleApplicationDataInfluenceDataSubsToNotifyPost(trInfluSub *models.TrafficInfluSub) *http_wrapper.Response { +func HandleApplicationDataInfluenceDataSubsToNotifyPost(trInfluSub *models.TrafficInfluSub, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle ApplicationDataInfluenceDataSubsToNotifyPost") udrSelf := udr_context.UDR_Self() newSubscID := strconv.FormatUint(udrSelf.NewAppDataInfluDataSubscriptionID(), 10) - response, status := postApplicationDataInfluenceDataSubsToNotifyToDB(newSubscID, trInfluSub) + response, status := postApplicationDataInfluenceDataSubsToNotifyToDB(newSubscID, trInfluSub, m) /* Contains the URI of the newly created resource, according to the structure: {apiRoot}/application-data/influenceData/subs-to-notify/{subscID} */ @@ -757,36 +827,39 @@ func HandleApplicationDataInfluenceDataSubsToNotifyPost(trInfluSub *models.Traff } func postApplicationDataInfluenceDataSubsToNotifyToDB(subscID string, - trInfluSub *models.TrafficInfluSub) (bson.M, int) { + trInfluSub *models.TrafficInfluSub, m mongoapi.MongoClient) (bson.M, int) { filter := bson.M{"subscriptionId": subscID} data := util.ToBsonM(*trInfluSub) // Add "subscriptionId" entry to DB data["subscriptionId"] = subscID - MongoDBLibrary.RestfulAPIPutOne(APPDATA_INFLUDATA_SUBSC_DB_COLLECTION_NAME, filter, data) + _, err := m.RestfulAPIPutOne(APPDATA_INFLUDATA_SUBSC_DB_COLLECTION_NAME, filter, data) + if err != nil { + logger.DataRepoLog.Errorln(err) + } // Revert back to origin data before return delete(data, "subscriptionId") return data, http.StatusCreated } -func HandleApplicationDataInfluenceDataSubsToNotifySubscriptionIdDelete(subscID string) *http_wrapper.Response { +func HandleApplicationDataInfluenceDataSubsToNotifySubscriptionIdDelete(subscID string, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof( "Handle ApplicationDataInfluenceDataSubsToNotifySubscriptionIdDelete: subscID=%q", subscID) - deleteApplicationDataIndividualInfluenceDataSubsToNotifyFromDB(subscID) + deleteApplicationDataIndividualInfluenceDataSubsToNotifyFromDB(subscID, m) return http_wrapper.NewResponse(http.StatusNoContent, nil, map[string]interface{}{}) } -func deleteApplicationDataIndividualInfluenceDataSubsToNotifyFromDB(subscID string) { +func deleteApplicationDataIndividualInfluenceDataSubsToNotifyFromDB(subscID string, m mongoapi.MongoClient) { filter := bson.M{"subscriptionId": subscID} - deleteDataFromDB(APPDATA_INFLUDATA_SUBSC_DB_COLLECTION_NAME, filter) + deleteDataFromDB(APPDATA_INFLUDATA_SUBSC_DB_COLLECTION_NAME, filter, m) } -func HandleApplicationDataInfluenceDataSubsToNotifySubscriptionIdGet(subscID string) *http_wrapper.Response { +func HandleApplicationDataInfluenceDataSubsToNotifySubscriptionIdGet(subscID string, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle ApplicationDataInfluenceDataSubsToNotifySubscriptionIdGet: subscID=%q", subscID) - response, problemDetails := getApplicationDataIndividualInfluenceDataSubsToNotifyFromDB(subscID) + response, problemDetails := getApplicationDataIndividualInfluenceDataSubsToNotifyFromDB(subscID, m) if problemDetails != nil { return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) @@ -795,9 +868,9 @@ func HandleApplicationDataInfluenceDataSubsToNotifySubscriptionIdGet(subscID str } func getApplicationDataIndividualInfluenceDataSubsToNotifyFromDB( - subscID string) (map[string]interface{}, *models.ProblemDetails) { + subscID string, m mongoapi.MongoClient) (map[string]interface{}, *models.ProblemDetails) { filter := bson.M{"subscriptionId": subscID} - data, problemDetails := getDataFromDB(APPDATA_INFLUDATA_SUBSC_DB_COLLECTION_NAME, filter) + data, problemDetails := getDataFromDB(APPDATA_INFLUDATA_SUBSC_DB_COLLECTION_NAME, filter, m) if data != nil { // Delete "subscriptionId" entry which is added by us delete(data, "subscriptionId") @@ -806,50 +879,56 @@ func getApplicationDataIndividualInfluenceDataSubsToNotifyFromDB( } func HandleApplicationDataInfluenceDataSubsToNotifySubscriptionIdPut( - subscID string, trInfluSub *models.TrafficInfluSub) *http_wrapper.Response { + subscID string, trInfluSub *models.TrafficInfluSub, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof( "Handle HandleApplicationDataInfluenceDataSubsToNotifySubscriptionIdPut: subscID=%q", subscID) - response, status := putApplicationDataIndividualInfluenceDataSubsToNotifyToDB(subscID, trInfluSub) + response, status := putApplicationDataIndividualInfluenceDataSubsToNotifyToDB(subscID, trInfluSub, m) return http_wrapper.NewResponse(status, nil, response) } func putApplicationDataIndividualInfluenceDataSubsToNotifyToDB(subscID string, - trInfluSub *models.TrafficInfluSub) (bson.M, int) { + trInfluSub *models.TrafficInfluSub, m mongoapi.MongoClient) (bson.M, int) { filter := bson.M{"subscriptionId": subscID} newData := util.ToBsonM(*trInfluSub) - oldData := MongoDBLibrary.RestfulAPIGetOne(APPDATA_INFLUDATA_SUBSC_DB_COLLECTION_NAME, filter) + oldData, errGetOne := m.RestfulAPIGetOne(APPDATA_INFLUDATA_SUBSC_DB_COLLECTION_NAME, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } if oldData == nil { return nil, http.StatusNotFound } // Add "subscriptionId" entry to DB newData["subscriptionId"] = subscID // Modify with new data - MongoDBLibrary.RestfulAPIPutOne(APPDATA_INFLUDATA_SUBSC_DB_COLLECTION_NAME, filter, newData) + _, err := m.RestfulAPIPutOne(APPDATA_INFLUDATA_SUBSC_DB_COLLECTION_NAME, filter, newData) + if err != nil { + logger.DataRepoLog.Errorln(err) + } // Roll back to origin data before return delete(newData, "subscriptionId") return newData, http.StatusOK } -func HandleApplicationDataPfdsAppIdDelete(appID string) *http_wrapper.Response { +func HandleApplicationDataPfdsAppIdDelete(appID string, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle ApplicationDataPfdsAppIdDelete: appID=%q", appID) - deleteApplicationDataIndividualPfdFromDB(appID) + deleteApplicationDataIndividualPfdFromDB(appID, m) return http_wrapper.NewResponse(http.StatusNoContent, nil, map[string]interface{}{}) } -func deleteApplicationDataIndividualPfdFromDB(appID string) { +func deleteApplicationDataIndividualPfdFromDB(appID string, m mongoapi.MongoClient) { filter := bson.M{"applicationId": appID} - deleteDataFromDB(APPDATA_PFD_DB_COLLECTION_NAME, filter) + deleteDataFromDB(APPDATA_PFD_DB_COLLECTION_NAME, filter, m) } -func HandleApplicationDataPfdsAppIdGet(appID string) *http_wrapper.Response { +func HandleApplicationDataPfdsAppIdGet(appID string, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle ApplicationDataPfdsAppIdGet: appID=%q", appID) - response, problemDetails := getApplicationDataIndividualPfdFromDB(appID) + response, problemDetails := getApplicationDataIndividualPfdFromDB(appID, m) if problemDetails != nil { return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) @@ -857,54 +936,62 @@ func HandleApplicationDataPfdsAppIdGet(appID string) *http_wrapper.Response { return http_wrapper.NewResponse(http.StatusOK, nil, response) } -func getApplicationDataIndividualPfdFromDB(appID string) (map[string]interface{}, *models.ProblemDetails) { +func getApplicationDataIndividualPfdFromDB(appID string, m mongoapi.MongoClient) (map[string]interface{}, *models.ProblemDetails) { filter := bson.M{"applicationId": appID} - return getDataFromDB(APPDATA_PFD_DB_COLLECTION_NAME, filter) + return getDataFromDB(APPDATA_PFD_DB_COLLECTION_NAME, filter, m) } -func HandleApplicationDataPfdsAppIdPut(appID string, pfdDataForApp *models.PfdDataForApp) *http_wrapper.Response { +func HandleApplicationDataPfdsAppIdPut(appID string, pfdDataForApp *models.PfdDataForApp, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle ApplicationDataPfdsAppIdPut: appID=%q", appID) - response, status := putApplicationDataIndividualPfdToDB(appID, pfdDataForApp) + response, status := putApplicationDataIndividualPfdToDB(appID, pfdDataForApp, m) return http_wrapper.NewResponse(status, nil, response) } -func putApplicationDataIndividualPfdToDB(appID string, pfdDataForApp *models.PfdDataForApp) (bson.M, int) { +func putApplicationDataIndividualPfdToDB(appID string, pfdDataForApp *models.PfdDataForApp, m mongoapi.MongoClient) (bson.M, int) { filter := bson.M{"applicationId": appID} data := util.ToBsonM(*pfdDataForApp) - isExisted := MongoDBLibrary.RestfulAPIPutOne(APPDATA_PFD_DB_COLLECTION_NAME, filter, data) - + isExisted, err := m.RestfulAPIPutOne(APPDATA_PFD_DB_COLLECTION_NAME, filter, data) + if err != nil { + logger.DataRepoLog.Errorln(err) + } if isExisted { return data, http.StatusOK } return data, http.StatusCreated } -func HandleApplicationDataPfdsGet(pfdsAppIDs []string) *http_wrapper.Response { +func HandleApplicationDataPfdsGet(pfdsAppIDs []string, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle ApplicationDataPfdsGet: pfdsAppIDs=%#v", pfdsAppIDs) // TODO: Parse appID with separator ',' // Ex: "app1,app2,..." - response := getApplicationDataPfdsFromDB(pfdsAppIDs) + response := getApplicationDataPfdsFromDB(pfdsAppIDs, m) return http_wrapper.NewResponse(http.StatusOK, nil, response) } -func getApplicationDataPfdsFromDB(pfdsAppIDs []string) (response []map[string]interface{}) { +func getApplicationDataPfdsFromDB(pfdsAppIDs []string, m mongoapi.MongoClient) (response []map[string]interface{}) { filter := bson.M{} - + var err error var matchedPfds []map[string]interface{} if len(pfdsAppIDs) == 0 { - matchedPfds = MongoDBLibrary.RestfulAPIGetMany(APPDATA_PFD_DB_COLLECTION_NAME, filter) + matchedPfds, err = m.RestfulAPIGetMany(APPDATA_PFD_DB_COLLECTION_NAME, filter) + if err != nil { + logger.DataRepoLog.Errorln(err) + } for i := 0; i < len(matchedPfds); i++ { delete(matchedPfds[i], "_id") } } else { for _, v := range pfdsAppIDs { filter := bson.M{"applicationId": v} - data := MongoDBLibrary.RestfulAPIGetOne(APPDATA_PFD_DB_COLLECTION_NAME, filter) + data, err := m.RestfulAPIGetOne(APPDATA_PFD_DB_COLLECTION_NAME, filter) + if err != nil { + logger.DataRepoLog.Errorln(err) + } if data != nil { // Delete "_id" entry which is auto-inserted by MongoDB delete(data, "_id") @@ -927,28 +1014,31 @@ func HandleExposureDataSubsToNotifySubIdPut(request *http_wrapper.Request) *http return http_wrapper.NewResponse(http.StatusOK, nil, map[string]interface{}{}) } -func HandlePolicyDataBdtDataBdtReferenceIdDelete(request *http_wrapper.Request) *http_wrapper.Response { +func HandlePolicyDataBdtDataBdtReferenceIdDelete(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle PolicyDataBdtDataBdtReferenceIdDelete") collName := "policyData.bdtData" bdtReferenceId := request.Params["bdtReferenceId"] - PolicyDataBdtDataBdtReferenceIdDeleteProcedure(collName, bdtReferenceId) + PolicyDataBdtDataBdtReferenceIdDeleteProcedure(collName, bdtReferenceId, m) return http_wrapper.NewResponse(http.StatusNoContent, nil, map[string]interface{}{}) } -func PolicyDataBdtDataBdtReferenceIdDeleteProcedure(collName string, bdtReferenceId string) { +func PolicyDataBdtDataBdtReferenceIdDeleteProcedure(collName string, bdtReferenceId string, m mongoapi.MongoClient) { filter := bson.M{"bdtReferenceId": bdtReferenceId} - MongoDBLibrary.RestfulAPIDeleteOne(collName, filter) + err := m.RestfulAPIDeleteOne(collName, filter) + if err != nil { + logger.DataRepoLog.Errorln(err) + } } -func HandlePolicyDataBdtDataBdtReferenceIdGet(request *http_wrapper.Request) *http_wrapper.Response { +func HandlePolicyDataBdtDataBdtReferenceIdGet(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle PolicyDataBdtDataBdtReferenceIdGet") collName := "policyData.bdtData" bdtReferenceId := request.Params["bdtReferenceId"] - response, problemDetails := PolicyDataBdtDataBdtReferenceIdGetProcedure(collName, bdtReferenceId) + response, problemDetails := PolicyDataBdtDataBdtReferenceIdGetProcedure(collName, bdtReferenceId, m) if response != nil { return http_wrapper.NewResponse(http.StatusOK, nil, response) } else if problemDetails != nil { @@ -959,11 +1049,14 @@ func HandlePolicyDataBdtDataBdtReferenceIdGet(request *http_wrapper.Request) *ht return http_wrapper.NewResponse(int(pd.Status), nil, pd) } -func PolicyDataBdtDataBdtReferenceIdGetProcedure(collName string, bdtReferenceId string) (*map[string]interface{}, +func PolicyDataBdtDataBdtReferenceIdGetProcedure(collName string, bdtReferenceId string, m mongoapi.MongoClient) (*map[string]interface{}, *models.ProblemDetails) { filter := bson.M{"bdtReferenceId": bdtReferenceId} - bdtData := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + bdtData, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } if bdtData != nil { return &bdtData, nil @@ -972,14 +1065,14 @@ func PolicyDataBdtDataBdtReferenceIdGetProcedure(collName string, bdtReferenceId } } -func HandlePolicyDataBdtDataBdtReferenceIdPut(request *http_wrapper.Request) *http_wrapper.Response { +func HandlePolicyDataBdtDataBdtReferenceIdPut(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle PolicyDataBdtDataBdtReferenceIdPut") collName := "policyData.bdtData" bdtReferenceId := request.Params["bdtReferenceId"] bdtData := request.Body.(models.BdtData) - response := PolicyDataBdtDataBdtReferenceIdPutProcedure(collName, bdtReferenceId, bdtData) + response := PolicyDataBdtDataBdtReferenceIdPutProcedure(collName, bdtReferenceId, bdtData, m) if response != nil { return http_wrapper.NewResponse(http.StatusOK, nil, response) } @@ -989,13 +1082,15 @@ func HandlePolicyDataBdtDataBdtReferenceIdPut(request *http_wrapper.Request) *ht } func PolicyDataBdtDataBdtReferenceIdPutProcedure(collName string, bdtReferenceId string, - bdtData models.BdtData) bson.M { + bdtData models.BdtData, m mongoapi.MongoClient) bson.M { putData := util.ToBsonM(bdtData) putData["bdtReferenceId"] = bdtReferenceId filter := bson.M{"bdtReferenceId": bdtReferenceId} - isExisted := MongoDBLibrary.RestfulAPIPutOne(collName, filter, putData) - + isExisted, errPutOne := m.RestfulAPIPutOne(collName, filter, putData) + if errPutOne != nil { + logger.DataRepoLog.Errorln(errPutOne) + } if isExisted { PreHandlePolicyDataChangeNotification("", bdtReferenceId, bdtData) return putData @@ -1004,28 +1099,31 @@ func PolicyDataBdtDataBdtReferenceIdPutProcedure(collName string, bdtReferenceId } } -func HandlePolicyDataBdtDataGet(request *http_wrapper.Request) *http_wrapper.Response { +func HandlePolicyDataBdtDataGet(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle PolicyDataBdtDataGet") collName := "policyData.bdtData" - response := PolicyDataBdtDataGetProcedure(collName) + response := PolicyDataBdtDataGetProcedure(collName, m) return http_wrapper.NewResponse(http.StatusOK, nil, response) } -func PolicyDataBdtDataGetProcedure(collName string) (response *[]map[string]interface{}) { +func PolicyDataBdtDataGetProcedure(collName string, m mongoapi.MongoClient) (response *[]map[string]interface{}) { filter := bson.M{} - bdtDataArray := MongoDBLibrary.RestfulAPIGetMany(collName, filter) + bdtDataArray, err := m.RestfulAPIGetMany(collName, filter) + if err != nil { + logger.DataRepoLog.Errorln(err) + } return &bdtDataArray } -func HandlePolicyDataPlmnsPlmnIdUePolicySetGet(request *http_wrapper.Request) *http_wrapper.Response { +func HandlePolicyDataPlmnsPlmnIdUePolicySetGet(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle PolicyDataPlmnsPlmnIdUePolicySetGet") collName := "policyData.plmns.uePolicySet" plmnId := request.Params["plmnId"] - response, problemDetails := PolicyDataPlmnsPlmnIdUePolicySetGetProcedure(collName, plmnId) + response, problemDetails := PolicyDataPlmnsPlmnIdUePolicySetGetProcedure(collName, plmnId, m) if response != nil { return http_wrapper.NewResponse(http.StatusOK, nil, response) @@ -1038,9 +1136,12 @@ func HandlePolicyDataPlmnsPlmnIdUePolicySetGet(request *http_wrapper.Request) *h } func PolicyDataPlmnsPlmnIdUePolicySetGetProcedure(collName string, - plmnId string) (*map[string]interface{}, *models.ProblemDetails) { + plmnId string, m mongoapi.MongoClient) (*map[string]interface{}, *models.ProblemDetails) { filter := bson.M{"plmnId": plmnId} - uePolicySet := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + uePolicySet, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } if uePolicySet != nil { return &uePolicySet, nil @@ -1049,13 +1150,13 @@ func PolicyDataPlmnsPlmnIdUePolicySetGetProcedure(collName string, } } -func HandlePolicyDataSponsorConnectivityDataSponsorIdGet(request *http_wrapper.Request) *http_wrapper.Response { +func HandlePolicyDataSponsorConnectivityDataSponsorIdGet(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle PolicyDataSponsorConnectivityDataSponsorIdGet") collName := "policyData.sponsorConnectivityData" sponsorId := request.Params["sponsorId"] - response, status := PolicyDataSponsorConnectivityDataSponsorIdGetProcedure(collName, sponsorId) + response, status := PolicyDataSponsorConnectivityDataSponsorIdGetProcedure(collName, sponsorId, m) if status == http.StatusOK { return http_wrapper.NewResponse(http.StatusOK, nil, response) @@ -1068,11 +1169,13 @@ func HandlePolicyDataSponsorConnectivityDataSponsorIdGet(request *http_wrapper.R } func PolicyDataSponsorConnectivityDataSponsorIdGetProcedure(collName string, - sponsorId string) (*map[string]interface{}, int) { + sponsorId string, m mongoapi.MongoClient) (*map[string]interface{}, int) { filter := bson.M{"sponsorId": sponsorId} - sponsorConnectivityData := MongoDBLibrary.RestfulAPIGetOne(collName, filter) - + sponsorConnectivityData, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } if sponsorConnectivityData != nil { return &sponsorConnectivityData, http.StatusOK } else { @@ -1160,13 +1263,13 @@ func PolicyDataSubsToNotifySubsIdPutProcedure(subsId string, return &policyDataSubscription, nil } -func HandlePolicyDataUesUeIdAmDataGet(request *http_wrapper.Request) *http_wrapper.Response { +func HandlePolicyDataUesUeIdAmDataGet(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle PolicyDataUesUeIdAmDataGet") collName := "policyData.ues.amData" ueId := request.Params["ueId"] - response, problemDetails := PolicyDataUesUeIdAmDataGetProcedure(collName, ueId) + response, problemDetails := PolicyDataUesUeIdAmDataGetProcedure(collName, ueId, m) if response != nil { return http_wrapper.NewResponse(http.StatusOK, nil, response) @@ -1179,10 +1282,13 @@ func HandlePolicyDataUesUeIdAmDataGet(request *http_wrapper.Request) *http_wrapp } func PolicyDataUesUeIdAmDataGetProcedure(collName string, - ueId string) (*map[string]interface{}, *models.ProblemDetails) { + ueId string, m mongoapi.MongoClient) (*map[string]interface{}, *models.ProblemDetails) { filter := bson.M{"ueId": ueId} - amPolicyData := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + amPolicyData, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } if amPolicyData != nil { return &amPolicyData, nil @@ -1191,13 +1297,13 @@ func PolicyDataUesUeIdAmDataGetProcedure(collName string, } } -func HandlePolicyDataUesUeIdOperatorSpecificDataGet(request *http_wrapper.Request) *http_wrapper.Response { +func HandlePolicyDataUesUeIdOperatorSpecificDataGet(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle PolicyDataUesUeIdOperatorSpecificDataGet") collName := "policyData.ues.operatorSpecificData" ueId := request.Params["ueId"] - response, problemDetails := PolicyDataUesUeIdOperatorSpecificDataGetProcedure(collName, ueId) + response, problemDetails := PolicyDataUesUeIdOperatorSpecificDataGetProcedure(collName, ueId, m) if response != nil { return http_wrapper.NewResponse(http.StatusOK, nil, response) @@ -1210,10 +1316,13 @@ func HandlePolicyDataUesUeIdOperatorSpecificDataGet(request *http_wrapper.Reques } func PolicyDataUesUeIdOperatorSpecificDataGetProcedure(collName string, - ueId string) (*interface{}, *models.ProblemDetails) { + ueId string, m mongoapi.MongoClient) (*interface{}, *models.ProblemDetails) { filter := bson.M{"ueId": ueId} - operatorSpecificDataContainerMapCover := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + operatorSpecificDataContainerMapCover, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } if operatorSpecificDataContainerMapCover != nil { operatorSpecificDataContainerMap := operatorSpecificDataContainerMapCover["operatorSpecificDataContainerMap"] @@ -1223,14 +1332,14 @@ func PolicyDataUesUeIdOperatorSpecificDataGetProcedure(collName string, } } -func HandlePolicyDataUesUeIdOperatorSpecificDataPatch(request *http_wrapper.Request) *http_wrapper.Response { +func HandlePolicyDataUesUeIdOperatorSpecificDataPatch(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle PolicyDataUesUeIdOperatorSpecificDataPatch") collName := "policyData.ues.operatorSpecificData" ueId := request.Params["ueId"] patchItem := request.Body.([]models.PatchItem) - problemDetails := PolicyDataUesUeIdOperatorSpecificDataPatchProcedure(collName, ueId, patchItem) + problemDetails := PolicyDataUesUeIdOperatorSpecificDataPatchProcedure(collName, ueId, patchItem, m) if problemDetails == nil { return http_wrapper.NewResponse(http.StatusNoContent, nil, map[string]interface{}{}) @@ -1240,7 +1349,7 @@ func HandlePolicyDataUesUeIdOperatorSpecificDataPatch(request *http_wrapper.Requ } func PolicyDataUesUeIdOperatorSpecificDataPatchProcedure(collName string, ueId string, - patchItem []models.PatchItem) *models.ProblemDetails { + patchItem []models.PatchItem, m mongoapi.MongoClient) *models.ProblemDetails { filter := bson.M{"ueId": ueId} patchJSON, err := json.Marshal(patchItem) @@ -1248,17 +1357,17 @@ func PolicyDataUesUeIdOperatorSpecificDataPatchProcedure(collName string, ueId s logger.DataRepoLog.Warnln(err) } - success := MongoDBLibrary.RestfulAPIJSONPatchExtend(collName, filter, patchJSON, + failure := m.RestfulAPIJSONPatchExtend(collName, filter, patchJSON, "operatorSpecificDataContainerMap") - if success { + if failure == nil { return nil } else { return util.ProblemDetailsModifyNotAllowed("") } } -func HandlePolicyDataUesUeIdOperatorSpecificDataPut(request *http_wrapper.Request) *http_wrapper.Response { +func HandlePolicyDataUesUeIdOperatorSpecificDataPut(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle PolicyDataUesUeIdOperatorSpecificDataPut") // json.NewDecoder(c.Request.Body).Decode(&operatorSpecificDataContainerMap) @@ -1267,22 +1376,25 @@ func HandlePolicyDataUesUeIdOperatorSpecificDataPut(request *http_wrapper.Reques ueId := request.Params["ueId"] OperatorSpecificDataContainer := request.Body.(map[string]models.OperatorSpecificDataContainer) - PolicyDataUesUeIdOperatorSpecificDataPutProcedure(collName, ueId, OperatorSpecificDataContainer) + PolicyDataUesUeIdOperatorSpecificDataPutProcedure(collName, ueId, OperatorSpecificDataContainer, m) return http_wrapper.NewResponse(http.StatusOK, nil, map[string]interface{}{}) } func PolicyDataUesUeIdOperatorSpecificDataPutProcedure(collName string, ueId string, - OperatorSpecificDataContainer map[string]models.OperatorSpecificDataContainer) { + OperatorSpecificDataContainer map[string]models.OperatorSpecificDataContainer, m mongoapi.MongoClient) { filter := bson.M{"ueId": ueId} putData := map[string]interface{}{"operatorSpecificDataContainerMap": OperatorSpecificDataContainer} putData["ueId"] = ueId - MongoDBLibrary.RestfulAPIPutOne(collName, filter, putData) + _, errPutOne := m.RestfulAPIPutOne(collName, filter, putData) + if errPutOne != nil { + logger.DataRepoLog.Errorln(errPutOne) + } } -func HandlePolicyDataUesUeIdSmDataGet(request *http_wrapper.Request) *http_wrapper.Response { +func HandlePolicyDataUesUeIdSmDataGet(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle PolicyDataUesUeIdSmDataGet") collName := "policyData.ues.smData" @@ -1295,7 +1407,7 @@ func HandlePolicyDataUesUeIdSmDataGet(request *http_wrapper.Request) *http_wrapp } dnn := request.Query.Get("dnn") - response, problemDetails := PolicyDataUesUeIdSmDataGetProcedure(collName, ueId, sNssai, dnn) + response, problemDetails := PolicyDataUesUeIdSmDataGetProcedure(collName, ueId, sNssai, dnn, m) if response != nil { return http_wrapper.NewResponse(http.StatusOK, nil, response) } else if problemDetails != nil { @@ -1307,7 +1419,7 @@ func HandlePolicyDataUesUeIdSmDataGet(request *http_wrapper.Request) *http_wrapp } func PolicyDataUesUeIdSmDataGetProcedure(collName string, ueId string, snssai models.Snssai, - dnn string) (*models.SmPolicyData, *models.ProblemDetails) { + dnn string, m mongoapi.MongoClient) (*models.SmPolicyData, *models.ProblemDetails) { filter := bson.M{"ueId": ueId} if !reflect.DeepEqual(snssai, models.Snssai{}) { @@ -1317,7 +1429,10 @@ func PolicyDataUesUeIdSmDataGetProcedure(collName string, ueId string, snssai mo filter["smPolicySnssaiData."+util.SnssaiModelsToHex(snssai)+".smPolicyDnnData."+dnn] = bson.M{"$exists": true} } - smPolicyData := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + smPolicyData, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } if smPolicyData != nil { var smPolicyDataResp models.SmPolicyData err := json.Unmarshal(util.MapToByte(smPolicyData), &smPolicyDataResp) @@ -1327,7 +1442,10 @@ func PolicyDataUesUeIdSmDataGetProcedure(collName string, ueId string, snssai mo { collName := "policyData.ues.smData.usageMonData" filter := bson.M{"ueId": ueId} - usageMonDataMapArray := MongoDBLibrary.RestfulAPIGetMany(collName, filter) + usageMonDataMapArray, err := m.RestfulAPIGetMany(collName, filter) + if err != nil { + logger.DataRepoLog.Errorln(err) + } if !reflect.DeepEqual(usageMonDataMapArray, []map[string]interface{}{}) { var usageMonDataArray []models.UsageMonData @@ -1347,14 +1465,14 @@ func PolicyDataUesUeIdSmDataGetProcedure(collName string, ueId string, snssai mo } } -func HandlePolicyDataUesUeIdSmDataPatch(request *http_wrapper.Request) *http_wrapper.Response { +func HandlePolicyDataUesUeIdSmDataPatch(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle PolicyDataUesUeIdSmDataPatch") collName := "policyData.ues.smData.usageMonData" ueId := request.Params["ueId"] usageMonData := request.Body.(map[string]models.UsageMonData) - problemDetails := PolicyDataUesUeIdSmDataPatchProcedure(collName, ueId, usageMonData) + problemDetails := PolicyDataUesUeIdSmDataPatchProcedure(collName, ueId, usageMonData, m) if problemDetails == nil { return http_wrapper.NewResponse(http.StatusNoContent, nil, map[string]interface{}{}) } else { @@ -1363,21 +1481,24 @@ func HandlePolicyDataUesUeIdSmDataPatch(request *http_wrapper.Request) *http_wra } func PolicyDataUesUeIdSmDataPatchProcedure(collName string, ueId string, - UsageMonData map[string]models.UsageMonData) *models.ProblemDetails { + UsageMonData map[string]models.UsageMonData, m mongoapi.MongoClient) *models.ProblemDetails { filter := bson.M{"ueId": ueId} successAll := true for k, usageMonData := range UsageMonData { limitId := k filterTmp := bson.M{"ueId": ueId, "limitId": limitId} - success := MongoDBLibrary.RestfulAPIMergePatch(collName, filterTmp, util.ToBsonM(usageMonData)) - if !success { + failure := m.RestfulAPIMergePatch(collName, filterTmp, util.ToBsonM(usageMonData)) + if failure == nil { successAll = false } else { var usageMonData models.UsageMonData - usageMonDataBsonM := MongoDBLibrary.RestfulAPIGetOne(collName, filter) - err := json.Unmarshal(util.MapToByte(usageMonDataBsonM), &usageMonData) + usageMonDataBsonM, err := m.RestfulAPIGetOne(collName, filter) if err != nil { + logger.DataRepoLog.Errorln(err) + } + errUnmarshal := json.Unmarshal(util.MapToByte(usageMonDataBsonM), &usageMonData) + if errUnmarshal != nil { logger.DataRepoLog.Warnln(err) } PreHandlePolicyDataChangeNotification(ueId, limitId, usageMonData) @@ -1385,7 +1506,10 @@ func PolicyDataUesUeIdSmDataPatchProcedure(collName string, ueId string, } if successAll { - smPolicyDataBsonM := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + smPolicyDataBsonM, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } var smPolicyData models.SmPolicyData err := json.Unmarshal(util.MapToByte(smPolicyDataBsonM), &smPolicyData) if err != nil { @@ -1394,7 +1518,10 @@ func PolicyDataUesUeIdSmDataPatchProcedure(collName string, ueId string, { collName := "policyData.ues.smData.usageMonData" filter := bson.M{"ueId": ueId} - usageMonDataMapArray := MongoDBLibrary.RestfulAPIGetMany(collName, filter) + usageMonDataMapArray, errGetMany := m.RestfulAPIGetMany(collName, filter) + if errGetMany != nil { + logger.DataRepoLog.Errorln(errGetMany) + } if !reflect.DeepEqual(usageMonDataMapArray, []map[string]interface{}{}) { var usageMonDataArray []models.UsageMonData @@ -1415,30 +1542,33 @@ func PolicyDataUesUeIdSmDataPatchProcedure(collName string, ueId string, } } -func HandlePolicyDataUesUeIdSmDataUsageMonIdDelete(request *http_wrapper.Request) *http_wrapper.Response { +func HandlePolicyDataUesUeIdSmDataUsageMonIdDelete(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle PolicyDataUesUeIdSmDataUsageMonIdDelete") collName := "policyData.ues.smData.usageMonData" ueId := request.Params["ueId"] usageMonId := request.Params["usageMonId"] - PolicyDataUesUeIdSmDataUsageMonIdDeleteProcedure(collName, ueId, usageMonId) + PolicyDataUesUeIdSmDataUsageMonIdDeleteProcedure(collName, ueId, usageMonId, m) return http_wrapper.NewResponse(http.StatusNoContent, nil, map[string]interface{}{}) } -func PolicyDataUesUeIdSmDataUsageMonIdDeleteProcedure(collName string, ueId string, usageMonId string) { +func PolicyDataUesUeIdSmDataUsageMonIdDeleteProcedure(collName string, ueId string, usageMonId string, m mongoapi.MongoClient) { filter := bson.M{"ueId": ueId, "usageMonId": usageMonId} - MongoDBLibrary.RestfulAPIDeleteOne(collName, filter) + err := m.RestfulAPIDeleteOne(collName, filter) + if err != nil { + logger.DataRepoLog.Errorln(err) + } } -func HandlePolicyDataUesUeIdSmDataUsageMonIdGet(request *http_wrapper.Request) *http_wrapper.Response { +func HandlePolicyDataUesUeIdSmDataUsageMonIdGet(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle PolicyDataUesUeIdSmDataUsageMonIdGet") collName := "policyData.ues.smData.usageMonData" ueId := request.Params["ueId"] usageMonId := request.Params["usageMonId"] - response := PolicyDataUesUeIdSmDataUsageMonIdGetProcedure(collName, usageMonId, ueId) + response := PolicyDataUesUeIdSmDataUsageMonIdGetProcedure(collName, usageMonId, ueId, m) if response != nil { return http_wrapper.NewResponse(http.StatusOK, nil, response) @@ -1448,15 +1578,18 @@ func HandlePolicyDataUesUeIdSmDataUsageMonIdGet(request *http_wrapper.Request) * } func PolicyDataUesUeIdSmDataUsageMonIdGetProcedure(collName string, usageMonId string, - ueId string) *map[string]interface{} { + ueId string, m mongoapi.MongoClient) *map[string]interface{} { filter := bson.M{"ueId": ueId, "usageMonId": usageMonId} - usageMonData := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + usageMonData, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } return &usageMonData } -func HandlePolicyDataUesUeIdSmDataUsageMonIdPut(request *http_wrapper.Request) *http_wrapper.Response { +func HandlePolicyDataUesUeIdSmDataUsageMonIdPut(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle PolicyDataUesUeIdSmDataUsageMonIdPut") ueId := request.Params["ueId"] @@ -1464,29 +1597,32 @@ func HandlePolicyDataUesUeIdSmDataUsageMonIdPut(request *http_wrapper.Request) * usageMonData := request.Body.(models.UsageMonData) collName := "policyData.ues.smData.usageMonData" - response := PolicyDataUesUeIdSmDataUsageMonIdPutProcedure(collName, ueId, usageMonId, usageMonData) + response := PolicyDataUesUeIdSmDataUsageMonIdPutProcedure(collName, ueId, usageMonId, usageMonData, m) return http_wrapper.NewResponse(http.StatusCreated, nil, response) } func PolicyDataUesUeIdSmDataUsageMonIdPutProcedure(collName string, ueId string, usageMonId string, - usageMonData models.UsageMonData) *bson.M { + usageMonData models.UsageMonData, m mongoapi.MongoClient) *bson.M { putData := util.ToBsonM(usageMonData) putData["ueId"] = ueId putData["usageMonId"] = usageMonId filter := bson.M{"ueId": ueId, "usageMonId": usageMonId} - MongoDBLibrary.RestfulAPIPutOne(collName, filter, putData) + _, errPutOne := m.RestfulAPIPutOne(collName, filter, putData) + if errPutOne != nil { + logger.DataRepoLog.Errorln(errPutOne) + } return &putData } -func HandlePolicyDataUesUeIdUePolicySetGet(request *http_wrapper.Request) *http_wrapper.Response { +func HandlePolicyDataUesUeIdUePolicySetGet(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle PolicyDataUesUeIdUePolicySetGet") ueId := request.Params["ueId"] collName := "policyData.ues.uePolicySet" - response, problemDetails := PolicyDataUesUeIdUePolicySetGetProcedure(collName, ueId) + response, problemDetails := PolicyDataUesUeIdUePolicySetGetProcedure(collName, ueId, m) if response != nil { return http_wrapper.NewResponse(http.StatusOK, nil, response) @@ -1498,11 +1634,14 @@ func HandlePolicyDataUesUeIdUePolicySetGet(request *http_wrapper.Request) *http_ return http_wrapper.NewResponse(int(pd.Status), nil, pd) } -func PolicyDataUesUeIdUePolicySetGetProcedure(collName string, ueId string) (*map[string]interface{}, +func PolicyDataUesUeIdUePolicySetGetProcedure(collName string, ueId string, m mongoapi.MongoClient) (*map[string]interface{}, *models.ProblemDetails) { filter := bson.M{"ueId": ueId} - uePolicySet := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + uePolicySet, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } if uePolicySet != nil { return &uePolicySet, nil @@ -1511,14 +1650,14 @@ func PolicyDataUesUeIdUePolicySetGetProcedure(collName string, ueId string) (*ma } } -func HandlePolicyDataUesUeIdUePolicySetPatch(request *http_wrapper.Request) *http_wrapper.Response { +func HandlePolicyDataUesUeIdUePolicySetPatch(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle PolicyDataUesUeIdUePolicySetPatch") collName := "policyData.ues.uePolicySet" ueId := request.Params["ueId"] UePolicySet := request.Body.(models.UePolicySet) - problemDetails := PolicyDataUesUeIdUePolicySetPatchProcedure(collName, ueId, UePolicySet) + problemDetails := PolicyDataUesUeIdUePolicySetPatchProcedure(collName, ueId, UePolicySet, m) if problemDetails == nil { return http_wrapper.NewResponse(http.StatusNoContent, nil, map[string]interface{}{}) @@ -1528,16 +1667,19 @@ func HandlePolicyDataUesUeIdUePolicySetPatch(request *http_wrapper.Request) *htt } func PolicyDataUesUeIdUePolicySetPatchProcedure(collName string, ueId string, - UePolicySet models.UePolicySet) *models.ProblemDetails { + UePolicySet models.UePolicySet, m mongoapi.MongoClient) *models.ProblemDetails { patchData := util.ToBsonM(UePolicySet) patchData["ueId"] = ueId filter := bson.M{"ueId": ueId} - success := MongoDBLibrary.RestfulAPIMergePatch(collName, filter, patchData) + failure := m.RestfulAPIMergePatch(collName, filter, patchData) - if success { + if failure == nil { var uePolicySet models.UePolicySet - uePolicySetBsonM := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + uePolicySetBsonM, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } err := json.Unmarshal(util.MapToByte(uePolicySetBsonM), &uePolicySet) if err != nil { logger.DataRepoLog.Warnln(err) @@ -1549,14 +1691,14 @@ func PolicyDataUesUeIdUePolicySetPatchProcedure(collName string, ueId string, } } -func HandlePolicyDataUesUeIdUePolicySetPut(request *http_wrapper.Request) *http_wrapper.Response { +func HandlePolicyDataUesUeIdUePolicySetPut(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle PolicyDataUesUeIdUePolicySetPut") collName := "policyData.ues.uePolicySet" ueId := request.Params["ueId"] UePolicySet := request.Body.(models.UePolicySet) - response, status := PolicyDataUesUeIdUePolicySetPutProcedure(collName, ueId, UePolicySet) + response, status := PolicyDataUesUeIdUePolicySetPutProcedure(collName, ueId, UePolicySet, m) if status == http.StatusNoContent { return http_wrapper.NewResponse(http.StatusNoContent, nil, map[string]interface{}{}) @@ -1569,12 +1711,15 @@ func HandlePolicyDataUesUeIdUePolicySetPut(request *http_wrapper.Request) *http_ } func PolicyDataUesUeIdUePolicySetPutProcedure(collName string, ueId string, - UePolicySet models.UePolicySet) (bson.M, int) { + UePolicySet models.UePolicySet, m mongoapi.MongoClient) (bson.M, int) { putData := util.ToBsonM(UePolicySet) putData["ueId"] = ueId filter := bson.M{"ueId": ueId} - isExisted := MongoDBLibrary.RestfulAPIPutOne(collName, filter, putData) + isExisted, errPutOne := m.RestfulAPIPutOne(collName, filter, putData) + if errPutOne != nil { + logger.DataRepoLog.Errorln(errPutOne) + } if !isExisted { return putData, http.StatusCreated } else { @@ -1713,7 +1858,7 @@ func ModifyAmfSubscriptionInfoProcedure(ueId string, subsId string, var modifiedData []models.AmfSubscriptionInfo err = json.Unmarshal(modified, &modifiedData) if err != nil { - logger.DataRepoLog.Error(err) + logger.DataRepoLog.Errorln(err) } UESubsData.EeSubscriptionCollection[subsId].AmfSubscriptionInfos = modifiedData @@ -1759,13 +1904,13 @@ func GetAmfSubscriptionInfoProcedure(subsId string, ueId string) (*[]models.AmfS return &UESubsData.EeSubscriptionCollection[subsId].AmfSubscriptionInfos, nil } -func HandleQueryEEData(request *http_wrapper.Request) *http_wrapper.Response { +func HandleQueryEEData(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle QueryEEData") ueId := request.Params["ueId"] collName := "subscriptionData.eeProfileData" - response, problemDetails := QueryEEDataProcedure(collName, ueId) + response, problemDetails := QueryEEDataProcedure(collName, ueId, m) if response != nil { return http_wrapper.NewResponse(http.StatusOK, nil, response) @@ -1777,9 +1922,12 @@ func HandleQueryEEData(request *http_wrapper.Request) *http_wrapper.Response { return http_wrapper.NewResponse(int(pd.Status), nil, pd) } -func QueryEEDataProcedure(collName string, ueId string) (*map[string]interface{}, *models.ProblemDetails) { +func QueryEEDataProcedure(collName string, ueId string, m mongoapi.MongoClient) (*map[string]interface{}, *models.ProblemDetails) { filter := bson.M{"ueId": ueId} - eeProfileData := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + eeProfileData, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } if eeProfileData != nil { return &eeProfileData, nil @@ -2068,14 +2216,14 @@ func QueryeesubscriptionsProcedure(ueId string) ([]models.EeSubscription, *model return eeSubscriptionSlice, nil } -func HandlePatchOperSpecData(request *http_wrapper.Request) *http_wrapper.Response { +func HandlePatchOperSpecData(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle PatchOperSpecData") collName := "subscriptionData.operatorSpecificData" ueId := request.Params["ueId"] patchItem := request.Body.([]models.PatchItem) - problemDetails := PatchOperSpecDataProcedure(collName, ueId, patchItem) + problemDetails := PatchOperSpecDataProcedure(collName, ueId, patchItem, m) if problemDetails == nil { return http_wrapper.NewResponse(http.StatusNoContent, nil, map[string]interface{}{}) @@ -2084,20 +2232,25 @@ func HandlePatchOperSpecData(request *http_wrapper.Request) *http_wrapper.Respon } } -func PatchOperSpecDataProcedure(collName string, ueId string, patchItem []models.PatchItem) *models.ProblemDetails { +func PatchOperSpecDataProcedure(collName string, ueId string, patchItem []models.PatchItem, m mongoapi.MongoClient) *models.ProblemDetails { filter := bson.M{"ueId": ueId} - origValue := MongoDBLibrary.RestfulAPIGetOne(collName, filter) - + origValue, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } patchJSON, err := json.Marshal(patchItem) if err != nil { logger.DataRepoLog.Errorln(err) } - success := MongoDBLibrary.RestfulAPIJSONPatch(collName, filter, patchJSON) + failure := m.RestfulAPIJSONPatch(collName, filter, patchJSON) - if success { - newValue := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + if failure == nil { + newValue, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } PreHandleOnDataChangeNotify(ueId, CurrentResourceUri, patchItem, origValue, newValue) return nil } else { @@ -2105,13 +2258,13 @@ func PatchOperSpecDataProcedure(collName string, ueId string, patchItem []models } } -func HandleQueryOperSpecData(request *http_wrapper.Request) *http_wrapper.Response { +func HandleQueryOperSpecData(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle QueryOperSpecData") ueId := request.Params["ueId"] collName := "subscriptionData.operatorSpecificData" - response, problemDetails := QueryOperSpecDataProcedure(collName, ueId) + response, problemDetails := QueryOperSpecDataProcedure(collName, ueId, m) if response != nil { return http_wrapper.NewResponse(http.StatusOK, nil, response) @@ -2123,10 +2276,13 @@ func HandleQueryOperSpecData(request *http_wrapper.Request) *http_wrapper.Respon return http_wrapper.NewResponse(int(pd.Status), nil, pd) } -func QueryOperSpecDataProcedure(collName string, ueId string) (*map[string]interface{}, *models.ProblemDetails) { +func QueryOperSpecDataProcedure(collName string, ueId string, m mongoapi.MongoClient) (*map[string]interface{}, *models.ProblemDetails) { filter := bson.M{"ueId": ueId} - operatorSpecificDataContainer := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + operatorSpecificDataContainer, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } // The key of the map is operator specific data element name and the value is the operator specific data of the UE. @@ -2137,13 +2293,13 @@ func QueryOperSpecDataProcedure(collName string, ueId string) (*map[string]inter } } -func HandleGetppData(request *http_wrapper.Request) *http_wrapper.Response { +func HandleGetppData(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle GetppData") collName := "subscriptionData.ppData" ueId := request.Params["ueId"] - response, problemDetails := GetppDataProcedure(collName, ueId) + response, problemDetails := GetppDataProcedure(collName, ueId, m) if response != nil { return http_wrapper.NewResponse(http.StatusOK, nil, response) @@ -2155,10 +2311,13 @@ func HandleGetppData(request *http_wrapper.Request) *http_wrapper.Response { return http_wrapper.NewResponse(int(pd.Status), nil, pd) } -func GetppDataProcedure(collName string, ueId string) (*map[string]interface{}, *models.ProblemDetails) { +func GetppDataProcedure(collName string, ueId string, m mongoapi.MongoClient) (*map[string]interface{}, *models.ProblemDetails) { filter := bson.M{"ueId": ueId} - ppData := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + ppData, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } if ppData != nil { return &ppData, nil @@ -2179,14 +2338,14 @@ func HandleQuerySessionManagementData(request *http_wrapper.Request) *http_wrapp return http_wrapper.NewResponse(http.StatusOK, nil, map[string]interface{}{}) } -func HandleQueryProvisionedData(request *http_wrapper.Request) *http_wrapper.Response { +func HandleQueryProvisionedData(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle QueryProvisionedData") var provisionedDataSets models.ProvisionedDataSets ueId := request.Params["ueId"] servingPlmnId := request.Params["servingPlmnId"] - response, problemDetails := QueryProvisionedDataProcedure(ueId, servingPlmnId, provisionedDataSets) + response, problemDetails := QueryProvisionedDataProcedure(ueId, servingPlmnId, provisionedDataSets, m) if response != nil { return http_wrapper.NewResponse(http.StatusOK, nil, response) @@ -2199,11 +2358,14 @@ func HandleQueryProvisionedData(request *http_wrapper.Request) *http_wrapper.Res } func QueryProvisionedDataProcedure(ueId string, servingPlmnId string, - provisionedDataSets models.ProvisionedDataSets) (*models.ProvisionedDataSets, *models.ProblemDetails) { + provisionedDataSets models.ProvisionedDataSets, m mongoapi.MongoClient) (*models.ProvisionedDataSets, *models.ProblemDetails) { { collName := "subscriptionData.provisionedData.amData" filter := bson.M{"ueId": ueId, "servingPlmnId": servingPlmnId} - accessAndMobilitySubscriptionData := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + accessAndMobilitySubscriptionData, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } if accessAndMobilitySubscriptionData != nil { var tmp models.AccessAndMobilitySubscriptionData err := mapstructure.Decode(accessAndMobilitySubscriptionData, &tmp) @@ -2217,7 +2379,10 @@ func QueryProvisionedDataProcedure(ueId string, servingPlmnId string, { collName := "subscriptionData.provisionedData.smfSelectionSubscriptionData" filter := bson.M{"ueId": ueId, "servingPlmnId": servingPlmnId} - smfSelectionSubscriptionData := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + smfSelectionSubscriptionData, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } if smfSelectionSubscriptionData != nil { var tmp models.SmfSelectionSubscriptionData err := mapstructure.Decode(smfSelectionSubscriptionData, &tmp) @@ -2231,7 +2396,10 @@ func QueryProvisionedDataProcedure(ueId string, servingPlmnId string, { collName := "subscriptionData.provisionedData.smsData" filter := bson.M{"ueId": ueId, "servingPlmnId": servingPlmnId} - smsSubscriptionData := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + smsSubscriptionData, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } if smsSubscriptionData != nil { var tmp models.SmsSubscriptionData err := mapstructure.Decode(smsSubscriptionData, &tmp) @@ -2245,7 +2413,10 @@ func QueryProvisionedDataProcedure(ueId string, servingPlmnId string, { collName := "subscriptionData.provisionedData.smData" filter := bson.M{"ueId": ueId, "servingPlmnId": servingPlmnId} - sessionManagementSubscriptionDatas := MongoDBLibrary.RestfulAPIGetMany(collName, filter) + sessionManagementSubscriptionDatas, errGetMany := m.RestfulAPIGetMany(collName, filter) + if errGetMany != nil { + logger.DataRepoLog.Errorln(errGetMany) + } if sessionManagementSubscriptionDatas != nil { var tmp []models.SessionManagementSubscriptionData err := mapstructure.Decode(sessionManagementSubscriptionDatas, &tmp) @@ -2259,7 +2430,10 @@ func QueryProvisionedDataProcedure(ueId string, servingPlmnId string, { collName := "subscriptionData.provisionedData.traceData" filter := bson.M{"ueId": ueId, "servingPlmnId": servingPlmnId} - traceData := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + traceData, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } if traceData != nil { var tmp models.TraceData err := mapstructure.Decode(traceData, &tmp) @@ -2273,7 +2447,10 @@ func QueryProvisionedDataProcedure(ueId string, servingPlmnId string, { collName := "subscriptionData.provisionedData.smsMngData" filter := bson.M{"ueId": ueId, "servingPlmnId": servingPlmnId} - smsManagementSubscriptionData := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + smsManagementSubscriptionData, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } if smsManagementSubscriptionData != nil { var tmp models.SmsManagementSubscriptionData err := mapstructure.Decode(smsManagementSubscriptionData, &tmp) @@ -2291,14 +2468,14 @@ func QueryProvisionedDataProcedure(ueId string, servingPlmnId string, } } -func HandleModifyPpData(request *http_wrapper.Request) *http_wrapper.Response { +func HandleModifyPpData(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle ModifyPpData") collName := "subscriptionData.ppData" patchItem := request.Body.([]models.PatchItem) ueId := request.Params["ueId"] - problemDetails := ModifyPpDataProcedure(collName, ueId, patchItem) + problemDetails := ModifyPpDataProcedure(collName, ueId, patchItem, m) if problemDetails == nil { return http_wrapper.NewResponse(http.StatusNoContent, nil, map[string]interface{}{}) } else { @@ -2306,20 +2483,26 @@ func HandleModifyPpData(request *http_wrapper.Request) *http_wrapper.Response { } } -func ModifyPpDataProcedure(collName string, ueId string, patchItem []models.PatchItem) *models.ProblemDetails { +func ModifyPpDataProcedure(collName string, ueId string, patchItem []models.PatchItem, m mongoapi.MongoClient) *models.ProblemDetails { filter := bson.M{"ueId": ueId} - origValue := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + origValue, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } patchJSON, err := json.Marshal(patchItem) if err != nil { logger.DataRepoLog.Errorln(err) } - success := MongoDBLibrary.RestfulAPIJSONPatch(collName, filter, patchJSON) + failure := m.RestfulAPIJSONPatch(collName, filter, patchJSON) - if success { - newValue := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + if failure == nil { + newValue, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } PreHandleOnDataChangeNotify(ueId, CurrentResourceUri, patchItem, origValue, newValue) return nil } else { @@ -2327,13 +2510,13 @@ func ModifyPpDataProcedure(collName string, ueId string, patchItem []models.Patc } } -func HandleGetIdentityData(request *http_wrapper.Request) *http_wrapper.Response { +func HandleGetIdentityData(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle GetIdentityData") ueId := request.Params["ueId"] collName := "subscriptionData.identityData" - response, problemDetails := GetIdentityDataProcedure(collName, ueId) + response, problemDetails := GetIdentityDataProcedure(collName, ueId, m) if response != nil { return http_wrapper.NewResponse(http.StatusOK, nil, response) @@ -2345,10 +2528,13 @@ func HandleGetIdentityData(request *http_wrapper.Request) *http_wrapper.Response return http_wrapper.NewResponse(int(pd.Status), nil, pd) } -func GetIdentityDataProcedure(collName string, ueId string) (*map[string]interface{}, *models.ProblemDetails) { +func GetIdentityDataProcedure(collName string, ueId string, m mongoapi.MongoClient) (*map[string]interface{}, *models.ProblemDetails) { filter := bson.M{"ueId": ueId} - identityData := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + identityData, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } if identityData != nil { return &identityData, nil @@ -2357,13 +2543,13 @@ func GetIdentityDataProcedure(collName string, ueId string) (*map[string]interfa } } -func HandleGetOdbData(request *http_wrapper.Request) *http_wrapper.Response { +func HandleGetOdbData(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle GetOdbData") ueId := request.Params["ueId"] collName := "subscriptionData.operatorDeterminedBarringData" - response, problemDetails := GetOdbDataProcedure(collName, ueId) + response, problemDetails := GetOdbDataProcedure(collName, ueId, m) if response != nil { return http_wrapper.NewResponse(http.StatusOK, nil, response) @@ -2375,10 +2561,13 @@ func HandleGetOdbData(request *http_wrapper.Request) *http_wrapper.Response { return http_wrapper.NewResponse(int(pd.Status), nil, pd) } -func GetOdbDataProcedure(collName string, ueId string) (*map[string]interface{}, *models.ProblemDetails) { +func GetOdbDataProcedure(collName string, ueId string, m mongoapi.MongoClient) (*map[string]interface{}, *models.ProblemDetails) { filter := bson.M{"ueId": ueId} - operatorDeterminedBarringData := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + operatorDeterminedBarringData, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } if operatorDeterminedBarringData != nil { return &operatorDeterminedBarringData, nil @@ -2387,7 +2576,7 @@ func GetOdbDataProcedure(collName string, ueId string) (*map[string]interface{}, } } -func HandleGetSharedData(request *http_wrapper.Request) *http_wrapper.Response { +func HandleGetSharedData(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle GetSharedData") var sharedDataIds []string @@ -2399,7 +2588,7 @@ func HandleGetSharedData(request *http_wrapper.Request) *http_wrapper.Response { } collName := "subscriptionData.sharedData" - response, problemDetails := GetSharedDataProcedure(collName, sharedDataIds) + response, problemDetails := GetSharedDataProcedure(collName, sharedDataIds, m) if response != nil { return http_wrapper.NewResponse(http.StatusOK, nil, response) @@ -2411,12 +2600,15 @@ func HandleGetSharedData(request *http_wrapper.Request) *http_wrapper.Response { return http_wrapper.NewResponse(int(pd.Status), nil, pd) } -func GetSharedDataProcedure(collName string, sharedDataIds []string) (*[]map[string]interface{}, +func GetSharedDataProcedure(collName string, sharedDataIds []string, m mongoapi.MongoClient) (*[]map[string]interface{}, *models.ProblemDetails) { var sharedDataArray []map[string]interface{} for _, sharedDataId := range sharedDataIds { filter := bson.M{"sharedDataId": sharedDataId} - sharedData := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + sharedData, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } if sharedData != nil { sharedDataArray = append(sharedDataArray, sharedData) } @@ -2573,7 +2765,7 @@ func QuerysdmsubscriptionsProcedure(ueId string) (*[]models.SdmSubscription, *mo return &sdmSubscriptionSlice, nil } -func HandleQuerySmData(request *http_wrapper.Request) *http_wrapper.Response { +func HandleQuerySmData(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle QuerySmData") collName := "subscriptionData.provisionedData.smData" @@ -2587,13 +2779,13 @@ func HandleQuerySmData(request *http_wrapper.Request) *http_wrapper.Response { } dnn := request.Query.Get("dnn") - response := QuerySmDataProcedure(collName, ueId, servingPlmnId, singleNssai, dnn) + response := QuerySmDataProcedure(collName, ueId, servingPlmnId, singleNssai, dnn, m) return http_wrapper.NewResponse(http.StatusOK, nil, response) } func QuerySmDataProcedure(collName string, ueId string, servingPlmnId string, - singleNssai models.Snssai, dnn string) *[]map[string]interface{} { + singleNssai models.Snssai, dnn string, m mongoapi.MongoClient) *[]map[string]interface{} { filter := bson.M{"ueId": ueId, "servingPlmnId": servingPlmnId} if !reflect.DeepEqual(singleNssai, models.Snssai{}) { @@ -2609,12 +2801,15 @@ func QuerySmDataProcedure(collName string, ueId string, servingPlmnId string, filter["dnnConfigurations."+dnn] = bson.M{"$exists": true} } - sessionManagementSubscriptionDatas := MongoDBLibrary.RestfulAPIGetMany(collName, filter) + sessionManagementSubscriptionDatas, errGetMany := m.RestfulAPIGetMany(collName, filter) + if errGetMany != nil { + logger.DataRepoLog.Errorln(errGetMany) + } return &sessionManagementSubscriptionDatas } -func HandleCreateSmfContextNon3gpp(request *http_wrapper.Request) *http_wrapper.Response { +func HandleCreateSmfContextNon3gpp(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle CreateSmfContextNon3gpp") SmfRegistration := request.Body.(models.SmfRegistration) @@ -2625,7 +2820,7 @@ func HandleCreateSmfContextNon3gpp(request *http_wrapper.Request) *http_wrapper. logger.DataRepoLog.Warnln(err) } - response, status := CreateSmfContextNon3gppProcedure(SmfRegistration, collName, ueId, pduSessionId) + response, status := CreateSmfContextNon3gppProcedure(SmfRegistration, collName, ueId, pduSessionId, m) if status == http.StatusCreated { return http_wrapper.NewResponse(http.StatusCreated, nil, response) @@ -2638,14 +2833,16 @@ func HandleCreateSmfContextNon3gpp(request *http_wrapper.Request) *http_wrapper. } func CreateSmfContextNon3gppProcedure(SmfRegistration models.SmfRegistration, - collName string, ueId string, pduSessionIdInt int64) (bson.M, int) { + collName string, ueId string, pduSessionIdInt int64, m mongoapi.MongoClient) (bson.M, int) { putData := util.ToBsonM(SmfRegistration) putData["ueId"] = ueId putData["pduSessionId"] = int32(pduSessionIdInt) filter := bson.M{"ueId": ueId, "pduSessionId": pduSessionIdInt} - isExisted := MongoDBLibrary.RestfulAPIPutOne(collName, filter, putData) - + isExisted, err := m.RestfulAPIPutOne(collName, filter, putData) + if err != nil { + logger.DataRepoLog.Errorln(err) + } if !isExisted { return putData, http.StatusCreated } else { @@ -2653,35 +2850,38 @@ func CreateSmfContextNon3gppProcedure(SmfRegistration models.SmfRegistration, } } -func HandleDeleteSmfContext(request *http_wrapper.Request) *http_wrapper.Response { +func HandleDeleteSmfContext(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle DeleteSmfContext") collName := "subscriptionData.contextData.smfRegistrations" ueId := request.Params["ueId"] pduSessionId := request.Params["pduSessionId"] - DeleteSmfContextProcedure(collName, ueId, pduSessionId) + DeleteSmfContextProcedure(collName, ueId, pduSessionId, m) return http_wrapper.NewResponse(http.StatusNoContent, nil, map[string]interface{}{}) } -func DeleteSmfContextProcedure(collName string, ueId string, pduSessionId string) { +func DeleteSmfContextProcedure(collName string, ueId string, pduSessionId string, m mongoapi.MongoClient) { pduSessionIdInt, err := strconv.ParseInt(pduSessionId, 10, 32) if err != nil { - logger.DataRepoLog.Error(err) + logger.DataRepoLog.Errorln(err) } filter := bson.M{"ueId": ueId, "pduSessionId": pduSessionIdInt} - MongoDBLibrary.RestfulAPIDeleteOne(collName, filter) + errDeleteOne := m.RestfulAPIDeleteOne(collName, filter) + if errDeleteOne != nil { + logger.DataRepoLog.Errorln(errDeleteOne) + } } -func HandleQuerySmfRegistration(request *http_wrapper.Request) *http_wrapper.Response { +func HandleQuerySmfRegistration(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle QuerySmfRegistration") ueId := request.Params["ueId"] pduSessionId := request.Params["pduSessionId"] collName := "subscriptionData.contextData.smfRegistrations" - response, problemDetails := QuerySmfRegistrationProcedure(collName, ueId, pduSessionId) + response, problemDetails := QuerySmfRegistrationProcedure(collName, ueId, pduSessionId, m) if response != nil { return http_wrapper.NewResponse(http.StatusOK, nil, response) } else if problemDetails != nil { @@ -2693,15 +2893,18 @@ func HandleQuerySmfRegistration(request *http_wrapper.Request) *http_wrapper.Res } func QuerySmfRegistrationProcedure(collName string, ueId string, - pduSessionId string) (*map[string]interface{}, *models.ProblemDetails) { + pduSessionId string, m mongoapi.MongoClient) (*map[string]interface{}, *models.ProblemDetails) { pduSessionIdInt, err := strconv.ParseInt(pduSessionId, 10, 32) if err != nil { - logger.DataRepoLog.Error(err) + logger.DataRepoLog.Errorln(err) } filter := bson.M{"ueId": ueId, "pduSessionId": pduSessionIdInt} - smfRegistration := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + smfRegistration, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } if smfRegistration != nil { return &smfRegistration, nil @@ -2710,12 +2913,12 @@ func QuerySmfRegistrationProcedure(collName string, ueId string, } } -func HandleQuerySmfRegList(request *http_wrapper.Request) *http_wrapper.Response { +func HandleQuerySmfRegList(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle QuerySmfRegList") collName := "subscriptionData.contextData.smfRegistrations" ueId := request.Params["ueId"] - response := QuerySmfRegListProcedure(collName, ueId) + response := QuerySmfRegListProcedure(collName, ueId, m) if response == nil { return http_wrapper.NewResponse(http.StatusOK, nil, []map[string]interface{}{}) @@ -2724,10 +2927,12 @@ func HandleQuerySmfRegList(request *http_wrapper.Request) *http_wrapper.Response } } -func QuerySmfRegListProcedure(collName string, ueId string) *[]map[string]interface{} { +func QuerySmfRegListProcedure(collName string, ueId string, m mongoapi.MongoClient) *[]map[string]interface{} { filter := bson.M{"ueId": ueId} - smfRegList := MongoDBLibrary.RestfulAPIGetMany(collName, filter) - + smfRegList, errGetMany := m.RestfulAPIGetMany(collName, filter) + if errGetMany != nil { + logger.DataRepoLog.Errorln(errGetMany) + } if smfRegList != nil { return &smfRegList } else { @@ -2736,13 +2941,13 @@ func QuerySmfRegListProcedure(collName string, ueId string) *[]map[string]interf } } -func HandleQuerySmfSelectData(request *http_wrapper.Request) *http_wrapper.Response { +func HandleQuerySmfSelectData(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle QuerySmfSelectData") collName := "subscriptionData.provisionedData.smfSelectionSubscriptionData" ueId := request.Params["ueId"] servingPlmnId := request.Params["servingPlmnId"] - response, problemDetails := QuerySmfSelectDataProcedure(collName, ueId, servingPlmnId) + response, problemDetails := QuerySmfSelectDataProcedure(collName, ueId, servingPlmnId, m) if problemDetails == nil { return http_wrapper.NewResponse(http.StatusOK, nil, response) @@ -2752,9 +2957,12 @@ func HandleQuerySmfSelectData(request *http_wrapper.Request) *http_wrapper.Respo } func QuerySmfSelectDataProcedure(collName string, ueId string, - servingPlmnId string) (*map[string]interface{}, *models.ProblemDetails) { + servingPlmnId string, m mongoapi.MongoClient) (*map[string]interface{}, *models.ProblemDetails) { filter := bson.M{"ueId": ueId, "servingPlmnId": servingPlmnId} - smfSelectionSubscriptionData := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + smfSelectionSubscriptionData, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } if smfSelectionSubscriptionData != nil { return &smfSelectionSubscriptionData, nil @@ -2763,48 +2971,54 @@ func QuerySmfSelectDataProcedure(collName string, ueId string, } } -func HandleCreateSmsfContext3gpp(request *http_wrapper.Request) *http_wrapper.Response { +func HandleCreateSmsfContext3gpp(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle CreateSmsfContext3gpp") SmsfRegistration := request.Body.(models.SmsfRegistration) collName := "subscriptionData.contextData.smsf3gppAccess" ueId := request.Params["ueId"] - CreateSmsfContext3gppProcedure(collName, ueId, SmsfRegistration) + CreateSmsfContext3gppProcedure(collName, ueId, SmsfRegistration, m) return http_wrapper.NewResponse(http.StatusNoContent, nil, map[string]interface{}{}) } -func CreateSmsfContext3gppProcedure(collName string, ueId string, SmsfRegistration models.SmsfRegistration) { +func CreateSmsfContext3gppProcedure(collName string, ueId string, SmsfRegistration models.SmsfRegistration, m mongoapi.MongoClient) { putData := util.ToBsonM(SmsfRegistration) putData["ueId"] = ueId filter := bson.M{"ueId": ueId} - MongoDBLibrary.RestfulAPIPutOne(collName, filter, putData) + _, errPutOne := m.RestfulAPIPutOne(collName, filter, putData) + if errPutOne != nil { + logger.DataRepoLog.Errorln(errPutOne) + } } -func HandleDeleteSmsfContext3gpp(request *http_wrapper.Request) *http_wrapper.Response { +func HandleDeleteSmsfContext3gpp(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle DeleteSmsfContext3gpp") collName := "subscriptionData.contextData.smsf3gppAccess" ueId := request.Params["ueId"] - DeleteSmsfContext3gppProcedure(collName, ueId) + DeleteSmsfContext3gppProcedure(collName, ueId, m) return http_wrapper.NewResponse(http.StatusNoContent, nil, map[string]interface{}{}) } -func DeleteSmsfContext3gppProcedure(collName string, ueId string) { +func DeleteSmsfContext3gppProcedure(collName string, ueId string, m mongoapi.MongoClient) { filter := bson.M{"ueId": ueId} - MongoDBLibrary.RestfulAPIDeleteOne(collName, filter) + err := m.RestfulAPIDeleteOne(collName, filter) + if err != nil { + logger.DataRepoLog.Errorln(err) + } } -func HandleQuerySmsfContext3gpp(request *http_wrapper.Request) *http_wrapper.Response { +func HandleQuerySmsfContext3gpp(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle QuerySmsfContext3gpp") collName := "subscriptionData.contextData.smsf3gppAccess" ueId := request.Params["ueId"] - response, problemDetails := QuerySmsfContext3gppProcedure(collName, ueId) + response, problemDetails := QuerySmsfContext3gppProcedure(collName, ueId, m) if response != nil { return http_wrapper.NewResponse(http.StatusOK, nil, response) } else if problemDetails != nil { @@ -2815,10 +3029,13 @@ func HandleQuerySmsfContext3gpp(request *http_wrapper.Request) *http_wrapper.Res return http_wrapper.NewResponse(int(pd.Status), nil, pd) } -func QuerySmsfContext3gppProcedure(collName string, ueId string) (*map[string]interface{}, *models.ProblemDetails) { +func QuerySmsfContext3gppProcedure(collName string, ueId string, m mongoapi.MongoClient) (*map[string]interface{}, *models.ProblemDetails) { filter := bson.M{"ueId": ueId} - smsfRegistration := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + smsfRegistration, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } if smsfRegistration != nil { return &smsfRegistration, nil @@ -2827,48 +3044,54 @@ func QuerySmsfContext3gppProcedure(collName string, ueId string) (*map[string]in } } -func HandleCreateSmsfContextNon3gpp(request *http_wrapper.Request) *http_wrapper.Response { +func HandleCreateSmsfContextNon3gpp(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle CreateSmsfContextNon3gpp") SmsfRegistration := request.Body.(models.SmsfRegistration) collName := "subscriptionData.contextData.smsfNon3gppAccess" ueId := request.Params["ueId"] - CreateSmsfContextNon3gppProcedure(SmsfRegistration, collName, ueId) + CreateSmsfContextNon3gppProcedure(SmsfRegistration, collName, ueId, m) return http_wrapper.NewResponse(http.StatusNoContent, nil, map[string]interface{}{}) } -func CreateSmsfContextNon3gppProcedure(SmsfRegistration models.SmsfRegistration, collName string, ueId string) { +func CreateSmsfContextNon3gppProcedure(SmsfRegistration models.SmsfRegistration, collName string, ueId string, m mongoapi.MongoClient) { putData := util.ToBsonM(SmsfRegistration) putData["ueId"] = ueId filter := bson.M{"ueId": ueId} - MongoDBLibrary.RestfulAPIPutOne(collName, filter, putData) + _, errPutOne := m.RestfulAPIPutOne(collName, filter, putData) + if errPutOne != nil { + logger.DataRepoLog.Errorln(errPutOne) + } } -func HandleDeleteSmsfContextNon3gpp(request *http_wrapper.Request) *http_wrapper.Response { +func HandleDeleteSmsfContextNon3gpp(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle DeleteSmsfContextNon3gpp") collName := "subscriptionData.contextData.smsfNon3gppAccess" ueId := request.Params["ueId"] - DeleteSmsfContextNon3gppProcedure(collName, ueId) + DeleteSmsfContextNon3gppProcedure(collName, ueId, m) return http_wrapper.NewResponse(http.StatusNoContent, nil, map[string]interface{}{}) } -func DeleteSmsfContextNon3gppProcedure(collName string, ueId string) { +func DeleteSmsfContextNon3gppProcedure(collName string, ueId string, m mongoapi.MongoClient) { filter := bson.M{"ueId": ueId} - MongoDBLibrary.RestfulAPIDeleteOne(collName, filter) + err := m.RestfulAPIDeleteOne(collName, filter) + if err != nil { + logger.DataRepoLog.Errorln(err) + } } -func HandleQuerySmsfContextNon3gpp(request *http_wrapper.Request) *http_wrapper.Response { +func HandleQuerySmsfContextNon3gpp(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle QuerySmsfContextNon3gpp") ueId := request.Params["ueId"] collName := "subscriptionData.contextData.smsfNon3gppAccess" - response, problemDetails := QuerySmsfContextNon3gppProcedure(collName, ueId) + response, problemDetails := QuerySmsfContextNon3gppProcedure(collName, ueId, m) if response != nil { return http_wrapper.NewResponse(http.StatusOK, nil, response) } else if problemDetails != nil { @@ -2879,10 +3102,13 @@ func HandleQuerySmsfContextNon3gpp(request *http_wrapper.Request) *http_wrapper. return http_wrapper.NewResponse(int(pd.Status), nil, pd) } -func QuerySmsfContextNon3gppProcedure(collName string, ueId string) (*map[string]interface{}, *models.ProblemDetails) { +func QuerySmsfContextNon3gppProcedure(collName string, ueId string, m mongoapi.MongoClient) (*map[string]interface{}, *models.ProblemDetails) { filter := bson.M{"ueId": ueId} - smsfRegistration := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + smsfRegistration, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } if smsfRegistration != nil { return &smsfRegistration, nil @@ -2891,13 +3117,13 @@ func QuerySmsfContextNon3gppProcedure(collName string, ueId string) (*map[string } } -func HandleQuerySmsMngData(request *http_wrapper.Request) *http_wrapper.Response { +func HandleQuerySmsMngData(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle QuerySmsMngData") collName := "subscriptionData.provisionedData.smsMngData" ueId := request.Params["ueId"] servingPlmnId := request.Params["servingPlmnId"] - response, problemDetails := QuerySmsMngDataProcedure(collName, ueId, servingPlmnId) + response, problemDetails := QuerySmsMngDataProcedure(collName, ueId, servingPlmnId, m) if response != nil { return http_wrapper.NewResponse(http.StatusOK, nil, response) @@ -2910,9 +3136,12 @@ func HandleQuerySmsMngData(request *http_wrapper.Request) *http_wrapper.Response } func QuerySmsMngDataProcedure(collName string, ueId string, - servingPlmnId string) (*map[string]interface{}, *models.ProblemDetails) { + servingPlmnId string, m mongoapi.MongoClient) (*map[string]interface{}, *models.ProblemDetails) { filter := bson.M{"ueId": ueId, "servingPlmnId": servingPlmnId} - smsManagementSubscriptionData := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + smsManagementSubscriptionData, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } if smsManagementSubscriptionData != nil { return &smsManagementSubscriptionData, nil @@ -2921,14 +3150,14 @@ func QuerySmsMngDataProcedure(collName string, ueId string, } } -func HandleQuerySmsData(request *http_wrapper.Request) *http_wrapper.Response { +func HandleQuerySmsData(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle QuerySmsData") ueId := request.Params["ueId"] servingPlmnId := request.Params["servingPlmnId"] collName := "subscriptionData.provisionedData.smsData" - response, problemDetails := QuerySmsDataProcedure(collName, ueId, servingPlmnId) + response, problemDetails := QuerySmsDataProcedure(collName, ueId, servingPlmnId, m) if response != nil { return http_wrapper.NewResponse(http.StatusOK, nil, response) @@ -2941,10 +3170,13 @@ func HandleQuerySmsData(request *http_wrapper.Request) *http_wrapper.Response { } func QuerySmsDataProcedure(collName string, ueId string, - servingPlmnId string) (*map[string]interface{}, *models.ProblemDetails) { + servingPlmnId string, m mongoapi.MongoClient) (*map[string]interface{}, *models.ProblemDetails) { filter := bson.M{"ueId": ueId, "servingPlmnId": servingPlmnId} - smsSubscriptionData := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + smsSubscriptionData, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } if smsSubscriptionData != nil { return &smsSubscriptionData, nil @@ -3005,14 +3237,14 @@ func RemovesubscriptionDataSubscriptionsProcedure(subsId string) *models.Problem return nil } -func HandleQueryTraceData(request *http_wrapper.Request) *http_wrapper.Response { +func HandleQueryTraceData(request *http_wrapper.Request, m mongoapi.MongoClient) *http_wrapper.Response { logger.DataRepoLog.Infof("Handle QueryTraceData") collName := "subscriptionData.provisionedData.traceData" ueId := request.Params["ueId"] servingPlmnId := request.Params["servingPlmnId"] - response, problemDetails := QueryTraceDataProcedure(collName, ueId, servingPlmnId) + response, problemDetails := QueryTraceDataProcedure(collName, ueId, servingPlmnId, m) if response != nil { return http_wrapper.NewResponse(http.StatusOK, nil, response) @@ -3025,10 +3257,13 @@ func HandleQueryTraceData(request *http_wrapper.Request) *http_wrapper.Response } func QueryTraceDataProcedure(collName string, ueId string, - servingPlmnId string) (*map[string]interface{}, *models.ProblemDetails) { + servingPlmnId string, m mongoapi.MongoClient) (*map[string]interface{}, *models.ProblemDetails) { filter := bson.M{"ueId": ueId, "servingPlmnId": servingPlmnId} - traceData := MongoDBLibrary.RestfulAPIGetOne(collName, filter) + traceData, errGetOne := m.RestfulAPIGetOne(collName, filter) + if errGetOne != nil { + logger.DataRepoLog.Errorln(errGetOne) + } if traceData != nil { return &traceData, nil diff --git a/service/init.go b/service/init.go index fb3d3dd..a301771 100644 --- a/service/init.go +++ b/service/init.go @@ -21,8 +21,6 @@ import ( "github.com/sirupsen/logrus" "github.com/urfave/cli" - "github.com/omec-project/MongoDBLibrary" - mongoDBLibLogger "github.com/omec-project/MongoDBLibrary/logger" "github.com/omec-project/http2_util" "github.com/omec-project/logger_util" "github.com/omec-project/path_util" @@ -35,6 +33,8 @@ import ( "github.com/omec-project/udr/logger" "github.com/omec-project/udr/producer" "github.com/omec-project/udr/util" + mongoDBLibLogger "github.com/omec-project/util/logger" + "github.com/omec-project/util/mongoapi" ) type UDR struct{} @@ -46,6 +46,7 @@ type ( } ) +var commonDBClient mongoapi.MongoClient var config Config var udrCLi = []cli.Flag{ @@ -141,14 +142,14 @@ func (udr *UDR) setLogLevel() { if factory.UdrConfig.Logger.MongoDBLibrary != nil { if factory.UdrConfig.Logger.MongoDBLibrary.DebugLevel != "" { if level, err := logrus.ParseLevel(factory.UdrConfig.Logger.MongoDBLibrary.DebugLevel); err != nil { - mongoDBLibLogger.MongoDBLog.Warnf("MongoDBLibrary Log level [%s] is invalid, set to [info] level", + mongoDBLibLogger.AppLog.Warnf("MongoDBLibrary Log level [%s] is invalid, set to [info] level", factory.UdrConfig.Logger.MongoDBLibrary.DebugLevel) mongoDBLibLogger.SetLogLevel(logrus.InfoLevel) } else { mongoDBLibLogger.SetLogLevel(level) } } else { - mongoDBLibLogger.MongoDBLog.Warnln("MongoDBLibrary Log level not set. Default set to [info] level") + mongoDBLibLogger.AppLog.Warnln("MongoDBLibrary Log level not set. Default set to [info] level") mongoDBLibLogger.SetLogLevel(logrus.InfoLevel) } mongoDBLibLogger.SetReportCaller(factory.UdrConfig.Logger.MongoDBLibrary.ReportCaller) @@ -168,6 +169,14 @@ func (udr *UDR) FilterCli(c *cli.Context) (args []string) { return args } +func mongoConnect(url string, dbname string) error { + var mClient, errConnect = mongoapi.NewMongoClient(url, dbname) + if mClient.Client != nil { + commonDBClient.Client = mClient.Client + } + return errConnect +} + func (udr *UDR) Start() { // get config file info config := factory.UdrConfig @@ -176,13 +185,28 @@ func (udr *UDR) Start() { initLog.Infof("UDR Config Info: Version[%s] Description[%s]", config.Info.Version, config.Info.Description) // Connect to MongoDB - MongoDBLibrary.SetMongoDB(mongodb.Name, mongodb.Url) + ticker := time.NewTicker(2 * time.Second) + defer func() { ticker.Stop() }() + timer := time.After(180 * time.Second) +ConnectMongo: + for { + if err := mongoConnect(mongodb.Url, mongodb.Name); err == nil { + break ConnectMongo + } + select { + case <-ticker.C: + continue + case <-timer: + logger.InitLog.Errorln("Timed out while connecting to MongoDB in 10 seconds.") + return + } + } initLog.Infoln("Server started") router := logger_util.NewGinWithLogrus(logger.GinLog) - datarepository.AddService(router) + datarepository.AddService(router, commonDBClient) udrLogPath := util.UdrLogPath udrPemPath := util.UdrPemPath @@ -301,7 +325,8 @@ func (udr *UDR) configUpdateDb() { err := producer.AddEntrySmPolicyTable( msg.SmPolicyTable.Imsi, msg.SmPolicyTable.Dnn, - msg.SmPolicyTable.Snssai) + msg.SmPolicyTable.Snssai, + commonDBClient) if err == nil { initLog.Infof("added entry to sm policy table success") } else {