client

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 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) CreateZettelJSON

func (c *Client) CreateZettelJSON(ctx context.Context, data *api.ZettelDataJSON) (api.ZettelID, error)

CreateZettelJSON 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 added in v0.12.0

func (c *Client) GetEvaluatedSz(ctx context.Context, zid api.ZettelID, part string, sf sxpf.SymbolFactory) (sxpf.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) GetMeta

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

GetMeta returns the metadata of a zettel.

func (*Client) GetParsedSz added in v0.12.0

func (c *Client) GetParsedSz(ctx context.Context, zid api.ZettelID, part string, sf sxpf.SymbolFactory) (sxpf.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) GetUnlinkedReferences

func (c *Client) GetUnlinkedReferences(
	ctx context.Context, zid api.ZettelID, query url.Values) (*api.ZidMetaRelatedList, error)

GetUnlinkedReferences returns connections to other zettel, embedded material, externals URLs.

func (*Client) GetVersionJSON

func (c *Client) GetVersionJSON(ctx context.Context) (api.VersionJSON, error)

GetVersionJSON 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) GetZettelJSON

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

GetZettelJSON returns a zettel as a JSON struct.

func (*Client) GetZettelOrder

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

GetZettelOrder returns metadata of the given zettel and, more important, metadata of zettel that are referenced in a list within the first zettel.

func (*Client) ListZettel

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

ListZettel returns a list of all Zettel.

func (*Client) ListZettelJSON

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

ListZettelJSON returns a list of zettel.

func (*Client) QueryMapMeta added in v0.7.0

func (c *Client) QueryMapMeta(ctx context.Context, query string) (api.MapMeta, error)

QueryMapMeta returns a map of all metadata values with the given query action to the list of zettel IDs containing this value.

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) UpdateZettelJSON

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

UpdateZettelJSON 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

Jump to

Keyboard shortcuts

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