-
Notifications
You must be signed in to change notification settings - Fork 0
/
nf_discovery.go
33 lines (27 loc) · 1022 Bytes
/
nf_discovery.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package consumer
import (
"context"
"fmt"
"github.com/nycu-ucr/gonet/http"
"github.com/nycu-ucr/openapi/Nnrf_NFDiscovery"
"github.com/nycu-ucr/openapi/models"
"github.com/nycu-ucr/udr/logger"
)
func SendSearchNFInstances(nrfUri string, targetNfType, requestNfType models.NfType,
param Nnrf_NFDiscovery.SearchNFInstancesParamOpts) (models.SearchResult, error) {
// Set client and set url
configuration := Nnrf_NFDiscovery.NewConfiguration()
configuration.SetBasePath(nrfUri)
client := Nnrf_NFDiscovery.NewAPIClient(configuration)
var res *http.Response
result, res, err := client.NFInstancesStoreApi.SearchNFInstances(context.TODO(), targetNfType, requestNfType, ¶m)
if res != nil && res.StatusCode == http.StatusTemporaryRedirect {
err = fmt.Errorf("Temporary Redirect For Non NRF Consumer")
}
defer func() {
if rspCloseErr := res.Body.Close(); rspCloseErr != nil {
logger.ConsumerLog.Errorf("SearchNFInstances response body cannot close: %+v", rspCloseErr)
}
}()
return result, err
}