netbox-client-ruby 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c78a4154a9944842dc75069f72e98f8a092d106
4
- data.tar.gz: 420ec013f408fe984a91d256901cfb2ddfdb45c8
3
+ metadata.gz: 4db0c7461a73226465cf363e1d36a4a0ae09e312
4
+ data.tar.gz: 57a277a47aae7aa4b061fda4c9a30621ef3957f5
5
5
  SHA512:
6
- metadata.gz: 61e11316f50ef1cd456d220eb0caa0357fda74e5107cf3a36f8a1788ef51761ff2f92dd5754317691218fcae2def4ed76d5a32403615ff2b075ef4f562e506db
7
- data.tar.gz: 31dcc06dfb01df37e4037f3bbb63ff8eec91d021dc88c331be7c60075e29240585bfa1d052ee7f79a8449ac2aa9fdbf21e2296e2d64257edf4383d70d814e0d1
6
+ metadata.gz: fb67919777abcd7de549a6477dde74f309c3942e31929896c739bd58a6c6e484f929ab73a888e15664af7fced94dbd7aa5fe6288718b55b9145ee2ea3eafeec4
7
+ data.tar.gz: 81ac1560d1839a15c74a6a4398fa782b8bf8edf83267e18235ef115cadc8fb3559b809a19449d786b6483fe99d974259aa39fb39a9b401edf18e4dba05c04b7b
data/.gitignore CHANGED
@@ -12,3 +12,5 @@
12
12
 
13
13
  quickstart.rb
14
14
  *.gz
15
+
16
+ /vendor/
data/.travis.yml CHANGED
@@ -1,6 +1,9 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  before_install: gem install bundler
4
+ rvm:
5
+ - 2.3
6
+ - 2.4
4
7
  notifications:
5
8
  email:
6
9
  on_success: never
data/Dockerfile CHANGED
@@ -1,5 +1,4 @@
1
1
  FROM ruby:2.3.4-alpine
2
- MAINTAINER development@nine.ch
3
2
 
4
3
  RUN apk add --no-cache git
5
4
 
@@ -7,6 +6,6 @@ RUN mkdir /app
7
6
  WORKDIR /app
8
7
 
9
8
  COPY . ./
10
- RUN bundle install --jobs 4 --quiet
9
+ RUN bundle install --jobs 4 --quiet --deployment
11
10
 
12
11
  CMD docker/start.sh
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.1.0
data/docker-compose.yml CHANGED
@@ -17,7 +17,7 @@ services:
17
17
  ports:
18
18
  - 80
19
19
  netbox:
20
- image: digitalocean/netbox:v2.0-beta2
20
+ image: ninech/netbox:latest
21
21
  depends_on:
22
22
  - postgres
23
23
  volumes:
data/docker/start.test.sh CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/bin/sh
2
2
 
3
- exec bundle exec rspec
3
+ exec bundle exec rake
@@ -5,14 +5,14 @@ require 'netbox_client_ruby/communication'
5
5
 
6
6
  module NetboxClientRuby
7
7
  def self.dcim
8
- @dcim ||= NetboxClientRuby::DCIM.new
8
+ @dcim ||= NetboxClientRuby::DCIM
9
9
  end
10
10
 
11
11
  def self.tenancy
12
- @tenancy ||= NetboxClientRuby::Tenancy.new
12
+ @tenancy ||= NetboxClientRuby::Tenancy
13
13
  end
14
14
 
15
15
  def self.ipam
16
- @ipam ||= NetboxClientRuby::IPAM.new
16
+ @ipam ||= NetboxClientRuby::IPAM
17
17
  end
18
18
  end
@@ -6,6 +6,8 @@ require 'netbox_client_ruby/api/dcim/device_type'
6
6
  require 'netbox_client_ruby/api/dcim/device_types'
7
7
  require 'netbox_client_ruby/api/dcim/interface'
8
8
  require 'netbox_client_ruby/api/dcim/interfaces'
9
+ require 'netbox_client_ruby/api/dcim/inventory_item'
10
+ require 'netbox_client_ruby/api/dcim/inventory_items'
9
11
  require 'netbox_client_ruby/api/dcim/manufacturer'
10
12
  require 'netbox_client_ruby/api/dcim/manufacturers'
11
13
  require 'netbox_client_ruby/api/dcim/platform'
@@ -19,21 +21,21 @@ require 'netbox_client_ruby/api/dcim/sites'
19
21
  require 'netbox_client_ruby/communication'
20
22
 
21
23
  module NetboxClientRuby
