Documentation
¶
Index ¶
- type Client
- type HTTPClient
- func (c *HTTPClient) Login(ctx context.Context, input *user.LoginInput) (*types.TokenResponse, error)
- func (c *HTTPClient) Register(ctx context.Context, input *user.RegisterInput) (*types.TokenResponse, error)
- func (c *HTTPClient) Self(ctx context.Context) (*types.User, error)
- func (c *HTTPClient) SetClient(client *http.Client)
- func (c *HTTPClient) SetDebug(debug bool)
- func (c *HTTPClient) User(ctx context.Context, key string) (*types.User, error)
- func (c *HTTPClient) UserCreate(ctx context.Context, user *types.User) (*types.User, error)
- func (c *HTTPClient) UserCreatePAT(ctx context.Context, in user.CreateTokenInput) (*types.TokenResponse, error)
- func (c *HTTPClient) UserDelete(ctx context.Context, key string) error
- func (c *HTTPClient) UserList(ctx context.Context, params types.UserFilter) ([]types.User, error)
- func (c *HTTPClient) UserUpdate(ctx context.Context, key string, user *types.UserInput) (*types.User, error)
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 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) 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) UserCreate ¶
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.