netbox-client-ruby 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 30ebbb6c61eea3d9d7d041a93900453bef596b63
4
- data.tar.gz: 9fb76ba45290bcc67f16b45274d69683ae21efbc
3
+ metadata.gz: 168709e9be66cbac5368b2bf2c9d88998e5d1287
4
+ data.tar.gz: ab817551670cc44a4e7e9aeb6e08f1fa72ff5a56
5
5
  SHA512:
6
- metadata.gz: 4f9f038e78e888472318b02e16a0df20846110d1efe351145a892f14fba2712879bb077d73128481a9caf7618eed1695bb4e6c1e0cf15a3e37ad14efdab53b5d
7
- data.tar.gz: f6cbf5a92b271ac8ef5c04d5f86cb8fe6b354a092117dda9eddeb70443ededd655a83505def5619a42069eb72bd6956dad37d906da3ea8cbb33c5f545cee4111
6
+ metadata.gz: 7d4332e0689c12f7f86903ef0afd7a6ac91f0c205cb34579c4d76b6ef2d57cb7bb6a1537c2997111a3698ca5a6df561359a4cae7748ba57f85b3c85a9c741bc8
7
+ data.tar.gz: ad322b6a0b4cb1e6e54156f386b6cfd4e0634231ebef45adcb96300c72d16701e855b68a6856954d187fa1a362e3be02eca6a4a715faa177e98c1febe2ee9944
data/Dockerfile CHANGED
@@ -11,5 +11,4 @@ RUN bundle install --jobs 4 --deployment --quiet
11
11
 
12
12
  COPY . ./
13
13
 
14
-
15
14
  CMD docker/start.sh
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- netbox-client-ruby (0.2.3)
4
+ netbox-client-ruby (0.3.0)
5
5
  dry-configurable (~> 0.1)
6
6
  faraday (>= 0.11.0)
7
7
  faraday-detailed_logger (~> 2.1)
data/README.md CHANGED
@@ -155,6 +155,12 @@ Not all objects which the Netbox API exposes are currently implemented. Implemen
155
155
  * Tenancy:
156
156
  * Tenant
157
157
  * Tenant Groups
158
+ * Virtualization:
159
+ * Cluster Types
160
+ * Cluster Groups
161
+ * Clusters
162
+ * Virtual Machines
163
+ * Interfaces
158
164
 
159
165
  If you can't find the object you need, also check
160
166
  [the source code](https://github.com/ninech/netbox-client-ruby/tree/master/lib/netbox_client_ruby/api)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.3.0
@@ -2,6 +2,7 @@ require 'netbox_client_ruby/api/dcim'
2
2
  require 'netbox_client_ruby/api/ipam'
3
3
  require 'netbox_client_ruby/api/secrets'
4
4
  require 'netbox_client_ruby/api/tenancy'
5
+ require 'netbox_client_ruby/api/virtualization'
5
6
  require 'netbox_client_ruby/communication'
6
7
 
7
8
  module NetboxClientRuby
@@ -20,4 +21,8 @@ module NetboxClientRuby
20
21
  def self.tenancy
21
22
  NetboxClientRuby::Tenancy
22
23
  end
24
+
25
+ def self.virtualization
26
+ NetboxClientRuby::Virtualization
27
+ end
23
28
  end
@@ -21,7 +21,7 @@ module NetboxClientRuby
21
21
  vrf: proc { |raw_data| Vrf.new raw_data['id'] },
22
22
  tenant: proc { |raw_data| Tenancy::Tenant.new raw_data['id'] },
23
23
  vlan: proc { |raw_data| Vlan.new raw_data['id'] },
24
- status: proc { |raw_data| PrefixStatus.new raw_data['value'] },
24
+ status: proc { |raw_data| PrefixStatus.new raw_data },
25
25
  role: proc { |raw_data| Role.new raw_data['id'] },
26
26
  prefix: proc { |raw_data| IPAddress.parse raw_data }
27
27
  )
@@ -31,20 +31,9 @@ module NetboxClientRuby
31
31
  class PrefixStatus
32
32
  attr_reader :value, :label
33
33
 
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
34
+ def initialize(raw_data)
35
+ @value = raw_data['value']
36
+ @label = raw_data['label']
48
37
  end
49
38
  end
50
39
  end
@@ -16,7 +16,7 @@ module NetboxClientRuby
16
16
  object_fields(
17
17
  tenant: proc { |raw_data| Tenancy::Tenant.new raw_data['id'] },
18
18
  role: proc { |raw_data| Role.new raw_data['id'] },
19
- status: proc { |raw_data| VlanStatus.new raw_data['value'] },
19
+ status: proc { |raw_data| VlanStatus.new raw_data },
20
20
  group: proc { |raw_data| VlanGroup.new raw_data['id'] },
21
21
  site: proc { |raw_data| DCIM::Site.new raw_data['id'] },
22
22
  )
@@ -26,18 +26,9 @@ module NetboxClientRuby
26
26
  class VlanStatus
27
27
  attr_reader :value, :label
28
28
 
