Documentation ¶
Index ¶
- Constants
- Variables
- type AddNoteAsset
- type AddNoteOptions
- type AddNoteParams
- type Anki
- func (a *Anki) AddNote(ctx context.Context, params *AddNoteParams, opts *AddNoteOptions) (int64, error)
- func (a *Anki) CreateDeck(ctx context.Context, deckName string) (int64, error)
- func (a *Anki) CreateModel(ctx context.Context, parameters *CreateModelRequest) (int64, error)
- func (a *Anki) DeckNames(ctx context.Context) ([]string, error)
- func (a *Anki) DeleteDecks(ctx context.Context, deckNames []string) error
- func (a *Anki) DeleteNotes(ctx context.Context, ids []int64) error
- func (a *Anki) FindNotes(ctx context.Context, query string) ([]int64, error)
- func (a *Anki) LoadProfile(ctx context.Context, name string) error
- func (a *Anki) ModelFieldNames(ctx context.Context, modelName string) ([]string, error)
- func (a *Anki) ModelNames(ctx context.Context) ([]string, error)
- func (a *Anki) NotesInfo(ctx context.Context, ids []int64) ([]*NoteInfo, error)
- func (a *Anki) RequestPermission(ctx context.Context) (*RequestPermissionResponse, error)
- func (a *Anki) Version(ctx context.Context) (int, error)
- type ConnectionError
- type CreateModelCardTemplate
- type CreateModelRequest
- type DuplicateFlags
- type DuplicateScope
- type MediaAssetOptions
- type MediaAssetRequest
- type MediaType
- type NoteInfo
- type NoteInfoField
- type Options
- type RequestPermissionResponse
- type ServerError
- type UnexpectedResponseError
Constants ¶
const ( PermissionDenied = "denied" PermissionGranted = "granted" )
Variables ¶
ErrCollectionUnavailable error indicating that action can not be processed, because anki is partially loaded (particular example is when user didn't login in profile).
var ErrInvalidAPIKey = errors.New("invalid API Key was provided")
ErrInvalidAPIKey error indicating that Anki-Connect protected by api key, and nor or invalid api key was provided
Functions ¶
This section is empty.
Types ¶
type AddNoteAsset ¶
type AddNoteAsset struct { Asset MediaAssetRequest Type MediaType }
type AddNoteOptions ¶
type AddNoteOptions struct { Deck string Model string DuplicateScope DuplicateScope DuplicateFlags DuplicateFlags DuplicateDeck string }
type AddNoteParams ¶
type AddNoteParams struct { Tags []string Fields map[string]string Assets []*AddNoteAsset }
type Anki ¶
type Anki struct {
// contains filtered or unexported fields
}
func (*Anki) AddNote ¶
func (a *Anki) AddNote(ctx context.Context, params *AddNoteParams, opts *AddNoteOptions) (int64, error)
AddNote creates new notes. Params specify note data and opts specifies where it belongs and how it should be added. So likely, that many notes can be added with different params and same opts.
func (*Anki) CreateDeck ¶
func (*Anki) CreateModel ¶
func (*Anki) DeleteDecks ¶
func (*Anki) ModelFieldNames ¶
func (*Anki) RequestPermission ¶
func (a *Anki) RequestPermission(ctx context.Context) (*RequestPermissionResponse, error)
RequestPermission need to authenticate client origin (it doesn't check api key!)
type ConnectionError ¶
type ConnectionError struct {
Err error
}
ConnectionError represents error occured when we tried to connect to server.
func (*ConnectionError) Error ¶
func (e *ConnectionError) Error() string
func (*ConnectionError) Unwrap ¶
func (e *ConnectionError) Unwrap() error
type CreateModelCardTemplate ¶
type CreateModelRequest ¶
type CreateModelRequest struct { ModelName string `json:"modelName,omitempty"` Fields []string `json:"inOrderFields,omitempty"` CSS string `json:"css,omitempty"` CardTemplates []CreateModelCardTemplate `json:"cardTemplates,omitempty"` }
type DuplicateFlags ¶
type DuplicateFlags int
const ( DuplicateFlagsCheck DuplicateFlags = 1 << iota DuplicateFlagsWithChildren DuplicateFlagsWithModels )
type DuplicateScope ¶
type DuplicateScope int
const ( DuplicateScopeDeck DuplicateScope = iota DuplicateScopeEverywhere )
type MediaAssetOptions ¶
type MediaAssetOptions struct { Filename string DeleteExisting bool Fields []string SkipHash []byte }
MediaAssetOptions represents common options about how asset should be saved.
type MediaAssetRequest ¶
type MediaAssetRequest struct { Data string `json:"data,omitempty"` Path string `json:"path,omitempty"` URL string `json:"url,omitempty"` Filename string `json:"filename,omitempty"` Fields []string `json:"fields,omitempty"` SkipHash string `json:"skipHash,omitempty"` DeleteExisting bool `json:"deleteExisting,omitempty"` }
MediaAssetRequest represents actual request that will go to anki-connect
func NewMediaBlob ¶
func NewMediaBlob(data []byte, opts *MediaAssetOptions) *MediaAssetRequest
func NewMediaFile ¶
func NewMediaFile(filename string, opts *MediaAssetOptions) *MediaAssetRequest
func NewMediaURL ¶
func NewMediaURL(url string, opts *MediaAssetOptions) *MediaAssetRequest
type NoteInfo ¶
type NoteInfo struct { NoteID int64 ModelName string Tags []string Fields map[string]*NoteInfoField }
type NoteInfoField ¶
type Options ¶
type Options struct { URL string APIKey string // Transport is used for http client. // Please not that anki-connect can not properly reuse connections! Transport http.RoundTripper }
type ServerError ¶
ServerError represent errors that we quite sure related to anki. Eiher it's message from field "error" from response or can be wrapper around ErrPermissionDenied
func (*ServerError) Error ¶
func (e *ServerError) Error() string
func (*ServerError) Unwrap ¶
func (e *ServerError) Unwrap() error
type UnexpectedResponseError ¶
UnexpectedResponseError represent error that possibly ocured because we connected to some server but probably not to anki-connect. Either we received unxpected status code or we were unable to decode body.
func (*UnexpectedResponseError) Error ¶
func (e *UnexpectedResponseError) Error() string
func (*UnexpectedResponseError) Unwrap ¶
func (e *UnexpectedResponseError) Unwrap() error