lib

package
v2.0.128-beta Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: MIT Imports: 18 Imported by: 2

Documentation

Index

Constants

View Source
const (
	BasePart = int64(1024*1024*5 + 1024*1024/3)
)

Variables

View Source
var PartSizes = partSizes()

PartSizes return 10k parts that add up to 4.9 TB

View Source
var QueryEscape = url.QueryEscape

Functions

func AnyError

func AnyError(callback func(error), functions ...func() error)

func Bool

func Bool(bool bool) *bool

func BuildPath

func BuildPath(resourcePath string, values interface{}) (string, error)

func CheckRequired

func CheckRequired(iStruct interface{}) error

func CloseBody

func CloseBody(res *http.Response)

func CopyAt

func CopyAt(dst io.WriterAt, writeOff int64, src io.Reader) (written int64, err error)

func CreateError

func CreateError(i interface{}, name string) error

func ExpandTilde

func ExpandTilde(path string) string

func Interface

func Interface() interface{}

func IsJSON

func IsJSON(res *http.Response) bool

func IsStatus

func IsStatus(status int) func(res *http.Response) error

func JSONEmptyValue

func JSONEmptyValue(v reflect.Type) string

func NewReader

func NewReader(ctx context.Context, r io.ReadCloser) io.ReadCloser

NewReader gets a context-aware io.Reader.

func NewReaderAt

func NewReaderAt(ctx context.Context, r io.ReaderAt) io.ReaderAt

NewReader gets a context-aware io.Reader.

func NonJSONError

func NonJSONError(res *http.Response) error

func NonOkError

func NonOkError(res *http.Response) error

func NotStatus

func NotStatus(status int) func(res *http.Response) error

func PathEscape

func PathEscape(path string) string

func ResponseErrors

func ResponseErrors(res *http.Response, errorFunc ...func(res *http.Response) error) error

func String

func String(string string) *string

func Time

func Time(t time.Time) *time.Time

func UnWrapBool

func UnWrapBool(b *bool) bool

Types

type ErrorWithOriginalResponse

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

func (ErrorWithOriginalResponse) OriginalResponse

func (u ErrorWithOriginalResponse) OriginalResponse() interface{}

func (ErrorWithOriginalResponse) ProcessError

func (u ErrorWithOriginalResponse) ProcessError(data []byte, err error, t interface{}) error

type ExportValues

type ExportValues struct {
	url.Values
}

func (ExportValues) ToJSON

func (m ExportValues) ToJSON() (io.Reader, error)

func (ExportValues) ToValues

func (m ExportValues) ToValues() (url.Values, error)

type Iter

type Iter struct {
	Query
	ListParams   ListParamsContainer
	Params       []interface{}
	CurrentIndex int
	Values       *[]interface{}
	Cursor       string
	Error        error
	OnPageError
}

func (*Iter) Current

func (i *Iter) Current() interface{}

func (*Iter) EOFPage

func (i *Iter) EOFPage() bool

func (*Iter) Err

func (i *Iter) Err() error

Err returns the error, if any, that caused the Iter to stop. It must be inspected after Next returns false.

func (*Iter) ExportParams

func (i *Iter) ExportParams() (ExportValues, error)

func (*Iter) GetCursor

func (i *Iter) GetCursor() string

func (*Iter) GetPage

func (i *Iter) GetPage() bool

func (*Iter) GetParams

func (i *Iter) GetParams() *ListParams

func (*Iter) Next

func (i *Iter) Next() bool

Next iterates the results in i.Current() or i.`ResourceName`(). It returns true until there are no results remaining. To adjust the number of results set ListParams.PerPage. To have it auto-paginate set ListParams.MaxPages, default is 1.

To iterate over all results use the following pattern.

for i.Next() {
  i.Current()
}

func (*Iter) NextPage

func (i *Iter) NextPage() bool

func (*Iter) Paging

func (i *Iter) Paging() bool

func (*Iter) SetCursor

func (i *Iter) SetCursor(cursor string)

type IterChan

type IterChan struct {
	Send      chan interface{}
	Stop      chan bool
	SendError chan error

	Error atomic.Value
	Start func(*IterChan)
	// contains filtered or unexported fields
}

func (*IterChan) Current

func (i *IterChan) Current() interface{}

func (*IterChan) Err

func (i *IterChan) Err() error

func (IterChan) Init

func (i IterChan) Init() *IterChan

func (*IterChan) Next

func (i *IterChan) Next() bool

type IterI

type IterI interface {
	Next() bool
	Current() interface{}
	Err() error
}

type IterPagingI

type IterPagingI interface {
	IterI
	EOFPage() bool
}

type ListParams

type ListParams struct {
	Page     int64  `json:"page,omitempty" url:"page,omitempty" required:"false"`
	PerPage  int64  `json:"per_page,omitempty" url:"per_page,omitempty" required:"false"`
	Cursor   string `json:"cursor,omitempty" url:"cursor,omitempty" required:"false"`
	MaxPages int64  `json:"-" url:"-"`
}

func (*ListParams) GetListParams

func (p *ListParams) GetListParams() *ListParams

GetListParams returns a ListParams struct (itself). It exists because any structs that embed ListParams will inherit it, and thus implement the ListParamsContainer interface.

type ListParamsContainer

type ListParamsContainer interface {
	GetListParams() *ListParams
}

ListParamsContainer is a general interface for which all list parameter structs should comply. They achieve this by embedding a ListParams struct and inheriting its implementation of this interface.

type OnPageError

type OnPageError func(error) (*[]interface{}, error)

type Params

type Params struct {
	Params interface{}
}

func (Params) ToJSON

func (p Params) ToJSON() (io.Reader, error)

func (Params) ToValues

func (p Params) ToValues() (url.Values, error)

type Path

type Path struct {
	Path string
}

func (Path) EndingSlash

func (p Path) EndingSlash() bool

func (Path) Join

func (p Path) Join(str ...string) Path

func (Path) Pop

func (p Path) Pop() string

func (Path) PruneStartingSlash

func (p Path) PruneStartingSlash() Path

func (Path) String

func (p Path) String() string

type ProgressWriter

type ProgressWriter struct {
	WriterAndAt
	ProgressWatcher func(int64)
}

func (ProgressWriter) Close

func (w ProgressWriter) Close() error

func (ProgressWriter) Write

func (w ProgressWriter) Write(p []byte) (n int, err error)

func (ProgressWriter) WriteAt

func (w ProgressWriter) WriteAt(p []byte, off int64) (n int, err error)

type Query

type Query func(params Values) (*[]interface{}, string, error)

type ReaderAtCloser

type ReaderAtCloser interface {
	io.ReaderAt
	io.ReadCloser
}

type Resource

type Resource struct {
	Path   string
	Params interface{}
	Method string
	Entity UnmarshalJSON
}

func (Resource) Out

func (r Resource) Out() (ResourceOut, error)

type ResourceOut

type ResourceOut struct {
	Resource
	Values
}

type ResponseError

type ResponseError struct {
	StatusCode int
	// contains filtered or unexported fields
}

type UnmarshalJSON

type UnmarshalJSON interface {
	UnmarshalJSON(data []byte) error
}

type Values

type Values interface {
	ToValues() (url.Values, error)
	ToJSON() (io.Reader, error)
}

type WithContextReader

type WithContextReader interface {
	WithContext(context.Context) interface{}
	io.Reader
}

type WithContextReaderAt

type WithContextReaderAt interface {
	WithContext(context.Context) interface{}
	io.ReaderAt
}

type WriterAndAt

type WriterAndAt interface {
	io.WriterAt
	io.Writer
	io.Closer
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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