netbox-client-ruby 0.4.10 → 0.5.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.
@@ -1,3 +1,4 @@
1
+ require 'netbox_client_ruby/api/circuits'
1
2
  require 'netbox_client_ruby/api/dcim'
2
3
  require 'netbox_client_ruby/api/ipam'
3
4
  require 'netbox_client_ruby/api/secrets'
@@ -6,6 +7,10 @@ require 'netbox_client_ruby/api/virtualization'
6
7
  require 'netbox_client_ruby/communication'
7
8
 
8
9
  module NetboxClientRuby
10
+ def self.circuits
11
+ NetboxClientRuby::Circuits
12
+ end
13
+
9
14
  def self.dcim
10
15
  NetboxClientRuby::DCIM
11
16
  end
@@ -0,0 +1,33 @@
1
+ require 'netbox_client_ruby/api/circuits/circuit'
2
+ require 'netbox_client_ruby/api/circuits/circuit_list'
3
+ require 'netbox_client_ruby/api/circuits/circuit_termination'
4
+ require 'netbox_client_ruby/api/circuits/circuit_terminations'
5
+ require 'netbox_client_ruby/api/circuits/circuit_type'
6
+ require 'netbox_client_ruby/api/circuits/circuit_types'
7
+ require 'netbox_client_ruby/api/circuits/provider'
8
+ require 'netbox_client_ruby/api/circuits/providers'
9
+ require 'netbox_client_ruby/communication'
10
+
11
+ module NetboxClientRuby
12
+ module Circuits
13
+ {
14
+ providers: Providers,
15
+ circuits: CircuitList,
16
+ circuit_types: CircuitTypes,
17
+ circuit_terminations: CircuitTerminations
18
+ }.each_pair do |method_name, class_name|
19
+ define_method(method_name) { class_name.new }
20
+ module_function(method_name)
21
+ end
22
+
23
+ {
24
+ provider: Provider,
25
+ circuit: Circuit,
26
+ circuit_type: CircuitType,
27
+ circuit_termination: CircuitTermination
28
+ }.each_pair do |method_name, class_name|
29
+ define_method(method_name) { |id| class_name.new id }
30
+ module_function(method_name)
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,37 @@
1
+ require 'netbox_client_ruby/entity'
2
+ require 'netbox_client_ruby/api/circuits/circuit_type'
3
+ require 'netbox_client_ruby/api/circuits/provider'
4
+ require 'netbox_client_ruby/api/tenancy/tenant'
5
+
6
+ module NetboxClientRuby
7
+ module Circuits
8
+ class Circuit
9
+ include Entity
10
+
11
+ STATUS_VALUES = {
12
+ deprovisioning: 0,
13
+ active: 1,
14
+ planned: 2,
15
+ provisioning: 3,
16
+ offline: 4,
17
+ decommissioned: 5
18
+ }.freeze
19
+
20
+ id id: :id
21
+ deletable true
22
+ path 'circuits/circuits/:id.json'
23
+ creation_path 'circuits/circuits/'
24
+
25
+ object_fields(
26
+ provider: proc do |raw_data|
27
+ Circuit::CircuitProvider.new raw_data['id']
28
+ end,
29
+ status: proc do |raw_status|
30
+ STATUS_VALUES.key(raw_status['value']) || raw_status['value']
31
+ end,
32
+ type: proc { |raw_data| Circuit::CircuitType.new raw_data['id'] },
33
+ tenant: proc { |raw_data| Tenancy::Tenant.new raw_data['id'] }
34
+ )
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,26 @@
1
+ require 'netbox_client_ruby/entities'
2
+ require 'netbox_client_ruby/api/circuits/circuit'
3
+
4
+ module NetboxClientRuby
5
+ module Circuits
6
+ ##
7
+ # This allows to access a list of Netbox Circuits.
8
+ #
9
+ # Normally, this class would be called `Circuits`.
10
+ # But this conflicts with the module of the same name.
11
+ class CircuitList
12
+ include Entities
13
+
14
+ path 'circuits/circuits.json'
15
+ data_key 'results'
16
+ count_key 'count'
17
+ entity_creator :entity_creator
18
+
19
+ private
20
+
21
+ def entity_creator(raw_entity)
22
+ Circuit.new raw_entity['id']
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,23 @@
1
+ require 'netbox_client_ruby/entity'
2
+ require 'netbox_client_ruby/api/circuits/circuit'
3
+ require 'netbox_client_ruby/api/dcim/site'
4
+ require 'netbox_client_ruby/api/dcim/interface'
5
+
6
+ module NetboxClientRuby
7
+ module Circuits
8
+ class CircuitTermination
9
+ include Entity
10
+
11
+ id id: :id
12
+ deletable true
13
+ path 'circuits/circuit-terminations/:id.json'
14
+ creation_path 'circuits/circuit-terminations/'
15
+
16
+ object_fields(
17
+ circuit: proc { |raw_data| Circuit::Circuit.new raw_data['id'] },
18
+ site: proc { |raw_data| DCIM::Site.new raw_data['id'] },
19
+ interface: proc { |raw_data| DCIM::Interface.new raw_data['id'] }
20
+ )
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,21 @@
1
+ require 'netbox_client_ruby/entities'
2
+ require 'netbox_client_ruby/api/circuits/circuit_termination'
3
+
4
+ module NetboxClientRuby
5
+ module Circuits
6
+ class CircuitTerminations
7
+ include Entities
8
+
9
+ path 'circuits/circuit-terminations.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
+ CircuitTermination.new raw_entity['id']
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,14 @@
1
+ require 'netbox_client_ruby/entity'
2
+
3
+ module NetboxClientRuby
4
+ module Circuits
5
+ class CircuitType
6
+ include Entity
7
+
8
+ id id: :id
9
+ deletable true
10
+ path 'circuits/circuit-types/:id.json'
11
+ creation_path 'circuits/circuit-types/'
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,21 @@
1
+ require 'netbox_client_ruby/entities'
2
+ require 'netbox_client_ruby/api/circuits/circuit_type'
3
+
4
+ module NetboxClientRuby
5
+ module Circuits
6
+ class CircuitTypes
7
+ include Entities
8
+
9
+ path 'circuits/circuit-types.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
+ CircuitType.new raw_entity['id']
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,14 @@
1
+ require 'netbox_client_ruby/entity'
2
+
3
+ module NetboxClientRuby
4
+ module Circuits
5
+ class Provider
6
+ include Entity
7
+
8
+ id id: :id
9
+ deletable true
10
+ path 'circuits/providers/:id.json'
11
+ creation_path 'circuits/providers/'
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,21 @@
1
+ require 'netbox_client_ruby/entities'
2
+ require 'netbox_client_ruby/api/circuits/provider'
3
+
4
+ module NetboxClientRuby
5
+ module Circuits
6
+ class Providers
7
+ include Entities
8
+
9
+ path 'circuits/providers.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
+ Provider.new raw_entity['id']
18
+ end
19
+ end
20
+ end
21
+ end
@@ -19,6 +19,8 @@ require 'netbox_client_ruby/api/dcim/power_ports'
19
19
  require 'netbox_client_ruby/api/dcim/rack'
20
20
  require 'netbox_client_ruby/api/dcim/rack_group'
21
21
  require 'netbox_client_ruby/api/dcim/rack_groups'
22
+ require 'netbox_client_ruby/api/dcim/rack_reservation'
23
+ require 'netbox_client_ruby/api/dcim/rack_reservations'
22
24
  require 'netbox_client_ruby/api/dcim/rack_role'
23
25
  require 'netbox_client_ruby/api/dcim/rack_roles'
24
26
  require 'netbox_client_ruby/api/dcim/racks'
@@ -42,6 +44,7 @@ module NetboxClientRuby
42
44
  power_ports: PowerPorts,
43
45
  racks: Racks,
44
46
  rack_groups: RackGroups,
47
+ rack_reservations: RackReservations,
45
48
  rack_roles: RackRoles,
46
49
  regions: Regions,
47
50
  sites: Sites
@@ -62,6 +65,7 @@ module NetboxClientRuby
62
65
  power_port: PowerPort,
63
66
  rack: Rack,
64
67
  rack_group: RackGroup,
68
+ rack_reservation: RackReservation,
65
69
  rack_role: RackRole,
66
70
  region: Region,
67
71
  site: Site
@@ -1,4 +1,5 @@
1
1
  require 'netbox_client_ruby/entity'
