Documentation ¶
Index ¶
- Constants
- type APKTokenRequest
- type Client
- func (c *Client) AutoRefreshToken()
- func (c *Client) ForgetSecrets()
- func (c *Client) GetDataset(name string) *Dataset
- func (c *Client) GetToken() Token
- func (c *Client) GetTokenRequest() interface{}
- func (c *Client) RefreshToken()
- func (c *Client) SetToken(token Token)
- func (c *Client) SetTokenLifetime(duration time.Duration)
- func (c *Client) SetTokenRequest(tokenRequest interface{})
- func (c *Client) UseAPKToken(apiKey, apiSecret string) error
- func (c *Client) UseUMSToken(email, password string) error
- type Dataset
- type Error
- type Option
- type Token
- type UMSTokenRequest
Constants ¶
const API = "API"
API signifies the error was send from the Jexia API directly
const ( // DefaultLifetime is 2 hours minus 2 minutes to ensure we never lose the token DefaultLifetime = 118 * time.Minute )
const Internal = "Internal"
Internal signifies the error was send from an internal source
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APKTokenRequest ¶
type APKTokenRequest struct { Method string `json:"method"` Key string `json:"key"` Secret string `json:"secret"` }
APKTokenRequest is the JSON data sent to the /auth endpoint when authenticating with the API key
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client contains most data needed for each request
func (*Client) AutoRefreshToken ¶
func (c *Client) AutoRefreshToken()
AutoRefreshToken sets the token to refresh at a certain interval based on token lifetime
func (*Client) ForgetSecrets ¶
func (c *Client) ForgetSecrets()
ForgetSecrets removes the secret from the APKTokenRequest or the password from the UMSTokenRequest
func (*Client) GetDataset ¶
GetDataset returns a dataset instance that can be used to perform actions against
func (*Client) GetTokenRequest ¶
func (c *Client) GetTokenRequest() interface{}
GetTokenRequest passes the current token request
func (*Client) RefreshToken ¶
func (c *Client) RefreshToken()
RefreshToken triggers a token refresh once called
func (*Client) SetTokenLifetime ¶
SetTokenLifetime sets the duration before a token refresh is called Note: This currently only applies after the first 118 minute loop TODO: Ensure that this new duration is set immediately and not after the current loop
func (*Client) SetTokenRequest ¶
func (c *Client) SetTokenRequest(tokenRequest interface{})
SetTokenRequest assigns the user token to the client for future use
func (*Client) UseAPKToken ¶
UseAPKToken assigns the user token to the client for future use
func (*Client) UseUMSToken ¶
UseUMSToken assigns the user token to the client for future use
type Dataset ¶
Dataset a struct containing the name of the dataset and the client memory pointer As the client is a memory pointer, any changes made to the client will be reflected within the dataset, therefore token refreshes will still work
type Error ¶
type Error struct { ID string `json:"request_id"` Message string `json:"message"` Origin string `json:"origin"` Temporary bool `json:"temporary"` }
Error is the error returned, allows for retry scenarios
type Option ¶
type Option func(*Client)
Option allows the client to be configured with different options.
func SetHTTPClient ¶
SetHTTPClient allows for a custom client to be set
func SetProjectURL ¶
SetProjectURL allows for a custom url to be set which does not match that of the standard pattern Note: If such url contains strings such as the project ID, this needs to be computed before being passed through
type Token ¶
type Token struct { Access string `json:"access_token"` Refresh string `json:"refresh_token"` Lifetime time.Duration }
Token is the response from the /auth request which contains the access and refresh tokens Currently, each token lasts 2 hours. https://docs.jexia.com/auth/#:~:text=token%20is%20valid%20for
type UMSTokenRequest ¶
type UMSTokenRequest struct { Method string `json:"method"` Email string `json:"email"` Password string `json:"password"` }
UMSTokenRequest is the JSON data sent to the /auth endpoint when authenticating with user credentials