Documentation ¶
Index ¶
- Constants
- Variables
- func SetRequestContextHeaders(ctx context.Context, headers map[string]string) context.Context
- func WithApplyPreProcessor(preProcessor applyPreProcessorFn) option
- func WithDeleteSuccessMessage(deleteSuccessMssg string) option
- func WithDeprecatedAlias(resourceType string) option
- func WithListPath(path string) option
- func WithPrefixGetter(prefixGetterFn prefixGetterFn) option
- func WithProxyResource(proxyResource string) option
- func WithResourceType(resourceType string) option
- func WithTableConfig(tableConfig TableConfig) option
- type Client
- func (c Client) Apply(ctx context.Context, inputFile fileutil.File, requestedFormat Format) (string, error)
- func (c Client) Delete(ctx context.Context, id string, format Format) (string, error)
- func (c Client) Get(ctx context.Context, id string, format Format) (string, error)
- func (c Client) List(ctx context.Context, opt ListOption, format Format) (string, error)
- func (c Client) WithHttpClient(HTTPClient *HTTPClient) Client
- func (c Client) WithOptions(opts ...option) Client
- type ContextOption
- type Format
- type HTTPClient
- type ListOption
- type Registry
- type RequestError
- type TableCellConfig
- type TableConfig
- type Verb
Constants ¶
View Source
const FormatJSON = "json"
View Source
const FormatPretty = "pretty"
View Source
const FormatYAML = "yaml"
Variables ¶
View Source
var ErrNotFound = RequestError{ Code: http.StatusNotFound, Message: "Resource not found", }
View Source
var ErrResourceNotFound = errors.New("resource not found")
View Source
var Formats = formatRegistry{
jsonFormat{},
yamlFormat{},
prettyFormat{},
}
Functions ¶
func WithApplyPreProcessor ¶
func WithApplyPreProcessor(preProcessor applyPreProcessorFn) option
func WithDeleteSuccessMessage ¶
func WithDeleteSuccessMessage(deleteSuccessMssg string) option
func WithDeprecatedAlias ¶
func WithDeprecatedAlias(resourceType string) option
func WithListPath ¶
func WithListPath(path string) option
func WithPrefixGetter ¶
func WithPrefixGetter(prefixGetterFn prefixGetterFn) option
func WithProxyResource ¶
func WithProxyResource(proxyResource string) option
func WithResourceType ¶
func WithResourceType(resourceType string) option
func WithTableConfig ¶
func WithTableConfig(tableConfig TableConfig) option
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient( httpClient *HTTPClient, logger *zap.Logger, resourceName, resourceNamePlural string, opts ...option) Client
NewClient creates a new client for a resource managed by the resourceamanger. The tableConfig parameter configures how the table view should be rendered. This configuration work both for a single resource from a Get, or a ResourceList from a List
func (Client) WithHttpClient ¶
func (c Client) WithHttpClient(HTTPClient *HTTPClient) Client
func (Client) WithOptions ¶
type ContextOption ¶
type ContextOption string
const (
ContextHeadersKey ContextOption = "headers"
)
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
func NewHTTPClient ¶
func NewHTTPClient(baseURL string, extraHeaders http.Header) *HTTPClient
type ListOption ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry() *Registry
type RequestError ¶
type RequestError struct { Code int `json:"code"` Message string `json:"error"` IsAuthError bool `json:"isAuthError"` }
func (RequestError) Error ¶
func (e RequestError) Error() string
func (RequestError) Is ¶
func (e RequestError) Is(target error) bool
type TableCellConfig ¶
type TableConfig ¶
type TableConfig struct { Cells []TableCellConfig ItemModifier func(item *gabs.Container) error }
TableConfig is a configuration for prettyFormat Cells is a list of mappings from JSON keys to table headers. See github.com/Jeffail/gabs. ItemModifier is an optional function that can modify each item before it's added to the table.
Click to show internal directories.
Click to hide internal directories.