mistclient

package module
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2025 License: MIT Imports: 15 Imported by: 0

README

mistclient

Go Reference

mistclient is a Go client library for interacting with the Juniper Mist API.

This package was created with an initial focus on observability, providing access to endpoints useful for building monitoring and exporting tools (e.g. a Prometheus exporter).

Features

  • Typed Go models for all supported API responses.
  • Support for both REST and WebSocket streaming endpoints.
  • Context-aware for handling cancellations and timeouts.
  • Configurable logger for integrating with your application's logging.

Requirements

  • Go 1.22 or newer is required. This library uses features of Go's for loop semantics that were introduced in version 1.22. Using an older version of Go may lead to subtle concurrency bugs.

Installation

go get github.com/gregwight/mistclient

Usage

First, you'll need a Mist API token. You can generate one from the Mist Dashboard under My Account > API Tokens. The following examples assume you have set the MIST_API_KEY and MIST_ORG_ID environment variables.

Basic API Calls

Here's a simple example of how to create a client and list the sites in an organization using a standard REST API endpoint.

package main

import (
    "context"
    "fmt"
    "log"
    "log/slog"
    "os"
    "time"

    "github.com/gregwight/mistclient"
)

func main() {
    apiKey := os.Getenv("MIST_API_KEY")
    if apiKey == "" {
        log.Fatal("MIST_API_KEY environment variable not set")
    }
    orgID := os.Getenv("MIST_ORG_ID")
    if orgID == "" {
        log.Fatal("MIST_ORG_ID environment variable not set")
    }

    // Create a new client
    client, err := mistclient.New(&mistclient.Config{
        BaseURL: "https://api.mist.com", // Or your regional cloud, e.g., https://api.eu.mist.com
        APIKey:  apiKey,
    }, slog.Default())
    if err != nil {
        log.Fatalf("Error creating client: %v", err)
    }
    
    // Get all sites for the organization
    sites, err := client.GetOrgSites(orgID)
    if err != nil {
        log.Fatalf("Error getting sites: %v", err)
    }

    fmt.Printf("Found %d sites in organization %s:\n", len(sites), orgID)
    for _, site := range sites {
        fmt.Printf("- %s (ID: %s)\n", site.Name, site.ID)
    }

    // Example: Streaming device statistics for a specific site
    // For this to work, you must have at least one site. We'll use the first one found.
    if len(sites) > 0 {
        siteID := sites[0].ID

        // Create a context that will be cancelled after 30 seconds
        ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
        defer cancel()

        fmt.Printf("\nStreaming device stats for site %s (%s) for 30 seconds...\n", sites[0].Name, siteID)

        // Start streaming device stats
        statsChan, err := client.StreamSiteDeviceStats(ctx, siteID)
        if err != nil {
            log.Fatalf("Error starting device stats stream: %v", err)
        }

        // Process messages from the stream until the context is cancelled
        for stat := range statsChan {
            fmt.Printf("Received update for device %s (%s): Status=%s, Uptime=%s\n",
                stat.Name, stat.Mac, stat.Status, time.Duration(stat.Uptime).String())
        }

        fmt.Println("Stream finished.")
    }
}
Configuring Logging

The client uses the standard log/slog library. You can pass in your own configured *slog.Logger to the New() constructor.

This package also includes a custom TRACE log level, which is more verbose than DEBUG. This level is used for logging sensitive or very detailed information, such as raw API request and response bodies, which can be useful for detailed troubleshooting.

WARNING: TRACE logs may include sensitive data (e.g., Authorization headers/tokens, device MACs, client identifiers). Enable TRACE only in secure environments, ensure logs are access-controlled, and consider redacting sensitive fields either in your logger (ReplaceAttr) or via client-side options if available.

NOTE: The handler options returned by NewTraceHandlerOptions() enable AddSource, causing the logger wrapper to preserve the original caller location. Thus file:line point to the calling code (not the wrapper).

Here is an example of how to configure a logger to show these TRACE messages:

package main

import (
    "log/slog"
    "os"

    "github.com/gregwight/mistclient"
)

func main() {
    // Get a pointer to a slog.HandlerOptions with the TRACE level set.
    optionsTrace := mistclient.NewTraceHandlerOptions()

    // Create a logger ensuring this options pointer is passed to the handler.
    logger := slog.New(slog.NewTextHandler(os.Stdout, optionsTrace))

    // Pass the configured logger when creating a new client.
    client, err := mistclient.New(&mistclient.Config{
         BaseURL: "https://api.mist.com",
         APIKey:  os.Getenv("MIST_API_KEY"),
    }, logger)
    if err != nil {
        logger.Error("failed to create client", "err", err)
        return
    }

    // Any calls made with this client will now produce TRACE logs.
    if _, err := client.GetSelf(); err != nil {
        logger.Error("GetSelf failed", "err", err)
    }
}

## Supported API Endpoints

The client is organized by Mist API resources (e.g., Self, Organization, Site).

