Skip to content

Commit

Permalink
Update nf_management.go (#2)
Browse files Browse the repository at this point in the history
NF Management put should support update and shall return 200/OK
  • Loading branch information
umutsahin authored Aug 27, 2021
1 parent 8297ca8 commit e74af1f
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions producer/nf_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,13 @@ func HandleNFRegisterRequest(request *http_wrapper.Request) *http_wrapper.Respon
logger.ManagementLog.Infoln("Handle NFRegisterRequest")
nfProfile := request.Body.(models.NfProfile)

header, response, problemDetails := NFRegisterProcedure(nfProfile)
header, response, isUpdate, problemDetails := NFRegisterProcedure(nfProfile)

if response != nil {
if isUpdate {
logger.ManagementLog.Traceln("update success")
return http_wrapper.NewResponse(http.StatusOK, header, response)
}
logger.ManagementLog.Traceln("register success")
return http_wrapper.NewResponse(http.StatusCreated, header, response)
} else if problemDetails != nil {
Expand Down Expand Up @@ -309,7 +313,7 @@ func GetNFInstanceProcedure(nfInstanceID string) (response map[string]interface{
}

func NFRegisterProcedure(nfProfile models.NfProfile) (header http.Header, response bson.M,
problemDetails *models.ProblemDetails) {
update bool, problemDetails *models.ProblemDetails) {
logger.ManagementLog.Traceln("[NRF] In NFRegisterProcedure")
var nf models.NfProfile

Expand All @@ -321,7 +325,7 @@ func NFRegisterProcedure(nfProfile models.NfProfile) (header http.Header, respon
Status: http.StatusBadRequest,
Detail: str1,
}
return nil, nil, problemDetails
return nil, nil, false, problemDetails
}

// make location header
Expand Down Expand Up @@ -354,13 +358,13 @@ func NFRegisterProcedure(nfProfile models.NfProfile) (header http.Header, respon
for _, uri := range uriList {
problemDetails = SendNFStatusNotify(Notification_event, nfInstanceUri, uri)
if problemDetails != nil {
return nil, nil, problemDetails
return nil, nil, true, problemDetails
}
}

header = make(http.Header)
header.Add("Location", locationHeaderValue)
return header, putData, nil
return header, putData, true, nil
} else { // Create NF Profile case
logger.ManagementLog.Infoln("Create NF Profile")
uriList := nrf_context.GetNofificationUri(nf)
Expand All @@ -371,14 +375,14 @@ func NFRegisterProcedure(nfProfile models.NfProfile) (header http.Header, respon
for _, uri := range uriList {
problemDetails = SendNFStatusNotify(Notification_event, nfInstanceUri, uri)
if problemDetails != nil {
return nil, nil, problemDetails
return nil, nil, false, problemDetails
}
}

header = make(http.Header)
header.Add("Location", locationHeaderValue)
logger.ManagementLog.Infoln("Location header: ", locationHeaderValue)
return header, putData, nil
return header, putData, false, nil
}
}

Expand Down

0 comments on commit e74af1f

Please sign in to comment.