abiquo-api 0.0.4 → 0.0.5

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
  SHA1:
3
- metadata.gz: fcac0cebe8eca1e8436a1e201a4fbc5ec3d7e30c
4
- data.tar.gz: d7d7b8036b8746c68e72c8d8d83e5e02a119845f
3
+ metadata.gz: ac0a5ff9c10d0b39f113f768cb9d93c68bd271b3
4
+ data.tar.gz: f69f314150ee749e51083511e005cc75b089cb1a
5
5
  SHA512:
6
- metadata.gz: 772ad5ac86fb5cef5a94a6fb4d623da66dc83c5cf4b76e5e8fbbe2db2af1837ceabd83e917250ab8cc0b56f2d06a4bd8e5076d16fe1d367037b62d2256b06521
7
- data.tar.gz: 8ec539f19258de9cf0bf4f9be60050956b27265680e46ba228a5793704547cfaaa0de7609d6c2abfd5c63381712216dc51a836b6027d40f5100a6d8446e874d7
6
+ metadata.gz: eb7a621e40a32e64d54f5b56e844e2023e058c20ea9b17ffb7744824756d8effa99bc67ff1385637796b1987b99558b67ac8e0fc7539fcb3442c265f668b29da
7
+ data.tar.gz: d9b10fc59d6f339d1bf63a8969e88d105c6a013e43bbac0ba717fcd69ffd63ef57fb61714b4f0d1d2f86cbb0582fb35de14c7928668cd9d363e7c69b2105fc49
data/README.md CHANGED
@@ -33,6 +33,22 @@ abq = AbiquoAPI.new(:abiquo_api_url => 'https://10.60.13.40/api',
33
33
  :version => "2.9")
34
34
  ```
35
35
 
36
+ You can also define some connection parameters that will be applied to HTTP connection:
37
+
38
+ ```ruby
39
+ require 'abiquo-api'
40
+
41
+ abq = AbiquoAPI.new(:abiquo_api_url => 'https://10.60.13.40/api',
42
+ :abiquo_username => "admin",
43
+ :abiquo_password => "xabiquo",
44
+ :connection_options => {
45
+ :connect_timeout => 30,
46
+ :read_timeout => 120,
47
+ :write_timeout => 120,
48
+ :ssl_verify_peer => true,
49
+ :ssl_ca_path => "/etc/pki/tls/private/myCA.crt" })
50
+ ```
51
+
36
52
  Then you can start browsing the API:
37
53
 
38
54
  ```ruby
@@ -38,22 +38,31 @@ class AbiquoAPI
38
38
  #
39
39
  # Required options:
40
40
  #
41
- # :abiquo_api_url => The URL of the Abiquo API. ie. https://yourserver/api
42
- # :abiquo_username => The username used to connect to the Abiquo API.
43
- # :abiquo_password => The password for your user.
44
- # :version => The Abiquo API version to include in each request.
45
- # Defaults to whatever is returned in the /api/version resource
41
+ # :abiquo_api_url => The URL of the Abiquo API. ie. https://yourserver/api
42
+ # :abiquo_username => The username used to connect to the Abiquo API.
43
+ # :abiquo_password => The password for your user.
44
+ # :version => The Abiquo API version to include in each request.
45
+ # Defaults to whatever is returned in the /api/version resource
46
+ # :connection_options => Excon HTTP client connection options.
47
+ # { :connect_timeout => <time_in_secs>,
48
+ # :read_timeout => <time_in_secs>,
49
+ # :write_timeout => <time_in_secs>,
50
+ # :ssl_verify_peer => <true_or_false>,
51
+ # :ssl_ca_path => <path_to_ca_file> }
46
52
  #
47
53
  def initialize(options = {})
48
54
  api_url = options[:abiquo_api_url]
49
55
  api_username = options[:abiquo_username]
50
56
  api_password = options[:abiquo_password]
57
+ connection_options = options[:connection_options] || {}
51
58
 
52
59
  raise "You need to set :abiquo_api_url, :abiquo_username and :abiquo_password" if api_url.nil? or api_username.nil? or api_password.nil?
53
60
 
54
61
  @http_client = AbiquoAPIClient::HTTPClient.new(api_url,
55
62
  api_username,
56
- api_password)
63
+ api_password,
64
+ connection_options)
65
+
57
66
  api_path = URI.parse(api_url).path
58
67
 
59
68
  loginresp = @http_client.request(
@@ -28,12 +28,24 @@ module AbiquoAPIClient
28
28
  # :abiquo_api_url:: The URL of the Abiquo API. ie. https://yourserver/api
29
29
  # :abiquo_username:: The username used to connect to the Abiquo API.
30
30
  # :abiquo_password:: The password for your user.
31
+ # :connection_options:: { :connect_timeout => <time_in_secs>, :read_timeout => <time_in_secs>, :write_timeout => <time_in_secs>,
32
+ # :ssl_verify_peer => <true_or_false>, :ssl_ca_path => <path_to_ca_file> }
31
33
  #
32
- def initialize(api_url, api_username, api_password)
33
- Excon.defaults[:ssl_verify_peer] = false
34
+ def initialize(api_url, api_username, api_password, connection_options)
35
+ Excon.defaults[:ssl_ca_path] = connection_options[:ssl_ca_path] || ''
36
+ Excon.defaults[:ssl_verify_peer] = connection_options[:ssl_verify_peer] || false
37
+
38
+ connect_timeout = connection_options[:connect_timeout] || 60
39
+ read_timeout = connection_options[:read_timeout] || 60
40
+ write_timeout = connection_options[:write_timeout] || 60
41
+
34
42
  @connection = Excon.new(api_url,
35
43
  :user => api_username,
36
- :password => api_password )
44
+ :password => api_password,
45
+ :connect_timeout => connect_timeout,
46
+ :read_timeout => read_timeout,
47
+ :write_timeout => write_timeout)
48
+
37
49
  self
38
50
  end
39
51
 
@@ -1,3 +1,3 @@
1
1
  module AbiquoAPIClient
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
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.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc Cirauqui
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-11 00:00:00.000000000 Z
11
+ date: 2015-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon