From bb4ecd30f75ba3b03116d63128d1a2d22e54f996 Mon Sep 17 00:00:00 2001 From: pobradovic08 Date: Fri, 6 Oct 2023 19:14:20 +0200 Subject: [PATCH] Rack elevation API call (#15) --- netbox_python/api/dcim.py | 9 ++++++++- netbox_python/baseapi.py | 12 ++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/netbox_python/api/dcim.py b/netbox_python/api/dcim.py index 91720d6..0934694 100644 --- a/netbox_python/api/dcim.py +++ b/netbox_python/api/dcim.py @@ -1,4 +1,4 @@ -from netbox_python.baseapi import APIResource, CreateableAPIResource +from netbox_python.baseapi import APIResource, CreateableAPIResource, ElevationAPIResource from netbox_python.rest import Result @@ -156,6 +156,13 @@ class _rack_roles(APIResource): class _racks(APIResource): path = "dcim/racks/" + def __init__(self, client): + self.elevation = self._elevation(client) + super().__init__(client) + + class _elevation(ElevationAPIResource): + path = "dcim/racks/{id}/elevation/" + class _rear_port_templates(APIResource): path = "dcim/rear-port-templates/" diff --git a/netbox_python/baseapi.py b/netbox_python/baseapi.py index b62ffc3..e7b1752 100644 --- a/netbox_python/baseapi.py +++ b/netbox_python/baseapi.py @@ -113,3 +113,15 @@ def list(self, id: str | int, **kwargs) -> Result: def all(self, id: str | int, **kwargs): path = self.path.format(id=id) return self._all(path, **kwargs) + +class ElevationAPIResource( + baseapi, + ListableAPIResource +): + def list(self, id: str | int, **kwargs) -> Result: + path = self.path.format(id=id) + return self._list(path, **kwargs) + + def all(self, id: str | int, **kwargs): + path = self.path.format(id=id) + return self._all(path, **kwargs)