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.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.travis.yml +3 -0
  4. data/Dockerfile +1 -2
  5. data/VERSION +1 -1
  6. data/docker-compose.yml +1 -1
  7. data/docker/start.test.sh +1 -1
  8. data/lib/netbox_client_ruby/api.rb +3 -3
  9. data/lib/netbox_client_ruby/api/dcim.rb +9 -7
  10. data/lib/netbox_client_ruby/api/dcim/device.rb +20 -18
  11. data/lib/netbox_client_ruby/api/dcim/device_role.rb +8 -6
  12. data/lib/netbox_client_ruby/api/dcim/device_roles.rb +11 -9
  13. data/lib/netbox_client_ruby/api/dcim/device_type.rb +18 -16
  14. data/lib/netbox_client_ruby/api/dcim/device_types.rb +11 -9
  15. data/lib/netbox_client_ruby/api/dcim/devices.rb +11 -9
  16. data/lib/netbox_client_ruby/api/dcim/interface.rb +9 -7
  17. data/lib/netbox_client_ruby/api/dcim/interfaces.rb +11 -9
  18. data/lib/netbox_client_ruby/api/dcim/inventory_item.rb +17 -0
  19. data/lib/netbox_client_ruby/api/dcim/inventory_items.rb +21 -0
  20. data/lib/netbox_client_ruby/api/dcim/manufacturer.rb +8 -6
  21. data/lib/netbox_client_ruby/api/dcim/manufacturers.rb +11 -9
  22. data/lib/netbox_client_ruby/api/dcim/platform.rb +8 -6
  23. data/lib/netbox_client_ruby/api/dcim/platforms.rb +11 -9
  24. data/lib/netbox_client_ruby/api/dcim/rack.rb +8 -6
  25. data/lib/netbox_client_ruby/api/dcim/racks.rb +11 -9
  26. data/lib/netbox_client_ruby/api/dcim/region.rb +9 -7
  27. data/lib/netbox_client_ruby/api/dcim/regions.rb +11 -9
  28. data/lib/netbox_client_ruby/api/dcim/site.rb +10 -8
  29. data/lib/netbox_client_ruby/api/dcim/sites.rb +11 -9
  30. data/lib/netbox_client_ruby/api/ipam.rb +5 -7
  31. data/lib/netbox_client_ruby/api/ipam/aggregate.rb +9 -7
  32. data/lib/netbox_client_ruby/api/ipam/aggregates.rb +11 -9
  33. data/lib/netbox_client_ruby/api/ipam/ip_address.rb +25 -23
  34. data/lib/netbox_client_ruby/api/ipam/ip_addresses.rb +11 -9
  35. data/lib/netbox_client_ruby/api/ipam/prefix.rb +35 -33
  36. data/lib/netbox_client_ruby/api/ipam/prefixes.rb +11 -9
  37. data/lib/netbox_client_ruby/api/ipam/rir.rb +8 -6
  38. data/lib/netbox_client_ruby/api/ipam/rirs.rb +11 -9
  39. data/lib/netbox_client_ruby/api/ipam/role.rb +8 -6
  40. data/lib/netbox_client_ruby/api/ipam/roles.rb +11 -9
  41. data/lib/netbox_client_ruby/api/ipam/vlan.rb +30 -28
  42. data/lib/netbox_client_ruby/api/ipam/vlan_group.rb +9 -7
  43. data/lib/netbox_client_ruby/api/ipam/vlan_groups.rb +11 -9
  44. data/lib/netbox_client_ruby/api/ipam/vlans.rb +11 -9
  45. data/lib/netbox_client_ruby/api/ipam/vrf.rb +9 -7
  46. data/lib/netbox_client_ruby/api/ipam/vrfs.rb +11 -9
  47. data/lib/netbox_client_ruby/api/tenancy.rb +13 -13
  48. data/lib/netbox_client_ruby/api/tenancy/tenant.rb +9 -7
  49. data/lib/netbox_client_ruby/api/tenancy/tenant_group.rb +8 -6
  50. data/lib/netbox_client_ruby/api/tenancy/tenant_groups.rb +11 -9
  51. data/lib/netbox_client_ruby/api/tenancy/tenants.rb +11 -9
  52. metadata +4 -2
@@ -2,18 +2,20 @@ require 'netbox_client_ruby/entities'
2
2
  require 'netbox_client_ruby/api/ipam/prefix'
3
3
 
4
4
  module NetboxClientRuby
5
- class Prefixes
6
- include NetboxClientRuby::Entities
5
+ module IPAM
6
+ class Prefixes
7
+ include Entities
7
8
 
