Skip to content

Commit ac1c7cb

Browse files
authored
Update to Version 1.0.8
## Version 1.0.8 (13/10/2025) 1. Updated common.py to include an optioal timeout parameter for web requests within the ClearPassAPILogin class. 2. API code includes new, modified or deleted API that is implemented in Aruba ClearPass v6.12.6. 3. Updated Readme 4. Included new function within new Utils class to pull token from token file. 5. Updated __init__.py file
1 parent 88af2d4 commit ac1c7cb

File tree

7 files changed

+46
-96
lines changed

7 files changed

+46
-96
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,4 @@ accepted.
171171

172172
[airheads-link]: https://community.arubanetworks.com/t5/Developer-Community/bd-p/DeveloperCommunity
173173
[devhub-link]: https://developer.arubanetworks.com/aruba-cppm/docs
174-
[email-link]: mailto:aruba-automation@hpe.com
174+
[email-link]: mailto:aruba-automation@hpe.com

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 Aruba, a Hewlett Packard Enterprise company
3+
Copyright (c) 2025 Aruba, a Hewlett Packard Enterprise company
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

PKG-INFO.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 2.1
22
Name: pyclearpass
3-
Version: 1.0.7
3+
Version: 1.0.8
44
Summary: This package contains all of the API functions to work with the HPE Aruba Networking ClearPass API. This package been built based on version v6.12 but is always generated on the latest version available to download.
55
Project-URL: Homepage, https://github.com/aruba/pyclearpass
66
Author-email: Aruba Automation <aruba-automation@hpe.com>

README.md

Lines changed: 34 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ from pyclearpass import *
6969
```
7070

7171
Create a object to login into ClearPass. The login object needs to be passed to use any function within the ClearPass API.
72-
Two examples below shows how to create the login object (either one can be used, but not both).
72+
Three examples below shows how to create the login object (either one can be used, but not both).
7373

7474
1. Using client credentials
7575

@@ -88,6 +88,17 @@ clientsecret="myclientsecretexample", clientid="myclientidexample", verify_ssl=F
8888
login = ClearPassAPILogin(server="https://yourserver.network.local:443/api",api_token="yoursecretapitoken", verify_ssl=False)
8989
```
9090

91+
3. Using the api token located in a file. You can generate an API token by clicking on the API client and then clicking 'Generate Access Token'. The Token file is expected in the following format and is expected to exist in the script execution folder. This is the preferred method to avoid having your credentials directly exposed in your script file.
92+
93+
```json
94+
{"access_token":"your_token_here"}
95+
```
96+
The python file is expected in the following format
97+
```python
98+
token = Utils.get_token_from_file("token.json")
99+
login = ClearPassAPILogin(server="https://yourserver.network.local:443/api",api_token=token, verify_ssl=False)
100+
```
101+
91102
Find an API you want to use, by prefixing `Api` in your IDE and Intellisense will show the available APIs available. Each of the top level API category names are available as a module. Once you have chosen a specific API module to use, for example ApiPolicyElements, it will show you the available methods if you suffix a . to the command - `ApiPolicyElements.`
92103

93104
The example below prints a single the roles available within the ClearPass server.
@@ -133,9 +144,10 @@ or
133144

134145
The examples below all exclude importing the module and creating the login variable. This is described directly below. Note, these are just a full examples, there are hundreds of API commands available within the SDK.
135146

136-
## New Login Session (Mandatory)
147+
## Login
148+
### Mandatory Login Session Parameters
137149

138-
The login variable only needs to be defined once in the script. Two examples are shown below to achieve this;
150+
The login variable only needs to be defined once in the script. Three examples are shown below to achieve this;
139151

140152
1. Using client_credentials
141153