### Self Endpoints
| Method Signature | API Endpoint |
|---|---|
| `GetSelf() (Self, error)` | `GET /api/v1/self` |

### Organization Endpoints
| Method Signature | API Endpoint |
|---|---|
| `GetOrgSites(orgID string) ([]Site, error)` | `GET /api/v1/orgs/:org_id/sites` |
| `CountOrgTickets(orgID string) (Count, error)` | `GET /api/v1/orgs/:org_id/tickets/count` |
| `CountOrgAlarms(orgID string) (Count, error)` | `GET /api/v1/orgs/:org_id/alarms/count` |

### Site Endpoints
| Method Signature | API Endpoint | Type |
|---|---|---|
| `GetSiteStats(siteID string) (SiteStat, error)` | `GET /api/v1/sites/:site_id/stats` | REST |
| `GetSiteDevices(siteID string) ([]Device, error)` | `GET /api/v1/sites/:site_id/devices` | REST |
| `GetSiteDeviceStats(siteID string) ([]DeviceStat, error)` | `GET /api/v1/sites/:site_id/stats/devices` | REST |
| `GetSiteClientStats(siteID string) ([]Client, error)` | `GET /api/v1/sites/:site_id/stats/clients` | REST |
| `StreamSiteDevices(ctx context.Context, siteID string) (<-chan Device, error)` | `stream /sites/:site_id/devices` | WebSocket |
| `StreamSiteDeviceStats(ctx context.Context, siteID string) (<-chan DeviceStat, error)` | `stream /sites/:site_id/stats/devices` | WebSocket |
| `StreamSiteClientStats(ctx context.Context, siteID string) (<-chan Client, error)` | `stream /sites/:site_id/stats/clients` | WebSocket |

## Testing

To run the test suite:
```sh
go test -v ./...

Documentation

Overview

Package mistclient provides a client for interacting Juniper's MIST API.

It has been written with an initial focus on observability, with the currently supported endpoints chosen for integration with a Prometheus exporter to produce operational metrics.

The client currently supports the following root endpoint:

  • /api/v1/self

The client currently supports the following Organization endpoints:

  • /api/v1/orgs/:org_id/sites
  • /api/v1/orgs/:org_id/tickets/count
  • /api/v1/orgs/:org_id/alarms/count

The client currently supports the following Site endpoints:

  • /api/v1/sites/:site_id/stats
  • /api/v1/sites/:site_id/devices
  • /api/v1/sites/:site_id/stats/devices
  • /api/v1/sites/:site_id/stats/clients

Index

Constants

View Source
const LevelTrace = slog.Level(-8)

LevelTrace is a custom log level for verbose, trace-level logging, for example, to log API request and response bodies.

Variables

View Source
var LevelNames = map[slog.Level]string{
	LevelTrace: "TRACE",
}

LevelNames is a map of custom log levels to their string representation.

Functions

func NewTraceHandlerOptions added in v1.1.1

func NewTraceHandlerOptions() *slog.HandlerOptions

NewTraceHandlerOptions is a constructor for generating a handler options with TRACE logging enabled.

Types

type APIClient added in v0.0.2

type APIClient struct {
	// contains filtered or unexported fields
}

APIClient represents the API client.

func New added in v0.0.2

func New(config *Config, logger *slog.Logger) (*APIClient, error)

New returns an instance of the API client.

func (*APIClient) ConnectWebSocket added in v0.0.6

func (c *APIClient) ConnectWebSocket() (*websocket.Conn, error)

ConnectWebSocket opens a websocket connection to the appropriate websocket endpoint.

func (*APIClient) CountOrgAlarms added in v0.0.2

func (c *APIClient) CountOrgAlarms(orgID string) (map[string]int, error)

CountOrgAlarms returns a map of counts of all alarms related to an organisation, keyed by their type.

func (*APIClient) CountOrgTickets added in v0.0.2

func (c *APIClient) CountOrgTickets(orgID string) (map[TicketStatus]int, error)

CountOrgTickets returns a map of counts of all tickets related to an organisation, keyed by their status.

func (*APIClient) Delete added in v0.0.2

func (c *APIClient) Delete(u *url.URL) (*http.Response, error)

Delete is a convenience function for performing HTTP DELETE requests using the API client.

func (*APIClient) Get added in v0.0.2

func (c *APIClient) Get(u *url.URL) (*http.Response, error)

Get is a convenience function for performing HTTP GET requests using the API client.

func (*APIClient) GetOrgSites added in v0.0.2

func (c *APIClient) GetOrgSites(orgID string) ([]Site, error)

GetOrgSites returns a list of all sites configured within an organisation.

func (*APIClient) GetSelf added in v0.0.2

func (c *APIClient) GetSelf() (Self, error)

GetSelf returns a ‘whoami’ and privileges of the account making the request

func (*APIClient) GetSiteClientStats added in v0.0.6

func (c *APIClient) GetSiteClientStats(siteID string) ([]Client, error)

GetSiteClientStats fetches and returns a list of all clients configured at a site

func (*APIClient) GetSiteDeviceStats added in v0.0.2

func (c *APIClient) GetSiteDeviceStats(siteID string) ([]DeviceStat, error)

GetSiteDeviceStats fetches and returns a list of all devices configured at a site, supplemented with operational statistics

func (*APIClient) GetSiteDevices added in v0.0.2

func (c *APIClient) GetSiteDevices(siteID string) ([]Device, error)

GetSiteDevices fetches and returns a list of all devices configured at a site

func (*APIClient) GetSiteStats added in v0.0.6

func (c *APIClient) GetSiteStats(siteID string) (SiteStat, error)

GetSiteStats fetches a site's operational statistics

func (*APIClient) GetWebsocketURL added in v0.0.6

func (c *APIClient) GetWebsocketURL() (*url.URL, error)

GetWebsocketURL maps the base API URL into the appropriate websocket endpoint. See https://www.juniper.net/documentation/us/en/software/mist/api/http/guides/websockets/hosts

func (*APIClient) ListOrgDevices added in v1.3.0

func (c *APIClient) ListOrgDevices(orgID string) (map[string]string, error)

ListOrgDevices returns a map of device MAC addresses to names.

func (*APIClient) Post added in v0.0.2

func (c *APIClient) Post(u *url.URL, body interface{}) (*http.Response, error)

Post is a convenience function for performing HTTP POST requests using the API client.

func (*APIClient) Put added in v0.0.2

func (c *APIClient) Put(u *url.URL, body interface{}) (*http.Response, error)

Put is a convenience function for performing HTTP PUT requests using the API client.

func (*APIClient) StreamSiteClientStats added in v0.0.6

func (c *APIClient) StreamSiteClientStats(ctx context.Context, siteID string) (<-chan StreamedClientStat, error)

StreamSiteClientStats opens a websocket connection and subscribes to the client statistics stream

func (*APIClient) StreamSiteDeviceStats added in v0.0.6

func (c *APIClient) StreamSiteDeviceStats(ctx context.Context, siteID string) (<-chan StreamedDeviceStat, error)

StreamSiteDeviceStats opens a websocket connection and subscribes to the device statistics stream

func (*APIClient) StreamSiteDevices added in v0.0.6

func (c *APIClient) StreamSiteDevices(ctx context.Context, siteID string) (<-chan Device, error)

StreamSiteDevices opens a websocket connection and subscribes to the site devices stream

func (*APIClient) Subscribe added in v0.0.6

func (c *APIClient) Subscribe(ctx context.Context, channel string) (<-chan WebsocketMessage, error)

Subscribe sends a subscription request over a new websocket connection and returns a channel over which received messages will be sent.

func (*APIClient) Unsubscribe added in v0.0.6

func (c *APIClient) Unsubscribe(conn *websocket.Conn, channel string) error

Unsubscribe sends an unsubscribe request over an existing websocket connection.

type Airwatch added in v0.0.2

type Airwatch struct {
	Authorized bool `json:"authorized,omitempty"`
}

Airwatch holds information regarding the 'airwatch` status of a Client

