Documentation
¶
Overview ¶
Package api provides an API for accessing/mangaging a Moonpool database.
Index ¶
- Variables
- func GenerateMockData(a *API, amount int, mockTags, mockTimestamps bool) ([]int64, error)
- type API
- func (a *API) AssignTags(ctx context.Context, archive_id int64, tags []string) error
- func (a *API) BeginTX(ctx context.Context) (*WithTX, error)
- func (a *API) Close(ctx context.Context) error
- func (a *API) DeleteTagAlias(ctx context.Context, tag_alias string) error
- func (a *API) DoesEntryExist(ctx context.Context, archive_id int64) bool
- func (a *API) GenerateBlurHash(ctx context.Context, archive_id int64) error
- func (a *API) GeneratePerceptualHash(ctx context.Context, archive_id int64, hashType string, r io.Reader) error
- func (a *API) GenerateThumbnail(ctx context.Context, archive_id int64) error
- func (a *API) GetBlurHashString(ctx context.Context, archive_id int64) (string, error)
- func (a *API) GetEntry(ctx context.Context, archive_id int64) (entry.Entries, error)
- func (a *API) GetFile(ctx context.Context, archive_id int64) (io.ReadCloser, error)
- func (a *API) GetHashes(ctx context.Context, archive_id int64) (entry.Hashes, error)
- func (a *API) GetMostRecentArchiveID(ctx context.Context) (int64, error)
- func (a *API) GetPage(ctx context.Context, sort string, amount, pagenation int64, desc bool) ([]archive.Archive, error)
- func (a *API) GetPath(ctx context.Context, archive_id int64) (entry.Path, error)
- func (a *API) GetPerceptualHash(ctx context.Context, archive_id int64, hashType string) (uint64, error)
- func (a *API) GetTagCount(ctx context.Context, tag string) (int64, error)
- func (a *API) GetTags(ctx context.Context, archive_id int64) ([]string, error)
- func (a *API) GetTagsByList(ctx context.Context, archive_ids []int64) ([]entry.TagCount, error)
- func (a *API) GetTagsByRange(ctx context.Context, start, end, offset int64) ([]entry.TagCount, error)
- func (a *API) GetThumbnail(ctx context.Context, archive_id int64, size, format string) ([]byte, error)
- func (a *API) GetTimestamps(ctx context.Context, archive_id int64) (entry.Timestamp, error)
- func (a *API) Import(ctx context.Context, i Importer) (int64, error)
- func (a *API) NewSavepoint(ctx context.Context, name string) error
- func (a *API) NewTagAlias(ctx context.Context, tag, tag_alias string) error
- func (a *API) QueryTags(ctx context.Context, sort, order string, q QueryTags) ([]int64, error)
- func (a *API) ReleaseSavepoint(ctx context.Context, name string) error
- func (a *API) RemoveArchive(ctx context.Context, archive_id int64) error
- func (a *API) RemoveTags(ctx context.Context, archive_id int64, tags []string) error
- func (a *API) RenderBlurHash(ctx context.Context, archive_id int64) (image.Image, error)
- func (a *API) ReplaceTags(ctx context.Context, archive_id int64, tags []string) error
- func (a *API) ResolveTagAlias(ctx context.Context, tag_alias []string) ([]entry.TagAlias, error)
- func (a *API) RollbackSavepoint(ctx context.Context, name string) error
- func (a *API) SearchTag(ctx context.Context, tag string) ([]int64, error)
- func (a *API) SetHashes(ctx context.Context, archive_id int64, h entry.Hashes) error
- func (a *API) SetTimestamps(ctx context.Context, archive_id int64, t entry.Timestamp) error
- func (a *API) Vaccum(ctx context.Context) (int64, error)
- type Config
- type Importer
- type QueryTags
- type WithTX
Constants ¶
This section is empty.
Variables ¶
var (
ErrThumbnailNotFound = errors.New("thumbnail not found")
)
Functions ¶
func GenerateMockData ¶
GenerateMockData creates an x amount of new entries with a random tag and .png extension as its metadata. GenerateMockData may return an error, along with partial ArchiveIDs if only some imports are successful.
Types ¶
type API ¶
type API struct {
Config Config
// contains filtered or unexported fields
}
func (*API) AssignTags ¶
AssignTags assigns a slice of tags to a given archive_id. A new tag will be implicitly created if one does not exist already. No errors will be given if a tag is already set. Tag aliases will automatically be resolved to their base tag.
func (*API) Close ¶
Close manually runs a SQL checkpoint and closes the API connection. Calling Close() will implicitly close the sql.DB connection as well
func (*API) DeleteTagAlias ¶
DeleteTagAlias completely deletes an alias tag from moonpool. Base tag is not affected whatsoever.
func (*API) DoesEntryExist ¶
func (*API) GenerateBlurHash ¶
func (*API) GeneratePerceptualHash ¶
func (a *API) GeneratePerceptualHash(ctx context.Context, archive_id int64, hashType string, r io.Reader) error
hashType is unused
func (*API) GenerateThumbnail ¶
func (*API) GetBlurHashString ¶
func (*API) GetMostRecentArchiveID ¶
GetMostRecentArchiveID gets the the most recently imported archive_id.
func (*API) GetPage ¶
func (a *API) GetPage(ctx context.Context, sort string, amount, pagenation int64, desc bool) ([]archive.Archive, error)
GetPage returns a list of archives within a given range. Valid sort options are "imported", "created", and "modified".
func (*API) GetPath ¶
GetPath takes an archive_id and returns its relative folder path that points to a file
func (*API) GetPerceptualHash ¶
func (a *API) GetPerceptualHash(ctx context.Context, archive_id int64, hashType string) (uint64, error)
hashType is unused
func (*API) GetTagsByList ¶
GetTagCountByList groups the total amount of tags that are assigned to a list of archive_id's. entry.TagCount is implicitly sorted from largest to smallest and returns 50 tags in total.
func (*API) GetTagsByRange ¶
func (a *API) GetTagsByRange(ctx context.Context, start, end, offset int64) ([]entry.TagCount, error)
GetTagCountByList groups the total amount of tags that are within a range of archive_id's. offset is the starting point in which to begin grouping each archive_id. entry.TagCount is implicitly sorted from largest to smallest
func (*API) GetThumbnail ¶
func (a *API) GetThumbnail(ctx context.Context, archive_id int64, size, format string) ([]byte, error)
GetThumbnail returns the thumbnail data from a given entry. Valid sizes are "small", "medium", and "large". Valid formats are "jpeg"
func (*API) GetTimestamps ¶
GetTimestamps returns the UTC timestamps of an entry. If only partial timestamp information exists, GetTimestamps will return a partial timestamp and an error. You should ALWAYS check whether a Timestamp is empty or not, regardless of any errors.
func (*API) Import ¶
Import takes an Importer interface and returns an archive_id and nil error on success, or both an archive_id AND non-nil error on partial success. Partial success currently only occurs when all other import routines (archive creation, file storing, timestamps, etc) are successful, except for tag importing. Import will return an ArchiveID of -1 if a non-partial success isn't possible.
You should ALWAYS check if "ArchiveID <=0 && error != nil"
func (*API) NewTagAlias ¶
func (*API) QueryTags ¶
Valid sort options are "imported", "created", and "modified". Valid order options are "descending", "ascending".
func (*API) ReleaseSavepoint ¶
func (*API) RemoveArchive ¶
RemoveArchive completely deletes an entry from the moonpool database.
func (*API) RemoveTags ¶
RemoveTags unassigns a list of tags from an entry. If a tag is no longer in reference to any entry, it is completely removed from the database.
func (*API) RenderBlurHash ¶
func (*API) ReplaceTags ¶
ReplaceTags unassigns any and all tags associated with a given archive_id, and replaces it with a given slice of tags.
func (*API) ResolveTagAlias ¶
ResolveTagAlias returns the base tag of a given tag alias.
func (*API) RollbackSavepoint ¶
func (*API) SetTimestamps ¶
SetTimestamps sets assigns or updates an existing timestamp to an entry. Timestamps are implicitly converted into a UTC timezone. If a timestamp field is empty, SetTimestamps will ignore that field and only update the field of an entry with a valid time.
type QueryTags ¶
type QueryTags struct {
TagsInclude, TagsExclude []string
}
func BuildQuery ¶
BuildQuery takes a string and returns a QueryTag to be used in API.QueryTags. Each tag can be separated by a comma (,) and have a prefixed special character to assign specific tag modifiers to it.
tag modifiers: dash (-) = exclude tag from search