diff --git a/go-apps/meep-app-enablement/server/capif-mgmt/service-mgmt.go b/go-apps/meep-app-enablement/server/capif-mgmt/service-mgmt.go index 963261462717eac1aa8342046a814304289ab45d..8264467fdf3e97ea97e899c8e0baa9fc2e59ac66 100644 --- a/go-apps/meep-app-enablement/server/capif-mgmt/service-mgmt.go +++ b/go-apps/meep-app-enablement/server/capif-mgmt/service-mgmt.go @@ -411,8 +411,8 @@ func appServicesByIdPUT(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") log.Info("appServicesByIdPUT") vars := mux.Vars(r) - appId := vars["appInstanceId"] - svcId := vars["serviceId"] + svcId := vars["serviceApiId"] + appId := vars["apfId"] mutex.Lock() defer mutex.Unlock() @@ -454,10 +454,12 @@ func appServicesByIdPUT(w http.ResponseWriter, r *http.Request) { } // NOTE: Set default values for omitted fields locality := MEC_HOST_LocalityType - sInfo := ServiceInfo{ - ScopeOfLocality: &locality, - IsLocal: true, - ConsumedLocalOnly: true, + sInfo := ServiceApiDescription{ + VendorSpecificUrnetsimeccapifextserviceInfo: &MecServiceInfoCapifExt{ + ScopeOfLocality: &locality, + IsLocal: true, + ConsumedLocalOnly: true, + }, } decoder := json.NewDecoder(r.Body) err = decoder.Decode(&sInfo) @@ -467,13 +469,64 @@ func appServicesByIdPUT(w http.ResponseWriter, r *http.Request) { return } + aefProfile := &AefProfile{ + AefId: sInfo.AefProfiles[0].AefId, + Versions: sInfo.AefProfiles[0].Versions, + InterfaceDescriptions: sInfo.AefProfiles[0].InterfaceDescriptions, + VendorSpecificUrnetsimeccapifexttransportInfo: &MecTransportInfoCapifExt{ + Name: sInfo.AefProfiles[0].VendorSpecificUrnetsimeccapifexttransportInfo.Name, + Type_: sInfo.AefProfiles[0].VendorSpecificUrnetsimeccapifexttransportInfo.Type_, + Protocol: sInfo.AefProfiles[0].VendorSpecificUrnetsimeccapifexttransportInfo.Protocol, + Version: sInfo.AefProfiles[0].VendorSpecificUrnetsimeccapifexttransportInfo.Version, + Security: sInfo.AefProfiles[0].VendorSpecificUrnetsimeccapifexttransportInfo.Security, + }, + } + dsInfo := &ServiceApiDescription{ + ApiName: sInfo.ApiName, + ApiId: uuid.New().String(), + AefProfiles: []AefProfile{*aefProfile}, + VendorSpecificUrnetsimeccapifextserviceInfo: &MecServiceInfoCapifExt{ + Serializer: sInfo.VendorSpecificUrnetsimeccapifextserviceInfo.Serializer, + State: sInfo.VendorSpecificUrnetsimeccapifextserviceInfo.State, + ScopeOfLocality: sInfo.VendorSpecificUrnetsimeccapifextserviceInfo.ScopeOfLocality, + ConsumedLocalOnly: sInfo.VendorSpecificUrnetsimeccapifextserviceInfo.ConsumedLocalOnly, + IsLocal: sInfo.VendorSpecificUrnetsimeccapifextserviceInfo.IsLocal, + Category: sInfo.VendorSpecificUrnetsimeccapifextserviceInfo.Category, + }, + } + + transportInfo_ := TransportInfo{ + Id: sInfo.AefProfiles[0].AefId, + Name: sInfo.AefProfiles[0].VendorSpecificUrnetsimeccapifexttransportInfo.Name, + Type_: sInfo.AefProfiles[0].VendorSpecificUrnetsimeccapifexttransportInfo.Type_, + Protocol: sInfo.AefProfiles[0].VendorSpecificUrnetsimeccapifexttransportInfo.Protocol, + Version: sInfo.AefProfiles[0].VendorSpecificUrnetsimeccapifexttransportInfo.Version, + Endpoint: sInfo.AefProfiles[0].InterfaceDescriptions, + Security: sInfo.AefProfiles[0].VendorSpecificUrnetsimeccapifexttransportInfo.Security, + } + + // Create Service + _sInfo := ServiceInfo{ + SerInstanceId: dsInfo.ApiId, + SerName: dsInfo.ApiName, + SerCategory: dsInfo.VendorSpecificUrnetsimeccapifextserviceInfo.Category, + Version: dsInfo.AefProfiles[0].Versions[0], + State: dsInfo.VendorSpecificUrnetsimeccapifextserviceInfo.State, + TransportInfo: &transportInfo_, + Serializer: dsInfo.VendorSpecificUrnetsimeccapifextserviceInfo.Serializer, + ScopeOfLocality: dsInfo.VendorSpecificUrnetsimeccapifextserviceInfo.ScopeOfLocality, + ConsumedLocalOnly: dsInfo.VendorSpecificUrnetsimeccapifextserviceInfo.ConsumedLocalOnly, + IsLocal: dsInfo.VendorSpecificUrnetsimeccapifextserviceInfo.IsLocal, + LivenessInterval: 0, + } + // Current implementation only supports state parameter change; // Make sure none of the other service information fields have changed - state := *sInfo.State - *sInfo.State = *sInfoPrev.State + state := *_sInfo.State + *_sInfo.State = *sInfoPrev.State // isLocal is only set in responses, subscriptions and notifications; // Ignore this field while comparing the previous & new service info structs - sInfo.IsLocal = sInfoPrev.IsLocal + _sInfo.IsLocal = sInfoPrev.IsLocal // Compare service information as JSON strings /* FSCOM: It is not specified that only the ServiceInfo state property may be changed in ETSI GS MEC 011 V3.2.1 (2024-04) @@ -486,9 +539,9 @@ func appServicesByIdPUT(w http.ResponseWriter, r *http.Request) { }*/ // Compare service info states & update DB if necessary - *sInfo.State = state - if *sInfo.State != *sInfoPrev.State { - err, retCode := setService(appId, &sInfo, STATE_CHANGED_ServiceAvailabilityNotificationChangeType) + *_sInfo.State = state + if *_sInfo.State != *sInfoPrev.State { + err, retCode := setService(appId, &_sInfo, STATE_CHANGED_ServiceAvailabilityNotificationChangeType) if err != nil { log.Error(err.Error()) errHandlerProblemDetails(w, err.Error(), retCode) @@ -497,24 +550,24 @@ func appServicesByIdPUT(w http.ResponseWriter, r *http.Request) { } // Compare LivenessInterval - if sInfo.LivenessInterval != sInfoPrev.LivenessInterval { - if _, ok := livenessTimerList[sInfo.SerInstanceId]; ok { // An entry already exist - if sInfo.LivenessInterval != 0 { // update it - updateLivenessTicker(sInfo) + if _sInfo.LivenessInterval != sInfoPrev.LivenessInterval { + if _, ok := livenessTimerList[_sInfo.SerInstanceId]; ok { // An entry already exist + if _sInfo.LivenessInterval != 0 { // update it + updateLivenessTicker(_sInfo) } else { - deleteLivenessTicker(sInfo.SerInstanceId) + deleteLivenessTicker(_sInfo.SerInstanceId) } } else { // No entry - if sInfo.LivenessInterval != 0 { // Create a new entry - createLivenessTicker(sInfo) + if _sInfo.LivenessInterval != 0 { // Create a new entry + createLivenessTicker(_sInfo) } } } // else, nothing to do - sInfo.LivenessInterval = sInfoPrev.LivenessInterval + _sInfo.LivenessInterval = sInfoPrev.LivenessInterval // Send response w.WriteHeader(http.StatusOK) - fmt.Fprint(w, convertServiceInfoToJson(&sInfo)) + fmt.Fprint(w, convertServiceInfoToJson_1(dsInfo)) } func appServicesByIdDELETE(w http.ResponseWriter, r *http.Request) { diff --git a/go-apps/meep-app-enablement/server/routers.go b/go-apps/meep-app-enablement/server/routers.go index 552bea469ecf2f4a152e5fdf9dee0d093bfcb2c8..f11334b72dde3c014069731ab1d1c68b7e6ffd2d 100644 --- a/go-apps/meep-app-enablement/server/routers.go +++ b/go-apps/meep-app-enablement/server/routers.go @@ -364,6 +364,13 @@ var routes = Routes{ capifMgmt.AppServicesServiceIdGET, }, + Route{ + "AppServicesServiceIdPUT", + strings.ToUpper("Put"), + "/published-apis/v1/{apfId}/service-apis/{serviceApiId}", + capifMgmt.AppServicesServiceIdPUT, + }, + Route{ "Index", "GET",