-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathapi.go
More file actions
39 lines (31 loc) · 944 Bytes
/
api.go
File metadata and controls
39 lines (31 loc) · 944 Bytes
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
39
// Copyright SAP SE
// SPDX-License-Identifier: Apache-2.0
package commitments
import (
"net/http"
"sync"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
)
// HTTPAPI implements Limes LIQUID commitment validation endpoints.
type HTTPAPI struct {
client client.Client
config Config
// Mutex to serialize change-commitments requests
changeMutex sync.Mutex
}
func NewAPI(client client.Client) *HTTPAPI {
return NewAPIWithConfig(client, DefaultConfig())
}
func NewAPIWithConfig(client client.Client, config Config) *HTTPAPI {
return &HTTPAPI{
client: client,
config: config,
}
}
func (api *HTTPAPI) Init(mux *http.ServeMux) {
mux.HandleFunc("/v1/commitments/change-commitments", api.HandleChangeCommitments)
mux.HandleFunc("/v1/report-capacity", api.HandleReportCapacity)
mux.HandleFunc("/v1/commitments/info", api.HandleInfo)
}
var commitmentApiLog = ctrl.Log.WithName("commitment_api")