form

package
v0.0.0-...-1ac8e50 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package form contains tagged structs for input value validation.

Copyright (c) 2018 - 2024 PhotoPrism UG. All rights reserved.

This program is free software: you can redistribute it and/or modify
it under Version 3 of the GNU Affero General Public License (the "AGPL"):
<https://docs.photoprism.app/license/agpl>

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

The AGPL is supplemented by our Trademark and Brand Guidelines,
which describe how our Brand Assets may be used:
<https://www.photoprism.app/trademark>

Feel free to send an email to hello@photoprism.app if you have questions, want to support our work, or just want to say hello.

Additional information can be found in our Developer Guide: <https://docs.photoprism.app/developer-guide/>

Index

Constants

View Source
const (
	RefID       = "ref_id"
	SessionID   = "session_id"
	AccessToken = "access_token"
)

Variables

This section is empty.

Functions

func AsJson

func AsJson(frm interface{}) string

AsJson returns the form data as a JSON string or an empty string in case of error.

func AsReader

func AsReader(frm interface{}) io.Reader

AsReader returns the form data as io.Reader, e.g. for use in tests.

func ParseQueryString

func ParseQueryString(f SearchForm) (result error)

func Report

func Report(f interface{}) (rows [][]string, cols []string)

Report returns form fields as table rows for reports.

func Serialize

func Serialize(f interface{}, all bool) string

Serialize returns a string containing all non-empty fields and values of a struct.

func Unserialize

func Unserialize(f SearchForm, q string) (result error)

Types

type Album

type Album struct {
	Thumb            string `json:"Thumb"`
	ThumbSrc         string `json:"ThumbSrc"`
	AlbumType        string `json:"Type"`
	AlbumTitle       string `json:"Title"`
	AlbumLocation    string `json:"Location"`
	AlbumCategory    string `json:"Category"`
	AlbumCaption     string `json:"Caption"`
	AlbumDescription string `json:"Description"`
	AlbumNotes       string `json:"Notes"`
	AlbumFilter      string `json:"Filter"`
	AlbumOrder       string `json:"Order"`
	AlbumTemplate    string `json:"Template"`
	AlbumCountry     string `json:"Country"`
	AlbumFavorite    bool   `json:"Favorite"`
	AlbumPrivate     bool   `json:"Private"`
}

Album represents an album edit form.

func NewAlbum

func NewAlbum(m interface{}) (f Album, err error)

type ChangePassword

type ChangePassword struct {
	OldPassword string `json:"old"`
	NewPassword string `json:"new"`
}

ChangePassword represents a password update form.

type Client

type Client struct {
	UserUID      string `json:"UserUID,omitempty" yaml:"UserUID,omitempty"`
	UserName     string `gorm:"size:64;index;" json:"UserName" yaml:"UserName,omitempty"`
	ClientID     string `json:"ClientID,omitempty" yaml:"ClientID,omitempty"`
	ClientSecret string `json:"ClientSecret,omitempty" yaml:"ClientSecret,omitempty"`
	ClientName   string `json:"ClientName,omitempty" yaml:"ClientName,omitempty"`
	ClientRole   string `json:"ClientRole,omitempty" yaml:"ClientRole,omitempty"`
	AuthProvider string `json:"AuthProvider,omitempty" yaml:"AuthProvider,omitempty"`
	AuthMethod   string `json:"AuthMethod,omitempty" yaml:"AuthMethod,omitempty"`
	AuthScope    string `json:"AuthScope,omitempty" yaml:"AuthScope,omitempty"`
	AuthExpires  int64  `json:"AuthExpires,omitempty" yaml:"AuthExpires,omitempty"`
	AuthTokens   int64  `json:"AuthTokens,omitempty" yaml:"AuthTokens,omitempty"`
	AuthEnabled  bool   `json:"AuthEnabled,omitempty" yaml:"AuthEnabled,omitempty"`
}

Client represents client application settings.

func AddClientFromCli

func AddClientFromCli(ctx *cli.Context) Client

AddClientFromCli creates a new form for adding a client with values from the specified CLI context.

func ModClientFromCli

func ModClientFromCli(ctx *cli.Context) Client

ModClientFromCli creates a new form for modifying a client with values from the specified CLI context.

func NewClient

func NewClient() Client

NewClient creates new client application settings.

func (Client) Expires

func (f Client) Expires() int64

Expires returns the access token expiry time in seconds or 0 if not specified.

func (*Client) ID

func (f *Client) ID() string

ID returns the client id, if any.

func (*Client) Method

func (f *Client) Method() authn.MethodType

Method returns the sanitized auth method name.

func (*Client) Name

func (f *Client) Name() string

Name returns the sanitized client name.

func (*Client) Provider

func (f *Client) Provider() authn.ProviderType

Provider returns the sanitized auth provider name.

func (*Client) Role

func (f *Client) Role() string

Role returns the sanitized client role.

func (Client) Scope

func (f Client) Scope() string

Scope returns the client scopes as sanitized string.

func (*Client) Secret

func (f *Client) Secret() string

Secret returns the client secret, if any.

func (Client) Tokens

func (f Client) Tokens() int64

Tokens returns the access token limit or 0 if not specified.

type Connect

type Connect struct {
	Token string `json:"Token"`
}

Connect represents a connection request with an external service.

func (Connect) Invalid

func (f Connect) Invalid() bool

Invalid tests if the form data is invalid.

type Details

