image

package
v2.260.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: MIT Imports: 13 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 an image api client which can be used to make requests to the server. It extends the generic healthcheck Client structure.

func NewAPIClient

func NewAPIClient(imageAPIURL string) *Client

NewAPIClient creates a new instance of ImageAPI Client with a given image api url

func NewWithHealthClient

func NewWithHealthClient(hcCli *healthcheck.Client) *Client

NewWithHealthClient creates a new instance of ImageAPI Client, reusing the URL and Clienter from the provided healthcheck 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) GetDownloadVariant

func (c *Client) GetDownloadVariant(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, imageID, variant string) (m ImageDownload, err error)

GetDownloadVariant returns a requested download variant for an image

func (*Client) GetDownloadVariants

func (c *Client) GetDownloadVariants(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, imageID string) (m ImageDownloads, err error)

GetDownloadVariants returns the list of download variants for an image

func (*Client) GetImage

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

GetImage returns a requested image

func (*Client) GetImages

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

GetImages returns the list of images

func (*Client) HealthClient

func (c *Client) HealthClient() *healthcheck.Client

HealthClient returns the underlying Healthcheck Client for this image API client

func (*Client) PostDownloadVariant

func (c *Client) PostDownloadVariant(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, imageID string, data NewImageDownload) (m ImageDownload, err error)

PostDownloadVariant adds a new download variant to the specified image

func (*Client) PostImage

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

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

func (*Client) PublishImage

func (c *Client) PublishImage(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, imageID string) (err error)

PublishImage triggers an image publishing

func (*Client) PutDownloadVariant

func (c *Client) PutDownloadVariant(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, imageID, variant string, data ImageDownload) (m ImageDownload, err error)

PutDownloadVariant updates the specified download variant for the specified image

func (*Client) PutImage

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

PutImage updates the specified image

func (*Client) URL

func (c *Client) URL() string

URL returns the URL used by this client

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
	//- importing
	//- imported
	//- published
	//- completed
	//- deleted
	//- failed_import
	//- failed_publish
	Error    string      `json:"error,omitempty"`
	Filename string      `json:"filename,omitempty"`
	License  License     `json:"license,omitempty"`
	Links    *ImageLinks `json:"links,omitempty"`
	Upload   ImageUpload `json:"upload,omitempty"`
	Type     string      `json:"type,omitempty"`
}

Image represents the fields for an Image

type ImageDownload

type ImageDownload struct {
	Id      string              `json:"id,omitempty"`
	Height  *int                `json:"height,omitempty"`
	Href    string              `json:"href,omitempty"`
	Palette string              `json:"palette,omitempty"`
	Private string              `json:"private,omitempty"`
	Public  bool                `json:"public,omitempty"`
	Size    int                 `json:"size,omitempty"`
	Type    string              `json:"type,omitempty"`
	Width   *int                `json:"width,omitempty"`
	Links   *ImageDownloadLinks `json:"links,omitempty"`
	State   string              `json:"state,omitempty"`
	//enum:
	//- pending
	//- importing
	//- imported
	//- published
	//- completed
	//- failed
	Error            string     `json:"error,omitempty"`
	ImportStarted    *time.Time `json:"import_started,omitempty"`
	ImportCompleted  *time.Time `json:"import_completed,omitempty"`
	PublishStarted   *time.Time `json:"publish_started,omitempty"`
	PublishCompleted *time.Time `json:"publish_completed,omitempty"`
}

ImageDownload represents the fields for an Image Download

type ImageDownloadLinks struct {
	Self  string `json:"self"`
	Image string `json:"image"`
}

ImageDownloadLinks represents the fields for the image download HATEOAS links

type ImageDownloads

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

ImageDownloads represents the fields for a group of image download variants as returned by Image API

type ImageLinks struct {
	Self      string `json:"self"`
	Downloads string `json:"downloads"`
}

ImageLinks represents the fields for the image HATEOAS links

type ImageUpload

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

ImageUpload represents the fields for an Image Upload

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"`
}

Images represents the fields for a group of images as returned by Image API

type License

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

License represents the fields for an Image License

type NewImage

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

NewImage represents the fields required to create a new Image

type NewImageDownload

type NewImageDownload struct {
	Id      string `json:"id,omitempty"`
	Height  *int   `json:"height,omitempty"`
	Palette string `json:"palette,omitempty"`
	Size    int    `json:"size,omitempty"`
	Type    string `json:"type,omitempty"`
	Width   *int   `json:"width,omitempty"`
	State   string `json:"state,omitempty"`
	//enum:
	//- importing
	ImportStarted *time.Time `json:"import_started,omitempty"`
}

NewImageDownload represents the fields for an Image Download

Jump to

Keyboard shortcuts

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