apiserver

package
v1.5.5 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PapiPullKey = "papi:last_pull"
)

Variables

View Source
var (
	SyncInterval = time.Second * 10
)

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

RecoveryWithWriter returns a middleware for a given 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(config *csconfig.OnlineApiClientCfg, dbClient *database.Client, consoleConfig *csconfig.ConsoleConfig, apicWhitelist *csconfig.CapiWhitelist) (*apic, error)

Types

type APIServer

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

func NewServer

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

func (*APIServer) AttachPluginBroker added in v1.2.0

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

func (*APIServer) Close

func (s *APIServer) Close()

func (*APIServer) GetTLSConfig added in v1.4.0

func (s *APIServer) GetTLSConfig() (*tls.Config, error)

func (*APIServer) InitController added in v1.2.0

func (s *APIServer) InitController() 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   interface{} `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() (PapiPermCheckSuccess, error)

func (*Papi) Pull added in v1.5.0

func (p *Papi) Pull() 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(since time.Time, sync bool) error

func (*Papi) SendDeletedDecisions added in v1.5.0

func (p *Papi) SendDeletedDecisions(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() 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