netbox-client-ruby 0.1.0 → 0.1.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/.dockerignore +17 -0
- data/Dockerfile +7 -3
- data/Gemfile.lock +5 -3
- data/README.md +26 -0
- data/VERSION +1 -1
- data/docker-compose.test.yml +12 -1
- data/docker-compose.yml +15 -1
- data/lib/netbox_client_ruby.rb +6 -0
- data/lib/netbox_client_ruby/api.rb +10 -5
- data/lib/netbox_client_ruby/api/secrets.rb +39 -0
- data/lib/netbox_client_ruby/api/secrets/rsa_key_pair.rb +48 -0
- data/lib/netbox_client_ruby/api/secrets/secret.rb +18 -0
- data/lib/netbox_client_ruby/api/secrets/secret_role.rb +16 -0
- data/lib/netbox_client_ruby/api/secrets/secret_roles.rb +21 -0
- data/lib/netbox_client_ruby/api/secrets/secrets.rb +21 -0
- data/lib/netbox_client_ruby/api/secrets/session_key.rb +114 -0
- data/lib/netbox_client_ruby/connection.rb +18 -8
- data/netbox-client-ruby.gemspec +3 -1
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b850829d19608cfc66a7952bee146baede04e39a
|
4
|
+
data.tar.gz: 4ace9252566509c6a674d136e3210f927a2d9e44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83da2f33336ec64d82a7dbd9fef0e6486a0f3f4912cfa9d6c5fbf07debf7b2b6bebc7fe9bc8aad0dcddd42c3666197b4e8f6651cbfcb412c228be8070ac53219
|
7
|
+
data.tar.gz: d46c1ed8e28580ffe57973f31dc789197359dd3a0140719455508a6699b69ca1d8147f316a2e85a5e6746526edba69b707bfe15f4e7d2be521db623c167007b3
|
data/.dockerignore
ADDED
data/Dockerfile
CHANGED
@@ -1,11 +1,15 @@
|
|
1
|
-
|
1
|
+
ARG RUBY_VERSION=2.3.4
|
2
|
+
FROM ruby:${RUBY_VERSION}-alpine
|
2
3
|
|
3
|
-
RUN apk add --no-cache git
|
4
|
+
RUN apk add --no-cache git openssl-dev build-base
|
4
5
|
|
5
6
|
RUN mkdir /app
|
6
7
|
WORKDIR /app
|
7
8
|
|
9
|
+
COPY Gemfile Gemfile.lock netbox-client-ruby.gemspec VERSION ./
|
10
|
+
RUN bundle install --jobs 4 --deployment --quiet
|
11
|
+
|
8
12
|
COPY . ./
|
9
|
-
|
13
|
+
|
10
14
|
|
11
15
|
CMD docker/start.sh
|
data/Gemfile.lock
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
netbox-client-ruby (0.
|
4
|
+
netbox-client-ruby (0.1.1)
|
5
5
|
dry-configurable (~> 0.1)
|
6
|
-
faraday (>= 0.11)
|
6
|
+
faraday (>= 0.11, <= 0.12.1)
|
7
7
|
faraday-detailed_logger (~> 2.1)
|
8
8
|
faraday_middleware (~> 0.11.0)
|
9
9
|
ipaddress (>= 0.8.3)
|
10
|
+
openssl (>= 2.0.5)
|
10
11
|
|
11
12
|
GEM
|
12
13
|
remote: https://rubygems.org/
|
@@ -26,6 +27,7 @@ GEM
|
|
26
27
|
ipaddress (0.8.3)
|
27
28
|
method_source (0.8.2)
|
28
29
|
multipart-post (2.0.0)
|
30
|
+
openssl (2.0.5)
|
29
31
|
parser (2.4.0.0)
|
30
32
|
ast (~> 2.2)
|
31
33
|
powerpack (0.1.1)
|
@@ -74,4 +76,4 @@ DEPENDENCIES
|
|
74
76
|
rubocop-rspec (~> 1.15)
|
75
77
|
|
76
78
|
BUNDLED WITH
|
77
|
-
1.
|
79
|
+
1.15.3
|
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
[](https://travis-ci.org/ninech/netbox-client-ruby)
|
4
4
|
[](https://badge.fury.io/rb/netbox-client-ruby)
|
5
|
+
[](https://codeclimate.com/github/ninech/netbox-client-ruby)
|
5
6
|
|
6
7
|
This is a gem to pragmatically access your [Netbox instance](https://github.com/digitalocean/netbox)
|
7
8
|
via it's API from Ruby. This gem is currently only compatible with Netbox v2.
|
@@ -36,6 +37,8 @@ NetboxClientRuby.configure do |config|
|
|
36
37
|
config.netbox.api_base_url = 'http://netbox.local/api/'
|
37
38
|
|
38
39
|
# these are optional:
|
40
|
+
config.netbox.auth.rsa_private_key.path = '~/.ssh/netbox_rsa'
|
41
|
+
config.netbox.auth.rsa_private_key.password = ''
|
39
42
|
config.netbox.pagination.default_limit = 50
|
40
43
|
config.faraday.adapter = Faraday.default_adapter
|
41
44
|
config.faraday.request_options = { open_timeout: 1, timeout: 5 }
|
@@ -57,6 +60,7 @@ So if the URL is `/api/dcim/sites.json`, then the corresponding Ruby code would
|
|
57
60
|
NetboxClientRuby.configure do |c|
|
58
61
|
c.netbox.auth.token = '2e35594ec8710e9922d14365a1ea66f27ea69450'
|
59
62
|
c.netbox.api_base_url = 'http://netbox.local/api/'
|
63
|
+
c.netbox.auth.rsa_private_key.path = '~/.ssh/netbox_rsa'
|
60
64
|
end
|
61
65
|
|
62
66
|
# get all sites
|
@@ -71,6 +75,23 @@ puts "The first site is called #{first_site.name}."
|
|
71
75
|
# Note that Netbox filters by *slug*
|
72
76
|
devices_of_site = NetboxClientRuby.dcim.devices.filter(site: first_site.slug)
|
73
77
|
puts "#{devices_of_site.total} devices belong to the site. #{devices_of_site}.length devices have been fetched."
|
78
|
+
|
79
|
+
# working with secrets
|
80
|
+
secrets = NetboxClientRuby.secrets.secrets
|
81
|
+
puts "#{secrets.total} secrets are in your Netbox."
|
82
|
+
secrets[0].plaintext # => nil, because you have not yet defined a session_key
|
83
|
+
NetboxClientRuby.secrets.get_session_key # now get a session_key
|
84
|
+
secrets = NetboxClientRuby.secrets.secrets # you must reload the data from the server
|
85
|
+
secrets[0].plaintext # => 'super secret password'
|
86
|
+
|
87
|
+
# optionally, you can persist the session_key:
|
88
|
+
session_key = NetboxClientRuby.secrets.get_session_key.session_key
|
89
|
+
FILE_NAME = File.expand_path('~/.netbox_session_key').freeze
|
90
|
+
File.write(FILE_NAME, session_key)
|
91
|
+
|
92
|
+
# later on, you can restore the persisted session_key:
|
93
|
+
persisted_session_key = File.read(FILE_NAME)
|
94
|
+
NetboxClientRuby.secrets.session_key = persisted_session_key
|
74
95
|
```
|
75
96
|
|
76
97
|
## Available Objects
|
@@ -97,6 +118,11 @@ Not all objects which the Netbox API exposes are currently implemented. Implemen
|
|
97
118
|
* VLANs
|
98
119
|
* VLAN Groups
|
99
120
|
* VRFs
|
121
|
+
* Secrets:
|
122
|
+
* Secrets
|
123
|
+
* Secret Roles
|
124
|
+
* get-session-key
|
125
|
+
* generate-rsa-key-pair
|
100
126
|
* Tenancy:
|
101
127
|
* Tenant
|
102
128
|
* Tenant Groups
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/docker-compose.test.yml
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
version: '2'
|
2
2
|
services:
|
3
3
|
app:
|
4
|
-
build:
|
4
|
+
build:
|
5
|
+
context: .
|
6
|
+
args:
|
7
|
+
RUBY_VERSION: 2.3.4
|
8
|
+
image: netbox-client-ruby:2.3.4
|
9
|
+
command: 'docker/start.test.sh'
|
10
|
+
app24:
|
11
|
+
build:
|
12
|
+
context: .
|
13
|
+
args:
|
14
|
+
RUBY_VERSION: 2.4.1
|
15
|
+
image: netbox-client-ruby:2.4.1
|
5
16
|
command: 'docker/start.test.sh'
|
data/docker-compose.yml
CHANGED
@@ -1,7 +1,21 @@
|
|
1
1
|
version: '2'
|
2
2
|
services:
|
3
3
|
app:
|
4
|
-
build:
|
4
|
+
build:
|
5
|
+
context: .
|
6
|
+
args:
|
7
|
+
RUBY_VERSION: 2.3.4
|
8
|
+
image: netbox-client-ruby:2.3.4
|
9
|
+
depends_on:
|
10
|
+
- nginx
|
11
|
+
volumes:
|
12
|
+
- .:/app
|
13
|
+
app24:
|
14
|
+
build:
|
15
|
+
context: .
|
16
|
+
args:
|
17
|
+
RUBY_VERSION: 2.4.1
|
18
|
+
image: netbox-client-ruby:2.4.1
|
5
19
|
depends_on:
|
6
20
|
- nginx
|
7
21
|
volumes:
|
data/lib/netbox_client_ruby.rb
CHANGED
@@ -10,6 +10,12 @@ module NetboxClientRuby
|
|
10
10
|
setting :api_base_url
|
11
11
|
setting :auth do
|
12
12
|
setting :token
|
13
|
+
setting :rsa_private_key do
|
14
|
+
# the default is intentionally not `~/.ssh/id_rsa`,
|
15
|
+
# to not accidentally leak someone's main rsa private key
|
16
|
+
setting :path, '~/.ssh/netbox_rsa'
|
17
|
+
setting :password
|
18
|
+
end
|
13
19
|
end
|
14
20
|
setting :pagination do
|
15
21
|
setting :default_limit, 50
|
@@ -1,18 +1,23 @@
|
|
1
1
|
require 'netbox_client_ruby/api/dcim'
|
2
2
|
require 'netbox_client_ruby/api/ipam'
|
3
|
+
require 'netbox_client_ruby/api/secrets'
|
3
4
|
require 'netbox_client_ruby/api/tenancy'
|
4
5
|
require 'netbox_client_ruby/communication'
|
5
6
|
|
6
7
|
module NetboxClientRuby
|
7
8
|
def self.dcim
|
8
|
-
|
9
|
+
NetboxClientRuby::DCIM
|
9
10
|
end
|
10
11
|
|
11
|
-
def self.
|
12
|
-
|
12
|
+
def self.ipam
|
13
|
+
NetboxClientRuby::IPAM
|
13
14
|
end
|
14
15
|
|
15
|
-
def self.
|
16
|
-
|
16
|
+
def self.secrets
|
17
|
+
NetboxClientRuby::Secrets
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.tenancy
|
21
|
+
NetboxClientRuby::Tenancy
|
17
22
|
end
|
18
23
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'netbox_client_ruby/api/secrets/rsa_key_pair'
|
2
|
+
require 'netbox_client_ruby/api/secrets/secret_roles'
|
3
|
+
require 'netbox_client_ruby/api/secrets/secrets'
|
4
|
+
require 'netbox_client_ruby/api/secrets/session_key'
|
5
|
+
require 'netbox_client_ruby/communication'
|
6
|
+
|
7
|
+
module NetboxClientRuby
|
8
|
+
module Secrets
|
9
|
+
{
|
10
|
+
secret_roles: SecretRoles,
|
11
|
+
secrets: Secrets,
|
12
|
+
generate_rsa_key_pair: RSAKeyPair,
|
13
|
+
get_session_key: SessionKey
|
14
|
+
}.each_pair do |method_name, class_name|
|
15
|
+
define_method(method_name) { class_name.new }
|
16
|
+
module_function(method_name)
|
17
|
+
end
|
18
|
+
|
19
|
+
{
|
20
|
+
secret_role: SecretRole,
|
21
|
+
secret: Secret
|
22
|
+
}.each_pair do |method_name, class_name|
|
23
|
+
define_method(method_name) { |id| class_name.new id }
|
24
|
+
module_function(method_name)
|
25
|
+
end
|
26
|
+
|
27
|
+
def session_key=(session_key)
|
28
|
+
@session_key = session_key
|
29
|
+
end
|
30
|
+
|
31
|
+
module_function(:session_key=)
|
32
|
+
|
33
|
+
def session_key
|
34
|
+
@session_key
|
35
|
+
end
|
36
|
+
|
37
|
+
module_function(:session_key)
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'netbox_client_ruby/entity'
|
2
|
+
require 'netbox_client_ruby/api/dcim/device'
|
3
|
+
require 'netbox_client_ruby/api/secrets/secret_role'
|
4
|
+
|
5
|
+
module NetboxClientRuby
|
6
|
+
module Secrets
|
7
|
+
class RSAKeyPair
|
8
|
+
include Communication
|
9
|
+
|
10
|
+
PATH = '/api/secrets/generate-rsa-key-pair/'.freeze
|
11
|
+
|
12
|
+
def public_key
|
13
|
+
get['public_key']
|
14
|
+
end
|
15
|
+
|
16
|
+
def private_key
|
17
|
+
get['private_key']
|
18
|
+
end
|
19
|
+
|
20
|
+
def reload
|
21
|
+
@response = nil
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def get
|
27
|
+
if authorization_token
|
28
|
+
@response ||= response connection.get(PATH)
|
29
|
+
else
|
30
|
+
raise LocalError,
|
31
|
+
"The authorization_token has not been configured, but it's required for get-session-key."
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def authorization_token
|
36
|
+
auth_config.token
|
37
|
+
end
|
38
|
+
|
39
|
+
def auth_config
|
40
|
+
netbox_config.auth
|
41
|
+
end
|
42
|
+
|
43
|
+
def netbox_config
|
44
|
+
NetboxClientRuby.config.netbox
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'netbox_client_ruby/entity'
|
2
|
+
require 'netbox_client_ruby/api/dcim/device'
|
3
|
+
require 'netbox_client_ruby/api/secrets/secret_role'
|
4
|
+
|
5
|
+
module NetboxClientRuby
|
6
|
+
module Secrets
|
7
|
+
class Secret
|
8
|
+
include Entity
|
9
|
+
|
10
|
+
id id: :id
|
11
|
+
deletable true
|
12
|
+
path 'secrets/secrets/:id.json'
|
13
|
+
creation_path 'secrets/secrets/'
|
14
|
+
object_fields device: proc { |raw_data| Device.new raw_data['id'] },
|
15
|
+
role: proc { |raw_data| SecretRole.new raw_data['id'] }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'netbox_client_ruby/entity'
|
2
|
+
require 'netbox_client_ruby/api/dcim/device'
|
3
|
+
require 'netbox_client_ruby/api/secrets/secret_role'
|
4
|
+
|
5
|
+
module NetboxClientRuby
|
6
|
+
module Secrets
|
7
|
+
class SecretRole
|
8
|
+
include Entity
|
9
|
+
|
10
|
+
id id: :id
|
11
|
+
deletable true
|
12
|
+
path 'secrets/secret-roles/:id.json'
|
13
|
+
creation_path 'secrets/secret-roles/'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'netbox_client_ruby/entities'
|
2
|
+
require 'netbox_client_ruby/api/secrets/secret_role'
|
3
|
+
|
4
|
+
module NetboxClientRuby
|
5
|
+
module Secrets
|
6
|
+
class SecretRoles
|
7
|
+
include Entities
|
8
|
+
|
9
|
+
path 'secrets/secret-roles.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
|
+
SecretRole.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/secrets/secret'
|
3
|
+
|
4
|
+
module NetboxClientRuby
|
5
|
+
module Secrets
|
6
|
+
class Secrets
|
7
|
+
include Entities
|
8
|
+
|
9
|
+
path 'secrets/secrets.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
|
+
Secret.new raw_entity['id']
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
require 'openssl/pkey'
|
2
|
+
require 'netbox_client_ruby/entity'
|
3
|
+
require 'netbox_client_ruby/api/dcim/device'
|
4
|
+
require 'netbox_client_ruby/api/secrets/secret_role'
|
5
|
+
|
6
|
+
module NetboxClientRuby
|
7
|
+
module Secrets
|
8
|
+
class SessionKey
|
9
|
+
include Communication
|
10
|
+
|
11
|
+
PATH = '/api/secrets/get-session-key/'.freeze
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
session_key
|
15
|
+
end
|
16
|
+
|
17
|
+
def session_key
|
18
|
+
NetboxClientRuby::Secrets.session_key ||= request['session_key']
|
19
|
+
end
|
20
|
+
|
21
|
+
def reload
|
22
|
+
NetboxClientRuby::Secrets.session_key = request['session_key']
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def request
|
28
|
+
if authorization_token
|
29
|
+
response(post)
|
30
|
+
else
|
31
|
+
raise LocalError,
|
32
|
+
"The authorization_token has not been configured, but it's required for get-session-key."
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def post
|
37
|
+
connection.post PATH, private_key: private_key
|
38
|
+
end
|
39
|
+
|
40
|
+
def connection
|
41
|
+
NetboxClientRuby::Connection.new(request_encoding: :url_encoded)
|
42
|
+
end
|
43
|
+
|
44
|
+
def authorization_token
|
45
|
+
auth_config.token
|
46
|
+
end
|
47
|
+
|
48
|
+
def private_key
|
49
|
+
key_file = open_private_key_file
|
50
|
+
encoded_private_key = read_private_key_file(key_file)
|
51
|
+
private_key = decode_private_key(encoded_private_key)
|
52
|
+
private_key.to_pem
|
53
|
+
end
|
54
|
+
|
55
|
+
def decode_private_key(encoded_private_key)
|
56
|
+
begin
|
57
|
+
private_key = OpenSSL::PKey::RSA.new encoded_private_key, rsa_private_key_password
|
58
|
+
|
59
|
+
return private_key if private_key.private?
|
60
|
+
rescue OpenSSL::PKey::RSAError
|
61
|
+
if rsa_private_key_password.empty?
|
62
|
+
raise LocalError,
|
63
|
+
"The private key at '#{rsa_private_key_path}' requires a password, but none was given, or the key data is corrupted. (The corresponding configuration is 'netbox.auth.rsa_private_key.password'.)"
|
64
|
+
else
|
65
|
+
raise LocalError,
|
66
|
+
"The password given for the private key at '#{rsa_private_key_path}' is not valid or the key data is corrupted. (The corresponding configuration is 'netbox.auth.rsa_private_key.password'.)"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
raise LocalError,
|
71
|
+
"The file at '#{rsa_private_key_path}' is not a private key, but a private key is required for get-session-key. (The corresponding configuration is 'netbox.auth.rsa_private_key.path'.)"
|
72
|
+
end
|
73
|
+
|
74
|
+
def rsa_private_key_password
|
75
|
+
pwd = rsa_private_key_config.password
|
76
|
+
# If nil is not converted to '', then OpenSSL will block and ask on console for the password.
|
77
|
+
# We really don't want that.
|
78
|
+
return '' if pwd.nil?
|
79
|
+
pwd
|
80
|
+
end
|
81
|
+
|
82
|
+
def read_private_key_file(key_file)
|
83
|
+
encoded_private_key = key_file.read
|
84
|
+
return encoded_private_key unless encoded_private_key.nil? || encoded_private_key.empty?
|
85
|
+
|
86
|
+
raise LocalError,
|
87
|
+
"The file at '#{rsa_private_key_path}' is empty, but a private key is required for get-session-key. (The corresponding configuration is 'netbox.auth.rsa_private_key.path'.)"
|
88
|
+
end
|
89
|
+
|
90
|
+
def open_private_key_file
|
91
|
+
return File.new rsa_private_key_path if File.exist? rsa_private_key_path
|
92
|
+
|
93
|
+
raise LocalError,
|
94
|
+
"No file exists at the given path '#{rsa_private_key_path}', but it's required for get-session-key. (The corresponding configuration is 'netbox.auth.rsa_private_key.path'.)"
|
95
|
+
end
|
96
|
+
|
97
|
+
def rsa_private_key_path
|
98
|
+
@rsa_private_key_path ||= File.expand_path(rsa_private_key_config.path)
|
99
|
+
end
|
100
|
+
|
101
|
+
def rsa_private_key_config
|
102
|
+
auth_config.rsa_private_key
|
103
|
+
end
|
104
|
+
|
105
|
+
def auth_config
|
106
|
+
netbox_config.auth
|
107
|
+
end
|
108
|
+
|
109
|
+
def netbox_config
|
110
|
+
NetboxClientRuby.config.netbox
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -5,24 +5,34 @@ require 'netbox_client_ruby/error/local_error'
|
|
5
5
|
|
6
6
|
module NetboxClientRuby
|
7
7
|
class Connection
|
8
|
-
|
9
|
-
|
8
|
+
DEFAULT_OPTIONS = {
|
9
|
+
request_encoding: :json
|
10
|
+
}.freeze
|
11
|
+
|
12
|
+
def self.new(options = {})
|
13
|
+
build_faraday(DEFAULT_OPTIONS.merge(options))
|
10
14
|
end
|
11
15
|
|
12
16
|
def self.headers
|
13
17
|
headers = {}
|
14
|
-
|
18
|
+
auth_token = auth_config.token
|
19
|
+
headers['Authorization'] = "Token #{auth_token}".freeze if auth_token
|
20
|
+
headers['X-Session-Key'] = NetboxClientRuby::Secrets.session_key if NetboxClientRuby::Secrets.session_key
|
21
|
+
headers
|
22
|
+
end
|
15
23
|
|
16
|
-
|
24
|
+
def self.auth_config
|
25
|
+
netbox_config.auth
|
26
|
+
end
|
17
27
|
|
18
|
-
|
19
|
-
|
28
|
+
def self.netbox_config
|
29
|
+
NetboxClientRuby.config.netbox
|
20
30
|
end
|
21
31
|
|
22
|
-
private_class_method def self.build_faraday
|
32
|
+
private_class_method def self.build_faraday(request_encoding: :json)
|
23
33
|
config = NetboxClientRuby.config
|
24
34
|
Faraday.new(url: config.netbox.api_base_url, headers: headers) do |faraday|
|
25
|
-
faraday.request
|
35
|
+
faraday.request request_encoding
|
26
36
|
faraday.response config.faraday.logger if config.faraday.logger
|
27
37
|
faraday.response :json, content_type: /\bjson$/
|
28
38
|
faraday.adapter config.faraday.adapter || Faraday.default_adapter
|
data/netbox-client-ruby.gemspec
CHANGED
@@ -30,10 +30,12 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.require_paths = ['lib']
|
31
31
|
|
32
32
|
spec.add_runtime_dependency 'dry-configurable', '~> 0.1'
|
33
|
-
|
33
|
+
# see https://github.com/lostisland/faraday/issues/717
|
34
|
+
spec.add_runtime_dependency 'faraday', '>= 0.11', '<= 0.12.1'
|
34
35
|
spec.add_runtime_dependency 'faraday_middleware', '~> 0.11.0'
|
35
36
|
spec.add_runtime_dependency 'faraday-detailed_logger', '~> 2.1'
|
36
37
|
spec.add_runtime_dependency 'ipaddress', '>= 0.8.3'
|
38
|
+
spec.add_runtime_dependency 'openssl', '>= 2.0.5'
|
37
39
|
|
38
40
|
spec.add_development_dependency 'bundler', '~> 1.14'
|
39
41
|
spec.add_development_dependency 'rake', '~> 10.0'
|
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.1.
|
4
|
+
version: 0.1.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: 2017-08-
|
11
|
+
date: 2017-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-configurable
|
@@ -31,6 +31,9 @@ dependencies:
|
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0.11'
|
34
|
+
- - "<="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 0.12.1
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -38,6 +41,9 @@ dependencies:
|
|
38
41
|
- - ">="
|
39
42
|
- !ruby/object:Gem::Version
|
40
43
|
version: '0.11'
|
44
|
+
- - "<="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.12.1
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: faraday_middleware
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +86,20 @@ dependencies:
|
|
80
86
|
- - ">="
|
81
87
|
- !ruby/object:Gem::Version
|
82
88
|
version: 0.8.3
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: openssl
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 2.0.5
|
96
|
+
type: :runtime
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 2.0.5
|
83
103
|
- !ruby/object:Gem::Dependency
|
84
104
|
name: bundler
|
85
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -171,6 +191,7 @@ executables: []
|
|
171
191
|
extensions: []
|
172
192
|
extra_rdoc_files: []
|
173
193
|
files:
|
194
|
+
- ".dockerignore"
|
174
195
|
- ".gitignore"
|
175
196
|
- ".rspec"
|
176
197
|
- ".ruby-version"
|
@@ -230,6 +251,13 @@ files:
|
|
230
251
|
- lib/netbox_client_ruby/api/ipam/vlans.rb
|
231
252
|
- lib/netbox_client_ruby/api/ipam/vrf.rb
|
232
253
|
- lib/netbox_client_ruby/api/ipam/vrfs.rb
|
254
|
+
- lib/netbox_client_ruby/api/secrets.rb
|
255
|
+
- lib/netbox_client_ruby/api/secrets/rsa_key_pair.rb
|
256
|
+
- lib/netbox_client_ruby/api/secrets/secret.rb
|
257
|
+
- lib/netbox_client_ruby/api/secrets/secret_role.rb
|
258
|
+
- lib/netbox_client_ruby/api/secrets/secret_roles.rb
|
259
|
+
- lib/netbox_client_ruby/api/secrets/secrets.rb
|
260
|
+
- lib/netbox_client_ruby/api/secrets/session_key.rb
|
233
261
|
- lib/netbox_client_ruby/api/tenancy.rb
|
234
262
|
- lib/netbox_client_ruby/api/tenancy/tenant.rb
|
235
263
|
- lib/netbox_client_ruby/api/tenancy/tenant_group.rb
|