22
- class DCIM
24
+ module DCIM
23
25
  {
24
26
  devices: Devices,
25
27
  device_roles: DeviceRoles,
26
28
  device_types: DeviceTypes,
27
29
  interfaces: Interfaces,
30
+ inventory_items: InventoryItems,
28
31
  manufacturers: Manufacturers,
29
32
  platforms: Platforms,
30
33
  racks: Racks,
31
34
  regions: Regions,
32
35
  sites: Sites
33
36
  }.each_pair do |method_name, class_name|
34
- define_method(method_name) do
35
- class_name.new
36
- end
37
+ define_method(method_name) { class_name.new }
38
+ module_function(method_name)
37
39
  end
38
40
 
39
41
  {
@@ -41,15 +43,15 @@ module NetboxClientRuby
41
43
  device_role: DeviceRole,
42
44
  device_type: DeviceType,
43
45
  interface: Interface,
46
+ inventory_item: InventoryItem,
44
47
  manufacturer: Manufacturer,
45
48
  platform: Platform,
46
49
  rack: Rack,
47
50
  region: Region,
48
51
  site: Site
49
52
  }.each_pair do |method_name, class_name|
50
- define_method(method_name) do |id|
51
- class_name.new id
52
- end
53
+ define_method(method_name) { |id| class_name.new id }
54
+ module_function(method_name)
53
55
  end
54
56
  end
55
57
  end
@@ -8,24 +8,26 @@ require 'netbox_client_ruby/api/dcim/rack'
8
8
  require 'netbox_client_ruby/api/ipam/ip_address'
9
9
 
10
10
  module NetboxClientRuby
11
- class Device
12
- include NetboxClientRuby::Entity
11
+ module DCIM
12
+ class Device
13
+ include Entity
13
14
 
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
- )
15
+ id id: :id
16
+ deletable true
17
+ path 'dcim/devices/:id.json'
18
+ creation_path 'dcim/devices/'
19
+ object_fields(
20
+ device_type: proc { |raw_data| DeviceType.new raw_data['id'] },
21
+ device_role: proc { |raw_data| DeviceRole.new raw_data['id'] },
22
+ tenant: proc { |raw_data| Tenancy::Tenant.new raw_data['id'] },
23
+ platform: proc { |raw_data| Platform.new raw_data['id'] },
24
+ site: proc { |raw_data| Site.new raw_data['id'] },
25
+ rack: proc { |raw_data| Rack.new raw_data['id'] },
26
+ parent_device: proc { |raw_data| Device.new raw_data['id'] },
27
+ primary_ip: proc { |raw_data| IPAM::IpAddress.new raw_data['id'] },
28
+ primary_ip4: proc { |raw_data| IPAM::IpAddress.new raw_data['id'] },
29
+ primary_ip6: proc { |raw_data| IPAM::IpAddress.new raw_data['id'] }
30
+ )
31
+ end
30
32
  end
31
33
  end
@@ -1,12 +1,14 @@
1
1
  require 'netbox_client_ruby/entity'
2
2
 
3
3
  module NetboxClientRuby
4
- class DeviceRole
5
- include NetboxClientRuby::Entity
4
+ module DCIM
5
+ class DeviceRole
6
+ include Entity
6
7
 
7
- id id: :id
8
- deletable true
9
- path 'dcim/device-roles/:id.json'
10
- creation_path 'dcim/device-roles/'
8
+ id id: :id
9
+ deletable true
10
+ path 'dcim/device-roles/:id.json'
11
+ creation_path 'dcim/device-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/dcim/device_type'
3
3
 
4
4
  module NetboxClientRuby
5
- class DeviceRoles
6
- include NetboxClientRuby::Entities
5
+ module DCIM
6
+ class DeviceRoles
7
+ include Entities
7
8
 
8
- path 'dcim/device-roles.json'
9
- data_key 'results'
10
- count_key 'count'
11
- entity_creator :entity_creator
9
+ path 'dcim/device-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::DeviceRole.new raw_entity['id']
16
+ def entity_creator(raw_entity)
17
+ DeviceRole.new raw_entity['id']
18
+ end
17
19
  end
18
20
  end
19
21
  end
@@ -2,25 +2,27 @@ require 'netbox_client_ruby/entity'
2
2
  require 'netbox_client_ruby/api/dcim/manufacturer'
3
3
 
4
4
  module NetboxClientRuby
5
- class InterfaceOrdering
6
- attr_reader :value, :label
5
+ module DCIM
6
+ class InterfaceOrdering
7
+ attr_reader :value, :label
7
8
 
8
- def initialize(raw_data)
9
- @value = raw_data['value']
10
- @label = raw_data['label']
9
+ def initialize(raw_data)
10
+ @value = raw_data['value']
11
+ @label = raw_data['label']
12
+ end
11
13
  end
