Documentation ¶
Index ¶
- Constants
- type Download
- type DownloadLinks
- type DownloadState
- type Downloads
- type Image
- func (i *Image) AllDownloadsOfState(s DownloadState) bool
- func (i *Image) AnyDownloadsOfState(s DownloadState) bool
- func (i *Image) StateTransitionAllowed(target string) bool
- func (i *Image) UpdatedState() string
- func (i *Image) Validate() error
- func (i *Image) ValidateTransitionFrom(existing *Image) error
- type ImageLinks
- type Images
- type License
- type State
- type Upload
Constants ¶
const MaxFilenameLen = 500
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 { ID string `bson:"id,omitempty" json:"id,omitempty"` Height *int `bson:"height,omitempty" json:"height,omitempty"` Href string `json:"href,omitempty"` Palette string `bson:"palette,omitempty" json:"palette,omitempty"` Private string `bson:"private,omitempty" json:"private,omitempty"` Public bool `json:"public,omitempty"` Size *int `bson:"size,omitempty" json:"size,omitempty"` Type string `bson:"type,omitempty" json:"type,omitempty"` Width *int `bson:"width,omitempty" json:"width,omitempty"` Links *DownloadLinks `bson:"links,omitempty" json:"links,omitempty"` State string `bson:"state,omitempty" json:"state,omitempty"` Error string `bson:"error,omitempty" json:"error,omitempty"` ImportStarted *time.Time `bson:"import_started,omitempty" json:"import_started,omitempty"` ImportCompleted *time.Time `bson:"import_completed,omitempty" json:"import_completed,omitempty"` PublishStarted *time.Time `bson:"publish_started,omitempty" json:"publish_started,omitempty"` PublishCompleted *time.Time `bson:"publish_completed,omitempty" json:"publish_completed,omitempty"` }
Download represents a download variant model
func (*Download) StateTransitionAllowed ¶ added in v0.5.0
StateTransitionAllowed checks if the download variant can transition from its current state to the provided target state
func (*Download) Validate ¶ added in v0.5.0
Validate checks that an download struct complies with the state name constraint, if provided.
func (*Download) ValidateForImage ¶ added in v0.10.0
ValidateForImage checks whether the new download state is valid for the specified parent image
func (*Download) ValidateTransitionFrom ¶ added in v0.10.0
ValidateTransitionFrom checks whether the new state is valid given the existing download state…
type DownloadLinks ¶ added in v0.9.0
type DownloadState ¶ added in v0.5.0
type DownloadState int
DownloadState - iota enum of possible image states
const ( StateDownloadPending DownloadState = iota StateDownloadImporting StateDownloadImported StateDownloadPublished StateDownloadCompleted StateDownloadFailed )
Possible values for a State of a download variant. It can only be one of the following:
func ParseDownloadState ¶ added in v0.5.0
func ParseDownloadState(downloadStateStr string) (DownloadState, error)
ParseDownloadState returns a download state from its string representation
func (DownloadState) String ¶ added in v0.5.0
func (ds DownloadState) String() string
String returns the string representation of a downlad state
func (DownloadState) TransitionAllowed ¶ added in v0.5.0
func (ds DownloadState) TransitionAllowed(target DownloadState) bool
TransitionAllowed returns true only if the transition from the current state and the provided target DownloadState is allowed
type Downloads ¶ added in v0.9.0
type Downloads 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 []Download `bson:"items,omitempty" json:"items"` TotalCount int `bson:"total_count,omitempty" json:"total_count"` }
Downloads represents an array of downloads model as it is stored in mongoDB and json representation for API
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"` Error string `bson:"error,omitempty" json:"error,omitempty"` Filename string `bson:"filename,omitempty" json:"filename,omitempty"` License *License `bson:"license,omitempty" json:"license,omitempty"` Links *ImageLinks `bson:"links,omitempty" json:"links,omitempty"` Upload *Upload `bson:"upload,omitempty" json:"upload,omitempty"` Type string `bson:"type,omitempty" json:"type,omitempty"` Downloads map[string]Download `bson:"downloads,omitempty" json:"-"` }
Image represents an image metadata model as it is stored in mongoDB and json representation for API
func (*Image) AllDownloadsOfState ¶ added in v0.10.0
func (i *Image) AllDownloadsOfState(s DownloadState) bool
AllDownloadsOfState returns trueOfS if all download variants are in specified state,
func (*Image) AnyDownloadsOfState ¶ added in v0.10.0
func (i *Image) AnyDownloadsOfState(s DownloadState) bool
AnyDownloadsOfState returns true if any image download variant is in specified state
func (*Image) StateTransitionAllowed ¶
StateTransitionAllowed checks if the image can transition from its current state to the provided target state
func (*Image) UpdatedState ¶ added in v0.10.0
UpdatedState returns a new image state based on the image's downloads and existing image state
func (*Image) Validate ¶
Validate checks that an image struct complies with the filename and state constraints, if provided.
func (*Image) ValidateTransitionFrom ¶ added in v0.10.0
ValidateTransitionFrom checks that this image state can be validly transitioned from the existing state
type ImageLinks ¶ added in v0.10.0
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 StateImporting StateImported StatePublished StateCompleted StateDeleted StateFailedImport StateFailedPublish )
Possible values for a State of an image. It can only be one of the following:
func ParseState ¶
ParseState returns a state from its string representation
func (State) TransitionAllowed ¶
TransitionAllowed returns true only if the transition from the current state and the provided targetState is allowed