Skip to content

Commit

Permalink
feat: upgrade routes
Browse files Browse the repository at this point in the history
  • Loading branch information
pf-lin committed Aug 12, 2024
1 parent 8765d97 commit 17e0bc2
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 66 deletions.
3 changes: 3 additions & 0 deletions internal/sbi/api_callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,19 @@ import (
func (s *Server) getCallbackRoutes() []Route {
return []Route{
{
Name: "SmPolicyUpdateNotification",
Method: http.MethodPost,
Pattern: "/sm-policies/:smContextRef/update",
APIFunc: s.HTTPSmPolicyUpdateNotification,
},
{
Name: "SmPolicyControlTerminationRequestNotification",
Method: http.MethodPost,
Pattern: "/sm-policies/:smContextRef/terminate",
APIFunc: s.SmPolicyControlTerminationRequestNotification,
},
{
Name: "ChargingNotification",
Method: http.MethodPost,
Pattern: "/:notifyUri",
APIFunc: s.HTTPChargingNotification,
Expand Down
29 changes: 17 additions & 12 deletions internal/sbi/api_eventexposure.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,51 +18,56 @@ import (
func (s *Server) getEventExposureRoutes() []Route {
return []Route{
{
Name: "Index",
Method: http.MethodGet,
Pattern: "/",
APIFunc: func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"status": "Service Available"})
},
},
{
Name: "CreateIndividualSubcription",
Method: http.MethodPost,
Pattern: "subscriptions",
APIFunc: s.SubscriptionsPost,
Pattern: "/subscriptions",
APIFunc: s.HTTPCreateIndividualSubcription,
},
{
Name: "DeleteIndividualSubcription",
Method: http.MethodDelete,
Pattern: "subscriptions/:subId",
APIFunc: s.SubscriptionsSubIdDelete,
Pattern: "/subscriptions/:subId",
APIFunc: s.HTTPDeleteIndividualSubcription,
},
{
Name: "GetIndividualSubcription",
Method: http.MethodGet,
Pattern: "subscriptions/:subId",
APIFunc: s.SubscriptionsSubIdGet,
Pattern: "/subscriptions/:subId",
APIFunc: s.HTTPGetIndividualSubcription,
},
{
Name: "ReplaceIndividualSubcription",
Method: http.MethodPut,
Pattern: "subscriptions/:subId",
APIFunc: s.SubscriptionsSubIdPut,
Pattern: "/subscriptions/:subId",
APIFunc: s.HTTPReplaceIndividualSubcription,
},
}
}

// SubscriptionsPost -
func (s *Server) SubscriptionsPost(c *gin.Context) {
func (s *Server) HTTPCreateIndividualSubcription(c *gin.Context) {
c.JSON(http.StatusNotImplemented, gin.H{})
}

// SubscriptionsSubIdDelete -
func (s *Server) SubscriptionsSubIdDelete(c *gin.Context) {
func (s *Server) HTTPDeleteIndividualSubcription(c *gin.Context) {
c.JSON(http.StatusNotImplemented, gin.H{})
}

// SubscriptionsSubIdGet -
func (s *Server) SubscriptionsSubIdGet(c *gin.Context) {
func (s *Server) HTTPGetIndividualSubcription(c *gin.Context) {
c.JSON(http.StatusNotImplemented, gin.H{})
}

// SubscriptionsSubIdPut -
func (s *Server) SubscriptionsSubIdPut(c *gin.Context) {
func (s *Server) HTTPReplaceIndividualSubcription(c *gin.Context) {
c.JSON(http.StatusNotImplemented, gin.H{})
}
3 changes: 3 additions & 0 deletions internal/sbi/api_oam.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,21 @@ import (
func (s *Server) getOAMRoutes() []Route {
return []Route{
{
Name: "Index",
Method: http.MethodGet,
Pattern: "/",
APIFunc: func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"status": "Service Available"})
},
},
{
Name: "Get UE PDU Session Info",
Method: http.MethodGet,
Pattern: "/ue-pdu-session-info/:smContextRef",
APIFunc: s.HTTPGetUEPDUSessionInfo,
},
{
Name: "Get SMF Userplane Information",
Method: http.MethodGet,
Pattern: "/user-plane-info/",
APIFunc: s.HTTPGetSMFUserPlaneInfo,
Expand Down
146 changes: 92 additions & 54 deletions internal/sbi/api_pdusession.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,65 +15,82 @@ import (
func (s *Server) getPDUSessionRoutes() []Route {
return []Route{
{
Name: "Index",
Method: http.MethodGet,
Pattern: "/",
APIFunc: func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"status": "Service Available"})
},
},
{
Name: "PostSmContexts",
Method: http.MethodPost,
Pattern: "/pdu-sessions/:pduSessionRef/release",
APIFunc: s.ReleasePduSession,
Pattern: "/sm-contexts",
APIFunc: s.HTTPPostSmContexts,
},
{
Name: "UpdateSmContext",
Method: http.MethodPost,
Pattern: "/pdu-sessions/:pduSessionRef/modify",
APIFunc: s.UpdatePduSession,
Pattern: "/sm-contexts/:smContextRef/modify",
APIFunc: s.HTTPUpdateSmContext,
},
{
Name: "RetrieveSmContext",
Method: http.MethodPost,
Pattern: "/sm-contexts/:smContextRef/release",
APIFunc: s.HTTPReleaseSmContext,
Pattern: "/sm-contexts/:smContextRef/retrieve",
APIFunc: s.HTTPRetrieveSmContext,
},
{
Name: "ReleaseSmContext",
Method: http.MethodPost,
Pattern: "/sm-contexts/:smContextRef/retrieve",
APIFunc: s.RetrieveSmContext,
Pattern: "/sm-contexts/:smContextRef/release",
APIFunc: s.HTTPReleaseSmContext,
},
{
Name: "SendMoData",
Method: http.MethodPost,
Pattern: "/sm-contexts/:smContextRef/modify",
APIFunc: s.HTTPUpdateSmContext,
Pattern: "/sm-contexts/:smContextRef/send-mo-data",
APIFunc: s.HTTPSendMoData,
},
{
Name: "PostPduSessions",
Method: http.MethodPatch,
Pattern: "/pdu-sessions",
APIFunc: s.PostPduSessions,
APIFunc: s.HTTPPostPduSessions,
},
{
Name: "UpdatePduSession",
Method: http.MethodPost,
Pattern: "/sm-contexts",
APIFunc: s.HTTPPostSmContexts,
Pattern: "/pdu-sessions/:pduSessionRef/modify",
APIFunc: s.HTTPUpdatePduSession,
},
{
Name: "ReleasePduSession",
Method: http.MethodPost,
Pattern: "/pdu-sessions/:pduSessionRef/release",
APIFunc: s.HTTPReleasePduSession,
},
{
Name: "RetrievePduSession",
Method: http.MethodPost,
Pattern: "/pdu-sessions/:pduSessionRef/retrieve",
APIFunc: s.HTTPRetrievePduSession,
},
{
Name: "TransferMoData",
Method: http.MethodPost,
Pattern: "/pdu-sessions/:pduSessionRef/transfer-mo-data",
APIFunc: s.HTTPTransferMoData,
},
}
}

// ReleasePduSession - Release
func (s *Server) ReleasePduSession(c *gin.Context) {
c.JSON(http.StatusNotImplemented, gin.H{})
}

// UpdatePduSession - Update (initiated by V-SMF)
func (s *Server) UpdatePduSession(c *gin.Context) {
c.JSON(http.StatusNotImplemented, gin.H{})
}
// HTTPPostSmContexts - Create SM Context
func (s *Server) HTTPPostSmContexts(c *gin.Context) {
logger.PduSessLog.Info("Receive Create SM Context Request")
var request models.PostSmContextsRequest

// HTTPReleaseSmContext - Release SM Context
func (s *Server) HTTPReleaseSmContext(c *gin.Context) {
logger.PduSessLog.Info("Receive Release SM Context Request")
var request models.ReleaseSmContextRequest
request.JsonData = new(models.SmfPduSessionSmContextReleaseData)
request.JsonData = new(models.SmfPduSessionSmContextCreateData)

contentType := strings.Split(c.GetHeader("Content-Type"), ";")
var err error
Expand All @@ -83,18 +100,21 @@ func (s *Server) HTTPReleaseSmContext(c *gin.Context) {
case MULTIPART_RELATED:
err = c.ShouldBindWith(&request, openapi.MultipartRelatedBinding{})
}

if err != nil {
log.Print(err)
problemDetail := "[Request Body] " + err.Error()
rsp := models.ProblemDetails{
Title: "Malformed request syntax",
Status: http.StatusBadRequest,
Detail: problemDetail,
}
logger.PduSessLog.Errorln(problemDetail)
c.JSON(http.StatusBadRequest, rsp)
return
}

smContextRef := c.Params.ByName("smContextRef")
s.Processor().HandlePDUSessionSMContextRelease(c, request, smContextRef)
}

// RetrieveSmContext - Retrieve SM Context
func (s *Server) RetrieveSmContext(c *gin.Context) {
c.JSON(http.StatusNotImplemented, gin.H{})
isDone := c.Done()
s.Processor().HandlePDUSessionSMContextCreate(c, request, isDone)
}

// HTTPUpdateSmContext - Update SM Context
Expand All @@ -120,17 +140,16 @@ func (s *Server) HTTPUpdateSmContext(c *gin.Context) {
s.Processor().HandlePDUSessionSMContextUpdate(c, request, smContextRef)
}

// PostPduSessions - Create
func (s *Server) PostPduSessions(c *gin.Context) {
// HTTPRetrieveSmContext - Retrieve SM Context
func (s *Server) HTTPRetrieveSmContext(c *gin.Context) {
c.JSON(http.StatusNotImplemented, gin.H{})
}

// HTTPPostSmContexts - Create SM Context
func (s *Server) HTTPPostSmContexts(c *gin.Context) {
logger.PduSessLog.Info("Receive Create SM Context Request")
var request models.PostSmContextsRequest

request.JsonData = new(models.SmfPduSessionSmContextCreateData)
// HTTPReleaseSmContext - Release SM Context
func (s *Server) HTTPReleaseSmContext(c *gin.Context) {
logger.PduSessLog.Info("Receive Release SM Context Request")
var request models.ReleaseSmContextRequest
request.JsonData = new(models.SmfPduSessionSmContextReleaseData)

contentType := strings.Split(c.GetHeader("Content-Type"), ";")
var err error
Expand All @@ -140,19 +159,38 @@ func (s *Server) HTTPPostSmContexts(c *gin.Context) {
case MULTIPART_RELATED:
err = c.ShouldBindWith(&request, openapi.MultipartRelatedBinding{})
}

if err != nil {
problemDetail := "[Request Body] " + err.Error()
rsp := models.ProblemDetails{
Title: "Malformed request syntax",
Status: http.StatusBadRequest,
Detail: problemDetail,
}
logger.PduSessLog.Errorln(problemDetail)
c.JSON(http.StatusBadRequest, rsp)
log.Print(err)
return
}

isDone := c.Done()
s.Processor().HandlePDUSessionSMContextCreate(c, request, isDone)
smContextRef := c.Params.ByName("smContextRef")
s.Processor().HandlePDUSessionSMContextRelease(c, request, smContextRef)
}

func (s *Server) HTTPSendMoData(c *gin.Context) {
c.JSON(http.StatusNotImplemented, gin.H{})
}

// HTTPPostPduSessions - Create
func (s *Server) HTTPPostPduSessions(c *gin.Context) {
c.JSON(http.StatusNotImplemented, gin.H{})
}

// HTTPUpdatePduSession - Update (initiated by V-SMF)
func (s *Server) HTTPUpdatePduSession(c *gin.Context) {
c.JSON(http.StatusNotImplemented, gin.H{})
}

// HTTPReleasePduSession - Release
func (s *Server) HTTPReleasePduSession(c *gin.Context) {
c.JSON(http.StatusNotImplemented, gin.H{})
}

func (s *Server) HTTPRetrievePduSession(c *gin.Context) {
c.JSON(http.StatusNotImplemented, gin.H{})
}

func (s *Server) HTTPTransferMoData(c *gin.Context) {
c.JSON(http.StatusNotImplemented, gin.H{})
}
4 changes: 4 additions & 0 deletions internal/sbi/api_upi.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,27 @@ import (
func (s *Server) getUPIRoutes() []Route {
return []Route{
{
Name: "Index",
Method: http.MethodGet,
Pattern: "/",
APIFunc: func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"status": "Service Available"})
},
},
{
Name: "GetUpNodesLinks",
Method: http.MethodGet,
Pattern: "/upNodesLinks",
APIFunc: s.GetUpNodesLinks,
},
{
Name: "AddUpNodesLinks",
Method: http.MethodPost,
Pattern: "/upNodesLinks",
APIFunc: s.PostUpNodesLinks,
},
{
Name: "DeleteUpNodeLink",
Method: http.MethodDelete,
Pattern: "/upNodesLinks/:upNodeRef",
APIFunc: s.DeleteUpNodeLink,
Expand Down
1 change: 1 addition & 0 deletions internal/sbi/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package sbi
import "github.com/gin-gonic/gin"

type Route struct {
Name string
Method string
Pattern string
APIFunc gin.HandlerFunc
Expand Down

0 comments on commit 17e0bc2

Please sign in to comment.