netbox-client-ruby 0.0.4 → 0.1.0
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 +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +3 -0
- data/Dockerfile +1 -2
- data/VERSION +1 -1
- data/docker-compose.yml +1 -1
- data/docker/start.test.sh +1 -1
- data/lib/netbox_client_ruby/api.rb +3 -3
- data/lib/netbox_client_ruby/api/dcim.rb +9 -7
- data/lib/netbox_client_ruby/api/dcim/device.rb +20 -18
- data/lib/netbox_client_ruby/api/dcim/device_role.rb +8 -6
- data/lib/netbox_client_ruby/api/dcim/device_roles.rb +11 -9
- data/lib/netbox_client_ruby/api/dcim/device_type.rb +18 -16
- data/lib/netbox_client_ruby/api/dcim/device_types.rb +11 -9
- data/lib/netbox_client_ruby/api/dcim/devices.rb +11 -9
- data/lib/netbox_client_ruby/api/dcim/interface.rb +9 -7
- data/lib/netbox_client_ruby/api/dcim/interfaces.rb +11 -9
- data/lib/netbox_client_ruby/api/dcim/inventory_item.rb +17 -0
- data/lib/netbox_client_ruby/api/dcim/inventory_items.rb +21 -0
- data/lib/netbox_client_ruby/api/dcim/manufacturer.rb +8 -6
- data/lib/netbox_client_ruby/api/dcim/manufacturers.rb +11 -9
- data/lib/netbox_client_ruby/api/dcim/platform.rb +8 -6
- data/lib/netbox_client_ruby/api/dcim/platforms.rb +11 -9
- data/lib/netbox_client_ruby/api/dcim/rack.rb +8 -6
- data/lib/netbox_client_ruby/api/dcim/racks.rb +11 -9
- data/lib/netbox_client_ruby/api/dcim/region.rb +9 -7
- data/lib/netbox_client_ruby/api/dcim/regions.rb +11 -9
- data/lib/netbox_client_ruby/api/dcim/site.rb +10 -8
- data/lib/netbox_client_ruby/api/dcim/sites.rb +11 -9
- data/lib/netbox_client_ruby/api/ipam.rb +5 -7
- data/lib/netbox_client_ruby/api/ipam/aggregate.rb +9 -7
- data/lib/netbox_client_ruby/api/ipam/aggregates.rb +11 -9
- data/lib/netbox_client_ruby/api/ipam/ip_address.rb +25 -23
- data/lib/netbox_client_ruby/api/ipam/ip_addresses.rb +11 -9
- data/lib/netbox_client_ruby/api/ipam/prefix.rb +35 -33
- data/lib/netbox_client_ruby/api/ipam/prefixes.rb +11 -9
- data/lib/netbox_client_ruby/api/ipam/rir.rb +8 -6
- data/lib/netbox_client_ruby/api/ipam/rirs.rb +11 -9
- data/lib/netbox_client_ruby/api/ipam/role.rb +8 -6
- data/lib/netbox_client_ruby/api/ipam/roles.rb +11 -9
- data/lib/netbox_client_ruby/api/ipam/vlan.rb +30 -28
- data/lib/netbox_client_ruby/api/ipam/vlan_group.rb +9 -7
- data/lib/netbox_client_ruby/api/ipam/vlan_groups.rb +11 -9
- data/lib/netbox_client_ruby/api/ipam/vlans.rb +11 -9
- data/lib/netbox_client_ruby/api/ipam/vrf.rb +9 -7
- data/lib/netbox_client_ruby/api/ipam/vrfs.rb +11 -9
- data/lib/netbox_client_ruby/api/tenancy.rb +13 -13
- data/lib/netbox_client_ruby/api/tenancy/tenant.rb +9 -7
- data/lib/netbox_client_ruby/api/tenancy/tenant_group.rb +8 -6
- data/lib/netbox_client_ruby/api/tenancy/tenant_groups.rb +11 -9
- data/lib/netbox_client_ruby/api/tenancy/tenants.rb +11 -9
- metadata +4 -2
@@ -2,18 +2,20 @@ require 'netbox_client_ruby/entities'
|
|
2
2
|
require 'netbox_client_ruby/api/dcim/manufacturer'
|
3
3
|
|
4
4
|
module NetboxClientRuby
|
5
|
-
|
6
|
-
|
5
|
+
module DCIM
|
6
|
+
class Manufacturers
|
7
|
+
include Entities
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
path 'dcim/manufacturers.json'
|
10
|
+
data_key 'results'
|
11
|
+
count_key 'count'
|
12
|
+
entity_creator :entity_creator
|
12
13
|
|
13
|
-
|
14
|
+
private
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
def entity_creator(raw_entity)
|
17
|
+
Manufacturer.new raw_entity['id']
|
18
|
+
end
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
@@ -1,12 +1,14 @@
|
|
1
1
|
require 'netbox_client_ruby/entity'
|
2
2
|
|
3
3
|
module NetboxClientRuby
|
4
|
-
|
5
|
-
|
4
|
+
module DCIM
|
5
|
+
class Platform
|
6
|
+
include Entity
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
id id: :id
|
9
|
+
deletable true
|
10
|
+
path 'dcim/platforms/:id.json'
|
11
|
+
creation_path 'dcim/platforms/'
|
12
|
+
end
|
11
13
|
end
|
12
14
|
end
|
@@ -2,18 +2,20 @@ require 'netbox_client_ruby/entities'
|
|
2
2
|
require 'netbox_client_ruby/api/dcim/platform'
|
3
3
|
|
4
4
|
module NetboxClientRuby
|
5
|
-
|
6
|
-
|
5
|
+
module DCIM
|
6
|
+
class Platforms
|
7
|
+
include Entities
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
path 'dcim/platforms.json'
|
10
|
+
data_key 'results'
|
11
|
+
count_key 'count'
|
12
|
+
entity_creator :entity_creator
|
12
13
|
|
13
|
-
|
14
|
+
private
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
def entity_creator(raw_entity)
|
17
|
+
Platform.new raw_entity['id']
|
18
|
+
end
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
@@ -1,12 +1,14 @@
|
|
1
1
|
require 'netbox_client_ruby/entity'
|
2
2
|
|
3
3
|
module NetboxClientRuby
|
4
|
-
|
5
|
-
|
4
|
+
module DCIM
|
5
|
+
class Rack
|
6
|
+
include Entity
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
id id: :id
|
9
|
+
deletable true
|
10
|
+
path 'dcim/racks/:id.json'
|
11
|
+
creation_path 'dcim/racks/'
|
12
|
+
end
|
11
13
|
end
|
12
14
|
end
|
@@ -2,18 +2,20 @@ require 'netbox_client_ruby/entities'
|
|
2
2
|
require 'netbox_client_ruby/api/dcim/rack'
|
3
3
|
|
4
4
|
module NetboxClientRuby
|
5
|
-
|
6
|
-
|
5
|
+
module DCIM
|
6
|
+
class Racks
|
7
|
+
include Entities
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
path 'dcim/racks.json'
|
10
|
+
data_key 'results'
|
11
|
+
count_key 'count'
|
12
|
+
entity_creator :entity_creator
|
12
13
|
|
13
|
-
|
14
|
+
private
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
def entity_creator(raw_entity)
|
17
|
+
Rack.new raw_entity['id']
|
18
|
+
end
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
@@ -1,13 +1,15 @@
|
|
1
1
|
require 'netbox_client_ruby/entity'
|
2
2
|
|
3
3
|
module NetboxClientRuby
|
4
|
-
|
5
|
-
|
4
|
+
module DCIM
|
5
|
+
class Region
|
6
|
+
include Entity
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
id id: :id
|
9
|
+
deletable true
|
10
|
+
path 'dcim/regions/:id.json'
|
11
|
+
creation_path 'dcim/regions/'
|
12
|
+
object_fields parent: proc { |raw_data| Region.new raw_data['id'] }
|
13
|
+
end
|
12
14
|
end
|
13
15
|
end
|
@@ -2,18 +2,20 @@ require 'netbox_client_ruby/entities'
|
|
2
2
|
require 'netbox_client_ruby/api/dcim/region'
|
3
3
|
|
4
4
|
module NetboxClientRuby
|
5
|
-
|
6
|
-
|
5
|
+
module DCIM
|
6
|
+
class Regions
|
7
|
+
include Entities
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
path 'dcim/regions.json'
|
10
|
+
data_key 'results'
|
11
|
+
count_key 'count'
|
12
|
+
entity_creator :entity_creator
|
12
13
|
|
13
|
-
|
14
|
+
private
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
def entity_creator(raw_entity)
|
17
|
+
Region.new raw_entity['id']
|
18
|
+
end
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
@@ -1,15 +1,17 @@
|
|
1
1
|
require 'netbox_client_ruby/entity'
|
2
2
|
|
3
3
|
module NetboxClientRuby
|
4
|
-
|
5
|
-
|
4
|
+
module DCIM
|
5
|
+
class Site
|
6
|
+
include Entity
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
id id: :id
|
9
|
+
readonly_fields :count_prefixes, :count_vlans, :count_racks, :count_devices,
|
10
|
+
:count_circuits
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
deletable true
|
13
|
+
path 'dcim/sites/:id.json'
|
14
|
+
creation_path 'dcim/sites/'
|
15
|
+
end
|
14
16
|
end
|
15
17
|
end
|
@@ -2,18 +2,20 @@ require 'netbox_client_ruby/entities'
|
|
2
2
|
require 'netbox_client_ruby/api/dcim/site'
|
3
3
|
|
4
4
|
module NetboxClientRuby
|
5
|
-
|
6
|
-
|
5
|
+
module DCIM
|
6
|
+
class Sites
|
7
|
+
include Entities
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
path 'dcim/sites.json'
|
10
|
+
data_key 'results'
|
11
|
+
count_key 'count'
|
12
|
+
entity_creator :entity_creator
|
12
13
|
|
13
|
-
|
14
|
+
private
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
def entity_creator(raw_entity)
|
17
|
+
Site.new raw_entity['id']
|
18
|
+
end
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
@@ -19,7 +19,7 @@ require 'netbox_client_ruby/api/ipam/vrfs'
|
|
19
19
|
require 'netbox_client_ruby/communication'
|
20
20
|
|
21
21
|
module NetboxClientRuby
|
22
|
-
|
22
|
+
module IPAM
|
23
23
|
{
|
24
24
|
aggregates: Aggregates,
|
25
25
|
ip_addresses: IpAddresses,
|
@@ -30,9 +30,8 @@ module NetboxClientRuby
|
|
30
30
|
vlan_groups: VlanGroups,
|
31
31
|
vrfs: Vrfs
|
32
32
|
}.each_pair do |method_name, class_name|
|
33
|
-
define_method(method_name)
|
34
|
-
|
35
|
-
end
|
33
|
+
define_method(method_name) { class_name.new }
|
34
|
+
module_function(method_name)
|
36
35
|
end
|
37
36
|
|
38
37
|
{
|
@@ -45,9 +44,8 @@ module NetboxClientRuby
|
|
45
44
|
vlan_group: VlanGroup,
|
46
45
|
vrf: Vrf
|
47
46
|
}.each_pair do |method_name, class_name|
|
48
|
-
define_method(method_name)
|
49
|
-
|
50
|
-
end
|
47
|
+
define_method(method_name) { |id| class_name.new id }
|
48
|
+
module_function(method_name)
|
51
49
|
end
|
52
50
|
end
|
53
51
|
end
|
@@ -2,13 +2,15 @@ require 'netbox_client_ruby/entity'
|
|
2
2
|
require 'netbox_client_ruby/api/ipam/rir'
|
3
3
|
|
4
4
|
module NetboxClientRuby
|
5
|
-
|
6
|
-
|
5
|
+
module IPAM
|
6
|
+
class Aggregate
|
7
|
+
include Entity
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
id id: :id
|
10
|
+
deletable true
|
11
|
+
path 'ipam/aggregates/:id.json'
|
12
|
+
creation_path 'ipam/aggregates/'
|
13
|
+
object_fields rir: proc { |raw_data| Rir.new raw_data['id'] }
|
14
|
+
end
|
13
15
|
end
|
14
16
|
end
|
@@ -2,18 +2,20 @@ require 'netbox_client_ruby/entities'
|
|
2
2
|
require 'netbox_client_ruby/api/ipam/aggregate'
|
3
3
|
|
4
4
|
module NetboxClientRuby
|
5
|
-
|
6
|
-
|
5
|
+
module IPAM
|
6
|
+
class Aggregates
|
7
|
+
include Entities
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
path 'ipam/aggregates.json'
|
10
|
+
data_key 'results'
|
11
|
+
count_key 'count'
|
12
|
+
entity_creator :entity_creator
|
12
13
|
|
13
|
-
|
14
|
+
private
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
def entity_creator(raw_entity)
|
17
|
+
Aggregate.new raw_entity['id']
|
18
|
+
end
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
@@ -5,32 +5,34 @@ require 'netbox_client_ruby/api/tenancy/tenant'
|
|
5
5
|
require 'ipaddress'
|
6
6
|
|
7
7
|
module NetboxClientRuby
|
8
|
-
|
9
|
-
|
8
|
+
module IPAM
|
9
|
+
class IpAddress
|
10
|
+
include Entity
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
STATUS_VALUES = {
|
13
|
+
active: 1,
|
14
|
+
reserved: 2,
|
15
|
+
deprecated: 3,
|
16
|
+
dhcp: 5
|
17
|
+
}.freeze
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
19
|
+
id id: :id
|
20
|
+
deletable true
|
21
|
+
path 'ipam/ip-addresses/:id.json'
|
22
|
+
creation_path 'ipam/ip-addresses/'
|
23
|
+
object_fields(
|
24
|
+
vrf: proc { |raw_data| Vrf.new raw_data['id'] },
|
25
|
+
tenant: proc { |raw_data| Tenancy::Tenant.new raw_data['id'] },
|
26
|
+
status: proc { |raw_data| STATUS_VALUES.key(raw_data['value']) || raw_data['value'] },
|
27
|
+
interface: proc { |raw_data| DCIM::Interface.new raw_data['id'] },
|
28
|
+
address: proc { |raw_ip| IPAddress.parse(raw_ip) }
|
29
|
+
)
|
30
|
+
readonly_fields :display_name
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
def status=(value)
|
33
|
+
status_code_lookup = STATUS_VALUES.fetch(value, value)
|
34
|
+
method_missing(:status=, status_code_lookup)
|
35
|
+
end
|
34
36
|
end
|
35
37
|
end
|
36
38
|
end
|
@@ -2,18 +2,20 @@ require 'netbox_client_ruby/entities'
|
|
2
2
|
require 'netbox_client_ruby/api/ipam/ip_address'
|
3
3
|
|
4
4
|
module NetboxClientRuby
|
5
|
-
|
6
|
-
|
5
|
+
module IPAM
|
6
|
+
class IpAddresses
|
7
|
+
include Entities
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
path 'ipam/ip-addresses.json'
|
10
|
+
data_key 'results'
|
11
|
+
count_key 'count'
|
12
|
+
entity_creator :entity_creator
|
12
13
|
|
13
|
-
|
14
|
+
private
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
def entity_creator(raw_entity)
|
17
|
+
IpAddress.new raw_entity['id']
|
18
|
+
end
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
@@ -8,42 +8,44 @@ require 'netbox_client_ruby/api/tenancy/tenant'
|
|
8
8
|
require 'ipaddress'
|
9
9
|
|
10
10
|
module NetboxClientRuby
|
11
|
-
|
12
|
-
|
11
|
+
module IPAM
|
12
|
+
class Prefix
|
13
|
+
include Entity
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
15
|
+
id id: :id
|
16
|
+
deletable true
|
17
|
+
path 'ipam/prefixes/:id.json'
|
18
|
+
creation_path 'ipam/prefixes/'
|
19
|
+
object_fields(
|
20
|
+
site: proc { |raw_data| DCIM::Site.new raw_data['id'] },
|
21
|
+
vrf: proc { |raw_data| Vrf.new raw_data['id'] },
|
22
|
+
tenant: proc { |raw_data| Tenancy::Tenant.new raw_data['id'] },
|
23
|
+
vlan: proc { |raw_data| Vlan.new raw_data['id'] },
|
24
|
+
status: proc { |raw_data| PrefixStatus.new raw_data['value'] },
|
25
|
+
role: proc { |raw_data| Role.new raw_data['id'] },
|
26
|
+
prefix: proc { |raw_data| IPAddress.parse raw_data }
|
27
|
+
)
|
28
|
+
readonly_fields :display_name
|
29
|
+
end
|
29
30
|
|
30
|
-
|
31
|
-
|
31
|
+
class PrefixStatus
|
32
|
+
attr_reader :value, :label
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
34
|
+
def initialize(status_value)
|
35
|
+
@value = status_value
|
36
|
+
@label = case status_value
|
37
|
+
when 0 then
|
38
|
+
'Container'.freeze
|
39
|
+
when 1 then
|
40
|
+
'Active'.freeze
|
41
|
+
when 2 then
|
42
|
+
'Reserved'.freeze
|
43
|
+
when 3 then
|
44
|
+
'Deprecated'.freeze
|
45
|
+
else
|
46
|
+
'UNDEFINED'.freeze
|
47
|
+
end
|
48
|
+
end
|
47
49
|
end
|
48
50
|
end
|
49
51
|
end
|