Back to godoc.org
github.com/mdlayher/unifi

package unifi

v0.0.0 (be73af8)
Latest Go to latest
Published: Jun 4, 2018 | License: MIT | Module: github.com/mdlayher/unifi

Overview

Package unifi implements a client for the Ubiquiti UniFi Controller v4 and v5 API.

Index

func InsecureHTTPClient

func InsecureHTTPClient(timeout time.Duration) *http.Client

InsecureHTTPClient creates a *http.Client which does not verify a UniFi Controller's certificate chain and hostname.

Please think carefully before using this client: it should only be used with self-hosted, internal UniFi Controllers.

type Alarm

type Alarm struct {
	ID        string
	APMAC     net.HardwareAddr
	APName    string
	Archived  bool
	DateTime  time.Time
	Key       string
	Message   string
	SiteID    string
	Subsystem string
}

An Alarm is an alert which is triggered when a Device becomes unavailable.

func (*Alarm) UnmarshalJSON

func (a *Alarm) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the raw JSON representation of an Alarm.

type Client

type Client struct {
	UserAgent string
	// contains filtered or unexported fields
}

A Client is a client for the Ubiquiti UniFi Controller v4 API.

Client.Login must be called and return a nil error before any additional actions can be performed with a Client.

func NewClient

func NewClient(addr string, client *http.Client) (*Client, error)

NewClient creates a new Client, using the input API address and an optional HTTP client. If no HTTP client is specified, a default one will be used.

If working with a self-hosted UniFi Controller which does not have a valid TLS certificate, InsecureHTTPClient can be used.

Client.Login must be called and return a nil error before any additional actions can be performed with a Client.

func (*Client) Alarms

func (c *Client) Alarms(siteName string) ([]*Alarm, error)

Alarms returns all of the Alarms for a specified site name.

func (*Client) Devices

func (c *Client) Devices(siteName string) ([]*Device, error)

Devices returns all of the Devices for a specified site name.

func (*Client) Login

func (c *Client) Login(username string, password string) error

Login authenticates against the UniFi Controller using the specified username and password. Login must be called and return a nil error before any additional actions can be performed.

func (*Client) Sites

func (c *Client) Sites() ([]*Site, error)

Sites returns all of the Sites managed by a UniFi Controller.

func (*Client) Stations

func (c *Client) Stations(siteName string) ([]*Station, error)

Stations returns all of the Stations for a specified site name.

type Device

type Device struct {
	ID        string
	Adopted   bool
	InformIP  net.IP
	InformURL *url.URL
	Model     string
	Name      string
	NICs      []*NIC
	Radios    []*Radio
	Serial    string
	SiteID    string
	Stats     *DeviceStats
	Uptime    time.Duration
	Version   string
}

A Device is a Ubiquiti UniFi device, such as a UniFi access point.

func (*Device) UnmarshalJSON

func (d *Device) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the raw JSON representation of a Device.

type DeviceStats

type DeviceStats struct {
	TotalBytes float64
	All        *WirelessStats
	Guest      *WirelessStats
	User       *WirelessStats
	Uplink     *WiredStats
}

DeviceStats contains device network activity statistics.

func (*DeviceStats) String

func (s *DeviceStats) String() string

type NIC

type NIC struct {
	MAC  net.HardwareAddr
	Name string
}

A NIC is a wired ethernet network interface, attached to a Device.

type Radio

type Radio struct {
	BuiltInAntenna     bool
	BuiltInAntennaGain int
	MaxTXPower         int
	MinTXPower         int
	Name               string
	Radio              string
	Stats              *RadioStationsStats
}

A Radio is a wireless radio, attached to a Device.

type RadioStationsStats

type RadioStationsStats struct {
	NumberStations      int
	NumberGuestStations int
	NumberUserStations  int
}

RadioStationsStats contains Station statistics for a Radio.

type Site

type Site struct {
	ID          string `json:"_id"`
	Description string `json:"desc"`
	Name        string `json:"name"`
	NumAPs      int    `json:"num_ap"`
	NumStations int    `json:"num_sta"`
	Role        string `json:"role"`
}

A Site is a physical location with UniFi devices managed by a UniFi Controller.

type Station

type Station struct {
	ID              string
	APMAC           net.HardwareAddr
	AssociationTime time.Time
	Channel         int
	FirstSeen       time.Time
	Hostname        string // Device-provided name
	IdleTime        time.Duration
	IP              net.IP
	IsWired         bool
	LastSeen        time.Time
	MAC             net.HardwareAddr
	RoamCount       int
	Name            string // Unifi-set name
	Noise           int
	RSSI            int
	SiteID          string
	Stats           *StationStats
	Uptime          time.Duration
	UserID          string
}

A Station is a client connected to a UniFi access point.

func (*Station) UnmarshalJSON

func (s *Station) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the raw JSON representation of a Station.

type StationStats

type StationStats struct {
	ReceiveBytes    int64
	ReceivePackets  int64
	ReceiveRate     int
	TransmitBytes   int64
	TransmitPackets int64
	TransmitPower   int
	TransmitRate    int
}

StationStats contains station network activity statistics.

type WiredStats

type WiredStats struct {
	ReceiveBytes    float64
	ReceivePackets  float64
	TransmitBytes   float64
	TransmitPackets float64
}

WiredStats contains wired device network activity statistics.

func (*WiredStats) String

func (s *WiredStats) String() string

type WirelessStats

type WirelessStats struct {
	ReceiveBytes    float64
	ReceivePackets  float64
	TransmitBytes   float64
	TransmitDropped float64
	TransmitPackets float64
}

WirelessStats contains wireless device network activity statistics.

func (*WirelessStats) String

func (s *WirelessStats) String() string
Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
f or F : Jump to identifier