type Alarm

type Alarm struct {
	ID             string   `json:"id,omitempty"`
	Timestamp      UnixTime `json:"timestamp,omitzero"`
	SiteID         string   `json:"site_id,omitempty"`
	Type           string   `json:"type,omitempty"`
	Count          int      `json:"count,omitempty"`
	Acked          bool     `json:"acked,omitempty"`
	AckedTime      UnixTime `json:"acked_time,omitzero"`
	AckedAdminName string   `json:"ack_admin_name,omitempty"`
	AckedAdminID   string   `json:"ack_admin_id,omitempty"`
	Note           string   `json:"note,omitempty"`
}

Alarm represents an alarm created by an error condition

type Client

type Client struct {
	Mac         string     `json:"mac,omitempty"`
	LastSeen    UnixTime   `json:"last_seen,omitzero"`
	Username    string     `json:"username,omitempty"`
	Hostname    string     `json:"hostname,omitempty"`
	OS          string     `json:"os,omitempty"`
	Manufacture string     `json:"manufacture,omitempty"`
	Family      string     `json:"family,omitempty"`
	Model       string     `json:"model,omitempty"`
	IP          netip.Addr `json:"ip,omitempty"`
	IP6         netip.Addr `json:"ip6,omitempty"`
	APMac       string     `json:"ap_mac,omitempty"`
	APID        string     `json:"ap_id,omitempty"`
	SSID        string     `json:"ssid,omitempty"`
	WLANID      string     `json:"wlan_id,omitempty"`
	PSKID       string     `json:"psk_id,omitempty"`

	Uptime      Seconds    `json:"uptime,omitempty"`
	Idletime    Seconds    `json:"idle_time,omitempty"`
	PowerSaving bool       `json:"power_saving,omitempty"`
	Band        Radio      `json:"band,omitempty"`
	Proto       Dot11Proto `json:"proto,omitempty"`
	KeyMgmt     string     `json:"key_mgmt,omitempty"`
	DualBand    bool       `json:"dual_band,omitempty"`

	Channel        int     `json:"channel,omitempty"`
	VLANID         string  `json:"vlan_id,omitempty"`
	AirspaceIfname string  `json:"airespace_ifname,omitempty"`
	RSSI           int     `json:"rssi,omitempty"`
	SNR            int     `json:"snr,omitempty"`
	TxRate         float32 `json:"tx_rate,omitempty"`
	RxRate         float32 `json:"rx_rate,omitempty"`

	TxBytes   int `json:"tx_bytes,omitempty"`
	TxBps     int `json:"tx_bps,omitempty"`
	TxPackets int `json:"tx_packets,omitempty"`
	TxRetries int `json:"tx_retries,omitempty"`
	RxBytes   int `json:"rx_bytes,omitempty"`
	RxBps     int `json:"rx_bps,omitempty"`
	RxPackets int `json:"rx_packets,omitempty"`
	RxRetries int `json:"rx_retries,omitempty"`

	MapID          string  `json:"map_id,omitempty"`
	X              float32 `json:"x,omitempty"`
	Y              float32 `json:"y,omitempty"`
	Xm             float32 `json:"x_m,omitempty"`
	Ym             float32 `json:"y_m,omitempty"`
	NumLocatingAPs int     `json:"num_locating_aps,omitempty"`

	IsGuest  bool     `json:"is_guest,omitempty"`
	Guest    Guest    `json:"guest,omitempty"`
	Airwatch Airwatch `json:"airwatch,omitempty"`
	TTL      int      `json:"_ttl,omitempty"`
}