@@ -156,6 +168,25 @@ from pyclearpass import *
156168
login = ClearPassAPILogin(server="https://yourserver.network.local:443/api",api_token="yoursecretapitoken", verify_ssl=False)
157169
```
158170

171+
3. Using the api token located in a file. You can generate an API token by clicking on the API client and then clicking 'Generate Access Token'. The Token file is expected in the following format and is expected to exist in the script execution folder. This is the preferred method to avoid having your credentials directly exposed in your script file.
172+
173+
```json
174+
{"access_token":"your_token_here"}
175+
```
176+
The python file is expected in the following format
177+
```python
178+
token = Utils.get_token_from_file("token.json")
179+
login = ClearPassAPILogin(server="https://yourserver.network.local:443/api",api_token=token, verify_ssl=False)
180+
```
181+
### Optional Login Session Parameters
182+
183+
You can also include a timeout on the within the ClearPassAPILogin class to define how long the web request should try before timing out. An example is provided below of 10 seconds
184+
185+
```python
186+
token = Utils.get_token_from_file("token.json")
187+
login = ClearPassAPILogin(server="https://yourserver.network.local:443/api",api_token=token, verify_ssl=False,timeout=10)
188+
```
189+
159190
## Get Local Server Configuration
160191

161192
```python
@@ -345,90 +376,3 @@ print(json.dumps(view_guest_device,indent=2))
345376
```python
346377
print(ApiPolicyElements.delete_enforcement_policy_by_enforcement_policy_id(login,enforcement_policy_id='3058'))
347378
```
348-
349-
## Create a new Enforcement Policy with staged initial rules and then a loop to create additional rules.
350-
351-
```python
352-
newEnforcementPolicy= {
353-
"name": "MPSK Demo",
354-
"description": "MPSK Enforcement",
355-
"enforcement_type": "RADIUS",
356-
"default_enforcement_profile": "Deny Device",
357-
"rule_eval_algo": "first-applicable",
358-
"rules": ''}
359-
360-
newEnforcementPolicyRules =({"rules":[]})
361-
362-
initialrule = {
363-
"enforcement_profile_names": [
364-
"Sample Enforcement Policy"
365-
],
366-
"condition": [
367-
{
368-
"type": "Connection",
369-
"name": "AP-Name",
370-
"oper": "BEGINS_WITH",
371-
"value": "APDemo"
372-
}
373-
]
374-
}
375-
newEnforcementPolicyRules["rules"].append(initialrule)
376-
377-
for id in range(9,11):
378-
randompsk = random.randint(8000000,9000000)
379-
epf ={
380-
"enforcement_profile_names": [
381-
"Sample Enforcement Policy"
382-
383-
],
384-
"condition": [
385-
{
386-
"type": "Connection",
387-
"name": "AP-Name",
388-
"oper": "BEGINS_WITH",
389-
"value": "APNo"+str(id)
390-
}
391-
]
392-
}
393-
394-
newEnforcementPolicyRules["rules"].append(epf)
395-
396-
newEnforcementPolicy["rules"] = newEnforcementPolicyRules["rules"]
397-
print(ApiPolicyElements.new_enforcement_policy(login,body=newEnforcementPolicy))
398-
```
399-
400-
> 📘
401-
>
402-
> You may find it easier to initially pull a working Enforcement Policy with minimal rules before trying to create a new one from scratch.
403-
>
404-
> For example, the rule evaluation in the GUI shows as 'First applicable', however in the back-end it is shown as 'first-applicable'. This example is a working policy. It is demonstrated with a loop which could read an entry in a CSV file if adapted.
405-
406-
## Update an existing Enforcement Policy, retaining the original items and using a loop to add additional items
407-
408-
```python
409-
epol = ApiPolicyElements.get_enforcement_policy_name_by_name(login, name="MPSK Enforcement")
410-
OriginalRules = epol["rules"]
411-
CombinedRules =({"rules":[]})
412-
for item in range(len(OriginalRules)):
413-
CombinedRules["rules"].append(OriginalRules[item])
414-
415-
for no in range(9,11):
416-
rule ={
417-
"enforcement_profile_names": [
418-
"Sample Enforcement Policy"
419-
420-
],
421-
"condition": [
422-
{
423-
"type": "Connection",
424-
"name": "AP-Name",
425-
"oper": "BEGINS_WITH",
426-
"value": "APNo"+str(no)
427-
}
428-
]
429-
}
430-
431-
CombinedRules["rules"].append(rule)
432-
433-
ApiPolicyElements.update_enforcement_policy_name_by_name(login,name="MPSK Enforcement",body=CombinedRules)
434-
```

RELEASE-NOTES.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,10 @@ This document contains high level documented changes to the pyclearpass package.
4040
2. Added response content-type to methods in other api files where required.
4141

4242
## Version 1.0.7 (08/11/2024)
43-
1. Updated common.py to convert dict to json when creating parameterised urls within the _generate_parameterised_url method.
43+
1. Updated common.py to convert dict to json when creating parameterised urls within the _generate_parameterised_url method.
44+
45+
## Version 1.0.8 (13/10/2025)
46+
1. Updated common.py to include an optioal timeout parameter for web requests within the ClearPassAPILogin class.
47+
2. API code includes new, modified or deleted API that is implemented in Aruba ClearPass v6.12.6.
48+
3. Updated Readme
49+
4. Included new function within new Utils class to pull token from token file.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = ["hatchling"]
33
build-backend = "hatchling.build"
44
[project]
55
name = "pyclearpass"
6-
version = "1.0.7"
6+
version = "1.0.8"
77
authors = [{ name="Aruba Automation", email="aruba-automation@hpe.com" }]
88
dependencies = ["requests >=2.24","urllib3 >=1.25.10"]
99
description = "HPE Aruba Networking ClearPass SDK has been developed in Python v3.9 to utilise the full functionality of the HPE Aruba Networking ClearPass REST API environment. Each available REST API command is available for use in this module."

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
author_email='aruba-automation@hpe.com',
99
packages=['pyclearpass'],
1010
install_requires=['requests >=2.24','urllib3 >=1.25.10'],
11-
version='1.0.7',
11+
version='1.0.8',
1212
license='MIT',
1313
description='HPE Aruba Networking ClearPass SDK has been developed in Python v3.9 to utilise the full functionality of the HPE Aruba Networking ClearPass REST API environment. Each available REST API command is available for use in this package.',
1414
long_description=open('README.md').read(),

0 commit comments

Comments
 (0)