models

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const MaxFilenameLen = 40

MaxFilenameLen is the maximum number of characters allowed for Image filenames

Variables

This section is empty.

Functions

This section is empty.

Types

type Download

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

Download represents a download variant model

type Image

type Image struct {
	ID           string                         `bson:"_id,omitempty"           json:"id,omitempty"`
	CollectionID string                         `bson:"collection_id,omitempty" json:"collection_id,omitempty"`
	State        string                         `bson:"state,omitempty"         json:"state,omitempty"`
	Filename     string                         `bson:"filename,omitempty"      json:"filename,omitempty"`
	License      *License                       `bson:"license,omitempty"       json:"license,omitempty"`
	Upload       *Upload                        `bson:"upload,omitempty"        json:"upload,omitempty"`
	Type         string                         `bson:"type,omitempty"          json:"type,omitempty"`
	Downloads    map[string]map[string]Download `bson:"downloads,omitempty"     json:"downloads,omitempty"`
}

Image represents an image metadata model as it is stored in mongoDB and json representation for API

func (*Image) StateTransitionAllowed

func (i *Image) StateTransitionAllowed(target string) bool

StateTransitionAllowed checks if the image can transition from its current state to the provided target state

func (*Image) Validate

func (i *Image) Validate() error

Validate checks that an image struct complies with the filename and state constraints, if provided.

type Images

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

Images represents an array of images model as it is stored in mongoDB and json representation for API

type License

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

License represents a license model

type State

type State int

State - iota enum of possible image states

const (
	StateCreated State = iota
	StateUploaded
	StatePublishing
	StatePublished
	StateDeleted
)

Possible values for a State of an image. It can only be one of the following:

func ParseState

func ParseState(stateStr string) (State, error)

ParseState returns a state from its string representation

func (State) String

func (s State) String() string

String returns the string representation of a state

func (State) TransitionAllowed

func (s State) TransitionAllowed(target State) bool

TransitionAllowed returns true only if the transition from the current state and the provided targetState is allowed

type Upload

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

Upload represents an upload model

Jump to

Keyboard shortcuts

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