-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_smsf3_gpp_registration_document.go
113 lines (97 loc) · 3.19 KB
/
api_smsf3_gpp_registration_document.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
* Nudr_DataRepository API OpenAPI file
*
* Unified Data Repository Service
*
* API version: 1.0.0
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
*/
package datarepository
import (
"github.com/nycu-ucr/gonet/http"
"github.com/nycu-ucr/gin"
"github.com/nycu-ucr/http_wrapper"
"github.com/nycu-ucr/openapi"
"github.com/nycu-ucr/openapi/models"
"github.com/nycu-ucr/udr/logger"
"github.com/nycu-ucr/udr/producer"
)
// 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",
}
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,
}
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(),
}
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(),
}
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(),
}
c.JSON(http.StatusInternalServerError, problemDetails)
} else {
c.Data(rsp.Status, "application/json", responseBody)
}
}