Documentation ¶
Overview ¶
Package client provides methods for accessing the discord bouncer REST API.
Index ¶
- Variables
- type AdminService
- type Client
- type DiscordService
- type FilterOption
- type UsersService
- func (s *UsersService) CreateUser(ctx context.Context, u *db.User) (int, error)
- func (s *UsersService) DeleteUser(ctx context.Context, id int) error
- func (s *UsersService) GetAllUsers(ctx context.Context, opts ...FilterOption) ([]*db.User, error)
- func (s *UsersService) GetUser(ctx context.Context, id int) (*db.User, error)
- func (s *UsersService) UpdateUser(ctx context.Context, u *db.User) error
- func (s *UsersService) Upload(ctx context.Context, u *db.User) (id int, key string, err error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidCredentials is returned when the server rejects credentials while logging in. ErrInvalidCredentials = errors.New("invalid credentials") // ErrPasswordTooShort is returned by ChangePassword if the password is too short. ErrPasswordTooShort = errors.New("password too short") // ErrPasswordTooLong is returned by ChangePassword if the password is too long. ErrPasswordTooLong = errors.New("password too long") )
var ErrNotLoggedIn = errors.New("not logged in")
ErrNotLoggedIn is returned when a 401: Unauthorized is returned by the server.
Functions ¶
This section is empty.
Types ¶
type AdminService ¶
type AdminService struct {
// contains filtered or unexported fields
}
AdminService is used to manage authentication with the server.
func (*AdminService) ChangePassword ¶
func (s *AdminService) ChangePassword(ctx context.Context, oldPass, newPass string) error
ChangePassword updates the password on the server. Must be logged in.
type Client ¶
type Client struct { Admin AdminService Users UsersService Discord DiscordService // contains filtered or unexported fields }
Client implements methods to access the disco-bouncer API.
type DiscordService ¶ added in v0.4.0
type DiscordService struct {
// contains filtered or unexported fields
}
DiscordService is used to perform actions on Discord through the bouncerbot.
type FilterOption ¶
type FilterOption = func(f *filters)
FilterOption is a way to add filter options to the request when calling GetAllUsers.
func WithKeyHash ¶
func WithKeyHash(keyHash string) FilterOption
WithKeyHash returns a FilterOption that filters by the provided MD5 key hash.
type UsersService ¶
type UsersService struct {
// contains filtered or unexported fields
}
UserService is used to view and modify the users table on the server.
func (*UsersService) CreateUser ¶
CreateUser creates a new user and returns the ID. u.ID is ignored.
func (*UsersService) DeleteUser ¶
func (s *UsersService) DeleteUser(ctx context.Context, id int) error
DeleteUser removes the user from the server.
func (*UsersService) GetAllUsers ¶
func (s *UsersService) GetAllUsers(ctx context.Context, opts ...FilterOption) ([]*db.User, error)
GetAllUsers gets the current users table.
func (*UsersService) UpdateUser ¶
UpdateUser updates the information for an existing user, selected by u.ID.