api

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2025 License: Unlicense Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxEagleItemIDLength = 15
)

Variables

View Source
var EagleNotOpenOrUnavailableErr = fmt.Errorf("Eagle is not open or unavailable.")
View Source
var (
	ErrStatusErr = fmt.Errorf("response key 'status' was not 'success'")
)
View Source
var LibraryIsAlreadyTargetErr = errors.New("Library is already active")

sentinel errors

Functions

func ApplicationCmd added in v0.1.0

func ApplicationCmd() *cobra.Command

provides commands

func FolderCmd added in v0.0.12

func FolderCmd() *cobra.Command

func FolderRename

func FolderRename(baseUrl string, folderId string, newName string) error

func FolderUpdate

func FolderUpdate(baseUrl string, folderId string, newName string, newDescription string, newColor string) error

colors

func GetCurrentLibraryIsAlreadyTargetError added in v0.0.7

func GetCurrentLibraryIsAlreadyTargetError(currLib string) error

constructor

func IsEagleNotOpenOrUnavailableError added in v0.1.0

func IsEagleNotOpenOrUnavailableError(err error) bool

func IsValidItemID

func IsValidItemID(id string) bool

TODO: remove regex?

func ItemAddBookmark

func ItemAddBookmark(baseUrl string, item ItemAddBookmarkOptions) error

endpoint only returns `status`

func ItemAddFromPath

func ItemAddFromPath(baseUrl string, item ItemAddFromPathOptions) error

returns status only. TODO: endpoint which adds item & returns itemId

func ItemAddFromPaths

func ItemAddFromPaths(baseUrl string, items []ItemAddFromPathOptions) error

func ItemAddFromUrl

func ItemAddFromUrl(baseUrl string, item ItemAddFromUrlOptions) error

endpoint only returns `status`

func ItemAddFromUrls

func ItemAddFromUrls(baseUrl string, items []ItemAddFromUrlOptions, folderId string) error

endpoint only returns `status`

func ItemCmd added in v0.1.0

func ItemCmd() *cobra.Command

func ItemMoveToTrash

func ItemMoveToTrash(baseUrl string, ids []string) error

func ItemRefreshPalette

func ItemRefreshPalette(baseUrl string, id string) error

func ItemRefreshThumbnail

func ItemRefreshThumbnail(baseUrl string, id string) error

func ItemThumbnail

func ItemThumbnail(baseUrl string, id string) (string, error)

returns thumbnail path and error

func LibraryCmd added in v0.1.0

func LibraryCmd() *cobra.Command

func LibraryHistory

func LibraryHistory(baseURL string) ([]string, error)

returns []string paths to libraries /api/library/history

func LibraryIcon

func LibraryIcon(baseURL string) (string, error)

returns string iconpath (broken)

func LibrarySwitch

func LibrarySwitch(baseURL string, libraryPath string) error

cleans libraryPath and tries to switch. /api/library/switch endpoint only returns `status`

func RegisterGroupRoutes

func RegisterGroupRoutes(g *echo.Group)

func RegisterRootRoutes

func RegisterRootRoutes(server *echo.Echo)

func Request

func Request[T any](method string, url string, body io.Reader, urlParam *url.Values, v *T) error

populates v with response from req

Types

type ApiItem

type ApiItem struct {
	ID               string    `json:"id"`
	Name             string    `json:"name"`
	Size             int       `json:"size"`
	Ext              string    `json:"ext"`
	Tags             []string  `json:"tags"`
	Folders          []string  `json:"folders"`
	IsDeleted        bool      `json:"isDeleted"`
	URL              string    `json:"url"`
	Annotation       string    `json:"annotation"`
	ModificationTime int64     `json:"modificationTime"`
	Width            int       `json:"width"`
	Height           int       `json:"height"`
	NoThumbnail      *bool     `json:"noThumbnail,omitempty"`
	LastModified     int64     `json:"lastModified"`
	Palettes         []Palette `json:"palettes"`
	Star             *int      `json:"star,omitempty"`
}

Fields returned by Eagle API endpoints (item/list, item/info, item/update).

NOTE:

  • item/info includes the optional key `noThumbnail`.
  • item/update includes `noThumbnail` and the optional key `star`.
  • For optional keys null represents unset

