client

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: EUPL-1.2 Imports: 15 Imported by: 0

Documentation

Overview

Package client provides a client for accessing the Zettelstore via its API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client contains all data to execute requests.

func NewClient

func NewClient(u *url.URL) *Client

NewClient create a new client.

func (*Client) Authenticate

func (c *Client) Authenticate(ctx context.Context) error

Authenticate sets a new token by sending user name and password.

func (*Client) Base

func (c *Client) Base() string

Base returns the base part of the URLs that are used to communicate with a Zettelstore.

func (*Client) CreateZettel

func (c *Client) CreateZettel(ctx context.Context, data []byte) (api.ZettelID, error)

CreateZettel creates a new zettel and returns its URL.

func (*Client) CreateZettelData

func (c *Client) CreateZettelData(ctx context.Context, data api.ZettelData) (api.ZettelID, error)

CreateZettelData creates a new zettel and returns its URL.

func (*Client) DeleteZettel

func (c *Client) DeleteZettel(ctx context.Context, zid api.ZettelID) error

DeleteZettel deletes a zettel with the given identifier.

func (*Client) ExecuteCommand

func (c *Client) ExecuteCommand(ctx context.Context, command api.Command) error

ExecuteCommand will execute a given command at the Zettelstore.

func (*Client) GetEvaluatedSz

func (c *Client) GetEvaluatedSz(ctx context.Context, zid api.ZettelID, part string, sf sx.SymbolFactory) (sx.Object, error)

GetEvaluatedSz returns an evaluated zettel as a Sexpr-decoded data structure.

func (*Client) GetEvaluatedZettel

func (c *Client) GetEvaluatedZettel(ctx context.Context, zid api.ZettelID, enc api.EncodingEnum) ([]byte, error)

GetEvaluatedZettel return an evaluated zettel in a defined encoding.

func (*Client) GetMetaData

func (c *Client) GetMetaData(ctx context.Context, zid api.ZettelID) (api.MetaRights, error)

GetMetaData returns the metadata of a zettel.

func (*Client) GetParsedSz

func (c *Client) GetParsedSz(ctx context.Context, zid api.ZettelID, part string, sf sx.SymbolFactory) (sx.Object, error)

GetParsedSz returns an parsed zettel as a Sexpr-decoded data structure.

func (*Client) GetParsedZettel

func (c *Client) GetParsedZettel(ctx context.Context, zid api.ZettelID, enc api.EncodingEnum) ([]byte, error)

GetParsedZettel return a parsed zettel in a defined encoding.

func (*Client) GetVersionInfo

func (c *Client) GetVersionInfo(ctx context.Context) (VersionInfo, error)

GetVersionInfo returns version information..

func (*Client) GetZettel

func (c *Client) GetZettel(ctx context.Context, zid api.ZettelID, part string) ([]byte, error)

GetZettel returns a zettel as a string.

func (*Client) GetZettelData

func (c *Client) GetZettelData(ctx context.Context, zid api.ZettelID) (api.ZettelData, error)

GetZettelData returns a zettel as a struct of its parts.

func (*Client) QueryAggregate

func (c *Client) QueryAggregate(ctx context.Context, query string) (api.Aggregate, error)

QueryAggregate returns a aggregate as a result of a query. It is most often used in a query with an action, where the action is either a metadata key of type Word, WordSet, or TagSet.

func (*Client) QueryZettel

func (c *Client) QueryZettel(ctx context.Context, query string) ([][]byte, error)

QueryZettel returns a list of all Zettel.

func (*Client) QueryZettelData

func (c *Client) QueryZettelData(ctx context.Context, query string) (string, string, []api.ZidMetaRights, error)

QueryZettelData returns a list of zettel metadata.

func (*Client) RefreshToken

func (c *Client) RefreshToken(ctx context.Context) error

RefreshToken updates the access token

func (*Client) RenameZettel

func (c *Client) RenameZettel(ctx context.Context, oldZid, newZid api.ZettelID) error

RenameZettel renames a zettel.

func (*Client) SetAuth

func (c *Client) SetAuth(username, password string)

SetAuth sets authentication data.

func (*Client) UpdateZettel

func (c *Client) UpdateZettel(ctx context.Context, zid api.ZettelID, data []byte) error

UpdateZettel updates an existing zettel.

func (*Client) UpdateZettelData

func (c *Client) UpdateZettelData(ctx context.Context, zid api.ZettelID, data api.ZettelData) error

UpdateZettelData updates an existing zettel.

type Error

type Error struct {
	StatusCode int
	Message    string
	Body       []byte
}

Error encapsulates the possible client call errors.

func (*Error) Error

func (err *Error) Error() string

type VersionInfo

type VersionInfo struct {
	Major int
	Minor int
	Patch int
	Info  string
	Hash  string
}

VersionInfo contains version information.

Source Files

  • client.go

Jump to

Keyboard shortcuts

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