Documentation ¶
Index ¶
- Variables
- type Account
- type Client
- func (c *Client) AddReferrer(ctx context.Context, acc, referrer *Account) error
- func (c *Client) ApplyKey(ctx context.Context, acc *Account, key string) error
- func (c *Client) Do(req *http.Request) (*http.Response, error)
- func (c *Client) GetAccountData(ctx context.Context, acc *Account) (*models.Account, error)
- func (c *Client) NewAccount(ctx context.Context) (*Account, error)
- func (c *Client) NewAccountWithLicense(ctx context.Context) (*models.Account, error)
- func (c *Client) RemoveDevice(ctx context.Context, acc *Account) error
- func (c *Client) UpdateConfig(config *ConfigurationData)
- type Configuration
- func (cc *Configuration) BaseURL() string
- func (cc *Configuration) CFClientVersion() string
- func (cc *Configuration) Data() ConfigurationData
- func (cc *Configuration) Host() string
- func (cc *Configuration) Keys() []string
- func (cc *Configuration) Update(updated *ConfigurationData)
- func (cc *Configuration) UserAgent() string
- func (cc *Configuration) WaitTime() time.Duration
- type ConfigurationData
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrRegAccount = errors.New("client: failed to register an account") ErrUpdateAccount = errors.New("client: failed to update the account data") ErrEncodeAccount = errors.New("client: failed to encode account data") ErrDecodeAccount = errors.New("client: failed to decode account data") ErrGetAccountData = errors.New("client: failed to get the account data") ErrFetchingConfiguration = errors.New("client: error fetching configuration") )
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { ID string `json:"id"` Account struct { License string `json:"license"` } `json:"account"` Token string `json:"token"` }
Account represents a registered CF account.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(config *Configuration, logging bool) *Client
func (*Client) AddReferrer ¶
func (*Client) GetAccountData ¶
func (*Client) NewAccountWithLicense ¶
NewAccountWithLicense creates models.Account with random license.
func (*Client) RemoveDevice ¶
func (*Client) UpdateConfig ¶
func (c *Client) UpdateConfig(config *ConfigurationData)
type Configuration ¶
type Configuration struct {
// contains filtered or unexported fields
}
Configuration wraps ConfigurationData with a mutex to allow goroutine-safe access.
func NewConfiguration ¶
func NewConfiguration() *Configuration
func (*Configuration) BaseURL ¶
func (cc *Configuration) BaseURL() string
func (*Configuration) CFClientVersion ¶
func (cc *Configuration) CFClientVersion() string
func (*Configuration) Data ¶
func (cc *Configuration) Data() ConfigurationData
Data returns a copy of stored data.
func (*Configuration) Host ¶
func (cc *Configuration) Host() string
func (*Configuration) Keys ¶
func (cc *Configuration) Keys() []string
func (*Configuration) Update ¶
func (cc *Configuration) Update(updated *ConfigurationData)
func (*Configuration) UserAgent ¶
func (cc *Configuration) UserAgent() string
func (*Configuration) WaitTime ¶
func (cc *Configuration) WaitTime() time.Duration
type ConfigurationData ¶
type ConfigurationData struct { CFClientVersion string UserAgent string Host string BaseURL string Keys []string WaitTime time.Duration }
ConfigurationData is the configuration required for the client to work.
func DefaultConfigurationData ¶
func DefaultConfigurationData() *ConfigurationData
DefaultConfigurationData returns usable default configuration.
func GetConfiguration ¶
func GetConfiguration(ctx context.Context, url string) (*ConfigurationData, error)
GetConfiguration returns a new configuration parsed from the url, or an error if it fails to parse.
Click to show internal directories.
Click to hide internal directories.