/
general.go
38 lines (31 loc) · 1.06 KB
/
general.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
34
35
36
37
38
//
// Copyright (C) 2021 IOTech Ltd
// Copyright (C) 2023 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
package http
import (
"context"
"github.com/edgexfoundry/go-mod-core-contracts/v3/clients/http/utils"
"github.com/edgexfoundry/go-mod-core-contracts/v3/clients/interfaces"
"github.com/edgexfoundry/go-mod-core-contracts/v3/common"
dtoCommon "github.com/edgexfoundry/go-mod-core-contracts/v3/dtos/common"
"github.com/edgexfoundry/go-mod-core-contracts/v3/errors"
)
type generalClient struct {
baseUrl string
authInjector interfaces.AuthenticationInjector
}
func NewGeneralClient(baseUrl string, authInjector interfaces.AuthenticationInjector) interfaces.GeneralClient {
return &generalClient{
baseUrl: baseUrl,
authInjector: authInjector,
}
}
func (g *generalClient) FetchConfiguration(ctx context.Context) (res dtoCommon.ConfigResponse, err errors.EdgeX) {
err = utils.GetRequest(ctx, &res, g.baseUrl, common.ApiConfigRoute, nil, g.authInjector)
if err != nil {
return res, errors.NewCommonEdgeXWrapper(err)
}
return res, nil
}