@@ -325,14 +325,6 @@ def get_interfaces(self, **kwargs):
325
325
"""Return interfaces"""
326
326
return self .netbox_con .get ('/dcim/interfaces' , ** kwargs )
327
327
328
- def get_interfaces_by_device (self , device_name , ** kwargs ):
329
- """Get all interfaces by device
330
-
331
- :param device_name: Name of device to get interfaces off
332
- :return: list of interfaces
333
- """
334
- return self .netbox_con .get ('/dcim/interfaces' , device = device_name , ** kwargs )
335
-
336
328
def create_interface (self , name , form_factor , device_id , ** kwargs ):
337
329
"""Create a new interface
338
330
@@ -360,12 +352,17 @@ def update_interface(self, interface, device, **kwargs):
360
352
raise exceptions .NotFoundException ('interface: {}' .format (interface )) from None
361
353
return self .netbox_con .patch ('/dcim/interfaces/' , interface_id , ** kwargs )
362
354
363
- def delete_interface_by_id (self , interface_id ):
364
- """Delete interface by id
355
+ def delete_interface (self , interface_name , device ):
356
+ """Delete platform
365
357
366
- :param interface_id: id of interface to remove
358
+ :param interface_name: Name of interface to delete
359
+ :param device: Device to which the interface belongs
367
360
:return: bool True if successful otherwise raise DeleteException
368
361
"""
362
+ try :
363
+ interface_id = self .get_interfaces (name = interface_name , device = device )[0 ]['id' ]
364
+ except IndexError :
365
+ raise exceptions .NotFoundException ('interface: {}' .format (interface_name )) from None
369
366
return self .netbox_con .delete ('/dcim/interfaces/' , interface_id )
370
367
371
368
def get_interface_connections (self , ** kwargs ):
0 commit comments