Simple Python client for SonicWall SonicOS REST API (with HTTP Digest Auth).
Project description
SonicWall API Python Client
A simple Python client for interacting with the SonicWall SonicOS REST API, using HTTP Digest Authentication.
Features
- Login / logout to the SonicOS API
- Check and manage pending configurations
- Generic requests (
GET,POST,PUT,PATCH,DELETE) - Persistent session support via
requests.Session()
Installation
Install the package from PyPI:
pip install sonicwall-api-client
Import
from sonicwall_api_client import SonicWallClient
Examples
Connect to the firewall
# Initialize the client
client = SonicWallClient(
ip="192.168.1.1",
port=443,
username="admin",
password="password"
)
# Log in
success, message, _ = client.login()
if success:
print("Login successful.")
else:
print(f"Login failed: {message}")
Check pending configurations
success, message, data = client.get_pending_configurations()
if success:
print("Pending configurations:", data)
else:
print(f"Error: {message}")
Commit configurations
success, message, _ = client.commit()
if success:
print("Configurations committed successfully.")
else:
print(f"Commit error: {message}")
Discard pending configurations
success, message, _ = client.delete_pending_configurations()
if success:
print("Pending changes discarded.")
else:
print(f"Error: {message}")
Generic request
# Without payload
success, message, data = client.request("get", "/zones")
if success:
print("Zones list:", data)
else:
print(f"Request error: {message}")
# With payload
payload = {
"zones": [
{
"name": "LAN_IT",
"security_type": "public",
"interface_trust": False,
"auto_generate_access_rules": {
"allow_from_to_equal": False,
"allow_from_higher": False,
"allow_to_lower": False,
"deny_from_lower": False
},
}
]
}
success, message, _ = client.request("post", "/zones", payload)
if success:
print("Object created successfully.")
else:
print(f"Creation error: {message}")
Logout
success, message, _ = client.logout()
if success:
print("Logged out successfully.")
else:
print(f"Logout error: {message}")
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sonicwall_api_client-1.0.2.tar.gz.
File metadata
- Download URL: sonicwall_api_client-1.0.2.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68b4e61472a20076363e4308473183c7c91440a32929a5bcdeed407e87c24420
|
|
| MD5 |
e4ca453ed0806984624bd6e1c8bb1765
|
|
| BLAKE2b-256 |
554491b22b7cd8c0479ca5851384655fedaf0262e1f397a35f693d07d3b834e8
|
File details
Details for the file sonicwall_api_client-1.0.2-py3-none-any.whl.
File metadata
- Download URL: sonicwall_api_client-1.0.2-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1b52c63a1a6336bc1e2de84e9edad225c5208c12a0c72bc98b21b3055be106f
|
|
| MD5 |
71818517fe23c8916b7cdfd1ac042769
|
|
| BLAKE2b-256 |
af9ba34a05d5860d98666d49f3e4b4e51450d1173f3b3bdd89ca4016fefea10b
|