Skip to content

Commit

Permalink
remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
KunLee76 committed Jun 12, 2024
1 parent 05102e0 commit 776c047
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 57 deletions.
32 changes: 0 additions & 32 deletions internal/sbi/api_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,39 +40,7 @@ func (s *Server) getSearchNFInstances(c *gin.Context) {
return
}

// req := httpwrapper.NewRequest(c.Request, nil)
// req.Query = c.Request.URL.Query()
// httpResponse := s.processor.HandleNFDiscoveryRequest(req)
query := c.Request.URL.Query()
s.Processor().NFDiscoveryProcedure(c, query)

Check failure on line 45 in internal/sbi/api_discovery.go

View workflow job for this annotation

GitHub Actions / lint (1.21)

File is not `gofumpt`-ed (gofumpt)
//--------------------第2層
//response, problemDetails := NFDiscoveryProcedure(url.Values(query))
// Send Response
// if response != nil {
// c.JSON(http.StatusOK, response)
// } else if problemDetails != nil {

// } else {
// problemDetails = &models.ProblemDetails{
// Status: http.StatusForbidden,
// Cause: "UNSPECIFIED",
// }
// c.JSON(http.StatusForbidden, problemDetails) // 問一下為什麼這個用不到
// }

//-------------------

// responseBody, err := openapi.Serialize(httpResponse.Body, "application/json")
// if err != nil {
// logger.DiscLog.Warnln(err)
// problemDetails := models.ProblemDetails{
// Status: http.StatusInternalServerError,
// Cause: "SYSTEM_FAILURE",
// Detail: err.Error(),
// }
// c.JSON(http.StatusInternalServerError, problemDetails)
// } else {
// c.Data(httpResponse.Status, "application/json", responseBody)
// }
}

Check failure on line 46 in internal/sbi/api_discovery.go

View workflow job for this annotation

GitHub Actions / lint (1.21)

unnecessary trailing newline (whitespace)
8 changes: 4 additions & 4 deletions internal/sbi/api_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (s *Server) getNFManagementRoutes() []Route {
}

