label

package
v2.7.7 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const MaxIDGenerationN = 100
View Source
const ReservedIDs = 1000

Variables

View Source
var (
	// NotUniqueIDError occurs when attempting to create a Label with an ID that already belongs to another one
	NotUniqueIDError = &errors.Error{
		Code: errors.EConflict,
		Msg:  "ID already exists",
	}

	// ErrFailureGeneratingID occurs ony when the random number generator
	// cannot generate an ID in MaxIDGenerationN times.
	ErrFailureGeneratingID = &errors.Error{
		Code: errors.EInternal,
		Msg:  "unable to generate valid id",
	}

	// ErrLabelNotFound occurs when a label cannot be found by its ID
	ErrLabelNotFound = &errors.Error{
		Code: errors.ENotFound,
		Msg:  "label not found",
	}
)

Functions

func NewService

func NewService(st *Store) influxdb.LabelService

Types

type AuthedLabelService

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

func NewAuthedLabelService

func NewAuthedLabelService(s influxdb.LabelService, orgIDResolver authorizer.OrgIDResolver) *AuthedLabelService

NewAuthedLabelService constructs an instance of an authorizing label serivce.

func (*AuthedLabelService) CreateLabel

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

func (*AuthedLabelService) CreateLabelMapping

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

CreateLabelMapping checks to see if the authorizer on context has write access to the label and the resource contained by the label mapping in creation.

func (*AuthedLabelService) DeleteLabel

func (s *AuthedLabelService) DeleteLabel(ctx context.Context, id platform.ID) error

DeleteLabel checks to see if the authorizer on context has write access to the label provided.

func (*AuthedLabelService) DeleteLabelMapping

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

DeleteLabelMapping checks to see if the authorizer on context has write access to the label and the resource of the label mapping to delete.

func (*AuthedLabelService) FindLabelByID

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

FindLabelByID checks to see if the authorizer on context has read access to the label id provided.

func (*AuthedLabelService) FindLabels

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

func (*AuthedLabelService) FindResourceLabels

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

FindResourceLabels retrieves all labels belonging to the filtering resource if the authorizer on context has read access to it. Then it filters the list down to only the labels that are authorized.

func (*AuthedLabelService) UpdateLabel

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

UpdateLabel checks to see if the authorizer on context has write access to the label provided.

type LabelClientService

type LabelClientService struct {
	Client *httpc.Client
}

func (*LabelClientService) CreateLabel

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

CreateLabel creates a new label.

func (*LabelClientService) CreateLabelMapping

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

CreateLabelMapping will create a label mapping

func (*LabelClientService) DeleteLabel

func (s *LabelClientService) DeleteLabel(ctx context.Context, id platform.ID) error

DeleteLabel removes a label by ID.

func (*LabelClientService) DeleteLabelMapping

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

func (*LabelClientService) FindLabelByID

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

FindLabelByID returns a single label by ID.

func (*LabelClientService) FindLabels

func (s *LabelClientService) 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 (*LabelClientService) FindResourceLabels

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

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

func (*LabelClientService) UpdateLabel

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

UpdateLabel updates a label and returns the updated label.

type LabelEmbeddedHandler

type LabelEmbeddedHandler struct {
	chi.Router
	// contains filtered or unexported fields
}

func NewHTTPEmbeddedHandler

func NewHTTPEmbeddedHandler(log *zap.Logger, rt influxdb.ResourceType, ls influxdb.LabelService) *LabelEmbeddedHandler

NewHTTPEmbeddedHandler create a label handler for embedding in other service apis

type LabelHandler

type LabelHandler struct {
	chi.Router
	// contains filtered or unexported fields
}

func NewHTTPLabelHandler

func NewHTTPLabelHandler(log *zap.Logger, ls influxdb.LabelService) *LabelHandler

func (*LabelHandler) Prefix

func (h *LabelHandler) Prefix() string

type LabelLogger

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

func NewLabelLogger

func NewLabelLogger(log *zap.Logger, s influxdb.LabelService) *LabelLogger

func (*LabelLogger) CreateLabel

func (l *LabelLogger) CreateLabel(ctx context.Context, label *influxdb.Label) (err error)

func (*LabelLogger) CreateLabelMapping

func (l *LabelLogger) CreateLabelMapping(ctx context.Context, m *influxdb.LabelMapping) (err error)

func (*LabelLogger) DeleteLabel

func (l *LabelLogger) DeleteLabel(ctx context.Context, id platform.ID) (err error)

func (*LabelLogger) DeleteLabelMapping

func (l *LabelLogger) DeleteLabelMapping(ctx context.Context, m *influxdb.LabelMapping) (err error)

func (*LabelLogger) FindLabelByID

func (l *LabelLogger) FindLabelByID(ctx context.Context, id platform.ID) (label *influxdb.Label, err error)

func (*LabelLogger) FindLabels

func (l *LabelLogger) FindLabels(ctx context.Context, filter influxdb.LabelFilter, opt ...influxdb.FindOptions) (ls []*influxdb.Label, err error)

func (*LabelLogger) FindResourceLabels

func (l *LabelLogger) FindResourceLabels(ctx context.Context, filter influxdb.LabelMappingFilter) (ls []*influxdb.Label, err error)

func (*LabelLogger) UpdateLabel

func (l *LabelLogger) UpdateLabel(ctx context.Context, id platform.ID, upd influxdb.LabelUpdate) (lbl *influxdb.Label, err error)

type LabelMetrics

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

func NewLabelMetrics

func NewLabelMetrics(reg prometheus.Registerer, s influxdb.LabelService, opts ...metric.ClientOptFn) *LabelMetrics

func (*LabelMetrics) CreateLabel

func (m *LabelMetrics) CreateLabel(ctx context.Context, l *influxdb.Label) (err error)

func (*LabelMetrics) CreateLabelMapping

func (m *LabelMetrics) CreateLabelMapping(ctx context.Context, lm *influxdb.LabelMapping) (err error)

func (*LabelMetrics) DeleteLabel

func (m *LabelMetrics) DeleteLabel(ctx context.Context, id platform.ID) (err error)

func (*LabelMetrics) DeleteLabelMapping

func (m *LabelMetrics) DeleteLabelMapping(ctx context.Context, lm *influxdb.LabelMapping) (err error)

func (*LabelMetrics) FindLabelByID

func (m *LabelMetrics) FindLabelByID(ctx context.Context, id platform.ID) (label *influxdb.Label, err error)

func (*LabelMetrics) FindLabels

func (m *LabelMetrics) FindLabels(ctx context.Context, filter influxdb.LabelFilter, opt ...influxdb.FindOptions) (ls []*influxdb.Label, err error)

func (*LabelMetrics) FindResourceLabels

func (m *LabelMetrics) FindResourceLabels(ctx context.Context, filter influxdb.LabelMappingFilter) (ls []*influxdb.Label, err error)

func (*LabelMetrics) UpdateLabel

func (m *LabelMetrics) UpdateLabel(ctx context.Context, id platform.ID, upd influxdb.LabelUpdate) (lbl *influxdb.Label, err error)

type Service

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

func (*Service) CreateLabel

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

CreateLabel creates a new label.

func (*Service) CreateLabelMapping

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

CreateLabelMapping creates a new mapping between a resource and a label.

func (*Service) DeleteLabel

func (s *Service) DeleteLabel(ctx context.Context, id platform.ID) error

DeleteLabel deletes a label.

func (*Service) DeleteLabelMapping

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

DeleteLabelMapping deletes a label mapping.

func (*Service) FindLabelByID

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

FindLabelByID finds a label by its ID

func (*Service) FindLabels

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

FindLabels returns a list of labels that match a filter.

func (*Service) FindResourceLabels

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

func (*Service) UpdateLabel

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

UpdateLabel updates a label.

type Store

type Store struct {
	IDGenerator platform.IDGenerator
	// contains filtered or unexported fields
}

func NewStore

func NewStore(kvStore kv.Store) (*Store, error)

func (*Store) CreateLabel

func (s *Store) CreateLabel(ctx context.Context, tx kv.Tx, l *influxdb.Label) error

func (*Store) CreateLabelMapping

func (s *Store) CreateLabelMapping(ctx context.Context, tx kv.Tx, m *influxdb.LabelMapping) error

func (*Store) DeleteLabel

func (s *Store) DeleteLabel(ctx context.Context, tx kv.Tx, id platform.ID) error

func (*Store) DeleteLabelMapping

func (s *Store) DeleteLabelMapping(ctx context.Context, tx kv.Tx, m *influxdb.LabelMapping) error

func (*Store) FindResourceLabels

func (s *Store) FindResourceLabels(ctx context.Context, tx kv.Tx, filter influxdb.LabelMappingFilter, ls *[]*influxdb.Label) error

func (*Store) GetLabel

func (s *Store) GetLabel(ctx context.Context, tx kv.Tx, id platform.ID) (*influxdb.Label, error)

func (*Store) ListLabels

func (s *Store) ListLabels(ctx context.Context, tx kv.Tx, filter influxdb.LabelFilter) ([]*influxdb.Label, error)

func (*Store) Update

func (s *Store) Update(ctx context.Context, fn func(kv.Tx) error) error

Update opens up a transaction that will mutate data.

func (*Store) UpdateLabel

func (s *Store) UpdateLabel(ctx context.Context, tx kv.Tx, id platform.ID, upd influxdb.LabelUpdate) (*influxdb.Label, error)

func (*Store) View

func (s *Store) View(ctx context.Context, fn func(kv.Tx) error) error

View opens up a transaction that will not write to any data. Implementing interfaces should take care to ensure that all view transactions do not mutate any data.

Jump to

Keyboard shortcuts

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