rest

package
v1.35.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const MaxWaitTime = 1 * time.Minute
View Source
const MinWaitTime = 5 * time.Second

Variables

View Source
var Logger = logger

Functions

func ContainsViolation

func ContainsViolation(err error, message string) bool

func MicrosecondsToUnixTime

func MicrosecondsToUnixTime(timeInMicroseconds int64) time.Time

MicrosecondsToUnixTime converts the UTC time in microseconds to a time.Time struct (unix time)

func Now

func Now() time.Time

func SetLogWriter

func SetLogWriter(writer io.Writer) error

func StringTimestampToHumanReadableFormat

func StringTimestampToHumanReadableFormat(unixTimestampAsString string) (humanReadable string, parsedTimestamp int64, err error)

StringTimestampToHumanReadableFormat parses and sanity-checks a unix timestamp as string and returns it as int64 and a human-readable representation of it

Types

type Client

type Client interface {
	Get(url string, expectedStatusCodes ...int) Request
	Post(url string, payload any, expectedStatusCodes ...int) Request
	Put(url string, payload any, expectedStatusCodes ...int) Request
	Delete(url string, expectedStatusCodes ...int) Request
}

func DefaultClient

func DefaultClient(envURL string, apiToken string) Client

type ClientFactory added in v1.28.0

type ClientFactory func(envURL, apiToken, schemaID string) Client

type ConstraintViolation

type ConstraintViolation struct {
	Description       string `json:"description,omitempty"`
	ParameterLocation string `json:"parameterLocation,omitempty"`
	Message           string `json:"message,omitempty"`
	Path              string `json:"path,omitempty"`
}

type Error

type Error struct {
	Code                 int                   `json:"code"`
	Message              string                `json:"message"`
	ConstraintViolations []ConstraintViolation `json:"constraintViolations,omitempty"`
	URL                  string                `json:"-"`
	Method               string                `json:"-"`
}

func (Error) ContainsViolation

func (me Error) ContainsViolation(message string) bool

func (Error) Error

func (me Error) Error() string

func (Error) ViolationMessage

func (me Error) ViolationMessage() string

type Forbidden added in v1.28.0

type Forbidden struct {
	Method string
}

func (*Forbidden) Expect added in v1.28.0

func (me *Forbidden) Expect(codes ...int) Request

func (*Forbidden) Finish added in v1.28.0

func (me *Forbidden) Finish(vs ...any) error

func (*Forbidden) OnResponse added in v1.28.0

func (me *Forbidden) OnResponse(func(resp *http.Response)) Request

func (*Forbidden) Payload added in v1.28.0

func (me *Forbidden) Payload(any) Request

func (*Forbidden) Raw added in v1.28.0

func (me *Forbidden) Raw() ([]byte, error)

type Request

type Request interface {
	// Raw() ([]byte, error)
	Finish(v ...any) error
	Expect(codes ...int) Request
	Payload(any) Request
	OnResponse(func(resp *http.Response)) Request
}

type StriclyForbidden added in v1.28.0

type StriclyForbidden struct {
	Method string
	URL    string
}

func (*StriclyForbidden) Expect added in v1.28.0

func (me *StriclyForbidden) Expect(codes ...int) Request

func (*StriclyForbidden) Finish added in v1.28.0

func (me *StriclyForbidden) Finish(vs ...any) error

func (*StriclyForbidden) OnResponse added in v1.28.0

func (me *StriclyForbidden) OnResponse(func(resp *http.Response)) Request

func (*StriclyForbidden) Payload added in v1.28.0

func (me *StriclyForbidden) Payload(any) Request

func (*StriclyForbidden) Raw added in v1.28.0

func (me *StriclyForbidden) Raw() ([]byte, error)

Jump to

Keyboard shortcuts

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