train-rest 0.3.0 → 0.3.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/lib/train-rest/auth_handler/anonymous.rb +1 -1
- data/lib/train-rest/auth_handler/basic.rb +6 -3
- data/lib/train-rest/auth_handler/redfish.rb +1 -1
- data/lib/train-rest/connection.rb +14 -11
- data/lib/train-rest/transport.rb +2 -2
- data/lib/train-rest/version.rb +1 -1
- data/train-rest.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd4a52ed234249cf9ae6c2de31b9883061ca31a9d34eb155a5f11e09b461b239
|
4
|
+
data.tar.gz: af4665c3c3637eb4c961f5419af4f145c85a2a60ff4125cfa9bc49800e21dae1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db180b1416450c343f28be8d2223d5610b4a7ec75216d43f4343842250a47149bad30f5f2436e336bff1d3504e5cb817916ef44adf95ae9c65663f8cc56af0ef
|
7
|
+
data.tar.gz: 586b34568e078702c3ecabf1f40c6a61bdd4557cf95b953389813563f9d023d5239574d621870f319092e7d33bd436bfc8674a8ca8dc4635d52ef8564f125814
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
require "base64" unless defined?(Base64)
|
2
|
+
|
3
|
+
require_relative "../auth_handler"
|
2
4
|
|
3
5
|
module TrainPlugins
|
4
6
|
module Rest
|
@@ -11,8 +13,9 @@ module TrainPlugins
|
|
11
13
|
|
12
14
|
def auth_parameters
|
13
15
|
{
|
14
|
-
|
15
|
-
|
16
|
+
headers: {
|
17
|
+
"Authorization" => format("Basic %s", Base64.encode64(options[:username] + ":" + options[:password]).chomp),
|
18
|
+
},
|
16
19
|
}
|
17
20
|
end
|
18
21
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require "json"
|
2
|
-
require "ostruct"
|
3
|
-
require "uri"
|
1
|
+
require "json" unless defined?(JSON)
|
2
|
+
require "ostruct" unless defined?(OpenStruct)
|
3
|
+
require "uri" unless defined?(URI)
|
4
4
|
|
5
|
-
require "rest-client"
|
6
|
-
require "train"
|
5
|
+
require "rest-client" unless defined?(RestClient)
|
6
|
+
require "train" unless defined?(Train)
|
7
7
|
|
8
8
|
module TrainPlugins
|
9
9
|
module Rest
|
@@ -27,7 +27,7 @@ module TrainPlugins
|
|
27
27
|
def setup_vcr
|
28
28
|
return unless options[:vcr_cassette]
|
29
29
|
|
30
|
-
require "vcr"
|
30
|
+
require "vcr" unless defined?(VCR)
|
31
31
|
|
32
32
|
# TODO: Starts from "/" :(
|
33
33
|
library = options[:vcr_library]
|
@@ -62,10 +62,12 @@ module TrainPlugins
|
|
62
62
|
components.to_s
|
63
63
|
end
|
64
64
|
|
65
|
+
# Allow overwriting to refine the type of REST API
|
66
|
+
attr_writer :detected_os
|
67
|
+
|
65
68
|
def inventory
|
66
|
-
# Faking it for Chef Target Mode only
|
67
69
|
OpenStruct.new({
|
68
|
-
name: "rest",
|
70
|
+
name: @detected_os || "rest",
|
69
71
|
release: TrainPlugins::Rest::VERSION,
|
70
72
|
family_hierarchy: %w{rest api},
|
71
73
|
family: "api",
|
@@ -98,8 +100,9 @@ module TrainPlugins
|
|
98
100
|
parameters[:url] = full_url(path)
|
99
101
|
|
100
102
|
if json_processing
|
103
|
+
parameters[:headers]["Accept"] = "application/json"
|
101
104
|
parameters[:headers]["Content-Type"] = "application/json"
|
102
|
-
parameters[:payload] = JSON.generate(data)
|
105
|
+
parameters[:payload] = JSON.generate(data) unless data.nil?
|
103
106
|
else
|
104
107
|
parameters[:payload] = data
|
105
108
|
end
|
@@ -172,14 +175,14 @@ module TrainPlugins
|
|
172
175
|
end
|
173
176
|
|
174
177
|
def login
|
175
|
-
logger.info format("REST Login via %s authentication handler", auth_type.to_s)
|
178
|
+
logger.info format("REST Login via %s authentication handler", auth_type.to_s) unless %i{anonymous basic}.include? auth_type
|
176
179
|
|
177
180
|
auth_handler.options = options
|
178
181
|
auth_handler.login
|
179
182
|
end
|
180
183
|
|
181
184
|
def logout
|
182
|
-
logger.info format("REST Logout via %s authentication handler", auth_type.to_s)
|
185
|
+
logger.info format("REST Logout via %s authentication handler", auth_type.to_s) unless %i{anonymous basic}.include? auth_type
|
183
186
|
|
184
187
|
auth_handler.logout
|
185
188
|
end
|
data/lib/train-rest/transport.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require "rubygems"
|
1
|
+
require "rubygems" unless defined?(Gem)
|
2
2
|
|
3
3
|
require "train-rest/connection"
|
4
4
|
|
@@ -10,7 +10,7 @@ module TrainPlugins
|
|
10
10
|
option :endpoint, required: true
|
11
11
|
option :verify_ssl, default: true
|
12
12
|
option :proxy, default: nil
|
13
|
-
option :headers, default:
|
13
|
+
option :headers, default: {}
|
14
14
|
option :timeout, default: 120
|
15
15
|
|
16
16
|
option :auth_type, default: :anonymous
|
data/lib/train-rest/version.rb
CHANGED
data/train-rest.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: train-rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Heinen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: train
|