Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection interface {
// Login authenticates against the controller and returns the controller ID.
Login(ctx context.Context) (string, error)
// RequestEndpoint performs an authenticated v2 API request.
RequestEndpoint(ctx context.Context, method, api, endpoint, site string, query url.Values, body any) (map[string]any, error)
// OpenapiRequest performs an authenticated OpenAPI-versioned request.
OpenapiRequest(ctx context.Context, method, version, endpoint, site string, query url.Values, body any) (map[string]any, error)
// SiteInfo fetches a site's detail object.
SiteInfo(ctx context.Context, site string) (map[string]any, error)
// SiteVersion returns the site's reported version.
SiteVersion(ctx context.Context, site string) (models.Version, error)
// DoMultipart performs a multipart form-data request against an explicit URL.
DoMultipart(ctx context.Context, method, u string, query url.Values, fields map[string]string, csrf string) (map[string]any, error)
// ControllerInfo fetches unauthenticated controller diagnostics.
ControllerInfo(ctx context.Context) (map[string]any, error)
// ControllerVersion returns the controller version, fetching it if unknown.
ControllerVersion(ctx context.Context) (models.Version, error)
// BuildURL joins the endpoint onto the base under the current controller ID.
BuildURL(api, endpoint, site string) string
// CSRFToken returns the current CSRF token snapshot.
CSRFToken() string
// CloseIdleConnections releases pooled idle connections.
CloseIdleConnections()
// PagesV2 collects all pages of a legacy v2 GET endpoint.
PagesV2(ctx context.Context, endpoint, site string, params url.Values) ([]map[string]any, error)
// PagesOpenAPIPost collects all pages of an OpenAPI POST endpoint.
PagesOpenAPIPost(ctx context.Context, api, endpoint, site string, body map[string]any) ([]map[string]any, error)
// PagesOpenAPI collects all pages of an OpenAPI versioned POST endpoint.
PagesOpenAPI(ctx context.Context, version, endpoint, site string, body map[string]any) ([]map[string]any, error)
// PagesOpenAPIGet collects all pages of an OpenAPI GET endpoint.
PagesOpenAPIGet(ctx context.Context, api, endpoint, site string, params url.Values) ([]map[string]any, error)
}
Connection is an authenticated connection to an Omada controller. Data requests run concurrently; only login/re-login transitions are serialized internally.
func New ¶
func New(rawURL, username, password string, httpClient *http.Client) (Connection, error)
New creates a Connection for the controller at rawURL. The URL is normalized: a missing scheme becomes https://, trailing slashes are trimmed, and the bare host (no port) is recorded. No login is performed.