Client represents an end-user device connected to the radio of a Device

type Config

type Config struct {
	BaseURL string        `yaml:"base_url,omitempty"`
	APIKey  string        `yaml:"api_key,omitempty"`
	Timeout time.Duration `yaml:"timeout,omitempty"`
}

Config represents the API access parameters.

type Device

type Device struct {
	ID           string     `json:"id,omitempty"`
	Name         string     `json:"name,omitempty"`
	Type         DeviceType `json:"type,omitempty"`
	Model        string     `json:"model,omitempty"`
	Serial       string     `json:"serial,omitempty"`
	HwRev        string     `json:"hw_rev,omitempty"`
	Mac          string     `json:"mac,omitempty"`
	OrgID        string     `json:"org_id,omitempty"`
	SiteID       string     `json:"site_id,omitempty"`
	ModifiedTime UnixTime   `json:"modified_time,omitzero"`
	CreatedTime  UnixTime   `json:"created_time,omitzero"`
}

Device represents a physical piece of network equipment

type DeviceStat

type DeviceStat struct {
	Device

	CPUUtil          int          `json:"cpu_util,omitempty"`
	EnvStat          EnvStat      `json:"env_stat,omitempty"`
	LastSeen         UnixTime     `json:"last_seen,omitzero"`
	NumClients       int          `json:"num_clients,omitempty"`
	Version          string       `json:"version,omitempty"`
	Status           DeviceStatus `json:"status,omitempty"`
	IP               netip.Addr   `json:"ip,omitempty"`
	ExtIP            netip.Addr   `json:"ext_ip,omitempty"`
	NumWLANs         int          `json:"num_wlans,omitempty"`
	Uptime           Seconds      `json:"uptime,omitempty"`
	TxBps            int          `json:"tx_bps,omitempty"`
	RxBps            int          `json:"rx_bps,omitempty"`
	TxBytes          int          `json:"tx_bytes,omitempty"`
	RxBytes          int          `json:"rx_bytes,omitempty"`
	TxPkts           int          `json:"tx_pkts,omitempty"`
	RxPkts           int          `json:"rx_pkts,omitempty"`
	PowerSrc         string       `json:"power_src,omitempty"`
	PowerBudget      int          `json:"power_budget,omitempty"`
	PowerOpMode      string       `json:"power_op_mode,omitempty"`
	PowerConstrained bool         `json:"power_constrained,omitempty"`

	RadioStats map[RadioConfig]RadioStat `json:"radio_stat,omitempty"`
}

DeviceStat holds operational statistics and data relating to a Device

type DeviceStatus

type DeviceStatus int

DeviceStatus defines the possible values for a device status.

const (
	Connected DeviceStatus = iota + 1
	Disconnected
	Restarting
	Upgrading
)

func DeviceStatusFromString

func DeviceStatusFromString(ds string) DeviceStatus

DeviceStatusFromString creates a DeviceStatus from the associated string representation.

func (DeviceStatus) MarshalJSON added in v0.0.6

func (ds DeviceStatus) MarshalJSON() ([]byte, error)

func (DeviceStatus) MarshalText added in v1.2.0

func (ds DeviceStatus) MarshalText() ([]byte, error)

func (DeviceStatus) String

func (ds DeviceStatus) String() string

func (*DeviceStatus) UnmarshalJSON