// DeregisterNFInstance - Deregisters a given NF Instance
func (s *Server) DeregisterNFInstance(c *gin.Context) { // OK
func (s *Server) DeregisterNFInstance(c *gin.Context) {
auth_err := authorizationCheck(c, "nnrf-nfm")
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
Expand All @@ -85,7 +85,7 @@ func (s *Server) DeregisterNFInstance(c *gin.Context) { // OK
}

// GetNFInstance - Read the profile of a given NF Instance
func (s *Server) NFInstance(c *gin.Context) { // OK
func (s *Server) NFInstance(c *gin.Context) {
auth_err := authorizationCheck(c, "nnrf-nfm")
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
Expand All @@ -98,7 +98,7 @@ func (s *Server) NFInstance(c *gin.Context) { // OK
s.Processor().GetNFInstanceProcedure(c, nfInstanceId)
}

func (s *Server) RegisterNFInstance(c *gin.Context) { // OK
func (s *Server) RegisterNFInstance(c *gin.Context) {
auth_err := authorizationCheck(c, "nnrf-nfm")
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
Expand Down Expand Up @@ -164,7 +164,7 @@ func (s *Server) RegisterNFInstance(c *gin.Context) { // OK
}

// UpdateNFInstance - Update NF Instance profile
func (s *Server) getUpdateNFInstance(c *gin.Context) { // OK
func (s *Server) getUpdateNFInstance(c *gin.Context) {
auth_err := authorizationCheck(c, "nnrf-nfm")
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
Expand Down
4 changes: 0 additions & 4 deletions internal/sbi/processor/nfdiscovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ func (p *Processor) NFDiscoveryProcedure(c *gin.Context, queryParameters url.Val
Status: http.StatusBadRequest,
Cause: "Loss mandatory parameter",
}
// return nil, problemDetails
c.JSON(int(problemDetails.Status), problemDetails)
}

Expand All @@ -100,7 +99,6 @@ func (p *Processor) NFDiscoveryProcedure(c *gin.Context, queryParameters url.Val
{Param: "complexQuery"},
},
}
// return nil, problemDetails
c.JSON(int(problemDetails.Status), problemDetails)
}
}
Expand All @@ -121,7 +119,6 @@ func (p *Processor) NFDiscoveryProcedure(c *gin.Context, queryParameters url.Val
Detail: err.Error(),
Cause: "SYSTEM_FAILURE",
}
// return nil, problemDetails
c.JSON(int(problemDetails.Status), problemDetails)
}

Expand All @@ -135,7 +132,6 @@ func (p *Processor) NFDiscoveryProcedure(c *gin.Context, queryParameters url.Val
Detail: err.Error(),
Cause: "SYSTEM_FAILURE",
}
// return nil, problemDetails
c.JSON(int(problemDetails.Status), problemDetails)
}

Expand Down
19 changes: 2 additions & 17 deletions internal/sbi/processor/nfmanagement.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,28 @@ import (

func (p *Processor) HandleRemoveSubscriptionRequest(c *gin.Context, subscriptionID string) {
logger.NfmLog.Infoln("Handle RemoveSubscription")
// subscriptionID := request.Params["subscriptionID"]

RemoveSubscriptionProcedure(subscriptionID)

c.JSON(http.StatusNoContent, nil)
// return httpwrapper.NewResponse(http.StatusNoContent, nil, nil)
}

func (p *Processor) HandleCreateSubscriptionRequest(c *gin.Context, subscription models.NrfSubscriptionData) {
logger.NfmLog.Infoln("Handle CreateSubscriptionRequest")
// subscription := request.Body.(models.NrfSubscriptionData)

response, problemDetails := CreateSubscriptionProcedure(subscription)
if response != nil {
logger.NfmLog.Traceln("CreateSubscription success")
// return httpwrapper.NewResponse(http.StatusCreated, nil, response)
c.JSON(http.StatusCreated, response)
} else if problemDetails != nil {
logger.NfmLog.Traceln("CreateSubscription failed")
// return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails)
c.JSON(int(problemDetails.Status), problemDetails)
}
problemDetails = &models.ProblemDetails{
Status: http.StatusForbidden,
Cause: "UNSPECIFIED",
}
logger.NfmLog.Traceln("CreateSubscription failed")
// return httpwrapper.NewResponse(http.StatusForbidden, nil, problemDetails)
c.JSON(http.StatusForbidden, problemDetails)
}

Expand Down Expand Up @@ -101,7 +95,6 @@ func CreateSubscriptionProcedure(subscription models.NrfSubscriptionData) (bson.
}

func (p *Processor) UpdateSubscriptionProcedure(c *gin.Context, subscriptionID string, patchJSON []byte) {
// map[string]interface{} { //OK
collName := "Subscriptions"
filter := bson.M{"subscriptionId": subscriptionID}

Expand All @@ -113,13 +106,10 @@ func (p *Processor) UpdateSubscriptionProcedure(c *gin.Context, subscriptionID s
Detail: err.Error(),
}
c.JSON(http.StatusInternalServerError, problemDetails)
// return nil
} else {
if response, err := mongoapi.RestfulAPIGetOne(collName, filter); err == nil {
c.JSON(http.StatusOK, response)
// return response
}
// return nil
}
}

Expand All @@ -132,9 +122,9 @@ func RemoveSubscriptionProcedure(subscriptionID string) {
}
}

func (p *Processor) GetNFInstancesProcedure( // OK
func (p *Processor) GetNFInstancesProcedure(
c *gin.Context, nfType string, limit int,
) { // (*nrf_context.UriList, *models.ProblemDetails) {
) {
collName := "urilist"
filter := bson.M{"nfType": nfType}
if nfType == "" {
Expand All @@ -151,7 +141,6 @@ func (p *Processor) GetNFInstancesProcedure( // OK
Detail: err.Error(),
Cause: "SYSTEM_FAILURE",
}
// return nil, problemDetail
c.JSON(int(problemDetail.Status), problemDetail)
}
logger.NfmLog.Infoln("ULs: ", ULs)
Expand All @@ -167,9 +156,6 @@ func (p *Processor) GetNFInstancesProcedure( // OK
Cause: "SYSTEM_FAILURE",
}
c.JSON(http.StatusInternalServerError, problemDetail)
// return nil, problemDetail
// c.JSON(int(problemDetail.Status), problemDetail)
// c.Data(http.StatusInternalServerError, "application/json", []byte("error in GetNFInstancesProcedure"))
}
rspUriList.Link.Item = append(rspUriList.Link.Item, originalUL.Link.Item...)
if nfType != "" && rspUriList.NfType == "" {
Expand All @@ -178,7 +164,6 @@ func (p *Processor) GetNFInstancesProcedure( // OK
}

nrf_context.NnrfUriListLimit(rspUriList, limit)
// return rspUriList, nil
c.JSON(http.StatusOK, rspUriList)

logger.NfmLog.Traceln("GetNFInstances failed")
Expand Down

0 comments on commit 776c047

Please sign in to comment.