2
+ require 'netbox_client_ruby/api/dcim/manufacturer'
2
3
 
3
4
  module NetboxClientRuby
4
5
  module DCIM
@@ -9,6 +10,11 @@ module NetboxClientRuby
9
10
  deletable true
10
11
  path 'dcim/platforms/:id.json'
11
12
  creation_path 'dcim/platforms/'
13
+ object_fields(
14
+ manufacturer: proc do |raw_manufacturer|
15
+ DCIM::Manufacturer.new raw_manufacturer['id']
16
+ end
17
+ )
12
18
  end
13
19
  end
14
20
  end
@@ -0,0 +1,21 @@
1
+ require 'netbox_client_ruby/entity'
2
+ require 'netbox_client_ruby/api/dcim/rack'
3
+ require 'netbox_client_ruby/api/tenancy/tenant'
4
+
5
+ module NetboxClientRuby
6
+ module DCIM
7
+ class RackReservation
8
+ include Entity
9
+
10
+ id id: :id
11
+ deletable true
12
+ path 'dcim/rack-reservations/:id.json'
13
+ creation_path 'dcim/rack-reservations/'
14
+
15
+ object_fields(
16
+ rack: proc { |raw_data| DCIM::Rack.new raw_data['id'] },
17
+ tenant: proc { |raw_data| Tenancy::Tenant.new raw_data['id'] },
18
+ )
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ require 'netbox_client_ruby/entities'
2
+ require 'netbox_client_ruby/api/dcim/rack_reservation'
3
+
4
+ module NetboxClientRuby
5
+ module DCIM
6
+ class RackReservations
7
+ include Entities
8
+
9
+ path 'dcim/rack-reservations.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
+ RackReservation.new raw_entity['id']
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,6 +1,4 @@
1
1
  require 'netbox_client_ruby/entity'
2
- require 'netbox_client_ruby/api/dcim/region'
3
- require 'netbox_client_ruby/api/tenancy/tenant'
4
2
 
5
3
  module NetboxClientRuby
6
4
  module DCIM
@@ -1,17 +1,30 @@
1
1
  require 'netbox_client_ruby/entity'
2
+ require 'netbox_client_ruby/api/dcim/region'
2
3
 
3
4
  module NetboxClientRuby
4
5
  module DCIM
5
6
  class Site
6
7
  include Entity
7
8
 
9
+ STATUS_VALUES = {
10
+ active: 1,
11
+ planned: 2,
12
+ retired: 4
13
+ }.freeze
14
+
8
15
  id id: :id
9
- readonly_fields :count_prefixes, :count_vlans, :count_racks, :count_devices,
10
- :count_circuits
16
+ readonly_fields :count_prefixes, :count_vlans, :count_racks,
17
+ :count_devices, :count_circuits
11
18
 
12
19
  deletable true
13
20
  path 'dcim/sites/:id.json'
14
21
  creation_path 'dcim/sites/'
22
+ object_fields(
23
+ region: proc { |raw_region| DCIM::Region.new raw_region['id'] },
24
+ status: proc do |raw_status|
25
+ STATUS_VALUES.key(raw_status['value']) || raw_status['value']
26
+ end
27
+ )
15
28
  end
16
29
  end
17
30
  end
@@ -11,8 +11,7 @@ module NetboxClientRuby
11
11
  path 'virtualization/interfaces/:id.json'
12
12
  creation_path 'virtualization/interfaces/'
13
13
  object_fields virtual_machine: proc { |raw_data|
14
- # https://github.com/digitalocean/netbox/issues/1794
15
- VirtualMachine.new(raw_data.is_a?(Hash) ? raw_data['id'] : raw_data)
14
+ VirtualMachine.new raw_data['id']
16
15
  }