type Details struct {
	PhotoID      uint   `json:"PhotoID" deepcopier:"skip"`
	Keywords     string `json:"Keywords"`
	KeywordsSrc  string `json:"KeywordsSrc"`
	Notes        string `json:"Notes"`
	NotesSrc     string `json:"NotesSrc"`
	Subject      string `json:"Subject"`
	SubjectSrc   string `json:"SubjectSrc"`
	Artist       string `json:"Artist"`
	ArtistSrc    string `json:"ArtistSrc"`
	Copyright    string `json:"Copyright"`
	CopyrightSrc string `json:"CopyrightSrc"`
	License      string `json:"License"`
	LicenseSrc   string `json:"LicenseSrc"`
}

Details contains detailed photo information

type Face

type Face struct {
	FaceHidden bool   `json:"Hidden"`
	SubjUID    string `json:"SubjUID"`
}

Face represents a face edit form.

func NewFace

func NewFace(m interface{}) (f Face, err error)

type Feedback

type Feedback struct {
	Category    string `json:"Category"`
	Message     string `json:"Message"`
	UserName    string `json:"UserName"`
	UserEmail   string `json:"UserEmail"`
	UserAgent   string `json:"UserAgent"`
	UserLocales string `json:"UserLocales"`
}

Feedback represents support requests / customer feedback.

func NewFeedback

func NewFeedback(m interface{}) (f Feedback, err error)

func (Feedback) Empty

func (f Feedback) Empty() bool

type File

type File struct {
	FileOrientation int `json:"Orientation"`
}

File represents a file edit form.

func NewFile

func NewFile(m interface{}) (f File, err error)

func (*File) Orientation

func (f *File) Orientation() int

Orientation returns the Exif orientation value within a valid range or 0 if it is invalid.

type Folder

type Folder struct {
	Path              string `json:"Path"`
	Root              string `json:"Root"`
	FolderType        string `json:"Type"`
	FolderTitle       string `json:"Title"`
	FolderCategory    string `json:"Category"`
	FolderDescription string `json:"Description"`
	FolderOrder       string `json:"Order"`
	FolderCountry     string `json:"Country"`
	FolderYear        int    `json:"Year"`
	FolderMonth       int    `json:"Month"`
	FolderFavorite    bool   `json:"Favorite"`
	FolderPrivate     bool   `json:"Private"`
	FolderIgnore      bool   `json:"Ignore"`
	FolderWatch       bool   `json:"Watch"`
}

Folder represents a file system directory edit form.

func NewFolder

func NewFolder(m interface{}) (f Folder, err error)

type ImportOptions

type ImportOptions struct {
	Albums []string `json:"albums"`
	Path   string   `json:"path"`
	Move   bool     `json:"move"`
}

type IndexOptions

type IndexOptions struct {
	Path    string `json:"path"`
	Rescan  bool   `json:"rescan"`
	Cleanup bool   `json:"cleanup"`
}

type Label

type Label struct {
	LabelName     string `json:"Name"`
	Uncertainty   int    `json:"Uncertainty"`
	LabelPriority int    `json:"Priority"`
}

Label represents a label edit form.

type Link struct {
	Password    string `json:"Password"`
	ShareSlug   string `json:"Slug"`
	LinkToken   string `json:"Token"`
	LinkExpires int    `json:"Expires"`
	MaxViews    uint   `json:"MaxViews"`
	CanComment  bool   `json:"CanComment"`
	CanEdit     bool   `json:"CanEdit"`
}

Link represents a link sharing form.

type Login

type Login struct {
	Username string `json:"username,omitempty"` // The local Username or LDAP user principal name (UPN).
	Password string `json:"password,omitempty"` // The user's Password.
	Code     string `json:"code,omitempty"`     // 2FA Verification Code (Passcodes).
	Token    string `json:"token,omitempty"`    // Share Token.
	Email    string `json:"email,omitempty"`    // Reserved.
}

Login represents a login form.

func (Login) CleanEmail

func (f Login) CleanEmail() string

CleanEmail returns the sanitized and normalized email.

func (Login) CleanUsername

func (f Login) CleanUsername() string

CleanUsername returns the sanitized and normalized username.

func (Login) HasCredentials

func (f Login) HasCredentials() bool

HasCredentials checks if all credentials is set.

func (Login) HasPasscode

func (f Login) HasPasscode() bool

HasPasscode checks if a verification passcode has been provided.

func (Login) HasPassword

func (f Login) HasPassword() bool

HasPassword checks if a password is set.

func (Login) HasShareToken

func (f Login) HasShareToken() bool

HasShareToken checks if a link share token has been provided.

func (Login) HasUsername

func (f Login) HasUsername() bool

HasUsername checks if a username is set.

func (Login) Passcode

func (f Login) Passcode() string

Passcode returns the sanitized verification passcode.

type Marker

type Marker struct {
	FileUID       string  `json:"FileUID,omitempty"`
	MarkerType    string  `json:"Type,omitempty"`
	MarkerSrc     string  `json:"Src,omitempty"`
	X             float32 `json:"X"`
	Y             float32 `json:"Y"`
	W             float32 `json:"W,omitempty"`
	H             float32 `json:"H,omitempty"`
	SubjSrc       string  `json:"SubjSrc"`
	MarkerName    string  `json:"Name"`
	MarkerReview  bool    `json:"MarkerReview"`
	MarkerInvalid bool    `json:"Invalid"`
}

Marker represents an image marker edit form.

func NewMarker

func NewMarker(m interface{}) (f Marker, err error)

NewMarker creates a new form initialized with model values.

func (*Marker) Validate

func (frm *Marker) Validate() error

Validate returns an error if any form values are invalid.

type OAuthCreateToken

