fog 0.0.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.
Files changed (171) hide show
  1. data/.document +5 -0
  2. data/.gitignore +6 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +7 -0
  5. data/Rakefile +98 -0
  6. data/VERSION +1 -0
  7. data/benchs/fog_vs.rb +135 -0
  8. data/benchs/headers_split_vs_match.rb +18 -0
  9. data/benchs/params.rb +43 -0
  10. data/benchs/parse_vs_push.rb +60 -0
  11. data/benchs/stripping.rb +26 -0
  12. data/lib/fog.rb +21 -0
  13. data/lib/fog/aws.rb +145 -0
  14. data/lib/fog/aws/ec2.rb +173 -0
  15. data/lib/fog/aws/models/ec2/address.rb +31 -0
  16. data/lib/fog/aws/models/ec2/addresses.rb +36 -0
  17. data/lib/fog/aws/models/ec2/key_pair.rb +35 -0
  18. data/lib/fog/aws/models/ec2/key_pairs.rb +36 -0
  19. data/lib/fog/aws/models/ec2/volume.rb +47 -0
  20. data/lib/fog/aws/models/ec2/volumes.rb +36 -0
  21. data/lib/fog/aws/models/s3/bucket.rb +77 -0
  22. data/lib/fog/aws/models/s3/buckets.rb +83 -0
  23. data/lib/fog/aws/models/s3/object.rb +76 -0
  24. data/lib/fog/aws/models/s3/objects.rb +97 -0
  25. data/lib/fog/aws/models/s3/owner.rb +18 -0
  26. data/lib/fog/aws/parsers/ec2/allocate_address.rb +19 -0
  27. data/lib/fog/aws/parsers/ec2/attach_volume.rb +22 -0
  28. data/lib/fog/aws/parsers/ec2/basic.rb +25 -0
  29. data/lib/fog/aws/parsers/ec2/create_key_pair.rb +20 -0
  30. data/lib/fog/aws/parsers/ec2/create_snapshot.rb +22 -0
  31. data/lib/fog/aws/parsers/ec2/create_volume.rb +24 -0
  32. data/lib/fog/aws/parsers/ec2/describe_addresses.rb +30 -0
  33. data/lib/fog/aws/parsers/ec2/describe_availability_zones.rb +30 -0
  34. data/lib/fog/aws/parsers/ec2/describe_images.rb +49 -0
  35. data/lib/fog/aws/parsers/ec2/describe_instances.rb +73 -0
  36. data/lib/fog/aws/parsers/ec2/describe_key_pairs.rb +30 -0
  37. data/lib/fog/aws/parsers/ec2/describe_regions.rb +30 -0
  38. data/lib/fog/aws/parsers/ec2/describe_security_groups.rb +75 -0
  39. data/lib/fog/aws/parsers/ec2/describe_snapshots.rb +30 -0
  40. data/lib/fog/aws/parsers/ec2/describe_volumes.rb +57 -0
  41. data/lib/fog/aws/parsers/ec2/detach_volume.rb +22 -0
  42. data/lib/fog/aws/parsers/ec2/get_console_output.rb +28 -0
  43. data/lib/fog/aws/parsers/ec2/run_instances.rb +65 -0
  44. data/lib/fog/aws/parsers/ec2/terminate_instances.rb +55 -0
  45. data/lib/fog/aws/parsers/s3/copy_object.rb +22 -0
  46. data/lib/fog/aws/parsers/s3/get_bucket.rb +46 -0
  47. data/lib/fog/aws/parsers/s3/get_bucket_location.rb +20 -0
  48. data/lib/fog/aws/parsers/s3/get_request_payment.rb +20 -0
  49. data/lib/fog/aws/parsers/s3/get_service.rb +32 -0
  50. data/lib/fog/aws/parsers/simpledb/basic.rb +31 -0
  51. data/lib/fog/aws/parsers/simpledb/domain_metadata.rb +30 -0
  52. data/lib/fog/aws/parsers/simpledb/get_attributes.rb +34 -0
  53. data/lib/fog/aws/parsers/simpledb/list_domains.rb +28 -0
  54. data/lib/fog/aws/parsers/simpledb/select.rb +39 -0
  55. data/lib/fog/aws/requests/ec2/allocate_address.rb +50 -0
  56. data/lib/fog/aws/requests/ec2/associate_address.rb +59 -0
  57. data/lib/fog/aws/requests/ec2/attach_volume.rb +71 -0
  58. data/lib/fog/aws/requests/ec2/authorize_security_group_ingress.rb +32 -0
  59. data/lib/fog/aws/requests/ec2/create_key_pair.rb +60 -0
  60. data/lib/fog/aws/requests/ec2/create_security_group.rb +61 -0
  61. data/lib/fog/aws/requests/ec2/create_snapshot.rb +65 -0
  62. data/lib/fog/aws/requests/ec2/create_volume.rb +66 -0
  63. data/lib/fog/aws/requests/ec2/delete_key_pair.rb +49 -0
  64. data/lib/fog/aws/requests/ec2/delete_security_group.rb +52 -0
  65. data/lib/fog/aws/requests/ec2/delete_snapshot.rb +53 -0
  66. data/lib/fog/aws/requests/ec2/delete_volume.rb +55 -0
  67. data/lib/fog/aws/requests/ec2/describe_addresses.rb +61 -0
  68. data/lib/fog/aws/requests/ec2/describe_availability_zones.rb +64 -0
  69. data/lib/fog/aws/requests/ec2/describe_images.rb +41 -0
  70. data/lib/fog/aws/requests/ec2/describe_instances.rb +114 -0
  71. data/lib/fog/aws/requests/ec2/describe_key_pairs.rb +63 -0
  72. data/lib/fog/aws/requests/ec2/describe_regions.rb +61 -0
  73. data/lib/fog/aws/requests/ec2/describe_security_groups.rb +71 -0
  74. data/lib/fog/aws/requests/ec2/describe_snapshots.rb +78 -0
  75. data/lib/fog/aws/requests/ec2/describe_volumes.rb +85 -0
  76. data/lib/fog/aws/requests/ec2/detach_volume.rb +62 -0
  77. data/lib/fog/aws/requests/ec2/disassociate_address.rb +55 -0
  78. data/lib/fog/aws/requests/ec2/get_console_output.rb +26 -0
  79. data/lib/fog/aws/requests/ec2/reboot_instances.rb +24 -0
  80. data/lib/fog/aws/requests/ec2/release_address.rb +50 -0
  81. data/lib/fog/aws/requests/ec2/revoke_security_group_ingress.rb +32 -0
  82. data/lib/fog/aws/requests/ec2/run_instances.rb +134 -0
  83. data/lib/fog/aws/requests/ec2/terminate_instances.rb +80 -0
  84. data/lib/fog/aws/requests/s3/copy_object.rb +79 -0
  85. data/lib/fog/aws/requests/s3/delete_bucket.rb +53 -0
  86. data/lib/fog/aws/requests/s3/delete_object.rb +52 -0
  87. data/lib/fog/aws/requests/s3/get_bucket.rb +100 -0
  88. data/lib/fog/aws/requests/s3/get_bucket_location.rb +53 -0
  89. data/lib/fog/aws/requests/s3/get_object.rb +82 -0
  90. data/lib/fog/aws/requests/s3/get_request_payment.rb +53 -0
  91. data/lib/fog/aws/requests/s3/get_service.rb +58 -0
  92. data/lib/fog/aws/requests/s3/head_object.rb +61 -0
  93. data/lib/fog/aws/requests/s3/put_bucket.rb +69 -0
  94. data/lib/fog/aws/requests/s3/put_object.rb +76 -0
  95. data/lib/fog/aws/requests/s3/put_request_payment.rb +56 -0
  96. data/lib/fog/aws/requests/simpledb/batch_put_attributes.rb +31 -0
  97. data/lib/fog/aws/requests/simpledb/create_domain.rb +25 -0
  98. data/lib/fog/aws/requests/simpledb/delete_attributes.rb +34 -0
  99. data/lib/fog/aws/requests/simpledb/delete_domain.rb +25 -0
  100. data/lib/fog/aws/requests/simpledb/domain_metadata.rb +30 -0
  101. data/lib/fog/aws/requests/simpledb/get_attributes.rb +35 -0
  102. data/lib/fog/aws/requests/simpledb/list_domains.rb +30 -0
  103. data/lib/fog/aws/requests/simpledb/put_attributes.rb +29 -0
  104. data/lib/fog/aws/requests/simpledb/select.rb +29 -0
  105. data/lib/fog/aws/s3.rb +157 -0
  106. data/lib/fog/aws/simpledb.rb +157 -0
  107. data/lib/fog/collection.rb +77 -0
  108. data/lib/fog/connection.rb +130 -0
  109. data/lib/fog/errors.rb +145 -0
  110. data/lib/fog/model.rb +72 -0
  111. data/lib/fog/parser.rb +30 -0
  112. data/lib/fog/response.rb +12 -0
  113. data/spec/aws/models/s3/bucket_spec.rb +130 -0
  114. data/spec/aws/models/s3/buckets_spec.rb +79 -0
  115. data/spec/aws/models/s3/object_spec.rb +121 -0
  116. data/spec/aws/models/s3/objects_spec.rb +112 -0
  117. data/spec/aws/models/s3/owner_spec.rb +18 -0
  118. data/spec/aws/requests/ec2/allocate_address_spec.rb +18 -0
  119. data/spec/aws/requests/ec2/associate_address_spec.rb +42 -0
  120. data/spec/aws/requests/ec2/attach_volume_spec.rb +53 -0
  121. data/spec/aws/requests/ec2/authorize_security_group_ingress_spec.rb +26 -0
  122. data/spec/aws/requests/ec2/create_key_pair_spec.rb +36 -0
  123. data/spec/aws/requests/ec2/create_security_group_spec.rb +34 -0
  124. data/spec/aws/requests/ec2/create_snapshot_spec.rb +37 -0
  125. data/spec/aws/requests/ec2/create_volume_spec.rb +23 -0
  126. data/spec/aws/requests/ec2/delete_key_pair_spec.rb +21 -0
  127. data/spec/aws/requests/ec2/delete_security_group_spec.rb +26 -0
  128. data/spec/aws/requests/ec2/delete_snapshot_spec.rb +35 -0
  129. data/spec/aws/requests/ec2/delete_volume_spec.rb +26 -0
  130. data/spec/aws/requests/ec2/describe_addresses_spec.rb +38 -0
  131. data/spec/aws/requests/ec2/describe_availability_zones_spec.rb +23 -0
  132. data/spec/aws/requests/ec2/describe_images_spec.rb +39 -0
  133. data/spec/aws/requests/ec2/describe_instances_spec.rb +86 -0
  134. data/spec/aws/requests/ec2/describe_key_pairs_spec.rb +42 -0
  135. data/spec/aws/requests/ec2/describe_regions_spec.rb +21 -0
  136. data/spec/aws/requests/ec2/describe_security_groups_spec.rb +51 -0
  137. data/spec/aws/requests/ec2/describe_snapshots_spec.rb +54 -0
  138. data/spec/aws/requests/ec2/describe_volumes_spec.rb +50 -0
  139. data/spec/aws/requests/ec2/detach_volume_spec.rb +43 -0
  140. data/spec/aws/requests/ec2/disassociate_address_spec.rb +35 -0
  141. data/spec/aws/requests/ec2/get_console_output_spec.rb +23 -0
  142. data/spec/aws/requests/ec2/reboot_instances_spec.rb +21 -0
  143. data/spec/aws/requests/ec2/release_address_spec.rb +26 -0
  144. data/spec/aws/requests/ec2/revoke_security_group_ingress_spec.rb +32 -0
  145. data/spec/aws/requests/ec2/run_instances_spec.rb +41 -0
  146. data/spec/aws/requests/ec2/terminate_instances_spec.rb +35 -0
  147. data/spec/aws/requests/s3/copy_object_spec.rb +62 -0
  148. data/spec/aws/requests/s3/delete_bucket_spec.rb +36 -0
  149. data/spec/aws/requests/s3/delete_object_spec.rb +37 -0
  150. data/spec/aws/requests/s3/get_bucket_location_spec.rb +30 -0
  151. data/spec/aws/requests/s3/get_bucket_spec.rb +110 -0
  152. data/spec/aws/requests/s3/get_object_spec.rb +45 -0
  153. data/spec/aws/requests/s3/get_request_payment_spec.rb +30 -0
  154. data/spec/aws/requests/s3/get_service_spec.rb +33 -0
  155. data/spec/aws/requests/s3/head_object_spec.rb +28 -0
  156. data/spec/aws/requests/s3/put_bucket_spec.rb +19 -0
  157. data/spec/aws/requests/s3/put_object_spec.rb +38 -0
  158. data/spec/aws/requests/s3/put_request_payment_spec.rb +29 -0
  159. data/spec/aws/requests/simpledb/batch_put_attributes_spec.rb +22 -0
  160. data/spec/aws/requests/simpledb/create_domain_spec.rb +21 -0
  161. data/spec/aws/requests/simpledb/delete_attributes_spec.rb +22 -0
  162. data/spec/aws/requests/simpledb/delete_domain_spec.rb +21 -0
  163. data/spec/aws/requests/simpledb/domain_metadata_spec.rb +43 -0
  164. data/spec/aws/requests/simpledb/get_attributes_spec.rb +31 -0
  165. data/spec/aws/requests/simpledb/list_domains_spec.rb +30 -0
  166. data/spec/aws/requests/simpledb/put_attributes_spec.rb +22 -0
  167. data/spec/aws/requests/simpledb/select_spec.rb +9 -0
  168. data/spec/lorem.txt +1 -0
  169. data/spec/spec.opts +1 -0
  170. data/spec/spec_helper.rb +66 -0
  171. metadata +309 -0
@@ -0,0 +1,58 @@
1
+ unless Fog.mocking?
2
+
3
+ module Fog
4
+ module AWS
5
+ class S3
6
+
7
+ # List information about S3 buckets for authorized user
8
+ #
9
+ # ==== Returns
10
+ # * response<~Fog::AWS::Response>:
11
+ # * body<~Hash>:
12
+ # * 'Buckets'<~Hash>:
13
+ # * 'Name'<~String> - Name of bucket
14
+ # * 'CreationTime'<~Time> - Timestamp of bucket creation
15
+ # * 'Owner'<~Hash>:
16
+ # * 'DisplayName'<~String> - Display name of bucket owner
17
+ # * 'ID'<~String> - Id of bucket owner
18
+ def get_service
19
+ request({
20
+ :expects => 200,
21
+ :headers => {},
22
+ :host => @host,
23
+ :method => 'GET',
24
+ :parser => Fog::Parsers::AWS::S3::GetService.new,
25
+ :url => @host
26
+ })
27
+ end
28
+
29
+ end
30
+ end
31
+ end
32
+
33
+ else
34
+
35
+ module Fog
36
+ module AWS
37
+ class S3
38
+
39
+ def get_service
40
+ response = Fog::Response.new
41
+ response.headers['Status'] = 200
42
+ buckets = Fog::AWS::S3.data[:buckets].values.map do |bucket|
43
+ bucket.reject do |key, value|
44
+ !['CreationDate', 'Name'].include?(key)
45
+ end
46
+ end
47
+ response.body = {
48
+ 'Buckets' => buckets,
49
+ 'Owner' => { 'DisplayName' => 'owner', 'ID' => 'some_id'}
50
+ }
51
+ response
52
+ end
53
+
54
+ end
55
+ end
56
+ end
57
+
58
+ end
@@ -0,0 +1,61 @@
1
+ unless Fog.mocking?
2
+
3
+ module Fog
4
+ module AWS
5
+ class S3
6
+
7
+ # Get headers for an object from S3
8
+ #
9
+ # ==== Parameters
10
+ # * bucket_name<~String> - Name of bucket to read from
11
+ # * object_name<~String> - Name of object to read
12
+ # * options<~Hash>:
13
+ # * 'If-Match'<~String> - Returns object only if its etag matches this value, otherwise returns 412 (Precondition Failed).
14
+ # * 'If-Modified-Since'<~Time> - Returns object only if it has been modified since this time, otherwise returns 304 (Not Modified).
15
+ # * 'If-None-Match'<~String> - Returns object only if its etag differs from this value, otherwise returns 304 (Not Modified)
16
+ # * 'If-Unmodified-Since'<~Time> - Returns object only if it has not been modified since this time, otherwise returns 412 (Precodition Failed).
17
+ # * 'Range'<~String> - Range of object to download
18
+ #
19
+ # ==== Returns
20
+ # * response<~Fog::AWS::Response>:
21
+ # * body<~String> - Contents of object
22
+ # * headers<~Hash>:
23
+ # * 'Content-Length'<~String> - Size of object contents
24
+ # * 'Content-Type'<~String> - MIME type of object
25
+ # * 'ETag'<~String> - Etag of object
26
+ # * 'Last-Modified'<~String> - Last modified timestamp for object
27
+ def head_object(bucket_name, object_name, options={})
28
+ headers = {}
29
+ headers['If-Modified-Since'] = options['If-Modified-Since'].utc.strftime("%a, %d %b %Y %H:%M:%S +0000") if options['If-Modified-Since']
30
+ headers['If-Unmodified-Since'] = options['If-Unmodified-Since'].utc.strftime("%a, %d %b %Y %H:%M:%S +0000") if options['If-Modified-Since']
31
+ headers.merge!(options)
32
+ request({
33
+ :expects => 200,
34
+ :headers => headers,
35
+ :host => "#{bucket_name}.#{@host}",
36
+ :method => 'HEAD',
37
+ :path => object_name
38
+ })
39
+ end
40
+
41
+ end
42
+ end
43
+ end
44
+
45
+ else
46
+
47
+ module Fog
48
+ module AWS
49
+ class S3
50
+
51
+ def head_object(bucket_name, object_name, options = {})
52
+ response = get_object(bucket_name, object_name, options)
53
+ response.body = nil
54
+ response
55
+ end
56
+
57
+ end
58
+ end
59
+ end
60
+
61
+ end
@@ -0,0 +1,69 @@
1
+ unless Fog.mocking?
2
+
3
+ module Fog
4
+ module AWS
5
+ class S3
6
+
7
+ # Create an S3 bucket
8
+ #
9
+ # ==== Parameters
10
+ # * bucket_name<~String> - name of bucket to create
11
+ # * options<~Hash> - config arguments for bucket. Defaults to {}.
12
+ # * :location_constraint<~Symbol> - sets the location for the bucket
13
+ #
14
+ # ==== Returns
15
+ # * response<~Fog::AWS::Response>:
16
+ # * status<~Integer> - 200
17
+ def put_bucket(bucket_name, options = {})
18
+ if options['LocationConstraint']
19
+ data =
20
+ <<-DATA
21
+ <CreateBucketConfiguration>
22
+ <LocationConstraint>#{options['LocationConstraint']}</LocationConstraint>
23
+ </CreateBucketConfiguration>
24
+ DATA
25
+ else
26
+ data = nil
27
+ end
28
+ request({
29
+ :expects => 200,
30
+ :body => data,
31
+ :headers => {},
32
+ :host => "#{bucket_name}.#{@host}",
33
+ :method => 'PUT'
34
+ })
35
+ end
36
+
37
+ end
38
+ end
39
+ end
40
+
41
+ else
42
+
43
+ module Fog
44
+ module AWS
45
+ class S3
46
+
47
+ def put_bucket(bucket_name, options = {})
48
+ response = Fog::Response.new
49
+ response.status = 200
50
+ bucket = {
51
+ :objects => {},
52
+ 'Name' => bucket_name,
53
+ 'CreationDate' => Time.now,
54
+ 'Payer' => 'BucketOwner'
55
+ }
56
+ if options['LocationConstraint']
57
+ bucket['LocationConstraint'] = options['LocationConstraint']
58
+ else
59
+ bucket['LocationConstraint'] = ''
60
+ end
61
+ Fog::AWS::S3.data[:buckets][bucket_name] = bucket
62
+ response
63
+ end
64
+
65
+ end
66
+ end
67
+ end
68
+
69
+ end
@@ -0,0 +1,76 @@
1
+ unless Fog.mocking?
2
+
3
+ module Fog
4
+ module AWS
5
+ class S3
6
+
7
+ # Create an object in an S3 bucket
8
+ #
9
+ # ==== Parameters
10
+ # * bucket_name<~String> - Name of bucket to create object in
11
+ # * object_name<~String> - Name of object to create
12
+ # * object<~String> - File to create object from
13
+ # * options<~Hash>:
14
+ # * 'Cache-Control'<~String> - Caching behaviour
15
+ # * 'Content-Disposition'<~String> - Presentational information for the object
16
+ # * 'Content-Encoding'<~String> - Encoding of object data
17
+ # * 'Content-Length'<~String> - Size of object in bytes (defaults to object.read.length)
18
+ # * 'Content-MD5'<~String> - Base64 encoded 128-bit MD5 digest of message (defaults to Base64 encoded MD5 of object.read)
19
+ # * 'Content-Type'<~String> - Standard MIME type describing contents (defaults to MIME::Types.of.first)
20
+ # * 'x-amz-acl'<~String> - Permissions, must be in ['private', 'public-read', 'public-read-write', 'authenticated-read']
21
+ # * "x-amz-meta-#{name}" - Headers to be returned with object, note total size of request without body must be less than 8 KB.
22
+ #
23
+ # ==== Returns
24
+ # * response<~Fog::AWS::Response>:
25
+ # * headers<~Hash>:
26
+ # * 'ETag'<~String> - etag of new object
27
+ def put_object(bucket_name, object_name, object, options = {})
28
+ file = parse_file(object)
29
+ headers = file[:headers].merge!(options)
30
+ request({
31
+ :body => file[:body],
32
+ :expects => 200,
33
+ :headers => headers,
34
+ :host => "#{bucket_name}.#{@host}",
35
+ :method => 'PUT',
36
+ :path => object_name
37
+ })
38
+ end
39
+
40
+ end
41
+ end
42
+ end
43
+
44
+ else
45
+
46
+ module Fog
47
+ module AWS
48
+ class S3
49
+
50
+ def put_object(bucket_name, object_name, object, options = {})
51
+ file = parse_file(object)
52
+ response = Fog::Response.new
53
+ if (bucket = Fog::AWS::S3.data[:buckets][bucket_name])
54
+ response.status = 200
55
+ bucket[:objects][object_name] = {
56
+ :body => file[:body],
57
+ 'Content-Type' => file[:headers]['Content-Type'],
58
+ 'ETag' => Fog::AWS::Mock.etag,
59
+ 'Key' => object_name,
60
+ 'LastModified' => Time.now.utc.strftime("%a, %d %b %Y %H:%M:%S +0000"),
61
+ 'Owner' => { 'DisplayName' => 'owner', 'ID' => 'some_id'},
62
+ 'Size' => file[:headers]['Content-Length'],
63
+ 'StorageClass' => 'STANDARD'
64
+ }
65
+ else
66
+ response.status = 404
67
+ raise(Fog::Errors.status_error(200, 404, response))
68
+ end
69
+ response
70
+ end
71
+
72
+ end
73
+ end
74
+ end
75
+
76
+ end
@@ -0,0 +1,56 @@
1
+ unless Fog.mocking?
2
+
3
+ module Fog
4
+ module AWS
5
+ class S3
6
+
7
+ # Change who pays for requests to an S3 bucket
8
+ #
9
+ # ==== Parameters
10
+ # * bucket_name<~String> - name of bucket to modify
11
+ # * payer<~String> - valid values are BucketOwner or Requester
12
+ def put_request_payment(bucket_name, payer)
13
+ data =
14
+ <<-DATA
15
+ <RequestPaymentConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
16
+ <Payer>#{payer}</Payer>
17
+ </RequestPaymentConfiguration>
18
+ DATA
19
+ request({
20
+ :body => data,
21
+ :expects => 200,
22
+ :headers => {},
23
+ :host => "#{bucket_name}.#{@host}",
24
+ :method => 'PUT',
25
+ :query => "requestPayment"
26
+ })
27
+ end
28
+
29
+ end
30
+ end
31
+ end
32
+
33
+ else
34
+
35
+ module Fog
36
+ module AWS
37
+ class S3
38
+
39
+ def put_request_payment(bucket_name, payer)
40
+ response = Fog::Response.new
41
+ if bucket = Fog::AWS::S3.data[:buckets][bucket_name]
42
+ response.status = 200
43
+ bucket['Payer'] = payer
44
+ else
45
+ response.status = 404
46
+ raise(Fog::Errors.status_error(200, 404, response))
47
+ end
48
+ response
49
+ end
50
+
51
+ end
52
+ end
53
+ end
54
+
55
+
56
+ end
@@ -0,0 +1,31 @@
1
+ module Fog
2
+ module AWS
3
+ class SimpleDB
4
+
5
+ # Put items attributes into a SimpleDB domain
6
+ #
7
+ # ==== Parameters
8
+ # * domain_name<~String> - Name of domain. Must be between 3 and 255 of the
9
+ # following characters: a-z, A-Z, 0-9, '_', '-' and '.'.
10
+ # * items<~Hash> - Keys are the items names and may use any UTF-8
11
+ # characters valid in xml. Control characters and sequences not allowed
12
+ # in xml are not valid. Can be up to 1024 bytes long. Values are the
13
+ # attributes to add to the given item and may use any UTF-8 characters
14
+ # valid in xml. Control characters and sequences not allowed in xml are
15
+ # not valid. Each name and value can be up to 1024 bytes long.
16
+ #
17
+ # ==== Returns
18
+ # * response<~Fog::AWS::Response>:
19
+ # * body<~Hash>:
20
+ # * 'BoxUsage'
21
+ # * 'RequestId'
22
+ def batch_put_attributes(domain_name, items, replace_attributes = Hash.new([]))
23
+ request({
24
+ 'Action' => 'BatchPutAttributes',
25
+ 'DomainName' => domain_name
26
+ }.merge!(encode_batch_attributes(items, replace_attributes)), Fog::Parsers::AWS::SimpleDB::Basic.new(@nil_string))
27
+ end
28
+
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,25 @@
1
+ module Fog
2
+ module AWS
3
+ class SimpleDB
4
+
5
+ # Create a SimpleDB domain
6
+ #
7
+ # ==== Parameters
8
+ # * domain_name<~String>:: Name of domain. Must be between 3 and 255 of the
9
+ # following characters: a-z, A-Z, 0-9, '_', '-' and '.'.
10
+ #
11
+ # ==== Returns
12
+ # * response<~Fog::AWS::Response>:
13
+ # * body<~Hash>:
14
+ # * 'BoxUsage'
15
+ # * 'RequestId'
16
+ def create_domain(domain_name)
17
+ request({
18
+ 'Action' => 'CreateDomain',
19
+ 'DomainName' => domain_name
20
+ }, Fog::Parsers::AWS::SimpleDB::Basic.new(@nil_string))
21
+ end
22
+
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,34 @@
1
+ module Fog
2
+ module AWS
3
+ class SimpleDB
4
+
5
+ # List metadata for SimpleDB domain
6
+ #
7
+ # ==== Parameters
8
+ # * domain_name<~String> - Name of domain. Must be between 3 and 255 of the
9
+ # following characters: a-z, A-Z, 0-9, '_', '-' and '.'.
10
+ # * item_name<~String> - Name of the item. May use any UTF-8 characters valid
11
+ # in xml. Control characters and sequences not allowed in xml are not
12
+ # valid. Can be up to 1024 bytes long.
13
+ # * attributes<~Hash> - Name/value pairs to remove from the item. Defaults to
14
+ # nil, which will delete the entire item. Attribute names and values may
15
+ # use any UTF-8 characters valid in xml. Control characters and sequences
16
+ # not allowed in xml are not valid. Each name and value can be up to 1024
17
+ # bytes long.
18
+ #
19
+ # ==== Returns
20
+ # * response<~Fog::AWS::Response>:
21
+ # * body<~Hash>:
22
+ # * 'BoxUsage'
23
+ # * 'RequestId'
24
+ def delete_attributes(domain_name, item_name, attributes = nil)
25
+ request({
26
+ 'Action' => 'DeleteAttributes',
27
+ 'DomainName' => domain_name,
28
+ 'ItemName' => item_name
29
+ }.merge!(encode_attributes(attributes)), Fog::Parsers::AWS::SimpleDB::Basic.new(@nil_string))
30
+ end
31
+
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,25 @@
1
+ module Fog
2
+ module AWS
3
+ class SimpleDB
4
+
5
+ # Delete a SimpleDB domain
6
+ #
7
+ # ==== Parameters
8
+ # * domain_name<~String>:: Name of domain. Must be between 3 and 255 of the
9
+ # following characters: a-z, A-Z, 0-9, '_', '-' and '.'.
10
+ #
11
+ # ==== Returns
12
+ # * response<~Fog::AWS::Response>:
13
+ # * body<~Hash>:
14
+ # * 'BoxUsage'
15
+ # * 'RequestId'
16
+ def delete_domain(domain_name)
17
+ request({
18
+ 'Action' => 'DeleteDomain',
19
+ 'DomainName' => domain_name
20
+ }, Fog::Parsers::AWS::SimpleDB::Basic.new(@nil_string))
21
+ end
22
+
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,30 @@
1
+ module Fog
2
+ module AWS
3
+ class SimpleDB
4
+
5
+ # List metadata for SimpleDB domain
6
+ #
7
+ # ==== Parameters
8
+ # * domain_name<~String> - Name of domain. Must be between 3 and 255 of the
9
+ # following characters: a-z, A-Z, 0-9, '_', '-' and '.'.
10
+ #
11
+ # ==== Returns
12
+ # * response<~Fog::AWS::Response>:
13
+ # * body<~Hash>:
14
+ # * 'AttributeNameCount' - number of unique attribute names in domain
15
+ # * 'AttributeNamesSizeBytes' - total size of unique attribute names, in bytes
16
+ # * 'AttributeValueCount' - number of all name/value pairs in domain
17
+ # * 'AttributeValuesSizeBytes' - total size of attributes, in bytes
18
+ # * 'ItemCount' - number of items in domain
19
+ # * 'ItemNameSizeBytes' - total size of item names in domain, in bytes
20
+ # * 'Timestamp' - last update time for metadata.
21
+ def domain_metadata(domain_name)
22
+ request({
23
+ 'Action' => 'DomainMetadata',
24
+ 'DomainName' => domain_name
25
+ }, Fog::Parsers::AWS::SimpleDB::DomainMetadata.new(@nil_string))
26
+ end
27
+
28
+ end
29
+ end
30
+ end