unifi: github.com/mdlayher/unifi Index | Files

package unifi

import "github.com/mdlayher/unifi"

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

Index

Package Files

alarms.go client.go devices.go sites.go stations.go

func InsecureHTTPClient Uses

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 Uses

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 Uses

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

UnmarshalJSON unmarshals the raw JSON representation of an Alarm.

type Client Uses

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 Uses

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 Uses

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

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

func (*Client) Devices Uses

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

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

func (*Client) Login Uses

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 Uses

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

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

func (*Client) Stations Uses

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

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

type Device Uses

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 Uses

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

UnmarshalJSON unmarshals the raw JSON representation of a Device.

type DeviceStats Uses

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

DeviceStats contains device network activity statistics.

func (*DeviceStats) String Uses

func (s *DeviceStats) String() string

type NIC Uses

type NIC struct {
    MAC  net.HardwareAddr
    Name string
}

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

type Radio Uses

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 Uses

type RadioStationsStats struct {
    NumberStations      int
    NumberGuestStations int
    NumberUserStations  int
}

RadioStationsStats contains Station statistics for a Radio.

type Site Uses

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 Uses

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 Uses

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

UnmarshalJSON unmarshals the raw JSON representation of a Station.

type StationStats Uses

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 Uses

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

WiredStats contains wired device network activity statistics.

func (*WiredStats) String Uses

func (s *WiredStats) String() string

type WirelessStats Uses

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

WirelessStats contains wireless device network activity statistics.

func (*WirelessStats) String Uses

func (s *WirelessStats) String() string

Package unifi imports 10 packages (graph) and is imported by 2 packages. Updated 2018-06-07. Refresh now. Tools for package owners.