pyarubacentral

A python module to authenticate and refresh tokens for Aruba Central


Keywords
arubacentral, aruba, python, development
License
MIT
Install
pip install pyarubacentral==2.1.12

Documentation

Aruba Central Python RESTful module

made-with-python MIT license Maintenance

A Python module for use with Aruba Central. The aim is to make life easier for people who are not primarily programmers, but need to interact with services in a programmatic manner (e.g. automation).

This python module is used primarily to refresh expired access tokens and generate new refresh tokens as well. It also supports profiles, so you can setup multiple Aruba Central accounts and easily include those tokens in your script and easily switching between accounts by passing the profile variable.

The example script is included to show a list of users in Aruba Central or display when an access token will expire.

Contents

Features

  • CLI script to refresh access tokens
  • CLI script to generate a new refresh and access token
  • Python module to import to generate and refresh tokens automatically as the script it executed. enter image description here enter image description here

Installation

To install directly into your python environment please install with the following command:

pip install pyarubacentral

If you prefer to clone this GitHub project, please be sure to run

git clone git@github.com:michaelrosejr/pyarubacentral.git
pipenv shell

before you start coding.

Prerequisites

The following Python module assumes you have already created an API account on Aruba Central, requested a code and exchanged that code for a token. For details on how to do setup an account for API access in Aruba Central, please go to the help documentation in Aruba Central.

Usage

arubacentral --configure

Once configured, open your editor and edit the following files

~/.arubacentral/accounts.yml
~/.arubacentral/config.yml
~/.arubacentral/regions.yml

accounts.yml

config.yaml

All tokens are stored in ~/.arubacentral/tokens/profilename.tokens.json should you need to edit them.

To refresh an expired token: arubacentral --refresh [profile_name]

enter image description here

To generate a new access and refresh token: arubacentral --newtoken [profile_name]

enter image description here

Python Module

To use it as a python module within your code. See the example

import pyarubacentral
profile = "ACME"

# Return User List from Aruba Central
session = pyarubacentral.start_session(profile)
access_token = pyarubacentral.check_if_expired(profile, session)
print(session.get_user_account_list(access_token))

License

MIT license

Contribute

If you're interested in contributing to add feature or fix bugs, please open an issue to discuss and Pull Requests to fix an identified bug. PR's are always welcome! Please be sure to have a detailed PR description that clearly describes the problem and solution.

Disclaimer

This module is incomplete. It does not have all the API calls available via Aruba Central. If you see something you need from the swagger client, let us know and we'll do our best to add it to this module. Even better, add it yourself and we'll help you merge your code in this repository.

This is not an 'official' SDK and is not guaranteed to always work with Aruba Central's APIs, on all platforms, or without eating up all your machine's resources. But we'll do our best to keep it in good shape, are happy to take suggestions for improvements, and are open to collaborations. License info is here.