lib

package
v2.0.79-beta Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2022 License: MIT Imports: 13 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 Bool

func Bool(bool bool) *bool

func BuildPath

func BuildPath(resourcePath string, unescapedPath string) string

func CheckRequired

func CheckRequired(iStruct interface{}) error

func CreateError

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

func Interface

func Interface() interface{}

func JSONEmptyValue

func JSONEmptyValue(v reflect.Type) string

func NewReader

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

NewReader gets a context-aware io.Reader.

func PathEscape

func PathEscape(path string) string

func String

func String(string string) *string

func UnWrapBool

func UnWrapBool(b *bool) bool

Types

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
}

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) 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.

func (*ListParams) Set

func (p *ListParams) Set(page int64, perPage int64, cursor string, maxPages int64)

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 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 ProgressWriter

type ProgressWriter struct {
	Writer          io.Writer
	ProgressWatcher func(int64)
}

func (ProgressWriter) Write

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

type Query

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

type Values

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

type WithContextReader

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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