api

package
v0.0.0-...-0ef1e8c Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EXPORT_STATUS_OK    = "OK"
	EXPORT_STATUS_ERROR = "ERROR"
	EXPORT_STATUS_START = "START"
	EXPORT_STATUS_HALT  = "HALT"
)

Variables

This section is empty.

Functions

func GetInterfaceUpdates

func GetInterfaceUpdates(nif *net.Interface) (map[string]InterfaceUpdate, error)

func IsErrorWithStatusCode

func IsErrorWithStatusCode(err error, code int) bool

func NormalizeName

func NormalizeName(name string) string

Types

type Addr

type Addr struct {
	Address string `json:"address"`
	Netmask string `json:"netmask"`
}

type AllDeviceWrapper

type AllDeviceWrapper struct {
	Devices []*Device `json:"devices"`
}

type Client

type Client struct {
	ClientConfig

	*http.Client
	// contains filtered or unexported fields
}

func NewClient

func NewClient(config ClientConfig) *Client

func (*Client) CreateDevice

func (c *Client) CreateDevice(create *DeviceCreate) (*Device, error)

func (*Client) CreateDeviceAndSite

func (c *Client) CreateDeviceAndSite(siteDevCreate *SiteAndDeviceCreate) (*Device, error)

func (*Client) GetAllDevices

func (c *Client) GetAllDevices() ([]*Device, error)

func (*Client) GetDeviceByID

func (c *Client) GetDeviceByID(did int) (*Device, error)

func (*Client) GetDeviceByIF

func (c *Client) GetDeviceByIF(name string) (*Device, error)

func (*Client) GetDeviceByIP

func (c *Client) GetDeviceByIP(ip net.IP) (*Device, error)

func (*Client) GetDeviceByName

func (c *Client) GetDeviceByName(name string) (*Device, error)

func (*Client) GetDevices

func (c *Client) GetDevices(filter *DevicesFilter) ([]*Device, error)

func (*Client) GetInterfaces

func (c *Client) GetInterfaces(did int) ([]Interface, error)

func (*Client) SendDNS

func (c *Client) SendDNS(url string, buf *bytes.Buffer) error

func (*Client) SendFlow

func (c *Client) SendFlow(url string, buf *bytes.Buffer) error

func (*Client) UpdateExportStatus

func (c *Client) UpdateExportStatus(status *ExportStatus) error

/internal/cloudExport/status/:id body expects `{status: string, message: string}`

func (*Client) UpdateInterfaces

func (c *Client) UpdateInterfaces(dev *Device, nif *net.Interface) error

func (*Client) UpdateInterfacesDirectly

func (c *Client) UpdateInterfacesDirectly(dev *Device, updates map[string]InterfaceUpdate) error

type ClientConfig

type ClientConfig struct {
	Email   string
	Token   string
	Timeout time.Duration
	Retries int
	API     *url.URL
	Proxy   *url.URL

	Logger interface{}
}

type Column

type Column struct {
	ID   uint64 `json:"field_id,string"`
	Name string `json:"col_name"`
	Type string `json:"col_type"`
}

func (Column) MarshalFlag

func (c Column) MarshalFlag() (string, error)

func (*Column) UnmarshalFlag

func (c *Column) UnmarshalFlag(value string) error

type DNSQuestion

type DNSQuestion struct {
	Name string
	Host []byte
}

func (*DNSQuestion) DecodeMsg

func (z *DNSQuestion) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*DNSQuestion) EncodeMsg

func (z *DNSQuestion) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*DNSQuestion) MarshalMsg

func (z *DNSQuestion) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*DNSQuestion) Msgsize

func (z *DNSQuestion) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*DNSQuestion) UnmarshalMsg

func (z *DNSQuestion) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type DNSResourceRecord

type DNSResourceRecord struct {
	Name  string // unused
	CNAME string
	IP    []byte
	TTL   uint32
}

func (*DNSResourceRecord) DecodeMsg

func (z *DNSResourceRecord) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*DNSResourceRecord) EncodeMsg

func (z *DNSResourceRecord) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*DNSResourceRecord) MarshalMsg

func (z *DNSResourceRecord) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*DNSResourceRecord) Msgsize

func (z *DNSResourceRecord) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*DNSResourceRecord) UnmarshalMsg

func (z *DNSResourceRecord) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type DNSResponse

type DNSResponse struct {
	Question DNSQuestion
	Answers  []DNSResourceRecord
}

func (*DNSResponse) DecodeMsg

func (z *DNSResponse) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*DNSResponse) EncodeMsg

func (z *DNSResponse) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*DNSResponse) MarshalMsg

func (z *DNSResponse) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*DNSResponse) Msgsize

func (z *DNSResponse) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*DNSResponse) UnmarshalMsg

func (z *DNSResponse) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Device

type Device struct {
	ID          int      `json:"id,string"`
	Name        string   `json:"device_name"`
	Type        string   `json:"device_type"`
	Subtype     string   `json:"device_subtype"`
	Description string   `json:"device_description"`
	IP          net.IP   `json:"ip"`
	SampleRate  int      `json:"device_sample_rate,string"`
	BgpType     string   `json:"device_bgp_type"`
	Plan        Plan     `json:"plan"`
	CdnAttr     string   `json:"cdn_attr"`
	MaxFlowRate int      `json:"max_flow_rate"`
	CompanyID   int      `json:"company_id,string"`
	Customs     []Column `json:"custom_column_data,omitempty"`
}

func (*Device) ClientID

func (d *Device) ClientID() string

type DeviceCreate

type DeviceCreate struct {
	Name        string   `json:"device_name"`
	Type        string   `json:"device_type"`
	Description string   `json:"device_description"`
	SampleRate  int      `json:"device_sample_rate,string"`
	BgpType     string   `json:"device_bgp_type"`
	PlanID      int      `json:"plan_id,omitempty"`
	SiteID      int      `json:"site_id,omitempty"`
	IPs         []net.IP `json:"sending_ips"`
	AllowNoIP   bool     `json:"-"`
	CdnAttr     string   `json:"cdn_attr"`
	ExportId    int      `json:"cloud_export_id,omitempty"`
	Subtype     string   `json:"device_subtype"`
	Region      string   `json:"cloud_region,omitempty"`
	Zone        string   `json:"cloud_zone,omitempty"`
}

func (*DeviceCreate) NormalizeName

func (c *DeviceCreate) NormalizeName()

type DeviceWrapper

type DeviceWrapper struct {
	Device *Device `json:"device"`
}

type DevicesFilter

type DevicesFilter struct {
	FilterCloud bool     `schema:"filterCloud"`
	CloudOnly   bool     `schema:"cloudOnly"`
	Subtypes    []string `schema:"subtypes"`
	AugmentWith []string `schema:"augmentWith"`
	Columns     []string `schema:"columns"`
}

type Error

type Error struct {
	StatusCode int
	Message    string
}

func (*Error) Error

func (e *Error) Error() string

type ExportStatus

type ExportStatus struct {
	ID      int    `json:"export_id"`
	Status  string `json:"status"`
	Message string `json:"message"`
}

func (*ExportStatus) Set

func (e *ExportStatus) Set(s string, m string) *ExportStatus

type Interface

type Interface struct {
	ID      uint64 `json:"id,string"`
	Index   uint64 `json:"snmp_id,string"`
	Alias   string `json:"snmp_alias"`
	Desc    string `json:"interface_description"`
	Address string `json:"interface_ip"`
	Netmask string `json:"interface_ip_netmask"`
	Addrs   []Addr `json:"secondary_ips"`
}

type InterfaceUpdate

type InterfaceUpdate struct {
	Index   uint64 `json:"index,string"`
	Alias   string `json:"alias"`
	Desc    string `json:"desc"`
	Speed   uint64 `json:"speed"`
	Type    uint64 `json:"type"`
	Address string `json:"address"`
	Netmask string `json:"netmask"`
	Addrs   []Addr `json:"alias_address"`
}

type Plan

type Plan struct {
	ID   uint64 `json:"id"`
	Name string `json:"name"`
}

type SiteAndDeviceCreate

type SiteAndDeviceCreate struct {
	Site   *SiteCreate   `json:"site"`
	Device *DeviceCreate `json:"device"`
}

type SiteCreate

type SiteCreate struct {
	Title   string `json:"title"`
	City    string `json:"city,omitempty"`
	Region  string `json:"region,omitempty"`
	Country string `json:"country,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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