diff options
Diffstat (limited to 'client/client.go')
-rw-r--r-- | client/client.go | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/client/client.go b/client/client.go index c571facd..4a94ac4a 100644 --- a/client/client.go +++ b/client/client.go @@ -535,8 +535,11 @@ func (cli *Client) DeleteVRF(name string) error { return err } -func (cli *Client) GetDefinedSet(typ table.DefinedType) ([]table.DefinedSet, error) { - ret, err := cli.cli.GetDefinedSet(context.Background(), &api.GetDefinedSetRequest{Type: api.DefinedType(typ)}) +func (cli *Client) getDefinedSet(typ table.DefinedType, name string) ([]table.DefinedSet, error) { + ret, err := cli.cli.GetDefinedSet(context.Background(), &api.GetDefinedSetRequest{ + Type: api.DefinedType(typ), + Name: name, + }) if err != nil { return nil, err } @@ -551,6 +554,23 @@ func (cli *Client) GetDefinedSet(typ table.DefinedType) ([]table.DefinedSet, err return ds, nil } +func (cli *Client) GetDefinedSet(typ table.DefinedType) ([]table.DefinedSet, error) { + return cli.getDefinedSet(typ, "") +} + +func (cli *Client) GetDefinedSetByName(typ table.DefinedType, name string) (table.DefinedSet, error) { + sets, err := cli.getDefinedSet(typ, name) + if err != nil { + return nil, err + } + if len(sets) == 0 { + return nil, fmt.Errorf("not found defined set: %s", name) + } else if len(sets) > 1 { + return nil, fmt.Errorf("invalid response for GetDefinedSetByName") + } + return sets[0], nil +} + func (cli *Client) AddDefinedSet(d table.DefinedSet) error { a, err := api.NewAPIDefinedSetFromTableStruct(d) if err != nil { |