ones-pyapi 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. ones_pyapi-0.1.0/PKG-INFO +45 -0
  2. ones_pyapi-0.1.0/README.md +36 -0
  3. ones_pyapi-0.1.0/examples/examples_usage_bgp.py +49 -0
  4. ones_pyapi-0.1.0/examples/examples_usage_control_plane.py +27 -0
  5. ones_pyapi-0.1.0/examples/examples_usage_device.py +47 -0
  6. ones_pyapi-0.1.0/examples/examples_usage_fm.py +26 -0
  7. ones_pyapi-0.1.0/examples/examples_usage_health.py +42 -0
  8. ones_pyapi-0.1.0/examples/examples_usage_inventory.py +68 -0
  9. ones_pyapi-0.1.0/examples/examples_usage_misc.py +29 -0
  10. ones_pyapi-0.1.0/examples/examples_usage_traffic.py +59 -0
  11. ones_pyapi-0.1.0/examples/test_example.py +13 -0
  12. ones_pyapi-0.1.0/ones/__init__.py +3 -0
  13. ones_pyapi-0.1.0/ones/client.py +75 -0
  14. ones_pyapi-0.1.0/ones/exceptions.py +2 -0
  15. ones_pyapi-0.1.0/ones/resources/__init__.py +0 -0
  16. ones_pyapi-0.1.0/ones/resources/base.py +24 -0
  17. ones_pyapi-0.1.0/ones/resources/bgp.py +80 -0
  18. ones_pyapi-0.1.0/ones/resources/control_plane.py +19 -0
  19. ones_pyapi-0.1.0/ones/resources/device.py +46 -0
  20. ones_pyapi-0.1.0/ones/resources/fm.py +137 -0
  21. ones_pyapi-0.1.0/ones/resources/health.py +63 -0
  22. ones_pyapi-0.1.0/ones/resources/inventory.py +145 -0
  23. ones_pyapi-0.1.0/ones/resources/misc.py +22 -0
  24. ones_pyapi-0.1.0/ones/resources/traffic.py +58 -0
  25. ones_pyapi-0.1.0/ones/resources/user.py +16 -0
  26. ones_pyapi-0.1.0/ones/transport.py +53 -0
  27. ones_pyapi-0.1.0/ones_pyapi.egg-info/PKG-INFO +45 -0
  28. ones_pyapi-0.1.0/ones_pyapi.egg-info/SOURCES.txt +31 -0
  29. ones_pyapi-0.1.0/ones_pyapi.egg-info/dependency_links.txt +1 -0
  30. ones_pyapi-0.1.0/ones_pyapi.egg-info/requires.txt +1 -0
  31. ones_pyapi-0.1.0/ones_pyapi.egg-info/top_level.txt +5 -0
  32. ones_pyapi-0.1.0/pyproject.toml +20 -0
  33. ones_pyapi-0.1.0/setup.cfg +4 -0
