client

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package client provides Memos API clients.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	Name       string `json:"name"`
	UID        string `json:"uid"`
	Filename   string `json:"filename"`
	Size       int64  `json:"size"`
	Type       string `json:"type"`
	CreateTime string `json:"createTime"`
}

Attachment represents a Memos attachment.

type AttachmentClient

type AttachmentClient struct {
	C *httpclient.Client
}

AttachmentClient handles attachment operations.

func (*AttachmentClient) Delete

func (a *AttachmentClient) Delete(ctx context.Context, id string) error

Delete deletes an attachment by ID.

func (*AttachmentClient) Get

func (a *AttachmentClient) Get(ctx context.Context, id, outputPath string) error

Get downloads an attachment to a local file.

func (*AttachmentClient) List

func (a *AttachmentClient) List(ctx context.Context, pageSize int) ([]Attachment, error)

List returns a list of attachments.

func (*AttachmentClient) Upload

func (a *AttachmentClient) Upload(ctx context.Context, filePath string) (*Attachment, error)

Upload uploads a file as an attachment.

type AuthClient

type AuthClient struct {
	C *httpclient.Client
}

AuthClient handles authentication operations.

func (*AuthClient) GetCurrentUserName

func (a *AuthClient) GetCurrentUserName(ctx context.Context) (string, error)

GetCurrentUserName returns the current username from the token. Since Memos doesn't have a direct /users/me endpoint that works with PAT, we extract the creator info from the list memos response.

type Comment

type Comment struct {
	Name       string `json:"name"`
	UID        string `json:"uid"`
	Content    string `json:"content"`
	Creator    string `json:"creator"`
	CreateTime string `json:"createTime"`
}

Comment represents a Memos comment.

type CommentClient

type CommentClient struct {
	C *httpclient.Client
}

CommentClient handles comment operations.

func (*CommentClient) Create

func (c *CommentClient) Create(ctx context.Context, memoID, content string) (*Comment, error)

Create creates a new comment on a memo.

func (*CommentClient) List

func (c *CommentClient) List(ctx context.Context, memoID string) ([]Comment, error)

List returns comments for a memo.

type Memo

type Memo struct {
	Name       string   `json:"name"` // "memos/123"
	UID        string   `json:"uid"`
	Content    string   `json:"content"`
	Visibility string   `json:"visibility"` // PRIVATE / PROTECTED / PUBLIC
	Pinned     bool     `json:"pinned"`
	Tags       []string `json:"tags"`
	Resources  []any    `json:"resources"`
	Creator    string   `json:"creator"`
	CreateTime string   `json:"createTime"`
	UpdateTime string   `json:"updateTime"`
}

Memo represents a Memos memo.

type MemoClient

type MemoClient struct {
	C *httpclient.Client
}

MemoClient handles memo operations.

func (*MemoClient) Create

func (m *MemoClient) Create(ctx context.Context, content, visibility string, tags []string) (*Memo, error)

Create creates a new memo.

func (*MemoClient) Delete

func (m *MemoClient) Delete(ctx context.Context, id string) error

Delete deletes a memo by ID.

func (*MemoClient) Get

func (m *MemoClient) Get(ctx context.Context, id string) (*Memo, error)

Get retrieves a memo by ID.

func (*MemoClient) List

func (m *MemoClient) List(ctx context.Context, pageSize int, pageToken, filter, sort string) ([]Memo, error)

List returns a list of memos.

func (*MemoClient) Search

func (m *MemoClient) Search(ctx context.Context, query string, pageSize int) ([]Memo, error)

Search searches for memos containing the query.

func (*MemoClient) Update

func (m *MemoClient) Update(ctx context.Context, id, content, visibility string, tags []string) (*Memo, error)

Update updates a memo.

type User

type User struct {
	Name        string `json:"name"` // "users/123"
	UID         string `json:"uid"`
	Username    string `json:"username"`
	DisplayName string `json:"displayName"`
	Email       string `json:"email"`
	Role        string `json:"role"` // ADMIN, USER
	Avatar      string `json:"avatar"`
	CreatedAt   string `json:"createdAt"`
	UpdatedAt   string `json:"updatedAt"`
}

User represents a Memos user.

Jump to

Keyboard shortcuts

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