Documentation ¶
Index ¶
- Constants
- Variables
- func Convert(influxQL string) (cloudhub.QueryConfig, error)
- func Difference(wants cloudhub.Permissions, haves cloudhub.Permissions) (revoke cloudhub.Permissions, add cloudhub.Permissions)
- func JWT(username, sharedSecret string, now Now) (string, error)
- func ParseTime(influxQL string, now time.Time) (time.Duration, error)
- func TimeRangeAsEpochNano(expr influxql.Expr, now time.Time) (min, max int64, err error)
- func ToGrant(username string, perm cloudhub.Permission) string
- func ToInfluxQL(action, preposition, username string, perm cloudhub.Permission) string
- func ToPriv(a cloudhub.Allowances) string
- func ToRevoke(username string, perm cloudhub.Permission) string
- type AnnotationStore
- func (a *AnnotationStore) Add(ctx context.Context, anno *cloudhub.Annotation) (*cloudhub.Annotation, error)
- func (a *AnnotationStore) All(ctx context.Context, start, stop time.Time, ...) ([]cloudhub.Annotation, error)
- func (a *AnnotationStore) Delete(ctx context.Context, id string) error
- func (a *AnnotationStore) Get(ctx context.Context, id string) (*cloudhub.Annotation, error)
- func (a *AnnotationStore) Update(ctx context.Context, anno *cloudhub.Annotation) error
- type Authorizer
- type BasicAuth
- type BearerJWT
- type Client
- func (c *Client) Add(ctx context.Context, u *cloudhub.User) (*cloudhub.User, error)
- func (c *Client) All(ctx context.Context) ([]cloudhub.User, error)
- func (c *Client) AllDB(ctx context.Context) ([]cloudhub.Database, error)
- func (c *Client) AllRP(ctx context.Context, db string) ([]cloudhub.RetentionPolicy, error)
- func (c *Client) Connect(ctx context.Context, src *cloudhub.Source) error
- func (c *Client) CreateDB(ctx context.Context, db *cloudhub.Database) (*cloudhub.Database, error)
- func (c *Client) CreateRP(ctx context.Context, db string, rp *cloudhub.RetentionPolicy) (*cloudhub.RetentionPolicy, error)
- func (c *Client) Delete(ctx context.Context, u *cloudhub.User) error
- func (c *Client) DropDB(ctx context.Context, db string) error
- func (c *Client) DropRP(ctx context.Context, db string, rp string) error
- func (c *Client) Get(ctx context.Context, q cloudhub.UserQuery) (*cloudhub.User, error)
- func (c *Client) GetMeasurements(ctx context.Context, db string, limit, offset int) ([]cloudhub.Measurement, error)
- func (c *Client) Num(ctx context.Context) (int, error)
- func (c *Client) Permissions(context.Context) cloudhub.Permissions
- func (c *Client) Ping(ctx context.Context) error
- func (c *Client) Query(ctx context.Context, q cloudhub.Query) (cloudhub.Response, error)
- func (c *Client) Roles(ctx context.Context) (cloudhub.RolesStore, error)
- func (c *Client) Type(ctx context.Context) (string, error)
- func (c *Client) Update(ctx context.Context, u *cloudhub.User) error
- func (c *Client) UpdateRP(ctx context.Context, db string, rp string, upd *cloudhub.RetentionPolicy) (*cloudhub.RetentionPolicy, error)
- func (c *Client) Users(ctx context.Context) cloudhub.UsersStore
- func (c *Client) Version(ctx context.Context) (string, error)
- func (c *Client) Write(ctx context.Context, points []cloudhub.Point) error
- type NoAuthorization
- type Now
- type Response
Constants ¶
const ( // AllAnnotations returns all annotations from the CloudHub database AllAnnotations = `SELECT * FROM "annotations" WHERE "deleted"=false AND time >= %dns and "start_time" <= %d %s ORDER BY time DESC` // GetAnnotationID returns all annotations from the CloudHub database where id is %s GetAnnotationID = `SELECT * FROM "annotations" WHERE "id"='%s' AND "deleted"=false ORDER BY time DESC` // AnnotationsDB is CloudHub. Perhaps later we allow this to be changed AnnotationsDB = "cloudhub" // DefaultRP is autogen. Perhaps later we allow this to be changed DefaultRP = "autogen" // DefaultMeasurement is annotations. DefaultMeasurement = "annotations" )
const WhereToken = "WHERE"
WhereToken is used to parse the time expression from an influxql query
Variables ¶
var ( // AllowAllDB means a user gets both read and write permissions for a db AllowAllDB = cloudhub.Allowances{"WRITE", "READ"} // AllowAllAdmin means a user gets both read and write permissions for an admin AllowAllAdmin = cloudhub.Allowances{"ALL"} // AllowRead means a user is only able to read the database. AllowRead = cloudhub.Allowances{"READ"} // AllowWrite means a user is able to only write to the database AllowWrite = cloudhub.Allowances{"WRITE"} // NoPrivileges occasionally shows up as a response for a users grants. NoPrivileges = "NO PRIVILEGES" // AllPrivileges means that a user has both read and write perms AllPrivileges = "ALL PRIVILEGES" // All means a user has both read and write perms. Alternative to AllPrivileges All = "ALL" // Read means a user can read a database Read = "READ" // Write means a user can write to a database Write = "WRITE" )
Functions ¶
func Convert ¶
func Convert(influxQL string) (cloudhub.QueryConfig, error)
Convert changes an InfluxQL query to a QueryConfig
func Difference ¶
func Difference(wants cloudhub.Permissions, haves cloudhub.Permissions) (revoke cloudhub.Permissions, add cloudhub.Permissions)
Difference compares two permission sets and returns a set to be revoked and a set to be added
func JWT ¶
JWT returns a token string accepted by InfluxDB using the sharedSecret as an Authorization: Bearer header
func TimeRangeAsEpochNano ¶
TimeRangeAsEpochNano extracs the min and max epoch times from the expression
func ToGrant ¶
func ToGrant(username string, perm cloudhub.Permission) string
ToGrant converts the permission into InfluxQL grants
func ToInfluxQL ¶
func ToInfluxQL(action, preposition, username string, perm cloudhub.Permission) string
ToInfluxQL converts the permission into InfluxQL
func ToPriv ¶
func ToPriv(a cloudhub.Allowances) string
ToPriv converts cloudhub allowances to InfluxQL
Types ¶
type AnnotationStore ¶
type AnnotationStore struct {
// contains filtered or unexported fields
}
AnnotationStore stores annotations within InfluxDB
func NewAnnotationStore ¶
func NewAnnotationStore(client cloudhub.TimeSeries) *AnnotationStore
NewAnnotationStore constructs an annoation store with a client
func (*AnnotationStore) Add ¶
func (a *AnnotationStore) Add(ctx context.Context, anno *cloudhub.Annotation) (*cloudhub.Annotation, error)
Add creates a new annotation in the store
func (*AnnotationStore) All ¶
func (a *AnnotationStore) All(ctx context.Context, start, stop time.Time, filters []*cloudhub.AnnotationTagFilter) ([]cloudhub.Annotation, error)
All lists all Annotations
func (*AnnotationStore) Delete ¶
func (a *AnnotationStore) Delete(ctx context.Context, id string) error
Delete removes the annotation from the store
func (*AnnotationStore) Get ¶
func (a *AnnotationStore) Get(ctx context.Context, id string) (*cloudhub.Annotation, error)
Get retrieves an annotation
func (*AnnotationStore) Update ¶
func (a *AnnotationStore) Update(ctx context.Context, anno *cloudhub.Annotation) error
Update replaces annotation; if the annotation's time is different, it also removes the previous annotation
type Authorizer ¶
type Authorizer interface { // Set may manipulate the request by adding the Authorization header Set(req *http.Request) error }
Authorizer adds optional authorization header to request
func DefaultAuthorization ¶
func DefaultAuthorization(src *cloudhub.Source) Authorizer
DefaultAuthorization creates either a shared JWT builder, basic auth or Noop
type BearerJWT ¶
BearerJWT is the default Bearer for InfluxDB
type Client ¶
type Client struct { URL *url.URL Authorizer Authorizer InsecureSkipVerify bool Logger cloudhub.Logger }
Client is a device for retrieving time series data from an InfluxDB instance
func (*Client) Connect ¶
Connect caches the URL and optional Bearer Authorization for the data source
func (*Client) CreateRP ¶
func (c *Client) CreateRP(ctx context.Context, db string, rp *cloudhub.RetentionPolicy) (*cloudhub.RetentionPolicy, error)
CreateRP creates a retention policy for a specific database
func (*Client) GetMeasurements ¶
func (c *Client) GetMeasurements(ctx context.Context, db string, limit, offset int) ([]cloudhub.Measurement, error)
GetMeasurements returns measurements in a specified database, paginated by optional limit and offset. If no limit or offset is provided, it defaults to a limit of 100 measurements with no offset.
func (*Client) Permissions ¶
func (c *Client) Permissions(context.Context) cloudhub.Permissions
Permissions return just READ and WRITE for OSS Influx
func (*Client) Query ¶
Query issues a request to a configured InfluxDB instance for time series information specified by query. Queries must be "fully-qualified," and include both the database and retention policy. In-flight requests can be cancelled using the provided context.
func (*Client) UpdateRP ¶
func (c *Client) UpdateRP(ctx context.Context, db string, rp string, upd *cloudhub.RetentionPolicy) (*cloudhub.RetentionPolicy, error)
UpdateRP updates a specific retention policy for a specific database
func (*Client) Users ¶
func (c *Client) Users(ctx context.Context) cloudhub.UsersStore
Users transforms InfluxDB into a user store
type NoAuthorization ¶
type NoAuthorization struct{}
NoAuthorization does not add any authorization headers
type Response ¶
type Response struct { Results json.RawMessage Err string `json:"error,omitempty"` }
Response is a partial JSON decoded InfluxQL response used to check for some errors
func (Response) MarshalJSON ¶
MarshalJSON returns the raw results bytes from the response