image

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2020 License: MIT Imports: 11 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a image api client which can be used to make requests to the server

func NewAPIClient

func NewAPIClient(imageAPIURL string) *Client

NewAPIClient creates a new instance of Client with a given image api url and the relevant tokens

func NewAPIClientWithMaxRetries

func NewAPIClientWithMaxRetries(imageAPIURL string, maxRetries int) *Client

NewAPIClientWithMaxRetries creates a new instance of Client with a given image api url and the relevant tokens, setting a number of max retires for the HTTP client

func (*Client) Checker

func (c *Client) Checker(ctx context.Context, check *health.CheckState) error

Checker calls image api health endpoint and returns a check object to the caller.

func (*Client) GetImage

func (c *Client) GetImage(ctx context.Context, imageID string) (m Image, err error)

GetImage returns a requested image

func (*Client) GetImages

func (c *Client) GetImages(ctx context.Context) (m Images, err error)

GetImages returns the list of images

func (*Client) PostImage

func (c *Client) PostImage(ctx context.Context, data NewImage) (m Image, err error)

PostImage performs a 'POST /images' with the provided NewImage

func (*Client) PutImage

func (c *Client) PutImage(ctx context.Context, imageID string, data Image) (m Image, err error)

PutImage updates the specified image

type ErrInvalidImageAPIResponse

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

ErrInvalidImageAPIResponse is returned when the image api does not respond with a valid status

func NewImageAPIResponse

func NewImageAPIResponse(resp *http.Response, uri string) (e *ErrInvalidImageAPIResponse)

NewImageAPIResponse creates an error response, optionally adding body to e when status is 404

func (ErrInvalidImageAPIResponse) Code

Code returns the status code received from image api if an error is returned

func (ErrInvalidImageAPIResponse) Error

Error should be called by the user to print out the stringified version of the error

type Image

type Image struct {
	Id           string `json:"id,omitempty"`
	CollectionId string `json:"collection_id,omitempty"`
	State        string `json:"state,omitempty"`
	//enum:
	//- created
	//- uploaded
	//- publishing
	//- published
	//- deleted
	Filename  string                              `json:"filename,omitempty"`
	License   License                             `json:"license,omitempty"`
	Upload    ImageUpload                         `json:"upload,omitempty"`
	Type      string                              `json:"type,omitempty"`
	Downloads map[string]map[string]ImageDownload `json:"downloads,omitempty"`
}

type ImageDownload

type ImageDownload struct {
	Size    int    `json:"size,omitempty"`
	Href    string `json:"href,omitempty"`
	Public  string `json:"public,omitempty"`
	Private string `json:"private,omitempty"`
}

type ImageUpload

type ImageUpload struct {
	Path string `json:"path,omitempty"`
}

type Images

type Images struct {
	Count      int     `json:"count"`
	Items      []Image `json:"items"`
	Limit      int     `json:"limit"`
	Offset     int     `json:"offset"`
	TotalCount int     `json:"total_count"`
}

type License

type License struct {
	Title string `json:"title,omitempty"`
	Href  string `json:"href,omitempty"`
}

type NewImage

type NewImage struct {
	CollectionId string  `json:"collection_id,omitempty"`
	Filename     string  `json:"filename,omitempty"`
	License      License `json:"license,omitempty"`
	Type         string  `json:"type,omitempty"`
}

Jump to

Keyboard shortcuts

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