bouncer/internal/client/update_proxy.go

29 lines
703 B
Go
Raw Permalink Normal View History

2023-04-24 20:52:12 +02:00
package client
import (
"context"
"fmt"
"forge.cadoles.com/cadoles/bouncer/internal/admin"
"forge.cadoles.com/cadoles/bouncer/internal/store"
"github.com/pkg/errors"
)
type UpdateProxyOptions = admin.UpdateProxyRequest
func (c *Client) UpdateProxy(ctx context.Context, proxyName store.ProxyName, opts *UpdateProxyOptions, funcs ...OptionFunc) (*store.Proxy, error) {
response := withResponse[admin.UpdateProxyResponse]()
path := fmt.Sprintf("/api/v1/proxies/%s", proxyName)
if err := c.apiPut(ctx, path, opts, &response); err != nil {
return nil, errors.WithStack(err)
}
if response.Error != nil {
return nil, errors.WithStack(response.Error)
}
return response.Data.Proxy, nil
}