type OAuthCreateToken struct {
	GrantType    authn.GrantType `form:"grant_type" json:"grant_type,omitempty"`
	ClientID     string          `form:"client_id" json:"client_id,omitempty"`
	ClientName   string          `form:"client_name" json:"client_name,omitempty"`
	ClientSecret string          `form:"client_secret" json:" client_secret,omitempty"`
	Username     string          `form:"username" json:"username,omitempty"`
	Password     string          `form:"password" json:"password,omitempty"`
	RefreshToken string          `form:"refresh_token" json:"refresh_token,omitempty"`
	Code         string          `form:"code" json:"code,omitempty"`
	CodeVerifier string          `form:"code_verifier" json:"code_verifier,omitempty"`
	RedirectURI  string          `form:"redirect_uri" json:"redirect_uri,omitempty"`
	Assertion    string          `form:"assertion" json:"assertion,omitempty"`
	Scope        string          `form:"scope" json:"scope,omitempty"`
	ExpiresIn    int64           `form:"expires_in" json:"expires_in,omitempty"`
}

OAuthCreateToken represents a create token request form.

func (OAuthCreateToken) CleanScope

func (f OAuthCreateToken) CleanScope() string

CleanScope returns the client scopes as sanitized string.

func (OAuthCreateToken) Validate

func (f OAuthCreateToken) Validate() error

Validate verifies the request parameters depending on the grant type.

type OAuthRevokeToken

type OAuthRevokeToken struct {
	Token         string `form:"token" binding:"required" json:"token,omitempty"`
	TokenTypeHint string `form:"token_type_hint" json:" token_type_hint,omitempty"`
}

OAuthRevokeToken represents a token revokation form.

func (*OAuthRevokeToken) Empty

func (f *OAuthRevokeToken) Empty() bool

Empty checks if all form values are unset.

func (*OAuthRevokeToken) Validate

func (f *OAuthRevokeToken) Validate() error

Validate checks the revoke token form values and returns an error if invalid.

type Passcode

type Passcode struct {
	Type     string `form:"type" json:"type,omitempty"`
	Password string `form:"password" json:"password,omitempty"`
	Code     string `form:"code" json:"code,omitempty"`
}

Passcode represents a multi-factor authentication key setup form.

func (Passcode) HasPasscode

func (f Passcode) HasPasscode() bool

HasPasscode checks if a verification code has been provided.

func (Passcode) HasPassword

func (f Passcode) HasPassword() bool

HasPassword checks if a password has been provided.

func (Passcode) Passcode

func (f Passcode) Passcode() string

Passcode returns the sanitized verification code.

type Photo

type Photo struct {
	PhotoType        string    `json:"Type"`
	TypeSrc          string    `json:"TypeSrc"`
	TakenAt          time.Time `json:"TakenAt"`
	TakenAtLocal     time.Time `json:"TakenAtLocal"`
	TakenSrc         string    `json:"TakenSrc"`
	TimeZone         string    `json:"TimeZone"`
	PhotoYear        int       `json:"Year"`
	PhotoMonth       int       `json:"Month"`
	PhotoDay         int       `json:"Day"`
	PhotoTitle       string    `json:"Title"`
	TitleSrc         string    `json:"TitleSrc"`
	PhotoDescription string    `json:"Description"`
	DescriptionSrc   string    `json:"DescriptionSrc"`
	Details          Details   `json:"Details"`
	PhotoStack       int8      `json:"Stack"`
	PhotoFavorite    bool      `json:"Favorite"`
	PhotoPrivate     bool      `json:"Private"`
	PhotoScan        bool      `json:"Scan"`
	PhotoPanorama    bool      `json:"Panorama"`
	PhotoAltitude    int       `json:"Altitude"`
	PhotoLat         float32   `json:"Lat"`
	PhotoLng         float32   `json:"Lng"`
	PhotoIso         int       `json:"Iso"`
	PhotoFocalLength int       `json:"FocalLength"`
	PhotoFNumber     float32   `json:"FNumber"`
	PhotoExposure    string    `json:"Exposure"`
	PhotoCountry     string    `json:"Country"`
	CellID           string    `json:"CellID"`
	CellAccuracy     int       `json:"CellAccuracy"`
	PlaceID          string    `json:"PlaceID"`
	PlaceSrc         string    `json:"PlaceSrc"`
	CameraID         uint      `json:"CameraID"`
	CameraSrc        string    `json:"CameraSrc"`
	LensID           uint      `json:"LensID"`
	OriginalName     string    `json:"OriginalName"`
}

Photo represents a photo edit form.

func NewPhoto

func NewPhoto(m interface{}) (f Photo, err error)

NewPhoto creates Photo struct from interface

type SearchAlbums

type SearchAlbums struct {
	Query    string `form:"q"`
	UID      string `form:"uid"`
	Type     string `form:"type"`
	Location string `form:"location"`
	Category string `form:"category"`
	Slug     string `form:"slug"`
	Title    string `form:"title"`
	Country  string `json:"country"`
	Year     string `form:"year" example:"year:1990|2003" notes:"Year (separate with |)"`
	Month    string `form:"month" example:"month:7|10" notes:"Month (1-12, separate with |)"`
	Day      string `form:"day" example:"day:3|13" notes:"Day of Month (1-31, separate with |)"`
	Favorite bool   `form:"favorite"`
	Public   bool   `form:"public"`
	Private  bool   `form:"private"`
	Count    int    `form:"count" binding:"required" serialize:"-"`
	Offset   int    `form:"offset" serialize:"-"`
	Order    string `form:"order" serialize:"-"`
}

SearchAlbums represents search form fields for "/api/v1/albums".

func NewAlbumSearch

func NewAlbumSearch(query string) SearchAlbums

func (*SearchAlbums) GetQuery

func (f *SearchAlbums) GetQuery() string

func (*SearchAlbums) ParseQueryString

func (f *SearchAlbums) ParseQueryString() error

func (*SearchAlbums) SetQuery

func (f *SearchAlbums) SetQuery(q string)

type SearchFaces

