abiquo-api 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8836f606285a63c433d784569b4d5f0847641aa5
4
- data.tar.gz: 7a063fd1c4b2be4ad830f3b5b51e7d276715b955
3
+ metadata.gz: fcced71f2e3f6782763643d062ada792dabc6023
4
+ data.tar.gz: 862f2f8b982f93e35de263aecf45b1b513842f05
5
5
  SHA512:
6
- metadata.gz: 5d11dbf20d34e360fdcf740203b5e7d12e51a851a197282a82bbb71b9db461584f4c41e475b0127d47c3c117fd46e8b26d1c7a28867d8a1c27df93dc82d55fc8
7
- data.tar.gz: b8af64523e3ed132e14596040224792bc9f748b973bf2205c2b8cbca13bbb6f4203017825931909880973134ce81c4afc702ab2500a9f54e6a3d74096d54c266
6
+ metadata.gz: e6b149388d3bf38f6417f0a57667deb6022bfdda8cb597063d6f3dd9c45949b83b84467ae968a65b530d8911573c9e1767c851b00df239abf691f0f84dcec6fc
7
+ data.tar.gz: 0dbd1de15111dfa23fbdd04a65b47481e347bdcd86fd7773c0ab786867cbeb1e3788272721cb2878c0d0f4d63b7d40265cd48719f3b3154d82725679aac4f386
@@ -56,13 +56,14 @@ class AbiquoAPI
56
56
  api_password = options[:abiquo_password]
57
57
  api_key = options[:abiquo_api_key]
58
58
  api_secret = options[:abiquo_api_secret]
59
+ access_token = options[:abiquo_access_token]
59
60
  token_key = options[:abiquo_token_key]
60
61
  token_secret = options[:abiquo_token_secret]
61
62
  connection_options = options[:connection_options] || {}
62
63
 
63
64
  raise "You need to set :abiquo_api_url" if api_url.nil?
64
- raise "You need to provide either basic auth or oauth credentials!!" if (api_username.nil? or api_password.nil?) and
65
- (api_key.nil? or api_secret.nil? or token_key.nil? or token_secret.nil?)
65
+ raise "You need to provide either basic auth, oauth credentials or OpenID access token!!" if (api_username.nil? or api_password.nil?) and
66
+ (api_key.nil? or api_secret.nil? or token_key.nil? or token_secret.nil?) and (access_token.nil?)
66
67
 
67
68
  unless api_key.nil?
68
69
  credentials = {
@@ -72,10 +73,16 @@ class AbiquoAPI
72
73
  :token_secret => token_secret
73
74
  }
74
75
  else
75
- credentials = {
76
- :api_username => api_username,
77
- :api_password => api_password
78
- }
76
+ if access_token.nil?
77
+ credentials = {
78
+ :api_username => api_username,
79
+ :api_password => api_password
80
+ }
81
+ else
82
+ credentials = {
83
+ :access_token => access_token
84
+ }
85
+ end
79
86
  end
80
87
 
81
88
  @http_client = AbiquoAPIClient::HTTPClient.new(api_url,
@@ -33,7 +33,12 @@ module AbiquoAPIClient
33
33
  # :ssl_verify_peer => <true_or_false>, :ssl_ca_path => <path_to_ca_file> }
34
34
  #
35
35
  def initialize(api_url, creds, connection_options)
36
- if creds.has_key? :consumer_key
36
+ if creds.has_key? :access_token
37
+ @connection = Faraday.new(api_url, connection_options) do |c|
38
+ c.authorization :Bearer, creds[:access_token]
39
+ c.adapter :excon
40
+ end
41
+ elsif creds.has_key? :consumer_key
37
42
  @connection = Faraday.new(api_url, connection_options) do |c|
38
43
  c.request :oauth, creds
39
44
  c.adapter :excon
@@ -1,3 +1,3 @@
1
1
  module AbiquoAPIClient
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abiquo-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc Cirauqui
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-05 00:00:00.000000000 Z
11
+ date: 2017-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon