netbox-client-ruby 0.9.0 → 0.10.1
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/.github/workflows/rspec.yml +26 -7
- data/.gitignore +0 -1
- data/Gemfile +3 -0
- data/Gemfile.lock +117 -0
- data/README.md +6 -0
- data/bin/setup +3 -1
- data/gemfiles/faraday0.gemfile +6 -0
- data/gemfiles/faraday0.gemfile.lock +94 -0
- data/gemfiles/faraday1.gemfile +6 -0
- data/gemfiles/faraday1.gemfile.lock +93 -0
- data/gemfiles/faraday2.gemfile +6 -0
- data/gemfiles/faraday2.gemfile.lock +101 -0
- data/lib/netbox_client_ruby/api/circuits/circuit_terminations.rb +1 -1
- data/lib/netbox_client_ruby/api/circuits/circuit_types.rb +1 -1
- data/lib/netbox_client_ruby/api/circuits/circuits.rb +1 -1
- data/lib/netbox_client_ruby/api/circuits/providers.rb +1 -1
- data/lib/netbox_client_ruby/api/dcim/console_connections.rb +1 -1
- data/lib/netbox_client_ruby/api/dcim/console_ports.rb +1 -1
- data/lib/netbox_client_ruby/api/dcim/console_server_ports.rb +1 -1
- data/lib/netbox_client_ruby/api/dcim/device_roles.rb +1 -1
- data/lib/netbox_client_ruby/api/dcim/device_types.rb +1 -1
- data/lib/netbox_client_ruby/api/dcim/devices.rb +1 -1
- data/lib/netbox_client_ruby/api/dcim/interface_connections.rb +1 -1
- data/lib/netbox_client_ruby/api/dcim/interfaces.rb +1 -1
- data/lib/netbox_client_ruby/api/dcim/inventory_items.rb +1 -1
- data/lib/netbox_client_ruby/api/dcim/manufacturers.rb +1 -1
- data/lib/netbox_client_ruby/api/dcim/platforms.rb +1 -1
- data/lib/netbox_client_ruby/api/dcim/power_connections.rb +1 -1
- data/lib/netbox_client_ruby/api/dcim/power_outlets.rb +1 -1
- data/lib/netbox_client_ruby/api/dcim/power_ports.rb +1 -1
- data/lib/netbox_client_ruby/api/dcim/rack_groups.rb +1 -1
- data/lib/netbox_client_ruby/api/dcim/rack_reservations.rb +1 -1
- data/lib/netbox_client_ruby/api/dcim/rack_roles.rb +1 -1
- data/lib/netbox_client_ruby/api/dcim/racks.rb +1 -1
- data/lib/netbox_client_ruby/api/dcim/regions.rb +1 -1
- data/lib/netbox_client_ruby/api/dcim/sites.rb +1 -1
- data/lib/netbox_client_ruby/api/dcim/virtual_chassis_list.rb +1 -1
- data/lib/netbox_client_ruby/api/extras/config_contexts.rb +1 -1
- data/lib/netbox_client_ruby/api/extras/journal_entries.rb +1 -1
- data/lib/netbox_client_ruby/api/extras/tags.rb +1 -1
- data/lib/netbox_client_ruby/api/ipam/aggregates.rb +1 -1
- data/lib/netbox_client_ruby/api/ipam/ip_address.rb +1 -1
- data/lib/netbox_client_ruby/api/ipam/ip_addresses.rb +1 -1
- data/lib/netbox_client_ruby/api/ipam/ip_ranges.rb +1 -1
- data/lib/netbox_client_ruby/api/ipam/prefixes.rb +1 -1
- data/lib/netbox_client_ruby/api/ipam/rirs.rb +1 -1
- data/lib/netbox_client_ruby/api/ipam/roles.rb +1 -1
- data/lib/netbox_client_ruby/api/ipam/services.rb +1 -1
- data/lib/netbox_client_ruby/api/ipam/vlan_groups.rb +1 -1
- data/lib/netbox_client_ruby/api/ipam/vlans.rb +1 -1
- data/lib/netbox_client_ruby/api/ipam/vrfs.rb +1 -1
- data/lib/netbox_client_ruby/api/secrets/secret_roles.rb +1 -1
- data/lib/netbox_client_ruby/api/secrets/secrets.rb +1 -1
- data/lib/netbox_client_ruby/api/tenancy/tenant_groups.rb +1 -1
- data/lib/netbox_client_ruby/api/tenancy/tenants.rb +1 -1
- data/lib/netbox_client_ruby/api/virtualization/cluster_groups.rb +1 -1
- data/lib/netbox_client_ruby/api/virtualization/cluster_types.rb +1 -1
- data/lib/netbox_client_ruby/api/virtualization/clusters.rb +1 -1
- data/lib/netbox_client_ruby/api/virtualization/interfaces.rb +1 -1
- data/lib/netbox_client_ruby/api/virtualization/virtual_machines.rb +1 -1
- data/lib/netbox_client_ruby/communication.rb +3 -4
- data/lib/netbox_client_ruby/connection.rb +17 -2
- data/lib/netbox_client_ruby/entities.rb +1 -1
- data/lib/netbox_client_ruby/entity.rb +8 -8
- data/lib/netbox_client_ruby/error.rb +6 -0
- data/lib/netbox_client_ruby.rb +1 -0
- data/netbox-client-ruby.gemspec +2 -3
- metadata +13 -29
- data/VERSION +0 -1
- data/lib/netbox_client_ruby/error/client_error.rb +0 -4
- data/lib/netbox_client_ruby/error/local_error.rb +0 -4
- data/lib/netbox_client_ruby/error/remote_error.rb +0 -4
|
@@ -38,7 +38,7 @@ module NetboxClientRuby
|
|
|
38
38
|
|
|
39
39
|
return nil unless interface_data
|
|
40
40
|
|
|
41
|
-
if interface_data.key?
|
|
41
|
+
if interface_data.key?('virtual_machine')
|
|
42
42
|
Virtualization::Interface.new interface_data['id']
|
|
43
43
|
else
|
|
44
44
|
DCIM::Interface.new interface_data['id']
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
require 'netbox_client_ruby/error
|
|
2
|
-
require 'netbox_client_ruby/error/remote_error'
|
|
1
|
+
require 'netbox_client_ruby/error'
|
|
3
2
|
require 'netbox_client_ruby/connection'
|
|
4
3
|
|
|
5
4
|
module NetboxClientRuby
|
|
@@ -24,8 +23,8 @@ module NetboxClientRuby
|
|
|
24
23
|
variable_name = sanitize_variable_name(k)
|
|
25
24
|
variable_name = "_#{variable_name}" if objectified_instance.methods.map(&:to_s).include?(variable_name)
|
|
26
25
|
|
|
27
|
-
objectified_instance.instance_variable_set("@#{variable_name}", v)
|
|
28
|
-
objectified_class.send(:define_method, variable_name, proc { instance_variable_get("@#{variable_name}") })
|
|
26
|
+
objectified_instance.instance_variable_set(:"@#{variable_name}", v)
|
|
27
|
+
objectified_class.send(:define_method, variable_name, proc { instance_variable_get(:"@#{variable_name}") })
|
|
29
28
|
end
|
|
30
29
|
objectified_instance
|
|
31
30
|
end
|
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
require 'faraday'
|
|
2
|
-
require 'faraday_middleware'
|
|
3
2
|
require 'faraday/detailed_logger'
|
|
4
|
-
require 'netbox_client_ruby/error
|
|
3
|
+
require 'netbox_client_ruby/error'
|
|
4
|
+
|
|
5
|
+
if Faraday::VERSION < '2'
|
|
6
|
+
begin
|
|
7
|
+
require 'faraday_middleware'
|
|
8
|
+
rescue LoadError => e
|
|
9
|
+
message = <<~MSG
|
|
10
|
+
For the current version of Faraday (#{Faraday::VERSION}), "faraday_middleware"
|
|
11
|
+
is a required peer dependency of "netbox-client-ruby". Please install
|
|
12
|
+
"faraday_middleware" separately OR upgrade to Faraday 2, in which case,
|
|
13
|
+
"faraday_middleware" is not needed to work with "netbox-client-ruby".
|
|
14
|
+
|
|
15
|
+
#{e.message}
|
|
16
|
+
MSG
|
|
17
|
+
raise NetboxClientRuby::Error, message
|
|
18
|
+
end
|
|
19
|
+
end
|
|
5
20
|
|
|
6
21
|
module NetboxClientRuby
|
|
7
22
|
class Connection
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require 'netbox_client_ruby/communication'
|
|
2
|
-
require 'netbox_client_ruby/error
|
|
2
|
+
require 'netbox_client_ruby/error'
|
|
3
3
|
|
|
4
4
|
module NetboxClientRuby
|
|
5
5
|
module Entity
|
|
@@ -38,7 +38,7 @@ module NetboxClientRuby
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
@id_fields.keys.each do |field|
|
|
41
|
-
define_method(field) { instance_variable_get "@#{field}" }
|
|
41
|
+
define_method(field) { instance_variable_get :"@#{field}" }
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
@id_fields
|
|
@@ -108,13 +108,13 @@ module NetboxClientRuby
|
|
|
108
108
|
return self if given_values.nil?
|
|
109
109
|
|
|
110
110
|
if id_fields.count == 1 && !given_values.is_a?(Hash)
|
|
111
|
-
instance_variable_set("@#{id_fields.keys.first}", given_values)
|
|
111
|
+
instance_variable_set(:"@#{id_fields.keys.first}", given_values)
|
|
112
112
|
return self
|
|
113
113
|
end
|
|
114
114
|
|
|
115
115
|
given_values.each do |field, value|
|
|
116
116
|
if id_fields.key? field.to_s
|
|
117
|
-
instance_variable_set "@#{field}", value
|
|
117
|
+
instance_variable_set :"@#{field}", value
|
|
118
118
|
else
|
|
119
119
|
# via method_missing, because it checks for readonly fields, etc.
|
|
120
120
|
method_missing("#{field}=", value)
|
|
@@ -164,7 +164,7 @@ module NetboxClientRuby
|
|
|
164
164
|
s_attribute = attribute.to_s
|
|
165
165
|
next if readonly_fields.include? s_attribute
|
|
166
166
|
|
|
167
|
-
sym_attr_writer = "#{attribute}="
|
|
167
|
+
sym_attr_writer = :"#{attribute}="
|
|
168
168
|
if methods.include?(sym_attr_writer)
|
|
169
169
|
public_send(sym_attr_writer, values)
|
|
170
170
|
else
|
|
@@ -197,7 +197,7 @@ module NetboxClientRuby
|
|
|
197
197
|
|
|
198
198
|
if name.end_with?('=')
|
|
199
199
|
is_readonly_field = readonly_fields.include?(name[0..-2])
|
|
200
|
-
is_instance_variable = instance_variables.include?("@#{name[0..-2]}"
|
|
200
|
+
is_instance_variable = instance_variables.include?(:"@#{name[0..-2]}")
|
|
201
201
|
not_this_classes_business = is_readonly_field || is_instance_variable
|
|
202
202
|
|
|
203
203
|
return super if not_this_classes_business
|
|
@@ -328,12 +328,12 @@ module NetboxClientRuby
|
|
|
328
328
|
raise LocalError, "Can't find the id field '#{id_field}' in the received data."
|
|
329
329
|
end
|
|
330
330
|
|
|
331
|
-
instance_variable_set("@#{id_attr}", data[id_field])
|
|
331
|
+
instance_variable_set(:"@#{id_attr}", data[id_field])
|
|
332
332
|
end
|
|
333
333
|
end
|
|
334
334
|
|
|
335
335
|
def ids_set?
|
|
336
|
-
id_fields.map { |id_attr, _| instance_variable_get("@#{id_attr}") }.all?
|
|
336
|
+
id_fields.map { |id_attr, _| instance_variable_get(:"@#{id_attr}") }.all?
|
|
337
337
|
end
|
|
338
338
|
end
|
|
339
339
|
end
|
data/lib/netbox_client_ruby.rb
CHANGED
data/netbox-client-ruby.gemspec
CHANGED
|
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
|
3
3
|
|
|
4
4
|
Gem::Specification.new do |spec|
|
|
5
5
|
spec.name = 'netbox-client-ruby'
|
|
6
|
-
spec.version =
|
|
6
|
+
spec.version = `git describe --tags --match="v[0-9]*" --abbrev=0`.strip.delete_prefix("v")
|
|
7
7
|
|
|
8
8
|
spec.summary = 'A read/write client for Netbox v2.'
|
|
9
9
|
spec.homepage = 'https://github.com/ninech/netbox-client-ruby'
|
|
@@ -26,9 +26,8 @@ Gem::Specification.new do |spec|
|
|
|
26
26
|
spec.required_ruby_version = '>= 2.7.0'
|
|
27
27
|
|
|
28
28
|
spec.add_runtime_dependency 'dry-configurable', '~> 1'
|
|
29
|
-
spec.add_runtime_dependency 'faraday', '>= 0.11.0', '<
|
|
29
|
+
spec.add_runtime_dependency 'faraday', '>= 0.11.0', '< 3'
|
|
30
30
|
spec.add_runtime_dependency 'faraday-detailed_logger', '~> 2.1'
|
|
31
|
-
spec.add_runtime_dependency 'faraday_middleware', '>= 0.11', '< 2'
|
|
32
31
|
spec.add_runtime_dependency 'ipaddress', '~> 0.8', '>= 0.8.3'
|
|
33
32
|
spec.add_runtime_dependency 'openssl', '>= 2.0.5'
|
|
34
33
|
|
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.
|
|
4
|
+
version: 0.10.1
|
|
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:
|
|
11
|
+
date: 2024-10-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: dry-configurable
|
|
@@ -33,7 +33,7 @@ dependencies:
|
|
|
33
33
|
version: 0.11.0
|
|
34
34
|
- - "<"
|
|
35
35
|
- !ruby/object:Gem::Version
|
|
36
|
-
version: '
|
|
36
|
+
version: '3'
|
|
37
37
|
type: :runtime
|
|
38
38
|
prerelease: false
|
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -43,7 +43,7 @@ dependencies:
|
|
|
43
43
|
version: 0.11.0
|
|
44
44
|
- - "<"
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: '
|
|
46
|
+
version: '3'
|
|
47
47
|
- !ruby/object:Gem::Dependency
|
|
48
48
|
name: faraday-detailed_logger
|
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -58,26 +58,6 @@ dependencies:
|
|
|
58
58
|
- - "~>"
|
|
59
59
|
- !ruby/object:Gem::Version
|
|
60
60
|
version: '2.1'
|
|
61
|
-
- !ruby/object:Gem::Dependency
|
|
62
|
-
name: faraday_middleware
|
|
63
|
-
requirement: !ruby/object:Gem::Requirement
|
|
64
|
-
requirements:
|
|
65
|
-
- - ">="
|
|
66
|
-
- !ruby/object:Gem::Version
|
|
67
|
-
version: '0.11'
|
|
68
|
-
- - "<"
|
|
69
|
-
- !ruby/object:Gem::Version
|
|
70
|
-
version: '2'
|
|
71
|
-
type: :runtime
|
|
72
|
-
prerelease: false
|
|
73
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
74
|
-
requirements:
|
|
75
|
-
- - ">="
|
|
76
|
-
- !ruby/object:Gem::Version
|
|
77
|
-
version: '0.11'
|
|
78
|
-
- - "<"
|
|
79
|
-
- !ruby/object:Gem::Version
|
|
80
|
-
version: '2'
|
|
81
61
|
- !ruby/object:Gem::Dependency
|
|
82
62
|
name: ipaddress
|
|
83
63
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -211,10 +191,10 @@ files:
|
|
|
211
191
|
- ".rspec"
|
|
212
192
|
- Dockerfile
|
|
213
193
|
- Gemfile
|
|
194
|
+
- Gemfile.lock
|
|
214
195
|
- LICENSE.txt
|
|
215
196
|
- README.md
|
|
216
197
|
- Rakefile
|
|
217
|
-
- VERSION
|
|
218
198
|
- bin/console
|
|
219
199
|
- bin/setup
|
|
220
200
|
- docker-compose.test.yml
|
|
@@ -222,6 +202,12 @@ files:
|
|
|
222
202
|
- docker/start.sh
|
|
223
203
|
- docker/start.test.sh
|
|
224
204
|
- dump.sql
|
|
205
|
+
- gemfiles/faraday0.gemfile
|
|
206
|
+
- gemfiles/faraday0.gemfile.lock
|
|
207
|
+
- gemfiles/faraday1.gemfile
|
|
208
|
+
- gemfiles/faraday1.gemfile.lock
|
|
209
|
+
- gemfiles/faraday2.gemfile
|
|
210
|
+
- gemfiles/faraday2.gemfile.lock
|
|
225
211
|
- lib/netbox-client-ruby.rb
|
|
226
212
|
- lib/netbox_client_ruby.rb
|
|
227
213
|
- lib/netbox_client_ruby/api.rb
|
|
@@ -332,9 +318,7 @@ files:
|
|
|
332
318
|
- lib/netbox_client_ruby/connection.rb
|
|
333
319
|
- lib/netbox_client_ruby/entities.rb
|
|
334
320
|
- lib/netbox_client_ruby/entity.rb
|
|
335
|
-
- lib/netbox_client_ruby/error
|
|
336
|
-
- lib/netbox_client_ruby/error/local_error.rb
|
|
337
|
-
- lib/netbox_client_ruby/error/remote_error.rb
|
|
321
|
+
- lib/netbox_client_ruby/error.rb
|
|
338
322
|
- netbox-client-ruby.gemspec
|
|
339
323
|
- netbox-client-ruby_rsa
|
|
340
324
|
- netbox-client-ruby_rsa.pub
|
|
@@ -359,7 +343,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
359
343
|
- !ruby/object:Gem::Version
|
|
360
344
|
version: '0'
|
|
361
345
|
requirements: []
|
|
362
|
-
rubygems_version: 3.4.
|
|
346
|
+
rubygems_version: 3.4.19
|
|
363
347
|
signing_key:
|
|
364
348
|
specification_version: 4
|
|
365
349
|
summary: A read/write client for Netbox v2.
|
data/VERSION
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0.9.0
|