type SearchFaces struct {
	Query   string `form:"q"`
	UID     string `form:"uid"`
	Subject string `form:"subject"`
	Unknown string `form:"unknown"`
	Hidden  string `form:"hidden"`
	Markers bool   `form:"markers"`
	Count   int    `form:"count" binding:"required" serialize:"-"`
	Offset  int    `form:"offset" serialize:"-"`
	Order   string `form:"order" serialize:"-"`
}

SearchFaces represents search form fields for "/api/v1/faces".

func NewFaceSearch

func NewFaceSearch(query string) SearchFaces

func (*SearchFaces) GetQuery

func (f *SearchFaces) GetQuery() string

func (*SearchFaces) ParseQueryString

func (f *SearchFaces) ParseQueryString() error

func (*SearchFaces) SetQuery

func (f *SearchFaces) SetQuery(q string)

type SearchFolders

type SearchFolders struct {
	Query     string `form:"q"`
	Recursive bool   `form:"recursive"`
	Files     bool   `form:"files"`
	Uncached  bool   `form:"uncached"`
	Public    bool   `form:"public"`
	Count     int    `form:"count" serialize:"-"`
	Offset    int    `form:"offset" serialize:"-"`
}

SearchFolders represents search form fields for "/api/v1/folders".

func (*SearchFolders) GetQuery

func (f *SearchFolders) GetQuery() string

func (*SearchFolders) ParseQueryString

func (f *SearchFolders) ParseQueryString() error

func (*SearchFolders) Serialize

func (f *SearchFolders) Serialize() string

Serialize returns a string containing non-empty fields and values of a struct.

func (*SearchFolders) SerializeAll

func (f *SearchFolders) SerializeAll() string

SerializeAll returns a string containing all non-empty fields and values of a struct.

func (*SearchFolders) SetQuery

func (f *SearchFolders) SetQuery(q string)

type SearchForm

type SearchForm interface {
	GetQuery() string
	SetQuery(q string)
}

type SearchLabels

type SearchLabels struct {
	Query    string `form:"q"`
	UID      string `form:"uid"`
	Slug     string `form:"slug"`
	Name     string `form:"name"`
	All      bool   `form:"all"`
	Favorite bool   `form:"favorite"`
	Count    int    `form:"count" binding:"required" serialize:"-"`
	Offset   int    `form:"offset" serialize:"-"`
	Order    string `form:"order" serialize:"-"`
}

SearchLabels represents search form fields for "/api/v1/labels".

func NewLabelSearch

func NewLabelSearch(query string) SearchLabels

func (*SearchLabels) GetQuery

func (f *SearchLabels) GetQuery() string

func (*SearchLabels) ParseQueryString

func (f *SearchLabels) ParseQueryString() error

func (*SearchLabels) SetQuery

func (f *SearchLabels) SetQuery(q string)

type SearchPhotos

type SearchPhotos struct {
	Query     string  `form:"q"`
	Scope     string  `form:"s" serialize:"-" example:"s:ariqwb43p5dh9h13" notes:"Limits the results to one album or another scope, if specified"`
	Filter    string  `form:"filter" serialize:"-" notes:"-"`
	ID        string  `form:"id" example:"id:123e4567-e89b-..." notes:"Finds pictures by Exif UID, XMP Document ID or Instance ID"`
	UID       string  `form:"uid" example:"uid:pqbcf5j446s0futy" notes:"Limits results to the specified internal unique IDs"`
	Type      string  `form:"type" example:"type:raw" notes:"Media Type (image, video, raw, live, animated); separate with |"`
	Path      string  `form:"path" example:"path:2020/Holiday" notes:"Path Name (separate with |), supports * wildcards"`
	Folder    string  `form:"folder" example:"folder:\"*/2020\"" notes:"Path Name (separate with |), supports * wildcards"` // Alias for Path
	Name      string  `form:"name" example:"name:\"IMG_9831-112*\"" notes:"File Name without path and extension (separate with |)"`
	Filename  string  `form:"filename" example:"filename:\"2021/07/12345.jpg\"" notes:"File Name with path and extension (separate with |)"`
	Original  string  `form:"original" example:"original:\"IMG_9831-112*\"" notes:"Original file name of imported files (separate with |)"`
	Title     string  `form:"title" example:"title:\"Lake*\"" notes:"Title (separate with |)"`
	Hash      string  `form:"hash" example:"hash:2fd4e1c67a2d" notes:"SHA1 File Hash (separate with |)"`
	Primary   bool    `form:"primary" notes:"Finds primary JPEG files only"`
	Stack     bool    `form:"stack" notes:"Finds pictures with more than one media file"`
	Unstacked bool    `form:"unstacked" notes:"Finds pictures with a file that has been removed from a stack"`
	Stackable bool    `form:"stackable" notes:"Finds pictures that can be stacked with additional media files"`
	Video     bool    `form:"video" notes:"Finds video files only"`
	Vector    bool    `form:"vector" notes:"Finds vector graphics only"`
	Animated  bool    `form:"animated" notes:"Finds animated GIFs"`
	Photo     bool    `form:"photo" notes:"Finds only photos, no videos"`
	Raw       bool    `form:"raw" notes:"Finds pictures with RAW image file"`
	Live      bool    `form:"live" notes:"Finds Live Photos and short videos"`
	Scan      string  `form:"scan" example:"scan:true scan:false" notes:"Finds scanned photos and documents"`
	Mp        string  `form:"mp" example:"mp:3-6" notes:"Resolution in Megapixels (MP)"`
	Panorama  bool    `form:"panorama" notes:"Finds pictures with an aspect ratio > 1.9:1"`
	Portrait  bool    `form:"portrait" notes:"Finds pictures in portrait format"`
	Landscape bool    `form:"landscape" notes:"Finds pictures in landscape format"`
	Square    bool    `form:"square" notes:"Finds images with an aspect ratio of 1:1"`
	Error     bool    `form:"error" notes:"Finds pictures with errors"`
	Hidden    bool    `form:"hidden" notes:"Finds hidden pictures (broken or unsupported)"`
	Archived  bool    `form:"archived" notes:"Finds archived pictures"`
	Public    bool    `form:"public" notes:"Excludes private pictures"`
	Private   bool    `form:"private" notes:"Finds private pictures"`
	Favorite  string  `form:"favorite" example:"favorite:true favorite:false" notes:"Finds images by favorite status"`
	Unsorted  bool    `form:"unsorted" notes:"Finds pictures not in an album"`
	Near      string  `form:"near" example:"near:pqbcf5j446s0futy" notes:"Finds nearby pictures (UID)"`
	S2        string  `form:"s2" example:"s2:4799e370ca54c8b9"  notes:"S2 Position (Cell ID)"`
	Olc       string  `form:"olc" example:"olc:8FWCHX7W+" notes:"OLC Position (Open Location Code)"`
	Lat       float64 `form:"lat" example:"lat:41.894043" notes:"GPS Position (Latitude)"`
	Lng       float64 `form:"lng" example:"lng:-87.62448" notes:"GPS Position (Longitude)"`
	Alt       string  `form:"alt" example:"alt:300-500" notes:"GPS Altitude (m)"`
	Dist      float64 `form:"dist" example:"dist:50" notes:"Distance to Position (km)"`
	Latlng    string  `form:"latlng" notes:"GPS Bounding Box (Lat N, Lng E, Lat S, Lng W)"`
	Camera    string  `form:"camera" example:"camera:canon" notes:"Camera Make/Model Name"` // Camera UID or name
	Lens      string  `form:"lens" example:"lens:ef24" notes:"Lens Make/Model Name"`        // Lens UID or name
	Iso       string  `form:"iso" example:"iso:200-400" notes:"ISO Number (light sensitivity)"`
	Mm        string  `form:"mm" example:"mm:28-35" notes:"Focal Length (35mm equivalent)"`
	F         string  `form:"f" example:"f:2.8-4.5" notes:"Aperture (f-number)"`
	Color     string  `` // Main color
	/* 187-byte string literal not displayed */
	Chroma   int16     `form:"chroma" example:"chroma:70" notes:"Chroma (0-100)"`
	Mono     bool      `form:"mono" notes:"Finds pictures with few or no colors"`
	Diff     uint32    `form:"diff" notes:"Differential Perceptual Hash (000000-FFFFFF)"`
	Geo      string    `form:"geo" example:"geo:yes" notes:"Finds pictures with or without coordinates"`
	Keywords string    `form:"keywords" example:"keywords:\"sand&water\"" notes:"Keywords (combinable with & and |)"`
	Label    string    `form:"label" example:"label:cat|dog" notes:"Label Names (separate with |)"`
	Category string    `form:"category" example:"category:airport" notes:"Location Category"`
	Country  string    `form:"country" example:"country:\"de|us\"" notes:"Location Country Code (separate with |)"`                            // Moments
	State    string    `form:"state" example:"state:\"Baden-Württemberg\"" notes:"Location State (separate with |)"`                           // Moments
	City     string    `form:"city" example:"city:\"Berlin\"" notes:"Location City (separate with |)"`                                         // Moments
	Year     string    `form:"year" example:"year:1990|2003" notes:"Year (separate with |)"`                                                   // Moments
	Month    string    `form:"month" example:"month:7|10" notes:"Month (1-12, separate with |)"`                                               // Moments
	Day      string    `form:"day" example:"day:3|13" notes:"Day of Month (1-31, separate with |)"`                                            // Moments
	Face     string    `form:"face" example:"face:PN6QO5INYTUSAATOFL43LL2ABAV5ACZG" notes:"Face ID, yes, no, new, or kind"`                    // UIDs
	Faces    string    `form:"faces" example:"faces:yes faces:3" notes:"Minimum number of Faces (yes = 1)"`                                    // Find or exclude faces if detected.
	Subject  string    `form:"subject" example:"subject:\"Jane Doe & John Doe\"" notes:"Alias for person"`                                     // UIDs
	Person   string    `form:"person" example:"person:\"Jane Doe & John Doe\"" notes:"Subject Names, exact matches (combinable with & and |)"` // Alias for Subject
	Subjects string    `form:"subjects" example:"subjects:\"Jane & John\"" notes:"Alias for people"`                                           // People names
	People   string    `form:"people" example:"people:\"Jane & John\"" notes:"Subject Names (combinable with & and |)"`                        // Alias for Subjects
	Album    string    `form:"album" example:"album:berlin" notes:"Album UID or Name, supports * wildcards"`                                   // Album UIDs or name
	Albums   string    `form:"albums" example:"albums:\"South Africa & Birds\"" notes:"Album Names (combinable with & and |)"`                 // Multi search with and/or
	Quality  int       `form:"quality" notes:"Minimum quality score (1-7)"`                                                                    // Photo quality score
	Review   bool      `form:"review" notes:"Finds pictures in review"`                                                                        // Find photos in review
	Before   time.Time `form:"before" time_format:"2006-01-02" notes:"Finds pictures taken before this date"`                                  // Finds images taken before date
	After    time.Time `form:"after" time_format:"2006-01-02" notes:"Finds pictures taken after this date"`                                    // Finds images taken after date
	Count    int       `form:"count" binding:"required" serialize:"-"`                                                                         // Result FILE limit
	Offset   int       `form:"offset" serialize:"-"`                                                                                           // Result FILE offset
	Order    string    `form:"order" serialize:"-"`                                                                                            // Sort order
	Merged   bool      `form:"merged" serialize:"-"`                                                                                           // Merge FILES in response
}

