client

package
v1.0.2-gitspaces-beta Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// Login authenticates the user and returns a JWT token.
	Login(ctx context.Context, input *user.LoginInput) (*types.TokenResponse, error)

	// Register registers a new  user and returns a JWT token.
	Register(ctx context.Context, input *user.RegisterInput) (*types.TokenResponse, error)

	// Self returns the currently authenticated user.
	Self(ctx context.Context) (*types.User, error)

	// User returns a user by ID or email.
	User(ctx context.Context, key string) (*types.User, error)

	// UserList returns a list of all registered users.
	UserList(ctx context.Context, params types.UserFilter) ([]types.User, error)

	// UserCreate creates a new user account.
	UserCreate(ctx context.Context, user *types.User) (*types.User, error)

	// UserUpdate updates a user account by ID or email.
	UserUpdate(ctx context.Context, key string, input *types.UserInput) (*types.User, error)

	// UserDelete deletes a user account by ID or email.
	UserDelete(ctx context.Context, key string) error

	// UserCreatePAT creates a new PAT for the user.
	UserCreatePAT(ctx context.Context, in user.CreateTokenInput) (*types.TokenResponse, error)
}

Client to access the remote APIs.

type HTTPClient

type HTTPClient struct {
	// contains filtered or unexported fields
}

HTTPClient provides an HTTP client for interacting with the remote API.

func New

func New(uri string) *HTTPClient

New returns a client at the specified url.

func NewToken

func NewToken(uri, token string) *HTTPClient

NewToken returns a client at the specified url that authenticates all outbound requests with the given token.

func (*HTTPClient) Login

func (c *HTTPClient) Login(ctx context.Context, input *user.LoginInput) (*types.TokenResponse, error)

Login authenticates the user and returns a JWT token.

func (*HTTPClient) Register

func (c *HTTPClient) Register(ctx context.Context, input *user.RegisterInput) (*types.TokenResponse, error)

Register registers a new user and returns a JWT token.

func (*HTTPClient) Self

func (c *HTTPClient) Self(ctx context.Context) (*types.User, error)

Self returns the currently authenticated user.

func (*HTTPClient) SetClient

func (c *HTTPClient) SetClient(client *http.Client)

SetClient sets the default http client. This can be used in conjunction with golang.org/x/oauth2 to authenticate requests to the server.

func (*HTTPClient) SetDebug

func (c *HTTPClient) SetDebug(debug bool)

SetDebug sets the debug flag. When the debug flag is true, the http.Resposne body to stdout which can be helpful when debugging.

func (*HTTPClient) User

func (c *HTTPClient) User(ctx context.Context, key string) (*types.User, error)

User returns a user by ID or email.

func (*HTTPClient) UserCreate

func (c *HTTPClient) UserCreate(ctx context.Context, user *types.User) (*types.User, error)

UserCreate creates a new user account.

func (*HTTPClient) UserCreatePAT

func (c *HTTPClient) UserCreatePAT(ctx context.Context, in user.CreateTokenInput) (*types.TokenResponse, error)

UserCreatePAT creates a new PAT for the user.

func (*HTTPClient) UserDelete

func (c *HTTPClient) UserDelete(ctx context.Context, key string) error

UserDelete deletes a user account by ID or email.

func (*HTTPClient) UserList

func (c *HTTPClient) UserList(ctx context.Context, params types.UserFilter) ([]types.User, error)

UserList returns a list of all registered users.

func (*HTTPClient) UserUpdate

func (c *HTTPClient) UserUpdate(ctx context.Context, key string, user *types.UserInput) (*types.User, error)

UserUpdate updates a user account by ID or email.

Jump to

Keyboard shortcuts

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