shoreline

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2023 License: BSD-2-Clause Imports: 19 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewShorelineClientFromEnv

func NewShorelineClientFromEnv(httpClient *http.Client) *Client

NewShorelineClientFromEnv read the config from the environment variables

func (*Client) CheckToken

func (client *Client) CheckToken(tkn string) *token.TokenData

CheckToken tests a token with the user-api to make sure it's current; if so, it returns the data encoded in the token.

func (*Client) Close

func (client *Client) Close()

func (*Client) DeleteUser added in v1.8.5

func (client *Client) DeleteUser(userID string, token string) error

Delete user

func (*Client) GetUnverifiedUsers added in v1.8.5

func (client *Client) GetUnverifiedUsers(token string) ([]schema.UserData, error)

Get users with unverified email

func (*Client) GetUser

func (client *Client) GetUser(userID, token string) (*schema.UserData, error)

Get user details for the given user In this case the userID could be the actual ID or an email address

func (*Client) Login

func (client *Client) Login(username, password string) (*schema.UserData, string, error)

Login logs in a user with a username and password. Returns a UserData object if successful and also stores the returned login token into ClientToken.

func (*Client) Signup

func (client *Client) Signup(username, password, email string) (*schema.UserData, error)

Signs up a new user Returns a UserData object if successful

func (*Client) Start

func (client *Client) Start() error

Start starts the client and makes it ready for us. This must be done before using any of the functionality that requires a server token

func (*Client) TokenProvide

func (client *Client) TokenProvide() string

func (*Client) UpdateUser

func (client *Client) UpdateUser(userID string, userUpdate schema.UserUpdate, token string) error

Get user details for the given user In this case the userID could be the actual ID or an email address

type ClientBuilder

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

func NewShorelineClientBuilder

func NewShorelineClientBuilder() *ClientBuilder

func (*ClientBuilder) Build

func (b *ClientBuilder) Build() *Client

Build return client from builder

func (*ClientBuilder) WithConfig

func (b *ClientBuilder) WithConfig(val *ClientConfig) *ClientBuilder

WithConfig sets the whole config

func (*ClientBuilder) WithHTTPClient

func (b *ClientBuilder) WithHTTPClient(httpClient *http.Client) *ClientBuilder

WithHTTPClient set the HTTP client

func (*ClientBuilder) WithHost

func (b *ClientBuilder) WithHost(host string) *ClientBuilder

WithHost set the host

func (*ClientBuilder) WithName

func (b *ClientBuilder) WithName(val string) *ClientBuilder

WithName sets the name of the server (config)

func (*ClientBuilder) WithSecret

func (b *ClientBuilder) WithSecret(val string) *ClientBuilder

WithSecret sets the secret (config)

func (*ClientBuilder) WithTokenGetInterval

func (b *ClientBuilder) WithTokenGetInterval(val time.Duration) *ClientBuilder

WithTokenGetInterval sets the duration interval for token initial ack (config)

func (*ClientBuilder) WithTokenRefreshInterval

func (b *ClientBuilder) WithTokenRefreshInterval(val time.Duration) *ClientBuilder

WithTokenRefreshInterval sets the duration interval for token refresh (config)

type ClientConfig

type ClientConfig struct {
	Name                 string          `json:"name"`                 // The name of this server for use in obtaining a server token
	Secret               string          `json:"secret"`               // The secret used along with the name to obtain a server token
	TokenRefreshInterval jepson.Duration `json:"tokenRefreshInterval"` // The amount of time between refreshes of the server token
	TokenGetInterval     time.Duration   `json:"tokenGetInterval"`     // The amount of time between attempts to get the server token
}

type ClientInterface

type ClientInterface interface {
	Start() error
	Close()
	Login(username, password string) (*schema.UserData, string, error)
	Signup(username, password, email string) (*schema.UserData, error)
	CheckToken(token string) *token.TokenData
	TokenProvide() string
	GetUser(userID, token string) (*schema.UserData, error)
	UpdateUser(userID string, userUpdate schema.UserUpdate, token string) error
	GetUnverifiedUsers(token string) ([]schema.UserData, error)
	DeleteUser(userID string, token string) error
}

type ShorelineMockClient

type ShorelineMockClient struct {
	mock.Mock
	ServerToken  string
	Unauthorized bool
	UserID       string
	IsServer     bool
}

func NewMock

func NewMock(token string) *ShorelineMockClient

func (*ShorelineMockClient) CheckToken

func (client *ShorelineMockClient) CheckToken(tkn string) *token.TokenData

func (*ShorelineMockClient) Close

func (client *ShorelineMockClient) Close()

func (*ShorelineMockClient) DeleteUser added in v1.8.5

func (client *ShorelineMockClient) DeleteUser(userId string, token string) error

func (*ShorelineMockClient) GetUnverifiedUsers added in v1.8.5

func (client *ShorelineMockClient) GetUnverifiedUsers(token string) ([]schema.UserData, error)

func (*ShorelineMockClient) GetUser

func (client *ShorelineMockClient) GetUser(userID, token string) (*schema.UserData, error)

func (*ShorelineMockClient) Login

func (client *ShorelineMockClient) Login(username, password string) (*schema.UserData, string, error)

func (*ShorelineMockClient) Signup

func (client *ShorelineMockClient) Signup(username, password, email string) (*schema.UserData, error)

func (*ShorelineMockClient) Start

func (client *ShorelineMockClient) Start() error

func (*ShorelineMockClient) TokenProvide

func (client *ShorelineMockClient) TokenProvide() string

func (*ShorelineMockClient) UpdateUser

func (client *ShorelineMockClient) UpdateUser(userID string, userUpdate schema.UserUpdate, token string) error

Jump to

Keyboard shortcuts

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