right_aws 1.9.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. data/History.txt +164 -13
  2. data/Manifest.txt +28 -1
  3. data/README.txt +12 -10
  4. data/Rakefile +56 -29
  5. data/lib/acf/right_acf_interface.rb +343 -172
  6. data/lib/acf/right_acf_invalidations.rb +144 -0
  7. data/lib/acf/right_acf_origin_access_identities.rb +230 -0
  8. data/lib/acf/right_acf_streaming_interface.rb +229 -0
  9. data/lib/acw/right_acw_interface.rb +248 -0
  10. data/lib/as/right_as_interface.rb +698 -0
  11. data/lib/awsbase/right_awsbase.rb +755 -115
  12. data/lib/awsbase/support.rb +2 -78
  13. data/lib/awsbase/version.rb +9 -0
  14. data/lib/ec2/right_ec2.rb +274 -1294
  15. data/lib/ec2/right_ec2_ebs.rb +514 -0
  16. data/lib/ec2/right_ec2_images.rb +444 -0
  17. data/lib/ec2/right_ec2_instances.rb +797 -0
  18. data/lib/ec2/right_ec2_monitoring.rb +70 -0
  19. data/lib/ec2/right_ec2_placement_groups.rb +108 -0
  20. data/lib/ec2/right_ec2_reserved_instances.rb +243 -0
  21. data/lib/ec2/right_ec2_security_groups.rb +496 -0
  22. data/lib/ec2/right_ec2_spot_instances.rb +422 -0
  23. data/lib/ec2/right_ec2_tags.rb +139 -0
  24. data/lib/ec2/right_ec2_vpc.rb +598 -0
  25. data/lib/ec2/right_ec2_vpc2.rb +382 -0
  26. data/lib/ec2/right_ec2_windows_mobility.rb +84 -0
  27. data/lib/elb/right_elb_interface.rb +573 -0
  28. data/lib/emr/right_emr_interface.rb +728 -0
  29. data/lib/iam/right_iam_access_keys.rb +71 -0
  30. data/lib/iam/right_iam_groups.rb +195 -0
  31. data/lib/iam/right_iam_interface.rb +341 -0
  32. data/lib/iam/right_iam_mfa_devices.rb +67 -0
  33. data/lib/iam/right_iam_users.rb +251 -0
  34. data/lib/rds/right_rds_interface.rb +1657 -0
  35. data/lib/right_aws.rb +30 -13
  36. data/lib/route_53/right_route_53_interface.rb +641 -0
  37. data/lib/s3/right_s3.rb +108 -41
  38. data/lib/s3/right_s3_interface.rb +349 -118
  39. data/lib/sdb/active_sdb.rb +388 -54
  40. data/lib/sdb/right_sdb_interface.rb +323 -64
  41. data/lib/sns/right_sns_interface.rb +286 -0
  42. data/lib/sqs/right_sqs.rb +1 -2
  43. data/lib/sqs/right_sqs_gen2.rb +73 -17
  44. data/lib/sqs/right_sqs_gen2_interface.rb +146 -73
  45. data/lib/sqs/right_sqs_interface.rb +12 -22
  46. data/right_aws.gemspec +91 -0
  47. data/test/README.mdown +39 -0
  48. data/test/acf/test_right_acf.rb +11 -19
  49. data/test/awsbase/test_helper.rb +2 -0
  50. data/test/awsbase/test_right_awsbase.rb +11 -0
  51. data/test/ec2/test_right_ec2.rb +32 -1
  52. data/test/elb/test_helper.rb +2 -0
  53. data/test/elb/test_right_elb.rb +43 -0
  54. data/test/rds/test_helper.rb +2 -0
  55. data/test/rds/test_right_rds.rb +120 -0
  56. data/test/route_53/fixtures/a_record.xml +18 -0
  57. data/test/route_53/fixtures/alias_record.xml +18 -0
  58. data/test/route_53/test_helper.rb +2 -0
  59. data/test/route_53/test_right_route_53.rb +141 -0
  60. data/test/s3/test_right_s3.rb +176 -42
  61. data/test/s3/test_right_s3_stubbed.rb +6 -4
  62. data/test/sdb/test_active_sdb.rb +120 -19
  63. data/test/sdb/test_batch_put_attributes.rb +54 -0
  64. data/test/sdb/test_right_sdb.rb +71 -16
  65. data/test/sns/test_helper.rb +2 -0
  66. data/test/sns/test_right_sns.rb +153 -0
  67. data/test/sqs/test_right_sqs.rb +0 -6
  68. data/test/sqs/test_right_sqs_gen2.rb +104 -49
  69. data/test/ts_right_aws.rb +1 -0
  70. metadata +181 -22
@@ -0,0 +1,286 @@
1
+ #
2
+ # Copyright (c) 2007-2008 RightScale Inc
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #
23
+
24
+ module RightAws
25
+ class SnsInterface < RightAwsBase
26
+ include RightAwsBaseInterface
27
+
28
+ DEFAULT_HOST = 'sns.us-east-1.amazonaws.com'
29
+ DEFAULT_PORT = 443
30
+ DEFAULT_PROTOCOL = 'https'
31
+ DEFAULT_SERVICE = '/'
32
+ REQUEST_TTL = 30
33
+
34
+ # Apparently boilerplate stuff
35
+ @@bench = AwsBenchmarkingBlock.new
36
+ def self.bench_xml
37
+ @@bench.xml
38
+ end
39
+ def self.bench_service
40
+ @@bench.service
41
+ end
42
+
43
+ def initialize(aws_access_key_id=nil, aws_secret_access_key=nil, params={})
44
+ if params[:region]
45
+ server = "sns.#{params[:region]}.amazonaws.com"
46
+ params.delete(:region)
47
+ else
48
+ server = DEFAULT_HOST
49
+ end
50
+ init({ :name => 'SNS',
51
+ :default_host => ENV['SNS_URL'] ? URI.parse(ENV['SNS_URL']).host : server,
52
+ :default_port => ENV['SNS_URL'] ? URI.parse(ENV['SNS_URL']).port : DEFAULT_PORT,
53
+ :default_service => ENV['SNS_URL'] ? URI.parse(ENV['SNS_URL']).path : DEFAULT_SERVICE,
54
+ :default_protocol => ENV['SNS_URL'] ? URI.parse(ENV['SNS_URL']).scheme : DEFAULT_PROTOCOL},
55
+ aws_access_key_id || ENV['AWS_ACCESS_KEY_ID'],
56
+ aws_secret_access_key || ENV['AWS_SECRET_ACCESS_KEY'],
57
+ params)
58
+ end
59
+
60
+ # TODO: RJG - Seems like generate_request and generate_rest_request could be in a sub class?
61
+ # Generates a request hash for the sns API
62
+ def generate_request(action, params={}) # :nodoc:
63
+ # Sometimes we need to use queue uri (delete queue etc)
64
+ # In that case we will use Symbol key: 'param[:queue_url]'
65
+ service = params[:sns_url] ? URI(params[:sns_url]).path : '/'
66
+ # remove unset(=optional) and symbolyc keys
67
+ params.each{ |key, value| params.delete(key) if (value.nil? || key.is_a?(Symbol)) }
68
+ # prepare output hash
69
+ service_hash = { "Action" => action,
70
+ "Expires" => (Time.now + REQUEST_TTL).utc.strftime("%Y-%m-%dT%H:%M:%SZ"),
71
+ "AWSAccessKeyId" => @aws_access_key_id }
72
+ #"Version" => API_VERSION }
73
+ service_hash.update(params)
74
+ service_params = signed_service_params(@aws_secret_access_key, service_hash, :get, @params[:server], service)
75
+ request = Net::HTTP::Get.new("#{AwsUtils::URLencode(service)}?#{service_params}")
76
+ # prepare output hash
77
+ { :request => request,
78
+ :server => @params[:server],
79
+ :port => @params[:port],
80
+ :protocol => @params[:protocol] }
81
+ end
82
+
83
+ # Generates a request hash for the REST API
84
+ def generate_rest_request(method, param) # :nodoc:
85
+ sns_uri = param[:sns_url] ? URI(param[:sns_url]).path : '/'
86
+ message = param[:message] # extract message body if nesessary
87
+ # remove unset(=optional) and symbolyc keys
88
+ param.each{ |key, value| param.delete(key) if (value.nil? || key.is_a?(Symbol)) }
89
+ # created request
90
+ param_to_str = param.to_a.collect{|key,val| key.to_s + "=" + CGI::escape(val.to_s) }.join("&")
91
+ param_to_str = "?#{param_to_str}" unless param_to_str.right_blank?
92
+ request = "Net::HTTP::#{method.capitalize}".right_constantize.new("#{sns_uri}#{param_to_str}")
93
+ request.body = message if message
94
+ # set main headers
95
+ request['content-md5'] = ''
96
+ request['Content-Type'] = 'text/plain'
97
+ request['Date'] = Time.now.httpdate
98
+ # generate authorization string
99
+ auth_string = "#{method.upcase}\n#{request['content-md5']}\n#{request['Content-Type']}\n#{request['Date']}\n#{CGI::unescape(sns_uri)}"
100
+ signature = AwsUtils::sign(@aws_secret_access_key, auth_string)
101
+ # set other headers
102
+ request['Authorization'] = "AWS #{@aws_access_key_id}:#{signature}"
103
+ #request['AWS-Version'] = API_VERSION
104
+ # prepare output hash
105
+ { :request => request,
106
+ :server => @params[:server],
107
+ :port => @params[:port],
108
+ :protocol => @params[:protocol] }
109
+ end
110
+
111
+ # Sends request to Amazon and parses the response
112
+ # Raises AwsError if any banana happened
113
+ def request_info(request, parser) # :nodoc:
114
+ request_info_impl(:sns_connection, @@bench, request, parser)
115
+ end
116
+
117
+ def create_topic(topic_name)
118
+ req_hash = generate_request('CreateTopic', 'Name' => topic_name)
119
+ request_info(req_hash, SnsCreateTopicParser.new)
120
+ end
121
+
122
+ def list_topics()
123
+ req_hash = generate_request('ListTopics')
124
+ request_info(req_hash, SnsListTopicsParser.new)
125
+ end
126
+
127
+ def delete_topic(topic_arn)
128
+ req_hash = generate_request('DeleteTopic', 'TopicArn' => topic_arn)
129
+ request_info(req_hash, RightHttp2xxParser.new)
130
+ end
131
+
132
+ def subscribe(topic_arn, protocol, endpoint)
133
+ req_hash = generate_request('Subscribe', 'TopicArn' => topic_arn, 'Protocol' => protocol, 'Endpoint' => endpoint)
134
+ request_info(req_hash, SnsSubscribeParser.new)
135
+ end
136
+
137
+ def unsubscribe(subscription_arn)
138
+ req_hash = generate_request('Unsubscribe', 'SubscriptionArn' => subscription_arn)
139
+ request_info(req_hash, RightHttp2xxParser.new)
140
+ end
141
+
142
+ def publish(topic_arn, message, subject)
143
+ req_hash = generate_request('Publish', 'TopicArn' => topic_arn, 'Message' => message, 'Subject' => subject)
144
+ request_info(req_hash, SnsPublishParser.new)
145
+ end
146
+
147
+ def set_topic_attribute(topic_arn, attribute_name, attribute_value)
148
+ if attribute_name != 'Policy' && attribute_name != 'DisplayName'
149
+ raise(ArgumentError, "The only values accepted for the attribute_name parameter are (Policy, DisplayName)")
150
+ end
151
+ req_hash = generate_request('SetTopicAttributes', 'TopicArn' => topic_arn, 'AttributeName' => attribute_name, 'AttributeValue' => attribute_value)
152
+ request_info(req_hash, RightHttp2xxParser.new)
153
+ end
154
+
155
+ def get_topic_attributes(topic_arn)
156
+ req_hash = generate_request('GetTopicAttributes', 'TopicArn' => topic_arn)
157
+ request_info(req_hash, SnsGetTopicAttributesParser.new)
158
+ end
159
+
160
+ # Calls either the ListSubscriptions or ListSubscriptionsByTopic depending on whether or not the topic_arn parameter is provided.
161
+ def list_subscriptions(topic_arn = nil)
162
+ req_hash = topic_arn ? generate_request('ListSubscriptionsByTopic', 'TopicArn' => topic_arn) : generate_request('ListSubscriptions')
163
+ request_info(req_hash, SnsListSubscriptionsParser.new)
164
+ end
165
+
166
+ def confirm_subscription(topic_arn, token, authenticate_on_unsubscribe=false)
167
+ req_hash = generate_request('ConfirmSubscription', 'AuthenticateOnUnsubscribe' => authenticate_on_unsubscribe.to_s, 'Token' => token, 'TopicArn' => topic_arn)
168
+ request_info(req_hash, SnsConfirmSubscriptionParser.new)
169
+ end
170
+
171
+ def add_permission(topic_arn, label, acct_action_hash_ary)
172
+ n_hash = {
173
+ 'TopicArn' => topic_arn,
174
+ 'Label' => label
175
+ }
176
+
177
+ acct_action_hash_ary.each_with_index do |hash_val, idx|
178
+ n_hash["AWSAccountId.member.#{idx+1}"] = hash_val[:aws_account_id]
179
+ n_hash["ActionName.member.#{idx+1}"] = hash_val[:action]
180
+ end
181
+
182
+ req_hash = generate_request('AddPermission', n_hash)
183
+ request_info(req_hash, RightHttp2xxParser.new)
184
+ end
185
+
186
+ def remove_permission(topic_arn, label)
187
+ req_hash = generate_request('RemovePermission', 'TopicArn' => topic_arn, 'Label' => label)
188
+ request_info(req_hash, RightHttp2xxParser.new)
189
+ end
190
+
191
+ class SnsCreateTopicParser < RightAWSParser # :nodoc:
192
+ def reset
193
+ @result = ''
194
+ @request_id = ''
195
+ end
196
+ def tagend(name)
197
+ case name
198
+ when 'RequestId' then @result_id = @text
199
+ when 'TopicArn' then @result = @text
200
+ end
201
+ end
202
+ end
203
+
204
+ class SnsListTopicsParser < RightAWSParser # :nodoc:
205
+ def reset
206
+ @result = []
207
+ @request_id = ''
208
+ end
209
+ def tagstart(name, attributes)
210
+ @current_key = {} if name == 'member'
211
+ end
212
+ def tagend(name)
213
+ case name
214
+ when 'RequestId' then @result_id = @text
215
+ when 'TopicArn' then @current_key[:arn] = @text
216
+ when 'member' then @result << @current_key
217
+ end
218
+ end
219
+ end
220
+
221
+ class SnsSubscribeParser < RightAWSParser # :nodoc:
222
+ def reset
223
+ @result = ''
224
+ end
225
+ def tagend(name)
226
+ case name
227
+ when 'SubscriptionArn' then @result = @text
228
+ end
229
+ end
230
+ end
231
+
232
+ class SnsPublishParser < RightAWSParser # :nodoc:
233
+ def reset
234
+ @result = ''
235
+ end
236
+ def tagend(name)
237
+ case name
238
+ when 'MessageId' then @result = @text
239
+ end
240
+ end
241
+ end
242
+
243
+ class SnsGetTopicAttributesParser < RightAWSParser # :nodoc:
244
+ def reset
245
+ @result = {}
246
+ end
247
+ def tagend(name)
248
+ case name
249
+ when 'key' then @current_attr = @text
250
+ when 'value' then @result[@current_attr] = @text
251
+ end
252
+ end
253
+ end
254
+
255
+ class SnsListSubscriptionsParser < RightAWSParser # :nodoc:
256
+ def reset
257
+ @result = []
258
+ end
259
+ def tagstart(name, attributes)
260
+ @current_key = {} if name == 'member'
261
+ end
262
+ def tagend(name)
263
+ case name
264
+ when 'TopicArn' then @current_key[:topic_arn] = @text
265
+ when 'Protocol' then @current_key[:protocol] = @text
266
+ when 'SubscriptionArn' then @current_key[:subscription_arn] = @text
267
+ when 'Owner' then @current_key[:owner] = @text
268
+ when 'Endpoint' then @current_key[:endpoint] = @text
269
+ when 'member' then @result << @current_key
270
+ end
271
+ end
272
+ end
273
+
274
+ class SnsConfirmSubscriptionParser < RightAWSParser # :nodoc:
275
+ def reset
276
+ @result = ''
277
+ end
278
+ def tagend(name)
279
+ case name
280
+ when 'SubscriptionArn' then @result = @text
281
+ end
282
+ end
283
+ end
284
+
285
+ end
286
+ end
data/lib/sqs/right_sqs.rb CHANGED
@@ -59,7 +59,6 @@ module RightAws
59
59
  #