func (ds *DeviceStatus) UnmarshalJSON(b []byte) error

func (*DeviceStatus) UnmarshalText added in v1.2.0

func (ds *DeviceStatus) UnmarshalText(b []byte) error

type DeviceType

type DeviceType int

DeviceType defines the possible values fo a device types.

const (
	AP DeviceType = iota + 1
	Switch
	Gateway
)

func DeviceTypeFromString

func DeviceTypeFromString(dt string) DeviceType

DeviceTypeFromString creates a DeviceType from the associated string representation.

func (DeviceType) MarshalJSON added in v0.0.6

func (dt DeviceType) MarshalJSON() ([]byte, error)

func (DeviceType) MarshalText added in v1.2.0

func (dt DeviceType) MarshalText() ([]byte, error)

func (DeviceType) String

func (dt DeviceType) String() string

func (*DeviceType) UnmarshalJSON

func (dt *DeviceType) UnmarshalJSON(b []byte) error

func (*DeviceType) UnmarshalText added in v1.2.0

func (dt *DeviceType) UnmarshalText(b []byte) error

type Dot11Proto added in v0.0.6

type Dot11Proto int

Dot11Proto defines the possible values for the dot11 protocol

const (
	A Dot11Proto = iota + 1
	AC
	AX
	B
	G
	N
)

func Dot11ProtoFromString added in v0.0.6

func Dot11ProtoFromString(dp string) Dot11Proto

Dot11ProtoFromString creates a Dot11Proto from the associated string representation.

func (Dot11Proto) MarshalJSON added in v0.0.6

func (dp Dot11Proto) MarshalJSON() ([]byte, error)

func (Dot11Proto) MarshalText added in v1.2.0

func (dp Dot11Proto) MarshalText() ([]byte, error)

func (Dot11Proto) String added in v0.0.6

func (dp Dot11Proto) String() string

func (*Dot11Proto) UnmarshalJSON added in v0.0.6

func (dp *Dot11Proto) UnmarshalJSON(b []byte) error

func (*Dot11Proto) UnmarshalText added in v0.0.6

func (dp *Dot11Proto) UnmarshalText(b []byte) error

type EnvStat added in v0.0.6

type EnvStat struct {
	AccelX       float32 `json:"accel_x,omitempty"`
	AccelY       float32 `json:"accel_y,omitempty"`
	AccelZ       float32 `json:"accel_z,omitempty"`
	AmbientTemp  int     `json:"ambient_temp,omitempty"`
	Attitude     int     `json:"attitude,omitempty"`
	CPUTemp      int     `json:"cpu_temp,omitempty"`
	Humidity     int     `json:"humidity,omitempty"`
	MagneX       float32 `json:"magne_x,omitempty"`
	MagneY       float32 `json:"magne_y,omitempty"`
	MagneZ       float32 `json:"magne_z,omitempty"`
	Pressure     float32 `json:"pressure,omitempty"`
	VcoreVoltage int     `json:"vcore_voltage,omitempty"`
}

EnvStat holds operational data relating to a device's environment

type Guest added in v0.0.2

type Guest struct {
	Authorized             bool     `json:"authorized,omitempty"`
	AuthorizedTime         UnixTime `json:"authorized_time,omitzero"`
	AuthorizedExpiringTime UnixTime `json:"authorized_expiring_time,omitzero"`

	Name      string `json:"name,omitempty"`
	Email     string `json:"email,omitempty"`
	Company   string `json:"company,omitempty"`
	Field1    string `json:"field1,omitempty"`
	CrossSite bool   `json:"cross_site,omitempty"`
}

Guest holds data relating to the `guest` status of a Client

type Logger added in v1.1.0

type Logger struct {
	*slog.Logger
}

Logger is a wrapper around slog.Logger to provide custom logging methods.

func (*Logger) Trace added in v1.1.0

func (l *Logger) Trace(msg string, args ...any)

Trace logs at the custom TRACE level.

type Org added in v0.0.6

type Org struct {
	ID              string   `json:"id,omitempty"`
	Name            string   `json:"name,omitempty"`
	MSPID           string   `json:"msp_id,omitempty"`
	AllowMist       bool     `json:"allow_mist,omitempty"`
	AlarmTemplateID string   `json:"alarmtemplate_id,omitempty"`
	OrgGroupIDs     []string `json:"orggroup_ids,omitempty"`
	SessionExpiry   Seconds  `json:"session_expiry,omitempty"`
	ModifiedTime    UnixTime `json:"modified_time,omitzero"`
	CreatedTime     UnixTime `json:"created_time,omitzero"`
}

Org represents an organization

type OrgStat added in v0.0.6

type OrgStat struct {
	NumAps                int `json:"num_aps,omitempty"`
	NumGateways           int `json:"num_gateways,omitempty"`
	NumMxedges            int `json:"num_mxedges,omitempty"`
	NumSwitches           int `json:"num_switches,omitempty"`
	NumUnassignedAps      int `json:"num_unassigned_aps,omitempty"`
	NumUnassignedGateways int `json:"num_unassigned_gateways,omitempty"`
	NumUnassignedSwitches int `json:"num_unassigned_switches,omitempty"`
}

OrgStat holds operational statistics and data relating to an org

type Privilege added in v0.0.2

type Privilege struct {
	Scope        string   `json:"scope,omitempty"`
	Name         string   `json:"name,omitempty"`
	Role         string   `json:"role,omitempty"`
	Views        []string `json:"views,omitempty"`
	OrgID        string   `json:"org_id,omitempty"`
	OrgName      string   `json:"org_name,omitempty"`
	SiteID       string   `json:"site_id,omitempty"`
	SiteName     string   `json:"site_name,omitempty"`
	MSPID        string   `json:"msp_id,omitempty"`
	MSPName      string   `json:"msp_name,omitempty"`
	MSPURL       string   `json:"msp_url,omitempty"`
	MSPLogoURL   string   `json:"msp_logo_url,omitempty"`
	OrgGroupIDs  []string `json:"orggroup_ids,omitempty"`
	SiteGroupIDs []string `json:"sitegroup_ids,omitempty"`
}

Privilege represents the permissions of the authenticated API user

type Radio

type Radio int

Radio defines the possible values for a radio band.

const (
	Band6 Radio = iota + 1
	Band5
	Band24
)

func RadioFromString

func RadioFromString(r string) Radio

RadioFromString creates a Radio from the associated string representation.

func (Radio) MarshalJSON added in v0.0.6

func (r Radio) MarshalJSON() ([]byte, error)

func (Radio) MarshalText added in v1.2.0

func (r Radio) MarshalText() ([]byte, error)

func (Radio) String

func (r Radio) String() string

func (*Radio) UnmarshalJSON

func (r *Radio) UnmarshalJSON(b []byte) error

func (*Radio) UnmarshalText

func (r *Radio) UnmarshalText(b []byte) error

type RadioConfig added in v0.0.2

type RadioConfig int

RadioConfig defines the possible values for a radio band configuration.

const (
	Band6Config RadioConfig = iota + 1
	Band5Config
	Band24Config
)

func RadioConfigFromString added in v0.0.2

func RadioConfigFromString(r string) RadioConfig

RadioConfigFromString creates a RadioConfig from the associated string representation.

func (RadioConfig) MarshalJSON added in v0.0.6

func (rc RadioConfig) MarshalJSON() ([]byte, error)

func (RadioConfig) MarshalText added in v1.2.0

func (rc RadioConfig) MarshalText() ([]byte, error)

func (RadioConfig) String added in v0.0.2

func (rc RadioConfig) String() string

func (*RadioConfig) UnmarshalJSON added in v0.0.2

func (rc *RadioConfig) UnmarshalJSON(b []byte) error

func (*RadioConfig) UnmarshalText added in v0.0.2

func (rc *RadioConfig) UnmarshalText(b []byte) error

type RadioStat

type RadioStat struct {
	Mac                    string `json:"mac,omitempty"`
	NumClients             int    `json:"num_clients,omitempty"`
	NumWLANs               int    `json:"num_wlans,omitempty"`
	Channel                int    `json:"channel,omitempty"`
	Bandwidth              int    `json:"bandwidth,omitempty"`
	DynamicChainingEnabled bool   `json:"dynamic_chaining_enabled,omitempty"`
	Power                  int    `json:"power,omitempty"`
	NoiseFloor             int    `json:"noise_floor,omitempty"`
	TxBytes                int    `json:"tx_bytes,omitempty"`
	TxPkts                 int    `json:"tx_pkts,omitempty"`
	RxBytes                int    `json:"rx_bytes,omitempty"`
	RxPkts                 int    `json:"rx_pkts,omitempty"`
	Usage                  string `json:"usage,omitempty"`
	UtilAll                int    `json:"util_all,omitempty"`
	UtilTx                 int    `json:"util_tx,omitempty"`
	UtilRxInBSS            int    `json:"util_rx_in_bss,omitempty"`
	UtilRxOtherBSS         int    `json:"util_rx_other_bss,omitempty"`
	UtilUnknownWiFi        int    `json:"util_unknown_wifi,omitempty"`
	UtilNonWiFi            int    `json:"util_non_wifi,omitempty"`
	UtilUndecodableWiFi    int    `json:"util_undecodable_wifi,omitempty"`
}

RadioStat holds operational statistics and data relating to the radio connectivity of a Device

type Seconds added in v0.0.2

type Seconds time.Duration

Seconds represents a time in seconds

func (Seconds) MarshalJSON added in v0.0.2

func (s Seconds) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (Seconds) Seconds added in v1.3.0

func (s Seconds) Seconds() float64

func (*Seconds) UnmarshalJSON added in v0.0.2

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

type Self added in v0.0.2

type Self struct {
	Email                string      `json:"email,omitempty"`
	FirstName            string      `json:"first_name,omitempty"`
	LastName             string      `json:"last_name,omitempty"`
	Phone                string      `json:"phone,omitempty"`
	SSO                  bool        `json:"via_sso,omitempty"`
	PasswordLastModified UnixTime    `json:"password_modified_time,omitzero"`
	Privileges           []Privilege `json:"privileges,omitempty"`
	Tags                 []string    `json:"tags,omitempty"`
}

Self represents the account associated with the authenticated API user

type Site

type Site struct {
	ID                string             `json:"id,omitempty"`
	Name              string             `json:"name,omitempty"`
	Timezone          string             `json:"timezone,omitempty"`
	CountryCode       string             `json:"country_code,omitempty"`
	LatLng            map[string]float32 `json:"latlng,omitempty"`
	SiteGroupIDs      []string           `json:"sitegroup_ids,omitempty"`
	Address           string             `json:"address,omitempty"`
	OrgID             string             `json:"org_id,omitempty"`
	ModifiedTime      UnixTime           `json:"modified_time,omitzero"`
	CreatedTime       UnixTime           `json:"created_time,omitzero"`
	Notes             string             `json:"notes,omitempty"`
	AlarmTemplateID   string             `json:"alarmtemplate_id,omitempty"`
	NetworkTemplateID string             `json:"networktemplate_id,omitempty"`
	RFTemplateID      string             `json:"rftemplate_id,omitempty"`
	APTemplateID      string             `json:"aptemplate_id,omitempty"`
	GatewayTemplateID string             `json:"gatewaytemplate_id,omitempty"`
	ApportTemplateID  string             `json:"apporttemplate_id,omitempty"`
	SecPolicyID       string             `json:"secpolicy_id,omitempty"`
}

Site represents a physical location containing devices

type SiteStat added in v0.0.6

type SiteStat struct {
	Site

	Lat                 float32 `json:"lat,omitempty"`
	Lng                 float32 `json:"lng,omitempty"`
	MSPID               string  `json:"msp_id,omitempty"`
	NumAP               int     `json:"num_ap,omitempty"`
	NumAPConnected      int     `json:"num_ap_connected,omitempty"`
	NumClients          int     `json:"num_clients,omitempty"`
	NumDevices          int     `json:"num_devices,omitempty"`
	NumDevicesConnected int     `json:"num_devices_connected,omitempty"`
	NumGateway          int     `json:"num_gateway,omitempty"`
	NumGatewayConnected int     `json:"num_gateway_connected,omitempty"`
	NumSwitch           int     `json:"num_switch,omitempty"`
	NumSwitchConnected  int     `json:"num_switch_connected,omitempty"`
	TZOffset            int     `json:"tzoffset,omitempty"`
}

SiteStat holds operational statistics and data relating to a Site

type StreamedClientStat added in v1.2.0

type StreamedClientStat struct {
	Client
}

StreamedClientStat holds information about a client returned by the websockets streaming stats API

type StreamedCpuStat added in v1.2.0

type StreamedCpuStat struct {
	System    int       `json:"system,omitempty"`
	Idle      int       `json:"idle,omitempty"`
	Interrupt int       `json:"interrupt,omitempty"`
	User      int       `json:"user,omitempty"`
	LoadAvg   []float32 `json:"load_avg,omitempty"`
}

StreamedCpuStat holds the CPU statistics of a device returned by the websockets streaming stats API

type StreamedDeviceStat added in v1.2.0

type StreamedDeviceStat struct {
	Mac        string                            `json:"mac,omitempty"`
	Version    string                            `json:"version,omitempty"`
	IP         string                            `json:"ip,omitempty"`
	ExtIP      string                            `json:"ext_ip,omitempty"`
	PowerSrc   string                            `json:"power_src,omitempty"`
	Uptime     Seconds                           `json:"uptime,omitempty"`
	LastSeen   UnixTime                          `json:"last_seen,omitempty"`
	NumClients int                               `json:"num_clients,omitempty"`
	IPStat     StreamedIPStat                    `json:"ip_stat,omitempty"`
	RadioStats map[RadioConfig]StreamedRadioStat `json:"radio_stat,omitempty"`
	PortStats  map[string]StreamedPortStat       `json:"port_stat,omitempty"`
	LldpStat   StreamedLldpStat                  `json:"lldp_stat,omitempty"`
	RxBytes    int                               `json:"rx_bytes,omitempty"`
	RxPkts     int                               `json:"rx_pkts,omitempty"`
	TxBytes    int                               `json:"tx_bytes,omitempty"`
	TxPkts     int                               `json:"tx_pkts,omitempty"`
	TxBps      int                               `json:"tx_bps,omitempty"`
	RxBps      int                               `json:"rx_bps,omitempty"`
	CpuStat    StreamedCpuStat                   `json:"cpu_stat,omitempty"`
	MemStat    StreamedMemStat                   `json:"memory_stat,omitempty"`
}

StreamedDeviceStat holds information regarding a device returned by the websockets streaming stats API

