Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
fccc6bc
fix: :bug: add missing function import from _timeseries_stats submodu…
zachcamara-hpe Oct 19, 2021
91e9d74
docs: :memo: add PyPI download badge counter to README
zachcamara-hpe Oct 19, 2021
ea42bd4
docs: :memo: remove erroneous ``name`` parameter from docstring of cr…
zachcamara-hpe Oct 19, 2021
89fcdb0
docs: :memo: update typo of directory name when cloning repo from GitHub
zachcamara-hpe Oct 19, 2021
316d70f
feat: :sparkles: add clearpass functions for _third_party_services su…
zachcamara-hpe Oct 19, 2021
07e0cd1
fix: :bug: Fix create_user.py example to includ orch.login() function…
zachcamara-hpe Nov 23, 2021
8a9e16e
fix: :bug: Add missing query parameter for delete_dependencies in upd…
zachcamara-hpe Nov 29, 2021
3fad4c5
docs: :memo: Add more details to docstring for get_gms_notification
zachcamara-hpe Dec 28, 2021
ea40469
feat: :sparkles: add Aruba Central functions to _third_party_services…
zachcamara-hpe Dec 28, 2021
3f92536
feat: :sparkles: Add _rbac_appliance_access_group submodule functions
zachcamara-hpe Dec 28, 2021
a6427b1
feat: :sparkles: add _link_aggregation submodule
zachcamara-hpe Dec 29, 2021
1571a4a
docs: :memo: Fix header comment line length
zachcamara-hpe Dec 29, 2021
88048d2
feat: :sparkles: add get_stats_appriximate_disk_space function to _st…
zachcamara-hpe Dec 29, 2021
1374d1c
fix: :bug: fix function name typo with get_stats_appriximate_disk_spa…
zachcamara-hpe Dec 29, 2021
0c96c27
docs: :memo: fix function reference with old package name to pyedgeco…
zachcamara-hpe Dec 29, 2021
bd516b2
feat: :sparkles: add appliance_delete_api, delete_denied_appliances, …
zachcamara-hpe Dec 29, 2021
4f05709
docs: :memo: Fixed legacy function references to :func:`silverpeak_py…
zachcamara-hpe Jan 3, 2022
c86b0d4
feat: :sparkles: Add _loopback_orch submodule functions
zachcamara-hpe Jan 3, 2022
6fef02c
feat: :sparkles: Add _subnets submodule functions
zachcamara-hpe Jan 3, 2022
01b790f
docs: :memo: Fix warning syntax in set_loopback_orchestration function
zachcamara-hpe Jan 3, 2022
5a484bc
feat: :sparkles: Add _user_account submodule functions
zachcamara-hpe Jan 3, 2022
2f31897
feat: :sparkles: Update change_appliance_license function to include …
zachcamara-hpe Jan 3, 2022
6d05684
fix: :bug: Fix missing ne_id paramter for set_appliance_subnet_sharin…
zachcamara-hpe Jan 4, 2022
3acbc4e
feat: :sparkles: add _ssl submodule functions
zachcamara-hpe Jan 4, 2022
e883322
feat: :sparkles: Add _session_timeout submodule functions
zachcamara-hpe Jan 4, 2022
21b7753
feat: :sparkles: Add _session submodule functions
zachcamara-hpe Jan 4, 2022
dd8277e
feat: :sparkles: add _ssl_substitute_cert submodule functions
zachcamara-hpe Jan 4, 2022
3bcaf1d
feat: :sparkles: add _app_system_state_info and _app_system_deploy_in…
zachcamara-hpe Jan 4, 2022
e1b20d3
feat: :sparkles: add _releases submodule functions
zachcamara-hpe Jan 5, 2022
d7da1f5
feat: :sparkles: Update get_zones to account for all segments filter
zachcamara-hpe Jan 5, 2022
5cca8e3
docs: :memo: Updated docstring for return item **portalObjectId** and…
zachcamara-hpe Jan 6, 2022
b3d1b94
feat: :sparkles: add _network_role_and_site submodule functions
zachcamara-hpe Jan 6, 2022
32eb27b
feat: :sparkles: add handling for ``files`` parameter in _post and _r…
zachcamara-hpe Jan 7, 2022
021c1bd
feat: :sparkles: add _appliance_upgrade, _upgrade_appliances, and _sn…
zachcamara-hpe Jan 7, 2022
98ddbd1
feat: :sparkles: add _schedule_timezone submodule functions
zachcamara-hpe Jan 11, 2022
6bffd29
feat: :sparkles: add _bridge_interface_state submodule functions
zachcamara-hpe Jan 11, 2022
98031b2
feat: :sparkles: add _gms_registration submodule functions
zachcamara-hpe Jan 11, 2022
257ee00
feat: :sparkles: add _appliance_resync submodule functions
zachcamara-hpe Jan 11, 2022
c9f9d6a
fix: :bug: Fix function name (and import to init) for _link_integrity…
zachcamara-hpe Jan 31, 2022
a855a78
feat: :sparkles: add _overlay_association submodule functions
zachcamara-hpe Feb 1, 2022
40d9917
feat: :sparkles: add _appliance_extra_info submodule functions
zachcamara-hpe Feb 3, 2022
6501c1f
feat: :sparkles: add _advanced_properties submodule functions
zachcamara-hpe Feb 3, 2022
5f8a15b
fix: :bug: Fix data return type for get_orchestrator_hello to "text"
zachcamara-hpe Mar 7, 2022
cb09793
refactor: :recycle: get_appliance_extra_info part of new _appliance_e…
zachcamara-hpe Mar 19, 2022
8eb9bf2
docs: :memo: fix docstring syntax errors
zachcamara-hpe Mar 20, 2022
da84483
docs: :memo: fix docstring line-length syntax errors
zachcamara-hpe Mar 20, 2022
5d75922
fix: :bug: fix expected_status for associate_template_group_to_applia…
zachcamara-hpe Mar 20, 2022
2367842
refactor: :boom: renamed parameter ``hostname`` for preconfig functio…
zachcamara-hpe Mar 22, 2022
eca3844
feat: :sparkles: Add _deployment submodule GET functions, POST functi…
zachcamara-hpe Mar 26, 2022
a88c07c
refactor: :recycle: Update existing examples with new authentication …
zachcamara-hpe Mar 26, 2022
4e6e468
docs: :memo: Update docs structure and new example documentation
zachcamara-hpe Mar 26, 2022
675fd6c
docs: :sparkles: Add new example script to generate Preconfig YAML vi…
zachcamara-hpe Mar 26, 2022
c26343c
docs: :memo: Update main README formatting
zachcamara-hpe Mar 26, 2022
a9249d9
docs: :memo: ignore preconfig_output from example directory
zachcamara-hpe Mar 26, 2022
a5bab59
docs: :memo: added warning for bulk upload functions that currently e…
zachcamara-hpe Mar 26, 2022
5ed24e0
final commit for version increment to 0.15.0
zachcamara-hpe Mar 27, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ wheels/
tests/
docs/build/
docs/source/_build
examples/generate_preconfig/preconfig_outputs

# dotenv
*.env
Expand Down
24 changes: 24 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the version of Python and other tools
build:
tools:
python: "3.9"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

# If using Sphinx, optionally build your docs in additional formats such as PDF
formats:
- pdf

# Optionally declare the Python requirements required to build your docs
python:
install:
- requirements: docs/requirements.txt
34 changes: 16 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Aruba Edge Connect Python SDK

[![Downloads](https://static.pepy.tech/personalized-badge/pyedgeconnect?period=total&units=none&left_color=grey&right_color=orange&left_text=PyPI%20Downloads)](https://pepy.tech/project/pyedgeconnect)

This package is a python wrapper for leveraging the API for Aruba
Orchestrator and Edge Connect SDWAN systems.
Expand All @@ -10,12 +11,8 @@ Edge Connect web interfaces under "Support > Rest API"
Many, but not all API functions have been implemented yet. Development
is underway to continue to add further functions.

As of 0.14.0+ 64% of non-deprecated Swagger functions are covered.


## Install


### Python Version

> **Note:** Requires Python 3.9.0+ (due to PEP585 type-hinting e.g. ``def my_func(var1 = list[str]``)
Expand Down Expand Up @@ -59,7 +56,7 @@ Now you can install the package and run your python code
### Install from PyPI

```bash
$ pip install pyedgeconnect
pip install pyedgeconnect
```

### Install from GitHub
Expand All @@ -70,13 +67,13 @@ interactive shell and run:
> **Note:** These commands assume you're within a Python 3.9 venv, or Python 3.9 is the exclusive Python version installed in regard to referencing the use of ``pip``. If that is not the case, you can specifically append ``python3.9 -m`` ahead of the ``pip install ...``

```bash
$ pip install git+https://github.com/SPOpenSource/edgeconnect-python
pip install git+https://github.com/SPOpenSource/edgeconnect-python
```

To install a specific branch use the @branch syntax

```bash
$ pip install git+https://github.com/SPOpenSource/edgeconnect-python@<branch_name>
pip install git+https://github.com/SPOpenSource/edgeconnect-python@<branch_name>
```

### Install dev options
Expand All @@ -91,7 +88,7 @@ following syntax:
```bash
$ pip install pyedgeconnect[dev]
or
$ pip install -e git+https://github.com/SPOpenSource/edgeconnect-python#egg=pyedgeconnect[dev]
$ pip install -e git+https://github.com/SPOpenSource/edgeconnect-python#egg=pyedgeconnect[dev]
```

## Docs
Expand All @@ -104,11 +101,11 @@ To build the documentation locally, clone the repository, install with ``[dev]``
to include sphinx and related packages, then in the docs directory run ``make html``

```bash
$ git clone https://github.com/SPOpenSource/edgeconnect-python.git
$ cd pyedgeconnect
$ pip install .[dev]
$ cd docs
$ make html
git clone https://github.com/SPOpenSource/edgeconnect-python.git
cd edgeconnect-python
pip install .[dev]
cd docs
make html
```

## Usage
Expand Down Expand Up @@ -213,15 +210,17 @@ In the [Examples](/examples) directory you can find scripts leveraging
the Orchestrator class demonstrating some uses

* [create_user.py](/examples/create_user.py)
* creates a new read-only user on Orchestrator and returns the
* creates a new read-only user on Orchestrator and returns the
configured details
* [print_appliance_info.py](/examples/print_appliance_info.py)
* retrieves all appliances, retrieves detailed attributes of the
* retrieves all appliances, retrieves detailed attributes of the
appliances, and prints details in a table format
* [run_packet_capture.py](/examples/run_packet_capture.py)
* runs a tcpdump packet capture on a specified appliance, once
* runs a tcpdump packet capture on a specified appliance, once
completed, uploads to Orchestrator for user retrieval

* [preconfig.py](/examples/generate_preconfig/preconfig.py)
* uses a CSV file as source data to generate Edge Connect YAML
preconfig from a Jinja template

## This is an alpha product

Expand Down Expand Up @@ -255,7 +254,6 @@ See contribution details at [Contributing](CONTRIBUTING.md)

Release notes are located in ``docs/source/release-notes`` directory [here](docs/source/release-notes)


## Authors

Authored by Zach Camara, email at <zachary.camara@hpe.com>
2 changes: 1 addition & 1 deletion _version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "0.14.0a2.dev1"
version = "0.15.0a2.dev0"
102 changes: 102 additions & 0 deletions docs/source/code_formatting.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
=========================
Code Formatting
=========================


Flake8 is run on the codebase according to parameters in the .flake8
file following PEP8 conventions where possible.

Naming Conventions
^^^^^^^^^^^^^^^^^^

* Classes are named in CamelCase, e.g. HttpCommon, Orchestrator,
EdgeConnect
* Functions are variables are named in snake_case, e.g. get_appliances()
* Private functions begin with ``_`` e.g. ``_get()`` or ``_req_post()``

Docstrings and comments
^^^^^^^^^^^^^^^^^^^^^^^
* Docstrings follow Sphinx/reStructured Text Formatting
* Short initial description
* Reference to where to find this function in Swagger UI
* Longer description, notes, examples if applicable
* parameter and return descriptions and types
* All functions have docstrings outlining parameters and returns
* Code in a function begins the line immediately following the docstring

**Example:**

.. code::

"""<Short description here>

.. list-table::
:header-rows: 1

* - Swagger Section
- Method
- Endpoint
* - <swagger section> -> e.g. login
- <method> -> e.g. GET
- <endpoint> -> e.g. /logout

<longer description>

.. note::

an optional note

.. warning::

an optional warning

:param <param name>: <param description>
:type <param name>: <param type>
:return: <return description>
:rtype: <return type>
"""
<code begins here>

Maximum Line Length
^^^^^^^^^^^^^^^^^^^
* All comments and docstrings have a maximum line length of 72
characters
* All functional code has a maximum line length of 79 characters
* In the rare case when a string or docstring can't be wrapped over
multiple lines (e.g. specifying a long API endpoint in docstring)
use ``# noqa:`` at the end of the docstring with ``E501``
for extending past 79 and ``W505`` for extending past 72, or just
``W505`` if past 72 but within 79.

**Example:**

.. code::

"""docstring

.. list-table::
:header-rows: 1

* - Swagger Section
- Method
- Endpoint
* - login
- GET
- /long_endpoint/path/{that_cannot}/be/wrapped/over_multiple_lines
...
""" # noqa: W505


Type Hinting (PEP585)
^^^^^^^^^^^^^^^^^^^^^
* All parameters for functions have type hinting following PEP585
(Python 3.9+) formatting with generic types.

.. code::

def my_func(my_var: str) -> dict:
...
# or
def my_func(my_var: list[int]) -> list:
...

6 changes: 3 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
# -- Project information -----------------------------------------------------

project = "pyedgeconnect"
copyright = "2021 Hewlett Packard Enterprise Development LP"
copyright = "2022 Hewlett Packard Enterprise Development LP"
author = "Zach Camara"

# Main version number
version = "0.14"
version = "0.15"
# The full version, including alpha/beta/rc tags
release = "0.14.0-a2"
release = "0.15.0-a1"


# -- General configuration ---------------------------------------------------
Expand Down
112 changes: 112 additions & 0 deletions docs/source/examples/auth_example.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
.. auth_example:

============================
Authentication
============================

The following code snippet is an example of handling multiple authentication
methods when connecting to an Aruba Orchestrator instance with pyedgeconnect.

The example scripts provided in the repository use this process in
addition to any other required logic for a particular use-case.



Environment variables
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The example script will also look for the following environment variables
related to authenticating to Orchestrator

``ORCH_URL``
``ORCH_API_KEY``
``ORCH_USER``
``ORCH_PASSWORD``

If ORCH_URL is specified, it will take precedence, otherwise user will
be prompted for input to enter the Orchestrator IP or FQDN

If ORCH_API_KEY is specified it will take precedence for an authentication
method over user/password authentication. If not found, the user will be
prompted for entering an API key.

.. code-block:: python

import argparse
import getpass
import os

from pyedgeconnect import Orchestrator

# Parse runtime arguments to specify an Orchestrator IP or FQDN
parser = argparse.ArgumentParser()
parser.add_argument(
"-o",
"--orch",
help="specify Orchestrator URL",
type=str,
)
args = parser.parse_args()

# Set Orchestrator FQDN/IP via arguments, environment variable,
# or user input if neither in argument or environment variable
if vars(args)["orch"] is not None:
orch_url = vars(args)["orch"]
elif os.getenv("ORCH_URL") is not None:
orch_url = os.getenv("ORCH_URL")
else:
orch_url = input("Orchstrator IP or FQDN: ")

# Set Orchestrator API Key via environment variable or user input
# Skipping will fallback to user/password authentication
if os.getenv("ORCH_API_KEY") is not None:
orch_api_key = os.getenv("ORCH_API_KEY")
else:
orch_api_key_input = input("Orchstrator API Key (enter to skip): ")
if len(orch_api_key_input) == 0:
orch_api_key = None
# Set user and password if present in environment variable
orch_user = os.getenv("ORCH_USER")
orch_pw = os.getenv("ORCH_PASSWORD")
else:
orch_api_key = orch_api_key_input

# Instantiate Orchestrator with ``log_console`` enabled for
# printing log messages to terminal, and ``verify_ssl`` to False
# which will not verify the web https certificate on Orchestrator
orch = Orchestrator(
orch_url,
api_key=orch_api_key,
log_console=True,
verify_ssl=False,
)

# If not using API key, login to Orchestrator with username/password
if orch_api_key is None:
# If username/password not in environment variables, prompt user
if orch_user is None:
orch_user = input("Enter Orchestrator username: ")
orch_pw = getpass.getpass("Enter Orchestrator password: ")
# Check if multi-factor authentication required
mfa_prompt = input("Are you using MFA for this user (y/n)?: ")
if mfa_prompt == "y":
orch.send_mfa(orch_user, orch_pw, temp_code=False)
token = input("Enter MFA token: ")
else:
token = ""
# Login to Orchestrator with user/password to check auth before
# proceeding
confirm_auth = orch.login(orch_user, orch_pw, mfacode=token)
if confirm_auth:
pass
else:
print("Authentication to Orchestrator Failed")
exit()
# If API key specified, check that key is valid before proceeding
else:
confirm_auth = orch.get_orchestrator_hello()
if confirm_auth != "There was an internal server error.":
pass
else:
print("Authentication to Orchestrator Failed")
exit()
Loading