ui

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2019 License: GPL-2.0 Imports: 20 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	api.Server
	DB   Database
	LDAP LDAP
	// contains filtered or unexported fields
}

func (*API) Serve

func (r *API) Serve() error

type Category

type Category struct {
	ID        uint64
	Name      string
	Timestamp time.Time
}

func (*Category) MarshalJSON

func (r *Category) MarshalJSON() ([]byte, error)

type CategoryTransaction

type CategoryTransaction interface {
	// Categories returns a list of registered categories. Pagination limit can be 0 that means no pagination.
	Categories(Pagination) ([]*Category, error)
	AddCategory(requesterID uint64, name string) (category *Category, duplicated bool, err error)
	// UpdateCategory updates name of a category specified by id and then returns information of the category. It returns nil if the category does not exist.
	UpdateCategory(requesterID, categoryID uint64, name string) (category *Category, duplicated bool, err error)
	// RemoveCategory removes a category specified by id and then returns information of the category before removing. It returns nil if the category does not exist.
	RemoveCategory(requesterID, categoryID uint64) (*Category, error)
}

type Column

type Column int
const (
	ColumnInvalid Column = iota
	ColumnTime
	ColumnIP
	ColumnMAC
	ColumnPort
	ColumnGroup
	ColumnDescription
	ColumnUser
	ColumnLogType
	ColumnLogMethod
)

type Component

type Component struct {
	ID        uint64
	Category  Category
	Name      string
	Timestamp time.Time
}

func (*Component) MarshalJSON

func (r *Component) MarshalJSON() ([]byte, error)

type ComponentTransaction

type ComponentTransaction interface {
	// Components returns a list of registered components. Pagination limit can be 0 that means no pagination.
	Components(categoryID uint64, pagination Pagination) ([]*Component, error)
	AddComponent(requesterID, categoryID uint64, name string) (component *Component, duplicated bool, err error)
	// UpdateComponent updates name of a component specified by id and then returns information of the component. It returns nil if the component does not exist.
	UpdateComponent(requesterID, componentID uint64, name string) (component *Component, duplicated bool, err error)
	// RemoveComponent removes a component specified by id and then returns information of the component before removing. It returns nil if the component does not exist.
	RemoveComponent(requesterID, componentID uint64) (*Component, error)
}

type Database

type Database interface {
	// Exec executes all queries of f in a single transaction. f should return the error raised from the Transaction
	// without any change or wrapping it for deadlock protection.
	Exec(f func(Transaction) error) error
}

type Group

type Group struct {
	ID        uint64    `json:"id"`
	Name      string    `json:"name"`
	Timestamp time.Time `json:"timestamp"`
}

func (*Group) MarshalJSON

func (r *Group) MarshalJSON() ([]byte, error)

type GroupTransaction

type GroupTransaction interface {
	// Groups returns a list of registered groups. Pagination limit can be 0 that means no pagination.
	Groups(Pagination) ([]*Group, error)
	AddGroup(requesterID uint64, name string) (group *Group, duplicated bool, err error)
	// UpdateGroup updates name of a group specified by id and then returns information of the group. It returns nil if the group does not exist.
	UpdateGroup(requesterID, groupID uint64, name string) (group *Group, duplicated bool, err error)
	// RemoveGroup removes a group specified by id and then returns information of the group before removing. It returns nil if the group does not exist.
	RemoveGroup(requesterID, groupID uint64) (*Group, error)
}

type Host

type Host struct {
	ID          uint64
	IP          string // FIXME: Use a native type.
	Port        string
	Group       string
	MAC         string // FIXME: Use a native type.
	Description string
	Enabled     bool
	Stale       bool
	Spec        []*Spec
	Timestamp   time.Time
}

func (*Host) MarshalJSON

func (r *Host) MarshalJSON() ([]byte, error)

type HostTransaction

type HostTransaction interface {
	Host(id uint64) (*Host, error)
	// Hosts returns a list of registered hosts. Search can be nil that means no search. Pagination limit can be 0 that means no pagination.
	Hosts(*Search, Sort, Pagination) ([]*Host, error)
	AddHost(requesterID, ipID uint64, groupID *uint64, mac net.HardwareAddr, desc string, spec []SpecParam) (host *Host, duplicated bool, err error)
	// UpdateHost updates a host specified by id and then returns information of the host. The parameters used for update can be nil that means no update about the parameters.
	UpdateHost(requesterID, hostID uint64, ipID, groupID *uint64, mac net.HardwareAddr, description *string, spec []SpecParam) (host *Host, duplicated bool, err error)
	// ActivateHost enables a host specified by id and then returns information of the host. It returns nil if the host does not exist.
	ActivateHost(requesterID, hostID uint64) (*Host, error)
	// DeactivateHost disables a host specified by id and then returns information of the host. It returns nil if the host does not exist.
	DeactivateHost(requesterID, hostID uint64) (*Host, error)
	CountVIPByHostID(id uint64) (count uint64, err error)
	// RemoveHost removes a host specified by id and then returns information of the host before removing. It returns nil if the host does not exist.
	RemoveHost(requesterID, hostID uint64) (*Host, error)
}

type IP

type IP struct {
	ID      uint64 `json:"id"`
	Address string `json:"address"` // FIXME: Use a native type.
	Used    bool   `json:"used"`
	Port    string `json:"port"`
	Host    struct {
		Description string `json:"description"`
		Enabled     bool   `json:"enabled"`
		Stale       bool   `json:"stale"`
	} `json:"host"`
}

type IPTransaction

type IPTransaction interface {
	IPAddrs(networkID uint64) ([]*IP, error)
}

type LDAP

type LDAP interface {
	Auth(username, password string) (ok bool, err error)
}