SearchPhotos represents search form fields for "/api/v1/photos".

func NewSearchPhotos

func NewSearchPhotos(query string) SearchPhotos

func (*SearchPhotos) FindUidOnly

func (f *SearchPhotos) FindUidOnly() bool

FindUidOnly checks if search filters other than UID may be skipped to improve performance.

func (*SearchPhotos) GetQuery

func (f *SearchPhotos) GetQuery() string

func (*SearchPhotos) ParseQueryString

func (f *SearchPhotos) ParseQueryString() error

func (*SearchPhotos) Serialize

func (f *SearchPhotos) Serialize() string

Serialize returns a string containing non-empty fields and values of a struct.

func (*SearchPhotos) SerializeAll

func (f *SearchPhotos) SerializeAll() string

SerializeAll returns a string containing all non-empty fields and values of a struct.

func (*SearchPhotos) SetQuery

func (f *SearchPhotos) SetQuery(q string)

type SearchPhotosGeo

type SearchPhotosGeo struct {
	Query     string    `form:"q"`
	Scope     string    `form:"s" serialize:"-" example:"s:ariqwb43p5dh9h13" notes:"Limits the results to one album or another scope, if specified"`
	Filter    string    `form:"filter" serialize:"-" notes:"-"`
	ID        string    `form:"id" example:"id:123e4567-e89b-..." notes:"Finds pictures by Exif UID, XMP Document ID or Instance ID"`
	UID       string    `form:"uid" example:"uid:pqbcf5j446s0futy" notes:"Limits results to the specified internal unique IDs"`
	Type      string    `form:"type"`
	Path      string    `form:"path"`
	Folder    string    `form:"folder"` // Alias for Path
	Name      string    `form:"name"`
	Title     string    `form:"title"`
	Before    time.Time `form:"before" time_format:"2006-01-02"`
	After     time.Time `form:"after" time_format:"2006-01-02"`
	Favorite  string    `form:"favorite" example:"favorite:yes" notes:"Finds favorites only"`
	Unsorted  bool      `form:"unsorted"`
	Video     bool      `form:"video"`
	Vector    bool      `form:"vector"`
	Animated  bool      `form:"animated"`
	Photo     bool      `form:"photo"`
	Raw       bool      `form:"raw"`
	Live      bool      `form:"live"`
	Scan      string    `form:"scan" example:"scan:true scan:false" notes:"Finds scanned photos and documents"`
	Mp        string    `form:"mp" example:"mp:3-6" notes:"Resolution in Megapixels (MP)"`
	Panorama  bool      `form:"panorama"`
	Portrait  bool      `form:"portrait"`
	Landscape bool      `form:"landscape"`
	Square    bool      `form:"square"`
	Archived  bool      `form:"archived"`
	Public    bool      `form:"public"`
	Private   bool      `form:"private"`
	Review    bool      `form:"review"`
	Quality   int       `form:"quality" notes:"Minimum quality score (1-7)"`
	Face      string    `form:"face" notes:"Face ID, yes, no, new, or kind"`
	Faces     string    `form:"faces"` // Find or exclude faces if detected.
	Subject   string    `form:"subject"`
	Near      string    `form:"near" example:"near:pqbcf5j446s0futy" notes:"Finds nearby pictures (UID)"`
	S2        string    `form:"s2" example:"s2:4799e370ca54c8b9"  notes:"S2 Position (Cell ID)"`
	Olc       string    `form:"olc" example:"olc:8FWCHX7W+" notes:"OLC Position (Open Location Code)"`
	Lat       float64   `form:"lat" example:"lat:41.894043" notes:"GPS Position (Latitude)"`
	Lng       float64   `form:"lng" example:"lng:-87.62448" notes:"GPS Position (Longitude)"`
	Alt       string    `form:"alt" example:"alt:300-500" notes:"GPS Altitude (m)"`
	Dist      float64   `form:"dist" example:"dist:50" notes:"Distance to Position (km)"`
	Latlng    string    `form:"latlng" notes:"GPS Bounding Box (Lat N, Lng E, Lat S, Lng W)"`
	Camera    int       `form:"camera"`
	Lens      int       `form:"lens"`
	Iso       string    `form:"iso" example:"iso:200-400" notes:"ISO Number (light sensitivity)"`
	Mm        string    `form:"mm" example:"mm:28-35" notes:"Focal Length (35mm equivalent)"`
	F         string    `form:"f" example:"f:2.8-4.5" notes:"Aperture (f-number)"`
	Color     string    `form:"color"`
	Chroma    int16     `form:"chroma" example:"chroma:70" notes:"Chroma (0-100)"`
	Mono      bool      `form:"mono" notes:"Finds pictures with few or no colors"`
	Person    string    `form:"person"`   // Alias for Subject
	Subjects  string    `form:"subjects"` // Text
	People    string    `form:"people"`   // Alias for Subjects
	Keywords  string    `form:"keywords" example:"keywords:\"sand&water\"" notes:"Keywords (combinable with & and |)"`
	Label     string    `form:"label" example:"label:cat|dog" notes:"Label Names (separate with |)"`
	Category  string    `form:"category" example:"category:airport" notes:"Location Category"`
	Album     string    `form:"album" example:"album:berlin" notes:"Album UID or Name, supports * wildcards"`
	Albums    string    `form:"albums" example:"albums:\"South Africa & Birds\"" notes:"Album Names (combinable with & and |)"`
	Country   string    `form:"country"`
	State     string    `form:"state"` // Moments
	City      string    `form:"city"`
	Year      string    `form:"year"`  // Moments
	Month     string    `form:"month"` // Moments
	Day       string    `form:"day"`   // Moments
	Count     int       `form:"count" serialize:"-"`
	Offset    int       `form:"offset" serialize:"-"`
}

