right_aws 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +22 -1
- data/Manifest.txt +11 -1
- data/README.txt +0 -4
- data/Rakefile +19 -25
- data/lib/acf/right_acf_interface.rb +199 -135
- data/lib/acf/right_acf_invalidations.rb +144 -0
- data/lib/acf/right_acf_origin_access_identities.rb +4 -4
- data/lib/acf/right_acf_streaming_interface.rb +19 -26
- data/lib/acw/right_acw_interface.rb +1 -2
- data/lib/as/right_as_interface.rb +6 -7
- data/lib/awsbase/right_awsbase.rb +287 -91
- data/lib/awsbase/support.rb +2 -82
- data/lib/awsbase/version.rb +9 -0
- data/lib/ec2/right_ec2.rb +101 -38
- data/lib/ec2/right_ec2_ebs.rb +71 -58
- data/lib/ec2/right_ec2_images.rb +82 -42
- data/lib/ec2/right_ec2_instances.rb +74 -44
- data/lib/ec2/right_ec2_placement_groups.rb +108 -0
- data/lib/ec2/right_ec2_reserved_instances.rb +50 -46
- data/lib/ec2/right_ec2_security_groups.rb +148 -32
- data/lib/ec2/right_ec2_spot_instances.rb +53 -27
- data/lib/ec2/right_ec2_tags.rb +139 -0
- data/lib/ec2/right_ec2_vpc.rb +151 -139
- data/lib/ec2/right_ec2_windows_mobility.rb +84 -0
- data/lib/elb/right_elb_interface.rb +93 -18
- data/lib/iam/right_iam_access_keys.rb +71 -0
- data/lib/iam/right_iam_groups.rb +195 -0
- data/lib/iam/right_iam_interface.rb +341 -0
- data/lib/iam/right_iam_mfa_devices.rb +67 -0
- data/lib/iam/right_iam_users.rb +251 -0
- data/lib/rds/right_rds_interface.rb +513 -202
- data/lib/right_aws.rb +12 -12
- data/lib/route_53/right_route_53_interface.rb +630 -0
- data/lib/s3/right_s3.rb +9 -12
- data/lib/s3/right_s3_interface.rb +10 -11
- data/lib/sdb/active_sdb.rb +18 -33
- data/lib/sdb/right_sdb_interface.rb +36 -4
- data/lib/sqs/right_sqs.rb +1 -2
- data/lib/sqs/right_sqs_gen2.rb +0 -1
- data/lib/sqs/right_sqs_gen2_interface.rb +4 -5
- data/lib/sqs/right_sqs_interface.rb +6 -7
- data/right_aws.gemspec +91 -0
- data/test/awsbase/test_helper.rb +2 -0
- data/test/awsbase/test_right_awsbase.rb +12 -0
- data/test/s3/test_right_s3.rb +1 -1
- data/test/sdb/test_active_sdb.rb +1 -1
- data/test/sdb/test_batch_put_attributes.rb +54 -0
- data/test/sqs/test_right_sqs.rb +0 -6
- data/test/sqs/test_right_sqs_gen2.rb +1 -1
- metadata +109 -58
data/lib/s3/right_s3.rb
CHANGED
@@ -59,7 +59,6 @@ module RightAws
|
|
59
59
|
# {:server => 's3.amazonaws.com' # Amazon service host: 's3.amazonaws.com'(default)
|
60
60
|
# :port => 443 # Amazon service port: 80 or 443(default)
|
61
61
|
# :protocol => 'https' # Amazon service protocol: 'http' or 'https'(default)
|
62
|
-
# :multi_thread => true|false # Multi-threaded (connection per each thread): true or false(default)
|
63
62
|
# :logger => Logger Object} # Logger instance: logs to STDOUT if omitted }
|
64
63
|
def initialize(aws_access_key_id=nil, aws_secret_access_key=nil, params={})
|
65
64
|
@interface = S3Interface.new(aws_access_key_id, aws_secret_access_key, params)
|
@@ -217,11 +216,10 @@ module RightAws
|
|
217
216
|
#
|
218
217
|
# keys, service = bucket.keys_and_service({'max-keys'=> 2, 'prefix' => 'logs'})
|
219
218
|
# p keys #=> # 2 keys array
|
220
|
-
# p service #=> {"max-keys"=>"2", "prefix"=>"logs", "name"=>"my_awesome_bucket", "marker"=>"", "is_truncated"=>true}
|
219
|
+
# p service #=> {"max-keys"=>"2", "prefix"=>"logs", "name"=>"my_awesome_bucket", "marker"=>"", "is_truncated"=>true, :common_prefixes=>[]}
|
221
220
|
#
|
222
221
|
def keys_and_service(options={}, head=false)
|
223
222
|
opt = {}; options.each{ |key, value| opt[key.to_s] = value }
|
224
|
-
service_data = {}
|
225
223
|
thislist = {}
|
226
224
|
list = []
|
227
225
|
@s3.interface.incrementally_list_bucket(@name, opt) do |thislist|
|
@@ -232,10 +230,8 @@ module RightAws
|
|
232
230
|
list << key
|
233
231
|
end
|
234
232
|
end
|
235
|
-
thislist.
|
236
|
-
|
237
|
-
end
|
238
|
-
[list, service_data]
|
233
|
+
thislist.delete(:contents)
|
234
|
+
[list, thislist]
|
239
235
|
end
|
240
236
|
|
241
237
|
# Retrieve key information from Amazon.
|
@@ -249,7 +245,7 @@ module RightAws
|
|
249
245
|
# key.head
|
250
246
|
#
|
251
247
|
def key(key_name, head=false)
|
252
|
-
raise 'Key name can not be empty.' if key_name.
|
248
|
+
raise 'Key name can not be empty.' if key_name.right_blank?
|
253
249
|
key_instance = nil
|
254
250
|
# if this key exists - find it ....
|
255
251
|
keys({'prefix'=>key_name}, head).each do |key|
|
@@ -346,9 +342,10 @@ module RightAws
|
|
346
342
|
# If +force+ is set, clears and deletes the bucket.
|
347
343
|
# Returns +true+.
|
348
344
|
#
|
349
|
-
# bucket.delete(true) #=> true
|
345
|
+
# bucket.delete(:force => true) #=> true
|
350
346
|
#
|
351
|
-
def delete(
|
347
|
+
def delete(options={})
|
348
|
+
force = options.is_a?(Hash) && options[:force]==true
|
352
349
|
force ? @s3.interface.force_delete_bucket(@name) : @s3.interface.delete_bucket(@name)
|
353
350
|
end
|
354
351
|
|
@@ -650,7 +647,7 @@ module RightAws
|
|
650
647
|
# key.delete #=> true
|
651
648
|
#
|
652
649
|
def delete
|
653
|
-
raise 'Key name must be specified.' if @name.
|
650
|
+
raise 'Key name must be specified.' if @name.right_blank?
|
654
651
|
@bucket.s3.interface.delete(@bucket, @name)
|
655
652
|
end
|
656
653
|
|
@@ -1086,7 +1083,7 @@ module RightAws
|
|
1086
1083
|
@bucket = bucket
|
1087
1084
|
@name = name.to_s
|
1088
1085
|
@meta_headers = meta_headers
|
1089
|
-
raise 'Key name can not be empty.' if @name.
|
1086
|
+
raise 'Key name can not be empty.' if @name.right_blank?
|
1090
1087
|
end
|
1091
1088
|
|
1092
1089
|
# Generate link to PUT key data.
|
@@ -63,14 +63,13 @@ module RightAws
|
|
63
63
|
|
64
64
|
# Creates new RightS3 instance.
|
65
65
|
#
|
66
|
-
# s3 = RightAws::S3Interface.new('1E3GDYEOGFJPIT7XXXXXX','hgTHt68JY07JKUY08ftHYtERkjgtfERn57XXXXXX', {:
|
66
|
+
# s3 = RightAws::S3Interface.new('1E3GDYEOGFJPIT7XXXXXX','hgTHt68JY07JKUY08ftHYtERkjgtfERn57XXXXXX', {:logger => Logger.new('/tmp/x.log')}) #=> #<RightAws::S3Interface:0xb7b3c27c>
|
67
67
|
#
|
68
68
|
# Params is a hash:
|
69
69
|
#
|
70
70
|
# {:server => 's3.amazonaws.com' # Amazon service host: 's3.amazonaws.com'(default)
|
71
71
|
# :port => 443 # Amazon service port: 80 or 443(default)
|
72
72
|
# :protocol => 'https' # Amazon service protocol: 'http' or 'https'(default)
|
73
|
-
# :multi_thread => true|false # Multi-threaded (connection per each thread): true or false(default)
|
74
73
|
# :logger => Logger Object} # Logger instance: logs to STDOUT if omitted }
|
75
74
|
#
|
76
75
|
def initialize(aws_access_key_id=nil, aws_secret_access_key=nil, params={})
|
@@ -162,7 +161,7 @@ module RightAws
|
|
162
161
|
headers['content-type'] ||= ''
|
163
162
|
headers['date'] = Time.now.httpdate
|
164
163
|
# create request
|
165
|
-
request = "Net::HTTP::#{method.capitalize}".
|
164
|
+
request = "Net::HTTP::#{method.capitalize}".right_constantize.new(path)
|
166
165
|
request.body = data if data
|
167
166
|
# set request headers and meta headers
|
168
167
|
headers.each { |key, value| request[key.to_s] = value }
|
@@ -214,7 +213,7 @@ module RightAws
|
|
214
213
|
else headers[:location].to_s
|
215
214
|
end
|
216
215
|
|
217
|
-
unless location.
|
216
|
+
unless location.right_blank?
|
218
217
|
data = "<CreateBucketConfiguration><LocationConstraint>#{location}</LocationConstraint></CreateBucketConfiguration>"
|
219
218
|
end
|
220
219
|
req_hash = generate_rest_request('PUT', headers.merge(:url=>bucket, :data => data))
|
@@ -300,7 +299,7 @@ module RightAws
|
|
300
299
|
# 'max-keys' => "5"}, ..., {...}]
|
301
300
|
#
|
302
301
|
def list_bucket(bucket, options={}, headers={})
|
303
|
-
bucket += '?'+options.map{|k, v| "#{k.to_s}=#{CGI::escape v.to_s}"}.join('&') unless options.
|
302
|
+
bucket += '?'+options.map{|k, v| "#{k.to_s}=#{CGI::escape v.to_s}"}.join('&') unless options.right_blank?
|
304
303
|
req_hash = generate_rest_request('GET', headers.merge(:url=>bucket))
|
305
304
|
request_info(req_hash, S3ListBucketParser.new(:logger => @logger))
|
306
305
|
rescue
|
@@ -335,10 +334,10 @@ module RightAws
|
|
335
334
|
# ]
|
336
335
|
# }
|
337
336
|
def incrementally_list_bucket(bucket, options={}, headers={}, &block)
|
338
|
-
internal_options = options.
|
337
|
+
internal_options = options.right_symbolize_keys
|
339
338
|
begin
|
340
339
|
internal_bucket = bucket.dup
|
341
|
-
internal_bucket += '?'+internal_options.map{|k, v| "#{k.to_s}=#{CGI::escape v.to_s}"}.join('&') unless internal_options.
|
340
|
+
internal_bucket += '?'+internal_options.map{|k, v| "#{k.to_s}=#{CGI::escape v.to_s}"}.join('&') unless internal_options.right_blank?
|
342
341
|
req_hash = generate_rest_request('GET', headers.merge(:url=>internal_bucket))
|
343
342
|
response = request_info(req_hash, S3ImprovedListBucketParser.new(:logger => @logger))
|
344
343
|
there_are_more_keys = response[:is_truncated]
|
@@ -701,7 +700,7 @@ module RightAws
|
|
701
700
|
# <Permission>FULL_CONTROL</Permission></Grant></AccessControlList></AccessControlPolicy>" }
|
702
701
|
#
|
703
702
|
def get_acl(bucket, key='', headers={})
|
704
|
-
key = key.
|
703
|
+
key = key.right_blank? ? '' : "/#{CGI::escape key}"
|
705
704
|
req_hash = generate_rest_request('GET', headers.merge(:url=>"#{bucket}#{key}?acl"))
|
706
705
|
request_info(req_hash, S3HttpResponseBodyParser.new)
|
707
706
|
rescue
|
@@ -731,7 +730,7 @@ module RightAws
|
|
731
730
|
# :display_name=>"root"}}
|
732
731
|
#
|
733
732
|
def get_acl_parse(bucket, key='', headers={})
|
734
|
-
key = key.
|
733
|
+
key = key.right_blank? ? '' : "/#{CGI::escape key}"
|
735
734
|
req_hash = generate_rest_request('GET', headers.merge(:url=>"#{bucket}#{key}?acl"))
|
736
735
|
acl = request_info(req_hash, S3AclParser.new(:logger => @logger))
|
737
736
|
result = {}
|
@@ -755,7 +754,7 @@ module RightAws
|
|
755
754
|
|
756
755
|
# Sets the ACL on a bucket or object.
|
757
756
|
def put_acl(bucket, key, acl_xml_doc, headers={})
|
758
|
-
key = key.
|
757
|
+
key = key.right_blank? ? '' : "/#{CGI::escape key}"
|
759
758
|
req_hash = generate_rest_request('PUT', headers.merge(:url=>"#{bucket}#{key}?acl", :data=>acl_xml_doc))
|
760
759
|
request_info(req_hash, S3HttpResponseBodyParser.new)
|
761
760
|
rescue
|
@@ -889,7 +888,7 @@ module RightAws
|
|
889
888
|
# s3.list_bucket_link('my_awesome_bucket') #=> url string
|
890
889
|
#
|
891
890
|
def list_bucket_link(bucket, options=nil, expires=nil, headers={})
|
892
|
-
bucket += '?' + options.map{|k, v| "#{k.to_s}=#{CGI::escape v.to_s}"}.join('&') unless options.
|
891
|
+
bucket += '?' + options.map{|k, v| "#{k.to_s}=#{CGI::escape v.to_s}"}.join('&') unless options.right_blank?
|
893
892
|
generate_link('GET', headers.merge(:url=>bucket), expires)
|
894
893
|
rescue
|
895
894
|
on_exception
|
data/lib/sdb/active_sdb.rb
CHANGED
@@ -21,13 +21,6 @@
|
|
21
21
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
22
|
#
|
23
23
|
|
24
|
-
begin
|
25
|
-
require 'uuidtools'
|
26
|
-
rescue LoadError => e
|
27
|
-
STDERR.puts("RightSDB requires the uuidtools gem. Run \'gem install uuidtools\' and try again.")
|
28
|
-
exit
|
29
|
-
end
|
30
|
-
|
31
24
|
module RightAws
|
32
25
|
|
33
26
|
# = RightAws::ActiveSdb -- RightScale SDB interface (alpha release)
|
@@ -39,9 +32,6 @@ module RightAws
|
|
39
32
|
# require 'right_aws'
|
40
33
|
# require 'sdb/active_sdb'
|
41
34
|
#
|
42
|
-
# Additionally, the ActiveSdb class requires the 'uuidtools' gem; this gem is not normally required by RightAws and is not installed as a
|
43
|
-
# dependency of RightAws.
|
44
|
-
#
|
45
35
|
# Simple ActiveSdb usage example:
|
46
36
|
#
|
47
37
|
# class Client < RightAws::ActiveSdb::Base
|
@@ -159,7 +149,6 @@ module RightAws
|
|
159
149
|
# :port => 443 # Amazon service port: 80 or 443(default)
|
160
150
|
# :protocol => 'https' # Amazon service protocol: 'http' or 'https'(default)
|
161
151
|
# :signature_version => '0' # The signature version : '0' or '1'(default)
|
162
|
-
# :multi_thread => true|false # Multi-threaded (connection per each thread): true or false(default)
|
163
152
|
# :logger => Logger Object # Logger instance: logs to STDOUT if omitted
|
164
153
|
# :nil_representation => 'mynil'} # interpret Ruby nil as this string value; i.e. use this string in SDB to represent Ruby nils (default is the string 'nil')
|
165
154
|
|
@@ -441,11 +430,7 @@ module RightAws
|
|
441
430
|
end
|
442
431
|
|
443
432
|
def generate_id # :nodoc:
|
444
|
-
|
445
|
-
UUID.timestamp_create().to_s
|
446
|
-
else
|
447
|
-
UUIDTools::UUID.timestamp_create().to_s
|
448
|
-
end
|
433
|
+
AwsUtils::generate_unique_token
|
449
434
|
end
|
450
435
|
|
451
436
|
protected
|
@@ -463,7 +448,7 @@ module RightAws
|
|
463
448
|
# user defined :conditions to string (if it was defined)
|
464
449
|
options[:conditions] = build_conditions(options[:conditions])
|
465
450
|
# join ids condition and user defined conditions
|
466
|
-
options[:conditions] = options[:conditions].
|
451
|
+
options[:conditions] = options[:conditions].right_blank? ? ids_cond : "(#{options[:conditions]}) AND #{ids_cond}"
|
467
452
|
result = sql_select(options)
|
468
453
|
# if one record was requested then return it
|
469
454
|
unless bunch_of_records_requested
|
@@ -552,7 +537,7 @@ module RightAws
|
|
552
537
|
query_expression = query_expression.to_s
|
553
538
|
# quote from Amazon:
|
554
539
|
# The sort attribute must be present in at least one of the predicates of the query expression.
|
555
|
-
if query_expression.
|
540
|
+
if query_expression.right_blank?
|
556
541
|
query_expression = sort_query_expression
|
557
542
|
elsif !query_attributes(query_expression).include?(sort_by)
|
558
543
|
query_expression += " intersection #{sort_query_expression}"
|
@@ -605,7 +590,7 @@ module RightAws
|
|
605
590
|
# user defined :conditions to string (if it was defined)
|
606
591
|
options[:conditions] = build_conditions(options[:conditions])
|
607
592
|
# join ids condition and user defined conditions
|
608
|
-
options[:conditions] = options[:conditions].
|
593
|
+
options[:conditions] = options[:conditions].right_blank? ? ids_cond : "#{options[:conditions]} intersection #{ids_cond}"
|
609
594
|
result = find_every(options)
|
610
595
|
# if one record was requested then return it
|
611
596
|
unless bunch_of_records_requested
|
@@ -656,9 +641,9 @@ module RightAws
|
|
656
641
|
order = options[:order] ? " ORDER BY #{options[:order]}" : ''
|
657
642
|
limit = options[:limit] ? " LIMIT #{options[:limit]}" : ''
|
658
643
|
# mix sort by argument (it must present in response)
|
659
|
-
unless order.
|
644
|
+
unless order.right_blank?
|
660
645
|
sort_by, sort_order = sort_options(options[:order])
|
661
|
-
conditions << (conditions.
|
646
|
+
conditions << (conditions.right_blank? ? " WHERE " : " AND ") << "(#{sort_by} IS NOT NULL)"
|
662
647
|
end
|
663
648
|
"SELECT #{select} FROM #{from}#{conditions}#{order}#{limit}"
|
664
649
|
end
|
@@ -745,7 +730,7 @@ module RightAws
|
|
745
730
|
def attributes=(attrs)
|
746
731
|
old_id = @attributes['id']
|
747
732
|
@attributes = uniq_values(attrs)
|
748
|
-
@attributes['id'] = old_id if @attributes['id'].
|
733
|
+
@attributes['id'] = old_id if @attributes['id'].right_blank? && !old_id.right_blank?
|
749
734
|
self.attributes
|
750
735
|
end
|
751
736
|
|
@@ -799,7 +784,7 @@ module RightAws
|
|
799
784
|
old_id = id
|
800
785
|
attrs = connection.get_attributes(domain, id)[:attributes]
|
801
786
|
@attributes = {}
|
802
|
-
unless attrs.
|
787
|
+
unless attrs.right_blank?
|
803
788
|
attrs.each { |attribute, values| @attributes[attribute] = values }
|
804
789
|
@attributes['id'] = old_id
|
805
790
|
end
|
@@ -825,7 +810,7 @@ module RightAws
|
|
825
810
|
attrs_list.flatten.uniq.each do |attribute|
|
826
811
|
attribute = attribute.to_s
|
827
812
|
values = connection.get_attributes(domain, id, attribute)[:attributes][attribute]
|
828
|
-
unless values.
|
813
|
+
unless values.right_blank?
|
829
814
|
@attributes[attribute] = result[attribute] = values
|
830
815
|
else
|
831
816
|
@attributes.delete(attribute)
|
@@ -855,7 +840,7 @@ module RightAws
|
|
855
840
|
prepare_for_update
|
856
841
|
attrs = @attributes.dup
|
857
842
|
attrs.delete('id')
|
858
|
-
connection.put_attributes(domain, id, attrs) unless attrs.
|
843
|
+
connection.put_attributes(domain, id, attrs) unless attrs.right_blank?
|
859
844
|
connection.put_attributes(domain, id, { 'id' => id }, :replace)
|
860
845
|
mark_as_old
|
861
846
|
@attributes
|
@@ -871,10 +856,10 @@ module RightAws
|
|
871
856
|
prepare_for_update
|
872
857
|
# if 'id' is present in attrs hash:
|
873
858
|
# replace internal 'id' attribute and remove it from the attributes to be sent
|
874
|
-
@attributes['id'] = attrs['id'] unless attrs['id'].
|
859
|
+
@attributes['id'] = attrs['id'] unless attrs['id'].right_blank?
|
875
860
|
attrs.delete('id')
|
876
861
|
# add new values to all attributes from list
|
877
|
-
connection.put_attributes(domain, id, attrs) unless attrs.
|
862
|
+
connection.put_attributes(domain, id, attrs) unless attrs.right_blank?
|
878
863
|
connection.put_attributes(domain, id, { 'id' => id }, :replace)
|
879
864
|
attrs.each do |attribute, values|
|
880
865
|
@attributes[attribute] ||= []
|
@@ -918,12 +903,12 @@ module RightAws
|
|
918
903
|
prepare_for_update
|
919
904
|
attrs = uniq_values(attrs)
|
920
905
|
# if 'id' is present in attrs hash then replace internal 'id' attribute
|
921
|
-
unless attrs['id'].
|
906
|
+
unless attrs['id'].right_blank?
|
922
907
|
@attributes['id'] = attrs['id']
|
923
908
|
else
|
924
909
|
attrs['id'] = id
|
925
910
|
end
|
926
|
-
connection.put_attributes(domain, id, attrs, :replace) unless attrs.
|
911
|
+
connection.put_attributes(domain, id, attrs, :replace) unless attrs.right_blank?
|
927
912
|
attrs.each { |attribute, values| attrs[attribute] = values }
|
928
913
|
mark_as_old
|
929
914
|
attrs
|
@@ -942,7 +927,7 @@ module RightAws
|
|
942
927
|
raise_on_id_absence
|
943
928
|
attrs = uniq_values(attrs)
|
944
929
|
attrs.delete('id')
|
945
|
-
unless attrs.
|
930
|
+
unless attrs.right_blank?
|
946
931
|
connection.delete_attributes(domain, id, attrs)
|
947
932
|
attrs.each do |attribute, values|
|
948
933
|
# remove the values from the attribute
|
@@ -971,7 +956,7 @@ module RightAws
|
|
971
956
|
raise_on_id_absence
|
972
957
|
attrs_list = attrs_list.flatten.map{ |attribute| attribute.to_s }
|
973
958
|
attrs_list.delete('id')
|
974
|
-
unless attrs_list.
|
959
|
+
unless attrs_list.right_blank?
|
975
960
|
connection.delete_attributes(domain, id, attrs_list)
|
976
961
|
attrs_list.each { |attribute| @attributes.delete(attribute) }
|
977
962
|
end
|
@@ -1026,7 +1011,7 @@ module RightAws
|
|
1026
1011
|
end
|
1027
1012
|
|
1028
1013
|
def prepare_for_update
|
1029
|
-
@attributes['id'] = self.class.generate_id if @attributes['id'].
|
1014
|
+
@attributes['id'] = self.class.generate_id if @attributes['id'].right_blank?
|
1030
1015
|
columns.all.each do |col_name|
|
1031
1016
|
self[col_name] ||= columns.default(col_name)
|
1032
1017
|
end
|
@@ -1044,7 +1029,7 @@ module RightAws
|
|
1044
1029
|
else
|
1045
1030
|
Array(values).uniq
|
1046
1031
|
end
|
1047
|
-
attrs.delete(attribute) if values.
|
1032
|
+
attrs.delete(attribute) if values.right_blank?
|
1048
1033
|
end
|
1049
1034
|
attrs
|
1050
1035
|
end
|
@@ -49,13 +49,12 @@ module RightAws
|
|
49
49
|
# :port => 443 # Amazon service port: 80 or 443(default)
|
50
50
|
# :protocol => 'https' # Amazon service protocol: 'http' or 'https'(default)
|
51
51
|
# :signature_version => '0' # The signature version : '0','1 or '2'(default)
|
52
|
-
# :multi_thread => true|false # Multi-threaded (connection per each thread): true or false(default)
|
53
52
|
# :logger => Logger Object # Logger instance: logs to STDOUT if omitted
|
54
53
|
# :nil_representation => 'mynil'} # interpret Ruby nil as this string value; i.e. use this string in SDB to represent Ruby nils (default is the string 'nil')
|
55
54
|
#
|
56
55
|
# Example:
|
57
56
|
#
|
58
|
-
# sdb = RightAws::SdbInterface.new('1E3GDYEOGFJPIT7XXXXXX','hgTHt68JY07JKUY08ftHYtERkjgtfERn57XXXXXX', {:
|
57
|
+
# sdb = RightAws::SdbInterface.new('1E3GDYEOGFJPIT7XXXXXX','hgTHt68JY07JKUY08ftHYtERkjgtfERn57XXXXXX', {:logger => Logger.new('/tmp/x.log')}) #=> #<RightSdb:0xa6b8c27c>
|
59
58
|
#
|
60
59
|
# see: http://docs.amazonwebservices.com/AmazonSimpleDB/2007-11-07/DeveloperGuide/
|
61
60
|
#
|
@@ -170,7 +169,7 @@ module RightAws
|
|
170
169
|
# (similar to ActiveRecord::Base#find using :conditions => ['query', param1, .., paramN])
|
171
170
|
#
|
172
171
|
def query_expression_from_array(params) #:nodoc:
|
173
|
-
return '' if params.
|
172
|
+
return '' if params.right_blank?
|
174
173
|
query = params.shift.to_s
|
175
174
|
query.gsub(/(\\)?(\?)/) do
|
176
175
|
if $1 # if escaped '\?' is found - replace it by '?' without backslash
|
@@ -182,7 +181,7 @@ module RightAws
|
|
182
181
|
end
|
183
182
|
|
184
183
|
def query_expression_from_hash(hash)
|
185
|
-
return '' if hash.
|
184
|
+
return '' if hash.right_blank?
|
186
185
|
expression = []
|
187
186
|
hash.each do |key, value|
|
188
187
|
expression << "#{key}=#{escape(value)}"
|
@@ -255,6 +254,27 @@ module RightAws
|
|
255
254
|
on_exception
|
256
255
|
end
|
257
256
|
|
257
|
+
# Query Metadata for Domain
|
258
|
+
#
|
259
|
+
# Returns a hash on success or an exception on error.
|
260
|
+
#
|
261
|
+
# example:
|
262
|
+
# sdb = RightAWS:::SdbInterface.new
|
263
|
+
# sdb.domain_metadata('toys') # => {:attribute_values_size_bytes=>"2754",
|
264
|
+
# :item_count=>"25",
|
265
|
+
# :item_names_size_bytes=>"900",
|
266
|
+
# :timestamp=>"1291890409",
|
267
|
+
# :attribute_name_count=>"7",
|
268
|
+
# :box_usage=>"0.0000071759",
|
269
|
+
# :attribute_names_size_bytes=>"48",
|
270
|
+
# :attribute_value_count=>"154",
|
271
|
+
# :request_id=>"79bbfe8f-f0c9-59a2-0963-16d5fc6c3c52"}
|
272
|
+
# see http://docs.amazonwebservices.com/AmazonSimpleDB/latest/DeveloperGuide/index.html?SDB_API_DomainMetadata.html
|
273
|
+
def domain_metadata(domain)
|
274
|
+
link = generate_request("DomainMetadata","DomainName"=>domain)
|
275
|
+
request_info(link,QSdbGenericParser.new)
|
276
|
+
end
|
277
|
+
|
258
278
|
# Delete SDB domain at Amazon.
|
259
279
|
#
|
260
280
|
# Returns a hash: { :box_usage, :request_id } on success or an exception on error.
|
@@ -615,6 +635,18 @@ module RightAws
|
|
615
635
|
#-----------------------------------------------------------------
|
616
636
|
# PARSERS:
|
617
637
|
#-----------------------------------------------------------------
|
638
|
+
class QSdbGenericParser < RightAWSParser #:nodoc:
|
639
|
+
def reset
|
640
|
+
@result = {}
|
641
|
+
end
|
642
|
+
def tagend(name)
|
643
|
+
case full_tag_name
|
644
|
+
when %r{/(DomainMetadataResult|ResponseMetadata)/}
|
645
|
+
@result[name.right_underscore.to_sym] = @text
|
646
|
+
end
|
647
|
+
end
|
648
|
+
end
|
649
|
+
|
618
650
|
class QSdbListDomainParser < RightAWSParser #:nodoc:
|
619
651
|
def reset
|
620
652
|
@result = { :domains => [] }
|
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.
|
273
|
+
grantees.right_blank? ? nil : grantees.shift
|
275
274
|
else
|
276
275
|
grantees
|
277
276
|
end
|
data/lib/sqs/right_sqs_gen2.rb
CHANGED
@@ -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
|
@@ -65,13 +65,12 @@ module RightAws
|
|
65
65
|
# Amazon's article "Migrating to Amazon SQS API version 2008-01-01" at:
|
66
66
|
# http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1148
|
67
67
|
#
|
68
|
-
# sqs = RightAws::SqsGen2Interface.new('1E3GDYEOGFJPIT75KDT40','hgTHt68JY07JKUY08ftHYtERkjgtfERn57DFE379', {:
|
68
|
+
# sqs = RightAws::SqsGen2Interface.new('1E3GDYEOGFJPIT75KDT40','hgTHt68JY07JKUY08ftHYtERkjgtfERn57DFE379', {:logger => Logger.new('/tmp/x.log')})
|
69
69
|
#
|
70
70
|
# Params is a hash:
|
71
71
|
#
|
72
72
|
# {:server => 'queue.amazonaws.com' # Amazon service host: 'queue.amazonaws.com' (default)
|
73
73
|
# :port => 443 # Amazon service port: 80 or 443 (default)
|
74
|
-
# :multi_thread => true|false # Multi-threaded (connection per each thread): true or false (default)
|
75
74
|
# :signature_version => '0' # The signature version : '0', '1' or '2'(default)
|
76
75
|
# :logger => Logger Object} # Logger instance: logs to STDOUT if omitted }
|
77
76
|
#
|
@@ -201,7 +200,7 @@ module RightAws
|
|
201
200
|
# http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/index.html?Query_QueryGetQueueAttributes.html
|
202
201
|
def get_queue_attributes(queue_url, *attributes)
|
203
202
|
attributes.flatten!
|
204
|
-
attributes << 'All' if attributes.
|
203
|
+
attributes << 'All' if attributes.right_blank?
|
205
204
|
params = amazonize_list('AttributeName', attributes)
|
206
205
|
params.merge!(:queue_url => queue_url)
|
207
206
|
req_hash = generate_request('GetQueueAttributes', params)
|
@@ -282,7 +281,7 @@ module RightAws
|
|
282
281
|
def receive_message(queue_url, max_number_of_messages=1, visibility_timeout=nil, attributes=nil)
|
283
282
|
return [] if max_number_of_messages == 0
|
284
283
|
params = {}
|
285
|
-
params.merge!(amazonize_list('AttributeName', Array(attributes))) unless attributes.
|
284
|
+
params.merge!(amazonize_list('AttributeName', Array(attributes))) unless attributes.right_blank?
|
286
285
|
params.merge!('MaxNumberOfMessages' => max_number_of_messages,
|
287
286
|
'VisibilityTimeout' => visibility_timeout,
|
288
287
|
:queue_url => queue_url )
|
@@ -429,7 +428,7 @@ module RightAws
|
|
429
428
|
#
|
430
429
|
def pop_message(queue_url, attributes=nil)
|
431
430
|
messages = pop_messages(queue_url, 1, attributes)
|
432
|
-
messages.
|
431
|
+
messages.right_blank? ? nil : messages[0]
|
433
432
|
rescue
|
434
433
|
on_exception
|
435
434
|
end
|