conn

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 14 Imported by: 1 module, 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

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.

Jump to

Keyboard shortcuts

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