influx2http

package
v0.0.0-...-03a88a3 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2022 License: MIT Imports: 22 Imported by: 0

README

This package is a temporary hack while the repo'd influxdb client settles down. The code herein was copied from github.com/influxdata/influxdb/http, at commit c1ad0f03d.

Documentation

Index

Constants

View Source
const (
	// OrgName is the http query parameter to specify an organization by name.
	OrgName = "org"
	// OrgID is the http query parameter to specify an organization by ID.
	OrgID = "orgID"
)

Variables

This section is empty.

Functions

func CheckError

func CheckError(resp *http.Response) (err error)

CheckError reads the http.Response and returns an error if one exists. It will automatically recognize the errors returned by Influx services and decode the error into an internal error type. If the error cannot be determined in that way, it will create a generic error message.

If there is no error, then this returns nil.

func NewClient

func NewClient(scheme string, insecure bool) *http.Client

func NewURL

func NewURL(addr, path string) (*url.URL, error)

func SetToken

func SetToken(token string, req *http.Request)

SetToken adds the token to the request.

Types

type BucketService

type BucketService struct {
	Addr               string
	Token              string
	InsecureSkipVerify bool
	// OpPrefix is an additional property for error
	// find bucket service, when finds nothing.
	OpPrefix string
}

BucketService connects to Influx via HTTP using tokens to manage buckets

func (*BucketService) FindBucket

func (s *BucketService) FindBucket(ctx context.Context, filter influxdb.BucketFilter) (*influxdb.Bucket, error)

FindBucket returns the first bucket that matches filter.

func (*BucketService) FindBuckets

func (s *BucketService) FindBuckets(ctx context.Context, filter influxdb.BucketFilter, opt ...influxdb.FindOptions) ([]*influxdb.Bucket, int, error)

FindBuckets returns a list of buckets that match filter and the total count of matching buckets. Additional options provide pagination & sorting.

type FluxQueryService

type FluxQueryService struct {
	Addr               string
	Token              string
	InsecureSkipVerify bool
}

FluxQueryService implements query.QueryService by making HTTP requests to the /api/v2/query API endpoint.

func (*FluxQueryService) Query

Query runs a flux query against a influx server and decodes the result

type FluxService

type FluxService struct {
	Addr               string
	Token              string
	InsecureSkipVerify bool
}

FluxService connects to Influx via HTTP using tokens to run queries.

func (*FluxService) Query

Query runs a flux query against a influx server and sends the results to the io.Writer. Will use the token from the context over the token within the service struct.

type OrganizationService

type OrganizationService struct {
	Addr               string
	Token              string
	InsecureSkipVerify bool
	// OpPrefix is for not found errors.
	OpPrefix string
}

OrganizationService connects to Influx via HTTP using tokens to manage organizations.

func (*OrganizationService) FindOrganization

FindOrganization gets a single organization matching the filter using HTTP.

func (*OrganizationService) FindOrganizations

FindOrganizations returns all organizations that match the filter via HTTP.

type QueryDialect

type QueryDialect struct {
	Header         *bool    `json:"header"`
	Delimiter      string   `json:"delimiter"`
	CommentPrefix  string   `json:"commentPrefix"`
	DateTimeFormat string   `json:"dateTimeFormat"`
	Annotations    []string `json:"annotations"`
}

QueryDialect is the formatting options for the query response.

type QueryRequest

type QueryRequest struct {
	Extern  *ast.File    `json:"extern,omitempty"`
	Spec    *flux.Spec   `json:"spec,omitempty"`
	AST     *ast.Package `json:"ast,omitempty"`
	Query   string       `json:"query"`
	Type    string       `json:"type"`
	Dialect QueryDialect `json:"dialect"`

	Org *influxdb.Organization `json:"-"`
}

QueryRequest is a flux query request.

func QueryRequestFromProxyRequest

func QueryRequestFromProxyRequest(req *query.ProxyRequest) (*QueryRequest, error)

QueryRequestFromProxyRequest converts a query.ProxyRequest into a QueryRequest. The ProxyRequest must contain supported compilers and dialects otherwise an error occurs.

func (QueryRequest) ProxyRequest

func (r QueryRequest) ProxyRequest() (*query.ProxyRequest, error)

ProxyRequest returns a request to proxy from the flux.

func (QueryRequest) Validate

func (r QueryRequest) Validate() error

Validate checks the query request and returns an error if the request is invalid.

func (QueryRequest) WithDefaults

func (r QueryRequest) WithDefaults() QueryRequest

WithDefaults adds default values to the request.

type WriteService

type WriteService struct {
	Addr               string
	Token              string
	Precision          string
	InsecureSkipVerify bool
}

WriteService sends data over HTTP to influxdb via line protocol.

func (*WriteService) Write

func (s *WriteService) Write(ctx context.Context, orgID, bucketID influxdb.ID, r io.Reader) error

Jump to

Keyboard shortcuts

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