some api changes
This commit is contained in:
parent
f305f96195
commit
70fd3f71e5
11 changed files with 118 additions and 76 deletions
|
|
@ -13,7 +13,7 @@ import (
|
|||
|
||||
var (
|
||||
ErrClientIsNil = errors.New("client is nil")
|
||||
base = "/" + schema.Version
|
||||
base = schema.LBPath
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
|
|
@ -32,7 +32,7 @@ func (c *Client) GetLoadBalancers(ctx context.Context) (lbs map[string]schema.Lo
|
|||
}
|
||||
|
||||
func (c *Client) GetLoadBalancersWithCluster(ctx context.Context, cluster string) (lbs map[string]schema.LoadBalancer, err error) {
|
||||
path := base + "/lb"
|
||||
path := base
|
||||
if cluster != "" {
|
||||
path += "/" + cluster
|
||||
}
|
||||
|
|
@ -46,7 +46,7 @@ func (c *Client) GetLoadBalancersWithCluster(ctx context.Context, cluster string
|
|||
}
|
||||
|
||||
func (c *Client) GetLoadBalancer(ctx context.Context, cluster, name string) (lb schema.LoadBalancer, err error) {
|
||||
path := fmt.Sprintf("%s/lb/%s/%s", base, cluster, name)
|
||||
path := fmt.Sprintf("%s/%s/%s", base, cluster, name)
|
||||
req, err := c.c.NewRequest(ctx, "GET", path, nil)
|
||||
if err != nil {
|
||||
return
|
||||
|
|
@ -57,7 +57,7 @@ func (c *Client) GetLoadBalancer(ctx context.Context, cluster, name string) (lb
|
|||
|
||||
func (c *Client) CreateLoadBalancer(ctx context.Context, cluster, name string, lb schema.LoadBalancer) (err error) {
|
||||
buf := new(bytes.Buffer)
|
||||
path := fmt.Sprintf("%s/lb/%s/%s", base, cluster, name)
|
||||
path := fmt.Sprintf("%s/%s/%s", base, cluster, name)
|
||||
err = lb.ValidateClient()
|
||||
if err != nil {
|
||||
return
|
||||
|
|
@ -75,7 +75,7 @@ func (c *Client) CreateLoadBalancer(ctx context.Context, cluster, name string, l
|
|||
}
|
||||
|
||||
func (c *Client) DeleteLoadBalancer(ctx context.Context, cluster, name string) (err error) {
|
||||
path := fmt.Sprintf("%s/lb/%s/%s", base, cluster, name)
|
||||
path := fmt.Sprintf("%s/%s/%s", base, cluster, name)
|
||||
req, err := c.c.NewRequest(ctx, "DELETE", path, nil)
|
||||
if err != nil {
|
||||
return
|
||||
|
|
@ -88,7 +88,7 @@ func (c *Client) DeleteLoadBalancersWithCluster(ctx context.Context, cluster str
|
|||
if cluster == "" {
|
||||
return errors.New("cluster value can not be empty")
|
||||
}
|
||||
path := base + "/lb/" + cluster
|
||||
path := base + "/" + cluster
|
||||
req, err := c.c.NewRequest(ctx, "DELETE", path, nil)
|
||||
if err != nil {
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue