api

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

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

Go to latest
Published: Sep 12, 2025 License: GPL-3.0 Imports: 12 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

NormalizeName is a helper for normalization of the devices name into an acceptable format for the Kentik API device endpoints.

Types

type Addr

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

type AllDeviceWrapper

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

AllDeviceWrapper is a wrapper around a list of Device instances, for endpoints that return a one or more Devices nested in a JSON structure.

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

SendFlow sends the provided buffer containing a gzipped, cap'n proto packed, representation of flows to the provided url.

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"`
}

Column is the JSON representation of a custom column from the Kentik API device endpoints.

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"`
}

Device is the JSON representation of a device from the Kentik API device endpoints.

func (*Device) ClientID

func (d *Device) ClientID() string

ClientID creates the encoding of Client ID which may be used for authentication purposes for sending data on behalf of the device.

type DeviceCreate

type DeviceCreate struct {
	Name        string `json:"device_name"`
	Type        string `json:"device_type"`
	Subtype     string `json:"device_subtype"`
	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"`

	CdnAttr string `json:"cdn_attr"`

	// IPs is the associated sending IP Address(es) for the device. For devices that do not have a set of permanent IP
	// addresses (i.e. cloud devices), this should not be set and AllowNoIP should be set to true.
	IPs []net.IP `json:"sending_ips"`

	// AllowNoIP is a flag to bypass the requirement of at least one IP address for creation of a device. This is only
	// applicable for devices that do not have a set of permanent IP addresses, such as cloud devices.
	AllowNoIP bool `json:"-"`

	// ExportId the optionally associated Cloud Exporter which first received flow and is creating the device.
	ExportId int `json:"cloud_export_id,omitempty"`

	// Region is the optionally associated cloud region for this device
	Region string `json:"cloud_region,omitempty"`

	// Zone is the optionally associated cloud zone for this device
	Zone string `json:"cloud_zone,omitempty"`
}

DeviceCreate is the payload JSON representation wrapper for creating a Device.

func (*DeviceCreate) NormalizeName

func (c *DeviceCreate) NormalizeName()

type DeviceWrapper

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

DeviceWrapper is a wrapper around the Device, for endpoints that return a single Device nested away next to other information.

type DevicesFilter

type DevicesFilter struct {

	// FilterCloud restricts the results to devices that were NOT created by cloud exporters.
	FilterCloud bool `schema:"filterCloud"`

	// CloudOnly restricts the results to ONLY devices created by cloud exporters.
	CloudOnly bool `schema:"cloudOnly"`

	// Subtypes restricts the results to only specific device subtypes. An empty or nil instance indicates no filtering
	// of results.
	Subtypes []string `schema:"subtypes"`

	// AugmentWith specifies which additional, potentially large, payload fields should be hydrated. Some supported
	// options are:
	//   - customColumns -
	//   - plan - The associated Plan for the device
	AugmentWith []string `schema:"augmentWith"`

	// Columns specifies additional, metadata fields i.e. table columns, to retrieve as part of the query. Examples
	// include id, device_name, etc.
	Columns []string `schema:"columns"`
}

DevicesFilter is a set of arguments that can be used to filter the devices queried along with the hydration of the resulting JSON.

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"`
}

Plan is the JSON representation of a Kentik License Plan that describes the services provided by Kentik (i.e. permitted data, maximum number of devices, maximum number of FPS, etc.).

type SiteAndDeviceCreate

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

SiteAndDeviceCreate is the payload JSON representation wrapper for creating a Site and 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"`
}

SiteCreate is the payload JSON representation wrapper for creating a Site.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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