fog 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. data/Gemfile +2 -2
  2. data/Gemfile.lock +5 -5
  3. data/README.rdoc +29 -29
  4. data/fog.gemspec +24 -2
  5. data/lib/fog.rb +4 -15
  6. data/lib/fog/aws.rb +2 -2
  7. data/lib/fog/aws/ec2.rb +64 -101
  8. data/lib/fog/aws/elb.rb +19 -27
  9. data/lib/fog/aws/models/ec2/addresses.rb +1 -9
  10. data/lib/fog/aws/models/ec2/flavors.rb +1 -7
  11. data/lib/fog/aws/models/ec2/images.rb +1 -7
  12. data/lib/fog/aws/models/ec2/key_pairs.rb +1 -7
  13. data/lib/fog/aws/models/ec2/security_groups.rb +1 -7
  14. data/lib/fog/aws/models/ec2/servers.rb +1 -7
  15. data/lib/fog/aws/models/ec2/snapshots.rb +1 -9
  16. data/lib/fog/aws/models/ec2/volumes.rb +1 -9
  17. data/lib/fog/aws/models/s3/directories.rb +1 -7
  18. data/lib/fog/aws/models/s3/file.rb +5 -0
  19. data/lib/fog/aws/requests/ec2/allocate_address.rb +2 -0
  20. data/lib/fog/aws/requests/ec2/attach_volume.rb +2 -0
  21. data/lib/fog/aws/requests/ec2/create_key_pair.rb +2 -0
  22. data/lib/fog/aws/requests/ec2/create_snapshot.rb +2 -0
  23. data/lib/fog/aws/requests/ec2/create_volume.rb +2 -0
  24. data/lib/fog/aws/requests/ec2/describe_addresses.rb +2 -0
  25. data/lib/fog/aws/requests/ec2/describe_availability_zones.rb +2 -0
  26. data/lib/fog/aws/requests/ec2/describe_images.rb +2 -0
  27. data/lib/fog/aws/requests/ec2/describe_instances.rb +2 -0
  28. data/lib/fog/aws/requests/ec2/describe_key_pairs.rb +2 -0
  29. data/lib/fog/aws/requests/ec2/describe_regions.rb +2 -0
  30. data/lib/fog/aws/requests/ec2/describe_reserved_instances.rb +2 -0
  31. data/lib/fog/aws/requests/ec2/describe_security_groups.rb +2 -0
  32. data/lib/fog/aws/requests/ec2/describe_snapshots.rb +2 -0
  33. data/lib/fog/aws/requests/ec2/describe_volumes.rb +2 -0
  34. data/lib/fog/aws/requests/ec2/detach_volume.rb +2 -0
  35. data/lib/fog/aws/requests/ec2/get_console_output.rb +2 -0
  36. data/lib/fog/aws/requests/ec2/run_instances.rb +2 -0
  37. data/lib/fog/aws/requests/ec2/terminate_instances.rb +2 -0
  38. data/lib/fog/aws/requests/elb/create_load_balancer.rb +2 -0
  39. data/lib/fog/aws/requests/elb/delete_load_balancer.rb +2 -0
  40. data/lib/fog/aws/requests/elb/deregister_instances_from_load_balancer.rb +2 -0
  41. data/lib/fog/aws/requests/elb/describe_instance_health.rb +2 -0
  42. data/lib/fog/aws/requests/elb/describe_load_balancers.rb +2 -0
  43. data/lib/fog/aws/requests/elb/disable_availability_zones_for_load_balancer.rb +2 -0
  44. data/lib/fog/aws/requests/elb/enable_availability_zones_for_load_balancer.rb +2 -0
  45. data/lib/fog/aws/requests/elb/register_instances_with_load_balancer.rb +2 -0
  46. data/lib/fog/aws/requests/s3/copy_object.rb +2 -0
  47. data/lib/fog/aws/requests/s3/get_bucket.rb +2 -0
  48. data/lib/fog/aws/requests/s3/get_bucket_acl.rb +2 -0
  49. data/lib/fog/aws/requests/s3/get_bucket_location.rb +2 -0
  50. data/lib/fog/aws/requests/s3/get_bucket_logging.rb +2 -0
  51. data/lib/fog/aws/requests/s3/get_bucket_object_versions.rb +2 -0
  52. data/lib/fog/aws/requests/s3/get_bucket_versioning.rb +2 -0
  53. data/lib/fog/aws/requests/s3/get_object_acl.rb +2 -0
  54. data/lib/fog/aws/requests/s3/get_request_payment.rb +2 -0
  55. data/lib/fog/aws/requests/s3/get_service.rb +2 -0
  56. data/lib/fog/aws/requests/s3/put_object.rb +2 -2
  57. data/lib/fog/aws/requests/simpledb/domain_metadata.rb +2 -0
  58. data/lib/fog/aws/requests/simpledb/get_attributes.rb +2 -0
  59. data/lib/fog/aws/requests/simpledb/list_domains.rb +2 -0
  60. data/lib/fog/aws/requests/simpledb/select.rb +2 -0
  61. data/lib/fog/aws/s3.rb +68 -85
  62. data/lib/fog/aws/simpledb.rb +15 -29
  63. data/lib/fog/bluebox.rb +23 -40
  64. data/lib/fog/bluebox/models/flavors.rb +1 -7
  65. data/lib/fog/bluebox/models/images.rb +1 -9
  66. data/lib/fog/bluebox/models/servers.rb +1 -7
  67. data/lib/fog/credentials.rb +2 -0
  68. data/lib/fog/errors.rb +20 -0
  69. data/lib/fog/hmac.rb +48 -0
  70. data/lib/fog/local.rb +9 -22
  71. data/lib/fog/local/models/directories.rb +1 -7
  72. data/lib/fog/rackspace.rb +2 -6
  73. data/lib/fog/rackspace/files.rb +46 -48
  74. data/lib/fog/rackspace/models/files/directories.rb +1 -7
  75. data/lib/fog/rackspace/models/servers/flavors.rb +1 -7
  76. data/lib/fog/rackspace/models/servers/images.rb +1 -9
  77. data/lib/fog/rackspace/models/servers/server.rb +37 -1
  78. data/lib/fog/rackspace/models/servers/servers.rb +8 -7
  79. data/lib/fog/rackspace/requests/files/put_object.rb +1 -1
  80. data/lib/fog/rackspace/servers.rb +33 -45
  81. data/lib/fog/service.rb +82 -0
  82. data/lib/fog/slicehost.rb +28 -42
  83. data/lib/fog/slicehost/models/flavors.rb +1 -7
  84. data/lib/fog/slicehost/models/images.rb +1 -9
  85. data/lib/fog/slicehost/models/servers.rb +1 -7
  86. data/lib/fog/ssh.rb +1 -1
  87. data/lib/fog/vcloud.rb +20 -3
  88. data/lib/fog/vcloud/collection.rb +25 -5
  89. data/lib/fog/vcloud/model.rb +4 -0
  90. data/lib/fog/vcloud/parsers/get_organization.rb +2 -2
  91. data/lib/fog/vcloud/parsers/get_vdc.rb +2 -2
  92. data/lib/fog/vcloud/parsers/get_versions.rb +1 -1
  93. data/lib/fog/vcloud/parsers/login.rb +2 -2
  94. data/lib/fog/vcloud/parsers/network.rb +53 -0
  95. data/lib/fog/vcloud/requests/get_network.rb +54 -0
  96. data/lib/fog/vcloud/requests/get_organization.rb +1 -2
  97. data/lib/fog/vcloud/terremark/ecloud.rb +17 -4
  98. data/lib/fog/vcloud/terremark/ecloud/models/internet_service.rb +35 -0
  99. data/lib/fog/vcloud/terremark/ecloud/models/internet_services.rb +9 -9
  100. data/lib/fog/vcloud/terremark/ecloud/models/ip.rb +18 -0
  101. data/lib/fog/vcloud/terremark/ecloud/models/ips.rb +36 -0
  102. data/lib/fog/vcloud/terremark/ecloud/models/network.rb +32 -0
  103. data/lib/fog/vcloud/terremark/ecloud/models/networks.rb +38 -0
  104. data/lib/fog/vcloud/terremark/ecloud/models/public_ip.rb +3 -1
  105. data/lib/fog/vcloud/terremark/ecloud/models/public_ips.rb +1 -1
  106. data/lib/fog/vcloud/terremark/ecloud/models/vdc.rb +9 -0
  107. data/lib/fog/vcloud/terremark/ecloud/models/vdcs.rb +2 -0
  108. data/lib/fog/vcloud/terremark/ecloud/parsers/network.rb +28 -0
  109. data/lib/fog/vcloud/terremark/ecloud/parsers/network_ips.rb +31 -0
  110. data/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb +10 -7
  111. data/lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb +99 -0
  112. data/lib/fog/vcloud/terremark/ecloud/requests/get_network.rb +54 -0
  113. data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ips.rb +51 -0
  114. data/spec/aws/models/s3/file_spec.rb +15 -0
  115. data/spec/vcloud/requests/get_network_spec.rb +55 -0
  116. data/spec/vcloud/spec_helper.rb +1 -0
  117. data/spec/vcloud/terremark/ecloud/models/internet_service_spec.rb +15 -0
  118. data/spec/vcloud/terremark/ecloud/models/ip_spec.rb +35 -0
  119. data/spec/vcloud/terremark/ecloud/models/ips_spec.rb +28 -0
  120. data/spec/vcloud/terremark/ecloud/models/network_spec.rb +65 -0
  121. data/spec/vcloud/terremark/ecloud/models/networks_spec.rb +26 -0
  122. data/spec/vcloud/terremark/ecloud/models/public_ip_spec.rb +0 -2
  123. data/spec/vcloud/terremark/ecloud/requests/configure_internet_service_spec.rb +44 -0
  124. data/spec/vcloud/terremark/ecloud/requests/get_network_ips_spec.rb +54 -0
  125. data/spec/vcloud/terremark/ecloud/requests/get_network_spec.rb +63 -0
  126. data/tests/aws/requests/ec2/volume_tests.rb +2 -2
  127. data/tests/helper.rb +2 -0
  128. metadata +25 -3
@@ -3,6 +3,8 @@ module Fog
3
3
  module ELB
4
4
  class Real
5
5
 
6
+ require 'fog/aws/parsers/elb/describe_load_balancers'
7
+
6
8
  # Describe all or specified load balancers
7
9
  #
8
10
  # ==== Parameters
@@ -3,6 +3,8 @@ module Fog
3
3
  module ELB
4
4
  class Real
5
5
 
6
+ require 'fog/aws/parsers/elb/disable_availability_zones_for_load_balancer'
7
+
6
8
  # Disable an availability zone for an existing ELB
7
9
  #
8
10
  # ==== Parameters
@@ -3,6 +3,8 @@ module Fog
3
3
  module ELB
4
4
  class Real
5
5
 
6
+ require 'fog/aws/parsers/elb/enable_availability_zones_for_load_balancer'
7
+
6
8
  # Enable an availability zone for an existing ELB
7
9
  #
8
10
  # ==== Parameters
@@ -3,6 +3,8 @@ module Fog
3
3
  module ELB
4
4
  class Real
5
5
 
6
+ require 'fog/aws/parsers/elb/register_instances_with_load_balancer'
7
+
6
8
  # Register an instance with an existing ELB
7
9
  #
8
10
  # ==== Parameters
@@ -3,6 +3,8 @@ module Fog
3
3
  module S3
4
4
  class Real
5
5
 
6
+ require 'fog/aws/parsers/s3/copy_object'
7
+
6
8
  # Copy an object from one S3 bucket to another
7
9
  #
8
10
  # ==== Parameters
@@ -3,6 +3,8 @@ module Fog
3
3
  module S3
4
4
  class Real
5
5
 
6
+ require 'fog/aws/parsers/s3/get_bucket'
7
+
6
8
  # List information about objects in an S3 bucket
7
9
  #
8
10
  # ==== Parameters
@@ -3,6 +3,8 @@ module Fog
3
3
  module S3
4
4
  class Real
5
5
 
6
+ require 'fog/aws/parsers/s3/access_control_list'
7
+
6
8
  # Get access control list for an S3 bucket
7
9
  #
8
10
  # ==== Parameters
@@ -3,6 +3,8 @@ module Fog
3
3
  module S3
4
4
  class Real
5
5
 
6
+ require 'fog/aws/parsers/s3/get_bucket_location'
7
+
6
8
  # Get location constraint for an S3 bucket
7
9
  #
8
10
  # ==== Parameters
@@ -3,6 +3,8 @@ module Fog
3
3
  module S3
4
4
  class Real
5
5
 
6
+ require 'fog/aws/parsers/s3/get_bucket_logging'
7
+
6
8
  # Get logging status for an S3 bucket
7
9
  #
8
10
  # ==== Parameters
@@ -3,6 +3,8 @@ module Fog
3
3
  module S3
4
4
  class Real
5
5
 
6
+ require 'fog/aws/parsers/s3/get_bucket_object_versions'
7
+
6
8
  # List information about object versions in an S3 bucket
7
9
  #
8
10
  # ==== Parameters
@@ -3,6 +3,8 @@ module Fog
3
3
  module S3
4
4
  class Real
5
5
 
6
+ require 'fog/aws/parsers/s3/get_bucket_versioning'
7
+
6
8
  # Get versioning status for an S3 bucket
7
9
  #
8
10
  # ==== Parameters
@@ -3,6 +3,8 @@ module Fog
3
3
  module S3
4
4
  class Real
5
5
 
6
+ require 'fog/aws/parsers/s3/access_control_list'
7
+
6
8
  # Get access control list for an S3 object
7
9
  #
8
10
  # ==== Parameters
@@ -3,6 +3,8 @@ module Fog
3
3
  module S3
4
4
  class Real
5
5
 
6
+ require 'fog/aws/parsers/s3/get_request_payment'
7
+
6
8
  # Get configured payer for an S3 bucket
7
9
  #
8
10
  # ==== Parameters
@@ -3,6 +3,8 @@ module Fog
3
3
  module S3
4
4
  class Real
5
5
 
6
+ require 'fog/aws/parsers/s3/get_service'
7
+
6
8
  # List information about S3 buckets for authorized user
7
9
  #
8
10
  # ==== Returns
@@ -24,7 +24,7 @@ module Fog
24
24
  # * headers<~Hash>:
25
25
  # * 'ETag'<~String> - etag of new object
26
26
  def put_object(bucket_name, object_name, data, options = {})
27
- data = Fog::AWS::S3.parse_data(data)
27
+ data = parse_data(data)
28
28
  headers = data[:headers].merge!(options)
29
29
  request({
30
30
  :body => data[:body],
@@ -42,7 +42,7 @@ module Fog
42
42
  class Mock
43
43
 
44
44
  def put_object(bucket_name, object_name, data, options = {})
45
- data = Fog::AWS::S3.parse_data(data)
45
+ data = parse_data(data)
46
46
  unless data[:body].is_a?(String)
47
47
  data[:body] = data[:body].read
48
48
  end
@@ -3,6 +3,8 @@ module Fog
3
3
  module SimpleDB
4
4
  class Real
5
5
 
6
+ require 'fog/aws/parsers/simpledb/domain_metadata'
7
+
6
8
  # List metadata for SimpleDB domain
7
9
  #
8
10
  # ==== Parameters
@@ -3,6 +3,8 @@ module Fog
3
3
  module SimpleDB
4
4
  class Real
5
5
 
6
+ require 'fog/aws/parsers/simpledb/get_attributes'
7
+
6
8
  # List metadata for SimpleDB domain
7
9
  #
8
10
  # ==== Parameters
@@ -3,6 +3,8 @@ module Fog
3
3
  module SimpleDB
4
4
  class Real
5
5
 
6
+ require 'fog/aws/parsers/simpledb/list_domains'
7
+
6
8
  # List SimpleDB domains
7
9
  #
8
10
  # ==== Parameters
@@ -3,6 +3,8 @@ module Fog
3
3
  module SimpleDB
4
4
  class Real
5
5
 
6
+ require 'fog/aws/parsers/simpledb/select'
7
+
6
8
  # Select item data from SimpleDB
7
9
  #
8
10
  # ==== Parameters
@@ -1,82 +1,64 @@
1
1
  module Fog
2
2
  module AWS
3
3
  module S3
4
+ extend Fog::Service
5
+
6
+ requires :aws_access_key_id, :aws_secret_access_key
7
+
8
+ model_path 'fog/aws/models/s3'
9
+ model 'directories'
10
+ model 'directory'
11
+ model 'files'
12
+ model 'file'
13
+
14
+ request_path 'fog/aws/requests/s3'
15
+ request 'copy_object'
16
+ request 'delete_bucket'
17
+ request 'delete_object'
18
+ request 'get_bucket'
19
+ request 'get_bucket_acl'
20
+ request 'get_bucket_location'
21
+ request 'get_bucket_logging'
22
+ request 'get_bucket_object_versions'
23
+ request 'get_bucket_versioning'
24
+ request 'get_object'
25
+ request 'get_object_acl'
26
+ request 'get_object_torrent'
27
+ request 'get_object_url'
28
+ request 'get_request_payment'
29
+ request 'get_service'
30
+ request 'head_object'
31
+ request 'put_bucket'
32
+ request 'put_bucket_acl'
33
+ request 'put_bucket_logging'
34
+ request 'put_bucket_versioning'
35
+ request 'put_object'
36
+ request 'put_object_url'
37
+ request 'put_request_payment'
4
38
 
5
- def self.new(options={})
6
-
7
- unless @required
8
- require 'fog/aws/models/s3/directories'
9
- require 'fog/aws/models/s3/directory'
10
- require 'fog/aws/models/s3/files'
11
- require 'fog/aws/models/s3/file'
12
- require 'fog/aws/parsers/s3/access_control_list'
13
- require 'fog/aws/parsers/s3/copy_object'
14
- require 'fog/aws/parsers/s3/get_bucket'
15
- require 'fog/aws/parsers/s3/get_bucket_location'
16
- require 'fog/aws/parsers/s3/get_bucket_logging'
17
- require 'fog/aws/parsers/s3/get_bucket_object_versions'
18
- require 'fog/aws/parsers/s3/get_bucket_versioning'
19
- require 'fog/aws/parsers/s3/get_request_payment'
20
- require 'fog/aws/parsers/s3/get_service'
21
- require 'fog/aws/requests/s3/copy_object'
22
- require 'fog/aws/requests/s3/delete_bucket'
23
- require 'fog/aws/requests/s3/delete_object'
24
- require 'fog/aws/requests/s3/get_bucket'
25
- require 'fog/aws/requests/s3/get_bucket_acl'
26
- require 'fog/aws/requests/s3/get_bucket_location'
27
- require 'fog/aws/requests/s3/get_bucket_logging'
28
- require 'fog/aws/requests/s3/get_bucket_object_versions'
29
- require 'fog/aws/requests/s3/get_bucket_versioning'
30
- require 'fog/aws/requests/s3/get_object'
31
- require 'fog/aws/requests/s3/get_object_acl'
32
- require 'fog/aws/requests/s3/get_object_torrent'
33
- require 'fog/aws/requests/s3/get_object_url'
34
- require 'fog/aws/requests/s3/get_request_payment'
35
- require 'fog/aws/requests/s3/get_service'
36
- require 'fog/aws/requests/s3/head_object'
37
- require 'fog/aws/requests/s3/put_bucket'
38
- require 'fog/aws/requests/s3/put_bucket_acl'
39
- require 'fog/aws/requests/s3/put_bucket_logging'
40
- require 'fog/aws/requests/s3/put_bucket_versioning'
41
- require 'fog/aws/requests/s3/put_object'
42
- require 'fog/aws/requests/s3/put_object_url'
43
- require 'fog/aws/requests/s3/put_request_payment'
44
- @required = true
45
- end
46
-
47
- if Fog.mocking?
48
- Fog::AWS::S3::Mock.new(options)
49
- else
50
- Fog::AWS::S3::Real.new(options)
51
- end
52
- end
39
+ module Utils
53
40
 
54
- def self.parse_data(data)
55
- metadata = {
56
- :body => nil,
57
- :headers => {}
58
- }
59
-
60
- if data.is_a?(String)
61
- metadata[:body] = data
62
- metadata[:headers]['Content-Length'] = metadata[:body].size.to_s
63
- else
64
- filename = ::File.basename(data.path)
65
- unless (mime_types = MIME::Types.of(filename)).empty?
66
- metadata[:headers]['Content-Type'] = mime_types.first.content_type
41
+ def parse_data(data)
42
+ metadata = {
43
+ :body => nil,
44
+ :headers => {}
45
+ }
46
+
47
+ if data.is_a?(String)
48
+ metadata[:body] = data
49
+ metadata[:headers]['Content-Length'] = metadata[:body].size.to_s
50
+ else
51
+ filename = ::File.basename(data.path)
52
+ unless (mime_types = MIME::Types.of(filename)).empty?
53
+ metadata[:headers]['Content-Type'] = mime_types.first.content_type
54
+ end
55
+ metadata[:body] = data
56
+ metadata[:headers]['Content-Length'] = ::File.size(data.path).to_s
67
57
  end
68
- metadata[:body] = data
69
- metadata[:headers]['Content-Length'] = ::File.size(data.path).to_s
58
+ # metadata[:headers]['Content-MD5'] = Base64.encode64(Digest::MD5.digest(metadata[:body])).strip
59
+ metadata
70
60
  end
71
- # metadata[:headers]['Content-MD5'] = Base64.encode64(Digest::MD5.digest(metadata[:body])).strip
72
- metadata
73
- end
74
61
 
75
- def self.reset_data(keys=Mock.data.keys)
76
- Mock.reset_data(keys)
77
- end
78
-
79
- module Utils
80
62
  def url(params, expires)
81
63
  params[:headers]['Date'] = expires.to_i
82
64
  query = [params[:query]].compact
@@ -85,9 +67,11 @@ module Fog
85
67
  query << "Expires=#{params[:headers]['Date']}"
86
68
  "http://#{params[:host]}/#{params[:path]}?#{query.join('&')}"
87
69
  end
70
+
88
71
  end
89
72
 
90
73
  class Mock
74
+ include Collections
91
75
  include Utils
92
76
 
93
77
  def self.data
@@ -115,7 +99,10 @@ module Fog
115
99
  end
116
100
 
117
101
  class Real
102
+ include Collections
118
103
  include Utils
104
+ extend Fog::Deprecation
105
+ deprecate(:reset, :reload)
119
106
 
120
107
  # Initialize connection to S3
121
108
  #
@@ -135,14 +122,10 @@ module Fog
135
122
  # ==== Returns
136
123
  # * S3 object with connection to aws.
137
124
  def initialize(options={})
138
- unless @aws_access_key_id = options[:aws_access_key_id]
139
- raise ArgumentError.new('aws_access_key_id is required to access ec2')
140
- end
141
- unless @aws_secret_access_key = options[:aws_secret_access_key]
142
- raise ArgumentError.new('aws_secret_access_key is required to access ec2')
143
- end
144
- @hmac = HMAC::SHA1.new(@aws_secret_access_key)
145
- @host = options[:host] || case options[:region]
125
+ @aws_access_key_id = options[:aws_access_key_id]
126
+ @aws_secret_access_key = options[:aws_secret_access_key]
127
+ @hmac = Fog::HMAC.new('sha1', @aws_secret_access_key)
128
+ @host = options[:host] || case options[:region]
146
129
  when 'ap-southeast-1'
147
130
  's3-ap-southeast-1.amazonaws.com'
148
131
  when 'us-west-1'
@@ -150,12 +133,12 @@ module Fog
150
133
  else
151
134
  's3.amazonaws.com'
152
135
  end
153
- @port = options[:port] || 443
154
- @scheme = options[:scheme] || 'https'
155
- reset
136
+ @port = options[:port] || 443
137
+ @scheme = options[:scheme] || 'https'
138
+ reload
156
139
  end
157
140
 
158
- def reset
141
+ def reload
159
142
  @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
160
143
  end
161
144
 
@@ -217,8 +200,8 @@ DATA
217
200
  canonical_resource.chop!
218
201
  string_to_sign << "#{canonical_resource}"
219
202
 
220
- hmac = @hmac.update(string_to_sign)
221
- signature = Base64.encode64(hmac.digest).chomp!
203
+ signed_string = @hmac.sign(string_to_sign)
204
+ signature = Base64.encode64(signed_string).chomp!
222
205
  end
223
206
  end
224
207
  end
@@ -1,38 +1,23 @@
1
1
  module Fog
2
2
  module AWS
3
3
  module SimpleDB
4
+ extend Fog::Service
4
5
 
5
- def self.new(options={})
6
-
7
- unless @required
8
- require 'fog/aws/parsers/simpledb/domain_metadata'
9
- require 'fog/aws/parsers/simpledb/get_attributes'
10
- require 'fog/aws/parsers/simpledb/list_domains'
11
- require 'fog/aws/parsers/simpledb/select'
12
- require 'fog/aws/requests/simpledb/batch_put_attributes'
13
- require 'fog/aws/requests/simpledb/create_domain'
14
- require 'fog/aws/requests/simpledb/delete_attributes'
15
- require 'fog/aws/requests/simpledb/delete_domain'
16
- require 'fog/aws/requests/simpledb/domain_metadata'
17
- require 'fog/aws/requests/simpledb/get_attributes'
18
- require 'fog/aws/requests/simpledb/list_domains'
19
- require 'fog/aws/requests/simpledb/put_attributes'
20
- require 'fog/aws/requests/simpledb/select'
21
- @required = true
22
- end
6
+ requires :aws_access_key_id, :aws_secret_access_key
23
7
 
24
- if Fog.mocking?
25
- Fog::AWS::SimpleDB::Mock.new(options)
26
- else
27
- Fog::AWS::SimpleDB::Real.new(options)
28
- end
29
- end
30
-
31
- def self.reset_data(keys=Mock.data.keys)
32
- Mock.reset_data(keys)
33
- end
8
+ request_path 'fog/aws/requests/simpledb'
9
+ request 'batch_put_attributes'
10
+ request 'create_domain'
11
+ request 'delete_attributes'
12
+ request 'delete_domain'
13
+ request 'domain_metadata'
14
+ request 'get_attributes'
15
+ request 'list_domains'
16
+ request 'put_attributes'
17
+ request 'select'
34
18
 
35
19
  class Mock
20
+ include Collections
36
21
 
37
22
  def self.data
38
23
  @data ||= Hash.new do |hash, key|
@@ -56,6 +41,7 @@ module Fog
56
41
  end
57
42
 
58
43
  class Real
44
+ include Collections
59
45
 
60
46
  # Initialize connection to SimpleDB
61
47
  #
@@ -77,7 +63,7 @@ module Fog
77
63
  def initialize(options={})
78
64
  @aws_access_key_id = options[:aws_access_key_id]
79
65
  @aws_secret_access_key = options[:aws_secret_access_key]
80
- @hmac = HMAC::SHA256.new(@aws_secret_access_key)
66
+ @hmac = Fog::HMAC.new('sha256', @aws_secret_access_key)
81
67
  @host = options[:host] || 'sdb.amazonaws.com'
82
68
  @nil_string = options[:nil_string]|| 'nil'
83
69
  @port = options[:port] || 443