bouncer/internal/client/get_layer.go

27 lines
671 B
Go
Raw 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"
)
func (c *Client) GetLayer(ctx context.Context, proxyName store.ProxyName, layerName store.LayerName, funcs ...OptionFunc) (*store.Layer, error) {
response := withResponse[admin.GetLayerResponse]()
path := fmt.Sprintf("/api/v1/proxies/%s/layers/%s", proxyName, layerName)
if err := c.apiGet(ctx, path, &response, funcs...); err != nil {
return nil, errors.WithStack(err)
}
if response.Error != nil {
return nil, errors.WithStack(response.Error)
}
return response.Data.Layer, nil
}