netbox-client-ruby 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/.travis.yml +8 -0
- data/Dockerfile +12 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +75 -0
- data/LICENSE.txt +21 -0
- data/README.md +138 -0
- data/Rakefile +6 -0
- data/VERSION +1 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/docker-compose.test.yml +5 -0
- data/docker-compose.yml +37 -0
- data/docker/start.sh +3 -0
- data/docker/start.test.sh +3 -0
- data/lib/netbox-client-ruby.rb +1 -0
- data/lib/netbox_client_ruby.rb +25 -0
- data/lib/netbox_client_ruby/api.rb +18 -0
- data/lib/netbox_client_ruby/api/dcim.rb +55 -0
- data/lib/netbox_client_ruby/api/dcim/device.rb +31 -0
- data/lib/netbox_client_ruby/api/dcim/device_role.rb +12 -0
- data/lib/netbox_client_ruby/api/dcim/device_roles.rb +19 -0
- data/lib/netbox_client_ruby/api/dcim/device_type.rb +26 -0
- data/lib/netbox_client_ruby/api/dcim/device_types.rb +19 -0
- data/lib/netbox_client_ruby/api/dcim/devices.rb +19 -0
- data/lib/netbox_client_ruby/api/dcim/interface.rb +14 -0
- data/lib/netbox_client_ruby/api/dcim/interfaces.rb +19 -0
- data/lib/netbox_client_ruby/api/dcim/manufacturer.rb +12 -0
- data/lib/netbox_client_ruby/api/dcim/manufacturers.rb +19 -0
- data/lib/netbox_client_ruby/api/dcim/platform.rb +12 -0
- data/lib/netbox_client_ruby/api/dcim/platforms.rb +19 -0
- data/lib/netbox_client_ruby/api/dcim/rack.rb +12 -0
- data/lib/netbox_client_ruby/api/dcim/racks.rb +19 -0
- data/lib/netbox_client_ruby/api/dcim/region.rb +13 -0
- data/lib/netbox_client_ruby/api/dcim/regions.rb +19 -0
- data/lib/netbox_client_ruby/api/dcim/site.rb +15 -0
- data/lib/netbox_client_ruby/api/dcim/sites.rb +19 -0
- data/lib/netbox_client_ruby/api/ipam.rb +53 -0
- data/lib/netbox_client_ruby/api/ipam/aggregate.rb +14 -0
- data/lib/netbox_client_ruby/api/ipam/aggregates.rb +19 -0
- data/lib/netbox_client_ruby/api/ipam/ip_address.rb +42 -0
- data/lib/netbox_client_ruby/api/ipam/ip_addresses.rb +19 -0
- data/lib/netbox_client_ruby/api/ipam/prefix.rb +47 -0
- data/lib/netbox_client_ruby/api/ipam/prefixes.rb +19 -0
- data/lib/netbox_client_ruby/api/ipam/rir.rb +12 -0
- data/lib/netbox_client_ruby/api/ipam/rirs.rb +19 -0
- data/lib/netbox_client_ruby/api/ipam/role.rb +12 -0
- data/lib/netbox_client_ruby/api/ipam/roles.rb +19 -0
- data/lib/netbox_client_ruby/api/ipam/vlan.rb +40 -0
- data/lib/netbox_client_ruby/api/ipam/vlan_group.rb +14 -0
- data/lib/netbox_client_ruby/api/ipam/vlan_groups.rb +19 -0
- data/lib/netbox_client_ruby/api/ipam/vlans.rb +19 -0
- data/lib/netbox_client_ruby/api/ipam/vrf.rb +14 -0
- data/lib/netbox_client_ruby/api/ipam/vrfs.rb +19 -0
- data/lib/netbox_client_ruby/api/tenancy.rb +25 -0
- data/lib/netbox_client_ruby/api/tenancy/tenant.rb +14 -0
- data/lib/netbox_client_ruby/api/tenancy/tenant_group.rb +12 -0
- data/lib/netbox_client_ruby/api/tenancy/tenant_groups.rb +19 -0
- data/lib/netbox_client_ruby/api/tenancy/tenants.rb +19 -0
- data/lib/netbox_client_ruby/communication.rb +74 -0
- data/lib/netbox_client_ruby/connection.rb +33 -0
- data/lib/netbox_client_ruby/entities.rb +200 -0
- data/lib/netbox_client_ruby/entity.rb +345 -0
- data/lib/netbox_client_ruby/error/client_error.rb +4 -0
- data/lib/netbox_client_ruby/error/local_error.rb +4 -0
- data/lib/netbox_client_ruby/error/remote_error.rb +4 -0
- data/netbox-client-ruby.gemspec +43 -0
- data/netbox.env +17 -0
- metadata +255 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'netbox_client_ruby/entity'
|
|
2
|
+
require 'netbox_client_ruby/api/dcim/device_type'
|
|
3
|
+
require 'netbox_client_ruby/api/dcim/device_role'
|
|
4
|
+
require 'netbox_client_ruby/api/tenancy/tenant'
|
|
5
|
+
require 'netbox_client_ruby/api/dcim/platform'
|
|
6
|
+
require 'netbox_client_ruby/api/dcim/site'
|
|
7
|
+
require 'netbox_client_ruby/api/dcim/rack'
|
|
8
|
+
require 'netbox_client_ruby/api/ipam/ip_address'
|
|
9
|
+
|
|
10
|
+
module NetboxClientRuby
|
|
11
|
+
class Device
|
|
12
|
+
include NetboxClientRuby::Entity
|
|
13
|
+
|
|
14
|
+
id id: :id
|
|
15
|
+
deletable true
|
|
16
|
+
path 'dcim/devices/:id.json'
|
|
17
|
+
creation_path 'dcim/devices/'
|
|
18
|
+
object_fields(
|
|
19
|
+
device_type: proc { |raw_data| NetboxClientRuby::DeviceType.new raw_data['id'] },
|
|
20
|
+
device_role: proc { |raw_data| NetboxClientRuby::DeviceRole.new raw_data['id'] },
|
|
21
|
+
tenant: proc { |raw_data| NetboxClientRuby::Tenant.new raw_data['id'] },
|
|
22
|
+
platform: proc { |raw_data| NetboxClientRuby::Platform.new raw_data['id'] },
|
|
23
|
+
site: proc { |raw_data| NetboxClientRuby::Site.new raw_data['id'] },
|
|
24
|
+
rack: proc { |raw_data| NetboxClientRuby::Rack.new raw_data['id'] },
|
|
25
|
+
parent_device: proc { |raw_data| NetboxClientRuby::Device.new raw_data['id'] },
|
|
26
|
+
primary_ip: proc { |raw_data| NetboxClientRuby::IpAddress.new raw_data['id'] },
|
|
27
|
+
primary_ip4: proc { |raw_data| NetboxClientRuby::IpAddress.new raw_data['id'] },
|
|
28
|
+
primary_ip6: proc { |raw_data| NetboxClientRuby::IpAddress.new raw_data['id'] }
|
|
29
|
+
)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'netbox_client_ruby/entities'
|
|
2
|
+
require 'netbox_client_ruby/api/dcim/device_type'
|
|
3
|
+
|
|
4
|
+
module NetboxClientRuby
|
|
5
|
+
class DeviceRoles
|
|
6
|
+
include NetboxClientRuby::Entities
|
|
7
|
+
|
|
8
|
+
path 'dcim/device-roles.json'
|
|
9
|
+
data_key 'results'
|
|
10
|
+
count_key 'count'
|
|
11
|
+
entity_creator :entity_creator
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def entity_creator(raw_entity)
|
|
16
|
+
NetboxClientRuby::DeviceRole.new raw_entity['id']
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require 'netbox_client_ruby/entity'
|
|
2
|
+
require 'netbox_client_ruby/api/dcim/manufacturer'
|
|
3
|
+
|
|
4
|
+
module NetboxClientRuby
|
|
5
|
+
class InterfaceOrdering
|
|
6
|
+
attr_reader :value, :label
|
|
7
|
+
|
|
8
|
+
def initialize(raw_data)
|
|
9
|
+
@value = raw_data['value']
|
|
10
|
+
@label = raw_data['label']
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
class DeviceType
|
|
15
|
+
include NetboxClientRuby::Entity
|
|
16
|
+
|
|
17
|
+
id id: :id
|
|
18
|
+
deletable true
|
|
19
|
+
path 'dcim/device-types/:id.json'
|
|
20
|
+
creation_path 'dcim/device-types/'
|
|
21
|
+
object_fields(
|
|
22
|
+
manufacturer: proc { |raw_data| NetboxClientRuby::Manufacturer.new raw_data['id'] },
|
|
23
|
+
interface_ordering: NetboxClientRuby::InterfaceOrdering
|
|
24
|
+
)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'netbox_client_ruby/entities'
|
|
2
|
+
require 'netbox_client_ruby/api/dcim/device_type'
|
|
3
|
+
|
|
4
|
+
module NetboxClientRuby
|
|
5
|
+
class DeviceTypes
|
|
6
|
+
include NetboxClientRuby::Entities
|
|
7
|
+
|
|
8
|
+
path 'dcim/device-types.json'
|
|
9
|
+
data_key 'results'
|
|
10
|
+
count_key 'count'
|
|
11
|
+
entity_creator :entity_creator
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def entity_creator(raw_entity)
|
|
16
|
+
NetboxClientRuby::DeviceType.new raw_entity['id']
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'netbox_client_ruby/entities'
|
|
2
|
+
require 'netbox_client_ruby/api/dcim/device'
|
|
3
|
+
|
|
4
|
+
module NetboxClientRuby
|
|
5
|
+
class Devices
|
|
6
|
+
include NetboxClientRuby::Entities
|
|
7
|
+
|
|
8
|
+
path 'dcim/devices.json'
|
|
9
|
+
data_key 'results'
|
|
10
|
+
count_key 'count'
|
|
11
|
+
entity_creator :entity_creator
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def entity_creator(raw_entity)
|
|
16
|
+
NetboxClientRuby::Device.new raw_entity['id']
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require 'netbox_client_ruby/entity'
|
|
2
|
+
require 'netbox_client_ruby/api/dcim/device'
|
|
3
|
+
|
|
4
|
+
module NetboxClientRuby
|
|
5
|
+
class Interface
|
|
6
|
+
include NetboxClientRuby::Entity
|
|
7
|
+
|
|
8
|
+
id id: :id
|
|
9
|
+
deletable true
|
|
10
|
+
path 'dcim/interfaces/:id.json'
|
|
11
|
+
creation_path 'dcim/interfaces/'
|
|
12
|
+
object_fields device: proc { |raw_data| NetboxClientRuby::Device.new raw_data['id'] }
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'netbox_client_ruby/entities'
|
|
2
|
+
require 'netbox_client_ruby/api/dcim/interface'
|
|
3
|
+
|
|
4
|
+
module NetboxClientRuby
|
|
5
|
+
class Interfaces
|
|
6
|
+
include NetboxClientRuby::Entities
|
|
7
|
+
|
|
8
|
+
path 'dcim/interfaces.json'
|
|
9
|
+
data_key 'results'
|
|
10
|
+
count_key 'count'
|
|
11
|
+
entity_creator :entity_creator
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def entity_creator(raw_entity)
|
|
16
|
+
NetboxClientRuby::Interface.new raw_entity['id']
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'netbox_client_ruby/entities'
|
|
2
|
+
require 'netbox_client_ruby/api/dcim/manufacturer'
|
|
3
|
+
|
|
4
|
+
module NetboxClientRuby
|
|
5
|
+
class Manufacturers
|
|
6
|
+
include NetboxClientRuby::Entities
|
|
7
|
+
|
|
8
|
+
path 'dcim/manufacturers.json'
|
|
9
|
+
data_key 'results'
|
|
10
|
+
count_key 'count'
|
|
11
|
+
entity_creator :entity_creator
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def entity_creator(raw_entity)
|
|
16
|
+
NetboxClientRuby::Manufacturer.new raw_entity['id']
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'netbox_client_ruby/entities'
|
|
2
|
+
require 'netbox_client_ruby/api/dcim/platform'
|
|
3
|
+
|
|
4
|
+
module NetboxClientRuby
|
|
5
|
+
class Platforms
|
|
6
|
+
include NetboxClientRuby::Entities
|
|
7
|
+
|
|
8
|
+
path 'dcim/platforms.json'
|
|
9
|
+
data_key 'results'
|
|
10
|
+
count_key 'count'
|
|
11
|
+
entity_creator :entity_creator
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def entity_creator(raw_entity)
|
|
16
|
+
NetboxClientRuby::Platform.new raw_entity['id']
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'netbox_client_ruby/entities'
|
|
2
|
+
require 'netbox_client_ruby/api/dcim/rack'
|
|
3
|
+
|
|
4
|
+
module NetboxClientRuby
|
|
5
|
+
class Racks
|
|
6
|
+
include NetboxClientRuby::Entities
|
|
7
|
+
|
|
8
|
+
path 'dcim/racks.json'
|
|
9
|
+
data_key 'results'
|
|
10
|
+
count_key 'count'
|
|
11
|
+
entity_creator :entity_creator
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def entity_creator(raw_entity)
|
|
16
|
+
NetboxClientRuby::Rack.new raw_entity['id']
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require 'netbox_client_ruby/entity'
|
|
2
|
+
|
|
3
|
+
module NetboxClientRuby
|
|
4
|
+
class Region
|
|
5
|
+
include NetboxClientRuby::Entity
|
|
6
|
+
|
|
7
|
+
id id: :id
|
|
8
|
+
deletable true
|
|
9
|
+
path 'dcim/regions/:id.json'
|
|
10
|
+
creation_path 'dcim/regions/'
|
|
11
|
+
object_fields parent: proc { |raw_data| Region.new raw_data['id'] }
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'netbox_client_ruby/entities'
|
|
2
|
+
require 'netbox_client_ruby/api/dcim/region'
|
|
3
|
+
|
|
4
|
+
module NetboxClientRuby
|
|
5
|
+
class Regions
|
|
6
|
+
include NetboxClientRuby::Entities
|
|
7
|
+
|
|
8
|
+
path 'dcim/regions.json'
|
|
9
|
+
data_key 'results'
|
|
10
|
+
count_key 'count'
|
|
11
|
+
entity_creator :entity_creator
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def entity_creator(raw_entity)
|
|
16
|
+
NetboxClientRuby::Region.new raw_entity['id']
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'netbox_client_ruby/entity'
|
|
2
|
+
|
|
3
|
+
module NetboxClientRuby
|
|
4
|
+
class Site
|
|
5
|
+
include NetboxClientRuby::Entity
|
|
6
|
+
|
|
7
|
+
id id: :id
|
|
8
|
+
readonly_fields :count_prefixes, :count_vlans, :count_racks, :count_devices,
|
|
9
|
+
:count_circuits
|
|
10
|
+
|
|
11
|
+
deletable true
|
|
12
|
+
path 'dcim/sites/:id.json'
|
|
13
|
+
creation_path 'dcim/sites/'
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'netbox_client_ruby/entities'
|
|
2
|
+
require 'netbox_client_ruby/api/dcim/site'
|
|
3
|
+
|
|
4
|
+
module NetboxClientRuby
|
|
5
|
+
class Sites
|
|
6
|
+
include NetboxClientRuby::Entities
|
|
7
|
+
|
|
8
|
+
path 'dcim/sites.json'
|
|
9
|
+
data_key 'results'
|
|
10
|
+
count_key 'count'
|
|
11
|
+
entity_creator :entity_creator
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def entity_creator(raw_entity)
|
|
16
|
+
NetboxClientRuby::Site.new raw_entity['id']
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
require 'netbox_client_ruby/api/ipam/aggregate'
|
|
2
|
+
require 'netbox_client_ruby/api/ipam/aggregates'
|
|
3
|
+
require 'netbox_client_ruby/api/ipam/ip_addresses'
|
|
4
|
+
require 'netbox_client_ruby/api/ipam/ip_address'
|
|
5
|
+
require 'netbox_client_ruby/api/ipam/prefix'
|
|
6
|
+
require 'netbox_client_ruby/api/ipam/prefixes'
|
|
7
|
+
require 'netbox_client_ruby/api/ipam/rir'
|
|
8
|
+
require 'netbox_client_ruby/api/ipam/rirs'
|
|
9
|
+
require 'netbox_client_ruby/api/ipam/role'
|
|
10
|
+
require 'netbox_client_ruby/api/ipam/roles'
|
|
11
|
+
# require 'netbox_client_ruby/api/ipam/service'
|
|
12
|
+
# require 'netbox_client_ruby/api/ipam/services'
|
|
13
|
+
require 'netbox_client_ruby/api/ipam/vlan_group'
|
|
14
|
+
require 'netbox_client_ruby/api/ipam/vlan_groups'
|
|
15
|
+
require 'netbox_client_ruby/api/ipam/vlan'
|
|
16
|
+
require 'netbox_client_ruby/api/ipam/vlans'
|
|
17
|
+
require 'netbox_client_ruby/api/ipam/vrf'
|
|
18
|
+
require 'netbox_client_ruby/api/ipam/vrfs'
|
|
19
|
+
require 'netbox_client_ruby/communication'
|
|
20
|
+
|
|
21
|
+
module NetboxClientRuby
|
|
22
|
+
class IPAM
|
|
23
|
+
{
|
|
24
|
+
aggregates: Aggregates,
|
|
25
|
+
ip_addresses: IpAddresses,
|
|
26
|
+
prefixes: Prefixes,
|
|
27
|
+
rirs: Rirs,
|
|
28
|
+
roles: Roles,
|
|
29
|
+
vlans: Vlans,
|
|
30
|
+
vlan_groups: VlanGroups,
|
|
31
|
+
vrfs: Vrfs
|
|
32
|
+
}.each_pair do |method_name, class_name|
|
|
33
|
+
define_method(method_name) do
|
|
34
|
+
class_name.new
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
{
|
|
39
|
+
aggregate: Aggregate,
|
|
40
|
+
ip_address: IpAddress,
|
|
41
|
+
prefix: Prefix,
|
|
42
|
+
rir: Rir,
|
|
43
|
+
role: Role,
|
|
44
|
+
vlan: Vlan,
|
|
45
|
+
vlan_group: VlanGroup,
|
|
46
|
+
vrf: Vrf
|
|
47
|
+
}.each_pair do |method_name, class_name|
|
|
48
|
+
define_method(method_name) do |id|
|
|
49
|
+
class_name.new id
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require 'netbox_client_ruby/entity'
|
|
2
|
+
require 'netbox_client_ruby/api/ipam/rir'
|
|
3
|
+
|
|
4
|
+
module NetboxClientRuby
|
|
5
|
+
class Aggregate
|
|
6
|
+
include NetboxClientRuby::Entity
|
|
7
|
+
|
|
8
|
+
id id: :id
|
|
9
|
+
deletable true
|
|
10
|
+
path 'ipam/aggregates/:id.json'
|
|
11
|
+
creation_path 'ipam/aggregates/'
|
|
12
|
+
object_fields rir: proc { |raw_data| NetboxClientRuby::Rir.new raw_data['id'] }
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'netbox_client_ruby/entities'
|
|
2
|
+
require 'netbox_client_ruby/api/ipam/aggregate'
|
|
3
|
+
|
|
4
|
+
module NetboxClientRuby
|
|
5
|
+
class Aggregates
|
|
6
|
+
include NetboxClientRuby::Entities
|
|
7
|
+
|
|
8
|
+
path 'ipam/aggregates.json'
|
|
9
|
+
data_key 'results'
|
|
10
|
+
count_key 'count'
|
|
11
|
+
entity_creator :entity_creator
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def entity_creator(raw_entity)
|
|
16
|
+
NetboxClientRuby::Aggregate.new raw_entity['id']
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require 'netbox_client_ruby/entity'
|
|
2
|
+
require 'netbox_client_ruby/api/dcim/interface'
|
|
3
|
+
require 'netbox_client_ruby/api/ipam/vrf'
|
|
4
|
+
require 'netbox_client_ruby/api/tenancy/tenant'
|
|
5
|
+
|
|
6
|
+
module NetboxClientRuby
|
|
7
|
+
class IpAddress
|
|
8
|
+
include NetboxClientRuby::Entity
|
|
9
|
+
|
|
10
|
+
id id: :id
|
|
11
|
+
deletable true
|
|
12
|
+
path 'ipam/ip-addresses/:id.json'
|
|
13
|
+
creation_path 'ipam/ip-addresses/'
|
|
14
|
+
object_fields(
|
|
15
|
+
vrf: proc { |raw_data| NetboxClientRuby::Vrf.new raw_data['id'] },
|
|
16
|
+
tenant: proc { |raw_data| NetboxClientRuby::Tenant.new raw_data['id'] },
|
|
17
|
+
status: proc { |raw_data| NetboxClientRuby::IpAddressStatus.new raw_data['value'] },
|
|
18
|
+
interface: proc { |raw_data| NetboxClientRuby::Interface.new raw_data['id'] }
|
|
19
|
+
)
|
|
20
|
+
readonly_fields :display_name
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
class IpAddressStatus
|
|
24
|
+
attr_reader :value, :label
|
|
25
|
+
|
|
26
|
+
def initialize(status_value)
|
|
27
|
+
@value = status_value
|
|
28
|
+
@label = case status_value
|
|
29
|
+
when 1 then
|
|
30
|
+
'Active'.freeze
|
|
31
|
+
when 2 then
|
|
32
|
+
'Reserved'.freeze
|
|
33
|
+
when 3 then
|
|
34
|
+
'Deprecated'.freeze
|
|
35
|
+
when 5 then
|
|
36
|
+
'DHCP'.freeze
|
|
37
|
+
else
|
|
38
|
+
'UNDEFINED'.freeze
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|