Documentation
¶
Overview ¶
Package remote talks to a self-hosted ZenNotes server over its HTTP API, the same routes the desktop and web clients use.
Index ¶
- func ConnectionErrorMessage(baseURL string, err error) string
- func NormalizeBaseURL(value string) string
- func StatusOf(err error) int
- type AbsenceAwareReader
- type Client
- func (c *Client) ArchiveNote(ctx context.Context, rel string) (vault.NoteMeta, error)
- func (c *Client) Capabilities(ctx context.Context) (map[string]any, error)
- func (c *Client) CreateFolder(ctx context.Context, folder vault.NoteFolder, subpath string) error
- func (c *Client) CreateNote(ctx context.Context, folder vault.NoteFolder, title, subpath string) (vault.NoteMeta, error)
- func (c *Client) DeleteFolder(ctx context.Context, folder vault.NoteFolder, subpath string) error
- func (c *Client) DeleteNote(ctx context.Context, rel string) error
- func (c *Client) DeleteTemplate(ctx context.Context, sourcePath string) error
- func (c *Client) DuplicateNote(ctx context.Context, rel string) (vault.NoteMeta, error)
- func (c *Client) EmptyTrash(ctx context.Context) error
- func (c *Client) Get(ctx context.Context, path string, out any) error
- func (c *Client) GetCurrentVault(ctx context.Context) (*vault.VaultInfo, error)
- func (c *Client) GetRaw(ctx context.Context, path string) ([]byte, error)
- func (c *Client) GetVaultSettings(ctx context.Context) (map[string]any, error)
- func (c *Client) ListAssets(ctx context.Context) ([]vault.AssetMeta, error)
- func (c *Client) ListFolders(ctx context.Context) ([]vault.FolderEntry, error)
- func (c *Client) ListNotes(ctx context.Context) ([]vault.NoteMeta, error)
- func (c *Client) ListTemplates(ctx context.Context) ([]vault.CustomTemplateFile, error)
- func (c *Client) MoveNote(ctx context.Context, rel string, folder vault.NoteFolder, subpath string) (vault.NoteMeta, error)
- func (c *Client) MoveToTrash(ctx context.Context, rel string) (vault.NoteMeta, error)
- func (c *Client) Post(ctx context.Context, path string, body any, out any) error
- func (c *Client) ReadAsset(ctx context.Context, rel string) ([]byte, error)
- func (c *Client) ReadComments(ctx context.Context, rel string) ([]vault.NoteComment, error)
- func (c *Client) ReadNote(ctx context.Context, rel string) (vault.NoteContent, error)
- func (c *Client) ReadTemplate(ctx context.Context, sourcePath string) (string, error)
- func (c *Client) RenameFolder(ctx context.Context, folder vault.NoteFolder, oldSubpath, newSubpath string) (string, error)
- func (c *Client) RenameNote(ctx context.Context, rel, nextTitle string) (vault.NoteMeta, error)
- func (c *Client) RestoreFromTrash(ctx context.Context, rel string) (vault.NoteMeta, error)
- func (c *Client) ScanTasks(ctx context.Context, includeExcluded bool) ([]vault.Task, error)
- func (c *Client) ScanTasksForPath(ctx context.Context, rel string, includeExcluded bool) ([]vault.Task, error)
- func (c *Client) SearchText(ctx context.Context, query string) ([]vault.TextSearchMatch, error)
- func (c *Client) SetVaultSettings(ctx context.Context, settings map[string]any) (map[string]any, error)
- func (c *Client) UnarchiveNote(ctx context.Context, rel string) (vault.NoteMeta, error)
- func (c *Client) WriteComments(ctx context.Context, rel string, comments []vault.NoteComment) ([]vault.NoteComment, error)
- func (c *Client) WriteNote(ctx context.Context, rel, body string) (vault.NoteMeta, error)
- func (c *Client) WriteTemplate(ctx context.Context, input vault.WriteTemplateInput) (vault.CustomTemplateFile, error)
- type RequestError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectionErrorMessage ¶
ConnectionErrorMessage phrases a transport-level failure. On macOS a server on the local network needs the Local Network permission, and without it the attempt looks exactly like a server that is down.
func NormalizeBaseURL ¶
NormalizeBaseURL turns `localhost:7878` into `http://localhost:7878` and drops any trailing slash.
Types ¶
type AbsenceAwareReader ¶
type AbsenceAwareReader struct {
// contains filtered or unexported fields
}
AbsenceAwareReader tells "this file is absent" apart from "this request failed" against a server whose answer for the two might be the same.
Servers from 2.20 on answer 404 for a missing file and reserve 500 for real failures. Older ones answered 500 for both, and a client refusing to read 500 as absence cannot open a single database against one. Rather than guess from a version, the reader asks the server what it does: it requests a path that cannot exist and looks at the status, once per connection.
func NewAbsenceAwareReader ¶
func NewAbsenceAwareReader(read func(ctx context.Context, rel string) (string, error)) *AbsenceAwareReader
NewAbsenceAwareReader wraps a raw read.
func (*AbsenceAwareReader) ReadFileTextOrNull ¶
ReadFileTextOrNull returns nil for an absent file and an error for everything else.
type Client ¶
Client is a fetch-only client for one server.
func (*Client) ArchiveNote ¶
func (*Client) Capabilities ¶
Capabilities is what the server says it supports.
func (*Client) CreateFolder ¶
func (*Client) CreateNote ¶
func (*Client) DeleteFolder ¶
func (*Client) DeleteTemplate ¶
func (*Client) DuplicateNote ¶
func (*Client) GetCurrentVault ¶
GetCurrentVault is the vault the server is serving, or nil.
func (*Client) GetVaultSettings ¶
GetVaultSettings is the server's vault.json as it reports it.
func (*Client) ListAssets ¶
func (*Client) ListFolders ¶
func (*Client) ListTemplates ¶
func (*Client) MoveToTrash ¶
func (*Client) ReadComments ¶
ReadComments loads a note's comment sidecar from the server.
func (*Client) ReadTemplate ¶
func (*Client) RenameFolder ¶
func (*Client) RenameNote ¶
func (*Client) RestoreFromTrash ¶
func (*Client) ScanTasksForPath ¶
func (*Client) SearchText ¶
func (*Client) SetVaultSettings ¶
func (c *Client) SetVaultSettings(ctx context.Context, settings map[string]any) (map[string]any, error)
SetVaultSettings writes the whole settings object back.
func (*Client) UnarchiveNote ¶
func (*Client) WriteComments ¶
func (c *Client) WriteComments(ctx context.Context, rel string, comments []vault.NoteComment) ([]vault.NoteComment, error)
WriteComments replaces a note's comments on the server.
func (*Client) WriteTemplate ¶
func (c *Client) WriteTemplate(ctx context.Context, input vault.WriteTemplateInput) (vault.CustomTemplateFile, error)
type RequestError ¶
RequestError is a non-2xx answer, with the status attached so a 404 (absent file) can be told from a real failure.
func (*RequestError) Error ¶
func (e *RequestError) Error() string