api

package
v0.0.0-...-5b448de Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2017 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DetectConfigFile = "etc/topology_detect.json"
)

Variables

This section is empty.

Functions

func NewCrudClientFromConfig

func NewCrudClientFromConfig(authOptions *shttp.AuthenticationOpts) (*shttp.CrudClient, error)

NewCrudClientFromConfig creates a new REST client on /api

func NewRestClientFromConfig

func NewRestClientFromConfig(authOptions *shttp.AuthenticationOpts) (*shttp.RestClient, error)

NewRestClientFromConfig creates a new REST client

func RegisterConfigAPI

func RegisterConfigAPI(r *shttp.Server)

RegisterConfigAPI registers a configuration endpoint (read only) in API server

func RegisterPacketInjectorAPI

func RegisterPacketInjectorAPI(pic *packet_injector.PacketInjectorClient, g *graph.Graph, r *shttp.Server)

RegisterPacketInjectorAPI registers a new packet injector ressource in the API

func RegisterPcapAPI

func RegisterPcapAPI(r *shttp.Server, store storage.Storage)

RegisterPcapAPI registers a new pcap injector API

func RegisterTopologyAPI

func RegisterTopologyAPI(r *shttp.Server, parser *traversal.GremlinTraversalParser, tdc *probes.TopologyDetectClient)

RegisterTopologyAPI registers a new topology query API

Types

type Alert

type Alert struct {
	Resource
	UUID        string
	Name        string `json:",omitempty"`
	Description string `json:",omitempty"`
	Expression  string `json:",omitempty" valid:"nonzero"`
	Action      string `json:",omitempty" valid:"regexp=^(|http://|https://|file://).*$"`
	Trigger     string `json:",omitempty" valid:"regexp=^(graph|duration:.+|)$"`
	CreateTime  time.Time
}

Alert is a set of parameters, the Alert Action will Trigger according to its Expression.

func NewAlert

func NewAlert() *Alert

NewAlert creates a New empty Alert, only UUID and CreateTime are set.

func (*Alert) ID

func (a *Alert) ID() string

ID returns the alert ID

func (*Alert) SetID

func (a *Alert) SetID(i string)

SetID set ID

type AlertAPIHandler

type AlertAPIHandler struct {
	BasicAPIHandler
}

AlertAPIHandler aims to exposes the Alert API.

func RegisterAlertAPI

func RegisterAlertAPI(apiServer *Server) (*AlertAPIHandler, error)

RegisterAlertAPI registers an Alert's API to a designated API Server

type AlertResourceHandler

type AlertResourceHandler struct {
	ResourceHandler
}

AlertResourceHandler aims to creates and manage a new Alert.

func (*AlertResourceHandler) Name

func (a *AlertResourceHandler) Name() string

Name returns ressource name "alert"

func (*AlertResourceHandler) New

func (a *AlertResourceHandler) New() Resource

New creates a new alert

type BasicAPIHandler

type BasicAPIHandler struct {
	ResourceHandler ResourceHandler
	EtcdKeyAPI      etcd.KeysAPI
}

BasicAPIHandler basic implementation of an Handler, should be used as embedded struct for the most part of the resources

func (*BasicAPIHandler) AsyncWatch

AsyncWatch registers a new resource watcher

func (*BasicAPIHandler) Create

func (h *BasicAPIHandler) Create(resource Resource) error

Create a new resource in Etcd

func (*BasicAPIHandler) Decorate

func (h *BasicAPIHandler) Decorate(resource Resource)

Decorate the resource

func (*BasicAPIHandler) Delete

func (h *BasicAPIHandler) Delete(id string) error

Delete a resource

func (*BasicAPIHandler) Get

func (h *BasicAPIHandler) Get(id string) (Resource, bool)

Get a specific resource

func (*BasicAPIHandler) Index

func (h *BasicAPIHandler) Index() map[string]Resource

Index returns the list of resource available in Etcd

func (*BasicAPIHandler) Name

func (h *BasicAPIHandler) Name() string

Name returns the resource name

func (*BasicAPIHandler) New

func (h *BasicAPIHandler) New() Resource

New creates a new resource

func (*BasicAPIHandler) Unmarshal

func (h *BasicAPIHandler) Unmarshal(b []byte) (resource Resource, err error)

Unmarshal deserialize a resource

type BasicStoppableWatcher

type BasicStoppableWatcher struct {
	StoppableWatcher
	// contains filtered or unexported fields
}

BasicStoppableWatcher basic implementation of a ressources watcher

func (*BasicStoppableWatcher) Stop

func (s *BasicStoppableWatcher) Stop()

Stop the resource watcher

type Capture