type StreamedIPStat added in v1.2.0

type StreamedIPStat struct {
	IP       netip.Addr        `json:"ip,omitempty"`
	Netmask  netip.Addr        `json:"netmask,omitempty"`
	Gateway  netip.Addr        `json:"gateway,omitempty"`
	IP6      netip.Addr        `json:"ip6,omitempty"`
	Netmask6 string            `json:"netmask6,omitempty"`
	Gateway6 netip.Addr        `json:"gateway6,omitempty"`
	DNS      []string          `json:"dns,omitempty"`
	IPs      map[string]string `json:"ips,omitempty"`
}

StreamedIPStat holds the IP addressing information of a device returned by the websockets streaming stats API

type StreamedLldpStat added in v1.2.0

type StreamedLldpStat struct {
	SystemName        string `json:"system_name,omitempty"`
	SystemDesc        string `json:"system_desc,omitempty"`
	MgmtAddr          string `json:"mgmt_addr,omitempty"`
	LldpMedSupported  bool   `json:"lldp_med_supported,omitempty"`
	PortDesc          string `json:"port_desc,omitempty"`
	PortID            string `json:"port_id,omitempty"`
	PowerRequestCount int    `json:"power_request_count,omitempty"`
	PowerAllocated    int    `json:"power_allocated,omitempty"`
	PowerDraw         int    `json:"power_draw,omitempty"`
	PowerRequested    int    `json:"power_requested,omitempty"`
}

StreamedLldpStat holds the LLDP information of a device returned by the websockets streaming stats API

type StreamedMemStat added in v1.2.0

type StreamedMemStat struct {
	Usage int `json:"usage,omitempty"`
}

StreamedMemStat holds the memory statistics of a device returned by the websockets streaming stats API

type StreamedPortStat added in v1.2.0

type StreamedPortStat struct {
	TxPkts     int  `json:"tx_pkts,omitempty"`
	TxBytes    int  `json:"tx_bytes,omitempty"`
	RxPkts     int  `json:"rx_pkts,omitempty"`
	RxBytes    int  `json:"rx_bytes,omitempty"`
	RxPeakBps  int  `json:"rx_peak_bps,omitempty"`
	TxPeakBps  int  `json:"tx_peak_bps,omitempty"`
	FullDuplex bool `json:"full_duplex,omitempty"`
	Speed      int  `json:"speed,omitempty"`
	Up         bool `json:"up"`
	RxErrors   int  `json:"rx_errors,omitempty"`
}

StreamedPortStat holds the wired port statistics of a device returned by the websockets streaming stats API

type StreamedRadioStat added in v1.2.0

type StreamedRadioStat struct {
	Bandwidth  int    `json:"bandwidth,omitempty"`
	Channel    int    `json:"channel,omitempty"`
	Mac        string `json:"mac,omitempty"`
	NumClients int    `json:"num_clients,omitempty"`
	Power      int    `json:"power,omitempty"`
	RxBytes    int    `json:"rx_bytes,omitempty"`
	RxPkts     int    `json:"rx_pkts,omitempty"`
	TxBytes    int    `json:"tx_bytes,omitempty"`
	TxPkts     int    `json:"tx_pkts,omitempty"`
}

StreamedRadioStat holds the radio statistics of a device returned by the websockets streaming stats API

type SubscriptionRequest added in v0.0.6

type SubscriptionRequest struct {
	Subscribe string `json:"subscribe"`
}

SubscriptionRequest represents a websocket subscription request

type SubscriptionResponse added in v0.0.6

type SubscriptionResponse struct {
	Event   string `json:"event"`
	Channel string `json:"channel"`
}

SubscriptionResponse represents a websocket subscription response

type TicketStatus

type TicketStatus int

TicketStatus defines the possible values for support ticket status.

const (
	Open TicketStatus = iota + 1
	Pending
	Solved
	Closed
	Hold
)

func TicketStatusFromString

func TicketStatusFromString(status string) TicketStatus

TicketStatusFromString creates a TicketStatus from the associated string representation.

func (TicketStatus) String

func (ts TicketStatus) String() string

type UnixTime added in v0.0.2

type UnixTime struct {
	time.Time
}

UnixTime represents the number of seconds since the Eunix epoch

func (UnixTime) MarshalJSON added in v1.2.0

func (ut UnixTime) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*UnixTime) UnmarshalJSON added in v0.0.2

func (ut *UnixTime) UnmarshalJSON(b []byte) error

type UnsubscribeRequest added in v0.0.6

type UnsubscribeRequest struct {
	Unsubscribe string `json:"unsubscribe"`
}

UnsubscribeRequest represents a websocket unsubscribe request

type WebsocketMessage added in v0.0.6

type WebsocketMessage struct {
	Event   string `json:"event"`
	Channel string `json:"channel"`
	Data    string `json:"data"`
}

WebsocketMessage represents a message streamed by a websocket connection

Jump to

Keyboard shortcuts

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