29
- def initialize(status_value)
30
- @value = status_value
31
- @label = case status_value
32
- when 1 then
33
- 'Active'.freeze
34
- when 2 then
35
- 'Reserved'.freeze
36
- when 3 then
37
- 'Deprecated'.freeze
38
- else
39
- 'UNDEFINED'.freeze
40
- end
29
+ def initialize(raw_data)
30
+ @value = raw_data['value']
31
+ @label = raw_data['label']
41
32
  end
42
33
  end
43
34
  end
@@ -0,0 +1,37 @@
1
+ require 'netbox_client_ruby/api/virtualization/cluster_group'
2
+ require 'netbox_client_ruby/api/virtualization/cluster_groups'
3
+ require 'netbox_client_ruby/api/virtualization/cluster_type'
4
+ require 'netbox_client_ruby/api/virtualization/cluster_types'
5
+ require 'netbox_client_ruby/api/virtualization/cluster'
6
+ require 'netbox_client_ruby/api/virtualization/clusters'
7
+ require 'netbox_client_ruby/api/virtualization/interface'
8
+ require 'netbox_client_ruby/api/virtualization/interfaces'
9
+ require 'netbox_client_ruby/api/virtualization/virtual_machine'
10
+ require 'netbox_client_ruby/api/virtualization/virtual_machines'
11
+ require 'netbox_client_ruby/communication'
12
+
13
+ module NetboxClientRuby
14
+ module Virtualization
15
+ {
16
+ cluster_groups: ClusterGroups,
17
+ cluster_types: ClusterTypes,
18
+ clusters: Clusters,
19
+ virtual_machines: VirtualMachines,
20
+ interfaces: Interfaces,
21
+ }.each_pair do |method_name, class_name|
22
+ define_method(method_name) { class_name.new }
23
+ module_function(method_name)
24
+ end
25
+
26
+ {
27
+ cluster_group: ClusterGroup,
28
+ cluster_type: ClusterType,
29
+ cluster: Cluster,
30
+ virtual_machine: VirtualMachine,
31
+ interface: Interface,
32
+ }.each_pair do |method_name, class_name|
33
+ define_method(method_name) { |id| class_name.new id }
34
+ module_function(method_name)
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,22 @@
1
+ require 'netbox_client_ruby/entity'
2
+ require 'netbox_client_ruby/api/virtualization/cluster_group'
3
+ require 'netbox_client_ruby/api/virtualization/cluster_type'
4
+ require 'netbox_client_ruby/api/dcim/site'
5
+
6
+ module NetboxClientRuby
7
+ module Virtualization
8
+ class Cluster
9
+ include Entity
10
+
11
+ id id: :id
12
+ deletable true
13
+ path 'virtualization/clusters/:id.json'
14
+ creation_path 'virtualization/clusters/'
15
+ object_fields(
16
+ group: proc { |raw_data| ClusterGroup.new raw_data['id'] },
17
+ site: proc { |raw_data| Site.new raw_data['id'] },
18
+ type: proc { |raw_data| ClusterType.new raw_data['id'] },
19
+ )
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,14 @@
1
+ require 'netbox_client_ruby/entity'
2
+
3
+ module NetboxClientRuby
4
+ module Virtualization
5
+ class ClusterGroup
6
+ include Entity
7
+
8
+ id id: :id
9
+ deletable true
10
+ path 'virtualization/cluster-groups/:id.json'
11
+ creation_path 'virtualization/cluster-groups/'
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,21 @@
1
+ require 'netbox_client_ruby/entities'
2
+ require 'netbox_client_ruby/api/virtualization/cluster_group'
3
+
4
+ module NetboxClientRuby
5
+ module Virtualization
6
+ class ClusterGroups
7
+ include Entities
8
+
9
+ path 'virtualization/cluster-groups.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
+ ClusterGroup.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 Virtualization
5
+ class ClusterType
6
+ include Entity
7
+
8
+ id id: :id
9
+ deletable true
10
+ path 'virtualization/cluster-types/:id.json'
11
+ creation_path 'virtualization/cluster-types/'
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,21 @@
1
+ require 'netbox_client_ruby/entities'
2
+ require 'netbox_client_ruby/api/virtualization/cluster_type'
3
+
4
+ module NetboxClientRuby
5
+ module Virtualization
6
+ class ClusterTypes
7
+ include Entities
8
+
9
+ path 'virtualization/cluster-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
+ ClusterType.new raw_entity['id']
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ require 'netbox_client_ruby/entities'
2
+ require 'netbox_client_ruby/api/virtualization/cluster'
3
+
4
+ module NetboxClientRuby
5
+ module Virtualization
6
+ class Clusters
7
+ include Entities
8
+
9
+ path 'virtualization/clusters.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
+ Cluster.new raw_entity['id']
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,16 @@
1
+ require 'netbox_client_ruby/entity'
2
+ require 'netbox_client_ruby/api/virtualization/virtual_machine'
3
+
4
+ module NetboxClientRuby
5
+ module Virtualization
6
+ class Interface
7
+ include Entity
8
+
9
+ id id: :id
10
+ deletable true
11
+ path 'virtualization/interfaces/:id.json'
12
+ creation_path 'virtualization/interfaces/'
13
+ object_fields virtual_machine: proc { |raw_data| VirtualMachine.new raw_data['id'] }
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,21 @@
1
+ require 'netbox_client_ruby/entities'
2
+ require 'netbox_client_ruby/api/virtualization/interface'
3
+
4
+ module NetboxClientRuby
5
+ module Virtualization
6
+ class Interfaces
7
+ include Entities
8
+
9
+ path 'virtualization/interfaces.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
+ Interface.new raw_entity['id']
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,38 @@
1
+ require 'netbox_client_ruby/entity'
2
+ require 'netbox_client_ruby/api/dcim/device_role'
3
+ require 'netbox_client_ruby/api/dcim/platform'
4
+ require 'netbox_client_ruby/api/ipam/ip_address'
5
+ require 'netbox_client_ruby/api/tenancy/tenant'
6
+ require 'netbox_client_ruby/api/virtualization/cluster'
7
+
8
+ module NetboxClientRuby
9
+ module Virtualization
10
+ class VirtualMachine
11
+ include Entity
12
+
13
+ id id: :id
14
+ deletable true
15
+ path 'virtualization/virtual-machines/:id.json'
16
+ creation_path 'virtualization/virtual-machines/'
17
+ object_fields(
18
+ cluster: proc { |raw_data| Cluster.new raw_data['id'] },
19
+ platform: proc { |raw_data| DCIM::Platform.new raw_data['id'] },
20
+ primary_ip: proc { |raw_data| IPAM::IpAddress.new raw_data['id'] },
21
+ primary_ip4: proc { |raw_data| IPAM::IpAddress.new raw_data['id'] },
22
+ primary_ip6: proc { |raw_data| IPAM::IpAddress.new raw_data['id'] },
23
+ role: proc { |raw_data| DCIM::DeviceRole.new raw_data['id'] },
24
+ status: proc { |raw_data| ClusterStatus.new raw_data },
25
+ tenant: proc { |raw_data| Tenancy::Tenant.new raw_data['id'] },
26
+ )
27
+ end
28
+
29
+ class ClusterStatus
30
+ attr_reader :value, :label
31
+
32
+ def initialize(raw_data)
33
+ @value = raw_data['value']
34
+ @label = raw_data['label']
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,21 @@
1
+ require 'netbox_client_ruby/entities'
2
+ require 'netbox_client_ruby/api/virtualization/virtual_machine'
3
+
4
+ module NetboxClientRuby
5
+ module Virtualization
6
+ class VirtualMachines
7
+ include Entities
8
+
9
+ path 'virtualization/virtual-machines.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
+ VirtualMachine.new raw_entity['id']
18
+ end
19
+ end
20
+ end
21
+ end
data/netbox.env CHANGED
@@ -1,7 +1,8 @@
1
1
  SUPERUSER_NAME=admin
