Documentation ¶
Overview ¶
Example (RegistrationURL) ¶
Example of getting a registration URL for a product
c := client.New("") r := client.Registration{ ClusterID: "clus1", Product: "chronograf", RedirectURL: "http://example.com", } s, _ := c.RegistrationURL(r) fmt.Printf("s: %s\n", s) // https://usage.influxdata.com/start?cluster_id=clus1&product=chronograf&redirect_url=http%3A%2F%2Fexample.com
Output:
Example (SaveServer) ¶
Example of saving a server to the Usage API
c := client.New("token-goes-here") // override the URL for testing c.URL = "https://usage.staging.influxdata.com" s := client.Server{ ClusterID: "clus1", Host: "example.com", Product: "jambox", Version: "1.0", ServerID: "serv1", } res, err := c.Save(s) fmt.Printf("err: %s\n", err) b, _ := ioutil.ReadAll(res.Body) fmt.Printf("b: %s\n", b)
Output:
Example (SaveStats) ¶
Example of saving Stats data to Enterprise
c := client.New("token-goes-here") // override the URL for testing c.URL = "https://usage.staging.influxdata.com" st := client.Stats{ ClusterID: "clus1", ServerID: "serv1", Product: "influxdb", Data: []client.StatsData{ client.StatsData{ Name: "engine", Tags: client.Tags{ "path": "/home/philip/.influxdb/data/_internal/monitor/1", "version": "bz1", }, Values: client.Values{ "blks_write": 39, "blks_write_bytes": 2421, "blks_write_bytes_c": 2202, "points_write": 39, "points_write_dedupe": 39, }, }, }, } res, err := c.Save(st) fmt.Printf("err: %s\n", err) b, _ := ioutil.ReadAll(res.Body) fmt.Printf("b: %s\n", b)
Output:
Example (SaveUsage) ¶
Example of saving Usage data to the Usage API
c := client.New("token-goes-here") // override the URL for testing c.URL = "https://usage.staging.influxdata.com" u := client.Usage{ Product: "influxdb", Data: []client.UsageData{ { Tags: client.Tags{ "version": "0.9.5", "arch": "amd64", "os": "linux", }, Values: client.Values{ "cluster_id": "23423", "server_id": "1", "num_databases": 3, "num_measurements": 2342, "num_series": 87232, }, }, }, } res, err := c.Save(u) fmt.Printf("err: %s\n", err) b, _ := ioutil.ReadAll(res.Body) fmt.Printf("b: %s\n", b)
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var URL = "https://usage.influxdata.com"
URL is the default URL for the host of the Usage API. This variable can be set globally or on a per Client instance.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { URL string // Defaults to `client.URL` Token string // OPTIONAL: The token of the customer making the request }
Client handles all of the heavy lifting of talking to the Usage API for you.
func New ¶
New returns a configured `Client`. The `token` is optional, but if you have it, you should pass it in.
func (*Client) RegistrationURL ¶
func (c *Client) RegistrationURL(r Registration) (string, error)
RegistrationURL returns a URL based on the Registration data provided. The app can then use this URL to direct customers over to the Enterprise application to complete their registration.
func (*Client) Save ¶
Save does all of the heavy lifting of saving a Saveable Type to the Usage API. This will take care of things like building the full path, setting the `token` on the request if one is available, etc... It will also check the status code of the response and handle non-successful responses by generating a proper `error` for them.
type Registration ¶
type Registration struct { ClusterID string Product string // influxdb, chronograf, telegraf, kapicator // OPTIONAL: Enterprise will redirect the customer back to the // RedirectURL if it is specified. RedirectURL string }
Registration is used to collect data needed by Enterprise to properly start the registration Process.
func (Registration) IsValid ¶
func (r Registration) IsValid() error
IsValid returns an error if the Registration is not valid. This is necessary since there is no server-side validation of this data.
type Saveable ¶
type Saveable interface { // Path returns specific path to where this type should // be saved, that is everything in the path __after__ "/api/v1". Path() string }
Saveable needs to be implemented for types that want to be able to be saved to the Usage API.
type Server ¶
type SimpleError ¶
type SimpleError struct {
Message string `json:"error"`
}
SimpleError wraps simple error messages that come from the Usage API, such as: {"error":"json: cannot unmarshal number into Go value of type string"}
func (SimpleError) Error ¶
func (se SimpleError) Error() string
type Stats ¶
type Usage ¶
func (Usage) MarshalJSON ¶
type ValidationErrors ¶
ValidationErrors wraps more complex validation errors that the Usage API generates. These most usually come as the result of a 422 error.
func (ValidationErrors) Error ¶
func (ve ValidationErrors) Error() string