60
60
  # {:server => 'queue.amazonaws.com' # Amazon service host: 'queue.amazonaws.com' (default)
61
61
  # :port => 443 # Amazon service port: 80 or 443 (default)
62
- # :multi_thread => true|false # Multi-threaded (connection per each thread): true or false (default)
63
62
  # :signature_version => '0' # The signature version : '0' or '1'(default)
64
63
  # :logger => Logger Object} # Logger instance: logs to STDOUT if omitted }
65
64
  #
@@ -271,7 +270,7 @@ module RightAws
271
270
  grantees << Grantee.new(self, grantee_email_address, key, value[:name], value[:perms])
272
271
  end
273
272
  if grantee_email_address
274
- grantees.blank? ? nil : grantees.shift
273
+ grantees.right_blank? ? nil : grantees.shift
275
274
  else
276
275
  grantees
277
276
  end
@@ -60,7 +60,6 @@ module RightAws
60
60
  #
61
61
  # {:server => 'queue.amazonaws.com' # Amazon service host: 'queue.amazonaws.com' (default)
62
62
  # :port => 443 # Amazon service port: 80 or 443 (default)
63
- # :multi_thread => true|false # Multi-threaded (connection per each thread): true or false (default)
64
63
  # :signature_version => '0' # The signature version : '0' or '1'(default)