2
2
  SUPERUSER_EMAIL=admin@example.com
3
3
  SUPERUSER_PASSWORD=admin
4
- ALLOWED_HOSTS=localhost
4
+ SUPERUSER_API_TOKEN=0123456789abcdef0123456789abcdef01234567
5
+ ALLOWED_HOSTS=localhost netboxclientruby.docker nginx.netboxclientruby.docker nginx
5
6
  DB_NAME=netbox
6
7
  DB_USER=netbox
7
8
  DB_PASSWORD=netbox
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netbox-client-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Mäder
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-29 00:00:00.000000000 Z
11
+ date: 2017-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-configurable
@@ -263,6 +263,17 @@ files:
263
263
  - lib/netbox_client_ruby/api/tenancy/tenant_group.rb
264
264
  - lib/netbox_client_ruby/api/tenancy/tenant_groups.rb
265
265
  - lib/netbox_client_ruby/api/tenancy/tenants.rb
266
+ - lib/netbox_client_ruby/api/virtualization.rb
267
+ - lib/netbox_client_ruby/api/virtualization/cluster.rb
268
+ - lib/netbox_client_ruby/api/virtualization/cluster_group.rb
269
+ - lib/netbox_client_ruby/api/virtualization/cluster_groups.rb
270
+ - lib/netbox_client_ruby/api/virtualization/cluster_type.rb
271
+ - lib/netbox_client_ruby/api/virtualization/cluster_types.rb
272
+ - lib/netbox_client_ruby/api/virtualization/clusters.rb
273
+ - lib/netbox_client_ruby/api/virtualization/interface.rb
274
+ - lib/netbox_client_ruby/api/virtualization/interfaces.rb
275
+ - lib/netbox_client_ruby/api/virtualization/virtual_machine.rb
276
+ - lib/netbox_client_ruby/api/virtualization/virtual_machines.rb
266
277
  - lib/netbox_client_ruby/communication.rb
267
278
  - lib/netbox_client_ruby/connection.rb
268
279
  - lib/netbox_client_ruby/entities.rb