lemmy

package module
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2023 License: GPL-3.0 Imports: 14 Imported by: 1

README

Go-Lemmy

Go Reference

Go bindings to the Lemmy API, automatically generated directly from Lemmy's source code using the generator in cmd/gen.

Examples:

How to generate

First, build the generator:

go build ./cmd/gen

Clone Lemmy's source code at whatever version you need:

git clone https://github.com/LemmyNet/lemmy -b 0.16.7

Remove all the existing generated code:

rm **/*.gen.go

Execute the generator:

./gen -out-dir .

And that's it! Your generated code should be ready for use.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeResponse

func DecodeResponse(data json.RawMessage, out any) error

Types

type Client

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

Client is a client for Lemmy's HTTP API

func New

func New(baseURL string) (*Client, error)

New creates a new Lemmy client with the default HTTP client.

func NewWithClient

func NewWithClient(baseURL string, client *http.Client) (*Client, error)

NewWithClient creates a new Lemmy client with the given HTTP client

func (*Client) AddAdmin

func (c *Client) AddAdmin(ctx context.Context, data types.AddAdmin) (*types.AddAdminResponse, error)

func (*Client) AddModToCommunity

func (c *Client) AddModToCommunity(ctx context.Context, data types.AddModToCommunity) (*types.AddModToCommunityResponse, error)

func (*Client) BanFromCommunity

func (c *Client) BanFromCommunity(ctx context.Context, data types.BanFromCommunity) (*types.BanFromCommunityResponse, error)

func (*Client) BanPerson

func (c *Client) BanPerson(ctx context.Context, data types.BanPerson) (*types.BanPersonResponse, error)

func (*Client) BannedPersons

func (c *Client) BannedPersons(ctx context.Context, data types.GetBannedPersons) (*types.BannedPersonsResponse, error)

func (*Client) BlockCommunity

func (c *Client) BlockCommunity(ctx context.Context, data types.BlockCommunity) (*types.BlockCommunityResponse, error)

func (*Client) BlockPerson

func (c *Client) BlockPerson(ctx context.Context, data types.BlockPerson) (*types.BlockPersonResponse, error)

func (*Client) Captcha

func (c *Client) Captcha(ctx context.Context, data types.GetCaptcha) (*types.GetCaptchaResponse, error)

func (*Client) ChangePassword

func (c *Client) ChangePassword(ctx context.Context, data types.ChangePassword) (*types.LoginResponse, error)

func (*Client) ClientLogin

func (c *Client) ClientLogin(ctx context.Context, l types.Login) error

ClientLogin logs in to Lemmy by sending an HTTP request to the login endpoint. It stores the returned token in the client for future use.

func (*Client) Comment

func (c *Client) Comment(ctx context.Context, data types.GetComment) (*types.CommentResponse, error)

func (*Client) CommentReports added in v0.17.0

func (*Client) Comments

func (*Client) Communities added in v0.17.0

func (*Client) Community

func (*Client) CommunityJoin

func (c *Client) CommunityJoin(ctx context.Context, data types.CommunityJoin) (*types.CommunityJoinResponse, error)

func (*Client) CreateComment

func (c *Client) CreateComment(ctx context.Context, data types.CreateComment) (*types.CommentResponse, error)

func (*Client) CreateCommentLike

func (c *Client) CreateCommentLike(ctx context.Context, data types.CreateCommentLike) (*types.CommentResponse, error)

func (*Client) CreateCommentReport

func (c *Client) CreateCommentReport(ctx context.Context, data types.CreateCommentReport) (*types.CommentReportResponse, error)

func (*Client) CreateCommunity

func (c *Client) CreateCommunity(ctx context.Context, data types.CreateCommunity) (*types.CommunityResponse, error)

func (*Client) CreatePost

func (c *Client) CreatePost(ctx context.Context, data types.CreatePost) (*types.PostResponse, error)

func (*Client) CreatePostLike

func (c *Client) CreatePostLike(ctx context.Context, data types.CreatePostLike) (*types.PostResponse, error)

func (*Client) CreatePostReport

func (c *Client) CreatePostReport(ctx context.Context, data types.CreatePostReport) (*types.PostReportResponse, error)

func (*Client) CreatePrivateMessage

func (c *Client) CreatePrivateMessage(ctx context.Context, data types.CreatePrivateMessage) (*types.PrivateMessageResponse, error)

func (*Client) CreatePrivateMessageReport added in v0.17.0

func (c *Client) CreatePrivateMessageReport(ctx context.Context, data types.CreatePrivateMessageReport) (*types.PrivateMessageReportResponse, error)

func (*Client) CreateSite

func (c *Client) CreateSite(ctx context.Context, data types.CreateSite) (*types.SiteResponse, error)

func (*Client) DeleteAccount

func (c *Client) DeleteAccount(ctx context.Context, data types.DeleteAccount) (*types.DeleteAccountResponse, error)

func (*Client) DeleteComment

func (c *Client) DeleteComment(ctx context.Context, data types.DeleteComment) (*types.CommentResponse, error)

func (*Client) DeleteCommunity

func (c *Client) DeleteCommunity(ctx context.Context, data types.DeleteCommunity) (*types.CommunityResponse, error)

func (*Client) DeletePost

func (c *Client) DeletePost(ctx context.Context, data types.DeletePost) (*types.PostResponse, error)

func (*Client) DeletePrivateMessage

func (c *Client) DeletePrivateMessage(ctx context.Context, data types.DeletePrivateMessage) (*types.PrivateMessageResponse, error)

func (*Client) EditComment

func (c *Client) EditComment(ctx context.Context, data types.EditComment) (*types.CommentResponse, error)

func (*Client) EditCommunity

func (c *Client) EditCommunity(ctx context.Context, data types.EditCommunity) (*types.CommunityResponse, error)

func (*Client) EditPost

func (c *Client) EditPost(ctx context.Context, data types.EditPost) (*types.PostResponse, error)

func (*Client) EditPrivateMessage

func (c *Client) EditPrivateMessage(ctx context.Context, data types.EditPrivateMessage) (*types.PrivateMessageResponse, error)

func (*Client) EditSite

func (c *Client) EditSite(ctx context.Context, data types.EditSite) (*types.SiteResponse, error)

func (*Client) FeaturePost added in v0.17.0

func (c *Client) FeaturePost(ctx context.Context, data types.FeaturePost) (*types.PostResponse, error)

func (*Client) FollowCommunity

func (c *Client) FollowCommunity(ctx context.Context, data types.FollowCommunity) (*types.CommunityResponse, error)

func (*Client) HideCommunity

func (c *Client) HideCommunity(ctx context.Context, data types.HideCommunity) (*types.CommunityResponse, error)

func (*Client) LeaveAdmin

func (c *Client) LeaveAdmin(ctx context.Context, data types.LeaveAdmin) (*types.GetSiteResponse, error)

func (*Client) LockPost

func (c *Client) LockPost(ctx context.Context, data types.LockPost) (*types.PostResponse, error)

func (*Client) Login

func (c *Client) Login(ctx context.Context, data types.Login) (*types.LoginResponse, error)

func (*Client) MarkAllAsRead

func (c *Client) MarkAllAsRead(ctx context.Context, data types.MarkAllAsRead) (*types.GetRepliesResponse, error)

func (*Client) MarkCommentReplyAsRead added in v0.17.0

func (c *Client) MarkCommentReplyAsRead(ctx context.Context, data types.MarkCommentReplyAsRead) (*types.CommentReplyResponse, error)

func (*Client) MarkPersonMentionAsRead

func (c *Client) MarkPersonMentionAsRead(ctx context.Context, data types.MarkPersonMentionAsRead) (*types.PersonMentionResponse, error)

func (*Client) MarkPostAsRead

func (c *Client) MarkPostAsRead(ctx context.Context, data types.MarkPostAsRead) (*types.PostResponse, error)

func (*Client) MarkPrivateMessageAsRead

func (c *Client) MarkPrivateMessageAsRead(ctx context.Context, data types.MarkPrivateMessageAsRead) (*types.PrivateMessageResponse, error)

func (*Client) ModJoin

func (c *Client) ModJoin(ctx context.Context, data types.ModJoin) (*types.ModJoinResponse, error)

func (*Client) Modlog

func (c *Client) Modlog(ctx context.Context, data types.GetModlog) (*types.GetModlogResponse, error)

func (*Client) PasswordChangeAfterReset

func (c *Client) PasswordChangeAfterReset(ctx context.Context, data types.PasswordChangeAfterReset) (*types.LoginResponse, error)

func (*Client) PasswordReset

func (c *Client) PasswordReset(ctx context.Context, data types.PasswordReset) (*types.PasswordResetResponse, error)

func (*Client) PersonDetails

func (*Client) PersonMentions

func (*Client) Post

func (c *Client) Post(ctx context.Context, data types.GetPost) (*types.GetPostResponse, error)

func (*Client) PostJoin

func (c *Client) PostJoin(ctx context.Context, data types.PostJoin) (*types.PostJoinResponse, error)

func (*Client) PostReports added in v0.17.0

func (*Client) Posts

func (c *Client) Posts(ctx context.Context, data types.GetPosts) (*types.GetPostsResponse, error)

func (*Client) PrivateMessageReports added in v0.17.0

func (*Client) PrivateMessages

func (*Client) PurgeComment added in v0.17.0

func (c *Client) PurgeComment(ctx context.Context, data types.PurgeComment) (*types.PurgeItemResponse, error)

func (*Client) PurgeCommunity added in v0.17.0

func (c *Client) PurgeCommunity(ctx context.Context, data types.PurgeCommunity) (*types.PurgeItemResponse, error)

func (*Client) PurgePerson added in v0.17.0

func (c *Client) PurgePerson(ctx context.Context, data types.PurgePerson) (*types.PurgeItemResponse, error)

func (*Client) PurgePost added in v0.17.0

func (c *Client) PurgePost(ctx context.Context, data types.PurgePost) (*types.PurgeItemResponse, error)

func (*Client) Register

func (c *Client) Register(ctx context.Context, data types.Register) (*types.LoginResponse, error)

func (*Client) RegistrationApplications added in v0.17.0

func (*Client) RemoveComment

func (c *Client) RemoveComment(ctx context.Context, data types.RemoveComment) (*types.CommentResponse, error)

func (*Client) RemoveCommunity

func (c *Client) RemoveCommunity(ctx context.Context, data types.RemoveCommunity) (*types.CommunityResponse, error)

func (*Client) RemovePost

func (c *Client) RemovePost(ctx context.Context, data types.RemovePost) (*types.PostResponse, error)

func (*Client) Replies

func (c *Client) Replies(ctx context.Context, data types.GetReplies) (*types.GetRepliesResponse, error)

func (*Client) ReportCount

func (*Client) ResolveCommentReport

func (c *Client) ResolveCommentReport(ctx context.Context, data types.ResolveCommentReport) (*types.CommentReportResponse, error)

func (*Client) ResolveObject

func (c *Client) ResolveObject(ctx context.Context, data types.ResolveObject) (*types.ResolveObjectResponse, error)

func (*Client) ResolvePostReport

func (c *Client) ResolvePostReport(ctx context.Context, data types.ResolvePostReport) (*types.PostReportResponse, error)

func (*Client) ResolvePrivateMessageReport added in v0.17.0

func (c *Client) ResolvePrivateMessageReport(ctx context.Context, data types.ResolvePrivateMessageReport) (*types.PrivateMessageReportResponse, error)

func (*Client) SaveComment

func (c *Client) SaveComment(ctx context.Context, data types.SaveComment) (*types.CommentResponse, error)

func (*Client) SavePost

func (c *Client) SavePost(ctx context.Context, data types.SavePost) (*types.PostResponse, error)

func (*Client) SaveUserSettings

func (c *Client) SaveUserSettings(ctx context.Context, data types.SaveUserSettings) (*types.LoginResponse, error)

func (*Client) Search

func (c *Client) Search(ctx context.Context, data types.Search) (*types.SearchResponse, error)

func (*Client) Site

func (c *Client) Site(ctx context.Context, data types.GetSite) (*types.GetSiteResponse, error)

func (*Client) SiteMetadata

func (*Client) TransferCommunity

func (c *Client) TransferCommunity(ctx context.Context, data types.TransferCommunity) (*types.GetCommunityResponse, error)

func (*Client) UnreadCount

func (*Client) UserJoin

func (c *Client) UserJoin(ctx context.Context, data types.UserJoin) (*types.UserJoinResponse, error)

func (*Client) VerifyEmail

func (c *Client) VerifyEmail(ctx context.Context, data types.VerifyEmail) (*types.VerifyEmailResponse, error)

type WSClient

type WSClient struct {
	Token string
	// contains filtered or unexported fields
}

WSClient is a client for Lemmy's WebSocket API

func NewWebSocket

func NewWebSocket(baseURL string) (*WSClient, error)

NewWebSocket creates and returns a new WSClient, and starts a goroutine to read server responses and errors

func (*WSClient) ClientLogin

func (c *WSClient) ClientLogin(ctx context.Context, l types.Login) error

ClientLogin logs in to Lemmy by sending an HTTP request to the login endpoint. It stores the returned token in the client for future use.

func (*WSClient) Errors

func (c *WSClient) Errors() <-chan error

Errors returns a channel that receives errors received while attempting to read responses

func (*WSClient) OnReconnect added in v0.17.0

func (c *WSClient) OnReconnect(rh func(c *WSClient))

func (*WSClient) Request

func (c *WSClient) Request(op types.Operation, data any) error

Request sends a request to the server. If data is nil, the authentication token will be sent instead. If data has an Auth field, it will be set to the authentication token automatically.

func (*WSClient) Responses

func (c *WSClient) Responses() <-chan types.LemmyWebSocketMsg

Responses returns a channel that receives messages from Lemmy.

Directories

Path Synopsis
cmd
gen
examples

Jump to

Keyboard shortcuts

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