Skip to content

Commit

Permalink
Merge pull request #238 from minitriga/elevation
Browse files Browse the repository at this point in the history
Rack Elevation Endpoint
  • Loading branch information
Zach Moody authored Jun 5, 2020
2 parents 0f745d0 + ec6fe98 commit 5cc0897
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pynetbox/models/dcim.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,23 @@ def units(self):
"""
return RODetailEndpoint(self, "units", custom_return=RUs)

@property
def elevation(self):
""" Represents the ``elevation`` detail endpoint.
Returns a DetailEndpoint object that is the interface for
viewing response from the elevation endpoint updated in Netbox version 2.8.
:returns: :py:class:`.DetailEndpoint`
:Examples:
>>> rack = nb.dcim.racks.get(123)
>>> rack.elevation.list()
{"get_facts": {"interface_list": ["ge-0/0/0"]}}
"""
return RODetailEndpoint(self, "elevation", custom_return=RUs)

class Termination(Record):
def __str__(self):
Expand Down
22 changes: 22 additions & 0 deletions tests/test_dcim.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,28 @@ def test_get_units(self, mock):
isinstance(ret[0].device, pynetbox.models.dcim.Devices)
)

@patch(
'pynetbox.core.query.requests.sessions.Session.get',
side_effect=[
Response(fixture='dcim/rack.json'),
Response(fixture='dcim/rack_u.json'),
]
)
def test_get_elevation(self, mock):
test = nb.racks.get(1)
ret = test.elevation.list()
mock.assert_called_with(
'http://localhost:8000/api/dcim/racks/1/elevation/',
params={},
json=None,
headers=HEADERS,
verify=True,
)
self.assertTrue(ret)
self.assertTrue(
isinstance(ret[0].device, pynetbox.models.dcim.Devices)
)


class RackRoleTestCase(Generic.Tests):
name = 'rack_roles'
Expand Down

0 comments on commit 5cc0897

Please sign in to comment.