admin

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2025 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartWebServer

func StartWebServer(data *Data) error

StartWebServer starts the HTTP service and listens for the admin requests

Types

type Auth added in v1.0.0

type Auth interface {
	ValidateToken(ctx context.Context, token string) (model.User, error)
}

type Data

type Data struct {
	Port         int
	OneKeyGetter OneKeyRetriever
	LogProvider  LogProvider
	// logProvider       LogProvider
	UsageRestorer    UsageRestorer
	UsageReseter     UsageReseter
	ProjectValidator PrValidator
	Auth             echo.MiddlewareFunc
	Hasher           Hasher

	CmsData *cms.Data
}

Data is service operation data

type Hasher added in v1.0.0

type Hasher interface {
	HashKey(key string) string
}

type LogProvider

type LogProvider interface {
	GetLogs(ctx context.Context, user *model.User, keyID string) ([]*adminapi.Log, error)
	ListLogs(ctx context.Context, project string, to time.Time) ([]*adminapi.Log, error)
	DeleteLogs(ctx context.Context, project string, to time.Time) (int, error)
}

LogRetriever retrieves one list from db

type OneKeyRetriever

type OneKeyRetriever interface {
	Get(ctx context.Context, user *model.User, id string) (*adminapi.Key, error)
}

type PrValidator

type PrValidator interface {
	Check(string) bool
	Projects() []string
}

PrValidator validates if project is available

type ProjectConfigValidator

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

ProjectConfigValidator loads available projects from config

func NewProjectConfigValidator

func NewProjectConfigValidator(projects string) (*ProjectConfigValidator, error)

NewProjectConfigValidator creates project validator, reads available projects from config

func (*ProjectConfigValidator) Check

func (pv *ProjectConfigValidator) Check(pr string) bool

Check tests if project is available

func (*ProjectConfigValidator) Projects

func (pv *ProjectConfigValidator) Projects() []string

Projects returns all supported projects

type UsageReseter

type UsageReseter interface {
	Reset(ctx context.Context, project string, since time.Time, limit float64) error
}

UsageReseter resets montly usage

type UsageRestorer

type UsageRestorer interface {
	RestoreUsage(ctx context.Context, project string, manual bool, request string, errorMsg string) error

} // OneKeyRetriever retrieves one list from db

UsageRestorer restores key usage by requestID

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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