Skip to content

Commit

Permalink
fix: change opanapi model in notifier
Browse files Browse the repository at this point in the history
  • Loading branch information
donald1218 committed Aug 11, 2024
1 parent 6e29b88 commit c13f70a
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 48 deletions.
2 changes: 1 addition & 1 deletion internal/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ type AMFContextEventSubscription struct {
IsGroupUe bool
UeSupiList []string
Expiry *time.Time
EventSubscription models.AmfEventSubscription
EventSubscription models.ExtAmfEventSubscription
}

type SecurityAlgorithm struct {
Expand Down
4 changes: 2 additions & 2 deletions internal/sbi/processor/callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
)

func (p *Processor) HandleSmContextStatusNotify(c *gin.Context,
smContextStatusNotification models.SmContextStatusNotification,
smContextStatusNotification models.SmfPduSessionSmContextStatusNotification,
) {
logger.ProducerLog.Infoln("[AMF] Handle SmContext Status Notify")

Expand All @@ -41,7 +41,7 @@ func (p *Processor) HandleSmContextStatusNotify(c *gin.Context,
}

func (p *Processor) SmContextStatusNotifyProcedure(supi string, pduSessionID int32,
smContextStatusNotification models.SmContextStatusNotification,
smContextStatusNotification models.SmfPduSessionSmContextStatusNotification,
) *models.ProblemDetails {
amfSelf := context.GetSelf()

Expand Down
60 changes: 29 additions & 31 deletions internal/sbi/processor/notifier/n1n2message.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,18 @@ func SendN1N2TransferFailureNotification(ue *amf_context.AmfUe, cause models.N1N
configuration := Namf_Communication.NewConfiguration()
client := Namf_Communication.NewAPIClient(configuration)

n1N2MsgTxfrFailureNotification := models.N1N2MsgTxfrFailureNotification{
Cause: cause,
N1n2MsgDataUri: n1n2Message.ResourceUri,
n1N2MsgTxfrFailureNotificationReq := Namf_Communication.N1N2TransferFailureNotificationRequest{
N1N2MsgTxfrFailureNotification: &models.N1N2MsgTxfrFailureNotification{
Cause: cause,
N1n2MsgDataUri: n1n2Message.ResourceUri,
},
}

httpResponse, err := client.N1N2MessageTransferStatusNotificationCallbackDocumentApi.
N1N2TransferFailureNotification(context.Background(), uri, n1N2MsgTxfrFailureNotification)
_, err := client.N1N2MessageCollectionCollectionApi.
N1N2TransferFailureNotification(context.Background(), uri, &n1N2MsgTxfrFailureNotificationReq)

if err != nil {
if httpResponse == nil {
HttpLog.Errorln(err.Error())
} else if err.Error() != httpResponse.Status {
HttpLog.Errorln(err.Error())
}
HttpLog.Errorln(err.Error())
} else {
ue.N1N2Message = nil
}
Expand Down Expand Up @@ -71,14 +69,14 @@ func SendN1MessageNotify(ue *amf_context.AmfUe, n1class models.N1MessageClass, n
},
BinaryDataN1Message: n1Msg,
}
httpResponse, err := client.N1MessageNotifyCallbackDocumentApiServiceCallbackDocumentApi.
N1MessageNotify(context.Background(), subscription.N1NotifyCallbackUri, n1MessageNotify)

n1MessageNotifyReq := Namf_Communication.N1MessageNotifyRequest{
N1MessageNotifyRequest: &n1MessageNotify,
}
_, err := client.N1N2SubscriptionsCollectionForIndividualUEContextsCollectionApi.
N1MessageNotify(context.Background(), subscription.N1NotifyCallbackUri, &n1MessageNotifyReq)
if err != nil {
if httpResponse == nil {
HttpLog.Errorln(err.Error())
} else if err.Error() != httpResponse.Status {
HttpLog.Errorln(err.Error())
}
HttpLog.Errorln(err.Error())
}
}
return true
Expand Down Expand Up @@ -106,6 +104,10 @@ func SendN1MessageNotifyAtAMFReAllocation(
BinaryDataN1Message: n1Msg,
}

n1MessageNotifyReq := Namf_Communication.N1MessageNotifyRequest{
N1MessageNotifyRequest: &n1MessageNotify,
}

var callbackUri string
for _, subscription := range ue.TargetAmfProfile.DefaultNotificationSubscriptions {
if subscription.NotificationType == models.NrfNfManagementNotificationType_N1_MESSAGES &&
Expand All @@ -115,14 +117,10 @@ func SendN1MessageNotifyAtAMFReAllocation(
}
}

httpResp, err := client.N1MessageNotifyCallbackDocumentApiServiceCallbackDocumentApi.
N1MessageNotify(context.Background(), callbackUri, n1MessageNotify)
_, err := client.N1N2SubscriptionsCollectionForIndividualUEContextsCollectionApi.
N1MessageNotify(context.Background(), callbackUri, &n1MessageNotifyReq)
if err != nil {
if httpResp == nil {
HttpLog.Errorln(err.Error())
} else if err.Error() != httpResp.Status {
HttpLog.Errorln(err.Error())
}
HttpLog.Errorln(err.Error())
return err
}
return nil
Expand Down Expand Up @@ -185,14 +183,14 @@ func SendN2InfoNotify(ue *amf_context.AmfUe, n2class models.N2InformationClass,
}
}

httpResponse, err := client.N2InfoNotifyCallbackDocumentApiServiceCallbackDocumentApi.
N2InfoNotify(context.Background(), subscription.N2NotifyCallbackUri, n2InformationNotify)
n2InformationNotifyReq := Namf_Communication.N2InfoNotifyRequest{
N2InfoNotifyRequest: &n2InformationNotify,
}

_, err := client.N1N2SubscriptionsCollectionForIndividualUEContextsCollectionApi.
N2InfoNotify(context.Background(), subscription.N2NotifyCallbackUri, &n2InformationNotifyReq)
if err != nil {
if httpResponse == nil {
HttpLog.Errorln(err.Error())
} else if err.Error() != httpResponse.Status {
HttpLog.Errorln(err.Error())
}
HttpLog.Errorln(err.Error())
}
}
return true
Expand Down
13 changes: 6 additions & 7 deletions internal/sbi/processor/notifier/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,14 @@ func SendAmfStatusChangeNotify(amfStatus string, guamiList []models.Guami) {
amfStatusNotification.AmfStatusInfoList = append(amfStatusNotification.AmfStatusInfoList, amfStatusInfo)
uri := subscriptionData.AmfStatusUri

amfStatusNotificationReq := Namf_Communication.AmfStatusChangeNOtifyRequest{
AmfStatusChangeNotification: &amfStatusNotification,
}
logger.ProducerLog.Infof("[AMF] Send Amf Status Change Notify to %s", uri)
httpResponse, err := client.AmfStatusChangeCallbackDocumentApiServiceCallbackDocumentApi.
AmfStatusChangeNotify(context.Background(), uri, amfStatusNotification)
_, err := client.IndividualSubscriptionDocumentApi.
AmfStatusChangeNOtify(context.Background(), uri, &amfStatusNotificationReq)
if err != nil {
if httpResponse == nil {
HttpLog.Errorln(err.Error())
} else if err.Error() != httpResponse.Status {
HttpLog.Errorln(err.Error())
}
HttpLog.Errorln(err.Error())
}
return true
})
Expand Down
15 changes: 8 additions & 7 deletions internal/sbi/processor/notifier/ue_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,18 @@ func SendN2InfoNotifyN2Handover(ue *amf_context.AmfUe, releaseList []int32) erro
NotifyReason: models.N2InfoNotifyReason_HANDOVER_COMPLETED,
}

_, httpResponse, err := client.N2MessageNotifyCallbackDocumentApiServiceCallbackDocumentApi.
N2InfoNotify(context.Background(), ue.HandoverNotifyUri, n2InformationNotification)
n2InformationNotificationReq := Namf_Communication.N2InfoNotifyHandoverCompleteRequest{
N2InformationNotification: &n2InformationNotification,
}

_, err := client.IndividualUeContextDocumentApi.
N2InfoNotifyHandoverComplete(context.Background(), ue.HandoverNotifyUri, &n2InformationNotificationReq)

if err == nil {
// TODO: handle Msg
} else {
if httpResponse == nil {
HttpLog.Errorln(err.Error())
} else if err.Error() != httpResponse.Status {
HttpLog.Errorln(err.Error())
}
HttpLog.Errorln(err.Error())
return err
}
return nil
}

0 comments on commit c13f70a

Please sign in to comment.