diff --git a/internal/sbi/consumer/pcf_service.go b/internal/sbi/consumer/pcf_service.go index e884a1f..3f780a9 100644 --- a/internal/sbi/consumer/pcf_service.go +++ b/internal/sbi/consumer/pcf_service.go @@ -1,7 +1,6 @@ package consumer import ( - "context" "net/http" "strings" "sync" @@ -65,8 +64,13 @@ func (s *npcfService) GetAppSession(appSessionId string) (int, interface{}) { } client := s.getClient(uri) + ctx, _, err := s.consumer.Context().GetTokenCtx(models.ServiceName_NPCF_POLICYAUTHORIZATION, models.NfType_PCF) + if err != nil { + return rspCode, rspBody + } + result, rsp, err = client.IndividualApplicationSessionContextDocumentApi. - GetAppSession(context.Background(), appSessionId) + GetAppSession(ctx, appSessionId) if rsp != nil { defer func() { @@ -108,7 +112,12 @@ func (s *npcfService) PostAppSessions(asc *models.AppSessionContext) (int, inter } client := s.getClient(uri) - result, rsp, err = client.ApplicationSessionsCollectionApi.PostAppSessions(context.TODO(), *asc) + ctx, _, err := s.consumer.Context().GetTokenCtx(models.ServiceName_NPCF_POLICYAUTHORIZATION, models.NfType_PCF) + if err != nil { + return rspCode, rspBody, appSessID + } + + result, rsp, err = client.ApplicationSessionsCollectionApi.PostAppSessions(ctx, *asc) if rsp != nil { defer func() { if rsp.Request.Response != nil { @@ -155,9 +164,14 @@ func (s *npcfService) PutAppSession( } client := s.getClient(uri) + ctx, _, err := s.consumer.Context().GetTokenCtx(models.ServiceName_NPCF_POLICYAUTHORIZATION, models.NfType_PCF) + if err != nil { + return rspCode, rspBody, appSessID + } + appSessID = appSessionId result, rsp, err = client.IndividualApplicationSessionContextDocumentApi. - GetAppSession(context.Background(), appSessionId) + GetAppSession(ctx, appSessionId) if rsp != nil { if rsp.Body != nil { if bodyCloseErr := rsp.Body.Close(); bodyCloseErr != nil { @@ -169,7 +183,7 @@ func (s *npcfService) PutAppSession( if rsp.StatusCode == http.StatusOK { // Patch result, rsp, err = client.IndividualApplicationSessionContextDocumentApi.ModAppSession( - context.Background(), appSessionId, *ascUpdateData) + ctx, appSessionId, *ascUpdateData) if rsp != nil { defer func() { if rsp.Request.Response != nil { @@ -224,8 +238,13 @@ func (s *npcfService) PatchAppSession(appSessionId string, } client := s.getClient(uri) + ctx, _, err := s.consumer.Context().GetTokenCtx(models.ServiceName_NPCF_POLICYAUTHORIZATION, models.NfType_PCF) + if err != nil { + return rspCode, rspBody + } + result, rsp, err = client.IndividualApplicationSessionContextDocumentApi.ModAppSession( - context.Background(), appSessionId, *ascUpdateData) + ctx, appSessionId, *ascUpdateData) if rsp != nil { defer func() { if rsp.Request.Response != nil { @@ -270,8 +289,13 @@ func (s *npcfService) DeleteAppSession(appSessionId string) (int, interface{}) { EventsSubscReqData: optional.NewInterface(models.EventsSubscReqData{}), } + ctx, _, err := s.consumer.Context().GetTokenCtx(models.ServiceName_NPCF_POLICYAUTHORIZATION, models.NfType_PCF) + if err != nil { + return rspCode, rspBody + } + result, rsp, err = client.IndividualApplicationSessionContextDocumentApi.DeleteAppSession( - context.Background(), appSessionId, param) + ctx, appSessionId, param) if rsp != nil { defer func() { if rsp.Request.Response != nil { diff --git a/internal/sbi/consumer/udr_service.go b/internal/sbi/consumer/udr_service.go index 610d998..cf6f7a0 100644 --- a/internal/sbi/consumer/udr_service.go +++ b/internal/sbi/consumer/udr_service.go @@ -1,7 +1,6 @@ package consumer import ( - "context" "net/http" "sync" @@ -68,8 +67,13 @@ func (s *nudrService) AppDataInfluenceDataGet(influenceIDs []string) (int, inter InfluenceIds: optional.NewInterface(influenceIDs), } + ctx, _, err := s.consumer.Context().GetTokenCtx(models.ServiceName_NUDR_DR, models.NfType_UDR) + if err != nil { + return rspCode, rspBody + } + result, rsp, err = client.InfluenceDataApi. - ApplicationDataInfluenceDataGet(context.Background(), param) + ApplicationDataInfluenceDataGet(ctx, param) if rsp != nil { defer func() { if rsp.Request.Response != nil { @@ -113,8 +117,13 @@ func (s *nudrService) AppDataInfluenceDataIdGet(influenceID string) (int, interf InfluenceIds: optional.NewInterface(influenceID), } + ctx, _, err := s.consumer.Context().GetTokenCtx(models.ServiceName_NUDR_DR, models.NfType_UDR) + if err != nil { + return rspCode, rspBody + } + result, rsp, err = client.InfluenceDataApi. - ApplicationDataInfluenceDataGet(context.Background(), param) + ApplicationDataInfluenceDataGet(ctx, param) if rsp != nil { defer func() { if rsp.Request.Response != nil { @@ -156,8 +165,13 @@ func (s *nudrService) AppDataInfluenceDataPut(influenceID string, } client := s.getClient(uri) + ctx, _, err := s.consumer.Context().GetTokenCtx(models.ServiceName_NUDR_DR, models.NfType_UDR) + if err != nil { + return rspCode, rspBody + } + result, rsp, err = client.IndividualInfluenceDataDocumentApi. - ApplicationDataInfluenceDataInfluenceIdPut(context.TODO(), influenceID, *tiData) + ApplicationDataInfluenceDataInfluenceIdPut(ctx, influenceID, *tiData) if rsp != nil { defer func() { if rsp.Request.Response != nil { @@ -202,7 +216,12 @@ func (s *nudrService) AppDataPfdsGet(appIDs []string) (int, interface{}) { AppId: optional.NewInterface(appIDs), } - result, rsp, err = client.DefaultApi.ApplicationDataPfdsGet(context.TODO(), param) + ctx, _, err := s.consumer.Context().GetTokenCtx(models.ServiceName_NUDR_DR, models.NfType_UDR) + if err != nil { + return rspCode, rspBody + } + + result, rsp, err = client.DefaultApi.ApplicationDataPfdsGet(ctx, param) if rsp != nil { defer func() { if rsp.Request.Response != nil { @@ -243,7 +262,12 @@ func (s *nudrService) AppDataPfdsAppIdPut(appID string, pfdDataForApp *models.Pf } client := s.getClient(uri) - result, rsp, err = client.DefaultApi.ApplicationDataPfdsAppIdPut(context.TODO(), appID, *pfdDataForApp) + ctx, _, err := s.consumer.Context().GetTokenCtx(models.ServiceName_NUDR_DR, models.NfType_UDR) + if err != nil { + return rspCode, rspBody + } + + result, rsp, err = client.DefaultApi.ApplicationDataPfdsAppIdPut(ctx, appID, *pfdDataForApp) if rsp != nil { defer func() { if rsp.Request.Response != nil { @@ -283,7 +307,12 @@ func (s *nudrService) AppDataPfdsAppIdDelete(appID string) (int, interface{}) { } client := s.getClient(uri) - rsp, err = client.DefaultApi.ApplicationDataPfdsAppIdDelete(context.TODO(), appID) + ctx, _, err := s.consumer.Context().GetTokenCtx(models.ServiceName_NUDR_DR, models.NfType_UDR) + if err != nil { + return rspCode, rspBody + } + + rsp, err = client.DefaultApi.ApplicationDataPfdsAppIdDelete(ctx, appID) if rsp != nil { defer func() { if rsp.Request.Response != nil { @@ -322,7 +351,12 @@ func (s *nudrService) AppDataPfdsAppIdGet(appID string) (int, interface{}) { } client := s.getClient(uri) - result, rsp, err = client.DefaultApi.ApplicationDataPfdsAppIdGet(context.TODO(), appID) + ctx, _, err := s.consumer.Context().GetTokenCtx(models.ServiceName_NUDR_DR, models.NfType_UDR) + if err != nil { + return rspCode, rspBody + } + + result, rsp, err = client.DefaultApi.ApplicationDataPfdsAppIdGet(ctx, appID) if rsp != nil { defer func() { if rsp.Request.Response != nil { @@ -364,8 +398,13 @@ func (s *nudrService) AppDataInfluenceDataPatch( } client := s.getClient(uri) + ctx, _, err := s.consumer.Context().GetTokenCtx(models.ServiceName_NUDR_DR, models.NfType_UDR) + if err != nil { + return rspCode, rspBody + } + result, rsp, err = client.IndividualInfluenceDataDocumentApi. - ApplicationDataInfluenceDataInfluenceIdPatch(context.Background(), influenceID, *tiSubPatch) + ApplicationDataInfluenceDataInfluenceIdPatch(ctx, influenceID, *tiSubPatch) if rsp != nil { defer func() { if rsp.Request.Response != nil { @@ -404,8 +443,13 @@ func (s *nudrService) AppDataInfluenceDataDelete(influenceID string) (int, inter } client := s.getClient(uri) + ctx, _, err := s.consumer.Context().GetTokenCtx(models.ServiceName_NUDR_DR, models.NfType_UDR) + if err != nil { + return rspCode, rspBody + } + rsp, err = client.IndividualInfluenceDataDocumentApi. - ApplicationDataInfluenceDataInfluenceIdDelete(context.Background(), influenceID) + ApplicationDataInfluenceDataInfluenceIdDelete(ctx, influenceID) if rsp != nil { defer func() { if rsp.Request.Response != nil {