cloud

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 30 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectAll

func CollectAll[T any](ctx context.Context, fetch func(ctx context.Context, page, pageSize int) (Page[T], error), pageSize int, maxRows int64) ([]T, error)

CollectAll fetches pages via fetch(ctx, page, pageSize) starting at page 1 until it has TotalRows rows (when known), a short page, or maxRows rows. A first error from fetch stops collection and is returned. The result never exceeds maxRows, and never exceeds TotalRows when it is known: a page that crosses the total is truncated to it.

Types

type APIError

type APIError struct {
	Code int
	Msg  string
}

APIError is a northbound API envelope error: a non-zero errorCode in the {errorCode, msg, ...} response envelope.

func NewAPIError

func NewAPIError(code int, msg string) *APIError

NewAPIError creates an APIError from an envelope errorCode and msg.

func (*APIError) Error

func (e *APIError) Error() string

Error implements error.

type Client

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

Client is a northbound Omada cloud API client. Every domain accessor returns a generated client whose requests flow through the auth transport.

func New

func New(opts Options) (*Client, error)

New creates a Client. Exactly one credential set must be provided: hosted (Username + Password) or on-prem org-level (OmadacID + ClientID + ClientSecret); both or neither is an error. BaseURL defaults to the hosted US-1 endpoint only in hosted mode; on-prem mode requires an explicit BaseURL.

func (*Client) Ap

func (c *Client) Ap() *ap.Client

Ap returns the AP domain client.

func (*Client) Clients

func (c *Client) Clients() *client.Client

Clients returns the customer domain client.

func (*Client) Devices

func (c *Client) Devices() *device.Client

Devices returns the device domain client.

func (*Client) Gateway

func (c *Client) Gateway() *gateway.Client

Gateway returns the gateway domain client.

func (*Client) HTTPClient

func (c *Client) HTTPClient() *http.Client

HTTPClient returns the client's auth transport wrapped http.Client for generic dispatch-style calls through the same token provider.

func (*Client) Insight

func (c *Client) Insight() *insight.Client

Insight returns the insight domain client.

func (*Client) InvalidateToken

func (c *Client) InvalidateToken()

InvalidateToken drops the cached token so the next request re-authenticates.

func (*Client) Lan

func (c *Client) Lan() *lan.Client

Lan returns the LAN domain client.

func (*Client) Msp

func (c *Client) Msp() *msp.Client

Msp returns the MSP domain client.

func (*Client) OmadaLog

func (c *Client) OmadaLog() *omadalog.Client

OmadaLog returns the log domain client.

func (*Client) PreflightToken

func (c *Client) PreflightToken(ctx context.Context) error

PreflightToken forces a token fetch (or serves the cached token) so callers can surface authentication problems — bad credentials, unreachable or failing token endpoints — before making domain calls.

func (*Client) Remote

func (c *Client) Remote() *remote.Client

Remote returns the remote domain client.

func (*Client) Security

func (c *Client) Security() *security.Client

Security returns the security domain client.

func (*Client) Sim

func (c *Client) Sim() *sim.Client

Sim returns the SIM domain client.

func (*Client) Site

func (c *Client) Site() *site.Client

Site returns the site domain client.

func (*Client) Stack

func (c *Client) Stack() *stack.Client

Stack returns the stack domain client.

func (*Client) Switch

func (c *Client) Switch() *switchpkg.Client

Switch returns the switch domain client.

func (*Client) Topology

func (c *Client) Topology() *topology.Client

Topology returns the topology domain client.

func (*Client) Users

func (c *Client) Users() *user.Client

Users returns the user domain client.

func (*Client) Voip

func (c *Client) Voip() *voip.Client

Voip returns the VoIP domain client.

func (*Client) Vpn

func (c *Client) Vpn() *vpn.Client

Vpn returns the VPN domain client.

func (*Client) Wireless

func (c *Client) Wireless() *wireless.Client

Wireless returns the wireless domain client.

type Options

type Options struct {
	BaseURL      string
	Username     string // hosted mode
	Password     string // hosted mode
	OmadacID     string // on-prem org-level mode
	ClientID     string // on-prem org-level mode
	ClientSecret string // on-prem org-level mode
	// InsecureTLS disables TLS certificate verification for every request,
	// including token requests. Enable it only for controllers that serve
	// the stock self-signed certificate (CN=localhost, no SAN), which
	// fails hostname verification in every modern client. Prefer installing
	// a proper certificate when possible: with verification off the
	// credentials are exposed to any on-path attacker.
	InsecureTLS bool
	HTTPClient  *http.Client
}

