manageiq-api-client 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +1 -1
- data/.github/workflows/ci.yaml +3 -3
- data/CHANGELOG.md +17 -1
- data/Gemfile +11 -6
- data/lib/manageiq/api/client/client.rb +2 -1
- data/lib/manageiq/api/client/connection.rb +17 -8
- data/lib/manageiq/api/client/resource.rb +2 -1
- data/lib/manageiq/api/client/version.rb +1 -1
- data/lib/manageiq/api/client.rb +2 -3
- data/manageiq-api-client.gemspec +3 -4
- data/renovate.json +6 -0
- metadata +21 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6403e45890ae054ae7a12596ab68ad0dbe0e03861f2e700fd5079c5af9d69529
|
4
|
+
data.tar.gz: 7cbe8890af71641ea6ec6b6b8374b719bc425b79eec850161f43d32ca544c1d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d61707917158f04f8d4ac00c3cf46c1d6e89c8b75b74a8a9ab8536c1df6f9c54f5430ecf416e8e2b9062d4b79452d22536824185acdc5feedc65772c2c239135
|
7
|
+
data.tar.gz: 8476cecd2949d77e0d2809e124f513f36fa612cf6fff5715ed6f398176f8bd8dd4e36ce196f4f4994e5f9196475e4dcc98e5744bcbd03e2fc71b07e339b10b5f
|
data/.codeclimate.yml
CHANGED
data/.github/workflows/ci.yaml
CHANGED
@@ -12,12 +12,12 @@ jobs:
|
|
12
12
|
strategy:
|
13
13
|
matrix:
|
14
14
|
ruby-version:
|
15
|
-
- '2.6'
|
16
|
-
- '2.7'
|
17
15
|
- '3.0'
|
16
|
+
- '3.1'
|
18
17
|
rails-version:
|
19
18
|
- '6.0'
|
20
19
|
- '6.1'
|
20
|
+
- '7.0'
|
21
21
|
env:
|
22
22
|
TEST_RAILS_VERSION: ${{ matrix.rails-version }}
|
23
23
|
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
|
@@ -34,4 +34,4 @@ jobs:
|
|
34
34
|
- name: Report code coverage
|
35
35
|
if: ${{ github.ref == 'refs/heads/master' && matrix.ruby-version == '3.0' && matrix.rails-version == '6.1' }}
|
36
36
|
continue-on-error: true
|
37
|
-
uses: paambaati/codeclimate-action@
|
37
|
+
uses: paambaati/codeclimate-action@v6
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,20 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [0.5.0] - 2024-05-13
|
10
|
+
### Changed
|
11
|
+
- Support faraday 1.0 and 2.0 [[#124]](https://github.com/ManageIQ/manageiq-api-client/pull/124)
|
12
|
+
- Upgrade faraday from 1.0 to 2.0 [[#122]](https://github.com/ManageIQ/manageiq-api-client/pull/122)
|
13
|
+
- Revert "drop activesupport dependency" [[#119]](https://github.com/ManageIQ/manageiq-api-client/pull/119)
|
14
|
+
|
15
|
+
### Fixed
|
16
|
+
- Raise exceptions on empty responses [[#121]](https://github.com/ManageIQ/manageiq-api-client/pull/121)
|
17
|
+
|
18
|
+
## [0.4.1] - 2024-03-06
|
19
|
+
### Added
|
20
|
+
- Drop active_support and more_core_extensions dependency [[#115]](https://github.com/ManageIQ/manageiq-api-client/pull/115)
|
21
|
+
- Add rails 7 support [[#114]](https://github.com/ManageIQ/manageiq-api-client/pull/114)
|
22
|
+
|
9
23
|
## [0.4.0] - 2023-10-16
|
10
24
|
### Added
|
11
25
|
- Add Bearer token support [[#113]](https://github.com/ManageIQ/manageiq-api-client/pull/113)
|
@@ -65,7 +79,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
65
79
|
- Add CHANGELOG.md
|
66
80
|
- Update README with simple instructions reflecting the query interface.
|
67
81
|
|
68
|
-
[Unreleased]: https://github.com/ManageIQ/manageiq-api-client/compare/v0.
|
82
|
+
[Unreleased]: https://github.com/ManageIQ/manageiq-api-client/compare/v0.5.0...HEAD
|
83
|
+
[0.5.0]: https://github.com/ManageIQ/manageiq-api-client/compare/v0.4.1...v0.5.0
|
84
|
+
[0.4.1]: https://github.com/ManageIQ/manageiq-api-client/compare/v0.4.0...v0.4.1
|
69
85
|
[0.4.0]: https://github.com/ManageIQ/manageiq-api-client/compare/v0.3.7...v0.4.0
|
70
86
|
[0.3.7]: https://github.com/ManageIQ/manageiq-api-client/compare/v0.3.6...v0.3.7
|
71
87
|
[0.3.6]: https://github.com/ManageIQ/manageiq-api-client/compare/v0.3.5...v0.3.6
|
data/Gemfile
CHANGED
@@ -7,9 +7,14 @@ gemspec
|
|
7
7
|
dev_gemfile = File.expand_path("Gemfile.dev.rb", __dir__)
|
8
8
|
eval_gemfile(dev_gemfile) if File.exist?(dev_gemfile)
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
minimum_version =
|
11
|
+
case ENV['TEST_RAILS_VERSION']
|
12
|
+
when "6.0"
|
13
|
+
"~>6.0.4"
|
14
|
+
when "7.0"
|
15
|
+
"~>7.0.8"
|
16
|
+
else
|
17
|
+
"~>6.1.4"
|
18
|
+
end
|
19
|
+
|
20
|
+
gem "activesupport", minimum_version
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module ManageIQ
|
2
2
|
module API
|
3
3
|
class Client
|
4
|
+
extend Forwardable
|
4
5
|
attr_reader :client_options
|
5
6
|
attr_reader :logger
|
6
7
|
attr_reader :url
|
@@ -62,7 +63,7 @@ module ManageIQ
|
|
62
63
|
load_definitions
|
63
64
|
end
|
64
65
|
|
65
|
-
|
66
|
+
def_delegators :connection, :get, :post, :put, :patch, :delete, :options, :error
|
66
67
|
|
67
68
|
private
|
68
69
|
|
@@ -2,6 +2,8 @@ module ManageIQ
|
|
2
2
|
module API
|
3
3
|
class Client
|
4
4
|
class Connection
|
5
|
+
extend Forwardable
|
6
|
+
|
5
7
|
attr_reader :url
|
6
8
|
attr_reader :authentication
|
7
9
|
attr_reader :client
|
@@ -9,7 +11,7 @@ module ManageIQ
|
|
9
11
|
attr_reader :response
|
10
12
|
attr_reader :error
|
11
13
|
|
12
|
-
|
14
|
+
def_delegators :client, :url, :authentication
|
13
15
|
|
14
16
|
API_PREFIX = "/api".freeze
|
15
17
|
CONTENT_TYPE = "application/json".freeze
|
@@ -58,12 +60,12 @@ module ManageIQ
|
|
58
60
|
end
|
59
61
|
|
60
62
|
def api_path(path)
|
61
|
-
if path.to_s.
|
63
|
+
if path.to_s.start_with?(url.to_s)
|
62
64
|
path.to_s
|
63
65
|
elsif path.to_s.blank?
|
64
66
|
URI.join(url, API_PREFIX).to_s
|
65
67
|
else
|
66
|
-
URI.join(url, path.to_s.
|
68
|
+
URI.join(url, path.to_s.start_with?(API_PREFIX) ? path.to_s : "#{API_PREFIX}/#{path}").to_s
|
67
69
|
end
|
68
70
|
end
|
69
71
|
|
@@ -74,10 +76,17 @@ module ManageIQ
|
|
74
76
|
faraday.options.open_timeout = @connection_options[:open_timeout] if @connection_options[:open_timeout]
|
75
77
|
faraday.options.timeout = @connection_options[:timeout] if @connection_options[:timeout]
|
76
78
|
faraday.response(:logger, client.logger)
|
77
|
-
faraday.
|
78
|
-
|
79
|
+
faraday.response(:follow_redirects, :limit => 3, :standards_compliant => true)
|
80
|
+
# make requests with Net::HTTP
|
81
|
+
faraday.adapter(Faraday.default_adapter)
|
79
82
|
if authentication.token.blank? && authentication.miqtoken.blank? && authentication.bearer_token.blank?
|
80
|
-
faraday.basic_auth
|
83
|
+
if faraday.respond_to?(:basic_auth)
|
84
|
+
# faraday 1.0
|
85
|
+
faraday.basic_auth(authentication.user, authentication.password)
|
86
|
+
else
|
87
|
+
# faraday 2.0
|
88
|
+
faraday.request(:authorization, :basic, authentication.user, authentication.password)
|
89
|
+
end
|
81
90
|
end
|
82
91
|
end
|
83
92
|
end
|
@@ -105,11 +114,11 @@ module ManageIQ
|
|
105
114
|
|
106
115
|
def check_response
|
107
116
|
if response.status == 404
|
108
|
-
message = json_response
|
117
|
+
message = json_response["error"].kind_of?(String) ? json_response["error"] : json_response.dig("error", "message")
|
109
118
|
raise ManageIQ::API::Client::ResourceNotFound, message
|
110
119
|
elsif response.status >= 400
|
111
120
|
@error = ManageIQ::API::Client::Error.new(response.status, json_response)
|
112
|
-
raise @error.message
|
121
|
+
raise ManageIQ::API::Client::Exception, @error.message || "Empty Response"
|
113
122
|
end
|
114
123
|
end
|
115
124
|
end
|
@@ -2,6 +2,7 @@ module ManageIQ
|
|
2
2
|
module API
|
3
3
|
class Client
|
4
4
|
class Resource
|
5
|
+
extend Forwardable
|
5
6
|
include ActionMixin
|
6
7
|
|
7
8
|
CUSTOM_INSPECT_EXCLUSIONS = [:@collection].freeze
|
@@ -21,7 +22,7 @@ module ManageIQ
|
|
21
22
|
attr_reader :collection
|
22
23
|
attr_reader :actions
|
23
24
|
|
24
|
-
|
25
|
+
def_delegators :collection, :client
|
25
26
|
|
26
27
|
def initialize(collection, resource_hash)
|
27
28
|
raise "Cannot instantiate a Resource directly" if instance_of?(Resource)
|
data/lib/manageiq/api/client.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
require "active_support"
|
2
2
|
require "active_support/core_ext"
|
3
3
|
require "faraday"
|
4
|
-
require "
|
4
|
+
require "faraday/follow_redirects"
|
5
|
+
require 'forwardable'
|
5
6
|
require "json"
|
6
|
-
require "more_core_extensions/all"
|
7
|
-
require "pp"
|
8
7
|
require "query_relation"
|
9
8
|
|
10
9
|
require "manageiq/api/client/client"
|
data/manageiq-api-client.gemspec
CHANGED
@@ -23,11 +23,10 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
24
|
spec.require_paths = ["lib"]
|
25
25
|
|
26
|
-
spec.add_dependency "activesupport", ">=
|
27
|
-
spec.add_dependency "faraday", "
|
28
|
-
spec.add_dependency "
|
26
|
+
spec.add_dependency "activesupport", ">= 6.0", "<7.1"
|
27
|
+
spec.add_dependency "faraday", ">= 1.0", "< 3.0"
|
28
|
+
spec.add_dependency "faraday-follow_redirects"
|
29
29
|
spec.add_dependency "json", "~> 2.3"
|
30
|
-
spec.add_dependency "more_core_extensions"
|
31
30
|
spec.add_dependency "query_relation"
|
32
31
|
|
33
32
|
spec.add_development_dependency "bundler"
|
data/renovate.json
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: manageiq-api-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alberto Bellotti
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2024-05-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -17,48 +17,54 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
20
|
+
version: '6.0'
|
21
21
|
- - "<"
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: '7.
|
23
|
+
version: '7.1'
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
27
27
|
requirements:
|
28
28
|
- - ">="
|
29
29
|
- !ruby/object:Gem::Version
|
30
|
-
version: '
|
30
|
+
version: '6.0'
|
31
31
|
- - "<"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '7.
|
33
|
+
version: '7.1'
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: faraday
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.0'
|
41
|
+
- - "<"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '3.0'
|
41
44
|
type: :runtime
|
42
45
|
prerelease: false
|
43
46
|
version_requirements: !ruby/object:Gem::Requirement
|
44
47
|
requirements:
|
45
|
-
- - "
|
48
|
+
- - ">="
|
46
49
|
- !ruby/object:Gem::Version
|
47
50
|
version: '1.0'
|
51
|
+
- - "<"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.0'
|
48
54
|
- !ruby/object:Gem::Dependency
|
49
|
-
name:
|
55
|
+
name: faraday-follow_redirects
|
50
56
|
requirement: !ruby/object:Gem::Requirement
|
51
57
|
requirements:
|
52
|
-
- - "
|
58
|
+
- - ">="
|
53
59
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
60
|
+
version: '0'
|
55
61
|
type: :runtime
|
56
62
|
prerelease: false
|
57
63
|
version_requirements: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
|
-
- - "
|
65
|
+
- - ">="
|
60
66
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
67
|
+
version: '0'
|
62
68
|
- !ruby/object:Gem::Dependency
|
63
69
|
name: json
|
64
70
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,20 +79,6 @@ dependencies:
|
|
73
79
|
- - "~>"
|
74
80
|
- !ruby/object:Gem::Version
|
75
81
|
version: '2.3'
|
76
|
-
- !ruby/object:Gem::Dependency
|
77
|
-
name: more_core_extensions
|
78
|
-
requirement: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
type: :runtime
|
84
|
-
prerelease: false
|
85
|
-
version_requirements: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
82
|
- !ruby/object:Gem::Dependency
|
91
83
|
name: query_relation
|
92
84
|
requirement: !ruby/object:Gem::Requirement
|
@@ -233,6 +225,7 @@ files:
|
|
233
225
|
- lib/manageiq/api/client/version.rb
|
234
226
|
- lib/manageiq_api_client.rb
|
235
227
|
- manageiq-api-client.gemspec
|
228
|
+
- renovate.json
|
236
229
|
homepage: http://github.com/ManageIQ/manageiq-api-client
|
237
230
|
licenses:
|
238
231
|
- MIT
|
@@ -252,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
252
245
|
- !ruby/object:Gem::Version
|
253
246
|
version: '0'
|
254
247
|
requirements: []
|
255
|
-
rubygems_version: 3.
|
248
|
+
rubygems_version: 3.3.27
|
256
249
|
signing_key:
|
257
250
|
specification_version: 4
|
258
251
|
summary: ManageIQ API Client
|