lib

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const ExportInstancePermissionsTopic = "export-instances"

Variables

View Source
var DB *gorm.DB

Functions

func Close

func Close()

func GetDB

func GetDB() *gorm.DB

func GetEnv

func GetEnv(key, fallback string) string

func Init

func Init()

func StringInSlice

func StringInSlice(str string, slice []string) bool

func ToJson

func ToJson(resp string) map[string]interface{}

Types

type Claims

type Claims struct {
	Sub         string              `json:"sub,omitempty"`
	RealmAccess map[string][]string `json:"realm_access,omitempty"`
}

func (Claims) IsAdmin

func (c Claims) IsAdmin() bool

func (Claims) Valid

func (c Claims) Valid() error

type Driver

type Driver interface {
	CreateInstance(instance *Instance, dataFields string, tagFields string) (serviceId string, err error)
	DeleteInstance(instance *Instance) (err error)
}

type ExportDatabase

type ExportDatabase struct {
	ID            string `gorm:"primary_key;type:varchar(255);column:id"`
	Name          string `gorm:"type:varchar(255)"`
	Description   string `gorm:"type:varchar(255)"`
	Type          string `gorm:"type:varchar(255)"`
	Deployment    string `gorm:"type:varchar(255)"`
	Url           string `gorm:"type:varchar(255)"`
	EwFilterTopic string `gorm:"type:varchar(255)"`
	UserId        string `gorm:"type:varchar(255)"`
	Public        bool   `gorm:"type:bool;DEFAULT:false"`
}

type ExportDatabaseRequest

type ExportDatabaseRequest struct {
	Name          string `json:"Name" validate:"required"`
	Description   string `json:"Description"`
	Type          string `json:"Type" validate:"required"`
	Deployment    string `json:"deployment" validate:"required"`
	Url           string `json:"Url" validate:"required"`
	EwFilterTopic string `json:"EwFilterTopic" validate:"required"`
	Public        bool   `json:"Public"`
}

type ExportWorkerKafkaApi

type ExportWorkerKafkaApi interface {
	CreateFilterTopic(topic string, checkExists bool) error
	InitFilterTopics(serving *Serving) error
}

type ImportDeployService

type ImportDeployService interface {
	UserHasImportAccess(id string, authorization string) (bool, error)
}

type Influx

type Influx interface {
	ForceDeleteMeasurement(id string, userId string, instance Instance) (errs []error)
}

type InfluxImpl added in v0.0.2

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

func NewInflux

func NewInflux() *InfluxImpl

func (*InfluxImpl) ForceDeleteMeasurement added in v0.0.2

func (i *InfluxImpl) ForceDeleteMeasurement(id string, userId string, instance Instance) (errs []error)

type Instance

type Instance struct {
	ID               uuid.UUID      `gorm:"primary_key;type:char(36);column:id"`
	Name             string         `gorm:"type:varchar(255)"`
	Description      string         `gorm:"type:varchar(255)"`
	EntityName       string         `gorm:"type:varchar(255)"`
	ServiceName      string         `gorm:"type:varchar(255)"`
	Topic            string         `gorm:"type:varchar(255)"`
	ApplicationId    uuid.UUID      `gorm:"type:char(36)"`
	Database         string         `gorm:"type:varchar(255)"`
	Measurement      string         `gorm:"type:varchar(255)"`
	Filter           string         `gorm:"type:varchar(255)"`
	FilterType       string         `gorm:"type:varchar(255)"`
	TimePath         string         `gorm:"type:varchar(255)"`
	TimePrecision    *string        `gorm:"type:varchar(255)"`
	UserId           string         `gorm:"type:varchar(255)"`
	Generated        bool           `gorm:"type:bool;DEFAULT:false"`
	RancherServiceId string         `gorm:"type:varchar(255)"`
	Offset           string         `gorm:"type:varchar(255)"`
	ExportDatabaseID string         `gorm:"type:varchar(255)"`
	ExportDatabase   ExportDatabase `gorm:"association_autoupdate:false;association_autocreate:false"`
	TimestampFormat  string         `gorm:"type:varchar(255)"`
	Values           []Value        `gorm:"foreignkey:InstanceID;association_foreignkey:ID"`
	CreatedAt        time.Time
	UpdatedAt        time.Time
}

type Instances

type Instances []Instance

type InstancesResponse

type InstancesResponse struct {
	Total     int64     `json:"total,omitempty"`
	Count     int       `json:"count,omitempty"`
	Instances Instances `json:"instances,omitempty"`
}

type LoggerMiddleWare

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

func NewLogger

func NewLogger(handler http.Handler, logLevel string) *LoggerMiddleWare

func (*LoggerMiddleWare) CloseLogFile

func (this *LoggerMiddleWare) CloseLogFile()

func (*LoggerMiddleWare) ServeHTTP

func (this *LoggerMiddleWare) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Migration

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

func NewMigration

func NewMigration(db *gorm.DB) *Migration

func (*Migration) Migrate

func (m *Migration) Migrate()

func (*Migration) TmpMigrate

func (m *Migration) TmpMigrate() (err error)

type MigrationInfo

type MigrationInfo struct {
	ID            string `json:"id"`
	Name          string `json:"name"`
	Description   string `json:"description"`
	Type          string `json:"type"`
	Deployment    string `json:"deployment"`
	Url           string `json:"url"`
	EwFilterTopic string `json:"ew_filter_topic"`
	UserID        string `json:"user_id"`
	Public        bool   `json:"public"`
}

type PermissionApiService

type PermissionApiService interface {
	UserHasDevicesReadAccess(ids []string, authorization string) (bool, error)
}

type PipelineApiService

type PipelineApiService interface {
	UserHasPipelineAccess(id string, authorization string) (bool, error)
}

type Response

type Response struct {
	Message string `json:"message,omitempty" validate:"required"`
}

type Serving

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

func NewServing

func NewServing(driver Driver, influx Influx, permissionService PermissionApiService, pipelineService PipelineApiService, importDeployService ImportDeployService, exportDatabaseIdPrefix string, permissionsV2 permV2Client.Client, cleanupChron string, cleanupRecheckWait time.Duration) (*Serving, error)

func (*Serving) CreateExportDatabase

func (f *Serving) CreateExportDatabase(id string, req ExportDatabaseRequest, userId string) (database ExportDatabase, errs []error)

func (*Serving) CreateFromInstance

func (f *Serving) CreateFromInstance(instance *Instance) (err error)

func (*Serving) CreateInstance

func (f *Serving) CreateInstance(req ServingRequest, userId string, token string) (instance Instance, err error)

func (*Serving) DeleteExportDatabase

func (f *Serving) DeleteExportDatabase(id string, userId string) (errs []error)

func (*Serving) DeleteInstanceForUser

func (f *Serving) DeleteInstanceForUser(id string, userId string, token string) (deleted bool, errors []error)

func (*Serving) DeleteInstanceWithPermHandling added in v0.0.2

func (f *Serving) DeleteInstanceWithPermHandling(id string, userId string, admin bool, token string) (deleted bool, errors []error)

func (*Serving) DeleteInstancesForUser

func (f *Serving) DeleteInstancesForUser(ids []string, userId string, token string) (deleted []string, errors []error)

func (*Serving) ExportInstanceCleanup added in v0.0.2

func (f *Serving) ExportInstanceCleanup(recheckWait time.Duration) error

func (*Serving) GetExportDatabase

func (f *Serving) GetExportDatabase(id string, userId string) (database ExportDatabase, errs []error)

func (*Serving) GetExportDatabases

func (f *Serving) GetExportDatabases(userId string, args map[string][]string) (databases []ExportDatabase, errs []error)

func (*Serving) GetInstance

func (f *Serving) GetInstance(id string, userId string, token string, admin bool) (instance Instance, errors []error)

func (*Serving) GetInstances

func (f *Serving) GetInstances(userId string, args map[string][]string, admin bool, token string) (instances Instances, total int64, errors []error)

func (*Serving) GetInstancesForUser

func (f *Serving) GetInstancesForUser(userId string, args map[string][]string, token string) (instances Instances, count int64, errors []error)

func (*Serving) UpdateExportDatabase

func (f *Serving) UpdateExportDatabase(id string, req ExportDatabaseRequest, userId string) (database ExportDatabase, errs []error)

func (*Serving) UpdateInstance

func (f *Serving) UpdateInstance(id string, userId string, request ServingRequest, token string) (instance Instance, errors []error)

type ServingRequest

type ServingRequest struct {
	FilterType       string                `json:"FilterType,omitempty" validate:"required"`
	Filter           string                `json:"Filter,omitempty" validate:"required"`
	Name             string                `json:"Name,omitempty" validate:"required"`
	EntityName       string                `json:"EntityName,omitempty" validate:"required"`
	ServiceName      string                `json:"ServiceName,omitempty" validate:"required"`
	Description      string                `json:"Description,omitempty"`
	Topic            string                `json:"Topic,omitempty" validate:"required"`
	TimePath         string                `json:"TimePath,omitempty"`
	TimePrecision    string                `json:"TimePrecision,omitempty"`
	Generated        bool                  `json:"generated,omitempty"`
	Offset           string                `json:"Offset,omitempty" validate:"required"`
	ForceUpdate      bool                  `json:"ForceUpdate,omitempty"`
	Values           []ServingRequestValue `json:"Values,omitempty"`
	ExportDatabaseID string                `json:"ExportDatabaseID,omitempty"`
	TimestampFormat  string                `json:"TimestampFormat,omitempty"`
}

type ServingRequestValue

type ServingRequestValue struct {
	Name string `json:"Name,omitempty"`
	Type string `json:"Type,omitempty"`
	Path string `json:"Path,omitempty"`
	Tag  bool   `json:"Tag"`
}

type Value

type Value struct {
	InstanceID uuid.UUID `gorm:"type:char(36)"`
	Name       string    `gorm:"type:varchar(255)"`
	Type       string    `gorm:"type:varchar(255)"`
	Path       string    `gorm:"type:varchar(255)"`
	Tag        bool      `gorm:"type:bool;DEFAULT:false"`
}

Jump to

Keyboard shortcuts

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