-
Notifications
You must be signed in to change notification settings - Fork 3k
/
prefilter.go
39 lines (34 loc) · 1.16 KB
/
prefilter.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
39
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Cilium
package client
import (
"github.com/cilium/cilium/api/v1/client/prefilter"
"github.com/cilium/cilium/api/v1/models"
"github.com/cilium/cilium/pkg/api"
)
// GetPrefilter returns a list of all CIDR prefixes
func (c *Client) GetPrefilter() (*models.Prefilter, error) {
resp, err := c.Prefilter.GetPrefilter(nil)
if err != nil {
return nil, Hint(err)
}
return resp.Payload, nil
}
// PatchPrefilter sets a list of CIDR prefixes
func (c *Client) PatchPrefilter(spec *models.PrefilterSpec) (*models.Prefilter, error) {
params := prefilter.NewPatchPrefilterParams().WithPrefilterSpec(spec).WithTimeout(api.ClientTimeout)
resp, err := c.Prefilter.PatchPrefilter(params)
if err != nil {
return nil, Hint(err)
}
return resp.Payload, nil
}
// DeletePrefilter deletes a list of CIDR prefixes
func (c *Client) DeletePrefilter(spec *models.PrefilterSpec) (*models.Prefilter, error) {
params := prefilter.NewDeletePrefilterParams().WithPrefilterSpec(spec).WithTimeout(api.ClientTimeout)
resp, err := c.Prefilter.DeletePrefilter(params)
if err != nil {
return nil, Hint(err)
}
return resp.Payload, nil
}