Commit d4c8cef3 authored by Ikram Haq's avatar Ikram Haq
Browse files

Implement logic to retrieves information about a mecService resource via CAPIF

parent 752196ee
Loading
Loading
Loading
Loading
+38 −20
Original line number Diff line number Diff line
@@ -253,9 +253,6 @@ func appServicesPOST(w http.ResponseWriter, r *http.Request) {
			IsLocal:           true,
			ConsumedLocalOnly: true,
		},
		// ScopeOfLocality:   &locality,
		// IsLocal:           true,
		// ConsumedLocalOnly: true,
	}
	decoder := json.NewDecoder(r.Body)
	err = decoder.Decode(&sInfoPost)
@@ -363,12 +360,12 @@ func appServicesPOST(w http.ResponseWriter, r *http.Request) {
	}

	transportInfo_ := TransportInfo{
		Id:       sInfoPost.AefProfiles[0].AefId, // Set this appropriately or generate it
		Id:       sInfoPost.AefProfiles[0].AefId,
		Name:     sInfoPost.AefProfiles[0].VendorSpecificUrnetsimeccapifexttransportInfo.Name,
		Type_:    sInfoPost.AefProfiles[0].VendorSpecificUrnetsimeccapifexttransportInfo.Type_,
		Protocol: sInfoPost.AefProfiles[0].VendorSpecificUrnetsimeccapifexttransportInfo.Protocol,
		Version:  sInfoPost.AefProfiles[0].VendorSpecificUrnetsimeccapifexttransportInfo.Version,
		Endpoint: sInfoPost.AefProfiles[0].InterfaceDescriptions, // Set the endpoint as required
		Endpoint: sInfoPost.AefProfiles[0].InterfaceDescriptions,
		Security: sInfoPost.AefProfiles[0].VendorSpecificUrnetsimeccapifexttransportInfo.Security,
	}

@@ -383,7 +380,6 @@ func appServicesPOST(w http.ResponseWriter, r *http.Request) {
		Serializer:        dsInfo.VendorSpecificUrnetsimeccapifextserviceInfo.Serializer,
		ScopeOfLocality:   dsInfo.VendorSpecificUrnetsimeccapifextserviceInfo.ScopeOfLocality,
		ConsumedLocalOnly: dsInfo.VendorSpecificUrnetsimeccapifextserviceInfo.ConsumedLocalOnly,
		// although IsLocal is reevaluated when a query is replied to, value stored in sInfo as is for now
		IsLocal:           dsInfo.VendorSpecificUrnetsimeccapifextserviceInfo.IsLocal,
		LivenessInterval:  0,
	}
@@ -615,8 +611,8 @@ func appServicesByIdGET(w http.ResponseWriter, r *http.Request) {
	log.Info("appServicesByIdGET")
	w.Header().Set("Content-Type", "application/json; charset=UTF-8")
	vars := mux.Vars(r)
	svcId := vars["serviceId"]
	appId := vars["appInstanceId"]
	svcId := vars["serviceApiId"]
	appId := vars["apfId"]

	mutex.Lock()
	defer mutex.Unlock()
@@ -1273,15 +1269,6 @@ func getServices(w http.ResponseWriter, r *http.Request, appId string) {
	}

	serName := q["api-name"]
	// var serName []string
	// if serNameParam != "" {
	// 	parsedParam, err := parseJSONQueryParam(serNameParam)
	// 	if err != nil {
	// 		errHandlerProblemDetails(w, "Invalid JSON in ser_name", http.StatusBadRequest)
	// 		return
	// 	}
	// 	serName = append(serName, parsedParam.Value)
	// }

	serCategoryIdParam := q.Get("vend-spec-etsi-mec-sercategory-id")
	var serCategoryId string
@@ -1450,8 +1437,39 @@ func getService(w http.ResponseWriter, r *http.Request, appId string, serviceId
		return
	}

	// Map ServiceInfoList to ServiceApiDescription list
	serviceApiDescriptions := make([]ServiceApiDescription, 0)
	for _, service := range sInfoList.Services {
		aefProfile := AefProfile{
			AefId:                 service.TransportInfo.Id,
			Versions:              []string{service.Version},
			InterfaceDescriptions: service.TransportInfo.Endpoint,
			VendorSpecificUrnetsimeccapifexttransportInfo: &MecTransportInfoCapifExt{
				Name:     service.TransportInfo.Name,
				Type_:    service.TransportInfo.Type_,
				Protocol: service.TransportInfo.Protocol,
				Version:  service.TransportInfo.Version,
				Security: service.TransportInfo.Security,
			},
		}
		apiDesc := ServiceApiDescription{
			ApiName:     service.SerName,
			ApiId:       service.SerInstanceId,
			AefProfiles: []AefProfile{aefProfile},
			VendorSpecificUrnetsimeccapifextserviceInfo: &MecServiceInfoCapifExt{
				Serializer:        service.Serializer,
				State:             service.State,
				ScopeOfLocality:   service.ScopeOfLocality,
				ConsumedLocalOnly: service.ConsumedLocalOnly,
				IsLocal:           service.IsLocal,
				Category:          service.SerCategory,
			},
		}
		serviceApiDescriptions = append(serviceApiDescriptions, apiDesc)
	}

	// Prepare & send response
	jsonResponse, err := json.Marshal(sInfoList.Services[0])
	jsonResponse, err := json.Marshal(serviceApiDescriptions)
	if err != nil {
		log.Error(err.Error())
		errHandlerProblemDetails(w, err.Error(), http.StatusInternalServerError)
+7 −0
Original line number Diff line number Diff line
@@ -357,6 +357,13 @@ var routes = Routes{
		capifMgmt.AppServicesPOST,
	},

	Route{
		"AppServicesServiceIdGET",
		strings.ToUpper("Get"),
		"/published-apis/v1/{apfId}/service-apis/{serviceId}",
		capifMgmt.AppServicesServiceIdGET,
	},

	Route{
		"Index",
		"GET",