Options configures a northbound cloud Client. Exactly one credential set is required: hosted (Username + Password) or on-prem org-level (OmadacID + ClientID + ClientSecret). BaseURL defaults to the US-1 northbound endpoint only in hosted mode; it is required in on-prem mode.

type OrgTokenProvider

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

OrgTokenProvider fetches and caches an on-prem org-level Open API token via the client-credentials grant against the controller's own /openapi/authorize/token endpoint. The response is enveloped (errorCode/msg/result); a non-zero errorCode is an error. The returned refreshToken is not used: re-authentication always re-runs the client-credentials grant.

func NewOrgTokenProvider

func NewOrgTokenProvider(baseURL, omadacID, clientID, clientSecret string, hc *http.Client) *OrgTokenProvider

func (*OrgTokenProvider) HeaderValue

func (p *OrgTokenProvider) HeaderValue(ctx context.Context) (string, error)

HeaderValue returns the full Authorization header value for a request: "AccessToken=<token>".

func (*OrgTokenProvider) Invalidate

func (p *OrgTokenProvider) Invalidate()

Invalidate drops the cached token so the next Token call refetches.

func (*OrgTokenProvider) Token

func (p *OrgTokenProvider) Token(ctx context.Context) (string, error)

Token returns the cached token if it is still valid, otherwise fetches a new one from the on-prem org-level token endpoint.

type Page

type Page[T any] struct {
	Rows      []T
	TotalRows int64
}

Page is one page of results; TotalRows <= 0 means "unknown".

type TokenProvider

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

TokenProvider fetches and caches a northbound client-credentials token.

func NewTokenProvider

func NewTokenProvider(baseURL, username, password string, hc *http.Client) *TokenProvider

func (*TokenProvider) HeaderValue

func (tp *TokenProvider) HeaderValue(ctx context.Context) (string, error)

HeaderValue returns the full Authorization header value for a request: "Bearer <token>".

func (*TokenProvider) Invalidate

func (tp *TokenProvider) Invalidate()

Invalidate drops the cached token so the next Token call refetches.

func (*TokenProvider) Token

func (tp *TokenProvider) Token(ctx context.Context) (string, error)

Token returns the cached token if it is still valid, otherwise fetches a new one from the northbound token endpoint.

Directories

Path Synopsis
Package ap provides primitives to interact with the openapi HTTP API.
Package ap provides primitives to interact with the openapi HTTP API.
Package client provides primitives to interact with the openapi HTTP API.
Package client provides primitives to interact with the openapi HTTP API.
Package device provides primitives to interact with the openapi HTTP API.
Package device provides primitives to interact with the openapi HTTP API.
Package gateway provides primitives to interact with the openapi HTTP API.
Package gateway provides primitives to interact with the openapi HTTP API.
Package insight provides primitives to interact with the openapi HTTP API.
Package insight provides primitives to interact with the openapi HTTP API.
Package lan provides primitives to interact with the openapi HTTP API.
Package lan provides primitives to interact with the openapi HTTP API.
Package log provides primitives to interact with the openapi HTTP API.
Package log provides primitives to interact with the openapi HTTP API.
Package msp provides primitives to interact with the openapi HTTP API.
Package msp provides primitives to interact with the openapi HTTP API.
Package remote provides primitives to interact with the openapi HTTP API.
Package remote provides primitives to interact with the openapi HTTP API.
Package security provides primitives to interact with the openapi HTTP API.
Package security provides primitives to interact with the openapi HTTP API.
Package sim provides primitives to interact with the openapi HTTP API.
Package sim provides primitives to interact with the openapi HTTP API.
Package site provides primitives to interact with the openapi HTTP API.
Package site provides primitives to interact with the openapi HTTP API.
Package stack provides primitives to interact with the openapi HTTP API.
Package stack provides primitives to interact with the openapi HTTP API.
Package switchpkg provides primitives to interact with the openapi HTTP API.
Package switchpkg provides primitives to interact with the openapi HTTP API.
Package topology provides primitives to interact with the openapi HTTP API.
Package topology provides primitives to interact with the openapi HTTP API.
Package user provides primitives to interact with the openapi HTTP API.
Package user provides primitives to interact with the openapi HTTP API.
Package voip provides primitives to interact with the openapi HTTP API.
Package voip provides primitives to interact with the openapi HTTP API.
Package vpn provides primitives to interact with the openapi HTTP API.
Package vpn provides primitives to interact with the openapi HTTP API.
Package wireless provides primitives to interact with the openapi HTTP API.
Package wireless provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

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