17
16
  end
18
17
  end
@@ -1,18 +1,17 @@
1
- # coding: utf-8
2
-
3
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
4
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
3
 
6
4
  Gem::Specification.new do |spec|
7
5
  spec.name = 'netbox-client-ruby'
8
- spec.version = File.read(File.expand_path('../VERSION', __FILE__)).strip
9
- spec.authors = ['Christian Mäder']
10
- spec.email = ['christian.maeder@nine.ch']
6
+ spec.version = File.read(File.expand_path('VERSION', __dir__)).strip
11
7
 
12
8
  spec.summary = 'A read/write client for Netbox v2.'
13
9
  spec.homepage = 'https://github.com/ninech/netbox-client-ruby'
14
10
  spec.license = 'MIT'
15
11
 
12
+ spec.authors = ['Christian Mäder']
13
+ spec.email = ['christian.maeder@nine.ch']
14
+
16
15
  if spec.respond_to?(:metadata)
17
16
  spec.metadata['allowed_push_host'] = 'https://rubygems.org'
18
17
  end
@@ -25,16 +24,16 @@ Gem::Specification.new do |spec|
25
24
  spec.require_paths = ['lib']
26
25
 
27
26
  spec.add_runtime_dependency 'dry-configurable', '~> 0.1'
28
- spec.add_runtime_dependency 'faraday', '>= 0.11.0'
29
- spec.add_runtime_dependency 'faraday_middleware', '~> 0.11.0'
27
+ spec.add_runtime_dependency 'faraday', '~> 0.11', '>= 0.11.0'
30
28
  spec.add_runtime_dependency 'faraday-detailed_logger', '~> 2.1'
31
- spec.add_runtime_dependency 'ipaddress', '>= 0.8.3'
32
- spec.add_runtime_dependency 'openssl', '>= 2.0.5'
29
+ spec.add_runtime_dependency 'faraday_middleware', '~> 0.11.0'
30
+ spec.add_runtime_dependency 'ipaddress', '~> 0.8', '>= 0.8.3'
31
+ spec.add_runtime_dependency 'openssl', '~> 2.0', '>= 2.0.5'
33
32
 
34
33
  spec.add_development_dependency 'bundler', '~> 1.14'
34
+ spec.add_development_dependency 'pry', '~> 0.10'
35
35
  spec.add_development_dependency 'rake', '~> 10.0'
36
36
  spec.add_development_dependency 'rspec', '~> 3.5'
37
- spec.add_development_dependency 'pry', '~> 0.10'
38
37
  spec.add_development_dependency 'rubocop', '~> 0.48'
39
38
  spec.add_development_dependency 'rubocop-rspec', '~> 1.15'
40
39
  end
@@ -0,0 +1,51 @@
1
+ -----BEGIN RSA PRIVATE KEY-----
2
+ MIIJKQIBAAKCAgEAq8CSKPwZSbdekzP4Bpp/3KWgQdBlQdgV9mzgvCf6cj8h2tYt
3
+ Y05QKP0pbQv1XAX0S1pave49xON9X/huGKdEtou6/XC3HrDyyAQ43wSR0gv357W7
4
+ B6DEpAhw6ApINPFY/KQL78BqcAEu4pwXvJ3IdwBIYLJ9Czrg8r+JPwOVNWbD0UWM
5
+ etsUKPKooOKbz1WPZwF9IEMUtTRYs7TlQyh5Sc7nDII0hvYpm9fwy+jpNYqF81nQ
6
+ SOFyNgNn/bHImqDVbZLS77/P4kTdbIQTDemPPppfOfMjjEsB1Z7J/I7S7x3C8kBX
7
+ JeGqpCwM/ZOMg/AvbiByAVO0g8fUs1loe8h0tpJgH+c2cLVgSDN9GRjpyG9ooOQx
8
+ GhOxm/0nsLVbmOZ4bAPBvrwSBrhj75qJa+lXW1PtKfjd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