65
64
  # :logger => Logger Object} # Logger instance: logs to STDOUT if omitted }
66
65
  class SqsGen2
@@ -136,7 +135,7 @@ module RightAws
136
135
  # queue.clear() #=> true
137
136
  #
138
137
  def clear()
139
- @sqs.interface.clear_queue(@url)
138
+ @sqs.interface.clear_queue(@url)
140
139
  end
141
140
 
142
141
  # Deletes queue. Any messages in the queue will be permanently lost.
@@ -167,11 +166,10 @@ module RightAws
167
166
  #
168
167
  # queue.receive_messages(2,10) #=> array of messages
169
168
  #
170
- def receive_messages(number_of_messages=1, visibility=nil)
171
- list = @sqs.interface.receive_message(@url, number_of_messages, visibility)
169
+ def receive_messages(number_of_messages=1, visibility=nil, attributes=nil)
170
+ list = @sqs.interface.receive_message(@url, number_of_messages, visibility, attributes)
172
171
  list.map! do |entry|
173
- msg = Message.new(self, entry['MessageId'], entry['ReceiptHandle'],
174
- entry['Body'], visibility)
172
+ msg = Message.new(self, entry['MessageId'], entry['ReceiptHandle'], entry['Body'], visibility, entry['Attributes'])
175
173
  msg.received_at = Time.now