8
- path 'ipam/prefixes.json'
9
- data_key 'results'
10
- count_key 'count'
11
- entity_creator :entity_creator
9
+ path 'ipam/prefixes.json'
10
+ data_key 'results'
11
+ count_key 'count'
12
+ entity_creator :entity_creator
12
13
 
13
- private
14
+ private
14
15
 
15
- def entity_creator(raw_entity)
16
- NetboxClientRuby::Prefix.new raw_entity['id']
16
+ def entity_creator(raw_entity)
17
+ Prefix.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
- class Rir
5
- include NetboxClientRuby::Entity
4
+ module IPAM
5
+ class Rir
6
+ include Entity
6
7
 
7
- id id: :id
8
- deletable true
9
- path 'ipam/rirs/:id.json'
10
- creation_path 'ipam/rirs/'
8
+ id id: :id
9
+ deletable true
10
+ path 'ipam/rirs/:id.json'
11
+ creation_path 'ipam/rirs/'
12
+ end
11
13
  end
12
14
  end
@@ -2,18 +2,20 @@ require 'netbox_client_ruby/entities'
2
2
  require 'netbox_client_ruby/api/ipam/rir'
3
3
 
4
4
  module NetboxClientRuby
5
- class Rirs
6
- include NetboxClientRuby::Entities
5
+ module IPAM
6
+ class Rirs
7
+ include Entities
7
8
 
8
- path 'ipam/rirs.json'
9
- data_key 'results'
10
- count_key 'count'
11
- entity_creator :entity_creator
9
+ path 'ipam/rirs.json'
10
+ data_key 'results'
11
+ count_key 'count'
12
+ entity_creator :entity_creator
12
13
 
13
- private
14
+ private
14
15
 
15
- def entity_creator(raw_entity)
16
- NetboxClientRuby::Rir.new raw_entity['id']
16
+ def entity_creator(raw_entity)
17
+ Rir.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
- class Role
5
- include NetboxClientRuby::Entity
4
+ module IPAM
5
+ class Role
6
+ include Entity
6
7
 
7
- id id: :id
8
- deletable true
9
- path 'ipam/roles/:id.json'
10
- creation_path 'ipam/roles/'
8
+ id id: :id
9
+ deletable true
10
+ path 'ipam/roles/:id.json'
11
+ creation_path 'ipam/roles/'
12
+ end
11
13
  end
12
14
  end
@@ -2,18 +2,20 @@ require 'netbox_client_ruby/entities'
2
2
  require 'netbox_client_ruby/api/ipam/role'
3
3
 
4
4
  module NetboxClientRuby
5
- class Roles
6
- include NetboxClientRuby::Entities
5
+ module IPAM
6
+ class Roles
7
+ include Entities
7
8
 
8
- path 'ipam/roles.json'
9
- data_key 'results'
10
- count_key 'count'
11
- entity_creator :entity_creator
9
+ path 'ipam/roles.json'
10
+ data_key 'results'
11
+ count_key 'count'
12
+ entity_creator :entity_creator
12
13
 
13
- private
14
+ private
14
15
 
15
- def entity_creator(raw_entity)
16
- NetboxClientRuby::Role.new raw_entity['id']
16
+ def entity_creator(raw_entity)
17
+ Role.new raw_entity['id']
18
+ end
17
19
  end
18
20
  end
19
21
  end
@@ -4,37 +4,39 @@ require 'netbox_client_ruby/api/ipam/role'
4
4
  require 'netbox_client_ruby/api/ipam/vlan_group'
5
5
 
6
6
  module NetboxClientRuby
7
- class Vlan
8
- include NetboxClientRuby::Entity
7
+ module IPAM
8
+ class Vlan
9
+ include Entity
9
10
 
10
- id id: :id
11
- deletable true
12
- path 'ipam/vlans/:id.json'
13
- creation_path 'ipam/vlans/'
14
- object_fields(
15
- tenant: proc { |raw_data| NetboxClientRuby::Tenant.new raw_data['id'] },
16
- role: proc { |raw_data| NetboxClientRuby::Role.new raw_data['id'] },
17
- status: proc { |raw_data| NetboxClientRuby::VlanStatus.new raw_data['value'] },
18
- group: proc { |raw_data| NetboxClientRuby::VlanGroup.new raw_data['id'] }
19
- )
20
- readonly_fields :display_name
21
- end
11
+ id id: :id
12
+ deletable true
13
+ path 'ipam/vlans/:id.json'
14
+ creation_path 'ipam/vlans/'
15
+ object_fields(
16
+ tenant: proc { |raw_data| Tenancy::Tenant.new raw_data['id'] },
17
+ role: proc { |raw_data| Role.new raw_data['id'] },
18
+ status: proc { |raw_data| VlanStatus.new raw_data['value'] },
19
+ group: proc { |raw_data| VlanGroup.new raw_data['id'] }
20
+ )
21
+ readonly_fields :display_name
22
+ end
22
23
 
