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



32
33
34
35
36
37
38
# File 'lib/netbox_client_ruby/api/ipam/ip_address.rb', line 32

def interface
  interface_data = data['interface']

  return nil unless interface_data
  return Virtualization::Interface.new interface_data['id'] unless interface_data.dig('virtual_machine').nil?
  return DCIM::Interface.new interface_data['id']
end

#status=(value) ⇒ Object



27
28
29
30
# File 'lib/netbox_client_ruby/api/ipam/ip_address.rb', line 27

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