manageiq-api-client 0.3.7 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8dec9fe356657ce4cfd68117c3782600682ad3866f666fd10aabbc88a0c47f3f
4
- data.tar.gz: f6b2c0d1515a13b033f23ba73aeb58e691810ebfcef3b1e26640180912f283e7
3
+ metadata.gz: 2cf72edce682a6dd72ea4e953b17db64d99cd5c32c9d768f1d41bf8c4b09b888
4
+ data.tar.gz: 1b2df1d7796fa18e4d20c00355b6505566dac1bd5454ca70b71ed80204832ec7
5
5
  SHA512:
6
- metadata.gz: da5baaedb66406e134675e01036f085b92e1fbf091c938f932ab9c81d5f3ca99e2ace57e12a66cbdead50d8794f095d0359511f1d061c3ebd0ea9cce3d8b86fc
7
- data.tar.gz: ff1c57b8ae147f36eed38b0535aa789776b2ed3e8088e37bd729b218e5e50afd6c97099e57fbb7244351fc5991f3595ad6fce8463fda72ec2aa2b4a29c098d0e
6
+ metadata.gz: 9591e051844cf72bcd26df553c0e4c745b7a430111cdbc3c5e5ef3e0aa25a3b78d3a9479b3821f8a1e9d1055c3256f2b8bd9c352ed34656a35cb0c58e4a60e94
7
+ data.tar.gz: ae40d2fefa9a9dcd234b0f158c2dd2dec3440c0c2ddf72143bb176eb221736c14b153aa10093e801e4210e36b648071c95f2b30bd71d8d1e6a1eec4c1a9f7f4c
@@ -22,7 +22,7 @@ jobs:
22
22
  TEST_RAILS_VERSION: ${{ matrix.rails-version }}
23
23
  CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
24
24
  steps:
25
- - uses: actions/checkout@v2
25
+ - uses: actions/checkout@v4
26
26
  - name: Set up Ruby
27
27
  uses: ruby/setup-ruby@v1
28
28
  with:
@@ -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@v3.0.0
37
+ uses: paambaati/codeclimate-action@v5
data/CHANGELOG.md CHANGED
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.4.0] - 2023-10-16
10
+ ### Added
11
+ - Add Bearer token support [[#113]](https://github.com/ManageIQ/manageiq-api-client/pull/113)
12
+
9
13
  ## [0.3.7] - 2023-05-19
10
14
  ### Changed
11
15
  - Loosen faraday to 1.x. [[#108]](https://github.com/ManageIQ/manageiq-api-client/pull/108)
@@ -61,7 +65,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
61
65
  - Add CHANGELOG.md
62
66
  - Update README with simple instructions reflecting the query interface.
63
67
 
64
- [Unreleased]: https://github.com/ManageIQ/manageiq-api-client/compare/v0.3.7...HEAD
68
+ [Unreleased]: https://github.com/ManageIQ/manageiq-api-client/compare/v0.4.0...HEAD
69
+ [0.4.0]: https://github.com/ManageIQ/manageiq-api-client/compare/v0.3.7...v0.4.0
65
70
  [0.3.7]: https://github.com/ManageIQ/manageiq-api-client/compare/v0.3.6...v0.3.7
66
71
  [0.3.6]: https://github.com/ManageIQ/manageiq-api-client/compare/v0.3.5...v0.3.6
67
72
  [0.3.5]: https://github.com/ManageIQ/manageiq-api-client/compare/v0.3.4...v0.3.5
@@ -6,6 +6,7 @@ module ManageIQ
6
6
  attr_reader :password
7
7
  attr_reader :token
8
8
  attr_reader :miqtoken
9
+ attr_reader :bearer_token
9
10
  attr_reader :group
10
11
 
11
12
  DEFAULTS = {
@@ -13,26 +14,26 @@ module ManageIQ
13
14
  :password => "smartvm"
14
15
  }.freeze
15
16
 
16
- CUSTOM_INSPECT_EXCLUSIONS = [:@password].freeze
17
+ CUSTOM_INSPECT_EXCLUSIONS = %i[@password @token @miqtoken @bearer_token].freeze
17
18
  include CustomInspectMixin
18
19
 
19
20
  def initialize(options = {})
20
21
  @user, @password = fetch_credentials(options)
21
- @token, @miqtoken, @group = options.values_at(:token, :miqtoken, :group)
22
+ @token, @miqtoken, @bearer_token, @group = options.values_at(:token, :miqtoken, :bearer_token, :group)
22
23
 
23
- unless token || miqtoken
24
+ unless token || miqtoken || bearer_token
24
25
  raise "Must specify both a user and a password" if user.blank? || password.blank?
25
26
  end
26
27
  end
27
28
 
28
29
  def self.auth_options_specified?(options)
29
- options.slice(:user, :password, :token, :miqtoken, :group).present?
30
+ options.slice(:user, :password, :token, :miqtoken, :bearer_token, :group).present?
30
31
  end
31
32
 
32
33
  private
33
34
 
34
35
  def fetch_credentials(options)
35
- if options.slice(:user, :password, :token, :miqtoken).blank?
36
+ if options.slice(:user, :password, :token, :miqtoken, :bearer_token).blank?
36
37
  [DEFAULTS[:user], DEFAULTS[:password]]
37
38
  else
38
39
  [options[:user], options[:password]]
@@ -76,7 +76,7 @@ module ManageIQ
76
76
  faraday.response(:logger, client.logger)
77
77
  faraday.use FaradayMiddleware::FollowRedirects, :limit => 3, :standards_compliant => true
78
78
  faraday.adapter(Faraday.default_adapter) # make requests with Net::HTTP
79
- if authentication.token.blank? && authentication.miqtoken.blank?
79
+ if authentication.token.blank? && authentication.miqtoken.blank? && authentication.bearer_token.blank?
80
80
  faraday.basic_auth(authentication.user, authentication.password)
81
81
  end
82
82
  end
@@ -90,6 +90,7 @@ module ManageIQ
90
90
  @response = handle.run_request(method.to_sym, api_path(path), nil, nil) do |request|
91
91
  request.headers[:content_type] = CONTENT_TYPE
92
92
  request.headers[:accept] = CONTENT_TYPE
93
+ request.headers[:authorization] = "Bearer #{authentication.bearer_token}" unless authentication.bearer_token.blank?
93
94
  request.headers['X-MIQ-Group'] = authentication.group unless authentication.group.blank?
94
95
  request.headers['X-Auth-Token'] = authentication.token unless authentication.token.blank?
95
96
  request.headers['X-MIQ-Token'] = authentication.miqtoken unless authentication.miqtoken.blank?
@@ -1,7 +1,7 @@
1
1
  module ManageIQ
2
2
  module API
3
3
  class Client
4
- VERSION = "0.3.7".freeze
4
+ VERSION = "0.4.0".freeze
5
5
  end
6
6
  end
7
7
  end
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.3.7
4
+ version: 0.4.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: 2023-05-19 00:00:00.000000000 Z
12
+ date: 2023-10-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport