Add your description here
Project description
Python NSO Library
Thin wrapper around RestConf designed to interact with NSO.
Key Features:
- Detect errors raising meaningful exceptions
- Parameter support in URL to avoid URL Encoding mistakes
- Support for generating and executing YANG Patches
- Handling of dry-run responses
Usage
Installing
uv add python-nso-client
Writing code with nso_client
from nso_client import NSOClient
from httpx import BasicAuth
nso = NSOClient(
"https://localhost",
auth=BasicAuth("acct", "secret")
)
# Fetching data
resp = nso.get("/tailf-ncs:services/bb:backbone", content="config")
for bb in resp["bb:backbone"]:
print(bb)
# Create objects
resp = nso.put(
"/tailf-ncs:services/bb:backbone={}",
"my-bb-1",
payload={
"bb:backbone": [
{
"name": "my-bb-1",
"links": [
{"device": "xr0", "interface": "TenGigE0/0/0"},
{"device": "xr1", "interface": "TenGigE0/0/1"},
],
"metric": 500,
"admin-state": "in-service",
}
]
},
)
# Using yang-patch to modify multiple areas in the same transaction
patch = nso.yang_patch("/tailf-ncs:services")
patch.merge("/bb:backbone={}", "my-bb-1", value=...)
patch.merge("/bb:backbone={}", "my-bb-2", value=...)
patch.delete("/bb:backbone={}", "my-bb-3")
resp = patch.commit(dry_run="cli")
print(resp.changes)
patch.commit()
# Error handling
try:
nso.delete("/tailf-ncs:services/bb:backbone={}", "does-not-exist")
except NotFoundError as exc:
print("Backbone already deleted", exc)
# Fetching results in a None, not an exception
resp = nso.get("/tailf-ncs:services/bb:backbone={}", "does-not-exist")
assert resp is None
Developing
# Build
uv build
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
python_nso_client-0.0.2.tar.gz
(27.0 kB
view details)
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 python_nso_client-0.0.2.tar.gz.
File metadata
- Download URL: python_nso_client-0.0.2.tar.gz
- Upload date:
- Size: 27.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
072b52d12067a634d12bfb39426c9411625cb7c6a8bc5f68fb04da6b6ba366d9
|
|
| MD5 |
16f38270ba30e6c04b1e1c00696b5f4e
|
|
| BLAKE2b-256 |
2644d7f3fd34e207b2869a1a837f24f61ef688792ed62e5580715a8860f132f7
|
File details
Details for the file python_nso_client-0.0.2-py3-none-any.whl.
File metadata
- Download URL: python_nso_client-0.0.2-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d740236a01f940f54d9bbc95f49c992759e4fcd52973ae45947f8b04164c0f38
|
|
| MD5 |
f337b8adde218987818f62d78309a3e9
|
|
| BLAKE2b-256 |
c1b6c3171c50bbcdc31722a8e487e314776b7edd49195ce05c372c9d18977009
|