Skip to main content

arubaos_cx_js

Authenticate and interact with the ArubaOS-CX REST API using 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

One request

Logs the user in, performs a 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/mod.ts";

const response = await fetchOnce({ host: "10.20.30.40" }, "/system");

Multiple requests

import { Client } from "https://deno.land/x/arubaos_cx/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 host, is defined in the following order of precedence:

  1. If defined within the function or class initialisation
  2. If defined by its environment variable
  3. 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 commiting 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.