apiserver

package
v1.7.0-rc5 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2025 License: MIT Imports: 44 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	SyncInterval = time.Second * 10
	PapiPullKey  = "papi:last_pull"
)

Variables

This section is empty.

Functions

func AlertCmd added in v1.5.0

func AlertCmd(message *Message, p *Papi, sync bool) error

func CustomRecoveryWithWriter added in v1.0.12

func CustomRecoveryWithWriter() gin.HandlerFunc

CustomRecoveryWithWriter returns a middleware for a writer that recovers from any panics and writes a 500 if there was one.

func DecisionCmd added in v1.5.0

func DecisionCmd(message *Message, p *Papi, sync bool) error

func ManagementCmd added in v1.5.0

func ManagementCmd(message *Message, p *Papi, sync bool) error

func NewAPIC

func NewAPIC(ctx context.Context, config *csconfig.OnlineApiClientCfg, dbClient *database.Client, consoleConfig *csconfig.ConsoleConfig, apicWhitelist *csconfig.CapiWhitelist) (*apic, error)

Types

type APIServer

type APIServer struct {
	URL        string
	UnixSocket string
	TLS        *csconfig.TLSCfg
	// contains filtered or unexported fields
}

func NewServer

func NewServer(ctx context.Context, config *csconfig.LocalApiServerCfg) (*APIServer, error)

NewServer creates a LAPI server. It sets up a gin router, a database client, and a controller.

func (*APIServer) AttachPluginBroker added in v1.2.0

func (s *APIServer) AttachPluginBroker(broker *csplugin.PluginBroker)

func (*APIServer) Close

func (s *APIServer) Close()

func (*APIServer) InitController added in v1.2.0

func (s *APIServer) InitController() error

func (*APIServer) InitPlugins added in v1.6.10

func (s *APIServer) InitPlugins(ctx context.Context, cConfig *csconfig.Config, pluginBroker *csplugin.PluginBroker) error

func (*APIServer) Router

func (s *APIServer) Router() (*gin.Engine, error)

func (*APIServer) Run

func (s *APIServer) Run(apiReady chan bool) error

func (*APIServer) Shutdown

func (s *APIServer) Shutdown() error
type Header struct {
	OperationType string    `json:"operation_type"`
	OperationCmd  string    `json:"operation_cmd"`
	Timestamp     time.Time `json:"timestamp"`
	Message       string    `json:"message"`
	UUID          string    `json:"uuid"`
	Source        *Source   `json:"source"`
	Destination   string    `json:"destination"`
}

type Message added in v1.5.0

type Message struct {
	Header *Header
	Data   any `json:"data"`
}

type OperationChannels added in v1.5.0

type OperationChannels struct {
	AddAlertChannel       chan []*models.Alert
	DeleteDecisionChannel chan []*models.Decision
}

type Papi added in v1.5.0

type Papi struct {
	URL      string
	Client   *longpollclient.LongPollClient
	DBClient *database.Client

	Channels *OperationChannels

	SyncInterval time.Duration

	Logger *log.Entry
	// contains filtered or unexported fields
}

func NewPAPI added in v1.5.0

func NewPAPI(apic *apic, dbClient *database.Client, consoleConfig *csconfig.ConsoleConfig, logLevel log.Level) (*Papi, error)

func (*Papi) GetPermissions added in v1.5.0

func (p *Papi) GetPermissions(ctx context.Context) (PapiPermCheckSuccess, error)

func (*Papi) Pull added in v1.5.0

func (p *Papi) Pull(ctx context.Context) error

PullPAPI is the long polling client for real-time decisions from PAPI

func (*Papi) PullOnce added in v1.5.0

func (p *Papi) PullOnce(ctx context.Context, since time.Time, sync bool) error

func (*Papi) SendDeletedDecisions added in v1.5.0

func (p *Papi) SendDeletedDecisions(ctx context.Context, cacheOrig *models.DecisionsDeleteRequest)

func (*Papi) Shutdown added in v1.5.0

func (p *Papi) Shutdown()

func (*Papi) SyncDecisions added in v1.5.0

func (p *Papi) SyncDecisions(ctx context.Context) error

type PapiPermCheckError added in v1.5.0

type PapiPermCheckError struct {
	Error string `json:"error"`
}

type PapiPermCheckSuccess added in v1.5.0

type PapiPermCheckSuccess struct {
	Status     string   `json:"status"`
	Plan       string   `json:"plan"`
	Categories []string `json:"categories"`
}

type Source added in v1.5.0

type Source struct {
	User string `json:"user"`
}

Directories

Path Synopsis
v1
middlewares
v1

Jump to

Keyboard shortcuts

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