api

package
v0.0.0-...-4946764 Latest Latest
Warning

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

Go to latest
Published: May 19, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentTypeJSON        = "application/json"
	ContentTypeFormEncoded = "application/x-www-form-urlencoded"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Client http.Client
	oauth.ForgeAuthenticator
}

func NewClient

func NewClient(auth oauth.ForgeAuthenticator) *Client

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, scope scopes.Scope, paths []string) error

func (*Client) DoRawRequest

func (c *Client) DoRawRequest(ctx context.Context, method string, scope scopes.Scope, paths []string, filters []Filterer, setHeaders func(http.Header) error, contentType string, body io.Reader) (*http.Response, error)

func (*Client) DoRequest

func (c *Client) DoRequest(ctx context.Context, method string, scope scopes.Scope, paths []string, result interface{}, filters []Filterer, contentType string, body io.Reader) error

func (*Client) Get

func (c *Client) Get(ctx context.Context, scope scopes.Scope, paths []string, result interface{}, filters ...Filterer) error

func (*Client) Post

func (c *Client) Post(ctx context.Context, scope scopes.Scope, paths []string, result interface{}, contentType string, body io.Reader) error

func (*Client) ProcessJSONError

func (c *Client) ProcessJSONError(response *http.Response, result interface{}) (err error)

func (*Client) ProcessRawError

func (c *Client) ProcessRawError(response *http.Response, result interface{}) (err error)

func (*Client) Put

func (c *Client) Put(ctx context.Context, scope scopes.Scope, paths []string, result interface{}, contentType string, body io.Reader) error

type ErrAPIIncompatible

type ErrAPIIncompatible struct {
	Err          error
	DeveloperMsg string
}

ErrAPIIncompatible reflect that the API version and the API server are misaligned

func (ErrAPIIncompatible) Error

func (err ErrAPIIncompatible) Error() string

func (ErrAPIIncompatible) Unwrap

func (err ErrAPIIncompatible) Unwrap() error

type ErrResult

type ErrResult struct {
	Reason     string `json:"reason"`
	StatusCode int
}

ErrResult reflects the body content when a request failed (g.e. Bad request or key conflict)

func (ErrResult) Error

func (err ErrResult) Error() string

func (ErrResult) IsForbidden

func (err ErrResult) IsForbidden() bool

func (ErrResult) IsNotFound

func (err ErrResult) IsNotFound() bool

func (ErrResult) IsRateLimited

func (err ErrResult) IsRateLimited() bool

func (ErrResult) IsSystemIssue

func (err ErrResult) IsSystemIssue() bool

func (ErrResult) IsTokenExpired

func (err ErrResult) IsTokenExpired() bool

func (ErrResult) IsUnauthorized

func (err ErrResult) IsUnauthorized() bool

type Filterer

type Filterer interface {
	Add(url.Values) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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