clientbase

package
v0.10.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2026 License: Apache-2.0 Imports: 16 Imported by: 386

Documentation

Index

Constants

View Source
const (
	SELF       = "self"
	COLLECTION = "collection"
)

Variables

View Source
var (
	Debug = false
)

Functions

func IsForbidden added in v0.10.1

func IsForbidden(err error) bool

IsForbidden returns true if the error is an APIError with a 403 status code.

It supports wrapped errors and returns false when the error is nil.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns true if the error is an APIError with a 404 status code.

It supports wrapped errors and returns false when the error is nil.

func IsUnauthorized added in v0.10.1

func IsUnauthorized(err error) bool

IsUnauthorized returns true if the error is an APIError with a 401 status code.

It supports wrapped errors and returns false when the error is nil.

func NewListOpts

func NewListOpts() *types.ListOpts

Types

type APIBaseClient

type APIBaseClient struct {
	Ops   *APIOperations
	Opts  *ClientOpts
	Types map[string]types.Schema
}

func NewAPIClient

func NewAPIClient(opts *ClientOpts) (APIBaseClient, error)

func (*APIBaseClient) Action

func (a *APIBaseClient) Action(schemaType string, action string,
	existing *types.Resource, inputObject, respObject interface{}) error

func (*APIBaseClient) ByID

func (a *APIBaseClient) ByID(schemaType string, id string, respObject interface{}) error

func (*APIBaseClient) Create

func (a *APIBaseClient) Create(schemaType string, createObj interface{}, respObject interface{}) error

func (*APIBaseClient) Delete

func (a *APIBaseClient) Delete(existing *types.Resource) error
func (a *APIBaseClient) GetLink(resource types.Resource, link string, respObject interface{}) error

func (*APIBaseClient) List

func (a *APIBaseClient) List(schemaType string, opts *types.ListOpts, respObject interface{}) error

func (*APIBaseClient) Post

func (a *APIBaseClient) Post(url string, createObj interface{}, respObject interface{}) error

func (*APIBaseClient) Reload

func (a *APIBaseClient) Reload(existing *types.Resource, output interface{}) error

func (*APIBaseClient) Replace

func (a *APIBaseClient) Replace(schemaType string, existing *types.Resource, updates interface{}, respObject interface{}) error

func (*APIBaseClient) Update

func (a *APIBaseClient) Update(schemaType string, existing *types.Resource, updates interface{}, respObject interface{}) error

func (*APIBaseClient) Websocket

func (a *APIBaseClient) Websocket(url string, headers map[string][]string) (*websocket.Conn, *http.Response, error)

type APIBaseClientInterface

type APIBaseClientInterface interface {
	Websocket(url string, headers map[string][]string) (*websocket.Conn, *http.Response, error)
	List(schemaType string, opts *types.ListOpts, respObject interface{}) error
	Post(url string, createObj interface{}, respObject interface{}) error
	GetLink(resource types.Resource, link string, respObject interface{}) error
	Create(schemaType string, createObj interface{}, respObject interface{}) error
	Update(schemaType string, existing *types.Resource, updates interface{}, respObject interface{}) error
	Replace(schemaType string, existing *types.Resource, updates interface{}, respObject interface{}) error
	ByID(schemaType string, id string, respObject interface{}) error
	Delete(existing *types.Resource) error
	Reload(existing *types.Resource, output interface{}) error
	Action(schemaType string, action string, existing *types.Resource, inputObject, respObject interface{}) error
}

type APIError

type APIError struct {
	StatusCode int
	URL        string
	Msg        string
	Status     string
	Body       string
}

func NewAPIError

func NewAPIError(resp *http.Response, url string) *APIError

func (*APIError) Error

func (e *APIError) Error() string

type APIOperations

type APIOperations struct {
	Opts   *ClientOpts
	Types  map[string]types.Schema
	Client *http.Client
	Dialer *websocket.Dialer
}

func (*APIOperations) DoAction

func (a *APIOperations) DoAction(schemaType string, action string,
	existing *types.Resource, inputObject, respObject interface{}) error

func (*APIOperations) DoByID

func (a *APIOperations) DoByID(schemaType string, id string, respObject interface{}) error

func (*APIOperations) DoCollectionAction

func (a *APIOperations) DoCollectionAction(schemaType string, action string,
	existing *types.Collection, inputObject, respObject interface{}) error

func (*APIOperations) DoCreate

func (a *APIOperations) DoCreate(schemaType string, createObj interface{}, respObject interface{}) error

func (*APIOperations) DoDelete

func (a *APIOperations) DoDelete(url string) error

func (*APIOperations) DoGet

func (a *APIOperations) DoGet(url string, opts *types.ListOpts, respObject interface{}) error

func (*APIOperations) DoList

func (a *APIOperations) DoList(schemaType string, opts *types.ListOpts, respObject interface{}) error

func (*APIOperations) DoModify

func (a *APIOperations) DoModify(method string, url string, createObj interface{}, respObject interface{}) error

func (*APIOperations) DoNext

func (a *APIOperations) DoNext(nextURL string, respObject interface{}) error

func (*APIOperations) DoReplace

func (a *APIOperations) DoReplace(schemaType string, existing *types.Resource, updates interface{}, respObject interface{}) error

func (*APIOperations) DoResourceDelete

func (a *APIOperations) DoResourceDelete(schemaType string, existing *types.Resource) error

func (*APIOperations) DoUpdate

func (a *APIOperations) DoUpdate(schemaType string, existing *types.Resource, updates interface{}, respObject interface{}) error

func (*APIOperations) SetupRequest

func (a *APIOperations) SetupRequest(req *http.Request)

type ClientOpts

type ClientOpts struct {
	URL        string
	AccessKey  string
	SecretKey  string
	TokenKey   string
	Timeout    time.Duration
	HTTPClient *http.Client
	WSDialer   *websocket.Dialer
	CACerts    string
	Insecure   bool
	ProxyURL   string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL