Back to godoc.org

Package http

v2.0.0 (beta.5)
Latest Go to latest
Published: Feb 13, 2020 | License: MIT | Module: github.com/mildebrandt/influxdb/v2

Index

Package Files

Constants

const (
	// Dir is prefix of the assets in the bindata
	Dir = "../../ui/build"
	// Default is the default item to load if 404
	Default = "../../ui/build/index.html"
	// DebugDefault is the default item to load if 404
	DebugDefault = "index.html"
	// DefaultContentType is the content-type to return for the Default file
	DefaultContentType = "text/html; charset=utf-8"
)
const (
	// MetricsPath exposes the prometheus metrics over /metrics.
	MetricsPath = "/metrics"
	// ReadyPath exposes the readiness of the service over /ready.
	ReadyPath = "/ready"
	// HealthPath exposes the health of the service over /health.
	HealthPath = "/health"
	// DebugPath exposes /debug/pprof for go debugging.
	DebugPath = "/debug"
)
const (
	// OrgID is the http query parameter to specify an organization by ID.
	OrgID = "orgID"
	// Org is the http query parameter that take either the ID or Name interchangeably
	Org = "org"
	// BucketID is the http query parameter to specify an bucket by ID.
	BucketID = "bucketID"
	// Bucket is the http query parameter take either the ID or Name interchangably
	Bucket = "bucket"
)
const DefaultShutdownTimeout = 20 * time.Second

DefaultShutdownTimeout is the default timeout for shutting down the http server.

const DefaultTokenFile = "credentials"

Variables

var (
	ErrAuthHeaderMissing = errors.New("authorization Header is missing")
	ErrAuthBadScheme     = errors.New("authorization Header Scheme is invalid")
)

errors

var ErrInvalidDuration = &influxdb.Error{
	Code: influxdb.EInvalid,
	Msg:  "invalid duration",
}

ErrInvalidDuration is returned when parsing a malformatted duration.

var (
	// ErrMaxBatchSizeExceeded is returned when a points batch exceeds
	// the defined upper limit in bytes. This pertains to the size of the
	// batch after inflation from any compression (i.e. ungzipped).
	ErrMaxBatchSizeExceeded = errors.New("points batch is too large")
)

func Asset

func Asset(string) ([]byte, error)

Asset returns an error stating no assets were included in the binary.

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 CheckErrorStatus

func CheckErrorStatus(code int, res *http.Response) error

CheckErrorStatus for status and any error in the response.

func DebugFlush

func DebugFlush(ctx context.Context, next http.Handler, f Flusher) http.HandlerFunc

DebugFlush clears all services for testing.

func FormatDuration

func FormatDuration(d time.Duration) string

FormatDuration formats a duration to a string.

func GetQueryResponse

func GetQueryResponse(qr *QueryRequest, addr, org, token string, headers ...string) (*http.Response, error)

GetQueryResponse runs a flux query with common parameters and returns the response from the query service.

func GetQueryResponseBody

func GetQueryResponseBody(res *http.Response) ([]byte, error)

GetQueryResponseBody reads the body of a response from some query service. It also checks for errors in the response.

func GetToken

func GetToken(r *http.Request) (string, error)

GetToken will parse the token from http Authorization Header.

func HealthHandler

func HealthHandler(w http.ResponseWriter, r *http.Request)

HealthHandler returns the status of the process.

func InactiveUserError

func InactiveUserError(ctx context.Context, h platform.HTTPErrorHandler, w http.ResponseWriter)

InactiveUserError encode a error message and status code for inactive users.

func ListenAndServe

func ListenAndServe(log *zap.Logger, addr string, handler http.Handler) error

ListenAndServe is a convenience method for opening a listener using the address and then serving the handler on that address. This method sets up the typical signal handlers.

func LoggingMW

func LoggingMW(log *zap.Logger) kithttp.Middleware

LoggingMW middleware for logging inflight http requests.

func NewBucketResponse

func NewBucketResponse(b *influxdb.Bucket, labels []*influxdb.Label) *bucketResponse

func NewClient

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

NewClient returns an http.Client that pools connections and injects a span.

func NewHTTPClient

func NewHTTPClient(addr, token string, insecureSkipVerify bool) (*httpc.Client, error)

NewHTTPClient creates a new httpc.Client type. This call sets all the options that are important to the http pkg on the httpc client. The default status fn and so forth will all be set for the caller.

func NewRouter

func NewRouter(h platform.HTTPErrorHandler) *httprouter.Router

NewRouter returns a new router with a 404 handler, a 405 handler, and a panic handler.

func NewURL

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

NewURL concats addr and path.

func ParseDuration

func ParseDuration(s string) (time.Duration, error)

ParseDuration parses a time duration from a string. This is needed instead of time.ParseDuration because this will support the full syntax that InfluxQL supports for specifying durations including weeks and days.

func ProbeAuthScheme

func ProbeAuthScheme(r *http.Request) (string, error)

ProbeAuthScheme probes the http request for the requests for token or cookie session.

func QueryHealthCheck

func QueryHealthCheck(url string, insecureSkipVerify bool) check.Response

func ReadyHandler

func ReadyHandler() http.Handler

ReadyHandler is a default readiness handler. The default behaviour is always ready.

func Redoc

func Redoc(swagger string) http.HandlerFunc

Redoc servers the swagger JSON using the redoc package.

func SetCookieSession

func SetCookieSession(key string, r *http.Request)

SetCookieSession adds a cookie for the session to an http request

func SetToken

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

SetToken adds the token to the request.

func SimpleQuery

func SimpleQuery(addr, flux, org, token string, headers ...string) ([]byte, error)

SimpleQuery runs a flux query with common parameters and returns CSV results.

func UnauthorizedError

func UnauthorizedError(ctx context.Context, h platform.HTTPErrorHandler, w http.ResponseWriter)

UnauthorizedError encodes a error message and status code for unauthorized access.

type APIBackend

type APIBackend struct {
	AssetsPath string // if empty then assets are served from bindata.
	Logger     *zap.Logger
	influxdb.HTTPErrorHandler
	SessionRenewDisabled bool
	// MaxBatchSizeBytes is the maximum number of bytes which can be written
	// in a single points batch
	MaxBatchSizeBytes int64

	// WriteParserMaxBytes specifies the maximum number of bytes that may be allocated when processing a single
	// write request. A value of zero specifies there is no limit.
	WriteParserMaxBytes int

	// WriteParserMaxLines specifies the maximum number of lines that may be parsed when processing a single
	// write request. A value of zero specifies there is no limit.
	WriteParserMaxLines int

	// WriteParserMaxValues specifies the maximum number of values that may be parsed when processing a single
	// write request. A value of zero specifies there is no limit.
	WriteParserMaxValues int

	NewBucketService func(*influxdb.Source) (influxdb.BucketService, error)
	NewQueryService  func(*influxdb.Source) (query.ProxyQueryService, error)

	WriteEventRecorder metric.EventRecorder
	QueryEventRecorder metric.EventRecorder

	PointsWriter                    storage.PointsWriter
	DeleteService                   influxdb.DeleteService
	BackupService                   influxdb.BackupService
	KVBackupService                 influxdb.KVBackupService
	AuthorizationService            influxdb.AuthorizationService
	BucketService                   influxdb.BucketService
	SessionService                  influxdb.SessionService
	UserService                     influxdb.UserService
	OrganizationService             influxdb.OrganizationService
	UserResourceMappingService      influxdb.UserResourceMappingService
	LabelService                    influxdb.LabelService
	DashboardService                influxdb.DashboardService
	DashboardOperationLogService    influxdb.DashboardOperationLogService
	BucketOperationLogService       influxdb.BucketOperationLogService
	UserOperationLogService         influxdb.UserOperationLogService
	OrganizationOperationLogService influxdb.OrganizationOperationLogService
	SourceService                   influxdb.SourceService
	VariableService                 influxdb.VariableService
	PasswordsService                influxdb.PasswordsService
	OnboardingService               influxdb.OnboardingService
	InfluxQLService                 query.ProxyQueryService
	FluxService                     query.ProxyQueryService
	TaskService                     influxdb.TaskService
	CheckService                    influxdb.CheckService
	TelegrafService                 influxdb.TelegrafConfigStore
	ScraperTargetStoreService       influxdb.ScraperTargetStoreService
	SecretService                   influxdb.SecretService
	LookupService                   influxdb.LookupService
	ChronografService               *server.Service
	OrgLookupService                authorizer.OrganizationService
	DocumentService                 influxdb.DocumentService
	NotificationRuleStore           influxdb.NotificationRuleStore
	NotificationEndpointService     influxdb.NotificationEndpointService
}

APIBackend is all services and associated parameters required to construct an APIHandler.

func (*APIBackend) PrometheusCollectors

func (b *APIBackend) PrometheusCollectors() []prometheus.Collector

PrometheusCollectors exposes the prometheus collectors associated with an APIBackend.

type APIHandler

type APIHandler struct {
	chi.Router
}

APIHandler is a collection of all the service handlers.

func NewAPIHandler

func NewAPIHandler(b *APIBackend, opts ...APIHandlerOptFn) *APIHandler

NewAPIHandler constructs all api handlers beneath it and returns an APIHandler

type APIHandlerOptFn

type APIHandlerOptFn func(chi.Router)

APIHandlerOptFn is a functional input param to set parameters on the APIHandler.

func WithResourceHandler

func WithResourceHandler(resHandler kithttp.ResourceHandler) APIHandlerOptFn

WithResourceHandler registers a resource handler on the APIHandler.

type AssetHandler

type AssetHandler struct {
	Path string
}

AssetHandler is an http handler for serving chronograf assets.

func NewAssetHandler

func NewAssetHandler() *AssetHandler

NewAssetHandler is the constructor an asset handler.

func (*AssetHandler) ServeHTTP

func (h *AssetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http handler interface for serving assets.

type AuthenticationHandler

type AuthenticationHandler struct {
	platform.HTTPErrorHandler

	AuthorizationService platform.AuthorizationService
	SessionService       platform.SessionService
	UserService          platform.UserService
	TokenParser          *jsonweb.TokenParser
	SessionRenewDisabled bool

	Handler http.Handler
	// contains filtered or unexported fields
}

AuthenticationHandler is a middleware for authenticating incoming requests.

func NewAuthenticationHandler

func NewAuthenticationHandler(log *zap.Logger, h platform.HTTPErrorHandler) *AuthenticationHandler

NewAuthenticationHandler creates an authentication handler.

func (*AuthenticationHandler) RegisterNoAuthRoute

func (h *AuthenticationHandler) RegisterNoAuthRoute(method, path string)

RegisterNoAuthRoute excludes routes from needing authentication.

func (*AuthenticationHandler) ServeHTTP

func (h *AuthenticationHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP extracts the session or token from the http request and places the resulting authorizer on the request context.

type AuthorizationBackend

type AuthorizationBackend struct {
	platform.HTTPErrorHandler

	AuthorizationService platform.AuthorizationService
	OrganizationService  platform.OrganizationService
	UserService          platform.UserService
	LookupService        platform.LookupService
	// contains filtered or unexported fields
}

AuthorizationBackend is all services and associated parameters required to construct the AuthorizationHandler.

func NewAuthorizationBackend

func NewAuthorizationBackend(log *zap.Logger, b *APIBackend) *AuthorizationBackend

NewAuthorizationBackend returns a new instance of AuthorizationBackend.

type AuthorizationHandler

type AuthorizationHandler struct {
	*httprouter.Router
	platform.HTTPErrorHandler

	OrganizationService  platform.OrganizationService
	UserService          platform.UserService
	AuthorizationService platform.AuthorizationService
	LookupService        platform.LookupService
	// contains filtered or unexported fields
}

AuthorizationHandler represents an HTTP API handler for authorizations.

func NewAuthorizationHandler

func NewAuthorizationHandler(log *zap.Logger, b *AuthorizationBackend) *AuthorizationHandler

NewAuthorizationHandler returns a new instance of AuthorizationHandler.

type AuthorizationService

type AuthorizationService struct {
	Client *httpc.Client
}

AuthorizationService connects to Influx via HTTP using tokens to manage authorizations

func (*AuthorizationService) CreateAuthorization

func (s *AuthorizationService) CreateAuthorization(ctx context.Context, a *platform.Authorization) error

CreateAuthorization creates a new authorization and sets b.ID with the new identifier.

func (*AuthorizationService) DeleteAuthorization

func (s *AuthorizationService) DeleteAuthorization(ctx context.Context, id platform.ID) error

DeleteAuthorization removes a authorization by id.

func (*AuthorizationService) FindAuthorizationByID

func (s *AuthorizationService) FindAuthorizationByID(ctx context.Context, id platform.ID) (*platform.Authorization, error)

FindAuthorizationByID finds the authorization against a remote influx server.

func (*AuthorizationService) FindAuthorizationByToken

func (s *AuthorizationService) FindAuthorizationByToken(ctx context.Context, token string) (*platform.Authorization, error)

FindAuthorizationByToken returns a single authorization by Token.

func (*AuthorizationService) FindAuthorizations

func (s *AuthorizationService) FindAuthorizations(ctx context.Context, filter platform.AuthorizationFilter, opt ...platform.FindOptions) ([]*platform.Authorization, int, error)

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

func (*AuthorizationService) UpdateAuthorization

func (s *AuthorizationService) UpdateAuthorization(ctx context.Context, id platform.ID, upd *platform.AuthorizationUpdate) (*platform.Authorization, error)

UpdateAuthorization updates the status and description if available.

type AuthzError

type AuthzError interface {
	error
	AuthzError() error
}

AuthzError is returned for authorization errors. When this error type is returned, the user can be presented with a generic "authorization failed" error, but the system can log the underlying AuthzError() so that operators have insight into what actually failed with authorization.

type BackupBackend

type BackupBackend struct {
	Logger *zap.Logger
	influxdb.HTTPErrorHandler

	BackupService   influxdb.BackupService
	KVBackupService influxdb.KVBackupService
}

BackupBackend is all services and associated parameters required to construct the BackupHandler.

func NewBackupBackend

func NewBackupBackend(b *APIBackend) *BackupBackend

NewBackupBackend returns a new instance of BackupBackend.

type BackupHandler

type BackupHandler struct {
	*httprouter.Router
	influxdb.HTTPErrorHandler
	Logger *zap.Logger

	BackupService   influxdb.BackupService
	KVBackupService influxdb.KVBackupService
}

func NewBackupHandler

func NewBackupHandler(b *BackupBackend) *BackupHandler

NewBackupHandler creates a new handler at /api/v2/backup to receive backup requests.

type BackupService

type BackupService struct {
	Addr               string
	Token              string
	InsecureSkipVerify bool
}

BackupService is the client implementation of influxdb.BackupService.

func (*BackupService) CreateBackup

func (s *BackupService) CreateBackup(ctx context.Context) (int, []string, error)

func (*BackupService) FetchBackupFile

func (s *BackupService) FetchBackupFile(ctx context.Context, backupID int, backupFile string, w io.Writer) error

func (*BackupService) InternalBackupPath

func (s *BackupService) InternalBackupPath(backupID int) string

type BucketBackend

type BucketBackend struct {
	influxdb.HTTPErrorHandler

	BucketService              influxdb.BucketService
	BucketOperationLogService  influxdb.BucketOperationLogService
	UserResourceMappingService influxdb.UserResourceMappingService
	LabelService               influxdb.LabelService
	UserService                influxdb.UserService
	OrganizationService        influxdb.OrganizationService
	// contains filtered or unexported fields
}

BucketBackend is all services and associated parameters required to construct the BucketHandler.

func NewBucketBackend

func NewBucketBackend(log *zap.Logger, b *APIBackend) *BucketBackend

NewBucketBackend returns a new instance of BucketBackend.

type BucketHandler

type BucketHandler struct {
	*httprouter.Router

	BucketService              influxdb.BucketService
	BucketOperationLogService  influxdb.BucketOperationLogService
	UserResourceMappingService influxdb.UserResourceMappingService
	LabelService               influxdb.LabelService
	UserService                influxdb.UserService
	OrganizationService        influxdb.OrganizationService
	// contains filtered or unexported fields
}

BucketHandler represents an HTTP API handler for buckets.

func NewBucketHandler

func NewBucketHandler(log *zap.Logger, b *BucketBackend) *BucketHandler

NewBucketHandler returns a new instance of BucketHandler.

type BucketService

type BucketService struct {
	Client *httpc.Client
	// 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) CreateBucket

func (s *BucketService) CreateBucket(ctx context.Context, b *influxdb.Bucket) error

CreateBucket creates a new bucket and sets b.ID with the new identifier.

func (*BucketService) DeleteBucket

func (s *BucketService) DeleteBucket(ctx context.Context, id influxdb.ID) error

DeleteBucket removes a bucket by ID.

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) FindBucketByID

func (s *BucketService) FindBucketByID(ctx context.Context, id influxdb.ID) (*influxdb.Bucket, error)

FindBucketByID returns a single bucket by ID.

func (*BucketService) FindBucketByName

func (s *BucketService) FindBucketByName(ctx context.Context, orgID influxdb.ID, name string) (*influxdb.Bucket, error)

FindBucketByName returns a single bucket by name

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.

func (*BucketService) UpdateBucket

func (s *BucketService) UpdateBucket(ctx context.Context, id influxdb.ID, upd influxdb.BucketUpdate) (*influxdb.Bucket, error)

UpdateBucket updates a single bucket with changeset. Returns the new bucket state after update.

type CheckBackend

type CheckBackend struct {
	influxdb.HTTPErrorHandler

	TaskService                influxdb.TaskService
	CheckService               influxdb.CheckService
	UserResourceMappingService influxdb.UserResourceMappingService
	LabelService               influxdb.LabelService
	UserService                influxdb.UserService
	OrganizationService        influxdb.OrganizationService
	// contains filtered or unexported fields
}

CheckBackend is all services and associated parameters required to construct the CheckBackendHandler.

func NewCheckBackend

func NewCheckBackend(log *zap.Logger, b *APIBackend) *CheckBackend

NewCheckBackend returns a new instance of CheckBackend.

type CheckHandler

type CheckHandler struct {
	*httprouter.Router
	influxdb.HTTPErrorHandler

	TaskService                influxdb.TaskService
	CheckService               influxdb.CheckService
	UserResourceMappingService influxdb.UserResourceMappingService
	LabelService               influxdb.LabelService
	UserService                influxdb.UserService
	OrganizationService        influxdb.OrganizationService
	// contains filtered or unexported fields
}

CheckHandler is the handler for the check service

func NewCheckHandler

func NewCheckHandler(log *zap.Logger, b *CheckBackend) *CheckHandler

NewCheckHandler returns a new instance of CheckHandler.

type ChronografHandler

type ChronografHandler struct {
	*httprouter.Router
	Service *server.Service
}

ChronografHandler is an http handler for serving chronograf chronografs.

func NewChronografHandler

func NewChronografHandler(s *server.Service, he influxdb.HTTPErrorHandler) *ChronografHandler

NewChronografHandler is the constructor an chronograf handler.

type DashboardBackend

type DashboardBackend struct {
	platform.HTTPErrorHandler

	DashboardService             platform.DashboardService
	DashboardOperationLogService platform.DashboardOperationLogService
	UserResourceMappingService   platform.UserResourceMappingService
	LabelService                 platform.LabelService
	UserService                  platform.UserService
	// contains filtered or unexported fields
}

DashboardBackend is all services and associated parameters required to construct the DashboardHandler.

func NewDashboardBackend

func NewDashboardBackend(log *zap.Logger, b *APIBackend) *DashboardBackend

NewDashboardBackend creates a backend used by the dashboard handler.

type DashboardHandler

type DashboardHandler struct {
	*httprouter.Router

	platform.HTTPErrorHandler

	DashboardService             platform.DashboardService
	DashboardOperationLogService platform.DashboardOperationLogService
	UserResourceMappingService   platform.UserResourceMappingService
	LabelService                 platform.LabelService
	UserService                  platform.UserService
	// contains filtered or unexported fields
}

DashboardHandler is the handler for the dashboard service

func NewDashboardHandler

func NewDashboardHandler(log *zap.Logger, b *DashboardBackend) *DashboardHandler

NewDashboardHandler returns a new instance of DashboardHandler.

type DashboardService

type DashboardService struct {
	Client *httpc.Client
}

DashboardService is a dashboard service over HTTP to the influxdb server.

func (*DashboardService) AddDashboardCell

func (s *DashboardService) AddDashboardCell(ctx context.Context, id platform.ID, c *platform.Cell, opts platform.AddDashboardCellOptions) error

AddDashboardCell adds a cell to a dashboard.

func (*DashboardService) CreateDashboard

func (s *DashboardService) CreateDashboard(ctx context.Context, d *platform.Dashboard) error

CreateDashboard creates a new dashboard and sets b.ID with the new identifier.

func (*DashboardService) DeleteDashboard

func (s *DashboardService) DeleteDashboard(ctx context.Context, id platform.ID) error

DeleteDashboard removes a dashboard by ID.

func (*DashboardService) FindDashboardByID

func (s *DashboardService) FindDashboardByID(ctx context.Context, id platform.ID) (*platform.Dashboard, error)

FindDashboardByID returns a single dashboard by ID.

func (*DashboardService) FindDashboards

func (s *DashboardService) FindDashboards(ctx context.Context, filter platform.DashboardFilter, opts platform.FindOptions) ([]*platform.Dashboard, int, error)

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

func (*DashboardService) GetDashboardCellView

func (s *DashboardService) GetDashboardCellView(ctx context.Context, dashboardID, cellID platform.ID) (*platform.View, error)

GetDashboardCellView retrieves the view for a dashboard cell.

func (*DashboardService) RemoveDashboardCell

func (s *DashboardService) RemoveDashboardCell(ctx context.Context, dashboardID, cellID platform.ID) error

RemoveDashboardCell removes a dashboard.

func (*DashboardService) ReplaceDashboardCells

func (s *DashboardService) ReplaceDashboardCells(ctx context.Context, id platform.ID, cs []*platform.Cell) error

ReplaceDashboardCells replaces all cells in a dashboard

func (*DashboardService) UpdateDashboard

func (s *DashboardService) UpdateDashboard(ctx context.Context, id platform.ID, upd platform.DashboardUpdate) (*platform.Dashboard, error)

UpdateDashboard updates a single dashboard with changeset. Returns the new dashboard state after update.

func (*DashboardService) UpdateDashboardCell

func (s *DashboardService) UpdateDashboardCell(ctx context.Context, dashboardID, cellID platform.ID, upd platform.CellUpdate) (*platform.Cell, error)

UpdateDashboardCell replaces the dashboard cell with the provided ID.

func (*DashboardService) UpdateDashboardCellView

func (s *DashboardService) UpdateDashboardCellView(ctx context.Context, dashboardID, cellID platform.ID, upd platform.ViewUpdate) (*platform.View, error)

UpdateDashboardCellView updates the view for a dashboard cell.

type DeleteBackend

type DeleteBackend struct {
	influxdb.HTTPErrorHandler

	DeleteService       influxdb.DeleteService
	BucketService       influxdb.BucketService
	OrganizationService influxdb.OrganizationService
	// contains filtered or unexported fields
}

DeleteBackend is all services and associated parameters required to construct the DeleteHandler.

func NewDeleteBackend

func NewDeleteBackend(log *zap.Logger, b *APIBackend) *DeleteBackend

NewDeleteBackend returns a new instance of DeleteBackend

type DeleteHandler

type DeleteHandler struct {
	influxdb.HTTPErrorHandler
	*httprouter.Router

	DeleteService       influxdb.DeleteService
	BucketService       influxdb.BucketService
	OrganizationService influxdb.OrganizationService
	// contains filtered or unexported fields
}

DeleteHandler receives a delete request with a predicate and sends it to storage.

func NewDeleteHandler

func NewDeleteHandler(log *zap.Logger, b *DeleteBackend) *DeleteHandler

NewDeleteHandler creates a new handler at /api/v2/delete to recieve delete requests.

type DeleteRequest

type DeleteRequest struct {
	OrgID     string `json:"-"`
	Org       string `json:"-"` // org name
	BucketID  string `json:"-"`
	Bucket    string `json:"-"`
	Start     string `json:"start"`
	Stop      string `json:"stop"`
	Predicate string `json:"predicate"`
}

DeleteRequest is the request send over http to delete points.

type DeleteService

type DeleteService struct {
	Addr               string
	Token              string
	InsecureSkipVerify bool
}

DeleteService sends data over HTTP to delete points.

func (*DeleteService) DeleteBucketRangePredicate

func (s *DeleteService) DeleteBucketRangePredicate(ctx context.Context, dr DeleteRequest) error

DeleteBucketRangePredicate send delete request over http to delete points.

type DocumentBackend

type DocumentBackend struct {
	influxdb.HTTPErrorHandler

	DocumentService influxdb.DocumentService
	LabelService    influxdb.LabelService
	// contains filtered or unexported fields
}

DocumentBackend is all services and associated parameters required to construct the DocumentHandler.

func NewDocumentBackend

func NewDocumentBackend(log *zap.Logger, b *APIBackend) *DocumentBackend

NewDocumentBackend returns a new instance of DocumentBackend.

type DocumentHandler

type DocumentHandler struct {
	*httprouter.Router

	influxdb.HTTPErrorHandler

	DocumentService influxdb.DocumentService
	LabelService    influxdb.LabelService
	// contains filtered or unexported fields
}

DocumentHandler represents an HTTP API handler for documents.

func NewDocumentHandler

func NewDocumentHandler(b *DocumentBackend) *DocumentHandler

NewDocumentHandler returns a new instance of DocumentHandler. TODO(desa): this should probably take a namespace

type Flusher

type Flusher interface {
	Flush(ctx context.Context)
}

Flusher flushes data from a store to reset; used for testing.

type FluxBackend

type FluxBackend struct {
	influxdb.HTTPErrorHandler

	QueryEventRecorder metric.EventRecorder

	OrganizationService influxdb.OrganizationService
	ProxyQueryService   query.ProxyQueryService
	// contains filtered or unexported fields
}

FluxBackend is all services and associated parameters required to construct the FluxHandler.

func NewFluxBackend

func NewFluxBackend(log *zap.Logger, b *APIBackend) *FluxBackend

NewFluxBackend returns a new instance of FluxBackend.

type FluxHandler

type FluxHandler struct {
	*httprouter.Router
	influxdb.HTTPErrorHandler

	Now                 func() time.Time
	OrganizationService influxdb.OrganizationService
	ProxyQueryService   query.ProxyQueryService

	EventRecorder metric.EventRecorder
	// contains filtered or unexported fields
}

FluxHandler implements handling flux queries.

func NewFluxHandler

func NewFluxHandler(log *zap.Logger, b *FluxBackend) *FluxHandler

NewFluxHandler returns a new handler at /api/v2/query for flux queries.

func (*FluxHandler) Prefix

func (*FluxHandler) Prefix() string

Prefix provides the route prefix.

func (*FluxHandler) PrometheusCollectors

func (h *FluxHandler) PrometheusCollectors() []prom.Collector

PrometheusCollectors satisifies the prom.PrometheusCollector interface.

type FluxQueryService

type FluxQueryService struct {
	Addr               string
	Token              string
	Name               string
	InsecureSkipVerify bool
}

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

func (FluxQueryService) Check

func (s FluxQueryService) Check(ctx context.Context) check.Response

func (*FluxQueryService) Query

func (s *FluxQueryService) Query(ctx context.Context, r *query.Request) (flux.ResultIterator, error)

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

type FluxService

type FluxService struct {
	Addr               string
	Token              string
	Name               string
	InsecureSkipVerify bool
}

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

func (FluxService) Check

func (s FluxService) Check(ctx context.Context) check.Response

func (*FluxService) Query

func (s *FluxService) Query(ctx context.Context, w io.Writer, r *query.ProxyRequest) (flux.Statistics, error)

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 HTTPDialect

type HTTPDialect interface {
	SetHeaders(w http.ResponseWriter)
}

HTTPDialect is an encoding dialect that can write metadata to HTTP headers

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler provides basic handling of metrics, health and debug endpoints. All other requests are passed down to the sub handler.

func NewHandlerFromRegistry

func NewHandlerFromRegistry(name string, reg *prom.Registry, opts ...HandlerOptFn) *Handler

NewHandlerFromRegistry creates a new handler with the given name, and sets the /metrics endpoint to use the metrics from the given registry, after self-registering h's metrics.

func (*Handler) PrometheusCollectors

func (h *Handler) PrometheusCollectors() []prometheus.Collector

PrometheusCollectors satisifies prom.PrometheusCollector.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP delegates a request to the appropriate subhandler.

type HandlerOptFn

type HandlerOptFn func(opts *handlerOpts)

func WithAPIHandler

func WithAPIHandler(h http.Handler) HandlerOptFn

func WithDebugHandler

func WithDebugHandler(h http.Handler) HandlerOptFn

func WithHealthHandler

func WithHealthHandler(h http.Handler) HandlerOptFn

func WithLog

func WithLog(l *zap.Logger) HandlerOptFn

func WithMetricsHandler

func WithMetricsHandler(h http.Handler) HandlerOptFn

func WithReadyHandler

func WithReadyHandler(h http.Handler) HandlerOptFn

type LabelBackend

type LabelBackend struct {
	influxdb.HTTPErrorHandler
	LabelService influxdb.LabelService
	ResourceType influxdb.ResourceType
	// contains filtered or unexported fields
}

LabelBackend is all services and associated parameters required to construct label handlers.

type LabelHandler

type LabelHandler struct {
	*httprouter.Router
	influxdb.HTTPErrorHandler

	LabelService influxdb.LabelService
	// contains filtered or unexported fields
}

LabelHandler represents an HTTP API handler for labels

func NewLabelHandler

func NewLabelHandler(log *zap.Logger, s influxdb.LabelService, he influxdb.HTTPErrorHandler) *LabelHandler

NewLabelHandler returns a new instance of LabelHandler

type LabelService

type LabelService struct {
	Client   *httpc.Client
	OpPrefix string
}

LabelService connects to Influx via HTTP using tokens to manage labels

func (*LabelService) CreateLabel

func (s *LabelService) CreateLabel(ctx context.Context, l *influxdb.Label) error

CreateLabel creates a new label.

func (*LabelService) CreateLabelMapping

func (s *LabelService) CreateLabelMapping(ctx context.Context, m *influxdb.LabelMapping) error

CreateLabelMapping will create a labbel mapping

func (*LabelService) DeleteLabel

func (s *LabelService) DeleteLabel(ctx context.Context, id influxdb.ID) error

DeleteLabel removes a label by ID.

func (*LabelService) DeleteLabelMapping

func (s *LabelService) DeleteLabelMapping(ctx context.Context, m *influxdb.LabelMapping) error

func (*LabelService) FindLabelByID

func (s *LabelService) FindLabelByID(ctx context.Context, id influxdb.ID) (*influxdb.Label, error)

FindLabelByID returns a single label by ID.

func (*LabelService) FindLabels

func (s *LabelService) FindLabels(ctx context.Context, filter influxdb.LabelFilter, opt ...influxdb.FindOptions) ([]*influxdb.Label, error)

FindLabels is a client for the find labels response from the server.

func (*LabelService) FindResourceLabels

func (s *LabelService) FindResourceLabels(ctx context.Context, filter influxdb.LabelMappingFilter) ([]*influxdb.Label, error)

FindResourceLabels returns a list of labels, derived from a label mapping filter.

func (*LabelService) UpdateLabel

func (s *LabelService) UpdateLabel(ctx context.Context, id influxdb.ID, upd influxdb.LabelUpdate) (*influxdb.Label, error)

UpdateLabel updates a label and returns the updated label.

type MemberBackend

type MemberBackend struct {
	influxdb.HTTPErrorHandler

	ResourceType influxdb.ResourceType
	UserType     influxdb.UserType

	UserResourceMappingService influxdb.UserResourceMappingService
	UserService                influxdb.UserService
	// contains filtered or unexported fields
}

MemberBackend is all services and associated parameters required to construct member handler.

type NotificationEndpointBackend

type NotificationEndpointBackend struct {
	influxdb.HTTPErrorHandler

	NotificationEndpointService influxdb.NotificationEndpointService
	UserResourceMappingService  influxdb.UserResourceMappingService
	LabelService                influxdb.LabelService
	UserService                 influxdb.UserService
	OrganizationService         influxdb.OrganizationService
	// contains filtered or unexported fields
}

NotificationEndpointBackend is all services and associated parameters required to construct the NotificationEndpointBackendHandler.

func NewNotificationEndpointBackend

func NewNotificationEndpointBackend(log *zap.Logger, b *APIBackend) *NotificationEndpointBackend

NewNotificationEndpointBackend returns a new instance of NotificationEndpointBackend.

func (*NotificationEndpointBackend) Logger

func (b *NotificationEndpointBackend) Logger() *zap.Logger

type NotificationEndpointHandler

type NotificationEndpointHandler struct {
	*httprouter.Router
	influxdb.HTTPErrorHandler

	NotificationEndpointService influxdb.NotificationEndpointService
	UserResourceMappingService  influxdb.UserResourceMappingService
	LabelService                influxdb.LabelService
	UserService                 influxdb.UserService
	OrganizationService         influxdb.OrganizationService
	// contains filtered or unexported fields
}

NotificationEndpointHandler is the handler for the notificationEndpoint service

func NewNotificationEndpointHandler

func NewNotificationEndpointHandler(log *zap.Logger, b *NotificationEndpointBackend) *NotificationEndpointHandler

NewNotificationEndpointHandler returns a new instance of NotificationEndpointHandler.

type NotificationEndpointService

type NotificationEndpointService struct {
	Client *httpc.Client
	*UserResourceMappingService
	*OrganizationService
}

NotificationEndpointService is an http client for the influxdb.NotificationEndpointService server implementation.

func NewNotificationEndpointService

func NewNotificationEndpointService(client *httpc.Client) *NotificationEndpointService

NewNotificationEndpointService constructs a new http NotificationEndpointService.

func (*NotificationEndpointService) CreateNotificationEndpoint

func (s *NotificationEndpointService) CreateNotificationEndpoint(ctx context.Context, ne influxdb.NotificationEndpoint, userID influxdb.ID) error

CreateNotificationEndpoint creates a new notification endpoint and sets b.ID with the new identifier. TODO(@jsteenb2): this is unsatisfactory, we have no way of grabbing the new notification endpoint without

serious hacky hackertoning. Put it on the list...

func (*NotificationEndpointService) DeleteNotificationEndpoint

func (s *NotificationEndpointService) DeleteNotificationEndpoint(ctx context.Context, id influxdb.ID) ([]influxdb.SecretField, influxdb.ID, error)

DeleteNotificationEndpoint removes a notification endpoint by ID, returns secret fields, orgID for further deletion. TODO: axe this delete design, makes little sense in how its currently being done. Right now, as an http client,

I am forced to know how the store handles this and then figure out what the server does in between me and that store,
then see what falls out :flushed... for now returning nothing for secrets, orgID, and only returning an error. This makes
the code/design smell super obvious imo

func (*NotificationEndpointService) FindNotificationEndpointByID

func (s *NotificationEndpointService) FindNotificationEndpointByID(ctx context.Context, id influxdb.ID) (influxdb.NotificationEndpoint, error)

FindNotificationEndpointByID returns a single notification endpoint by ID.

func (*NotificationEndpointService) FindNotificationEndpoints

func (s *NotificationEndpointService) FindNotificationEndpoints(ctx context.Context, filter influxdb.NotificationEndpointFilter, opt ...influxdb.FindOptions) ([]influxdb.NotificationEndpoint, int, error)

FindNotificationEndpoints returns a list of notification endpoints that match filter and the total count of matching notification endpoints. Additional options provide pagination & sorting.

func (*NotificationEndpointService) PatchNotificationEndpoint

func (s *NotificationEndpointService) PatchNotificationEndpoint(ctx context.Context, id influxdb.ID, upd influxdb.NotificationEndpointUpdate) (influxdb.NotificationEndpoint, error)

PatchNotificationEndpoint updates a single notification endpoint with changeset. Returns the new notification endpoint state after update.

func (*NotificationEndpointService) UpdateNotificationEndpoint

func (s *NotificationEndpointService) UpdateNotificationEndpoint(ctx context.Context, id influxdb.ID, ne influxdb.NotificationEndpoint, userID influxdb.ID) (influxdb.NotificationEndpoint, error)

UpdateNotificationEndpoint updates a single notification endpoint. Returns the new notification endpoint after update.

type NotificationRuleBackend

type NotificationRuleBackend struct {
	influxdb.HTTPErrorHandler

	NotificationRuleStore       influxdb.NotificationRuleStore
	NotificationEndpointService influxdb.NotificationEndpointService
	UserResourceMappingService  influxdb.UserResourceMappingService
	LabelService                influxdb.LabelService
	UserService                 influxdb.UserService
	OrganizationService         influxdb.OrganizationService
	TaskService                 influxdb.TaskService
	// contains filtered or unexported fields
}

NotificationRuleBackend is all services and associated parameters required to construct the NotificationRuleBackendHandler.

func NewNotificationRuleBackend

func NewNotificationRuleBackend(log *zap.Logger, b *APIBackend) *NotificationRuleBackend

NewNotificationRuleBackend returns a new instance of NotificationRuleBackend.

type NotificationRuleHandler

type NotificationRuleHandler struct {
	*httprouter.Router
	influxdb.HTTPErrorHandler

	NotificationRuleStore       influxdb.NotificationRuleStore
	NotificationEndpointService influxdb.NotificationEndpointService
	UserResourceMappingService  influxdb.UserResourceMappingService
	LabelService                influxdb.LabelService
	UserService                 influxdb.UserService
	OrganizationService         influxdb.OrganizationService
	TaskService                 influxdb.TaskService
	// contains filtered or unexported fields
}

NotificationRuleHandler is the handler for the notification rule service

func NewNotificationRuleHandler

func NewNotificationRuleHandler(log *zap.Logger, b *NotificationRuleBackend) *NotificationRuleHandler

NewNotificationRuleHandler returns a new instance of NotificationRuleHandler.

type OrgBackend

type OrgBackend struct {
	influxdb.HTTPErrorHandler

	OrganizationService             influxdb.OrganizationService
	OrganizationOperationLogService influxdb.OrganizationOperationLogService
	UserResourceMappingService      influxdb.UserResourceMappingService
	SecretService                   influxdb.SecretService
	LabelService                    influxdb.LabelService
	UserService                     influxdb.UserService
	// contains filtered or unexported fields
}

OrgBackend is all services and associated parameters required to construct the OrgHandler.

func NewOrgBackend

func NewOrgBackend(log *zap.Logger, b *APIBackend) *OrgBackend

NewOrgBackend is a datasource used by the org handler.

type OrgHandler

type OrgHandler struct {
	*httprouter.Router
	*kithttp.API

	OrgSVC                          influxdb.OrganizationService
	OrganizationOperationLogService influxdb.OrganizationOperationLogService
	UserResourceMappingService      influxdb.UserResourceMappingService
	SecretService                   influxdb.SecretService
	LabelService                    influxdb.LabelService
	UserService                     influxdb.UserService
	// contains filtered or unexported fields
}

OrgHandler represents an HTTP API handler for orgs.

func NewOrgHandler

func NewOrgHandler(log *zap.Logger, b *OrgBackend) *OrgHandler

NewOrgHandler returns a new instance of OrgHandler.

type OrganizationService

type OrganizationService struct {
	Client *httpc.Client
	// OpPrefix is for not found errors.
	OpPrefix string
}

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

func (*OrganizationService) CreateOrganization

func (s *OrganizationService) CreateOrganization(ctx context.Context, o *influxdb.Organization) error

CreateOrganization creates an organization.

func (*OrganizationService) DeleteOrganization

func (s *OrganizationService) DeleteOrganization(ctx context.Context, id influxdb.ID) error

DeleteOrganization removes organization id over HTTP.

func (*OrganizationService) FindOrganization

func (s *OrganizationService) FindOrganization(ctx context.Context, filter influxdb.OrganizationFilter) (*influxdb.Organization, error)

FindOrganization gets a single organization matching the filter using HTTP.

func (*OrganizationService) FindOrganizationByID

func (s *OrganizationService) FindOrganizationByID(ctx context.Context, id influxdb.ID) (*influxdb.Organization, error)

FindOrganizationByID gets a single organization with a given id using HTTP.

func (*OrganizationService) FindOrganizations

func (s *OrganizationService) FindOrganizations(ctx context.Context, filter influxdb.OrganizationFilter, opt ...influxdb.FindOptions) ([]*influxdb.Organization, int, error)

FindOrganizations returns all organizations that match the filter via HTTP.

func (*OrganizationService) UpdateOrganization

func (s *OrganizationService) UpdateOrganization(ctx context.Context, id influxdb.ID, upd influxdb.OrganizationUpdate) (*influxdb.Organization, error)

UpdateOrganization updates the organization over HTTP.

type PasswordService

type PasswordService struct {
	Client *httpc.Client
}

PasswordService is an http client to speak to the password service.

func (*PasswordService) CompareAndSetPassword

func (s *PasswordService) CompareAndSetPassword(ctx context.Context, userID influxdb.ID, old string, new string) error

CompareAndSetPassword compares the old and new password and submits the new password if possoble. Note: is not implemented.

func (*PasswordService) ComparePassword

func (s *PasswordService) ComparePassword(ctx context.Context, userID influxdb.ID, password string) error

ComparePassword compares the user new password with existing. Note: is not implemented.

func (*PasswordService) SetPassword

func (s *PasswordService) SetPassword(ctx context.Context, userID influxdb.ID, password string) error

SetPassword sets the user's password.

type PlatformHandler

type PlatformHandler struct {
	AssetHandler *AssetHandler
	DocsHandler  http.HandlerFunc
	APIHandler   http.Handler
}

PlatformHandler is a collection of all the service handlers.

func NewPlatformHandler

func NewPlatformHandler(b *APIBackend, opts ...APIHandlerOptFn) *PlatformHandler

NewPlatformHandler returns a platform handler that serves the API and associated assets.

func (*PlatformHandler) ServeHTTP

func (h *PlatformHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP delegates a request to the appropriate subhandler.

type QueryAnalysis

type QueryAnalysis struct {
	Errors []queryParseError `json:"errors"`
}

QueryAnalysis is a structured response of errors.

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 {
	Type  string `json:"type"`
	Query string `json:"query"`

	// Flux fields
	Extern  *ast.File    `json:"extern,omitempty"`
	Spec    *flux.Spec   `json:"spec,omitempty"`
	AST     *ast.Package `json:"ast,omitempty"`
	Dialect QueryDialect `json:"dialect"`

	// InfluxQL fields
	Bucket string `json:"bucket,omitempty"`

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

	// PreferNoContent specifies if the Response to this request should
	// contain any result. This is done for avoiding unnecessary
	// bandwidth consumption in certain cases. For example, when the
	// query produces side effects and the results do not matter. E.g.:
	// 	from(...) |> ... |> to()
	// For example, tasks do not use the results of queries, but only
	// care about their side effects.
	// To obtain a QueryRequest with no result, add the header
	// `Prefer: return-no-content` to the HTTP request.
	PreferNoContent bool
	// PreferNoContentWithError is the same as above, but it forces the
	// Response to contain an error if that is a Flux runtime error encoded
	// in the response body.
	// To obtain a QueryRequest with no result but runtime errors,
	// add the header `Prefer: return-no-content-with-error` to the HTTP request.
	PreferNoContentWithError bool
}

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) Analyze

func (r QueryRequest) Analyze() (*QueryAnalysis, error)

Analyze attempts to parse the query request and returns any errors encountered in a structured way.

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 ScraperBackend

type ScraperBackend struct {
	influxdb.HTTPErrorHandler

	ScraperStorageService      influxdb.ScraperTargetStoreService
	BucketService              influxdb.BucketService
	OrganizationService        influxdb.OrganizationService
	UserService                influxdb.UserService
	UserResourceMappingService influxdb.UserResourceMappingService
	LabelService               influxdb.LabelService
	// contains filtered or unexported fields
}

ScraperBackend is all services and associated parameters required to construct the ScraperHandler.

func NewScraperBackend

func NewScraperBackend(log *zap.Logger, b *APIBackend) *ScraperBackend

NewScraperBackend returns a new instance of ScraperBackend.

type ScraperHandler

type ScraperHandler struct {
	*httprouter.Router
	influxdb.HTTPErrorHandler

	UserService                influxdb.UserService
	UserResourceMappingService influxdb.UserResourceMappingService
	LabelService               influxdb.LabelService
	ScraperStorageService      influxdb.ScraperTargetStoreService
	BucketService              influxdb.BucketService
	OrganizationService        influxdb.OrganizationService
	// contains filtered or unexported fields
}

ScraperHandler represents an HTTP API handler for scraper targets.

func NewScraperHandler

func NewScraperHandler(log *zap.Logger, b *ScraperBackend) *ScraperHandler

NewScraperHandler returns a new instance of ScraperHandler.

type ScraperService

type ScraperService struct {
	Addr               string
	Token              string
	InsecureSkipVerify bool
	// OpPrefix is for update invalid ops
	OpPrefix string
}

ScraperService connects to Influx via HTTP using tokens to manage scraper targets.

func (*ScraperService) AddTarget

func (s *ScraperService) AddTarget(ctx context.Context, target *influxdb.ScraperTarget, userID influxdb.ID) error

AddTarget creates a new scraper target and sets target.ID with the new identifier.

func (*ScraperService) GetTargetByID

func (s *ScraperService) GetTargetByID(ctx context.Context, id influxdb.ID) (*influxdb.ScraperTarget, error)

GetTargetByID returns a single target by ID.

func (*ScraperService) ListTargets

func (s *ScraperService) ListTargets(ctx context.Context, filter influxdb.ScraperTargetFilter) ([]influxdb.ScraperTarget, error)

ListTargets returns a list of all scraper targets.

func (*ScraperService) RemoveTarget

func (s *ScraperService) RemoveTarget(ctx context.Context, id influxdb.ID) error

RemoveTarget removes a scraper target by ID.

func (*ScraperService) UpdateTarget

func (s *ScraperService) UpdateTarget(ctx context.Context, update *influxdb.ScraperTarget, userID influxdb.ID) (*influxdb.ScraperTarget, error)

UpdateTarget updates a single scraper target with changeset. Returns the new target state after update.

type SecretService

type SecretService struct {
	Client *httpc.Client
}

SecretService connects to Influx via HTTP using tokens to manage secrets.

func (*SecretService) DeleteSecret

func (s *SecretService) DeleteSecret(ctx context.Context, orgID influxdb.ID, ks ...string) error

DeleteSecret removes a single secret via HTTP.

func (*SecretService) GetSecretKeys

func (s *SecretService) GetSecretKeys(ctx context.Context, orgID influxdb.ID) ([]string, error)

GetSecretKeys get all secret keys mathing an org ID via HTTP.

func (*SecretService) LoadSecret

func (s *SecretService) LoadSecret(ctx context.Context, orgID influxdb.ID, k string) (string, error)

LoadSecret is not implemented for http

func (*SecretService) PatchSecrets

func (s *SecretService) PatchSecrets(ctx context.Context, orgID influxdb.ID, m map[string]string) error

PatchSecrets will update the existing secret with new via http.

func (*SecretService) PutSecret

func (s *SecretService) PutSecret(ctx context.Context, orgID influxdb.ID, k string, v string) error

PutSecret is not implemented for http.

func (*SecretService) PutSecrets

func (s *SecretService) PutSecrets(ctx context.Context, orgID influxdb.ID, m map[string]string) error

PutSecrets is not implemented for http.

type Server

type Server struct {
	ShutdownTimeout time.Duration
	// contains filtered or unexported fields
}

Server is an abstraction around the http.Server that handles a server process. It manages the full lifecycle of a server by serving a handler on a socket. If signals have been registered, it will attempt to terminate the server using Shutdown if a signal is received and will force a shutdown if a second signal is received.

func NewServer

func NewServer(log *zap.Logger, handler http.Handler) *Server

NewServer returns a new server struct that can be used.

func (*Server) ListenForSignals

func (s *Server) ListenForSignals(signals ...os.Signal)

ListenForSignals registers the the server to listen for the given signals to shutdown the server. The signals are not captured until Serve is called.

func (*Server) Serve

func (s *Server) Serve(listener net.Listener) error

Serve will run the server using the listener to accept connections.

type Service

type Service struct {
	Addr               string
	Token              string
	InsecureSkipVerify bool

	*AuthorizationService
	*BackupService
	*BucketService
	*DashboardService
	*OrganizationService
	*UserService
	*VariableService
	*WriteService
}

Service connects to an InfluxDB via HTTP.

func NewService

func NewService(addr, token string) (*Service, error)

NewService returns a service that is an HTTP client to a remote

type SessionBackend

type SessionBackend struct {
	platform.HTTPErrorHandler

	PasswordsService platform.PasswordsService
	SessionService   platform.SessionService
	UserService      platform.UserService
	// contains filtered or unexported fields
}

SessionBackend is all services and associated parameters required to construct the SessionHandler.

type SessionHandler

type SessionHandler struct {
	*httprouter.Router
	platform.HTTPErrorHandler

	PasswordsService platform.PasswordsService
	SessionService   platform.SessionService
	UserService      platform.UserService
	// contains filtered or unexported fields
}

SessionHandler represents an HTTP API handler for authorizations.

func NewSessionHandler

func NewSessionHandler(log *zap.Logger, b *SessionBackend) *SessionHandler

NewSessionHandler returns a new instance of SessionHandler.

type SetupBackend

type SetupBackend struct {
	platform.HTTPErrorHandler

	OnboardingService platform.OnboardingService
	// contains filtered or unexported fields
}

SetupBackend is all services and associated parameters required to construct the SetupHandler.

func NewSetupBackend

func NewSetupBackend(log *zap.Logger, b *APIBackend) *SetupBackend

NewSetupBackend returns a new instance of SetupBackend.

type SetupHandler

type SetupHandler struct {
	*httprouter.Router
	platform.HTTPErrorHandler

	OnboardingService platform.OnboardingService
	// contains filtered or unexported fields
}

SetupHandler represents an HTTP API handler for onboarding setup.

func NewSetupHandler

func NewSetupHandler(log *zap.Logger, b *SetupBackend) *SetupHandler

NewSetupHandler returns a new instance of SetupHandler.

type SetupService

type SetupService struct {
	Addr               string
	InsecureSkipVerify bool
}

SetupService connects to Influx via HTTP to perform onboarding operations

func (*SetupService) Generate

func (s *SetupService) Generate(ctx context.Context, or *platform.OnboardingRequest) (*platform.OnboardingResults, error)

Generate OnboardingResults.

func (*SetupService) IsOnboarding

func (s *SetupService) IsOnboarding(ctx context.Context) (bool, error)

IsOnboarding determine if onboarding request is allowed.

type SourceBackend

type SourceBackend struct {
	platform.HTTPErrorHandler

	SourceService   platform.SourceService
	LabelService    platform.LabelService
	BucketService   platform.BucketService
	NewQueryService func(s *platform.Source) (query.ProxyQueryService, error)
	// contains filtered or unexported fields
}

SourceBackend is all services and associated parameters required to construct the SourceHandler.

func NewSourceBackend

func NewSourceBackend(log *zap.Logger, b *APIBackend) *SourceBackend

NewSourceBackend returns a new instance of SourceBackend.

type SourceHandler

type SourceHandler struct {
	*httprouter.Router
	platform.HTTPErrorHandler

	SourceService platform.SourceService
	LabelService  platform.LabelService
	BucketService platform.BucketService

	// TODO(desa): this was done so in order to remove an import cycle and to allow
	// for http mocking.
	NewQueryService func(s *platform.Source) (query.ProxyQueryService, error)
	// contains filtered or unexported fields
}

SourceHandler is a handler for sources

func NewSourceHandler

func NewSourceHandler(log *zap.Logger, b *SourceBackend) *SourceHandler

NewSourceHandler returns a new instance of SourceHandler.

type SourceProxyQueryService

type SourceProxyQueryService struct {
	Addr               string
	InsecureSkipVerify bool
	platform.SourceFields
}

func (*SourceProxyQueryService) Check

func (s *SourceProxyQueryService) Check(context.Context) check.Response

func (*SourceProxyQueryService) Query

func (s *SourceProxyQueryService) Query(ctx context.Context, w io.Writer, req *query.ProxyRequest) (flux.Statistics, error)

type SourceService

type SourceService struct {
	Client *httpc.Client
}

SourceService connects to Influx via HTTP using tokens to manage sources

func (*SourceService) CreateSource

func (s *SourceService) CreateSource(ctx context.Context, b *platform.Source) error

CreateSource creates a new source and sets b.ID with the new identifier.

func (*SourceService) DeleteSource

func (s *SourceService) DeleteSource(ctx context.Context, id platform.ID) error

DeleteSource removes a source by ID.

func (*SourceService) FindSourceByID

func (s *SourceService) FindSourceByID(ctx context.Context, id platform.ID) (*platform.Source, error)

FindSourceByID returns a single source by ID.

func (*SourceService) FindSources

func (s *SourceService) FindSources(ctx context.Context, opt platform.FindOptions) ([]*platform.Source, int, error)

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

func (*SourceService) UpdateSource

func (s *SourceService) UpdateSource(ctx context.Context, id platform.ID, upd platform.SourceUpdate) (*platform.Source, error)

UpdateSource updates a single source with changeset. Returns the new source state after update.

type SpanTransport

type SpanTransport struct {
	// contains filtered or unexported fields
}

SpanTransport injects the http.RoundTripper.RoundTrip() request with a span.

func (*SpanTransport) RoundTrip

func (s *SpanTransport) RoundTrip(r *http.Request) (*http.Response, error)

RoundTrip implements the http.RoundTripper, intercepting the base round trippers call and injecting a span.

type Task

type Task struct {
	ID              influxdb.ID            `json:"id"`
	OrganizationID  influxdb.ID            `json:"orgID"`
	Organization    string                 `json:"org"`
	OwnerID         influxdb.ID            `json:"ownerID"`
	Name            string                 `json:"name"`
	Description     string                 `json:"description,omitempty"`
	Status          string                 `json:"status"`
	Flux            string                 `json:"flux"`
	Every           string                 `json:"every,omitempty"`
	Cron            string                 `json:"cron,omitempty"`
	Offset          string                 `json:"offset,omitempty"`
	LatestCompleted string                 `json:"latestCompleted,omitempty"`
	LastRunStatus   string                 `json:"lastRunStatus,omitempty"`
	LastRunError    string                 `json:"lastRunError,omitempty"`
	CreatedAt       string                 `json:"createdAt,omitempty"`
	UpdatedAt       string                 `json:"updatedAt,omitempty"`
	Metadata        map[string]interface{} `json:"metadata,omitempty"`
}

func NewFrontEndTask

func NewFrontEndTask(t influxdb.Task) Task

NewFrontEndTask converts a internal task type to a task that we want to display to users

type TaskBackend

type TaskBackend struct {
	influxdb.HTTPErrorHandler

	TaskService                influxdb.TaskService
	AuthorizationService       influxdb.AuthorizationService
	OrganizationService        influxdb.OrganizationService
	UserResourceMappingService influxdb.UserResourceMappingService
	LabelService               influxdb.LabelService
	UserService                influxdb.UserService
	BucketService              influxdb.BucketService
	// contains filtered or unexported fields
}

TaskBackend is all services and associated parameters required to construct the TaskHandler.

func NewTaskBackend

func NewTaskBackend(log *zap.Logger, b *APIBackend) *TaskBackend

NewTaskBackend returns a new instance of TaskBackend.

type TaskHandler

type TaskHandler struct {
	*httprouter.Router
	influxdb.HTTPErrorHandler

	TaskService                influxdb.TaskService
	AuthorizationService       influxdb.AuthorizationService
	OrganizationService        influxdb.OrganizationService
	UserResourceMappingService influxdb.UserResourceMappingService
	LabelService               influxdb.LabelService
	UserService                influxdb.UserService
	BucketService              influxdb.BucketService
	// contains filtered or unexported fields
}

TaskHandler represents an HTTP API handler for tasks.

func NewTaskHandler

func NewTaskHandler(log *zap.Logger, b *TaskBackend) *TaskHandler

NewTaskHandler returns a new instance of TaskHandler.

type TaskService

type TaskService struct {
	Addr               string
	Token              string
	InsecureSkipVerify bool
}

TaskService connects to Influx via HTTP using tokens to manage tasks.

func (TaskService) CancelRun

func (t TaskService) CancelRun(ctx context.Context, taskID, runID influxdb.ID) error

CancelRun stops a longer running run.

func (TaskService) CreateTask

func (t TaskService) CreateTask(ctx context.Context, tc influxdb.TaskCreate) (*Task, error)

CreateTask creates a new task.

func (TaskService) DeleteTask

func (t TaskService) DeleteTask(ctx context.Context, id influxdb.ID) error

DeleteTask removes a task by ID and purges all associated data and scheduled runs.

func (TaskService) FindLogs

func (t TaskService) FindLogs(ctx context.Context, filter influxdb.LogFilter) ([]*influxdb.Log, int, error)

FindLogs returns logs for a run.

func (TaskService) FindRunByID

func (t TaskService) FindRunByID(ctx context.Context, taskID, runID influxdb.ID) (*influxdb.Run, error)

FindRunByID returns a single run of a specific task.

func (TaskService) FindRuns

func (t TaskService) FindRuns(ctx context.Context, filter influxdb.RunFilter) ([]*influxdb.Run, int, error)

FindRuns returns a list of runs that match a filter and the total count of returned runs.

func (TaskService) FindTaskByID

func (t TaskService) FindTaskByID(ctx context.Context, id influxdb.ID) (*Task, error)

FindTaskByID returns a single task

func (TaskService) FindTasks

func (t TaskService) FindTasks(ctx context.Context, filter influxdb.TaskFilter) ([]Task, int, error)

FindTasks returns a list of tasks that match a filter (limit 100) and the total count of matching tasks.

func (TaskService) ForceRun

func (t TaskService) ForceRun(ctx context.Context, taskID influxdb.ID, scheduledFor int64) (*influxdb.Run, error)

ForceRun starts a run manually right now.

func (TaskService) RetryRun

func (t TaskService) RetryRun(ctx context.Context, taskID, runID influxdb.ID) (*influxdb.Run, error)

RetryRun creates and returns a new run (which is a retry of another run).

func (TaskService) UpdateTask

func (t TaskService) UpdateTask(ctx context.Context, id influxdb.ID, upd influxdb.TaskUpdate) (*Task, error)

UpdateTask updates a single task with changeset.

type TelegrafBackend

type TelegrafBackend struct {
	platform.HTTPErrorHandler

	TelegrafService            platform.TelegrafConfigStore
	UserResourceMappingService platform.UserResourceMappingService
	LabelService               platform.LabelService
	UserService                platform.UserService
	OrganizationService        platform.OrganizationService
	// contains filtered or unexported fields
}

TelegrafBackend is all services and associated parameters required to construct the TelegrafHandler.

func NewTelegrafBackend

func NewTelegrafBackend(log *zap.Logger, b *APIBackend) *TelegrafBackend

NewTelegrafBackend returns a new instance of TelegrafBackend.

type TelegrafHandler

type TelegrafHandler struct {
	*httprouter.Router
	platform.HTTPErrorHandler

	TelegrafService            platform.TelegrafConfigStore
	UserResourceMappingService platform.UserResourceMappingService
	LabelService               platform.LabelService
	UserService                platform.UserService
	OrganizationService        platform.OrganizationService
	// contains filtered or unexported fields
}

TelegrafHandler is the handler for the telegraf service

func NewTelegrafHandler

func NewTelegrafHandler(log *zap.Logger, b *TelegrafBackend) *TelegrafHandler

NewTelegrafHandler returns a new instance of TelegrafHandler.

type TelegrafService

type TelegrafService struct {
	*UserResourceMappingService
	// contains filtered or unexported fields
}

TelegrafService is an http client that speaks to the telegraf service via HTTP.

func NewTelegrafService

func NewTelegrafService(httpClient *httpc.Client) *TelegrafService

NewTelegrafService is a constructor for a telegraf service.

func (*TelegrafService) CreateTelegrafConfig

func (s *TelegrafService) CreateTelegrafConfig(ctx context.Context, tc *platform.TelegrafConfig, userID platform.ID) error

CreateTelegrafConfig creates a new telegraf config and sets b.ID with the new identifier.

func (*TelegrafService) DeleteTelegrafConfig

func (s *TelegrafService) DeleteTelegrafConfig(ctx context.Context, id platform.ID) error

DeleteTelegrafConfig removes a telegraf config by ID.

func (*TelegrafService) FindTelegrafConfigByID

func (s *TelegrafService) FindTelegrafConfigByID(ctx context.Context, id platform.ID) (*platform.TelegrafConfig, error)

FindTelegrafConfigByID returns a single telegraf config by ID.

func (*TelegrafService) FindTelegrafConfigs

func (s *TelegrafService) FindTelegrafConfigs(ctx context.Context, f platform.TelegrafConfigFilter, opt ...platform.FindOptions) ([]*platform.TelegrafConfig, int, error)

FindTelegrafConfigs returns a list of telegraf configs that match filter and the total count of matching telegraf configs. Additional options provide pagination & sorting.

func (*TelegrafService) UpdateTelegrafConfig

func (s *TelegrafService) UpdateTelegrafConfig(ctx context.Context, id platform.ID, tc *platform.TelegrafConfig, userID platform.ID) (*platform.TelegrafConfig, error)

UpdateTelegrafConfig updates a single telegraf config. Returns the new telegraf config after update.

type UsageHandler

type UsageHandler struct {
	*httprouter.Router
	platform.HTTPErrorHandler

	UsageService platform.UsageService
	// contains filtered or unexported fields
}

UsageHandler represents an HTTP API handler for usages.

func NewUsageHandler

func NewUsageHandler(log *zap.Logger, he platform.HTTPErrorHandler) *UsageHandler

NewUsageHandler returns a new instance of UsageHandler.

type UserBackend

type UserBackend struct {
	influxdb.HTTPErrorHandler

	UserService             influxdb.UserService
	UserOperationLogService influxdb.UserOperationLogService
	PasswordsService        influxdb.PasswordsService
	// contains filtered or unexported fields
}

UserBackend is all services and associated parameters required to construct the UserHandler.

func NewUserBackend

func NewUserBackend(log *zap.Logger, b *APIBackend) *UserBackend

NewUserBackend creates a UserBackend using information in the APIBackend.

type UserHandler

type UserHandler struct {
	*httprouter.Router
	influxdb.HTTPErrorHandler

	UserService             influxdb.UserService
	UserOperationLogService influxdb.UserOperationLogService
	PasswordsService        influxdb.PasswordsService
	// contains filtered or unexported fields
}

UserHandler represents an HTTP API handler for users.

func NewUserHandler

func NewUserHandler(log *zap.Logger, b *UserBackend) *UserHandler

NewUserHandler returns a new instance of UserHandler.

type UserResourceMappingService

type UserResourceMappingService struct {
	Client *httpc.Client
}

UserResourceMappingService is the struct of urm service

func (*UserResourceMappingService) CreateUserResourceMapping

func (s *UserResourceMappingService) CreateUserResourceMapping(ctx context.Context, m *influxdb.UserResourceMapping) error

CreateUserResourceMapping will create a user resource mapping

func (*UserResourceMappingService) DeleteUserResourceMapping

func (s *UserResourceMappingService) DeleteUserResourceMapping(ctx context.Context, resourceID influxdb.ID, userID influxdb.ID) error

DeleteUserResourceMapping will delete user resource mapping based in criteria.

func (*UserResourceMappingService) FindUserResourceMappings

func (s *UserResourceMappingService) FindUserResourceMappings(ctx context.Context, f influxdb.UserResourceMappingFilter, opt ...influxdb.FindOptions) ([]*influxdb.UserResourceMapping, int, error)

FindUserResourceMappings returns the user resource mappings

type UserResponse

type UserResponse struct {
	Links map[string]string `json:"links"`
	influxdb.User
}

UserResponse is the response of user

type UserService

type UserService struct {
	Client *httpc.Client
	// OpPrefix is the ops of not found error.
	OpPrefix string
}

UserService connects to Influx via HTTP using tokens to manage users

func (*UserService) CreateUser

func (s *UserService) CreateUser(ctx context.Context, u *influxdb.User) error

CreateUser creates a new user and sets u.ID with the new identifier.

func (*UserService) DeleteUser

func (s *UserService) DeleteUser(ctx context.Context, id influxdb.ID) error

DeleteUser removes a user by ID.

func (*UserService) FindMe

func (s *UserService) FindMe(ctx context.Context, id influxdb.ID) (*influxdb.User, error)

FindMe returns user information about the owner of the token

func (*UserService) FindUser

func (s *UserService) FindUser(ctx context.Context, filter influxdb.UserFilter) (*influxdb.User, error)

FindUser returns the first user that matches filter.

func (*UserService) FindUserByID

func (s *UserService) FindUserByID(ctx context.Context, id influxdb.ID) (*influxdb.User, error)

FindUserByID returns a single user by ID.

func (*UserService) FindUsers

func (s *UserService) FindUsers(ctx context.Context, filter influxdb.UserFilter, opt ...influxdb.FindOptions) ([]*influxdb.User, int, error)

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

func (*UserService) UpdateUser

func (s *UserService) UpdateUser(ctx context.Context, id influxdb.ID, upd influxdb.UserUpdate) (*influxdb.User, error)

UpdateUser updates a single user with changeset. Returns the new user state after update.

type VariableBackend

type VariableBackend struct {
	platform.HTTPErrorHandler

	VariableService platform.VariableService
	LabelService    platform.LabelService
	// contains filtered or unexported fields
}

VariableBackend is all services and associated parameters required to construct the VariableHandler.

func NewVariableBackend

func NewVariableBackend(log *zap.Logger, b *APIBackend) *VariableBackend

NewVariableBackend creates a backend used by the variable handler.

type VariableHandler

type VariableHandler struct {
	*httprouter.Router

	platform.HTTPErrorHandler

	VariableService platform.VariableService
	LabelService    platform.LabelService
	// contains filtered or unexported fields
}

VariableHandler is the handler for the variable service

func NewVariableHandler

func NewVariableHandler(log *zap.Logger, b *VariableBackend) *VariableHandler

NewVariableHandler creates a new VariableHandler

type VariableService

type VariableService struct {
	Client *httpc.Client
}

VariableService is a variable service over HTTP to the influxdb server

func (*VariableService) CreateVariable

func (s *VariableService) CreateVariable(ctx context.Context, m *platform.Variable) error

CreateVariable creates a new variable and assigns it an platform.ID

func (*VariableService) DeleteVariable

func (s *VariableService) DeleteVariable(ctx context.Context, id platform.ID) error

DeleteVariable removes a variable from the store

func (*VariableService) FindVariableByID

func (s *VariableService) FindVariableByID(ctx context.Context, id platform.ID) (*platform.Variable, error)

FindVariableByID finds a single variable from the store by its ID

func (*VariableService) FindVariables

func (s *VariableService) FindVariables(ctx context.Context, filter platform.VariableFilter, opts ...platform.FindOptions) ([]*platform.Variable, error)

FindVariables returns a list of variables that match filter. Additional options provide pagination & sorting.

func (*VariableService) ReplaceVariable

func (s *VariableService) ReplaceVariable(ctx context.Context, variable *platform.Variable) error

ReplaceVariable replaces a single variable

func (*VariableService) UpdateVariable

func (s *VariableService) UpdateVariable(ctx context.Context, id platform.ID, update *platform.VariableUpdate) (*platform.Variable, error)

UpdateVariable updates a single variable with a changeset

type WriteBackend

type WriteBackend struct {
	influxdb.HTTPErrorHandler

	WriteEventRecorder metric.EventRecorder

	PointsWriter        storage.PointsWriter
	BucketService       influxdb.BucketService
	OrganizationService influxdb.OrganizationService
	// contains filtered or unexported fields
}

WriteBackend is all services and associated parameters required to construct the WriteHandler.

func NewWriteBackend

func NewWriteBackend(log *zap.Logger, b *APIBackend) *WriteBackend

NewWriteBackend returns a new instance of WriteBackend.

type WriteHandler

type WriteHandler struct {
	*httprouter.Router
	influxdb.HTTPErrorHandler

	BucketService       influxdb.BucketService
	OrganizationService influxdb.OrganizationService

	PointsWriter storage.PointsWriter

	EventRecorder metric.EventRecorder
	// contains filtered or unexported fields
}

WriteHandler receives line protocol and sends to a publish function.

func NewWriteHandler

func NewWriteHandler(log *zap.Logger, b *WriteBackend, opts ...WriteHandlerOption) *WriteHandler

NewWriteHandler creates a new handler at /api/v2/write to receive line protocol.

func (*WriteHandler) Prefix

func (*WriteHandler) Prefix() string

Prefix provides the route prefix.

type WriteHandlerOption

type WriteHandlerOption func(*WriteHandler)

WriteHandlerOption is a functional option for a *WriteHandler

func WithMaxBatchSizeBytes

func WithMaxBatchSizeBytes(n int64) WriteHandlerOption

WithMaxBatchSizeBytes configures the maximum size for a (decompressed) points batch allowed by the write handler

func WithParserMaxBytes

func WithParserMaxBytes(n int) WriteHandlerOption

WithParserMaxBytes specifies the maximum number of bytes that may be allocated when processing a single write request. When n is zero, there is no limit.

func WithParserMaxLines

func WithParserMaxLines(n int) WriteHandlerOption

WithParserMaxLines specifies the maximum number of lines that may be parsed when processing a single write request. When n is zero, there is no limit.

func WithParserMaxValues

func WithParserMaxValues(n int) WriteHandlerOption

WithParserMaxValues specifies the maximum number of values that may be parsed when processing a single write request. When n is zero, there is no limit.

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
Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier