HomeGuidesAPI Reference
GuidesAPI ReferenceGitHubAirheads Developer CommunityLog In
Guides

Installing Python Package - pyhpeuxi

HPE Aruba Networking User Experience Insight (UXI) SDK
This package has been developed in Python v3.9 to utilize the full functionality of the HPE Aruba Networking User Experience Insight API environment. Each available REST API command is available for use in this module. All responses from HPE Aruba Networking User Experience Insight API are in JSON format (converted into a Python dictionary object).

This package has been uploaded to PyPI and is also available to install via GitHub. These instructions will also be available at the Aruba Developer Network in due course. Installation instructions and usage instructions are also provided below.

📘

Please note that this package has been developed by an HPE employee; however, it is not officially supported by the HPE UXI Support Team. As a result, no assistance or support will be provided for its use. If you encounter any issues with this package, please report them by opening a new issue on the GitHub repository.

Available API Categories
The following describes the available top-level API functionality of the HPE Aruba Networking User Experience Insight SDK available within this Python Package:

API Service - Agents
API Service - Agent Group Assignments
API Service - Groups
API Service - Network Group Assignments
API Service - Sensors
API Service - Sensor Group Assignments
API Service - Service Tests Group Assignments
API Service - Service Tests
API Service - Wired Networks
API Service - Wireless Networks

HPE Aruba Networking User Experience Insight (UXI) SDK API Prerequisites
As a prerequisite to using the onboarding API, the following conditions must be met:

Your dashboard must be on the HPE Greenlake Cloud Platform (GLP). If you are not yet migrated to the platform, you can follow these steps to migrate via support.
Your dashboard must be using the new group-based configuration. We are beginning to migrate our customers to the new group-based configuration automatically beginning in February, but it may take a few months to complete for all dashboards. You can expedite the migration by following the steps to prepare your dashboard for group-based configuration.

HPE Aruba Networking User Experience Insight (UXI) SDK API Readiness
These steps list what is required on the HPE Aruba Networking User Experience Insight Management Console:

To get started with the UXI Onboarding API, first go to your Greenlake Cloud Workspace and select Manage Workspace.
Next, select the option for Personal API clients and select Create Personal API Client.
In the pop-up menu, provide a personal API client name and select the service for User Experience Insight (US West). Then select Create Personal API client.
You will then be given a Client ID and Client secret. Store these values locally in a safe location. These can be used within your script or you can use the API token provided in the next step. Note the access token described below is only valid for a short period of time.
When you look at the page for personal API clients again, you will see the one you created. Expand the menu to generate an access token using the client secret. This access token will be used for API requests.
If you need further information, refer to the HPE Aruba Networking User Experience Insight configuration documentation for the API account - UXI API Reference Guide.

Python Requirements
Ensure Python v3 or greater is installed on your operating system

Package Installation
Method 1 - Installing Package from PyPi
Run the following in a command line terminal to install the pip package - pip3 install pyhpeuxi or pip install pyhpeuxi. This may vary between Operating Systems.

Method 2 - Installing Package from Github (not using Git.exe)
Click into the Aruba GitHub Repository where the latest version of pyhpeuxi is located
Click Code (in green) and Download to Zip
Extract the zip file into a directory
Go into a command line terminal and change directory (cd) into the folder where you extracted the zipped file and then down one child folder. The folder contents should pyhpeuxi (FOLDER), LICENCE, pyproject.toml and README.md
In your command line terminal type python3 -m build or python -m build. This will create a folder called dist with a file containing a .gz extension.
Run the following in a command line terminal to install the pip package - pip3 install pathtozip.gz or pip install pathtozip.gz. This may vary between Operating Systems.

Method 3 - Installing Package from Github (using Git.exe)
Install Git for your Operating System from https://git-scm.com/download
Run the following in a command line terminal to install the pip package - pip3 install git+https://github.com/aruba/pyhpeuxi or pip install git+https://github.com/aruba/pyhpeuxi. This may vary between Operating Systems.

Initial Usage Instructions
Within your favorite Python IDE environment, create an import reference.

from pyhpeuxi import \*

Create an object to login into the API. The login object needs to be passed to use any function to use the API.
Four examples below show how to create the login object (choose only one method).

  1. Using API Token
    login = HPEUXIApiLogin(api_token="your API Token"))
    
  2. Using API Client Credentials
     login = HPEUXIApiLogin(client_id="your client id",client_secret="your client secret"))
    
  3. Using the API Client Credentials retrieved from a JSON structured file. The file must exist in the same working directory of the script and contain the following structure. {"client_id":"your_client_id","client_secret":"your_client_secret"}
    apiCreds = Utils_UXI.get_personal_api_client_creds_from_file("your_cred_file.token")  
    login = HPEUXIApiLogin(api_client_credentials=apiCreds)
    
  4. Using API Token retrieved from a JSON structured file. The file must exist in the same working directory of the script and contain the following structure. {"access_token":"your_secret_token"}
    apiToken = Utils_UXI.get_token_from_file("my_token_file.token")  
    login = HPEUXIApiLogin(api_token=apiToken)
    

Warning : Never expose your credentials directly in your scripts. The above is just an example of completeness and to get you going. When using the likes of Github, use your ignores file to exclude the credential files.

Note: When using Method 2 to use the API of the UXI environment, you can retrieve the API token by calling the login variable and referencing the variable api_token (login.api_token). The API Tokens expire after 120 minutes.

Find an API you want to use, by prefixing OpenApi. in your IDE and Intellisense will show the available APIs.

The example below prints the contents of all the groups within the UXI environment. You must pass in the login variable to execute to function correctly.

print(OpenApi.get_networks_wireless(login))

Working Example

Below is an example of the initial usage instructions, which includes a console print to display the result.

from pyhpeuxi import \*  
login = HPEUXIApiLogin(client_id="your client id",client_secret="your client secret")  
print(OpenApi.get_networks_wireless(login))

Optional Parameters
The following details the additional available parameters within the HPEUXIApiLogin class.

verify_ssl = False, #Disable SSL if required. By default, verify SSL is enabled. 	  
url = "<https://api.capenetworks.com">) # Override the API Service URL. Default URL is shown  
oauth_token_url = "<https://sso.common.cloud.hpe.com/as/token.oauth2">, #Override the GreenLake OAuth Token Service URL. The default URL is shown

Help
After writing a specific API call such as OpenApi.function_name(, you can hover your cursor over the command to view help information and the required parameters (e.g., in Visual Studio Code). Note that the first parameter is always "login." Additionally, you can read the function's help documentation by calling help(OpenApi.function_name). Each function includes a concise help summary.

Full Function List
The following list details all the available functions within this package. Please use the help function described earlier to understand how to use each function.

Agent Functions (OpenApi Class)

delete_agent
delete_group_agent
get_agents
get_group_agent
new_group_agent
update_agent

Group Functions (OpenApi Class)

delete_group
get_groups
update_group
new_group

Network Group Functions (OpenApi Class)

delete_group_network
get_group_network
new_group_network

Sensor Functions (OpenApi Class)

get_group_sensor
get_sensors
update_sensor
new_group_sensor

Service Functions (OpenApi Class)

delete_test_service
get_test_service
get_tests_service
new_test_service

Wireless / Wired Networks (OpenApi Class)

get_networks_wired
get_networks_wireless

Utilities (Utils_UXI Class)

get_personal_api_client_creds_from_file
get_token_from_file
export_to_csv

Python Package Upgrade Instructions
Once an update is available on the Python PyPi repository, you may upgrade your release by completing the following in a command line terminal -

pip3 install pyhpeuxi --upgrade
or
pip install pyhpeuxi --upgrade

To install a specific version, execute the following command with x.x.x being the specific version number you want to install.

pip3 install pyhpeuxi==x.x.x
or
pip install pyhpeuxi==x.x.x

Uninstall Package Package

To remove the Python pyhpeuxi package, type the following command into a command line terminal -
pip3 uninstall pyhpeuxi
or
pip uninstall pyhpeuxi