@@ -0,0 +1,45 @@
1
+ Metadata-Version: 2.4
2
+ Name: ones-pyapi
3
+ Version: 0.1.0
4
+ Summary: Python SDK for ONES (Aviz Networks)
5
+ Author-email: Kavyansh Pandey <kavyansh.pandey@aviznetworks.com>
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: requests
9
+
10
+ ones_sdk/
11
+
12
+ ├── ones/ # main package
13
+ │ ├── __init__.py
14
+ │ │
15
+ │ ├── client.py # main entry point
16
+ │ ├── transport.py # HTTP layer
17
+ │ ├── exceptions.py # custom errors
18
+ │ ├── constants.py # endpoints, paths
19
+ │ │
20
+ │ ├── resources/ # API groups
21
+ │ │ ├── __init__.py
22
+ │ │ ├── base.py
23
+ │ │ ├── user.py
24
+ │ │ ├── health.py
25
+ │ │ └── inventory.py
26
+ │ │
27
+ │ ├── utils/ # helpers
28
+ │ │ ├── __init__.py
29
+ │ │ └── parser.py # json parsing helpers
30
+ │ │
31
+ │ └── models/ # (optional, later)
32
+ │ ├── __init__.py
33
+ │ └── user.py
34
+
35
+ ├── tests/
36
+ │ ├── test_user.py
37
+ │ ├── test_health.py
38
+ │ └── test_inventory.py
39
+
40
+ ├── examples/
41
+ │ └── basic_usage.py
42
+
43
+ ├── requirements.txt
44
+ ├── setup.py / pyproject.toml
45
+ └── README.md
@@ -0,0 +1,36 @@
1
+ ones_sdk/
2
+
3
+ ├── ones/ # main package
4
+ │ ├── __init__.py
5
+ │ │
6
+ │ ├── client.py # main entry point
7
+ │ ├── transport.py # HTTP layer
8
+ │ ├── exceptions.py # custom errors
9
+ │ ├── constants.py # endpoints, paths
10
+ │ │
11
+ │ ├── resources/ # API groups
12
+ │ │ ├── __init__.py
13
+ │ │ ├── base.py
14
+ │ │ ├── user.py
15
+ │ │ ├── health.py
16
+ │ │ └── inventory.py
17
+ │ │
18
+ │ ├── utils/ # helpers
19
+ │ │ ├── __init__.py
20
+ │ │ └── parser.py # json parsing helpers
21
+ │ │
22
+ │ └── models/ # (optional, later)
23
+ │ ├── __init__.py
24
+ │ └── user.py
25
+
26
+ ├── tests/
27
+ │ ├── test_user.py
28
+ │ ├── test_health.py
29
+ │ └── test_inventory.py
30
+
31
+ ├── examples/
32
+ │ └── basic_usage.py
33
+
34
+ ├── requirements.txt
35
+ ├── setup.py / pyproject.toml
36
+ └── README.md
@@ -0,0 +1,49 @@
1
+ from ones.client import ONESClient
2
+
3
+ client = ONESClient(
4
+ url="https://your-instance/",
5
+ username="your_username",
6
+ password="your_password"
7
+ )
8
+
9
+ client.connect()
10
+
11
+ # 1. BGP List
12
+ bgp_list = client.bgp.bgp_list()
13
+ print("BGP List:", bgp_list)
14
+
15
+ # 2. Neighbor List
16
+ neighbors = client.bgp.neighbor_list(device_address="xx.xx.xx.xx.xx.xx", vrf="default")
17
+ print("Neighbor List:", neighbors)
18
+
19
+ # 3. Protocol Mega
20
+ protocol_mega = client.bgp.protocol_mega(
21
+ from_date="2026-03-23 10:09:36",
22
+ to_date="2026-03-23 11:09:36",
23
+ window_size="1 hour",
24
+ device_address="xx.xx.xx.xx.xx.xx",
25
+ vrf="default"
26
+ )
27
+ print("Protocol Mega:", protocol_mega)
28
+
29
+ # 4. Protocol Neighbor Mega
30
+ protocol_neighbor_mega = client.bgp.protocol_neighbor_mega(
31
+ from_date="2026-03-23 10:09:36",
32
+ to_date="2026-03-23 11:09:36",
33
+ window_size="1 hour",
34
+ device_address="xx.xx.xx.xx.xx.xx",
35
+ vrf="default"
36
+ )
37
+ print("Protocol Neighbor Mega:", protocol_neighbor_mega)
38
+
39
+ protocol_bgps = client.bgp.protocols_bgp(ip_address="x.x.x.x")
40
+ print("Protocol Map:", protocol_bgps)
41
+
42
+ vlan_mapping = client.bgp.vlan_mapping(device_address="xx.xx.xx.xx.xx.xx")
43
+ print("VLAN Mapping:", vlan_mapping)
44
+
45
+
46
+
47
+
48
+
49
+
@@ -0,0 +1,27 @@
1
+ from ones.client import ONESClient
2
+
3
+ client = ONESClient(
4
+ url="https://your-instance/",
5
+ username="your_username",
6
+ password="your_password"
7
+ )
8
+
9
+ client.connect()
10
+
11
+
12
+ # VLAN
13
+ vlan_info = client.control_plane.vlan()
14
+ print("VLAN Info:", vlan_info)
15
+
16
+ # MCLAG
17
+ mclag_info = client.control_plane.mclag()
18
+ print("MCLAG Info:", mclag_info)
19
+
20
+ # LACP
21
+ lacp_info = client.control_plane.lacp()
22
+ print("LACP Info:", lacp_info)
23
+
24
+ # VRRP
25
+ vrrp_info = client.control_plane.vrrp()
26
+ print("VRRP Info:", vrrp_info)
27
+
@@ -0,0 +1,47 @@
1
+ from ones.client import ONESClient
2
+ client = ONESClient(
3
+ url="https://your-instance/",
4
+ username="your_username",
5
+ password="your_password"
6
+ )
7
+
8
+ client.connect()
9
+
10
+
11
+ # Example usage of DeviceResource methods
12
+ links = client.device.get_links()
13
+ print("Links:", links)
14
+
15
+
16
+ transceiver_mega = client.device.get_transceiver_mega(
17
+ from_date="2024-06-01T00:00:00Z",
18
+ to_date="2024-06-02T00:00:00Z",
19
+ window_size=10,
20
+ device_address="example_device_address",
21
+ active_tab="example_active_tab",
22
+ ifname="example_ifname"
23
+ )
24
+
25
+ print("Transceiver Mega:", transceiver_mega)
26
+
27
+ transceiver_details = client.device.get_transceiver_details(
28
+ device_address="example_device_address",
29
+ name="example_name"
30
+ )
31
+ print("Transceiver Details:", transceiver_details)
32
+
33
+ device_list_telemetry_version_and_fm_version = client.device.get_device_list_telemetry_version_and_fm_version()
34
+ print("Device List Telemetry Version and FM Version:", device_list_telemetry_version_and_fm_version)
35
+
36
+ interfaces = client.device.get_interfaces()
37
+ print("Interfaces:", interfaces)
38
+
39
+ gpu_list = client.device.get_gpu_list()
40
+ print("GPU List:", gpu_list)
41
+
42
+ docker_containers = client.device.get_docker_containers()
43
+ print("Docker Containers:", docker_containers)
44
+ gpu_stats = client.device.get_gpu_stats()
45
+ print("GPU Stats:", gpu_stats)
46
+ image_management_status = client.device.get_image_management_status(ip_address="example_ip_address")
47
+ print("Image Management Status:", image_management_status)
@@ -0,0 +1,26 @@
1
+
2
+ from ones.client import ONESClient
3
+
4
+ client = ONESClient(
5
+ url="https://your-instance/",
6
+ username="your_username",
7
+ password="your_password"
8
+ )
9
+
10
+ client.connect()
11
+
12
+
13
+
14
+ # Testing FM Backup Config API
15
+ check =client.fm.backupConfig({
16
+ "data": [
17
+ {
18
+ "ip": "xx.xx.xx.xx",
19
+ "label": "ss"
20
+ }
21
+ ]
22
+ })
23
+
24
+ print(check)
25
+
26
+
@@ -0,0 +1,42 @@
1
+ from ones.client import ONESClient
2
+
3
+ client = ONESClient(
4
+ url="https://your-instance/",
5
+ username="your_username",
6
+ password="your_password"
7
+ )
8
+
9
+ client.connect()
10
+
11
+ # Device List
12
+ devices = client.health.device_list()
13
+ print("Devices:", devices)
14
+
15
+ # Device Info
16
+ info = client.health.device_info(
17
+ from_date="2026-03-23 00:56:30",
18
+ to_date="2026-03-24 09:56:30",
19
+ window_size="1 hour",
20
+ device_address="xx.xx.xx.xx.xx.xx"
21
+ )
22
+ print("Device Info:", info)
23
+
24
+ # Mega API
25
+ mega = client.health.mega(
26
+ from_date="2026-03-23 12:05:44",
27
+ to_date="2026-03-24 12:05:44",
28
+ window_size="1 day",
29
+ device_address="xx.xx.xx.xx.xx.xx"
30
+ )
31
+ print("Mega:", mega)
32
+
33
+ # Top CPU Consuming Services
34
+ top_services = client.health.top_cpu_consuming_services(
35
+ device_address="xx.xx.xx.xx.xx.xx"
36
+ )
37
+
38
+ print("Top CPU Consuming Services:", top_services)
39
+
40
+ # Fabric Wise Health
41
+ fabric_health = client.health.fabric_wise_health()
42
+ print("Fabric Wise Health:", fabric_health)
@@ -0,0 +1,68 @@
1
+ from ones.client import ONESClient
2
+
3
+ client = ONESClient(
4
+ url="https://your-instance/",
5
+ username="your_username",
6
+ password="your_password"
7
+ )
8
+
9
+ client.connect()
10
+
11
+ # Device Interfaces
12
+ interfaces = client.inventory.device_interfaces(device_address="xx.xx.xx.xx.xx.xx")
13
+ print("Device Interfaces:", interfaces)
14
+
15
+ # Device Peripherals
16
+ peripherals = client.inventory.device_peripherals(device_address="xx.xx.xx.xx.xx.xx")
17
+ print("Device Peripherals:", peripherals)
18
+
19
+ # Device Info
20
+ device_info = client.inventory.device_info(device_address="xx.xx.xx.xx.xx.xx")
21
+ print("Device Info:", device_info)
22
+
23
+ # Device Firmware
24
+ firmware = client.inventory.device_firmware(device_address="xx.xx.xx.xx.xx.xx")
25
+ print("Device Firmware:", firmware)
26
+
27
+ # Link Info
28
+ link_info = client.inventory.link_info(device_address="xx.xx.xx.xx.xx.xx")
29
+ print("Link Info:", link_info)
30
+
31
+ # minizip test
32
+ minizip = client.inventory.minizip_test()
33
+ print("Minizip Test:", minizip)
34
+
35
+ # Interface Flaps
36
+ interface_flaps = client.inventory.interface_flaps(
37
+ start_time="2026-03-23 02:09:36",
38
+ end_time="2026-03-24 11:09:36",
39
+ limit=10
40
+ )
41
+ print("Interface Flaps:", interface_flaps)
42
+
43
+ # Interface Mega
44
+ interface_mega = client.inventory.interface_mega()
45
+ print("Interface Mega:", interface_mega)
46
+
47
+ # NIC Info
48
+ nic_info = client.inventory.nic_info(device_address="xx.xx.xx.xx.xx.xx")
49
+ print("NIC Info:", nic_info)
50
+
51
+ # Device Details
52
+ device_details = client.inventory.device_details(device_address="xx.xx.xx.xx.xx.xx")
53
+ print("Device Details:", device_details)
54
+
55
+ # Inventory Details Orchestration
56
+ inv_details_orchest = client.inventory.inv_details_orchest()
57
+ print("Inventory Details Orchestration:", inv_details_orchest)
58
+
59
+
60
+ # Device YAML Files
61
+ device_yaml_files = client.inventory.device_yaml_files()
62
+ print("Device YAML Files:", device_yaml_files)
63
+
64
+ # Mini Inventory
65
+ mini_inventory = client.inventory.mini_inventory()
66
+ print("Mini Inventory:", mini_inventory)
67
+
68
+
@@ -0,0 +1,29 @@
1
+ from ones.client import ONESClient
2
+
3
+ client = ONESClient(
4
+ url="https://your-instance/",
5
+ username="your_username",
6
+ password="your_password"
7
+ )
8
+
9
+ client.connect()
10
+
11
+
12
+ # Add methofs for above calls
13
+ is_fm_enabled = client.misc.is_fm_enabled()
14
+ print("Is FM Enabled:", is_fm_enabled)
15
+
16
+ world_map_data = client.misc.world_map_data()
17
+ print("World Map Data:", world_map_data)
18
+
19
+ is_ai_assistant_enabled = client.misc.is_ai_assistant_enabled()
20
+ print("Is AI Assistant Enabled:", is_ai_assistant_enabled)
21
+
22
+ illustrator_yaml = client.misc.get_illustrator_yaml()
23
+ print("Illustrator YAML:", illustrator_yaml)
24
+
25
+ region_list = client.misc.region_list()
26
+ print("Region List:", region_list)
27
+
28
+ telemetry_preferences = client.misc.telemetry_preferences()
29
+ print("Telemetry Preferences:", telemetry_preferences)
@@ -0,0 +1,59 @@
1
+
2
+ from ones.client import ONESClient
3
+
4
+ client = ONESClient(
5
+ url="https://your-instance/",
6
+ username="your_username",
7
+ password="your_password"
8
+ )
9
+
10
+ client.connect()
11
+
12
+
13
+
14
+ # 1. is_interf_pfc_enabled
15
+ resp1 = client.traffic.is_interf_pfc_enabled(device_address="xx.xx.xx.xx.xx.xx", ifname="Ethernet1")
16
+ print("is_interf_pfc_enabled:", resp1)
17
+
18
+ # 2. traffic_list
19
+ resp2 = client.traffic.traffic_list(device_address="xx.xx.xx.xx.xx.xx")
20
+ print("traffic_list:", resp2)
21
+
22
+ # 3. get_interface_details
23
+ resp3 = client.traffic.get_interface_details(
24
+ device_address="xx.xx.xx.xx.xx.xx",
25
+ hostname="switch1",
26
+ ipaddress="192.168.1.1",
27
+ layer="L2",
28
+ time_bucket="5m",
29
+ window_size=10,
30
+ license_="standard"
31
+ )
32
+ print("get_interface_details:", resp3)
33
+
34
+ # 4. interface_details
35
+ resp4 = client.traffic.interface_details(
36
+ from_date="2024-06-01T00:00:00Z",
37
+ to_date="2024-06-02T00:00:00Z",
38
+ window_size=10,
39
+ device_address="xx.xx.xx.xx.xx.xx",
40
+ active_tab="tab1",
41
+ ifname="Ethernet1"
42
+ )
43
+ print("interface_details:", resp4)
44
+
45
+ # 5. traffic_mega
46
+ resp5 = client.traffic.traffic_mega(
47
+ from_date="2024-06-01T00:00:00Z",
48
+ to_date="2024-06-02T00:00:00Z",
49
+ window_size=10,
50
+ device_address="xx.xx.xx.xx.xx.xx",
51
+ active_tab="tab1",
52
+ ifname="Ethernet1"
53
+ )
54
+ print("traffic_mega:", resp5)
55
+
56
+ # 6. priority_mapping
57
+ resp6 = client.traffic.priority_mapping(device_address="xx.xx.xx.xx.xx.xx", ifname="Ethernet1")
58
+ print("priority_mapping:", resp6)
59
+
@@ -0,0 +1,13 @@
1
+ # examples/basic_usage.py
2
+
3
+ from ones.client import ONESClient
4
+
5
+ client = ONESClient(
6
+ url="https://your-instance/",
7
+ username="your_username",
8
+ password="your_password"
9
+ )
10
+
11
+ client.connect()
12
+
13
+ print(client.user.list())
@@ -0,0 +1,3 @@
1
+ from .client import ONESClient
2
+
3
+ __all__ = ["ONESClient"]
@@ -0,0 +1,75 @@
1
+ # ones/client.py
2
+
3
+ import requests
4
+ from .transport import Transport
5
+ from .resources.user import UserResource
6
+ from .resources.health import HealthResource
7
+ from .resources.inventory import InventoryResource
8
+ from .resources.traffic import TrafficResource
9
+ from .resources.bgp import BGPResource
10
+ from .resources.control_plane import ControlPlaneResource
11
+ from .resources.misc import MiscResource
12
+ from .resources.device import DeviceResource
13
+ from .resources.fm import FMResource
14
+
15
+ class ONESClient:
16
+ def __init__(self, url, username=None, password=None):
17
+ self.url = url
18
+ self.username = username
19
+ self.password = password
20
+
21
+ self.transport = Transport(base_url=url)
22
+
23
+ # attach resources
24
+ self.user = UserResource(self.transport)
25
+
26
+ # attach health
27
+ self.health = HealthResource(self.transport)
28
+
29
+ # attch inventory
30
+ self.inventory = InventoryResource(self.transport)
31
+
32
+ # attach traffic
33
+ self.traffic = TrafficResource(self.transport)
34
+
35
+ # attach BGP
36
+ self.bgp = BGPResource(self.transport)
37
+
38
+ # attch control plane
39
+ self.control_plane = ControlPlaneResource(self.transport)
40
+
41
+ # attach misc
42
+ self.misc = MiscResource(self.transport)
43
+
44
+ #attach device
45
+ self.device = DeviceResource(self.transport)
46
+
47
+ # Attach FM
48
+ self.fm = FMResource(self.transport)
49
+
50
+ def connect(self):
51
+ import requests
52
+
53
+ resp = requests.post(
54
+ f"{self.url}/api/user/login",
55
+ json={
56
+ "username": self.username,
57
+ "password": self.password,
58
+ "extendedExpiry": False
59
+ },
60
+ verify=False
61
+ )
62
+
63
+ print("STATUS:", resp.status_code)
64
+ print("RAW RESPONSE:", resp.text) # 👈 VERY IMPORTANT
65
+
66
+ if resp.status_code != 200:
67
+ raise Exception(resp.text)
68
+
69
+ try:
70
+ data = resp.json()
71
+ except Exception:
72
+ raise Exception(f"Invalid JSON response: {resp.text}")
73
+
74
+ token = data["data"]["token"]
75
+ self.transport.set_token(token)
@@ -0,0 +1,2 @@
1
+ class OnesClientException(Exception):
2
+ pass
File without changes
@@ -0,0 +1,24 @@
1
+ # ones/resources/base.py
2
+
3
+ import json
4
+
5
+
6
+ class BaseResource:
7
+ def __init__(self, transport):
8
+ self.transport = transport
9
+
10
+ def _get(self, path, filters=None):
11
+ params = None
12
+ if filters:
13
+ params = {"filter": json.dumps(filters)}
14
+ return self.transport.request("GET", path, params=params)
15
+
16
+ def _post(self, path, payload=None):
17
+ return self.transport.request("POST", path, json=payload)
18
+
19
+ def _put(self, path, payload=None):
20
+ return self.transport.request("PUT", path, json=payload)
21
+
22
+ def _delete(self, path):
23
+ return self.transport.request("DELETE", path)
24
+
@@ -0,0 +1,80 @@
1
+ from .base import BaseResource
2
+
3
+ class BGPResource(BaseResource):
4
+ BASE = "/api/bgps"
5
+
6
+ # Handlers
7
+ def bgp_list(self):
8
+ return self._get(f"{self.BASE}/list")
9
+
10
+ def neighbor_list(self, device_address, vrf):
11
+ filters = {
12
+ "deviceAddress": device_address,
13
+ "vrf": vrf
14
+ }
15
+
16
+ return self._get(f"{self.BASE}/neighborList", filters=filters)
17
+
18
+ def protocol_mega(self, from_date, to_date, window_size, device_address, vrf):
19
+ filters = {
20
+ "fromDate": from_date,
21
+ "toDate": to_date,
22
+ "windowSize": window_size,
23
+ "deviceAddress": device_address,
24
+ "vrf": vrf
25
+ }
26
+
27
+ return self._get(f"{self.BASE}/protocolMega", filters=filters)
28
+
29
+ def protocol_neighbor_mega(self, from_date, to_date, window_size, device_address, vrf):
30
+ filters = {
31
+ "fromDate": from_date,
32
+ "toDate": to_date,
33
+ "windowSize": window_size,
34
+ "deviceAddress": device_address,
35
+ "vrf": vrf
36
+ }
37
+
38
+ return self._get(f"{self.BASE}/protocolNeighborMega", filters=filters)
39
+
40
+
41
+ def protocols_bgp(self, ip_address):
42
+ filters = {
43
+ "ipAddress": ip_address
44
+ }
45
+
46
+ return self._get(f"{self.BASE}/Protocols/bgp", filters=filters)
47
+
48
+
49
+ def vlan_mapping(self, device_address):
50
+ filters = {
51
+ "deviceAddress": device_address
52
+ }
53
+
54
+ return self._get(f"{self.BASE}/vlanMapping", filters=filters)
55
+
56
+ def mclag_grid(self, device_address, domain_id, window_size):
57
+ filters = {
58
+ "deviceAddress": device_address,
59
+ "domainId": domain_id,
60
+ "windowSize": window_size
61
+ }
62
+
63
+ return self._get(f"{self.BASE}/mclag-grid", filters=filters)
64
+
65
+ def lacp_grid(self, device_address, port_channel, window_size):
66
+ filters = {
67
+ "deviceAddress": device_address,
68
+ "portChannel": port_channel,
69
+ "windowSize": window_size
70
+ }
71
+
72
+ return self._get(f"{self.BASE}/lacp-grid", filters=filters)
73
+
74
+ def vtep_health_grid(self, device_address, remote_vtep_ip, window_size):
75
+ filters = {
76
+ "deviceAddress": device_address,
77
+ "windowSize": window_size
78
+ }
79
+
80
+ return self._get(f"{self.BASE}/vtep-health-grid", filters=filters)
@@ -0,0 +1,19 @@
1
+ from .base import BaseResource
2
+
3
+ class ControlPlaneResource(BaseResource):
4
+ BASE = "/api/Control-plane"
5
+
6
+ def vxlan(self):
7
+ return self._get(f"{self.BASE}/vxlan")
8
+
9
+ def mclag(self):
10
+ return self._get(f"{self.BASE}/mclag")
11
+
12
+ def lacp(self):
13
+ return self._get(f"{self.BASE}/lacp")
14
+
15
+ def vrrp(self):
16
+ return self._get(f"{self.BASE}/vrrp")
17
+
18
+ def vlan(self):
19
+ return self._get(f"{self.BASE}/vlan")
@@ -0,0 +1,46 @@
1
+ from .base import BaseResource
2
+
3
+ class DeviceResource(BaseResource):
4
+ BASE = "/api/devices"
5
+
6
+ def get_links(self):
7
+ return self._get(f"{self.BASE}/links")
8
+
9
+ def get_transceiver_info(self, filters):
10
+ return self._get(f"{self.BASE}/transceiverInfo", filters=filters)
11
+
12
+ def get_transceiver_mega(self, from_date, to_date, window_size, device_address, active_tab, ifname):
13
+ filters = {
14
+ "fromDate": from_date,
15
+ "toDate": to_date,
16
+ "windowSize": window_size,
17
+ "deviceAddress": device_address,
18
+ "activeTab": active_tab,
19
+ "ifname": ifname
20
+ }
21
+ return self._get(f"{self.BASE}/transceiverMega", filters=filters)
22
+
23
+ def get_transceiver_details(self, device_address, name):
24
+ filters = {
25
+ "deviceAddress": device_address,
26
+ "name": name
27
+ }
28
+ return self._get(f"/api/Device/transceiverDetails", filters=filters)
29
+
30
+ def get_device_list_telemetry_version_and_fm_version(self):
31
+ return self._get(f"/api/Device/deviceListTelemetryVersionAndFMVersion")
32
+
33
+ def get_interfaces(self):
34
+ return self._get(f"/api/Device/interfaces")
35
+
36
+ def get_gpu_list(self):
37
+ return self._get(f"/api/Device/gpulist")
38
+
39
+ def get_docker_containers(self):
40
+ return self._get(f"/api/Device/docker-containers")
41
+
42
+ def get_gpu_stats(self):
43
+ return self._get(f"/api/Device/gpu-stats")
44
+
45
+ def get_image_management_status(self, ip_address):
46
+ return self._get(f"/api/device/imageManagementStatus", filters={"ipAddress": ip_address})
@@ -0,0 +1,137 @@
1
+ from .base import BaseResource
2
+
3
+
4
+ class FMResource(BaseResource):
5
+ BASE = "/api/config"
6
+
7
+ # =====================================
8
+ # FABRIC APIs
9
+ # =====================================
10
+ def listFabric(self):
11
+ return self._get(f"{self.BASE}/listFabric")
12
+
13
+ def getFabric(self, fabricId):
14
+ return self._get(f"{self.BASE}/getFabric", filters={"fabricId": fabricId})
15
+
16
+ def createFabric(self, payload):
17
+ return self._post(f"{self.BASE}/createFabric", payload)
18
+
19
+ def deleteFabric(self, payload):
20
+ return self._post(f"{self.BASE}/deleteFabric", payload)
21
+
22
+ def updateFabric(self, payload):
23
+ return self._patch(f"{self.BASE}/updateFabric", payload)
24
+
25
+ # =====================================
26
+ # INTENT APIs (DAY-1)
27
+ # =====================================
28
+ def uploadIntent(self, payload):
29
+ return self._post(f"{self.BASE}/uploadIntent", payload)
30
+
31
+ def validateIntent(self, payload):
32
+ return self._post(f"{self.BASE}/validateIntent", payload)
33
+
34
+ def getIntentValidation(self, fabricId):
35
+ return self._get(
36
+ f"{self.BASE}/getIntentValidation",
37
+ filters={"fabricId": fabricId}
38
+ )
39
+
40
+ def applyIntent(self, payload):
41
+ return self._post(f"{self.BASE}/applyIntent", payload)
42
+
43
+ def getIntentStatus(self, fabricId):
44
+ return self._get(
45
+ f"{self.BASE}/getIntentStatus",
46
+ filters={"fabricId": fabricId}
47
+ )
48
+
49
+ # =====================================
50
+ # CONFIG APIs (DAY-2)
51
+ # =====================================
52
+ def backupConfig(self, payload):
53
+ return self._post(f"{self.BASE}/backupConfig", payload)
54
+
55
+ def restoreConfig(self, payload):
56
+ return self._post(f"{self.BASE}/restoreConfig", payload)
57
+
58
+ def replaceConfig(self, payload):
59
+ return self._post(f"{self.BASE}/replaceConfig", payload)
60
+
61
+ def diffConfig(self, fabricId):
62
+ return self._get(
63
+ f"{self.BASE}/diffConfig",
64
+ filters={"fabricId": fabricId}
65
+ )
66
+
67
+ def commitConfig(self, payload):
68
+ return self._post(f"{self.BASE}/commitConfig", payload)
69
+
70
+ def getConfigStatus(self, fabricId):
71
+ return self._get(
72
+ f"{self.BASE}/getConfigStatus",
73
+ filters={"fabricId": fabricId}
74
+ )
75
+
76
+ # =====================================
77
+ # DEVICE APIs
78
+ # =====================================
79
+ def listDevice(self, fabricId):
80
+ return self._get(
81
+ f"{self.BASE}/listDevice",
82
+ filters={"fabricId": fabricId}
83
+ )
84
+
85
+ def getDevice(self, deviceId):
86
+ return self._get(
87
+ f"{self.BASE}/getDevice",
88
+ filters={"deviceId": deviceId}
89
+ )
90
+
91
+ def rebootDevice(self, payload):
92
+ return self._post(f"{self.BASE}/rebootDevice", payload)
93
+
94
+ def upgradeDevice(self, payload):
95
+ return self._post(f"{self.BASE}/upgradeDevice", payload)
96
+
97
+ def replaceDevice(self, payload):
98
+ return self._post(f"{self.BASE}/replaceDevice", payload)
99
+
100
+ # =====================================
101
+ # TENANT APIs
102
+ # =====================================
103
+ def addTenant(self, payload):
104
+ return self._post(f"{self.BASE}/addTenant", payload)
105
+
106
+ def deleteTenant(self, payload):
107
+ return self._post(f"{self.BASE}/deleteTenant", payload)
108
+
109
+ def listTenant(self, fabricId):
110
+ return self._get(
111
+ f"{self.BASE}/listTenant",
112
+ filters={"fabricId": fabricId}
113
+ )
114
+
115
+ # =====================================
116
+ # JOB APIs
117
+ # =====================================
118
+ def listJobs(self):
119
+ return self._get(f"{self.BASE}/listJobs")
120
+
121
+ def getJobStatus(self, jobId):
122
+ return self._get(
123
+ f"{self.BASE}/getJobStatus",
124
+ filters={"jobId": jobId}
125
+ )
126
+
127
+ # =====================================
128
+ # GENERIC FALLBACK (KEEP THIS)
129
+ # =====================================
130
+ def customGET(self, path, filters=None):
131
+ return self._get(path, filters=filters)
132
+
133
+ def customPOST(self, path, payload=None):
134
+ return self._post(path, payload)
135
+
136
+ def customPATCH(self, path, payload=None):
137
+ return self.transport.request("PATCH", path, json=payload)
@@ -0,0 +1,63 @@
1
+ # ones/resources/health.py
2
+
3
+ from .base import BaseResource
4
+
5
+
6
+ class HealthResource(BaseResource):
7
+ BASE = "/api/health"
8
+
9
+ def device_list(self):
10
+ return self._get(f"{self.BASE}/DeviceList")
11
+
12
+ def device_info(
13
+ self,
14
+ from_date,
15
+ to_date,
16
+ window_size,
17
+ device_address,
18
+ fan=None,
19
+ psu=None,
20
+ active_tab="system",
21
+ ):
22
+ filters = {
23
+ "fromDate": from_date,
24
+ "toDate": to_date,
25
+ "windowSize": window_size,
26
+ "deviceAddress": device_address,
27
+ "fan": fan,
28
+ "psu": psu,
29
+ "activeTab": active_tab,
30
+ }
31
+
32
+ return self._get(f"{self.BASE}/deviceInfo", filters=filters)
33
+
34
+ def mega(
35
+ self,
36
+ from_date,
37
+ to_date,
38
+ window_size,
39
+ device_address,
40
+ ):
41
+ filters = {
42
+ "fromDate": from_date,
43
+ "toDate": to_date,
44
+ "windowSize": window_size,
45
+ "deviceAddress": device_address,
46
+ }
47
+
48
+ return self._get(f"{self.BASE}/mega", filters=filters)
49
+
50
+ # GET /health/topCpuConsumingServices "68:21:5F:A6:61:72"
51
+
52
+ def top_cpu_consuming_services(self, device_address):
53
+ filters = {
54
+ "deviceAddress": device_address
55
+ }
56
+
57
+ return self._get(f"{self.BASE}/topCpuConsumingServices", filters=filters)
58
+
59
+ # GET /health/fabricWiseHealth NULL
60
+
61
+ def fabric_wise_health(self):
62
+ return self._get(f"{self.BASE}/fabricWiseHealth")
63
+
@@ -0,0 +1,145 @@
1
+ from .base import BaseResource
2
+
3
+ class InventoryResource(BaseResource):
4
+ BASE = "/api/inventory"
5
+
6
+ def fm_agent_version_list(self):
7
+ return self._get(f"{self.BASE}/FMAgentVersionList")
8
+
9
+ def get_inventory_roles(self):
10
+ return self._get(f"{self.BASE}/Roles")
11
+
12
+ def get_switch_skus(self):
13
+ return self._get(f"{self.BASE}/SwitchSKUs")
14
+
15
+ def get_devices(self):
16
+ return self._get(f"{self.BASE}/Devices")
17
+
18
+ def get_action_btn(self):
19
+ return self._get(f"{self.BASE}/ActionBtn")
20
+
21
+ def get_device_ip_trans(self):
22
+ return self._get(f"{self.BASE}/DeviceIpTrans")
23
+
24
+ # GET /inventory/Devices/streaming-status-history { "deviceAddress" : "68:21:5F:A6:61:72", "windowSize" : "4 hour" }
25
+ def streaming_status_history(self, device_address, window_size):
26
+ filters = {
27
+ "deviceAddress": device_address,
28
+ "windowSize": window_size
29
+ }
30
+
31
+ return self._get(f"{self.BASE}/Devices/streaming-status-history", filters=filters)
32
+
33
+
34
+ # GET /inventory/Devices/streaming-status { "deviceAddress" : "68:21:5F:A6:61:72", "windowSize" : "4 hour" }
35
+ def streaming_status(self, device_address, window_size):
36
+ filters = {
37
+ "deviceAddress": device_address,
38
+ "windowSize": window_size
39
+ }
40
+
41
+ return self._get(f"{self.BASE}/Devices/streaming-status", filters=filters)
42
+
43
+
44
+ # GET /inventory/Devices/qosOnly NULL
45
+ def qos_only(self):
46
+ return self._get(f"{self.BASE}/Devices/qosOnly")
47
+
48
+
49
+
50
+ # GET /inventory/Devices/count NULL
51
+ def device_count(self):
52
+ return self._get(f"{self.BASE}/Devices/count")
53
+
54
+
55
+ # GET /inventory/Devices/interfaces { "deviceAddress" : "68:21:5F:A6:4A:72" }
56
+ def device_interfaces(self, device_address):
57
+ filters = {
58
+ "deviceAddress": device_address
59
+ }
60
+
61
+ return self._get(f"{self.BASE}/Devices/interfaces", filters=filters)
62
+
63
+
64
+ # GET /inventory/Devices/peripherals { "deviceAddress" : "68:21:5F:A6:4A:72" }
65
+ def device_peripherals(self, device_address):
66
+ filters = {
67
+ "deviceAddress": device_address
68
+ }
69
+
70
+ return self._get(f"{self.BASE}/Devices/peripherals", filters=filters)
71
+
72
+
73
+ # GET /inventory/deviceInfo { "deviceAddress" : "68:21:5F:A6:4A:72" }
74
+ def device_info(self, device_address):
75
+ filters = {
76
+ "deviceAddress": device_address
77
+ }
78
+
79
+ return self._get(f"{self.BASE}/deviceInfo", filters=filters)
80
+
81
+
82
+ # GET /inventory/Devices/firmware { "deviceAddress" : "68:21:5F:A6:4A:72" }
83
+ def device_firmware(self, device_address):
84
+ filters = {
85
+ "deviceAddress": device_address
86
+ }
87
+
88
+ return self._get(f"{self.BASE}/Devices/firmware", filters=filters)
89
+
90
+
91
+ # GET /inventory/linkInfo { "deviceAddress" : "68:21:5F:A6:4A:72" }
92
+ def link_info(self, device_address):
93
+ filters = {
94
+ "deviceAddress": device_address
95
+ }
96
+
97
+ return self._get(f"{self.BASE}/linkInfo", filters=filters)
98
+
99
+
100
+ # GET /inventory/minizip-test NULL
101
+ def minizip_test(self):
102
+ return self._get(f"{self.BASE}/minizip-test")
103
+
104
+
105
+ # GET /inventory/interfaceFlaps { "startTime" : "2026-03-23 02:09:36", "endTime" : "2026-03-24 11:09:36", "limit" : 10 }
106
+ def interface_flaps(self, start_time, end_time, limit):
107
+ filters = {
108
+ "startTime": start_time,
109
+ "endTime": end_time,
110
+ "limit": limit
111
+ }
112
+
113
+ return self._get(f"{self.BASE}/interfaceFlaps", filters=filters)
114
+
115
+ # GET /inventory/interfaceMega NULL
116
+ def interface_mega(self):
117
+ return self._get(f"{self.BASE}/interfaceMega")
118
+
119
+ # GET /inventory/nic-info { "deviceAddress" : "68:21:5F:A6:61:72" }
120
+ def nic_info(self, device_address):
121
+ filters = {
122
+ "deviceAddress": device_address
123
+ }
124
+
125
+ return self._get(f"{self.BASE}/nic-info", filters=filters)
126
+
127
+ # GET /inventory/device-details { "deviceAddress" : "68:21:5F:A6:61:72" }
128
+ def device_details(self, device_address):
129
+ filters = {
130
+ "deviceAddress": device_address
131
+ }
132
+
133
+ return self._get(f"{self.BASE}/device-details", filters=filters)
134
+
135
+ # GET /inventory/inv-details-orchest NULL
136
+ def inv_details_orchest(self):
137
+ return self._get(f"{self.BASE}/inv-details-orchest")
138
+
139
+ # GET /inventory/device-yaml-files NULL
140
+ def device_yaml_files(self):
141
+ return self._get(f"{self.BASE}/device-yaml-files")
142
+
143
+ # GET /inventory/mini-inventory NULL
144
+ def mini_inventory(self):
145
+ return self._get(f"{self.BASE}/mini-inventory")
@@ -0,0 +1,22 @@
1
+ from .base import BaseResource
2
+
3
+ class MiscResource(BaseResource):
4
+ BASE = "/api/misc"
5
+
6
+ def is_fm_enabled(self):
7
+ return self._get(f"{self.BASE}/isFmEnabled")
8
+
9
+ def world_map_data(self):
10
+ return self._get(f"{self.BASE}/world-map-data")
11
+
12
+ def is_ai_assistant_enabled(self):
13
+ return self._get(f"{self.BASE}/is-ai-assistant-enabled")
14
+
15
+ def get_illustrator_yaml(self):
16
+ return self._get(f"{self.BASE}/get-illustrator-yaml")
17
+
18
+ def region_list(self):
19
+ return self._get(f"{self.BASE}/region-list")
20
+
21
+ def telemetry_preferences(self):
22
+ return self._get(f"{self.BASE}/telemetry-preferences")
@@ -0,0 +1,58 @@
1
+ from .base import BaseResource
2
+
3
+ class TrafficResource(BaseResource):
4
+ BASE = "/api/traffic"
5
+
6
+ def is_interf_pfc_enabled(self, device_address, ifname):
7
+ filters = {
8
+ "deviceAddress": device_address,
9
+ "ifname": ifname
10
+ }
11
+ return self._get(f"{self.BASE}/is-interf-pfc-enabled", filters=filters)
12
+
13
+ def traffic_list(self, device_address="all"):
14
+ filters = {
15
+ "deviceAddress": device_address
16
+ }
17
+ return self._get(f"{self.BASE}/trafficList", filters=filters)
18
+
19
+ def get_interface_details(self, device_address, hostname, ipaddress, layer, time_bucket, window_size, license_):
20
+ filters = {
21
+ "deviceAddress": device_address,
22
+ "hostname": hostname,
23
+ "ipaddress": ipaddress,
24
+ "layer": layer,
25
+ "timeBucket": time_bucket,
26
+ "windowSize": window_size,
27
+ "license": license_
28
+ }
29
+ return self._get(f"{self.BASE}/getInterfaceDetails", filters=filters)
30
+
31
+ def interface_details(self, from_date, to_date, window_size, device_address, active_tab, ifname):
32
+ filters = {
33
+ "fromDate": from_date,
34
+ "toDate": to_date,
35
+ "windowSize": window_size,
36
+ "deviceAddress": device_address,
37
+ "activeTab": active_tab,
38
+ "ifname": ifname
39
+ }
40
+ return self._get(f"{self.BASE}/interfaceDetails", filters=filters)
41
+
42
+ def traffic_mega(self, from_date, to_date, window_size, device_address, active_tab, ifname):
43
+ filters = {
44
+ "fromDate": from_date,
45
+ "toDate": to_date,
46
+ "windowSize": window_size,
47
+ "deviceAddress": device_address,
48
+ "activeTab": active_tab,
49
+ "ifname": ifname
50
+ }
51
+ return self._get(f"{self.BASE}/trafficMega", filters=filters)
52
+
53
+ def priority_mapping(self, device_address, ifname):
54
+ filters = {
55
+ "deviceAddress": device_address,
56
+ "ifname": ifname
57
+ }
58
+ return self._get(f"{self.BASE}/priorityMapping", filters=filters)
@@ -0,0 +1,16 @@
1
+ # ones/resources/user.py
2
+
3
+ from .base import BaseResource
4
+
5
+
6
+ class UserResource(BaseResource):
7
+ BASE = "/api/user"
8
+
9
+ def list(self, filters=None):
10
+ return self._get(self.BASE, filters)
11
+
12
+ def roles(self):
13
+ return self._get(f"{self.BASE}/role")
14
+
15
+ def preferences(self):
16
+ return self._get(f"{self.BASE}/preferences")
@@ -0,0 +1,53 @@
1
+ # ones/transport.py
2
+
3
+ import requests
4
+ import logging
5
+ from .exceptions import OnesClientException
6
+
7
+
8
+ class Transport:
9
+ def __init__(self, base_url, token=None, timeout=10, verify=False):
10
+ self.base_url = base_url.rstrip("/")
11
+ self.token = token
12
+ self.timeout = timeout
13
+ self.verify = verify
14
+
15
+ self.session = requests.Session()
16
+
17
+ def set_token(self, token):
18
+ self.token = token
19
+
20
+ def request(self, method, path, params=None, json=None):
21
+ url = f"{self.base_url}{path}"
22
+
23
+ print(f"REQUEST: {method} {url}")
24
+
25
+ headers = {"Content-Type": "application/json"}
26
+
27
+ if self.token:
28
+ headers["Authorization"] = self.token # keep as-is (your backend expects this)
29
+
30
+ try:
31
+ resp = self.session.request(
32
+ method=method,
33
+ url=url,
34
+ headers=headers,
35
+ params=params,
36
+ json=json,
37
+ timeout=self.timeout,
38
+ verify=self.verify,
39
+ )
40
+
41
+ if resp.status_code not in (200, 201):
42
+ logging.error(f"Request failed: {method} {url} - Status: {resp.status_code} - Response: {resp.text}")
43
+ return None
44
+
45
+ try:
46
+ return resp.json()
47
+ except Exception:
48
+ logging.error(f"No JSON data returned: {resp.text}")
49
+ return None # or {} if you prefer
50
+
51
+ except Exception as e:
52
+ logging.error(e)
53
+ raise OnesClientException(str(e))
@@ -0,0 +1,45 @@
1
+ Metadata-Version: 2.4
2
+ Name: ones-pyapi
3
+ Version: 0.1.0
4
+ Summary: Python SDK for ONES (Aviz Networks)
5
+ Author-email: Kavyansh Pandey <kavyansh.pandey@aviznetworks.com>
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: requests
9
+
10
+ ones_sdk/
11
+
12
+ ├── ones/ # main package
13
+ │ ├── __init__.py
14
+ │ │
15
+ │ ├── client.py # main entry point
16
+ │ ├── transport.py # HTTP layer
17
+ │ ├── exceptions.py # custom errors
18
+ │ ├── constants.py # endpoints, paths
19
+ │ │
20
+ │ ├── resources/ # API groups
21
+ │ │ ├── __init__.py
22
+ │ │ ├── base.py
23
+ │ │ ├── user.py
24
+ │ │ ├── health.py
25
+ │ │ └── inventory.py
26
+ │ │
27
+ │ ├── utils/ # helpers
28
+ │ │ ├── __init__.py
29
+ │ │ └── parser.py # json parsing helpers
30
+ │ │
31
+ │ └── models/ # (optional, later)
32
+ │ ├── __init__.py
33
+ │ └── user.py
34
+
35
+ ├── tests/
36
+ │ ├── test_user.py
37
+ │ ├── test_health.py
38
+ │ └── test_inventory.py
39
+
40
+ ├── examples/
41
+ │ └── basic_usage.py
42
+
43
+ ├── requirements.txt
44
+ ├── setup.py / pyproject.toml
45
+ └── README.md
@@ -0,0 +1,31 @@
1
+ README.md
2
+ pyproject.toml
3
+ examples/examples_usage_bgp.py
4
+ examples/examples_usage_control_plane.py
5
+ examples/examples_usage_device.py
6
+ examples/examples_usage_fm.py
7
+ examples/examples_usage_health.py
8
+ examples/examples_usage_inventory.py
9
+ examples/examples_usage_misc.py
10
+ examples/examples_usage_traffic.py
11
+ examples/test_example.py
12
+ ones/__init__.py
13
+ ones/client.py
14
+ ones/exceptions.py
15
+ ones/transport.py
16
+ ones/resources/__init__.py
17
+ ones/resources/base.py
18
+ ones/resources/bgp.py
19
+ ones/resources/control_plane.py
20
+ ones/resources/device.py
21
+ ones/resources/fm.py
22
+ ones/resources/health.py
23
+ ones/resources/inventory.py
24
+ ones/resources/misc.py
25
+ ones/resources/traffic.py
26
+ ones/resources/user.py
27
+ ones_pyapi.egg-info/PKG-INFO
28
+ ones_pyapi.egg-info/SOURCES.txt
29
+ ones_pyapi.egg-info/dependency_links.txt
30
+ ones_pyapi.egg-info/requires.txt
31
+ ones_pyapi.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ requests
@@ -0,0 +1,5 @@
1
+ dist
2
+ examples
3
+ ones
4
+ tests
5
+ venv
@@ -0,0 +1,20 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "ones-pyapi"
7
+ version = "0.1.0"
8
+ description = "Python SDK for ONES (Aviz Networks)"
9
+ authors = [
10
+ { name="Kavyansh Pandey", email="kavyansh.pandey@aviznetworks.com" }
11
+ ]
12
+ readme = "README.md"
13
+ requires-python = ">=3.8"
14
+
15
+ dependencies = [
16
+ "requests"
17
+ ]
18
+
19
+ [tool.setuptools.packages.find]
20
+ where = ["."]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+