176
174
  msg.receive_checksum = entry['MD5OfBody']
177
175
  msg
@@ -183,8 +181,8 @@ module RightAws
183
181
  #
184
182
  # queue.receive #=> #<RightAws::SqsGen2::Message:0xb7bf0884 ... >
185
183
  #
186
- def receive(visibility=nil)
187
- list = receive_messages(1, visibility)
184
+ def receive(visibility=nil, attributes=nil)
185
+ list = receive_messages(1, visibility, attributes)
188
186
  list.empty? ? nil : list[0]
189
187
  end
190
188
 
@@ -193,12 +191,15 @@ module RightAws
193
191
  #
194
192
  # queue.pop #=> #<RightAws::SqsGen2::Message:0xb7bf0884 ... >
195
193
  #
196
- def pop
197
- list = @sqs.interface.pop_messages(@url, 1)
194
+ # # pop a message with custom attributes
195
+ # m = queue.pop(['SenderId', 'SentTimestamp']) #=> #<RightAws::SqsGen2::Message:0xb7bf1884 ... >
196
+ # m.attributes #=> {"SentTimestamp"=>"1240991906937", "SenderId"=>"800000000005"}
197
+ #
198
+ def pop(attributes=nil)
199
+ list = @sqs.interface.pop_messages(@url, 1, attributes)
198
200
  return nil if list.empty?
199
201
  entry = list[0]
200
- msg = Message.new(self, entry['MessageId'], entry['ReceiptHandle'],
201
- entry['Body'], visibility)
202
+ msg = Message.new(self, entry['MessageId'], entry['ReceiptHandle'], entry['Body'], visibility, entry['Attributes'])
202
203
  msg.received_at = Time.now
203
204
  msg.receive_checksum = entry['MD5OfBody']
204
205
  msg
@@ -241,27 +242,77 @@ module RightAws
241
242
  end
242
243
 
243
244
  # Retrieves queue attributes.
244
- # At this moment Amazon supports +VisibilityTimeout+ and +ApproximateNumberOfMessages+ only.
245
245
  # If the name of attribute is set, returns its value. Otherwise, returns a hash of attributes.
246
246
  #
