warehouse

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: MIT Imports: 16 Imported by: 0

README

Go client library for warehouse (BETA)

This library implements basic functionality for interaction with a warehouse instance.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoBundles = errors.New("no bundles found")
	ErrNoFiles   = errors.New("no files found")
)

Functions

This section is empty.

Types

type AndQuery

type AndQuery struct {
	Children []Query
}

func NewAndQuery

func NewAndQuery(children []Query) *AndQuery

func (*AndQuery) MarshalJSON

func (n *AndQuery) MarshalJSON() ([]byte, error)

type ArchiveType

type ArchiveType int
const (
	ArchiveTypeInvalid ArchiveType = iota
	ArchiveTypeTar
	ArchiveTypeZip
)

type Bundle

type Bundle struct {
	ID           uuid.UUID
	ProjectID    uuid.UUID
	Files        []*File
	CreatedTime  time.Time
	ModifiedTime time.Time
	Props        map[string]interface{}
	// contains filtered or unexported fields
}

func (*Bundle) DownloadTar

func (b *Bundle) DownloadTar(t ArchiveType) (*DownloadInfo, error)

func (*Bundle) FindFile

func (b *Bundle) FindFile(q Query, s Sorting, limit int) (*File, error)

func (*Bundle) FindFiles

func (b *Bundle) FindFiles(q Query, s Sorting, limit int) ([]*File, error)

func (*Bundle) Get

func (b *Bundle) Get(key string) interface{}

func (*Bundle) GetInt

func (b *Bundle) GetInt(key string) int

func (*Bundle) GetObject

func (b *Bundle) GetObject(key string) map[string]interface{}

func (*Bundle) GetString

func (b *Bundle) GetString(key string) string

func (*Bundle) Restore

func (b *Bundle) Restore() error

func (*Bundle) Set

func (b *Bundle) Set(m map[string]interface{}) error

func (*Bundle) Trash

func (b *Bundle) Trash() error

func (*Bundle) Update

func (b *Bundle) Update(cmd []Update) error

func (*Bundle) Upload

func (b *Bundle) Upload(r io.Reader, m map[string]string) (*File, error)

type Client

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

func New

func New(address string) *Client

func (*Client) Bundle

func (c *Client) Bundle(id uuid.UUID) (*Bundle, error)

func (*Client) DisableTLSVerification

func (c *Client) DisableTLSVerification()

func (*Client) File

func (c *Client) File(id uuid.UUID) (*File, error)

func (*Client) FileNoProps

func (c *Client) FileNoProps(id uuid.UUID) (*File, error)

func (*Client) FindBundle

func (c *Client) FindBundle(q Query, s Sorting) (*Bundle, error)

func (*Client) FindBundles

func (c *Client) FindBundles(q Query, s Sorting, limit int) ([]*Bundle, error)

func (*Client) FindFile

func (c *Client) FindFile(q Query, s Sorting) (*File, error)

func (*Client) FindFiles

func (c *Client) FindFiles(q Query, s Sorting, limit int) ([]*File, error)

func (*Client) Login

func (c *Client) Login(username, password string) error

func (*Client) Organization

func (c *Client) Organization(name string) (*Organization, error)

func (*Client) Organizations

func (c *Client) Organizations() ([]*Organization, error)

func (*Client) Project

func (c *Client) Project(name string) (*Project, error)

func (*Client) ProjectSettingsCategory

func (c *Client) ProjectSettingsCategory(proj, cat string, v interface{}) error

func (*Client) SearchKeys

func (c *Client) SearchKeys(s KeySearch) ([]keyResult, error)

func (*Client) SetAPIKey

func (c *Client) SetAPIKey(apikey string)

func (*Client) SetCredentials

func (c *Client) SetCredentials(username, password string)

func (*Client) SetRawAuth

func (c *Client) SetRawAuth(auth string)

func (*Client) SetToken

func (c *Client) SetToken(token string)

func (*Client) SettingsCategory

func (c *Client) SettingsCategory(cat string, v interface{}) error

type DownloadInfo

type DownloadInfo struct {
	Body   io.ReadCloser
	Header http.Header
	Size   int64
	SHA512 []byte
}

type EqualsQuery

type EqualsQuery struct {
	Key   string
	Value interface{}
}

func NewEqualsQuery

func NewEqualsQuery(key, value string) *EqualsQuery

func (*EqualsQuery) MarshalJSON

func (q *EqualsQuery) MarshalJSON() ([]byte, error)

type File

type File struct {
	ID           uuid.UUID `json:"file_id"`
	BundleID     uuid.UUID `json:"bundle_id"`
	ProjectID    uuid.UUID `json:"project_id"`
	CreatedTime  time.Time `json:"created_time"`
	ModifiedTime time.Time `json:"modified_time"`
	Downloads    int64     `json:"downloads"`
	Size         int64     `json:"size"`

	Props map[string]interface{}
	// contains filtered or unexported fields
}

