// O-RAN-SC
// %%
// Copyright (C) 2022: Nordix Foundation
+// Copyright (C) 2023: OpenInfra Foundation Europe.
// %%
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
package discoverservice
import (
+ "fmt"
"net/http"
"oransc.org/nonrtric/capifcore/internal/common29122"
func (ds *DiscoverService) GetAllServiceAPIs(ctx echo.Context, params discoverapi.GetAllServiceAPIsParams) error {
allApis := ds.invokerRegister.GetInvokerApiList(params.ApiInvokerId)
if allApis == nil {
- return sendCoreError(ctx, http.StatusNotFound, "Invoker not registered")
+ return sendCoreError(ctx, http.StatusNotFound, fmt.Sprintf("Invoker %s not registered", params.ApiInvokerId))
}
+
filteredApis := []publishapi.ServiceAPIDescription{}
- gatewayDomain := "r1-expo-func-aef"
for _, api := range *allApis {
- if !matchesFilter(api, params) {
- continue
- }
- profiles := *api.AefProfiles
- for i, profile := range profiles {
- profile.DomainName = &gatewayDomain // Hardcoded for now. Should be provided through some other mechanism.
- profiles[i] = profile
+ if matchesFilter(api, params) {
+ filteredApis = append(filteredApis, api)
}
- filteredApis = append(filteredApis, api)
}
discoveredApis := discoverapi.DiscoveredAPIs{
ServiceAPIDescriptions: &filteredApis,
}
func checkCommType(resources *[]publishapi.Resource, commType *publishapi.CommunicationType) bool {
- match := false
- if commType != nil {
- for _, resource := range *resources {
- if resource.CommType == *commType {
- match = true
- break
- }
+ for _, resource := range *resources {
+ if resource.CommType == *commType {
+ return true
}
- } else {
- match = true
}
- return match
+ return false
}
// This function wraps sending of an error in the Error format, and