23
- class VlanStatus
24
- attr_reader :value, :label
24
+ class VlanStatus
25
+ attr_reader :value, :label
25
26
 
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
- else
36
- 'UNDEFINED'.freeze
37
- end
27
+ def initialize(status_value)
28
+ @value = status_value
29
+ @label = case status_value
30
+ when 1 then
31
+ 'Active'.freeze
32
+ when 2 then
33
+ 'Reserved'.freeze
34
+ when 3 then
35
+ 'Deprecated'.freeze
36
+ else
37
+ 'UNDEFINED'.freeze
38
+ end
39
+ end
38
40
  end
39
41
  end
40
42
  end
@@ -2,13 +2,15 @@ require 'netbox_client_ruby/entity'
2
2
  require 'netbox_client_ruby/api/dcim/site'
3
3
 
4
4
  module NetboxClientRuby
5
- class VlanGroup
6
- include NetboxClientRuby::Entity
5
+ module IPAM
6
+ class VlanGroup
7
+ include Entity
7
8
 
8
- id id: :id
9
- deletable true
10
- path 'ipam/vlan-groups/:id.json'
11
- creation_path 'ipam/vlan-groups/'
12
- object_fields site: proc { |raw_data| NetboxClientRuby::Site.new raw_data['id'] }
9
+ id id: :id
10
+ deletable true
11
+ path 'ipam/vlan-groups/:id.json'
12
+ creation_path 'ipam/vlan-groups/'
13
+ object_fields site: proc { |raw_data| Site.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/vlan_group'
3
3
 
4
4
  module NetboxClientRuby
5
- class VlanGroups
6
- include NetboxClientRuby::Entities
5
+ module IPAM
6
+ class VlanGroups
7
+ include Entities
7
8
 
8
- path 'ipam/vlan-groups.json'
9
- data_key 'results'
10
- count_key 'count'
11
- entity_creator :entity_creator
9
+ path 'ipam/vlan-groups.json'
10
+ data_key 'results'
11
+ count_key 'count'
12
+ entity_creator :entity_creator
12
13
 
13
- private
14
+ private
14
15
 
15
- def entity_creator(raw_entity)
16
- NetboxClientRuby::VlanGroup.new raw_entity['id']
16
+ def entity_creator(raw_entity)
17
+ VlanGroup.new raw_entity['id']
18
+ end
17
19
  end
18
20
  end
19
21
  end
@@ -2,18 +2,20 @@ require 'netbox_client_ruby/entities'
2
2
  require 'netbox_client_ruby/api/ipam/vlan'
3
3
 
4
4
  module NetboxClientRuby
5
- class Vlans
6
- include NetboxClientRuby::Entities
5
+ module IPAM
6
+ class Vlans
7
+ include Entities
7
8
 
8
- path 'ipam/vlans.json'
9
- data_key 'results'
10
- count_key 'count'
11
- entity_creator :entity_creator
9
+ path 'ipam/vlans.json'
10
+ data_key 'results'
11
+ count_key 'count'
12
+ entity_creator :entity_creator
12
13
 
13
- private
14
+ private
14
15
 
15
- def entity_creator(raw_entity)
16
- NetboxClientRuby::Vlan.new raw_entity['id']
16
+ def entity_creator(raw_entity)
17
+ Vlan.new raw_entity['id']
18
+ end
17
19
  end
18
20
  end
19
21
  end
@@ -2,13 +2,15 @@ require 'netbox_client_ruby/entity'
2
2
  require 'netbox_client_ruby/api/tenancy/tenant'
3
3
 
4
4
  module NetboxClientRuby
5
- class Vrf
6
- include NetboxClientRuby::Entity
5
+ module IPAM
6
+ class Vrf
7
+ include Entity
7
8
 
8
- id id: :id
9
- deletable true
10
- path 'ipam/vrfs/:id.json'
11
- creation_path 'ipam/vrfs/'
12
- object_fields tenant: proc { |raw_data| NetboxClientRuby::Tenant.new raw_data['id'] }
9
+ id id: :id
10
+ deletable true
11
+ path 'ipam/vrfs/:id.json'
12
+ creation_path 'ipam/vrfs/'
13
+ object_fields tenant: proc { |raw_data| Tenancy::Tenant.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/vrf'
3
3
 
4
4
  module NetboxClientRuby
5
- class Vrfs
6
- include NetboxClientRuby::Entities
5
+ module IPAM
6
+ class Vrfs
7
+ include Entities
7
8
 
8
- path 'ipam/vrfs.json'
9
- data_key 'results'
10
- count_key 'count'
11
- entity_creator :entity_creator
9
+ path 'ipam/vrfs.json'
10
+ data_key 'results'
11
+ count_key 'count'
12
+ entity_creator :entity_creator
12
13
 
13
- private
14
+ private
14
15
 
15
- def entity_creator(raw_entity)
16
- NetboxClientRuby::Vrf.new raw_entity['id']
16
+ def entity_creator(raw_entity)
17
+ Vrf.new raw_entity['id']
18
+ end
17
19
  end
18
20
  end
19
21
  end
@@ -5,21 +5,21 @@ require 'netbox_client_ruby/api/tenancy/tenant_groups'
5
5
  require 'netbox_client_ruby/communication'
6
6
 
7
7
  module NetboxClientRuby
8
- class Tenancy
9
- def tenants
10
- Tenants.new
8
+ module Tenancy
9
+ {
10
+ tenants: Tenants,
11
+ tenant_groups: TenantGroups
12
+ }.each_pair do |method_name, class_name|
13
+ define_method(method_name) { class_name.new }
14
+ module_function(method_name)
11
15
  end
12
16
 
13
- def tenant(id)
14
- Tenant.new id
15
- end
16
-
17
- def tenant_groups
18
- TenantGroups.new
19
- end
20
-
21
- def tenant_group
22
- TenantGroup.new
17
+ {
18
+ tenant: Tenant,
19
+ tenant_group: TenantGroup
20
+ }.each_pair do |method_name, class_name|
21
+ define_method(method_name) { |id| class_name.new id }
22
+ module_function(method_name)
23
23
  end
24
24
  end
25
25
  end
@@ -2,13 +2,15 @@ require 'netbox_client_ruby/entity'
2
2
  require 'netbox_client_ruby/api/tenancy/tenant_group'
3
3
 
4
4
  module NetboxClientRuby
5
- class Tenant
6
- include NetboxClientRuby::Entity
5
+ module Tenancy
6
+ class Tenant
7
+ include Entity
7
8
 
8
- id id: :id
9
- deletable true
10
- path 'tenancy/tenants/:id.json'
11
- creation_path 'tenancy/tenants/'
12
- object_fields group: proc { |raw_data| NetboxClientRuby::TenantGroup.new raw_data['id'] }
9
+ id id: :id
10
+ deletable true
11
+ path 'tenancy/tenants/:id.json'
12
+ creation_path 'tenancy/tenants/'
13
+ object_fields group: proc { |raw_data| TenantGroup.new raw_data['id'] }
14
+ end
13
15
  end
14
16
  end
@@ -1,12 +1,14 @@
1
1
  require 'netbox_client_ruby/entity'
2
2
 
3
3
  module NetboxClientRuby
4
- class TenantGroup
5
- include NetboxClientRuby::Entity
4
+ module Tenancy
5
+ class TenantGroup
6
+ include Entity
6
7
 
7
- id id: :id
8
- deletable true
9
- path 'tenancy/tenant-groups/:id.json'
10
- creation_path 'tenancy/tenant-groups/'
8
+ id id: :id
9
+ deletable true
10
+ path 'tenancy/tenant-groups/:id.json'
11
+ creation_path 'tenancy/tenant-groups/'
12
+ end
11
13
  end
12
14
  end
@@ -2,18 +2,20 @@ require 'netbox_client_ruby/entities'
2
2
  require 'netbox_client_ruby/api/tenancy/tenant_group'
3
3
 
4
4
  module NetboxClientRuby
5
- class TenantGroups
6
- include NetboxClientRuby::Entities
5
+ module Tenancy
6
+ class TenantGroups
7
+ include Entities
7
8
 
8
- path 'tenancy/tenant-groups.json'
9
- data_key 'results'
10
- count_key 'count'
11
- entity_creator :entity_creator
9
+ path 'tenancy/tenant-groups.json'
10
+ data_key 'results'
11
+ count_key 'count'
12
+ entity_creator :entity_creator
12
13
 
13
- private
14
+ private
14
15
 
15
- def entity_creator(raw_entity)
16
- NetboxClientRuby::TenantGroup.new raw_entity['id']
16
+ def entity_creator(raw_entity)
17
+ TenantGroup.new raw_entity['id']
18
+ end
17
19
  end
18
20
  end
19
21
  end