func ItemInfo

func ItemInfo(baseUrl string, id string) (respItem ApiItem, err error)

func ItemUpdate

func ItemUpdate(baseUrl string, item ItemUpdateOptions) (respItem ApiItem, err error)

type ApiKeyErr

type ApiKeyErr struct {
	Message string
}

func (*ApiKeyErr) Error

func (e *ApiKeyErr) Error() string

type ApplicationInfoData

type ApplicationInfoData struct {
	Version           string `json:"version"`
	PreReleaseVersion string `json:"preReleaseVersion,omitempty"`
	BuildVersion      string `json:"buildVersion"`
	ExecPath          string `json:"execPath"`
	Platform          string `json:"platform"`
}

func ApplicationInfo

func ApplicationInfo(baseUrl string) (ApplicationInfoData, error)

GET Get detailed information on the Eagle App currently running. In most cases, this could be used to determine whether certain functions are available on the user's device. <https://api.eagle.cool/application/info>

type BaseItem

type BaseItem struct {
}

site, annotation, tags, folderid ?

type BulkItem

type BulkItem struct {
	Item
}

no folder Id

type Condition

type Condition struct {
	HashKey string `json:"$$hashKey,omitempty"`
	Match   string `json:"match"`
	Rules   []Rule `json:"rules"`
}

type EagleApiErr

type EagleApiErr struct {
	Message  string
	Endpoint endpoints.Endpoint
	Err      error
}

func (*EagleApiErr) Error

func (e *EagleApiErr) Error() string

type EagleApiResponse

type EagleApiResponse struct {
	Status string
	Data   []interface{} // optional
}

type EagleArray

type EagleArray struct {
	EagleResponse
	Data []string
}

for endpoints that return an array of strings.

type EagleMessage

type EagleMessage struct {
	EagleResponse
	Data any
}

type EagleResponse

type EagleResponse struct {
	Status string `json:"status"`
}

maybe? func (data EagleResponse) GetData() {}

type Folder

type Folder struct {
	ID               string   `json:"id"`
	Name             string   `json:"name"`
	Description      string   `json:"description"`
	Children         []Folder `json:"children"`
	ModificationTime int64    `json:"modificationTime,omitempty"`
	Tags             []string `json:"tags,omitempty"`
	IconColor        string   `json:"iconColor,omitempty"`
	Password         string   `json:"password,omitempty"`
	PasswordTips     string   `json:"passwordTips,omitempty"`
	CoverID          string   `json:"coverId,omitempty"`
	OrderBy          string   `json:"orderBy,omitempty"`
	SortIncrease     bool     `json:"sortIncrease,omitempty"`
	Icon             string   `json:"icon,omitempty"`
}

type FolderCreateResponse

type FolderCreateResponse struct {
	ID               string `json:"id"`
	Name             string `json:"name"`
	ModificationTime int    `json:"modificationTime"`
}

todo rename

func FolderCreate

func FolderCreate(baseUrl string, folderName string) (FolderCreateResponse, error)

type FolderDetailOverview

type FolderDetailOverview struct {
	ID                   string    `json:"id"`
	Name                 string    `json:"name"`
	Description          string    `json:"description"`
	Children             []any     `json:"children"`
	ModificationTime     int       `json:"modificationTime"`
	Tags                 []string  `json:"tags"`
	Password             *string   `json:"password"`     // optional
	PasswordTips         *string   `json:"passwordTips"` // optional
	Images               *[]string `json:"images"`       // optional
	IsExpand             bool      `json:"isExpand"`
	ImageCount           int       `json:"imageCount"`
	DescendantImageCount int       `json:"descendantImageCount"`
	Pinyin               string    `json:"pinyin"`
	ExtendTags           []string  `json:"extendTags"`
}

overview information of a folder. for some reason, listrecent has more fields... pointers are optional fields

func FolderList

func FolderList(baseUrl string) ([]FolderDetailOverview, error)

func FolderListRecent

func FolderListRecent(baseUrl string) ([]FolderDetailOverview, error)

type FolderRenameResponse

type FolderRenameResponse struct {
	ID               string `json:"id"`
	Name             string `json:"name"`
	ModificationTime int    `json:"modificationTime"`
	IsExpand         bool   `json:"isExpand"`
	Size             int    `json:"size"`
	Vstype           string `json:"vstype"`
	IsVisible        bool   `json:"isVisible"`
	HashKey          string `json:"$$hashKey"`
	NewFolderName    string `json:"newFolderName"`
	Editable         bool   `json:"editable"`
	Pinyin           string `json:"pinyin"`
}

type FolderStyles

type FolderStyles struct {
	Depth int  `json:"depth"`
	First bool `json:"first"`
	Last  bool `json:"last"`
}

type FolderUpdateResponse

type FolderUpdateResponse struct {
	ID               string `json:"id"`
	Name             string `json:"name"`
	ModificationTime int    `json:"modificationTime"`
	IsExpand         bool   `json:"isExpand"`
	Size             int    `json:"size"`
	Vstype           string `json:"vstype"`
	IsVisible        bool   `json:"isVisible"`
	HashKey          string `json:"$$hashKey"`
	NewFolderName    string `json:"newFolderName"`
	Editable         bool   `json:"editable"`
	Pinyin           string `json:"pinyin"`
}

type Item

type Item struct {
	URL              string   `json:"url"`
	Name             string   `json:"name"`
	Website          string   `json:"website"`
	Tags             []string `json:"tags"`
	Star             int      `json:"star"`
	Annotation       string   `json:"annotation"`
	ModificationTime int64    `json:"modificationTime"`
	FolderID         string   `json:"folderId"`
}

type ItemAddBookmarkOptions

type ItemAddBookmarkOptions struct {
	URL              string   `json:"url" flag:"URL of the bookmark"`
	Name             string   `json:"name" flag:"Display name for the bookmark"`
	Base64           string   `json:"base64,omitempty" flag:"Optional base64-encoded data"`
	Tags             []string `json:"tags,omitempty" flag:"Optional list of tag names"`
	ModificationTime string   `json:"modificationTime,omitempty" flag:"DESC TODO"`
	FolderID         string   `json:"folderId,omitempty" flag:"Optional ID of target folder to place the bookmark"`
}

give better name

func (ItemAddBookmarkOptions) Validate added in v0.1.0

func (o ItemAddBookmarkOptions) Validate() error

func (ItemAddBookmarkOptions) WithDefaults added in v0.1.0

type ItemAddFromPathOptions

type ItemAddFromPathOptions struct {
	Path       string   `json:"path" flag:"Required, the path of the local file."`
	Name       string   `json:"name,omitempty" flag:"Required, the name of the image to be added. (not really req)"`
	Website    string   `json:"website,omitempty" flag:"The Address of the source of the image."`
	Annotation string   `json:"annotation,omitempty" flag:"The annotation for the image."`
	Tags       []string `json:"tags,omitempty" flag:"Tags for the image."`
	FolderId   string   `json:"folderId,omitempty" flag:"If this parameter is defined, the image will be added to the corresponding folder."`
}

func (ItemAddFromPathOptions) Validate added in v0.1.0

func (o ItemAddFromPathOptions) Validate() error

type ItemAddFromUrlOptions

type ItemAddFromUrlOptions struct {
	URL              string            `json:"url" flag:"url to item to add"`
	Name             string            `json:"name" flag:"name to use for item"`
	Website          string            `json:"website,omitempty" flag:"associated website of item"`
	Tags             []string          `json:"tags,omitempty" flag:"tags to apply to item"`
	Star             *int              `json:"star,omitempty" flag:"star rating of the item"`
	Annotation       string            `json:"annotation,omitempty" flag:"annotation text for the item"`
	ModificationTime int               `json:"modificationTime,omitempty" flag:"modification time in epoch milliseconds"`
	FolderID         *string           `json:"folderId,omitempty" flag:"folder id to place the item in"`
	Headers          map[string]string `json:"headers,omitempty" flag:"http headers to be sent with requests"`
}

give a better name defaults to use url as item name in eagle bulk (addFromUrls) does not include `star` or `folderId` pointers represent optional keys and null represents unset

func (ItemAddFromUrlOptions) Validate added in v0.1.0

func (o ItemAddFromUrlOptions) Validate() error

func (ItemAddFromUrlOptions) WithDefaults added in v0.1.0

type ItemListOptions