247
247
  # queue.get_attribute('VisibilityTimeout') #=> {"VisibilityTimeout"=>"45"}
248
248
  #
249
+ # P.S. This guy is deprecated. Use +get_attributes+ instead.
249
250
  def get_attribute(attribute='All')
250
- attributes = @sqs.interface.get_queue_attributes(@url, attribute)
251
+ attributes = get_attributes(attribute)
251
252
  attribute=='All' ? attributes : attributes[attribute]
252
253
  end
254
+
255
+ # Retrieves queue attributes.
256
+ #
257
+ # queue.get_attributes #=>
258
+ # {"ApproximateNumberOfMessages" => "0",
259
+ # "LastModifiedTimestamp" => "1240946032",
260
+ # "CreatedTimestamp" => "1240816887",
261
+ # "VisibilityTimeout" => "30",
262
+ # "Policy" => "{"Version":"2008-10-17","Id":...}"}
263
+ #
264
+ # queue.get_attributes("LastModifiedTimestamp", "VisibilityTimeout") #=>
265
+ # {"LastModifiedTimestamp" => "1240946032",
266
+ # "VisibilityTimeout" => "30"}
267
+ #
268
+ def get_attributes(*attributes)
269
+ @sqs.interface.get_queue_attributes(@url, attributes)
270
+ end
271
+
272
+ # Add permission to the queue.
273
+ #
274
+ # queue.add_permissions('testLabel',['125074342641', '125074342642'],
275
+ # ['SendMessage','SendMessage','ReceiveMessage']) #=> true
276
+ #
277
+ def add_permissions(label, grantees, actions)
278
+ @sqs.interface.add_permissions(@url, label, grantees, actions)
279
+ end
280
+
281
+ # Revoke any permissions in the queue policy that matches the +label+ parameter.
282
+ #
283
+ # sqs.remove_permissions('testLabel') # => true
284
+ #
285
+ def remove_permissions(label)
286
+ @sqs.interface.remove_permissions(@url, label)
287
+ end
288
+
289
+ # Get current permissions set. The set is JSON packed.
290
+ #
291
+ # sqs.get_permissions #=>
292
+ # '{"Version":"2008-10-17","Id":"/826693181925/kd-test-gen-2_5/SQSDefaultPolicy",
293
+ # "Statement":[{"Sid":"kd-perm-04","Effect":"Allow","Principal":{"AWS":"100000000001",
294
+ # "AWS":"100000000001","AWS":"100000000002"},"Action":["SQS:SendMessage","SQS:DeleteMessage",
295
+ # "SQS:ReceiveMessage"],"Resource":"/826693181925/kd-test-gen-2_5"},{"Sid":"kd-perm-03",
296
+ # "Effect":"Allow","Principal":{"AWS":"648772224137"},"Action":"SQS:SendMessage",
297
+ # "Resource":"/826693181925/kd-test-gen-2_5"}]}'
298
+ #
299
+ def get_permissions
300
+ get_attributes('Policy')['Policy']
301
+ end
302
+
253
303
  end
254
304
 
255
305
  class Message
256
- attr_reader :queue, :id, :body, :visibility, :receipt_handle
306
+ attr_reader :queue, :id, :body, :visibility, :receipt_handle, :attributes
257
307
  attr_accessor :sent_at, :received_at, :send_checksum, :receive_checksum
258
308
 
259
- def initialize(queue, id=nil, rh = nil, body=nil, visibility=nil)
309
+ def initialize(queue, id=nil, rh = nil, body=nil, visibility=nil, attributes=nil)
260
310
  @queue = queue
261
311
  @id = id
262
312
  @receipt_handle = rh
263
313
  @body = body
264
314
  @visibility = visibility
315
+ @attributes = attributes
265
316
  @sent_at = nil
266
317
  @received_at = nil
267
318
  @send_checksum = nil
@@ -273,6 +324,12 @@ module RightAws
273
324
  @body
274
325
  end
275
326
 
327
+ # Set message visibility timeout.
328
+ def visibility=(visibility_timeout)
329
+ @queue.sqs.interface.change_message_visibility(@queue.url, @receipt_handle, visibility_timeout)
330
+ @visibility = visibility_timeout
331
+ end
332
+
276
333
  # Removes message from queue.
277
334
  # Returns +true+.
278
335
  def delete
@@ -281,6 +338,5 @@ module RightAws
281
338
 
282
339
  end
283
340
 
284
-
285
341
  end
286
342
  end