type Capture struct {
	UUID         string
	GremlinQuery string `json:"GremlinQuery,omitempty" valid:"isGremlinExpr"`
	BPFFilter    string `json:"BPFFilter,omitempty" valid:"isBPFFilter"`
	Name         string `json:"Name,omitempty"`
	Description  string `json:"Description,omitempty"`
	Type         string `json:"Type,omitempty"`
	Count        int    `json:"Count,omitempty"`
	PCAPSocket   string `json:"PCAPSocket,omitempty"`
	Port         int    `json:"Port,omitempty"`
}

Capture describes a capture API

func NewCapture

func NewCapture(query string, bpfFilter string) *Capture

NewCapture creates a new capture

func (*Capture) ID

func (c *Capture) ID() string

ID returns the capture Identifier

func (*Capture) SetID

func (c *Capture) SetID(i string)

SetID set a new identifier for this capture

type CaptureAPIHandler

type CaptureAPIHandler struct {
	BasicAPIHandler
	Graph *graph.Graph
}

CaptureAPIHandler based on BasicAPIHandler

func RegisterCaptureAPI

func RegisterCaptureAPI(apiServer *Server, g *graph.Graph) (*CaptureAPIHandler, error)

RegisterCaptureAPI registers an new resource, capture

func (*CaptureAPIHandler) Create

func (c *CaptureAPIHandler) Create(r Resource) error

Create tests that resource GremlinQuery does not exists already

func (*CaptureAPIHandler) Decorate

func (c *CaptureAPIHandler) Decorate(resource Resource)

Decorate populate the capture resource

type CaptureResourceHandler

type CaptureResourceHandler struct {
	ResourceHandler
}

CaptureResourceHandler describes a capture ressouce handler

func (*CaptureResourceHandler) Name

func (c *CaptureResourceHandler) Name() string

Name returns "capture"

func (*CaptureResourceHandler) New

New creates a new capture resource

type DetectConfig

type DetectConfig struct {
	Detectip     string
	Detectperiod int
	Community    string
}

type Handler

type Handler interface {
	Name() string
	New() Resource
	Index() map[string]Resource
	Get(id string) (Resource, bool)
	Decorate(resource Resource)
	Create(resource Resource) error
	Delete(id string) error
	AsyncWatch(f WatcherCallback) StoppableWatcher
}

Handler describes resources for each API

type HandlerFunc

type HandlerFunc func(w http.ResponseWriter, r *http.Request)

HandlerFunc describes an http(s) router handler callback function

type Info

type Info struct {
	Host    string
	Version string
	Service string
}

Info for each host describes his API version and service (agent or analyzer)

type PacketInjectorAPI

type PacketInjectorAPI struct {
	PIClient *packet_injector.PacketInjectorClient
	Graph    *graph.Graph
}

PacketInjectorAPI exposes the packet injector API

type PacketParamsReq

type PacketParamsReq struct {
	Src        string
	Dst        string
	SrcIP      string
	DstIP      string
	SrcMAC     string
	DstMAC     string
	Type       string
	Payload    string
	TrackingID string
	ID         int64
	Count      int64
	Interval   int64
}

PacketParamsReq packet injector API parameters

type PcapAPI

type PcapAPI struct {
	Storage storage.Storage
}

PcapAPI exposes the pcap injector API

type Resource

type Resource interface {
	ID() string
	SetID(string)
}

Resource used as interface resources for each API

type ResourceHandler

type ResourceHandler interface {
	Name() string
	New() Resource
}

ResourceHandler aims to creates new resource of an API

type ResourceWatcher

type ResourceWatcher interface {
	AsyncWatch(f WatcherCallback) StoppableWatcher
}

ResourceWatcher asynchronous interface

type Server

type Server struct {
	HTTPServer  *shttp.Server
	EtcdKeyAPI  etcd.KeysAPI
	ServiceType common.ServiceType
	// contains filtered or unexported fields
}

Server object are created once for each ServiceType (agent or analyzer)

func NewAPI

func NewAPI(server *shttp.Server, kapi etcd.KeysAPI, serviceType common.ServiceType) (*Server, error)

NewAPI creates a new API server based on http

func (*Server) GetHandler

func (a *Server) GetHandler(hname string) Handler

GetHandler returns the hander named hname

func (*Server) RegisterAPIHandler

func (a *Server) RegisterAPIHandler(handler Handler) error

RegisterAPIHandler registers a new handler for an API

type StoppableWatcher

type StoppableWatcher interface {
	Stop()
}

StoppableWatcher interface

type TopologyAPI

type TopologyAPI struct {
	TDClient *probes.TopologyDetectClient
	// contains filtered or unexported fields
}

TopologyAPI exposes the topology query API

type TopologyDetect

type TopologyDetect struct {
	IP        string
	Period    int64
	Community string
}

type TopologyParam

type TopologyParam struct {
	GremlinQuery string `json:"GremlinQuery,omitempty" valid:"isGremlinExpr"`
}

TopologyParam topology API parameter

type WatcherCallback

type WatcherCallback func(action string, id string, resource Resource)

WatcherCallback callback called by the ressources watcher

Jump to

Keyboard shortcuts

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