SearchPhotosGeo represents search form fields for "/api/v1/geo".

func NewSearchPhotosGeo

func NewSearchPhotosGeo(query string) SearchPhotosGeo

func (*SearchPhotosGeo) FindUidOnly

func (f *SearchPhotosGeo) FindUidOnly() bool

FindUidOnly checks if search filters other than UID may be skipped to improve performance.

func (*SearchPhotosGeo) GetQuery

func (f *SearchPhotosGeo) GetQuery() string

GetQuery returns the query parameter as string.

func (*SearchPhotosGeo) ParseQueryString

func (f *SearchPhotosGeo) ParseQueryString() error

ParseQueryString parses the query parameter if possible.

func (*SearchPhotosGeo) Serialize

func (f *SearchPhotosGeo) Serialize() string

Serialize returns a string containing non-empty fields and values of a struct.

func (*SearchPhotosGeo) SerializeAll

func (f *SearchPhotosGeo) SerializeAll() string

SerializeAll returns a string containing all non-empty fields and values of a struct.

func (*SearchPhotosGeo) SetQuery

func (f *SearchPhotosGeo) SetQuery(q string)

SetQuery sets the query parameter.

type SearchServices

type SearchServices struct {
	Query  string `form:"q"`
	Share  bool   `form:"share"`
	Sync   bool   `form:"sync"`
	Status string `form:"status"`
	Count  int    `form:"count" binding:"required" serialize:"-"`
	Offset int    `form:"offset" serialize:"-"`
	Order  string `form:"order" serialize:"-"`
}

SearchServices represents search form fields for "/api/v1/services".

func NewSearchServices

func NewSearchServices(query string) SearchServices

func (*SearchServices) GetQuery

func (f *SearchServices) GetQuery() string

func (*SearchServices) ParseQueryString

func (f *SearchServices) ParseQueryString() error

func (*SearchServices) SetQuery

func (f *SearchServices) SetQuery(q string)

type SearchSessions

type SearchSessions struct {
	Query    string `form:"q"`
	UID      string `form:"uid"`
	Provider string `form:"provider"`
	Method   string `form:"method"`
	Count    int    `form:"count" binding:"required" serialize:"-"`
	Offset   int    `form:"offset" serialize:"-"`
	Order    string `form:"order" serialize:"-"`
}

SearchSessions represents a session search form.

func (*SearchSessions) AuthMethods

func (f *SearchSessions) AuthMethods() []authn.MethodType

AuthMethods returns the normalized authentication method types.

func (*SearchSessions) AuthProviders

func (f *SearchSessions) AuthProviders() []authn.ProviderType

AuthProviders returns the normalized authentication provider types.

func (*SearchSessions) GetQuery

func (f *SearchSessions) GetQuery() string

GetQuery returns the query string.

func (*SearchSessions) ParseQueryString

func (f *SearchSessions) ParseQueryString() error

ParseQueryString parses the query string into form fields.

func (*SearchSessions) SetQuery

func (f *SearchSessions) SetQuery(q string)

SetQuery sets the query string.

type SearchSubjects

type SearchSubjects struct {
	Query    string `form:"q"`
	UID      string `form:"uid"`
	Type     string `form:"type"`
	Name     string `form:"name"`
	All      bool   `form:"all"`
	Hidden   string `form:"hidden"`
	Favorite string `form:"favorite"`
	Private  string `form:"private"`
	Excluded string `form:"excluded"`
	Files    int    `form:"files"`
	Photos   int    `form:"photos"`
	Count    int    `form:"count" binding:"required" serialize:"-"`
	Offset   int    `form:"offset" serialize:"-"`
	Order    string `form:"order" serialize:"-"`
}

SearchSubjects represents search form fields for "/api/v1/subjects".

func NewSubjectSearch

func NewSubjectSearch(query string) SearchSubjects

func (*SearchSubjects) GetQuery

func (f *SearchSubjects) GetQuery() string

func (*SearchSubjects) ParseQueryString

func (f *SearchSubjects) ParseQueryString() error

func (*SearchSubjects) SetQuery

func (f *SearchSubjects) SetQuery(q string)

type SearchUsers

type SearchUsers struct {
	User   string `form:"user"`
	Query  string `form:"q"`
	Name   string `form:"name"`
	Email  string `form:"email"`
	Count  int    `form:"count" binding:"required" serialize:"-"`
	Offset int    `form:"offset" serialize:"-"`
	Order  string `form:"order" serialize:"-"`
}

SearchUsers represents a user search form.

func (*SearchUsers) GetQuery

func (f *SearchUsers) GetQuery() string

func (*SearchUsers) ParseQueryString

func (f *SearchUsers) ParseQueryString() error

func (*SearchUsers) SetQuery

func (f *SearchUsers) SetQuery(q string)

type Selection

type Selection struct {
	All      bool     `json:"all"`
	Files    []string `json:"files"`
	Photos   []string `json:"photos"`
	Albums   []string `json:"albums"`
	Labels   []string `json:"labels"`
	Places   []string `json:"places"`
	Subjects []string `json:"subjects"`
}

Selection represents items selected in the user interface.

func (Selection) Empty

func (f Selection) Empty() bool

Empty checks if any specific items were selected.

func (Selection) Get

func (f Selection) Get() []string

Get returns a string slice with the selected item UIDs.

func (Selection) String

func (f Selection) String() string

String returns a string containing all selected item UIDs.

type Service

