profitbricks 1.0.0 → 1.0.1

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: 7eff0a7923f9a91e6b21df7f6a0ed25dd958099a
4
- data.tar.gz: 535952263dae50c778ff480e9a6b36304056aece
3
+ metadata.gz: c7b4d1eb20600d65ab78c002755ac2869426785a
4
+ data.tar.gz: c7280d386007c4a9b9889455a38f6ded432a539b
5
5
  SHA512:
6
- metadata.gz: b4756b5b0e0685ea5fabf087b54222d7081da44270effa01a95db5a288651d26284020a9e4bd58af0889a5040fbb24ce8d1604d9993e079660271032927569d9
7
- data.tar.gz: 26e43a768c5d4a9d783a7a45be46836e2c641ff0a56f6c1789962fdcb3e387ca0949c621c95614788d8c9792ac4c42c6112f6df27b27db3dc5c049f3396ab666
6
+ metadata.gz: fecca29515ddaae5fe833b29e402eec0f4c2a37d3a70895ead1ae1876b3b7e9717d4741297ea0a20d4215915ee6f919b860a82714e539b9dffa58aeb72abbc3a
7
+ data.tar.gz: 92bae68c2d6399c18d9d32888c5a725545f21ae49b910ff2adc38fdb6dd584aa8927ed1539442d58e5fa066cd2a171f995c2435d1c359bad2065db132dc7b4ce
@@ -1,7 +1,12 @@
1
+ === 1.0.1 / 2013-07-09
2
+
3
+ * Raise an Profitbricks::AuthenticationError when the authentication failed
4
+ * Temporarily hardcoded the endpoint and namespace
5
+
1
6
  === 0.9.5 / 2013-02-16
2
7
 
3
8
  * 1 bug fix:
4
- * Cast the passed options to Server#create before checking for validity
9
+ * Cast the passed options to Server#create before checking for validity
5
10
 
6
11
  === 0.9.1 / 2012-05-16
7
12
 
@@ -15,7 +15,7 @@ require 'profitbricks/ip_block'
15
15
  require 'profitbricks/rule'
16
16
 
17
17
  module Profitbricks
18
- VERSION = '1.0.0'
18
+ VERSION = '1.0.1'
19
19
  end
20
20
 
21
21
  PB = Profitbricks
@@ -1,4 +1,6 @@
1
+
1
2
  module Profitbricks
3
+ class AuthenticationError < StandardError; end
2
4
  NEED_PREFIX = [:create_nic, :create_load_balancer, :update_storage, :create_storage,
3
5
  :update_data_center, :rom_drive, :update_nic, :create_server,
4
6
  :update_load_balancer, :connect_storage_to_server, :update_server]
@@ -16,9 +18,12 @@ module Profitbricks
16
18
  HTTPI.log = false
17
19
 
18
20
  @client = Savon::Client.new do |globals|
19
- globals.wsdl "https://api.profitbricks.com/1.2/wsdl"
21
+ # FIXME the WSDL currently returns a wrong endpoint
22
+ #globals.wsdl "https://api.profitbricks.com/1.2/wsdl"
23
+ globals.namespace "http://ws.api.profitbricks.com/"
24
+ globals.endpoint "https://api.profitbricks.com/1.2"
20
25
  globals.convert_request_keys_to :lower_camelcase
21
- globals.raise_errors true
26
+ globals.raise_errors true
22
27
  globals.log Profitbricks::Config.log
23
28
  globals.pretty_print_xml true
24
29
 
@@ -41,7 +46,7 @@ module Profitbricks
41
46
  end
42
47
  end
43
48
 
44
- private
49
+ private
45
50
  def self.request(method, options={})
46
51
  begin
47
52
  message = if NEED_PREFIX.include? method
@@ -60,6 +65,12 @@ module Profitbricks
60
65
  puts error.to_hash
61
66
  puts "--------------------------------------------------------------------------"
62
67
  raise RuntimeError.new("Error during request '#{method}': #{error.to_s}")
68
+ rescue Savon::HTTPError => error
69
+ if error.to_hash[:code] == 401
70
+ raise AuthenticationError.new('Failed to authenticate.')
71
+ else
72
+ raise error
73
+ end
63
74
  end
64
75
  (resp.body["#{method}_response".to_sym] || resp.body["#{method}_return".to_sym])[:return]
65
76
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: profitbricks
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominik Sander
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-18 00:00:00.000000000 Z
11
+ date: 2013-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: savon
@@ -243,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
243
243
  version: '0'
244
244
  requirements: []
245
245
  rubyforge_project: profitbricks
246
- rubygems_version: 2.0.0
246
+ rubygems_version: 2.0.3
247
247
  signing_key:
248
248
  specification_version: 4
249
249
  summary: A Ruby client for the ProfitBricks API.