Class: NetboxClientRuby::IPAM::IpAddress

Inherits:
Object
  • Object
show all
Includes:
Entity
Defined in:
lib/netbox_client_ruby/api/ipam/ip_address.rb

Constant Summary collapse

STATUS_VALUES =
{
  active: 1,
  reserved: 2,
  deprecated: 3,
  dhcp: 5
}.freeze

Instance Method Summary collapse

Methods included from Entity

#[], #[]=, #create, #data=, #delete, included, #initialize, #method_missing, #raw_data!, #reload, #respond_to_missing?, #revert, #save, #update, #url

Methods included from Communication

#connection, #hash_to_object, #response

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class NetboxClientRuby::Entity

Instance Method Details

#interfaceObject



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/netbox_client_ruby/api/ipam/ip_address.rb', line 36

def interface
  interface_data = data['interface']

  return nil unless interface_data

  if interface_data.key? ('virtual_machine')
    Virtualization::Interface.new interface_data['id']
  else
    DCIM::Interface.new interface_data['id']
  end
end

#status=(value) ⇒ Object



31
32
33
34
# File 'lib/netbox_client_ruby/api/ipam/ip_address.rb', line 31

def status=(value)
  status_code_lookup = STATUS_VALUES.fetch(value, value)
  method_missing(:status=, status_code_lookup)
end