Skip to content

Commit

Permalink
Rack elevation API call (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
pobradovic08 authored Oct 6, 2023
1 parent d94a96c commit bb4ecd3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
9 changes: 8 additions & 1 deletion netbox_python/api/dcim.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down Expand Up @@ -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/"

Expand Down
12 changes: 12 additions & 0 deletions netbox_python/baseapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit bb4ecd3

Please sign in to comment.