http

package
v4.7.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2020 License: BSD-4-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthAPI     = "AUTHENTICATION_API"
	ScalingoAPI = "SCALINGO_API"
	DBAPI       = "DATABASES_API"
)

Variables

View Source
var ErrOTPRequired = errors.New("OTP Required")

Functions

func IsOTPRequired

func IsOTPRequired(err error) bool

IsOTPRequired tests if the authentication backend return an OTP Required error

func IsRequestFailedError

func IsRequestFailedError(err error) bool

func NewRequestFailedError

func NewRequestFailedError(res *http.Response, req *APIRequest) error

Types

type APIError

type APIError struct {
	Error string `json:"error"`
}

type APIRequest

type APIRequest struct {
	NoAuth      bool
	URL         string
	Method      string
	Endpoint    string
	Expected    Statuses
	Params      interface{}
	HTTPRequest *http.Request
	Token       string // Directly use a Bearer token
	Username    string // Username for the OAuth generator (nil if you use a token)
	Password    string // Password for the OAuth generator
	OTP         string // OTP value
}

func (*APIRequest) BuildQueryFromParams

func (req *APIRequest) BuildQueryFromParams() (url.Values, error)

type APITokenGenerator

type APITokenGenerator struct {
	APIToken      string
	TokensService TokensService
	// contains filtered or unexported fields
}

func NewAPITokenGenerator

func NewAPITokenGenerator(tokensService TokensService, apiToken string) *APITokenGenerator

func (*APITokenGenerator) GetAccessToken

func (t *APITokenGenerator) GetAccessToken() (string, error)

type AdddonTokenExchanger

type AdddonTokenExchanger interface {
	AddonToken(app, addonID string) (string, error)
}

type AddonTokenGenerator

type AddonTokenGenerator struct {
	// contains filtered or unexported fields
}

func (*AddonTokenGenerator) GetAccessToken

func (c *AddonTokenGenerator) GetAccessToken() (string, error)

type BadRequestError

type BadRequestError struct {
	ErrMessage string `json:"error"`
	Code       string `json:"code"`
}

func (BadRequestError) Error

func (err BadRequestError) Error() string

type Client

type Client interface {
	ResourceList(resource string, payload, data interface{}) error
	ResourceAdd(resource string, payload, data interface{}) error
	ResourceGet(resource, resourceID string, payload, data interface{}) error
	ResourceUpdate(resource, resourceID string, payload, data interface{}) error
	ResourceDelete(resource, resourceID string) error

	SubresourceList(resource, resourceID, subresource string, payload, data interface{}) error
	SubresourceAdd(resource, resourceID, subresource string, payload, data interface{}) error
	SubresourceGet(resource, resourceID, subresource, id string, payload, data interface{}) error
	SubresourceUpdate(resource, resourceID, subresource, id string, payload, data interface{}) error
	SubresourceDelete(resource, resourceID, subresource, id string) error
	DoRequest(req *APIRequest, data interface{}) error
	Do(req *APIRequest) (*http.Response, error)

	TokenGenerator() TokenGenerator
	IsAuthenticatedClient() bool
	BaseURL() string
	HTTPClient() *http.Client
}

func NewClient

func NewClient(api string, cfg ClientConfig) Client

type ClientConfig

type ClientConfig struct {
	UserAgent      string
	Timeout        time.Duration
	TLSConfig      *tls.Config
	APIVersion     string
	Endpoint       string
	TokenGenerator TokenGenerator
}

type ForbiddenError

type ForbiddenError struct {
	Err  string `json:"error"`
	Code string `json:"code"`
}

func (ForbiddenError) Error

func (err ForbiddenError) Error() string

type NotFoundError

type NotFoundError struct {
	Resource string `json:"resource"`
	Err      string `json:"error"`
}

func (NotFoundError) Error

func (err NotFoundError) Error() string

type PaymentRequiredError

type PaymentRequiredError struct {
	Name       string `json:"name"`
	ErrMessage string `json:"error"`
	URL        string `json:"url"`
}

func (PaymentRequiredError) Error

func (err PaymentRequiredError) Error() string

type RequestFailedError

type RequestFailedError struct {
	Code     int
	APIError error
	Req      *APIRequest
	Message  string
}

func (*RequestFailedError) Error

func (err *RequestFailedError) Error() string

func (*RequestFailedError) String

func (err *RequestFailedError) String() string

type Statuses

type Statuses []int

func (Statuses) Contains

func (statuses Statuses) Contains(status int) bool

type TokenGenerator

type TokenGenerator interface {
	GetAccessToken() (string, error)
}

func NewAddonTokenGenerator

func NewAddonTokenGenerator(app, addon string, exchanger AdddonTokenExchanger) TokenGenerator

type TokensService

type TokensService interface {
	TokenExchange(token string) (string, error)
}

type UnprocessableEntity

type UnprocessableEntity struct {
	Errors map[string][]string `json:"errors"`
}

func (UnprocessableEntity) Error

func (err UnprocessableEntity) Error() string

Directories

Path Synopsis
Package httpmock is a generated GoMock package.
Package httpmock is a generated GoMock package.
Package tokensservicemock is a generated GoMock package.
Package tokensservicemock is a generated GoMock package.

Jump to

Keyboard shortcuts

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