type Service struct {
	AccName       string `json:"AccName"`
	AccOwner      string `json:"AccOwner"`
	AccURL        string `json:"AccURL"`
	AccType       string `json:"AccType"`
	AccKey        string `json:"AccKey"`
	AccUser       string `json:"AccUser"`
	AccPass       string `json:"AccPass"`
	AccTimeout    string `json:"AccTimeout"` // Request timeout: default, high, medium, low, none
	AccError      string `json:"AccError"`
	AccShare      bool   `json:"AccShare"`   // Manual upload enabled, see SharePath, ShareSize, and ShareExpires.
	AccSync       bool   `json:"AccSync"`    // Background sync enabled, see SyncDownload and SyncUpload.
	RetryLimit    int    `json:"RetryLimit"` // Maximum number of failed requests.
	SharePath     string `json:"SharePath"`
	ShareSize     string `json:"ShareSize"`
	ShareExpires  int    `json:"ShareExpires"`
	SyncPath      string `json:"SyncPath"`
	SyncInterval  int    `json:"SyncInterval"`
	SyncUpload    bool   `json:"SyncUpload"`
	SyncDownload  bool   `json:"SyncDownload"`
	SyncFilenames bool   `json:"SyncFilenames"`
	SyncRaw       bool   `json:"SyncRaw"`
}

Service represents a remote service form for uploading, downloading or syncing media files.

func NewService

func NewService(m interface{}) (f Service, err error)

NewService creates a new service form.

func (*Service) Discovery

func (f *Service) Discovery() error

Discovery performs automatic service discovery.

type Subject

type Subject struct {
	SubjName     string `json:"Name"`
	SubjAlias    string `json:"Alias"`
	SubjAbout    string `json:"About"`
	SubjBio      string `json:"Bio"`
	SubjNotes    string `json:"Notes"`
	SubjFavorite bool   `json:"Favorite"`
	SubjHidden   bool   `json:"Hidden"`
	SubjPrivate  bool   `json:"Private"`
	SubjExcluded bool   `json:"Excluded"`
}

Subject represents an image subject edit form.

func NewSubject

func NewSubject(m interface{}) (f Subject, err error)

type SyncUpload

type SyncUpload struct {
	Selection Selection `json:"selection"`
	Folder    string    `json:"folder"`
}

type UploadOptions

type UploadOptions struct {
	Albums []string `json:"albums"`
}

type User

type User struct {
	UserName     string       `json:"Name,omitempty" yaml:"Name,omitempty"`
	AuthProvider string       `json:"AuthProvider,omitempty" yaml:"AuthProvider,omitempty"`
	AuthMethod   string       `json:"AuthMethod,omitempty" yaml:"AuthMethod,omitempty"`
	UserEmail    string       `json:"Email,omitempty" yaml:"Email,omitempty"`
	DisplayName  string       `json:"DisplayName,omitempty" yaml:"DisplayName,omitempty"`
	UserRole     string       `json:"Role,omitempty" yaml:"Role,omitempty"`
	SuperAdmin   bool         `json:"SuperAdmin,omitempty" yaml:"SuperAdmin,omitempty"`
	CanLogin     bool         `json:"CanLogin,omitempty" yaml:"CanLogin,omitempty"`
	WebDAV       bool         `json:"WebDAV,omitempty" yaml:"WebDAV,omitempty"`
	UserAttr     string       `json:"Attr,omitempty" yaml:"Attr,omitempty"`
	BasePath     string       `json:"BasePath,omitempty" yaml:"BasePath,omitempty"`
	UploadPath   string       `json:"UploadPath,omitempty" yaml:"UploadPath,omitempty"`
	Password     string       `json:"Password,omitempty" yaml:"Password,omitempty"`
	UserDetails  *UserDetails `json:"Details,omitempty"`
}

User represents a user account form.

func NewUserFromCli

func NewUserFromCli(ctx *cli.Context) User

NewUserFromCli creates a new form with values from a CLI context.

func (*User) Attr

func (f *User) Attr() string

Attr returns the sanitized user account attributes.

func (*User) Email

func (f *User) Email() string

Email returns the sanitized email in lowercase.

func (*User) Method

func (f *User) Method() authn.MethodType

Method returns the sanitized auth method name.

func (*User) Provider

func (f *User) Provider() authn.ProviderType

Provider returns the sanitized auth provider name.

func (*User) Role

func (f *User) Role() string

Role returns the sanitized user role string.

func (*User) Username

func (f *User) Username() string

Username returns the sanitized username in lowercase.

type UserDetails

type UserDetails struct {
	BirthYear    int    `json:"BirthYear"`
	BirthMonth   int    `json:"BirthMonth"`
	BirthDay     int    `json:"BirthDay"`
	NameTitle    string `json:"NameTitle"`
	GivenName    string `json:"GivenName"`
	MiddleName   string `json:"MiddleName"`
	FamilyName   string `json:"FamilyName"`
	NameSuffix   string `json:"NameSuffix"`
	NickName     string `json:"NickName"`
	NameSrc      string `json:"NameSrc"`
	UserGender   string `json:"Gender"`
	UserAbout    string `json:"About"`
	UserBio      string `json:"Bio"`
	UserLocation string `json:"Location"`
	UserCountry  string `json:"Country"`
	UserPhone    string `json:"Phone"`
	SiteURL      string `json:"SiteURL"`
	ProfileURL   string `json:"ProfileURL"`
	FeedURL      string `json:"FeedURL"`
	OrgTitle     string `json:"OrgTitle"`
	OrgName      string `json:"OrgName"`
	OrgEmail     string `json:"OrgEmail"`
	OrgPhone     string `json:"OrgPhone"`
	OrgURL       string `json:"OrgURL"`
}

UserDetails represents a user details form.

Jump to

Keyboard shortcuts

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