right_aws 2.1.0 → 3.0.0
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.
- data/History.txt +38 -14
- data/Manifest.txt +1 -0
- data/Rakefile +34 -8
- data/lib/awsbase/right_awsbase.rb +176 -12
- data/lib/awsbase/version.rb +2 -2
- data/lib/ec2/right_ec2.rb +120 -37
- data/lib/ec2/right_ec2_ebs.rb +57 -41
- data/lib/ec2/right_ec2_images.rb +73 -44
- data/lib/ec2/right_ec2_instances.rb +158 -155
- data/lib/ec2/right_ec2_reserved_instances.rb +36 -26
- data/lib/ec2/right_ec2_security_groups.rb +261 -166
- data/lib/ec2/right_ec2_spot_instances.rb +72 -75
- data/lib/ec2/right_ec2_vpc.rb +15 -8
- data/lib/ec2/right_ec2_vpc2.rb +381 -0
- data/lib/elb/right_elb_interface.rb +3 -1
- data/lib/emr/right_emr_interface.rb +727 -0
- data/lib/rds/right_rds_interface.rb +102 -27
- data/lib/right_aws.rb +4 -1
- data/lib/route_53/right_route_53_interface.rb +24 -14
- data/lib/s3/right_s3.rb +16 -15
- data/lib/s3/right_s3_interface.rb +42 -10
- data/lib/sdb/right_sdb_interface.rb +14 -5
- data/lib/sns/right_sns_interface.rb +286 -0
- data/test/README.mdown +39 -0
- data/test/awsbase/test_right_awsbase.rb +0 -1
- data/test/ec2/test_right_ec2.rb +0 -1
- data/test/elb/test_helper.rb +2 -0
- data/test/elb/test_right_elb.rb +43 -0
- data/test/route_53/fixtures/a_record.xml +18 -0
- data/test/route_53/fixtures/alias_record.xml +18 -0
- data/test/route_53/test_helper.rb +2 -0
- data/test/route_53/test_right_route_53.rb +141 -0
- data/test/s3/test_right_s3.rb +97 -39
- data/test/sns/test_helper.rb +2 -0
- data/test/sns/test_right_sns.rb +153 -0
- data/test/ts_right_aws.rb +1 -0
- metadata +28 -9
@@ -27,7 +27,7 @@ module RightAws
|
|
27
27
|
|
28
28
|
include RightAwsBaseInterface
|
29
29
|
|
30
|
-
API_VERSION = "
|
30
|
+
API_VERSION = "2011-04-01"
|
31
31
|
DEFAULT_HOST = 'rds.amazonaws.com'
|
32
32
|
DEFAULT_PORT = 443
|
33
33
|
DEFAULT_PROTOCOL = 'https'
|
@@ -35,6 +35,7 @@ module RightAws
|
|
35
35
|
|
36
36
|
DEFAULT_INSTANCE_CLASS = 'db.m1.small'
|
37
37
|
INSTANCE_CLASSES = ['db.m1.small', 'db.m1.large', 'db.m1.xlarge', 'db.m2.2xlarge', 'db.m2.2xlarge', 'db.m2.4xlarge']
|
38
|
+
LICENSE_MODELS = ['bring-your-own-license', 'license-included', 'general-public-license']
|
38
39
|
|
39
40
|
@@bench = AwsBenchmarkingBlock.new
|
40
41
|
def self.bench_xml
|
@@ -161,7 +162,7 @@ module RightAws
|
|
161
162
|
def describe_db_instances(*params, &block)
|
162
163
|
item, params = AwsUtils::split_items_and_params(params)
|
163
164
|
params = params.dup
|
164
|
-
params['DBInstanceIdentifier'] = item
|
165
|
+
params['DBInstanceIdentifier'] = item.first unless item.right_blank?
|
165
166
|
result = []
|
166
167
|
incrementally_list_items('DescribeDBInstances', DescribeDbInstancesParser, params) do |response|
|
167
168
|
result += response[:db_instances]
|
@@ -175,10 +176,11 @@ module RightAws
|
|
175
176
|
# Mandatory arguments: +aws_id+, +master_username+, +master_user_password+
|
176
177
|
# Optional params: +:allocated_storage+ (25 by def), +:instance_class+, +:engine+ ('MySQL' by def),
|
177
178
|
# +:endpoint_port+, +:db_name+, +:db_security_groups+, +:db_parameter_group+, +:availability_zone+, +:preferred_maintenance_window+
|
178
|
-
# +:backup_retention_period+, +:preferred_backup_window+, +:multi_az+, +:engine_version+, +:auto_minor_version_upgrade
|
179
|
+
# +:backup_retention_period+, +:preferred_backup_window+, +:multi_az+, +:engine_version+, +:auto_minor_version_upgrade+,
|
180
|
+
# +:license_model+
|
179
181
|
#
|
180
182
|
# rds.create_db_instance('kd-delete-me-01', 'username', 'password',
|
181
|
-
# :
|
183
|
+
# :instance_class => 'db.m1.small',
|
182
184
|
# :multi_az => true,
|
183
185
|
# :auto_minor_version_upgrade => false ) #=>
|
184
186
|
# {:instance_class=>"db.m1.small",
|
@@ -219,6 +221,7 @@ module RightAws
|
|
219
221
|
request_hash['DBParameterGroupName'] = params[:db_parameter_group] unless params[:db_parameter_group].right_blank?
|
220
222
|
request_hash['EngineVersion'] = params[:engine_version] unless params[:engine_version].right_blank?
|
221
223
|
request_hash['AutoMinorVersionUpgrade'] = params[:auto_minor_version_upgrade].to_s unless params[:auto_minor_version_upgrade].nil?
|
224
|
+
request_hash['LicenseModel'] = params[:license_model] unless params[:license_model].right_blank?
|
222
225
|
request_hash.merge!(amazonize_list('DBSecurityGroups.member', params[:db_security_groups]))
|
223
226
|
link = generate_request('CreateDBInstance', request_hash)
|
224
227
|
request_info(link, DescribeDbInstancesParser.new(:logger => @logger))[:db_instances].first
|
@@ -636,6 +639,31 @@ module RightAws
|
|
636
639
|
result
|
637
640
|
end
|
638
641
|
|
642
|
+
# Describe a list of orderable DB Instance options for the specified engine.
|
643
|
+
# Optionals: +:instance_class+, +:engine_version+ , +:license_model+
|
644
|
+
#
|
645
|
+
# rds.describe_orderable_db_instance_options('oracle-ee', :engine_version => '11.2.0.2.v2') #=>
|
646
|
+
# [{:read_replica_capable=>false,
|
647
|
+
# :instance_class=>"db.m1.large",
|
648
|
+
# :availability_zones=>["us-east-1a", "us-east-1b", "us-east-1d"],
|
649
|
+
# :engine=>"oracle-ee",
|
650
|
+
# :license_model=>"bring-your-own-license",
|
651
|
+
# :engine_version=>"11.2.0.2.v2",
|
652
|
+
# :multi_az_capable=>"false"}, ... ]
|
653
|
+
#
|
654
|
+
def describe_orderable_db_instance_options(engine, params={}, &block)
|
655
|
+
request_hash = { 'Engine' => engine }
|
656
|
+
request_hash['DBInstanceClass'] = params[:instance_class] unless params[:instance_class].right_blank?
|
657
|
+
request_hash['EngineVersion'] = params[:engine_version] unless params[:engine_version].right_blank?
|
658
|
+
request_hash['LicenseModel'] = params[:license_model] unless params[:license_model].right_blank?
|
659
|
+
result = []
|
660
|
+
incrementally_list_items('DescribeOrderableDBInstanceOptions', DescribeOrderableDBInstanceOptionsParser, request_hash) do |response|
|
661
|
+
result += response[:items]
|
662
|
+
block ? block.call(response) : true
|
663
|
+
end
|
664
|
+
result
|
665
|
+
end
|
666
|
+
|
639
667
|
# --------------------------------------------
|
640
668
|
# DB Snapshots
|
641
669
|
# --------------------------------------------
|
@@ -717,7 +745,7 @@ module RightAws
|
|
717
745
|
# in the "Available" state. The new RDS instance is created with the Default security group.
|
718
746
|
#
|
719
747
|
# Optional params: +:instance_class+, +:endpoint_port+, +:availability_zone+, +:multi_az+,
|
720
|
-
# +:auto_minor_version_upgrade+
|
748
|
+
# +:auto_minor_version_upgrade+, +:license_model+, +:db_name+, +:engine+
|
721
749
|
#
|
722
750
|
# rds.restore_db_instance_from_db_snapshot('ahahahaha-final-snapshot-20090828081159', 'q1') #=>
|
723
751
|
# {:status=>"creating",
|
@@ -741,6 +769,9 @@ module RightAws
|
|
741
769
|
request_hash['AvailabilityZone'] = params[:availability_zone] unless params[:availability_zone].right_blank?
|
742
770
|
request_hash['MultiAZ'] = params[:multi_az] unless params[:multi_az].nil?
|
743
771
|
request_hash['AutoMinorVersionUpgrade'] = params[:auto_minor_version_upgrade] unless params[:auto_minor_version_upgrade].nil?
|
772
|
+
request_hash['LicenseModel'] = params[:license_model] unless params[:license_model].right_blank?
|
773
|
+
request_hash['DBName'] = params[:db_name] unless params[:db_name].right_blank?
|
774
|
+
request_hash['Engine'] = params[:engine] unless params[:enginel].right_blank?
|
744
775
|
link = generate_request('RestoreDBInstanceFromDBSnapshot', request_hash)
|
745
776
|
request_info(link, DescribeDbInstancesParser.new(:logger => @logger))[:db_instances].first
|
746
777
|
end
|
@@ -751,7 +782,7 @@ module RightAws
|
|
751
782
|
# security group.
|
752
783
|
#
|
753
784
|
# Optional params: +:instance_class+, +:endpoint_port+, +:availability_zone+, +:multi_az+, +:restore_time+,
|
754
|
-
# +:auto_minor_version_upgrade+, +:use_latest_restorable_time+
|
785
|
+
# +:auto_minor_version_upgrade+, +:use_latest_restorable_time+, +:license_model+, +:db_name+, +:engine+
|
755
786
|
#
|
756
787
|
def restore_db_instance_to_point_in_time(instance_aws_id, new_instance_aws_id, params={})
|
757
788
|
request_hash = { 'SourceDBInstanceIdentifier' => instance_aws_id,
|
@@ -763,6 +794,9 @@ module RightAws
|
|
763
794
|
request_hash['Port'] = params[:endpoint_port] unless params[:endpoint_port].right_blank?
|
764
795
|
request_hash['AvailabilityZone'] = params[:availability_zone] unless params[:availability_zone].right_blank?
|
765
796
|
request_hash['AutoMinorVersionUpgrade'] = params[:auto_minor_version_upgrade] unless params[:auto_minor_version_upgrade].nil?
|
797
|
+
request_hash['LicenseModel'] = params[:license_model] unless params[:license_model].right_blank?
|
798
|
+
request_hash['DBName'] = params[:db_name] unless params[:db_name].right_blank?
|
799
|
+
request_hash['Engine'] = params[:engine] unless params[:enginel].right_blank?
|
766
800
|
link = generate_request('RestoreDBInstanceToPointInTime', request_hash)
|
767
801
|
request_info(link, DescribeDbInstancesParser.new(:logger => @logger))[:db_instances].first
|
768
802
|
end
|
@@ -844,15 +878,17 @@ module RightAws
|
|
844
878
|
# Optional params: +:db_parameter_group_family+, +:default_only+, +:engine+, +:engine_version+
|
845
879
|
#
|
846
880
|
# rds.describe_db_engine_versions #=>
|
847
|
-
# [{:
|
848
|
-
# :
|
881
|
+
# [{:db_parameter_group_family=>"mysql5.1",
|
882
|
+
# :engine=>"mysql",
|
883
|
+
# :db_engine_description=>"MySQL Community Edition",
|
884
|
+
# :db_engine_version_description=>"Mysql 5.1.45",
|
849
885
|
# :engine_version=>"5.1.45"},
|
850
|
-
# {:
|
851
|
-
# :
|
852
|
-
# :
|
853
|
-
#
|
854
|
-
#
|
855
|
-
# :engine_version=>"
|
886
|
+
# {:db_parameter_group_family=>"oracle-se1-11.2",
|
887
|
+
# :engine=>"oracle-se1",
|
888
|
+
# :db_engine_description=>"Oracle Database Standard Edition One",
|
889
|
+
# :db_engine_version_description=>
|
890
|
+
# "Oracle Standard Edition One - DB Engine Version 11.2.0.2.v2",
|
891
|
+
# :engine_version=>"11.2.0.2.v2"}]
|
856
892
|
#
|
857
893
|
def describe_db_engine_versions(params={}, &block)
|
858
894
|
params = params.dup
|
@@ -874,10 +910,10 @@ module RightAws
|
|
874
910
|
|
875
911
|
# Create a DB Instance that acts as a Read Replica of a source DB Instance.
|
876
912
|
#
|
877
|
-
# Optional params: +:endpoint_port+, +:availability_zone+, +:
|
913
|
+
# Optional params: +:endpoint_port+, +:availability_zone+, +:instance_class+, +:auto_minor_version_upgrade+
|
878
914
|
#
|
879
915
|
# rds.create_db_instance_read_replica('kd-delete-me-01-replica-01', 'kd-delete-me-01',
|
880
|
-
# :
|
916
|
+
# :instance_class => 'db.m1.small',
|
881
917
|
# :endpoint_port => '11000',
|
882
918
|
# :auto_minor_version_upgrade => false ) #=>
|
883
919
|
# {:auto_minor_version_upgrade=>false,
|
@@ -903,7 +939,7 @@ module RightAws
|
|
903
939
|
'SourceDBInstanceIdentifier' => source_db_instance_identifier}
|
904
940
|
request_hash['Port'] = params[:endpoint_port] unless params[:endpoint_port].right_blank?
|
905
941
|
request_hash['AvailabilityZone'] = params[:availability_zone] unless params[:availability_zone].right_blank?
|
906
|
-
request_hash['DBInstanceClass'] = params[:
|
942
|
+
request_hash['DBInstanceClass'] = params[:instance_class] unless params[:instance_class].right_blank?
|
907
943
|
request_hash['AutoMinorVersionUpgrade'] = params[:auto_minor_version_upgrade].to_s unless params[:auto_minor_version_upgrade].nil?
|
908
944
|
link = generate_request('CreateDBInstanceReadReplica', request_hash)
|
909
945
|
request_info(link, DescribeDbInstancesParser.new(:logger => @logger))[:db_instances].first
|
@@ -918,26 +954,29 @@ module RightAws
|
|
918
954
|
# Options: :aws_id, :instance_class, :duration, :product_description, :multi_az
|
919
955
|
#
|
920
956
|
# rds.describe_reserved_db_instances_offerings #=>
|
921
|
-
# [{:
|
957
|
+
# [{:usage_price=>0.262,
|
958
|
+
# :offering_aws_id=>"248e7b75-2451-4381-9025-b5553d421c7b",
|
959
|
+
# :multi_az=>false,
|
922
960
|
# :duration=>31536000,
|
923
|
-
# :
|
924
|
-
# :usage_price=>0.262,
|
925
|
-
# :aws_id=>"248e7b75-2451-4381-9025-b5553d421c7b",
|
961
|
+
# :currency_code=>"USD",
|
926
962
|
# :instance_class=>"db.m2.xlarge",
|
927
|
-
# :product_description=>"mysql"
|
928
|
-
#
|
963
|
+
# :product_description=>"mysql",
|
964
|
+
# :fixed_price=>1325.0},
|
965
|
+
# {:usage_price=>0.092,
|
966
|
+
# :offering_aws_id=>"248e7b75-49a7-4cd7-9a9b-354f4906a9b1",
|
967
|
+
# :multi_az=>true,
|
929
968
|
# :duration=>94608000,
|
930
|
-
# :
|
931
|
-
# :usage_price=>0.092,
|
932
|
-
# :aws_id=>"248e7b75-49a7-4cd7-9a9b-354f4906a9b1",
|
969
|
+
# :currency_code=>"USD",
|
933
970
|
# :instance_class=>"db.m1.small",
|
934
|
-
# :product_description=>"mysql"
|
971
|
+
# :product_description=>"mysql",
|
972
|
+
# :fixed_price=>700.0}, ...]
|
935
973
|
#
|
936
974
|
# rds.describe_reserved_db_instances_offerings(:aws_id => "248e7b75-49a7-4cd7-9a9b-354f4906a9b1") #=>
|
937
975
|
# [{:duration=>94608000,
|
938
976
|
# :multi_az=>true,
|
939
977
|
# :fixed_price=>700.0,
|
940
978
|
# :usage_price=>0.092,
|
979
|
+
# :currency_code=>"USD",
|
941
980
|
# :aws_id=>"248e7b75-49a7-4cd7-9a9b-354f4906a9b1",
|
942
981
|
# :instance_class=>"db.m1.small",
|
943
982
|
# :product_description=>"mysql"}]
|
@@ -1033,6 +1072,8 @@ module RightAws
|
|
1033
1072
|
when 'MasterUsername' then @item[:master_username] = @text
|
1034
1073
|
when 'AvailabilityZone' then @item[:availability_zone] = @text
|
1035
1074
|
when 'LatestRestorableTime' then @item[:latest_restorable_time] = @text
|
1075
|
+
when 'LicenseModel' then @item[:license_model] = @text
|
1076
|
+
when 'DBName' then @item[:db_name] = @text
|
1036
1077
|
when 'ReadReplicaSourceDBInstanceIdentifier' then @item[:read_replica_source_db_instance_identifier] = @text
|
1037
1078
|
when 'ReadReplicaDBInstanceIdentifier' then @item[:read_replica_db_instance_identifiers] << @text
|
1038
1079
|
when 'DBSecurityGroupName' then @db_security_group[:name] = @text
|
@@ -1069,6 +1110,31 @@ module RightAws
|
|
1069
1110
|
end
|
1070
1111
|
end
|
1071
1112
|
|
1113
|
+
class DescribeOrderableDBInstanceOptionsParser < RightAWSParser # :nodoc:
|
1114
|
+
def reset
|
1115
|
+
@result = { :items => [] }
|
1116
|
+
end
|
1117
|
+
def tagstart(name, attributes)
|
1118
|
+
case name
|
1119
|
+
when 'OrderableDBInstanceOption' then @item = { :availability_zones => [] }
|
1120
|
+
end
|
1121
|
+
end
|
1122
|
+
def tagend(name)
|
1123
|
+
case name
|
1124
|
+
when 'Marker' then @result[:marker] = @text
|
1125
|
+
when 'MaxRecords' then @result[:max_records] = @text.to_i
|
1126
|
+
when 'DBInstanceClass' then @item[:instance_class] = @text
|
1127
|
+
when 'Engine' then @item[:engine] = @text
|
1128
|
+
when 'EngineVersion' then @item[:engine_version] = @text
|
1129
|
+
when 'LicenseModel' then @item[:license_model] = @text
|
1130
|
+
when 'MultiAZCapable' then @item[:multi_az_capable] = @text
|
1131
|
+
when 'ReadReplicaCapable' then @item[:read_replica_capable] = @text == 'true'
|
1132
|
+
when 'Name' then @item[:availability_zones] << @text
|
1133
|
+
when 'OrderableDBInstanceOption' then @result[:items] << @item
|
1134
|
+
end
|
1135
|
+
end
|
1136
|
+
end
|
1137
|
+
|
1072
1138
|
# --------------------------------------------
|
1073
1139
|
# DB Security Groups
|
1074
1140
|
# --------------------------------------------
|
@@ -1157,6 +1223,8 @@ module RightAws
|
|
1157
1223
|
when 'Description' then @item[:description] = @text
|
1158
1224
|
when 'IsModifiable' then @item[:is_modifiable] = (@text == 'true')
|
1159
1225
|
when 'ApplyType' then @item[:apply_type] = @text
|
1226
|
+
when 'ApplyMethod' then @item[:apply_method] = @text
|
1227
|
+
when 'MinimumEngineVersion' then @item[:minimum_engine_version] = @text
|
1160
1228
|
when 'AllowedValues' then @item[:allowed_values] = @text
|
1161
1229
|
when 'ParameterName' then @item[:name] = @text
|
1162
1230
|
when 'ParameterValue' then @item[:value] = @text
|
@@ -1193,6 +1261,7 @@ module RightAws
|
|
1193
1261
|
when 'SnapshotCreateTime' then @item[:create_time] = @text
|
1194
1262
|
when 'DBInstanceIdentifier' then @item[:instance_aws_id] = @text
|
1195
1263
|
when 'DBSnapshotIdentifier' then @item[:aws_id] = @text
|
1264
|
+
when 'LicenseModel' then @item[:license_model] = @text
|
1196
1265
|
when 'DBSnapshot' then @result[:db_snapshots] << @item
|
1197
1266
|
end
|
1198
1267
|
end
|
@@ -1244,6 +1313,8 @@ module RightAws
|
|
1244
1313
|
when 'DBParameterGroupFamily' then @item[:db_parameter_group_family] = @text
|
1245
1314
|
when 'Engine' then @item[:engine] = @text
|
1246
1315
|
when 'EngineVersion' then @item[:engine_version] = @text
|
1316
|
+
when 'DBEngineDescription' then @item[:db_engine_description] = @text
|
1317
|
+
when 'DBEngineVersionDescription' then @item[:db_engine_version_description] = @text
|
1247
1318
|
when 'DBEngineVersion' then @result[:db_engine_versions] << @item
|
1248
1319
|
end
|
1249
1320
|
end
|
@@ -1266,6 +1337,7 @@ module RightAws
|
|
1266
1337
|
case name
|
1267
1338
|
when 'Marker' then @result[:marker] = @text
|
1268
1339
|
when 'MaxRecords' then @result[:max_records] = @text.to_i
|
1340
|
+
when 'CurrencyCode' then @item[:currency_code] = @text
|
1269
1341
|
when 'DBInstanceClass' then @item[:instance_class] = @text
|
1270
1342
|
when 'Duration' then @item[:duration] = @text.to_i
|
1271
1343
|
when 'FixedPrice' then @item[:fixed_price] = @text.to_f
|
@@ -1292,6 +1364,7 @@ module RightAws
|
|
1292
1364
|
when 'Marker' then @result[:marker] = @text
|
1293
1365
|
when 'MaxRecords' then @result[:max_records] = @text.to_i
|
1294
1366
|
when 'DBInstanceClass' then @item[:instance_class] = @text
|
1367
|
+
when 'CurrencyCode' then @item[:currency_code] = @text
|
1295
1368
|
when 'Duration' then @item[:duration] = @text.to_i
|
1296
1369
|
when 'FixedPrice' then @item[:fixed_price] = @text.to_f
|
1297
1370
|
when 'UsagePrice' then @item[:usage_price] = @text.to_f
|
@@ -1300,6 +1373,8 @@ module RightAws
|
|
1300
1373
|
when 'ReservedDBInstancesOfferingId' then @item[:offering_aws_id] = @text
|
1301
1374
|
when 'ReservedDBInstanceId' then @item[:aws_id] = @text
|
1302
1375
|
when 'State' then @item[:state] = @text
|
1376
|
+
when 'DBInstanceCount' then @item[:instance_count] = @text.to_i
|
1377
|
+
when 'StartTime' then @item[:start_time] = @text
|
1303
1378
|
when 'ReservedDBInstance' then @result[:reserved_db_instances] << @item
|
1304
1379
|
end
|
1305
1380
|
end
|
data/lib/right_aws.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (c) 2007-
|
2
|
+
# Copyright (c) 2007-2011 RightScale Inc
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining
|
5
5
|
# a copy of this software and associated documentation files (the
|
@@ -47,11 +47,13 @@ require 'ec2/right_ec2_spot_instances'
|
|
47
47
|
require 'ec2/right_ec2_ebs'
|
48
48
|
require 'ec2/right_ec2_reserved_instances'
|
49
49
|
require 'ec2/right_ec2_vpc'
|
50
|
+
require 'ec2/right_ec2_vpc2'
|
50
51
|
require 'ec2/right_ec2_monitoring'
|
51
52
|
require 'ec2/right_ec2_placement_groups'
|
52
53
|
require 'ec2/right_ec2_windows_mobility'
|
53
54
|
require 'ec2/right_ec2_tags'
|
54
55
|
require 'elb/right_elb_interface'
|
56
|
+
require 'emr/right_emr_interface'
|
55
57
|
require 'acw/right_acw_interface'
|
56
58
|
require 'as/right_as_interface'
|
57
59
|
require 's3/right_s3_interface'
|
@@ -72,6 +74,7 @@ require 'iam/right_iam_users'
|
|
72
74
|
require 'iam/right_iam_access_keys'
|
73
75
|
require 'iam/right_iam_mfa_devices'
|
74
76
|
require 'route_53/right_route_53_interface'
|
77
|
+
require 'sns/right_sns_interface'
|
75
78
|
|
76
79
|
#-
|
77
80
|
|
@@ -158,7 +158,7 @@ module RightAws
|
|
158
158
|
|
159
159
|
include RightAwsBaseInterface
|
160
160
|
|
161
|
-
API_VERSION = "
|
161
|
+
API_VERSION = "2011-05-05"
|
162
162
|
DEFAULT_HOST = "route53.amazonaws.com"
|
163
163
|
DEFAULT_PATH = '/'
|
164
164
|
DEFAULT_PROTOCOL = 'https'
|
@@ -295,11 +295,22 @@ module RightAws
|
|
295
295
|
" <Action>#{AwsUtils::xml_escape(change[:action].to_s.upcase)}</Action>\n" +
|
296
296
|
" <ResourceRecordSet>\n" +
|
297
297
|
" <Name>#{AwsUtils::xml_escape(change[:name])}</Name>\n" +
|
298
|
-
" <Type>#{AwsUtils::xml_escape(change[:type].to_s.upcase)}</Type>\n"
|
298
|
+
" <Type>#{AwsUtils::xml_escape(change[:type].to_s.upcase)}</Type>\n"
|
299
|
+
if change[:alias_target]
|
300
|
+
alias_target = change[:alias_target]
|
301
|
+
xml_changes +=
|
302
|
+
" <AliasTarget>\n" +
|
303
|
+
" <HostedZoneId>#{AwsUtils::xml_escape(alias_target[:hosted_zone_id].to_s)}</HostedZoneId>\n" +
|
304
|
+
" <DNSName>#{AwsUtils::xml_escape(alias_target[:dns_name].to_s)}</DNSName>\n" +
|
305
|
+
" </AliasTarget>\n"
|
306
|
+
else
|
307
|
+
xml_changes +=
|
299
308
|
" <TTL>#{AwsUtils::xml_escape(change[:ttl].to_s)}</TTL>\n" +
|
300
309
|
" <ResourceRecords>\n" +
|
301
310
|
xml_resource_records +
|
302
|
-
" </ResourceRecords>\n"
|
311
|
+
" </ResourceRecords>\n"
|
312
|
+
end
|
313
|
+
xml_changes +=
|
303
314
|
" </ResourceRecordSet>\n" +
|
304
315
|
" </Change>\n"
|
305
316
|
end
|
@@ -416,7 +427,6 @@ module RightAws
|
|
416
427
|
# Options: :type, :name, :max_items
|
417
428
|
#
|
418
429
|
# r53.list_resource_record_sets("/hostedzone/ZWEC7PPVACGQ4") #=>
|
419
|
-
# {:items=>
|
420
430
|
# [{:type=>"NS",
|
421
431
|
# :ttl=>172800,
|
422
432
|
# :name=>"mysite.patch-island.com.",
|
@@ -433,9 +443,7 @@ module RightAws
|
|
433
443
|
# {:type=>"NS",
|
434
444
|
# :ttl=>600,
|
435
445
|
# :resource_records=>["xxx.mysite.com"],
|
436
|
-
# :name=>"m1.mysite.patch-island.com."}]
|
437
|
-
# :is_truncated=>false,
|
438
|
-
# :max_items=>100}
|
446
|
+
# :name=>"m1.mysite.patch-island.com."}]
|
439
447
|
#
|
440
448
|
# PS: http://docs.amazonwebservices.com/Route53/latest/APIReference/API_ListResourceRecordSets.html
|
441
449
|
#
|
@@ -451,7 +459,7 @@ module RightAws
|
|
451
459
|
|
452
460
|
# Create or delete DNS records.
|
453
461
|
#
|
454
|
-
# resource_record_sets =
|
462
|
+
# resource_record_sets = [{ :action => :create,
|
455
463
|
# :name => 'm3.mysite.patch-island.com',
|
456
464
|
# :type => 'NS',
|
457
465
|
# :ttl => 600,
|
@@ -460,7 +468,7 @@ module RightAws
|
|
460
468
|
# :name => 'm2.mysite.patch-island.com',
|
461
469
|
# :type => 'A',
|
462
470
|
# :ttl => 600,
|
463
|
-
# :resource_records => ['10.0.0.1'] }
|
471
|
+
# :resource_records => ['10.0.0.1'] }]
|
464
472
|
# r53.change_resource_record_sets("/hostedzone/Z1K6NCF0EB26FB", resource_record_sets, 'KD: Comment#1') #=>
|
465
473
|
# {:status=>"PENDING",
|
466
474
|
# :submitted_at=>"2011-01-18T20:21:56.828Z",
|
@@ -476,14 +484,14 @@ module RightAws
|
|
476
484
|
|
477
485
|
# Create DNS records.
|
478
486
|
#
|
479
|
-
# resource_record_sets =
|
487
|
+
# resource_record_sets = [{ :name => 'm3.mysite.patch-island.com',
|
480
488
|
# :type => 'NS',
|
481
489
|
# :ttl => 600,
|
482
490
|
# :resource_records => 'xxx.mysite.com' },
|
483
491
|
# { :name => 'm2.mysite.patch-island.com',
|
484
492
|
# :type => 'A',
|
485
493
|
# :ttl => 600,
|
486
|
-
# :resource_records => ['10.0.0.1'] }
|
494
|
+
# :resource_records => ['10.0.0.1'] }]
|
487
495
|
# r53.create_resource_record_sets("/hostedzone/Z1K6NCF0EB26FB", resource_record_sets, 'KD: Comment#1') #=>
|
488
496
|
# {:status=>"PENDING",
|
489
497
|
# :submitted_at=>"2011-01-18T20:21:56.828Z",
|
@@ -498,14 +506,14 @@ module RightAws
|
|
498
506
|
|
499
507
|
# Delete DNS records.
|
500
508
|
#
|
501
|
-
# resource_record_sets =
|
509
|
+
# resource_record_sets = [{ :name => 'm3.mysite.patch-island.com',
|
502
510
|
# :type => 'NS',
|
503
511
|
# :ttl => 600,
|
504
512
|
# :resource_records => 'xxx.mysite.com' },
|
505
513
|
# { :name => 'm2.mysite.patch-island.com',
|
506
514
|
# :type => 'A',
|
507
515
|
# :ttl => 600,
|
508
|
-
# :resource_records => ['10.0.0.1'] }
|
516
|
+
# :resource_records => ['10.0.0.1'] }]
|
509
517
|
# r53.create_resource_record_sets("/hostedzone/Z1K6NCF0EB26FB", resource_record_sets, 'KD: Comment#1') #=>
|
510
518
|
# {:status=>"PENDING",
|
511
519
|
# :submitted_at=>"2011-01-18T20:21:56.828Z",
|
@@ -606,7 +614,9 @@ module RightAws
|
|
606
614
|
when 'ResourceRecordSet' then @result[:items] << @item
|
607
615
|
else
|
608
616
|
case full_tag_name
|
609
|
-
when %r{/ResourceRecord/Value}
|
617
|
+
when %r{/ResourceRecord/Value} then (@item[:resource_records] ||= []) << @text
|
618
|
+
when %r{/AliasTarget/DNSName} then (@item[:alias_target] ||= {})[:dns_name] = @text
|
619
|
+
when %r{/AliasTarget/HostedZoneId} then (@item[:alias_target] ||= {})[:hosted_zone_id] = @text
|
610
620
|
end
|
611
621
|
end
|
612
622
|
end
|
data/lib/s3/right_s3.rb
CHANGED
@@ -220,18 +220,19 @@ module RightAws
|
|
220
220
|
#
|
221
221
|
def keys_and_service(options={}, head=false)
|
222
222
|
opt = {}; options.each{ |key, value| opt[key.to_s] = value }
|
223
|
-
|
224
|
-
|
225
|
-
@s3.interface.incrementally_list_bucket(@name, opt) do |
|
226
|
-
|
223
|
+
service = {}
|
224
|
+
keys = []
|
225
|
+
@s3.interface.incrementally_list_bucket(@name, opt) do |_service|
|
226
|
+
service = _service
|
227
|
+
service[:contents].each do |entry|
|
227
228
|
owner = Owner.new(entry[:owner_id], entry[:owner_display_name])
|
228
229
|
key = Key.new(self, entry[:key], nil, {}, {}, entry[:last_modified], entry[:e_tag], entry[:size], entry[:storage_class], owner)
|
229
230
|
key.head if head
|
230
|
-
|
231
|
+
keys << key
|
231
232
|
end
|
232
233
|
end
|
233
|
-
|
234
|
-
[
|
234
|
+
service.delete(:contents)
|
235
|
+
[keys, service]
|
235
236
|
end
|
236
237
|
|
237
238
|
# Retrieve key information from Amazon.
|
@@ -272,12 +273,12 @@ module RightAws
|
|
272
273
|
key.put(data, perms, headers)
|
273
274
|
end
|
274
275
|
|
275
|
-
# Retrieve object
|
276
|
+
# Retrieve data object from Amazon.
|
276
277
|
# The +key+ is a +String+ or Key.
|
277
|
-
# Returns
|
278
|
+
# Returns String instance.
|
278
279
|
#
|
279
|
-
#
|
280
|
-
# puts
|
280
|
+
# data = bucket.get('logs/today/1.log') #=>
|
281
|
+
# puts data #=> 'sasfasfasdf'
|
281
282
|
#
|
282
283
|
def get(key, headers={})
|
283
284
|
key = Key.create(self, key.to_s) unless key.is_a?(Key)
|
@@ -1041,8 +1042,8 @@ module RightAws
|
|
1041
1042
|
#
|
1042
1043
|
# bucket.get('logs/today/1.log', 1.hour)
|
1043
1044
|
#
|
1044
|
-
def get(key, expires=nil, headers={})
|
1045
|
-
@s3.interface.get_link(@name, key.to_s, expires, headers)
|
1045
|
+
def get(key, expires=nil, headers={}, response_params={})
|
1046
|
+
@s3.interface.get_link(@name, key.to_s, expires, headers, response_params)
|
1046
1047
|
end
|
1047
1048
|
|
1048
1049
|
# Generate link to delete bucket.
|
@@ -1098,8 +1099,8 @@ module RightAws
|
|
1098
1099
|
#
|
1099
1100
|
# bucket.get('logs/today/1.log', 1.hour) #=> https://s3.amazonaws.com:443/my_awesome_bucket/logs%2Ftoday%2F1.log?Signature=h...M%3D&Expires=1180820032&AWSAccessKeyId=1...2
|
1100
1101
|
#
|
1101
|
-
def get(expires=nil, headers={})
|
1102
|
-
@bucket.s3.interface.get_link(@bucket.to_s, @name, expires, headers)
|
1102
|
+
def get(expires=nil, headers={}, response_params={})
|
1103
|
+
@bucket.s3.interface.get_link(@bucket.to_s, @name, expires, headers, response_params)
|
1103
1104
|
end
|
1104
1105
|
|
1105
1106
|
# Generate link to delete key.
|