Documentation ¶
Index ¶
- Variables
- func FilterByVisibilityTokens(filter bson.M, tokens []string) error
- type APIs
- type Categories
- type Dates
- type EventCountQuery
- type EventCountResult
- type EventGranularity
- type EventInfo
- type Events
- type FolderVisibilityTokenTarget
- type Folders
- type GroupListParams
- type GroupUpdate
- type Keywords
- type Locations
- type PhotoListKey
- type PhotoListParams
- type PhotoRandomListParams
- type Photos
- type TimelineGroups
- type Users
- type Visibility
Constants ¶
This section is empty.
Variables ¶
var ErrFolderNotFound = errors.New("Folder not found")
ErrFolderNotFound means that a folder could not be found
var ErrInvalidArgs = errors.New("Invalid arguments")
ErrInvalidArgs ia generic error for invalid argument values
var ErrInvalidFolderPath = errors.New("Invalid folder path")
ErrInvalidFolderPath means invalid path
var ErrInvalidID = errors.New("Invalid id")
ErrInvalidID is an error if the provided id is invalid
var ErrInvalidListParams = errors.New("Invalid list params")
ErrInvalidListParams indicates that the list parameters were invalid
var ErrNoVisibilityTokens = errors.New("No visibility tokens provided")
ErrNoVisibilityTokens is an error if there are no visibility tokens provided
var ErrPhotoInvalidResizeMaxLength = errors.New("Invalid resize max length")
ErrPhotoInvalidResizeMaxLength signifies an invalid resize max length
var ErrSessionNotFound = errors.New("No session found")
ErrSessionNotFound means that there was no session
var ErrUserExisting = errors.New("There is already at least one existing user")
ErrUserExisting means that no new users can be added because at least one user already exists
var ErrUserInvalidPassword = errors.New("Invalid password")
ErrUserInvalidPassword represents invalid password error
Functions ¶
Types ¶
type APIs ¶
type APIs struct { Categories Categories Dates Dates Events Events Folders Folders Keywords Keywords Locations Locations Photos Photos TimelineGroups TimelineGroups Users Users Visibility Visibility }
APIs is the combination of all APIs
type Categories ¶
type Categories interface { Collection() *mongo.Collection Create(ctx context.Context, catValue string) (string, error) Get(ctx context.Context, id string, projKeys []string, tokens []string) (*docs.CategoryEntry, error) GetMulti(ctx context.Context, ids []string, projKeys []string, tokens []string) ([]docs.CategoryEntry, error) GetOrCreate(ctx context.Context, catValue string, projKeys []string) (*docs.CategoryEntry, error) ListChildren(ctx context.Context, params *GroupListParams) ([]docs.CategoryEntry, error) DiffAndUpdate(ctx context.Context, oldIDs []string, newIDs []string, oldTokens []string, newTokens []string, count int) error Update(ctx context.Context, id string, update *GroupUpdate) error UpdateRelated(ctx context.Context, catID string) error UpdateCustomViews(ctx context.Context) error ViewByRelatedParkCollection() *mongo.Collection }
Categories API
type Dates ¶
type Dates interface { Collection() *mongo.Collection Create(ctx context.Context, date string) (string, error) Get(ctx context.Context, id string, projKeys []string, tokens []string) (*docs.Date, error) GetOrCreate(ctx context.Context, date string, projKeys []string) (*docs.Date, error) ListChildren(ctx context.Context, params *GroupListParams) ([]docs.Date, error) DiffAndUpdate(ctx context.Context, oldID *string, newID *string, oldTokens []string, newTokens []string, count int) error }
Dates API
type EventCountQuery ¶ added in v1.18.5
type EventCountQuery struct { StartDate *time.Time `json:"startDate,omitempty"` EndDate *time.Time `json:"endDate,omitempty"` Granularity EventGranularity `json:"granularity"` Event *string `json:"event,omitempty"` EventRegex bool `json:"eventRegex,omitempty"` Object *string `json:"object,omitempty"` ObjectRegex bool `json:"objectRegex,omitempty"` Context *string `json:"context,omitempty"` ContextRegex bool `json:"contextRegex,omitempty"` Extra *string `json:"extra,omitempty"` ExtraRegex bool `json:"extraRegex,omitempty"` GroupByEvent bool `json:"groupByEvent,omitempty"` GroupByObject bool `json:"groupByObject,omitempty"` GroupByContext bool `json:"groupByContext,omitempty"` GroupByExtra bool `json:"groupByExtra,omitempty"` Limit int }
type EventCountResult ¶ added in v1.18.6
type EventCountResult struct { ID struct { Date *time.Time `json:"date,omitempty" bson:"date,omitempty"` Event *string `json:"event,omitempty" bson:"event,omitempty"` Object *string `json:"object,omitempty" bson:"object,omitempty"` Context *string `json:"context,omitempty" bson:"context,omitempty"` Extra *string `json:"extra,omitempty" bson:"extra,omitempty"` } `json:"id,omitempty" bson:"_id"` Count int `json:"count" bson:"count"` }
type EventGranularity ¶ added in v1.18.6
type EventGranularity int
const ( EventByDay EventGranularity = iota EventByMonth EventByYear EventAllTime )
type Events ¶ added in v1.17.0
type Events interface { Collection() *mongo.Collection Add(ctx context.Context, events []EventInfo, tokens []string) error CountOne(ctx context.Context, event string, object *string, context *string, startDate *time.Time, endDate *time.Time) (int, error) Count(ctx context.Context, query EventCountQuery) ([]EventCountResult, error) ConvertDateToNewFormat(ctx context.Context) error ConvertYearMonthDayToDate(ctx context.Context) error }
Events API
type FolderVisibilityTokenTarget ¶
type FolderVisibilityTokenTarget int
FolderVisibilityTokenTarget determines what to target for visibility tokens
const ( // FolderTarget targets just the folder itself FolderTarget FolderVisibilityTokenTarget = iota // FolderTargetPhotos targets the folder and photos directly in it FolderTargetPhotos // FolderTargetFullTree targets the folder, photos and sub-folders in its full tree FolderTargetFullTree )
func (FolderVisibilityTokenTarget) Validate ¶
func (target FolderVisibilityTokenTarget) Validate() error
Validate target
type Folders ¶
type Folders interface { Collection() *mongo.Collection Exists(ctx context.Context, id string) bool Create(ctx context.Context, path string) (string, error) Get(ctx context.Context, id string, projKeys []string, tokens []string) (*docs.Folder, error) GetOrCreate(ctx context.Context, path string, projKeys []string) (*docs.Folder, error) ListChildren(ctx context.Context, params *GroupListParams) ([]docs.Folder, error) DiffAndUpdate(ctx context.Context, oldID *string, newID *string, oldTokens []string, newTokens []string, count int) error Update(ctx context.Context, id string, update *GroupUpdate) error // Visibility tokens AddVisibilityToken(ctx context.Context, id string, target FolderVisibilityTokenTarget, token string) error DeleteVisibilityToken(ctx context.Context, id string, target FolderVisibilityTokenTarget, token string) error }
Folders API
type GroupListParams ¶ added in v1.0.0
type GroupListParams struct { Limit int64 `json:"limit,omitempty"` RefID string `json:"refId,omitempty"` RefOp list.RefOperator `json:"refOp,omitempty"` // defaults to list.OpGt ProjectionKeys []string `json:"projKeys,omitempty"` ID string `json:"id,omitempty"` // Max relative depth // Default is 0, which is the same as 1. Indicates the max level of children // to list relative to the depth of ID. A value of -1 means unlimited depth. MaxRelDepth int `json:"maxRelDepth,omitempty"` // Custom sort key that takes precedence over all other sort orders. // Example use case: related.park CustomSortKey string `json:"customSortKey,omitempty"` // Name of the custom view to use for the listing. If empty, uses default collection. CustomView string `json:"customView,omitempty"` // Custom filter. Arbitrary. CustomFilter bson.M `json:"customFilter,omitempty"` // Visibility tokens. Must have at least one token. VisibilityTokens []string `json:"visibilityTokens,omitempty"` }
GroupListParams contains parameters for listing group children
func (*GroupListParams) AssignDefaults ¶ added in v1.0.0
func (params *GroupListParams) AssignDefaults()
AssignDefaults to parameters
func (*GroupListParams) Validate ¶ added in v1.0.0
func (params *GroupListParams) Validate() error
Validate parameters
type GroupUpdate ¶ added in v1.4.0
type GroupUpdate struct { Display *string `json:"display,omitempty"` SortOrder *interface{} `json:"sortOrder,omitempty"` // string or number MetaDescription *string `json:"metaDescription,omitempty"` RichText *string `json:"richText,omitempty"` }
GroupUpdate describes the fields that can be updated
func NewGroupUpdate ¶ added in v1.4.0
func NewGroupUpdate() *GroupUpdate
NewGroupUpdate creates a new update struct
func (*GroupUpdate) SetDisplay ¶ added in v1.4.0
func (gu *GroupUpdate) SetDisplay(d string) *GroupUpdate
SetDisplay sets the display
func (*GroupUpdate) SetMetaDescription ¶ added in v1.13.0
func (gu *GroupUpdate) SetMetaDescription(d string) *GroupUpdate
SetMetaDescription sets the meta description
func (*GroupUpdate) SetRichText ¶ added in v1.13.0
func (gu *GroupUpdate) SetRichText(t string) *GroupUpdate
SetRichtext sets the rich text
func (*GroupUpdate) SetSortOrder ¶ added in v1.4.0
func (gu *GroupUpdate) SetSortOrder(o interface{}) *GroupUpdate
SetSortOrder sets the sort order
type Keywords ¶
type Keywords interface { Collection() *mongo.Collection Create(ctx context.Context, name string) (string, error) Get(ctx context.Context, id string, projKeys []string, tokens []string) (*docs.Keyword, error) GetMulti(ctx context.Context, ids []string, projKeys []string, tokens []string) ([]docs.Keyword, error) GetOrCreate(ctx context.Context, name string, projKeys []string) (*docs.Keyword, error) ListChildren(ctx context.Context, params *GroupListParams) ([]docs.Keyword, error) DiffAndUpdate(ctx context.Context, oldIDs []string, newIDs []string, oldTokens []string, newTokens []string, count int) error Update(ctx context.Context, id string, update *GroupUpdate) error }
Keywords API
type Locations ¶
type Locations interface { Collection() *mongo.Collection Create(ctx context.Context, loc string) (string, error) Get(ctx context.Context, id string, projKeys []string, tokens []string) (*docs.Location, error) GetOrCreate(ctx context.Context, loc string, projKeys []string) (*docs.Location, error) ListChildren(ctx context.Context, params *GroupListParams) ([]docs.Location, error) DiffAndUpdate(ctx context.Context, oldID *string, newID *string, oldTokens []string, newTokens []string, count int) error Update(ctx context.Context, id string, update *GroupUpdate) error }
Locations API
type PhotoListKey ¶
type PhotoListKey string
PhotoListKey is an enum for the listing key
const ( PhotoListKeySortKey PhotoListKey = "sortKey" PhotoListKeyTimestamp PhotoListKey = "timestamp" )
List keys
func (PhotoListKey) Validate ¶
func (key PhotoListKey) Validate() error
Validate photo list key value
type PhotoListParams ¶
type PhotoListParams struct { Limit int64 `json:"limit,omitempty"` // >= 0 (0 means no limit) // RefKeyValue expectations for different RefKeys // - ListKeySortKey: RefKeyValue should be a string with the sort key // - ListKeyTimestamp: RefKeyValue should be a string with the timestamp value (in RFC3339 layout) RefKey PhotoListKey `json:"refKey,omitempty"` // defaults to ListKeySortKey RefKeyValue string `json:"refKeyValue,omitempty"` RefOp list.RefOperator `json:"refOp,omitempty"` // defaults to list.OpGt ProjectionKeys []string `json:"projKeys,omitempty"` Filter docs.PhotoListFilterExpr `json:"filter"` // Visibility tokens. Must have at least one token. VisibilityTokens []string `json:"visTokens"` }
PhotoListParams contains parameters for listing photos
func (*PhotoListParams) AssignDefaults ¶
func (params *PhotoListParams) AssignDefaults()
AssignDefaults to list parameters
func (*PhotoListParams) Validate ¶
func (params *PhotoListParams) Validate() error
Validate list parameters
type PhotoRandomListParams ¶ added in v0.11.0
type PhotoRandomListParams struct { Count int64 `json:"count"` // > 0 ProjectionKeys []string `json:"projKeys,omitempty"` Filter docs.PhotoListFilterExpr `json:"filter"` // Visibility tokens. Must have at least one token. VisibilityTokens []string `json:"visTokens"` }
PhotoRandomListParams contains parameters for random list photos
func (*PhotoRandomListParams) AssignDefaults ¶ added in v0.11.0
func (params *PhotoRandomListParams) AssignDefaults()
AssignDefaults to list parameters
func (*PhotoRandomListParams) Validate ¶ added in v0.11.0
func (params *PhotoRandomListParams) Validate() error
Validate list parameters
type Photos ¶
type Photos interface { Collection() *mongo.Collection AddOrUpdate(ctx context.Context, bucketID string, objectID string, objectGenVal uint64, fileSize int, md *photomd.Metadata) (*docs.Photo, error) AddOrUpdateAndResize(ctx context.Context, bucketID string, objectID string, objectGenVal uint64) (*docs.Photo, error) Delete(ctx context.Context, bucketID string, objectID string) error Get(ctx context.Context, id docs.PhotoID, projKeys []string, tokens []string) (*docs.Photo, error) // Photo resizing ResizeCacheCollection() *mongo.Collection GetResizeCacheEntry(ctx context.Context, id docs.PhotoID, maxLength int) *docs.PhotoResizeCacheEntry GetResizedImage(ctx context.Context, id docs.PhotoID, maxLength int, tokens []string) (io.ReadCloser, int, bool, error) // Listing List(ctx context.Context, params *PhotoListParams) ([]docs.Photo, error) RandomList(ctx context.Context, params *PhotoRandomListParams) ([]docs.Photo, error) // Visibility tokens AddInheritedVisibilityToken(ctx context.Context, folderSlugPath string, fullTree bool, token string) error DeleteInheritedVisibilityToken(ctx context.Context, folderSlugPath string, fullTree bool, token string) error }
Photos API
type TimelineGroups ¶ added in v1.6.0
type TimelineGroups interface { Collection() *mongo.Collection Create(ctx context.Context, folderID string, name string, filter *docs.PhotoListFilterExpr) (string, error) Get(ctx context.Context, id string, projKeys []string, tokens []string) (*docs.TimelineGroup, error) ListChildren(ctx context.Context, params *GroupListParams) ([]docs.TimelineGroup, error) Update(ctx context.Context, id string, update *GroupUpdate) error UpdateFilter(ctx context.Context, id string, filter *docs.PhotoListFilterExpr) error Sync(ctx context.Context, id string) error Delete(ctx context.Context, id string) error // Visibility tokens AddVisibilityToken(ctx context.Context, id string, token string, recurse bool) error DeleteVisibilityToken(ctx context.Context, id string, token string, recurse bool) error // Utilities UnwrapFilter(filter *docs.PhotoListFilterExpr) *docs.PhotoListFilterExpr }
TimelineGroups API
type Users ¶
type Users interface { Collection() *mongo.Collection SessionCollection() *mongo.Collection GetUserCount(ctx context.Context) (int64, error) AddUser(ctx context.Context, id string, password string) error Login(ctx context.Context, id string, password string) (*docs.Session, error) IsAdmin(ctx context.Context, id docs.UserID) bool // Sessions GetSession(ctx context.Context, sessionID docs.SessionID) *docs.Session RefreshSession(ctx context.Context, sessionID docs.SessionID) error EndSession(ctx context.Context, sessionID docs.SessionID) error CleanupExpiredSessions(ctx context.Context) error }
Users API
type Visibility ¶
type Visibility interface { Collection() *mongo.Collection Create(ctx context.Context, name string) (string, error) Get(ctx context.Context, id string, projKeys []string) (*docs.VisibilityToken, error) GetOrCreate(ctx context.Context, name string, projKeys []string) (*docs.VisibilityToken, error) GetByActivationValue(ctx context.Context, actValue string, projKeys []string) (*docs.VisibilityToken, error) List(ctx context.Context, projKeys []string) ([]docs.VisibilityToken, error) DiffAndUpdate(ctx context.Context, oldIDs []string, newIDs []string, count int) error // Initial values only allow setting Redirect and Comment CreateLink(ctx context.Context, id string, initial *docs.VisibilityTokenLink) (*docs.VisibilityTokenLink, error) // Update only allows changing Redirect, Comment or Disabled UpdateLink(ctx context.Context, actValue string, toUpdate *docs.VisibilityTokenLink) error // Returns token with ID and the activated link (activation count is not accurate), if the activation value // is valid and enabled. ActivateLink(ctx context.Context, actValue string) (*docs.VisibilityToken, error) }
Visibility API