netbox-client-ruby 0.0.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 +7 -0
- data/.gitignore +13 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/.travis.yml +8 -0
- data/Dockerfile +12 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +75 -0
- data/LICENSE.txt +21 -0
- data/README.md +138 -0
- data/Rakefile +6 -0
- data/VERSION +1 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/docker-compose.test.yml +5 -0
- data/docker-compose.yml +37 -0
- data/docker/start.sh +3 -0
- data/docker/start.test.sh +3 -0
- data/lib/netbox-client-ruby.rb +1 -0
- data/lib/netbox_client_ruby.rb +25 -0
- data/lib/netbox_client_ruby/api.rb +18 -0
- data/lib/netbox_client_ruby/api/dcim.rb +55 -0
- data/lib/netbox_client_ruby/api/dcim/device.rb +31 -0
- data/lib/netbox_client_ruby/api/dcim/device_role.rb +12 -0
- data/lib/netbox_client_ruby/api/dcim/device_roles.rb +19 -0
- data/lib/netbox_client_ruby/api/dcim/device_type.rb +26 -0
- data/lib/netbox_client_ruby/api/dcim/device_types.rb +19 -0
- data/lib/netbox_client_ruby/api/dcim/devices.rb +19 -0
- data/lib/netbox_client_ruby/api/dcim/interface.rb +14 -0
- data/lib/netbox_client_ruby/api/dcim/interfaces.rb +19 -0
- data/lib/netbox_client_ruby/api/dcim/manufacturer.rb +12 -0
- data/lib/netbox_client_ruby/api/dcim/manufacturers.rb +19 -0
- data/lib/netbox_client_ruby/api/dcim/platform.rb +12 -0
- data/lib/netbox_client_ruby/api/dcim/platforms.rb +19 -0
- data/lib/netbox_client_ruby/api/dcim/rack.rb +12 -0
- data/lib/netbox_client_ruby/api/dcim/racks.rb +19 -0
- data/lib/netbox_client_ruby/api/dcim/region.rb +13 -0
- data/lib/netbox_client_ruby/api/dcim/regions.rb +19 -0
- data/lib/netbox_client_ruby/api/dcim/site.rb +15 -0
- data/lib/netbox_client_ruby/api/dcim/sites.rb +19 -0
- data/lib/netbox_client_ruby/api/ipam.rb +53 -0
- data/lib/netbox_client_ruby/api/ipam/aggregate.rb +14 -0
- data/lib/netbox_client_ruby/api/ipam/aggregates.rb +19 -0
- data/lib/netbox_client_ruby/api/ipam/ip_address.rb +42 -0
- data/lib/netbox_client_ruby/api/ipam/ip_addresses.rb +19 -0
- data/lib/netbox_client_ruby/api/ipam/prefix.rb +47 -0
- data/lib/netbox_client_ruby/api/ipam/prefixes.rb +19 -0
- data/lib/netbox_client_ruby/api/ipam/rir.rb +12 -0
- data/lib/netbox_client_ruby/api/ipam/rirs.rb +19 -0
- data/lib/netbox_client_ruby/api/ipam/role.rb +12 -0
- data/lib/netbox_client_ruby/api/ipam/roles.rb +19 -0
- data/lib/netbox_client_ruby/api/ipam/vlan.rb +40 -0
- data/lib/netbox_client_ruby/api/ipam/vlan_group.rb +14 -0
- data/lib/netbox_client_ruby/api/ipam/vlan_groups.rb +19 -0
- data/lib/netbox_client_ruby/api/ipam/vlans.rb +19 -0
- data/lib/netbox_client_ruby/api/ipam/vrf.rb +14 -0
- data/lib/netbox_client_ruby/api/ipam/vrfs.rb +19 -0
- data/lib/netbox_client_ruby/api/tenancy.rb +25 -0
- data/lib/netbox_client_ruby/api/tenancy/tenant.rb +14 -0
- data/lib/netbox_client_ruby/api/tenancy/tenant_group.rb +12 -0
- data/lib/netbox_client_ruby/api/tenancy/tenant_groups.rb +19 -0
- data/lib/netbox_client_ruby/api/tenancy/tenants.rb +19 -0
- data/lib/netbox_client_ruby/communication.rb +74 -0
- data/lib/netbox_client_ruby/connection.rb +33 -0
- data/lib/netbox_client_ruby/entities.rb +200 -0
- data/lib/netbox_client_ruby/entity.rb +345 -0
- data/lib/netbox_client_ruby/error/client_error.rb +4 -0
- data/lib/netbox_client_ruby/error/local_error.rb +4 -0
- data/lib/netbox_client_ruby/error/remote_error.rb +4 -0
- data/netbox-client-ruby.gemspec +43 -0
- data/netbox.env +17 -0
- metadata +255 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 9f3cb350125a887f394b1d4154cf36a127b76716
|
|
4
|
+
data.tar.gz: 1c58dd91126cd77adb231b2cb77f647c5561d3af
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 5c045749cdcd91e09f8c3c9321155b2498cc28a8f1ed02644273b261f2e7091a699912509cb4b302e67042d1e824ee54e6173af2ebc478a5be6c69ac961d1855
|
|
7
|
+
data.tar.gz: f7b906ef672ea5645e07fe83c63d5242895466fc316ab8a088b968bb2487b8320ca4f69149df92cdca137fe21c4fc2dbf4bdf285e697c19bdae4e5caf6327d4b
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.3.4
|
data/.travis.yml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
sudo: false
|
|
2
|
+
language: ruby
|
|
3
|
+
before_install: gem install bundler
|
|
4
|
+
notifications:
|
|
5
|
+
email:
|
|
6
|
+
on_success: never
|
|
7
|
+
slack:
|
|
8
|
+
secure: kcRMRU/epqsBn3n0McTz0RdGSR07xhyz5g6jOfufA1bRlmLsIQtIaeqeO0VLtcQFUd5JJ1Z2iVz9YdvbA0RLeXwI0ZS96g9NWZn1TFBk6zMM8/CN4kZcWcPKO9INbBMziRlF7lb039CRrusE0ei1YJLojPGWnsKITcS88rSX+Uq0wPDaN6nEzQbDU2HV3TBl31W0LlYYpcmz6Ju9HGVdU1NrA0DRbeV78YmUkyJ4v6p8pgOaKKx+oZidUQmjvBIuBcko9VayXnncg4NQZWG4c6A5keLEFHzgOpSEgu+NnHsTz5ILT2AtysNxC8UJ5dYc7hR/qXsB9Z6ZJjRc+oGTXq6j58f153AW+2R4Mtx7Lp2zg+JeqYO34riu8vnihBk5rNsuHNcz3+ipmePjBt6emmJVpMxleWs9JFpbxXm3JnaSQZtUqALqvs6ZL9gxxokQcy4xbD8BJFvhYpc3b2464JPJhK7LNDNobTv4LdG6m6KSzTnN//zNuE5hSQhMbjo9mnYWN7V9n3asi1EsEpIYqpjRJnlNVDwTdW0jJ7wUSNPdEvSL7g1lDqgJTUuNBh/stpXh6nA8Um5ZxU3cAuuX7VwnDqIdaw81UnkGIlYWBFYMMR2p03y7EaTMZafKWKEcS6LJsv7yIjtfHJgf45LkIHceEj++8JEOKItvDYWHOL4=
|
data/Dockerfile
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
netbox-client-ruby (0.0.1)
|
|
5
|
+
dry-configurable (~> 0.1)
|
|
6
|
+
faraday (~> 0.12)
|
|
7
|
+
faraday-detailed_logger (~> 2.1)
|
|
8
|
+
faraday_middleware (~> 0.11.0)
|
|
9
|
+
|
|
10
|
+
GEM
|
|
11
|
+
remote: https://rubygems.org/
|
|
12
|
+
specs:
|
|
13
|
+
ast (2.3.0)
|
|
14
|
+
coderay (1.1.1)
|
|
15
|
+
concurrent-ruby (1.0.5)
|
|
16
|
+
diff-lcs (1.3)
|
|
17
|
+
dry-configurable (0.7.0)
|
|
18
|
+
concurrent-ruby (~> 1.0)
|
|
19
|
+
faraday (0.12.1)
|
|
20
|
+
multipart-post (>= 1.2, < 3)
|
|
21
|
+
faraday-detailed_logger (2.1.1)
|
|
22
|
+
faraday (~> 0.8)
|
|
23
|
+
faraday_middleware (0.11.0.1)
|
|
24
|
+
faraday (>= 0.7.4, < 1.0)
|
|
25
|
+
method_source (0.8.2)
|
|
26
|
+
multipart-post (2.0.0)
|
|
27
|
+
parser (2.4.0.0)
|
|
28
|
+
ast (~> 2.2)
|
|
29
|
+
powerpack (0.1.1)
|
|
30
|
+
pry (0.10.4)
|
|
31
|
+
coderay (~> 1.1.0)
|
|
32
|
+
method_source (~> 0.8.1)
|
|
33
|
+
slop (~> 3.4)
|
|
34
|
+
rainbow (2.2.2)
|
|
35
|
+
rake
|
|
36
|
+
rake (10.5.0)
|
|
37
|
+
rspec (3.6.0)
|
|
38
|
+
rspec-core (~> 3.6.0)
|
|
39
|
+
rspec-expectations (~> 3.6.0)
|
|
40
|
+
rspec-mocks (~> 3.6.0)
|
|
41
|
+
rspec-core (3.6.0)
|
|
42
|
+
rspec-support (~> 3.6.0)
|
|
43
|
+
rspec-expectations (3.6.0)
|
|
44
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
45
|
+
rspec-support (~> 3.6.0)
|
|
46
|
+
rspec-mocks (3.6.0)
|
|
47
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
48
|
+
rspec-support (~> 3.6.0)
|
|
49
|
+
rspec-support (3.6.0)
|
|
50
|
+
rubocop (0.48.1)
|
|
51
|
+
parser (>= 2.3.3.1, < 3.0)
|
|
52
|
+
powerpack (~> 0.1)
|
|
53
|
+
rainbow (>= 1.99.1, < 3.0)
|
|
54
|
+
ruby-progressbar (~> 1.7)
|
|
55
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
|
56
|
+
rubocop-rspec (1.15.1)
|
|
57
|
+
rubocop (>= 0.42.0)
|
|
58
|
+
ruby-progressbar (1.8.1)
|
|
59
|
+
slop (3.6.0)
|
|
60
|
+
unicode-display_width (1.2.1)
|
|
61
|
+
|
|
62
|
+
PLATFORMS
|
|
63
|
+
ruby
|
|
64
|
+
|
|
65
|
+
DEPENDENCIES
|
|
66
|
+
bundler (~> 1.14)
|
|
67
|
+
netbox-client-ruby!
|
|
68
|
+
pry (~> 0.10)
|
|
69
|
+
rake (~> 10.0)
|
|
70
|
+
rspec (~> 3.5)
|
|
71
|
+
rubocop (~> 0.48)
|
|
72
|
+
rubocop-rspec (~> 1.15)
|
|
73
|
+
|
|
74
|
+
BUNDLED WITH
|
|
75
|
+
1.14.6
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Nine Internet Solutions AG
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# NetboxClientRuby
|
|
2
|
+
|
|
3
|
+
[](https://travis-ci.org/ninech/netbox-client-ruby)
|
|
4
|
+
[](https://badge.fury.io/rb/netbox-client-ruby)
|
|
5
|
+
|
|
6
|
+
This is a gem to pragmatically access your [Netbox instance](https://github.com/digitalocean/netbox)
|
|
7
|
+
via it's API from Ruby. This gem is currently only compatible with Netbox v2.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Add this line to your application's Gemfile:
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
gem 'netbox-client-ruby'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
And then execute:
|
|
18
|
+
|
|
19
|
+
$ bundle
|
|
20
|
+
|
|
21
|
+
Or install it manually:
|
|
22
|
+
|
|
23
|
+
$ gem install netbox-client-ruby
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
### Configuration
|
|
28
|
+
|
|
29
|
+
Put this somewhere, where it runs, before any call to anything else of Cloudflair.
|
|
30
|
+
If you are using Rails, then this would probably be somewhere underneath /config.
|
|
31
|
+
|
|
32
|
+
```ruby
|
|
33
|
+
require 'netbox-client-ruby'
|
|
34
|
+
NetboxClientRuby.configure do |config|
|
|
35
|
+
config.netbox.auth.token = 'YOUR_API_TOKEN'
|
|
36
|
+
config.netbox.api_base_url = 'http://netbox.local/api/'
|
|
37
|
+
|
|
38
|
+
# these are optional:
|
|
39
|
+
config.netbox.pagination.default_limit = 50
|
|
40
|
+
config.faraday.adapter = Faraday.default_adapter
|
|
41
|
+
config.faraday.request_options = { open_timeout: 1, timeout: 5 }
|
|
42
|
+
config.faraday.logger = :logger # built-in options: :logger, :detailed_logger; default: nil
|
|
43
|
+
end
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Structure
|
|
47
|
+
|
|
48
|
+
The methods are aligned with the API as it is defined in Netbox.
|
|
49
|
+
You can explore the API endpoints in your browser by opening the API endpoint. Usually that's `http://YOUR_NETBOX/api/`.
|
|
50
|
+
|
|
51
|
+
So if the URL is `/api/dcim/sites.json`, then the corresponding Ruby code would be `NetboxClientRuby.dcim.sites`.
|
|
52
|
+
|
|
53
|
+
### Examples
|
|
54
|
+
|
|
55
|
+
```ruby
|
|
56
|
+
# configuration
|
|
57
|
+
NetboxClientRuby.configure do |c|
|
|
58
|
+
c.netbox.auth.token = '2e35594ec8710e9922d14365a1ea66f27ea69450'
|
|
59
|
+
c.netbox.api_base_url = 'http://netbox.local/api/'
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# get all sites
|
|
63
|
+
sites = NetboxClientRuby.dcim.sites
|
|
64
|
+
puts "There are #{sites.total} sites in your Netbox instance."
|
|
65
|
+
|
|
66
|
+
# get the first site of the result set
|
|
67
|
+
first_site = sites[0]
|
|
68
|
+
puts "The first site is called #{first_site.name}."
|
|
69
|
+
|
|
70
|
+
# filter devices by site
|
|
71
|
+
# Note that Netbox filters by *slug*
|
|
72
|
+
devices_of_site = NetboxClientRuby.dcim.devices.filter(site: first_site.slug)
|
|
73
|
+
puts "#{devices_of_site.total} devices belong to the site. #{devices_of_site}.length devices have been fetched."
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Available Objects
|
|
77
|
+
|
|
78
|
+
Not all objects which the Netbox API exposes are currently implemented. Implementing new objects
|
|
79
|
+
[is trivial](https://github.com/ninech/netbox-client-ruby/commit/e3cee19d21a8a6ce480d7c03d23d7c3fbc92417a), though.
|
|
80
|
+
|
|
81
|
+
* DCIM:
|
|
82
|
+
* Devices
|
|
83
|
+
* Device Roles
|
|
84
|
+
* Device Types
|
|
85
|
+
* Interfaces
|
|
86
|
+
* Manufacturers
|
|
87
|
+
* Platforms
|
|
88
|
+
* Racks
|
|
89
|
+
* Regions
|
|
90
|
+
* Sites
|
|
91
|
+
* IPAM:
|
|
92
|
+
* Aggregates
|
|
93
|
+
* IP Addresses
|
|
94
|
+
* Prefixes
|
|
95
|
+
* RIRs
|
|
96
|
+
* Roles
|
|
97
|
+
* VLANs
|
|
98
|
+
* VLAN Groups
|
|
99
|
+
* VRFs
|
|
100
|
+
* Tenancy:
|
|
101
|
+
* Tenant
|
|
102
|
+
* Tenant Groups
|
|
103
|
+
|
|
104
|
+
If you can't find the object you need, also check
|
|
105
|
+
[the source code](https://github.com/ninech/netbox-client-ruby/tree/master/lib/netbox_client_ruby/api)
|
|
106
|
+
if it was added in the meantime without the list above having been updated.
|
|
107
|
+
|
|
108
|
+
## Development
|
|
109
|
+
|
|
110
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests.
|
|
111
|
+
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
112
|
+
|
|
113
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
|
114
|
+
|
|
115
|
+
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`,
|
|
116
|
+
which will create a git tag for the version, push git commits and tags,
|
|
117
|
+
and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
118
|
+
|
|
119
|
+
## Contributing
|
|
120
|
+
|
|
121
|
+
Bug reports and pull requests are very welcome [on GitHub](https://github.com/ninech/netbox-client-ruby).
|
|
122
|
+
|
|
123
|
+
Before opening a PR, please
|
|
124
|
+
|
|
125
|
+
* extend the existing specs
|
|
126
|
+
* run rspec
|
|
127
|
+
* run rubocop and fix your warnings
|
|
128
|
+
* check if this README.md file needs adjustments
|
|
129
|
+
|
|
130
|
+
## License
|
|
131
|
+
|
|
132
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
133
|
+
|
|
134
|
+
## About
|
|
135
|
+
|
|
136
|
+
This gem is currently maintained and funded by [nine.ch](https://nine.ch).
|
|
137
|
+
|
|
138
|
+
[](https://nine.ch)
|
data/Rakefile
ADDED
data/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.0.1
|
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
require 'netbox-client-ruby'
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
require 'pry'
|
|
11
|
+
Pry.start
|
|
12
|
+
|
|
13
|
+
# require 'irb'
|
|
14
|
+
# IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/docker-compose.yml
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
version: '2'
|
|
2
|
+
services:
|
|
3
|
+
app:
|
|
4
|
+
build: .
|
|
5
|
+
depends_on:
|
|
6
|
+
- nginx
|
|
7
|
+
volumes:
|
|
8
|
+
- .:/app
|
|
9
|
+
nginx:
|
|
10
|
+
image: nginx:1.11-alpine
|
|
11
|
+
command: nginx -g 'daemon off;' -c /etc/netbox-nginx/nginx.conf
|
|
12
|
+
depends_on:
|
|
13
|
+
- netbox
|
|
14
|
+
volumes:
|
|
15
|
+
- netbox-nginx-config:/etc/netbox-nginx/
|
|
16
|
+
- netbox-static-files:/opt/netbox/netbox/static
|
|
17
|
+
ports:
|
|
18
|
+
- 80
|
|
19
|
+
netbox:
|
|
20
|
+
image: digitalocean/netbox:v2.0-beta2
|
|
21
|
+
depends_on:
|
|
22
|
+
- postgres
|
|
23
|
+
volumes:
|
|
24
|
+
- netbox-static-files:/opt/netbox/netbox/static
|
|
25
|
+
- netbox-nginx-config:/etc/netbox-nginx/
|
|
26
|
+
env_file: 'netbox.env'
|
|
27
|
+
postgres:
|
|
28
|
+
image: postgres:9.6-alpine
|
|
29
|
+
environment:
|
|
30
|
+
POSTGRES_USER: netbox
|
|
31
|
+
POSTGRES_PASSWORD: netbox
|
|
32
|
+
POSTGRES_DB: netbox
|
|
33
|
+
volumes:
|
|
34
|
+
netbox-static-files:
|
|
35
|
+
driver: local
|
|
36
|
+
netbox-nginx-config:
|
|
37
|
+
driver: local
|
data/docker/start.sh
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'netbox_client_ruby'
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'dry-configurable'
|
|
2
|
+
require 'netbox_client_ruby/api'
|
|
3
|
+
|
|
4
|
+
module NetboxClientRuby
|
|
5
|
+
extend Dry::Configurable
|
|
6
|
+
|
|
7
|
+
MAX_SIGNED_64BIT_INT = 9_223_372_036_854_775_807
|
|
8
|
+
|
|
9
|
+
setting :netbox do
|
|
10
|
+
setting :api_base_url
|
|
11
|
+
setting :auth do
|
|
12
|
+
setting :token
|
|
13
|
+
end
|
|
14
|
+
setting :pagination do
|
|
15
|
+
setting :default_limit, 50
|
|
16
|
+
setting :max_limit, MAX_SIGNED_64BIT_INT
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
setting :faraday do
|
|
21
|
+
setting :adapter, :net_http
|
|
22
|
+
setting :logger
|
|
23
|
+
setting :request_options, open_timeout: 1, timeout: 5
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'netbox_client_ruby/api/dcim'
|
|
2
|
+
require 'netbox_client_ruby/api/ipam'
|
|
3
|
+
require 'netbox_client_ruby/api/tenancy'
|
|
4
|
+
require 'netbox_client_ruby/communication'
|
|
5
|
+
|
|
6
|
+
module NetboxClientRuby
|
|
7
|
+
def self.dcim
|
|
8
|
+
@dcim ||= NetboxClientRuby::DCIM.new
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def self.tenancy
|
|
12
|
+
@tenancy ||= NetboxClientRuby::Tenancy.new
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.ipam
|
|
16
|
+
@ipam ||= NetboxClientRuby::IPAM.new
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
require 'netbox_client_ruby/api/dcim/device'
|
|
2
|
+
require 'netbox_client_ruby/api/dcim/devices'
|
|
3
|
+
require 'netbox_client_ruby/api/dcim/device_role'
|
|
4
|
+
require 'netbox_client_ruby/api/dcim/device_roles'
|
|
5
|
+
require 'netbox_client_ruby/api/dcim/device_type'
|
|
6
|
+
require 'netbox_client_ruby/api/dcim/device_types'
|
|
7
|
+
require 'netbox_client_ruby/api/dcim/interface'
|
|
8
|
+
require 'netbox_client_ruby/api/dcim/interfaces'
|
|
9
|
+
require 'netbox_client_ruby/api/dcim/manufacturer'
|
|
10
|
+
require 'netbox_client_ruby/api/dcim/manufacturers'
|
|
11
|
+
require 'netbox_client_ruby/api/dcim/platform'
|
|
12
|
+
require 'netbox_client_ruby/api/dcim/platforms'
|
|
13
|
+
require 'netbox_client_ruby/api/dcim/rack'
|
|
14
|
+
require 'netbox_client_ruby/api/dcim/racks'
|
|
15
|
+
require 'netbox_client_ruby/api/dcim/region'
|
|
16
|
+
require 'netbox_client_ruby/api/dcim/regions'
|
|
17
|
+
require 'netbox_client_ruby/api/dcim/site'
|
|
18
|
+
require 'netbox_client_ruby/api/dcim/sites'
|
|
19
|
+
require 'netbox_client_ruby/communication'
|
|
20
|
+
|
|
21
|
+
module NetboxClientRuby
|
|
22
|
+
class DCIM
|
|
23
|
+
{
|
|
24
|
+
devices: Devices,
|
|
25
|
+
device_roles: DeviceRoles,
|
|
26
|
+
device_types: DeviceTypes,
|
|
27
|
+
interfaces: Interfaces,
|
|
28
|
+
manufacturers: Manufacturers,
|
|
29
|
+
platforms: Platforms,
|
|
30
|
+
racks: Racks,
|
|
31
|
+
regions: Regions,
|
|
32
|
+
sites: Sites
|
|
33
|
+
}.each_pair do |method_name, class_name|
|
|
34
|
+
define_method(method_name) do
|
|
35
|
+
class_name.new
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
{
|
|
40
|
+
device: Device,
|
|
41
|
+
device_role: DeviceRole,
|
|
42
|
+
device_type: DeviceType,
|
|
43
|
+
interface: Interface,
|
|
44
|
+
manufacturer: Manufacturer,
|
|
45
|
+
platform: Platform,
|
|
46
|
+
rack: Rack,
|
|
47
|
+
region: Region,
|
|
48
|
+
site: Site
|
|
49
|
+
}.each_pair do |method_name, class_name|
|
|
50
|
+
define_method(method_name) do |id|
|
|
51
|
+
class_name.new id
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|