type Log

type Log struct {
	ID        uint64
	User      string
	Type      LogType
	Method    LogMethod
	Data      string
	Timestamp time.Time
}

func (*Log) MarshalJSON

func (r *Log) MarshalJSON() ([]byte, error)

type LogMethod

type LogMethod string
const (
	LogMethodAdd    LogMethod = "ADD"
	LogMethodUpdate LogMethod = "UPDATE"
	LogMethodRemove LogMethod = "REMOVE"
)

func (LogMethod) Validate

func (r LogMethod) Validate() error

type LogTransaction

type LogTransaction interface {
	// Logs returns a list of registered logs. Search can be nil that means no search.
	QueryLog(*Search, Pagination) ([]*Log, error)
}

type LogType

type LogType string
const (
	LogTypeUser      LogType = "USER"
	LogTypeGroup     LogType = "GROUP"
	LogTypeSwitch    LogType = "SWITCH"
	LogTypeNetwork   LogType = "NETWORK"
	LogTypeHost      LogType = "HOST"
	LogTypeVIP       LogType = "VIP"
	LogTypeCategory  LogType = "CATEGORY"
	LogTypeComponent LogType = "COMPONENT"
)

func (LogType) Validate

func (r LogType) Validate() error

type Network

type Network struct {
	ID      uint64 `json:"id"`
	Address string `json:"address"` // FIXME: Use a native type.
	Mask    uint8  `json:"mask"`    // FIXME: Use a native type.
	Gateway string `json:"gateway"` // FIXME: Use a native type.
}

type NetworkTransaction

type NetworkTransaction interface {
	// Networks returns a list of registered networks. Address can be nil that means no address search. Pagination limit can be 0 that means no pagination.
	Networks(address *string, pagination Pagination) ([]*Network, error)
	AddNetwork(requesterID uint64, addr net.IP, mask net.IPMask, gateway net.IP) (network *Network, duplicated bool, err error)
	// RemoveNetwork removes a network specified by id and then returns information of the network before removing. It returns nil if the network does not exist.
	RemoveNetwork(requesterID, netID uint64) (*Network, error)
}

type Order

type Order int
const (
	OrderInvalid Order = iota
	OrderAscending
	OrderDescending
)

type Pagination

type Pagination struct {
	Offset uint32 `json:"offset"`
	Limit  uint8  `json:"limit"`
}
type Search struct {
	Key   Column `json:"key"`
	Value string `json:"value"`
}

func (*Search) Validate

func (r *Search) Validate() error

type Sort

type Sort struct {
	Key   Column `json:"key"`
	Order Order  `json:"order"`
}

func (*Sort) Validate

func (r *Sort) Validate() error

type Spec

type Spec struct {
	ID        uint64    `json:"id"`
	Component Component `json:"component"`
	Count     uint16    `json:"count"`
}

type SpecParam

type SpecParam struct {
	ComponentID uint64 `json:"component_id"`
	Count       uint16 `json:"count"`
}

func (*SpecParam) Validate

func (r *SpecParam) Validate() error

type Switch

type Switch struct {
	ID               uint64 `json:"id"`
	DPID             uint64 `json:"dpid"`
	NumPorts         uint16 `json:"n_ports"`
	FirstPort        uint16 `json:"first_port"`
	FirstPrintedPort uint16 `json:"first_printed_port"`
	Description      string `json:"description"`
}

func (*Switch) MarshalJSON

func (r *Switch) MarshalJSON() ([]byte, error)

type SwitchTransaction

type SwitchTransaction interface {
	Switches(Pagination) ([]*Switch, error)
	AddSwitch(requesterID, dpid uint64, nPorts, firstPort, firstPrintedPort uint16, desc string) (sw *Switch, duplicated bool, err error)
	// RemoveSwitch removes a switch specified by id and then returns information of the switch before removing. It returns nil if the switch does not exist.
	RemoveSwitch(requesterID, swID uint64) (*Switch, error)
}

type User

type User struct {
	ID        uint64
	Name      string
	Key       string // Key used in OTP Authentication.
	Enabled   bool
	Admin     bool
	Timestamp time.Time
}

func (*User) MarshalJSON

func (r *User) MarshalJSON() ([]byte, error)

type UserTransaction

type UserTransaction interface {
	User(name string) (*User, error)
	Users(Pagination) ([]*User, error)
	AddUser(requesterID uint64, name, key string) (user *User, duplicated bool, err error)
	// UpdateUser updates enabled and admin authorization of a user specified by id and then returns information of the user. It returns nil if the user does not exist.
	UpdateUser(requesterID, userID uint64, enabled, admin *bool) (*User, error)
	ResetOTPKey(name, key string) (ok bool, err error)
}

type VIP

type VIP struct {
	ID          uint64 `json:"id"`
	IP          string `json:"ip"` // FIXME: Use a native type.
	ActiveHost  Host   `json:"active_host"`
	StandbyHost Host   `json:"standby_host"`
	Description string `json:"description"`
}

type VIPTransaction

type VIPTransaction interface {
	VIPs(Pagination) ([]*VIP, error)
	AddVIP(requesterID, ipID, activeID, standbyID uint64, desc string) (vip *VIP, duplicated bool, err error)
	// RemoveVIP removes a VIP specified by id and then returns information of the VIP before removing. It returns nil if the VIP does not exist.
	RemoveVIP(requesterID, vipID uint64) (*VIP, error)
	// ToggleVIP swaps active host and standby host of a VIP specified by id and then returns information of the VIP. It returns nil if the VIP does not exist.
	ToggleVIP(requesterID, vipID uint64) (*VIP, error)
}

Jump to

Keyboard shortcuts

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