12
- end
13
14
 
14
- class DeviceType
15
- include NetboxClientRuby::Entity
15
+ class DeviceType
16
+ include Entity
16
17
 
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
- )
18
+ id id: :id
19
+ deletable true
20
+ path 'dcim/device-types/:id.json'
21
+ creation_path 'dcim/device-types/'
22
+ object_fields(
23
+ manufacturer: proc { |raw_data| Manufacturer.new raw_data['id'] },
24
+ interface_ordering: InterfaceOrdering
25
+ )
26
+ end
25
27
  end
26
28
  end
@@ -2,18 +2,20 @@ require 'netbox_client_ruby/entities'
2
2
  require 'netbox_client_ruby/api/dcim/device_type'
3
3
 
4
4
  module NetboxClientRuby
5
- class DeviceTypes
6
- include NetboxClientRuby::Entities
5
+ module DCIM
6
+ class DeviceTypes
7
+ include Entities
7
8
 
8
- path 'dcim/device-types.json'
9
- data_key 'results'
10
- count_key 'count'
11
- entity_creator :entity_creator
9
+ path 'dcim/device-types.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::DeviceType.new raw_entity['id']
16
+ def entity_creator(raw_entity)
17
+ DeviceType.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/dcim/device'
3
3
 
4
4
  module NetboxClientRuby
5
- class Devices
6
- include NetboxClientRuby::Entities
5
+ module DCIM
6
+ class Devices
7
+ include Entities
7
8
 
8
- path 'dcim/devices.json'
9
- data_key 'results'
10
- count_key 'count'
11
- entity_creator :entity_creator
9
+ path 'dcim/devices.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::Device.new raw_entity['id']
16
+ def entity_creator(raw_entity)
17
+ Device.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/dcim/device'
3
3
 
4
4
  module NetboxClientRuby
5
- class Interface
6
- include NetboxClientRuby::Entity
5
+ module DCIM
6
+ class Interface
7
+ include Entity
7
8
 
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'] }
9
+ id id: :id
10
+ deletable true
11
+ path 'dcim/interfaces/:id.json'
12
+ creation_path 'dcim/interfaces/'
13
+ object_fields device: proc { |raw_data| Device.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/dcim/interface'
3
3
 
4
4
  module NetboxClientRuby
5
- class Interfaces
6
- include NetboxClientRuby::Entities
5
+ module DCIM
6
+ class Interfaces
7
+ include Entities
7
8
 
8
- path 'dcim/interfaces.json'
9
- data_key 'results'
10
- count_key 'count'
11
- entity_creator :entity_creator
9
+ path 'dcim/interfaces.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::Interface.new raw_entity['id']
16
+ def entity_creator(raw_entity)
17
+ Interface.new raw_entity['id']
18
+ end
17
19
  end
18
20
  end
19
21
  end
@@ -0,0 +1,17 @@
1
+ require 'netbox_client_ruby/entity'
2
+ require 'netbox_client_ruby/api/dcim/device'
3
+
4
+ module NetboxClientRuby
5
+ module DCIM
6
+ class InventoryItem
7
+ include Entity
8
+
9
+ id id: :id
10
+ deletable true
11
+ path 'dcim/inventory-items/:id.json'
12
+ creation_path 'dcim/inventory-items/'
13
+ object_fields device: proc { |raw_data| Device.new raw_data['id'] },
14
+ manufacturer: proc { |raw_data| Manufacturer.new raw_data['id'] }
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,21 @@
1
+ require 'netbox_client_ruby/entities'
2
+ require 'netbox_client_ruby/api/dcim/inventory_item'
3
+
4
+ module NetboxClientRuby
5
+ module DCIM
6
+ class InventoryItems
7
+ include Entities
8
+
9
+ path 'dcim/inventory-items.json'
10
+ data_key 'results'
11
+ count_key 'count'
12
+ entity_creator :entity_creator
13
+
14
+ private
15
+
16
+ def entity_creator(raw_entity)
17
+ InventoryItem.new raw_entity['id']
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,12 +1,14 @@
1
1
  require 'netbox_client_ruby/entity'
2
2
 
3
3
  module NetboxClientRuby
4
- class Manufacturer
5
- include NetboxClientRuby::Entity
4
+ module DCIM
5
+ class Manufacturer
6
+ include Entity
6
7
 
7
- id id: :id
8
- deletable true
9
- path 'dcim/manufacturers/:id.json'
10
- creation_path 'dcim/manufacturers/'
8
+ id id: :id
9
+ deletable true
10
+ path 'dcim/manufacturers/:id.json'
11
+ creation_path 'dcim/manufacturers/'
12
+ end
11
13
  end
12
14
  end