|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | 3 | require 'dry-configurable' |
4 | | -require 'netbox_client_ruby/error' |
5 | | -require 'netbox_client_ruby/api' |
| 4 | +require 'ipaddress' |
| 5 | +require 'openssl' |
| 6 | + |
| 7 | +require 'faraday' |
| 8 | +require 'faraday/detailed_logger' |
| 9 | + |
| 10 | +if Faraday::VERSION < '2' |
| 11 | + begin |
| 12 | + require 'faraday_middleware' |
| 13 | + rescue LoadError => e |
| 14 | + message = <<~MSG |
| 15 | + For the current version of Faraday (#{Faraday::VERSION}), "faraday_middleware" |
| 16 | + is a required peer dependency of "netbox-client-ruby". Please install |
| 17 | + "faraday_middleware" separately OR upgrade to Faraday 2, in which case, |
| 18 | + "faraday_middleware" is not needed to work with "netbox-client-ruby". |
| 19 | +
|
| 20 | + #{e.message} |
| 21 | + MSG |
| 22 | + raise NetboxClientRuby::Error, message |
| 23 | + end |
| 24 | +end |
| 25 | + |
| 26 | +require 'zeitwerk' |
| 27 | + |
| 28 | +# load zeitwerk |
| 29 | +Zeitwerk::Loader.for_gem.tap do |loader| |
| 30 | + loader.ignore("#{__dir__}/netbox-client-ruby.rb") |
| 31 | + loader.collapse("#{__dir__}/netbox_client_ruby/api") |
| 32 | + loader.inflector.inflect('dcim' => 'DCIM') |
| 33 | + loader.inflector.inflect('ipam' => 'IPAM') |
| 34 | + loader.inflector.inflect('rsa_key_pair' => 'RSAKeyPair') |
| 35 | + # loader.log! |
| 36 | + loader.setup |
| 37 | +end |
| 38 | + |
| 39 | +# load gem errors |
| 40 | +require_relative 'netbox_client_ruby/error' |
6 | 41 |
|
7 | 42 | module NetboxClientRuby |
8 | 43 | extend Dry::Configurable |
@@ -31,4 +66,32 @@ module NetboxClientRuby |
31 | 66 | setting :logger |
32 | 67 | setting :request_options, default: { open_timeout: 1, timeout: 5 } |
33 | 68 | end |
| 69 | + |
| 70 | + def self.circuits |
| 71 | + NetboxClientRuby::Circuits |
| 72 | + end |
| 73 | + |
| 74 | + def self.dcim |
| 75 | + NetboxClientRuby::DCIM |
| 76 | + end |
| 77 | + |
| 78 | + def self.extras |
| 79 | + NetboxClientRuby::Extras |
| 80 | + end |
| 81 | + |
| 82 | + def self.ipam |
| 83 | + NetboxClientRuby::IPAM |
| 84 | + end |
| 85 | + |
| 86 | + def self.secrets |
| 87 | + NetboxClientRuby::Secrets |
| 88 | + end |
| 89 | + |
| 90 | + def self.tenancy |
| 91 | + NetboxClientRuby::Tenancy |
| 92 | + end |
| 93 | + |
| 94 | + def self.virtualization |
| 95 | + NetboxClientRuby::Virtualization |
| 96 | + end |
34 | 97 | end |
0 commit comments