arubaos_cx_js
ArubaOS-CX REST API client for Deno. Design principles:
- Must be fundamentally simple
- Based on and has a similar API to the Fetch API
- Built for scale and reduced time required to automate tasks
Disclaimer: this is not an official Aruba software project.
Usage
Must be run with the --allow-env
, --allow-net
and possibly the
--unsafely-ignore-certificate-error
environment variables.
One request
Logs the user in, performs an HTTP request, then logs out, returning the response. This is the easiest way to make a single request.
import { fetchOnce } from "https://deno.land/x/arubaos_cx@$VERSION/mod.ts";
const response = await fetchOnce({ host: "10.20.30.40" }, "/system");
Multiple requests
import { Client } from "https://deno.land/x/arubaos_cx@$VERSION/mod.ts";
const client = new Client({ host: "10.20.30.40" });
await client.login();
const response1 = await client.fetch("/system");
const response2 = await client.fetch("/firmware");
await client.logout();
Default values
Each parameter, except for the host
, is defined in the following order of
precedence:
- If defined within the function or class initialisation
- If defined by its environment variable
- Its default value (see documentation)
Environment variables
Environment variables are used by default to discourage explicitly defining confidential credentials within scripts. Many have made the mistake of committing code containing such secrets. See documentation for more information.
Documentation
Check out the full documentation here.
Testing
ARUBAOS_CX_HOST=10.20.30.40 ARUBAOS_CX_PASSWORD=password deno task test
Note: Tests must run with environmental variables defined, including an extra
ARUBAOS_CX_HOST
.