type ItemListOptions struct {
	Limit   int    `json:"limit" flag:"The number of items to be displayed. the default number is 200"`
	Offset  int    `json:"offset,omitempty" flag:"Offset a collection of results from the api. Start with 0."`
	OrderBy string `` /* 143-byte string literal not displayed */
	Keyword string `json:"keyword,omitempty" flag:"Filter by the keyword"`
	Ext     string `json:"ext,omitempty" flag:"Filter by the extension type, e.g.: jpg ,  png"`
	Tags    string `json:"tags,omitempty" flag:"Filter by tags. Use , to divide different tags. E.g.: Design, Poster"`
	Folders string `json:"folders,omitempty" flag:"Filter by Folders.  Use , to divide folder IDs. E.g.: KAY6NTU6UYI5Q,KBJ8Z60O88VMG"`
}

func (ItemListOptions) WithDefaults added in v0.1.0

func (o ItemListOptions) WithDefaults() ItemListOptions

type ItemUpdateOptions

type ItemUpdateOptions struct {
	ID         string    `json:"id" flag:"unique identifier"`
	Tags       *[]string `json:"tags" flag:"list of tags associated with the item"`
	Annotation *string   `json:"annotation" flag:"user-provided annotation or note"`
	URL        *string   `json:"url" flag:"web URL associated with the item"`
	Star       *int      `json:"star" flag:"star rating from 1-5, nil for no rating"`
}

pointers represent optional keys and null represents unset

func (ItemUpdateOptions) Validate added in v0.1.0

func (o ItemUpdateOptions) Validate() error

type Library

type Library struct {
	Path string `json:"path"`
	Name string `json:"name"`
}

type LibraryData

type LibraryData struct {
	Folders            []Folder      `json:"folders"`
	SmartFolders       []SmartFolder `json:"smartFolders"`
	QuickAccess        []QuickAccess `json:"quickAccess"`
	TagsGroups         []TagsGroup   `json:"tagsGroups"`
	ModificationTime   int64         `json:"modificationTime"`
	ApplicationVersion string        `json:"applicationVersion"`
	Library            Library       `json:"library"`
}

func LibraryInfo

func LibraryInfo(baseURL string) (*LibraryData, error)

type LibraryInfoResponse

type LibraryInfoResponse struct {
	Data   LibraryData `json:"data"`
	Status string      `json:"status"`
}

type ListItem

type ListItem struct {
	Id   string `json:"id"`
	Name string `json:"name"`
	// Size
	// ext
	Tags    []string `json:"tags"`
	Folders []string `json:"folders"`
	// isDeleted
	URL              string `json:"url"`
	Annotation       string `json:"annotation"`
	ModificationTime int64  `json:"modificationTime"`
	// height
	// width
	// lastModified
	// palettes
	Website string `json:"website"`
}

func ItemList

func ItemList(baseUrl string, opts ItemListOptions) ([]*ListItem, error)

creates an *http.Request and sends to InvokeEagleAPIV1

type Palette

type Palette struct {
	Color   []int   `json:"color"`
	Ratio   float64 `json:"ratio"`
	HashKey string  `json:"$$hashKey"`
}

type QuickAccess

type QuickAccess struct {
	Type string `json:"type"`
	ID   string `json:"id"`
}

type Rule

type Rule struct {
	HashKey  string `json:"$$hashKey,omitempty"`
	Method   string `json:"method"`
	Property string `json:"property"`
	Value    any    `json:"value"` // Can be []int or string or []string
}

type SmartFolder

type SmartFolder struct {
	ID               string      `json:"id"`
	Icon             string      `json:"icon"`
	Name             string      `json:"name"`
	Description      string      `json:"description"`
	ModificationTime int64       `json:"modificationTime"`
	Conditions       []Condition `json:"conditions"`
	OrderBy          string      `json:"orderBy,omitempty"`
	SortIncrease     bool        `json:"sortIncrease,omitempty"`
}

type TagsGroup

type TagsGroup struct {
	ID    string   `json:"id"`
	Name  string   `json:"name"`
	Tags  []string `json:"tags"`
	Color string   `json:"color,omitempty"`
}

type ThumbnailData

type ThumbnailData struct {
	Status        string `json:"status"`
	ThumbnailPath string `json:"data"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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