func (*File) Download

func (f *File) Download() (*DownloadInfo, error)

func (*File) Get

func (f *File) Get(key string) interface{}

func (*File) GetInt

func (f *File) GetInt(key string) int

func (*File) GetObject

func (f *File) GetObject(key string) map[string]interface{}

func (*File) GetString

func (f *File) GetString(key string) string

func (*File) Restore

func (f *File) Restore() error

func (*File) Set

func (f *File) Set(m map[string]interface{}) error

func (*File) Trash

func (f *File) Trash() error

func (*File) Update

func (f *File) Update(cmd []Update) error

type KeyExistsQuery

type KeyExistsQuery struct {
	Key string
}

func NewKeyExistsQuery

func NewKeyExistsQuery(key string) *KeyExistsQuery

func (*KeyExistsQuery) MarshalJSON

func (q *KeyExistsQuery) MarshalJSON() ([]byte, error)

type KeySearch

type KeySearch struct {
	Table          string   `json:"table"`
	Keys           []string `json:"keys"`
	Limit          int      `json:"limit,omitempty"`
	Query          Query    `json:"query"`
	Sorting        Sorting  `json:"sorting,omitempty"`
	Distinct       bool     `json:"distinct"`
	IncludeGarbage bool     `json:"includeGarbage"`
}

type NaturalQuery

type NaturalQuery struct {
	Query string
}

func NewNaturalQuery

func NewNaturalQuery(q string) *NaturalQuery

func (*NaturalQuery) MarshalJSON

func (n *NaturalQuery) MarshalJSON() ([]byte, error)

type NotQuery

type NotQuery struct {
	Child Query
}

func NewNotQuery

func NewNotQuery(child Query) *NotQuery

func (*NotQuery) MarshalJSON

func (n *NotQuery) MarshalJSON() ([]byte, error)

type OrQuery

type OrQuery struct {
	Children []Query
}

func NewOrQuery

func NewOrQuery(children []Query) *OrQuery

func (*OrQuery) MarshalJSON

func (n *OrQuery) MarshalJSON() ([]byte, error)

type Organization

type Organization struct {
	ID   uuid.UUID
	Name string
	// contains filtered or unexported fields
}

func (*Organization) FindBundle

func (o *Organization) FindBundle(q Query, s Sorting, limit int) (*Bundle, error)

func (*Organization) FindBundles

func (o *Organization) FindBundles(q Query, s Sorting, limit int) ([]*Bundle, error)

func (*Organization) FindFile

func (o *Organization) FindFile(q Query, s Sorting, limit int) (*File, error)

func (*Organization) FindFiles

func (o *Organization) FindFiles(q Query, s Sorting, limit int) ([]*File, error)

func (*Organization) Projects

func (o *Organization) Projects() ([]*Project, error)

type Project

type Project struct {
	ID             uuid.UUID
	OrganizationID uuid.UUID
	Name           string
	// contains filtered or unexported fields
}

func (*Project) FindBundle

func (p *Project) FindBundle(q Query, s Sorting, limit int) (*Bundle, error)

func (*Project) FindBundles

func (p *Project) FindBundles(q Query, s Sorting, limit int) ([]*Bundle, error)

func (*Project) FindFile

func (p *Project) FindFile(q Query, s Sorting, limit int) (*File, error)

func (*Project) FindFiles

func (p *Project) FindFiles(q Query, s Sorting, limit int) ([]*File, error)

type Query

type Query interface {
	MarshalJSON() ([]byte, error)
	// contains filtered or unexported methods
}

type SortOrder

type SortOrder int
const (
	SortOrderNone SortOrder = iota
	SortOrderAscending
	SortOrderDescending
)

func (SortOrder) MarshalText

func (s SortOrder) MarshalText() ([]byte, error)

type SortType

type SortType int
const (
	SortTypeNone SortType = iota
	SortTypeAlphanumerical
	SortTypeNatural
	SortTypeChronological
	SortTypeChronologicalModification
)

func (SortType) MarshalText

func (s SortType) MarshalText() ([]byte, error)

type Sorting

type Sorting struct {
	Sort  SortType  `json:"sort,omitempty"`
	Order SortOrder `json:"order,omitempty"`
	Key   string    `json:"key,omitempty"`
}

type StrInListQuery

type StrInListQuery struct {
	Key    string
	Values []string
}

func NewStrInListQuery

func NewStrInListQuery(key string, values []string) *StrInListQuery

func (*StrInListQuery) MarshalJSON

func (q *StrInListQuery) MarshalJSON() ([]byte, error)

type Update

type Update struct {
	Assign UpdateAssign `json:"assign"`
	Delete UpdateDelete `json:"delete"`
}

type UpdateAssign

type UpdateAssign struct {
	Key   string      `json:"key"`
	Value interface{} `json:"value"`
}

type UpdateDelete

type UpdateDelete struct {
	Key string `json:"key"`
}

Jump to

Keyboard shortcuts

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