right_aws_api 0.1.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.
- checksums.yaml +7 -0
- data/HISTORY +2 -0
- data/LICENSE +19 -0
- data/README.md +164 -0
- data/Rakefile +38 -0
- data/lib/cloud/aws/as/manager.rb +118 -0
- data/lib/cloud/aws/base/helpers/utils.rb +328 -0
- data/lib/cloud/aws/base/manager.rb +186 -0
- data/lib/cloud/aws/base/parsers/response_error.rb +117 -0
- data/lib/cloud/aws/base/routines/request_signer.rb +80 -0
- data/lib/cloud/aws/cf/manager.rb +171 -0
- data/lib/cloud/aws/cf/routines/request_signer.rb +70 -0
- data/lib/cloud/aws/cf/wrappers/default.rb +213 -0
- data/lib/cloud/aws/cfm/manager.rb +90 -0
- data/lib/cloud/aws/cw/manager.rb +113 -0
- data/lib/cloud/aws/eb/manager.rb +87 -0
- data/lib/cloud/aws/ec/manager.rb +91 -0
- data/lib/cloud/aws/ec2/manager.rb +222 -0
- data/lib/cloud/aws/elb/manager.rb +120 -0
- data/lib/cloud/aws/emr/manager.rb +86 -0
- data/lib/cloud/aws/iam/manager.rb +100 -0
- data/lib/cloud/aws/rds/manager.rb +110 -0
- data/lib/cloud/aws/route53/manager.rb +177 -0
- data/lib/cloud/aws/route53/routines/request_signer.rb +70 -0
- data/lib/cloud/aws/route53/wrappers/default.rb +132 -0
- data/lib/cloud/aws/s3/manager.rb +373 -0
- data/lib/cloud/aws/s3/parsers/response_error.rb +76 -0
- data/lib/cloud/aws/s3/routines/request_signer.rb +243 -0
- data/lib/cloud/aws/s3/wrappers/default.rb +315 -0
- data/lib/cloud/aws/sdb/manager.rb +150 -0
- data/lib/cloud/aws/sns/manager.rb +96 -0
- data/lib/cloud/aws/sqs/manager.rb +335 -0
- data/lib/right_aws_api.rb +45 -0
- data/lib/right_aws_api_version.rb +40 -0
- data/right_aws_api.gemspec +55 -0
- data/spec/describe_calls.rb +92 -0
- metadata +118 -0
@@ -0,0 +1,87 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2013 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 NONINFRINGEMENT.
|
18
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
19
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
20
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
21
|
+
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
require "cloud/aws/base/manager"
|
25
|
+
|
26
|
+
module RightScale
|
27
|
+
module CloudApi
|
28
|
+
module AWS
|
29
|
+
|
30
|
+
# Elastic Beanstalk namespace
|
31
|
+
module EB
|
32
|
+
|
33
|
+
# Amazon Elastic Beanstalk (EB) compatible manager (thread safe).
|
34
|
+
#
|
35
|
+
# @example
|
36
|
+
# require "right_aws_api"
|
37
|
+
#
|
38
|
+
# eb = RightScale::CloudApi::AWS::EB::Manager::new(key, secret, 'https://elasticbeanstalk.us-east-1.amazonaws.com')
|
39
|
+
#
|
40
|
+
# # Get the descriptions of existing applications
|
41
|
+
# eb.DescribeApplications #=>
|
42
|
+
# {"DescribeApplicationsResponse"=>
|
43
|
+
# {"@xmlns"=>"http://elasticbeanstalk.amazonaws.com/docs/2010-12-01/",
|
44
|
+
# "DescribeApplicationsResult"=>{"Applications"=>nil},
|
45
|
+
# "ResponseMetadata"=>{"RequestId"=>"b7c61b5a-4f69-11e2-a3d0-a772ddd49d31"}}}
|
46
|
+
#
|
47
|
+
# @example
|
48
|
+
# # Create a new application
|
49
|
+
# eb.CreateApplication('ApplicationName' => 'MyApp',
|
50
|
+
# 'Description' => 'My Description')
|
51
|
+
#
|
52
|
+
# @see ApiManager
|
53
|
+
# @see http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_Operations.html
|
54
|
+
#
|
55
|
+
class Manager < AWS::Manager
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
# Amazon Elastic Beanstalk (EB) compatible manager (thread unsafe).
|
60
|
+
#
|
61
|
+
# @see Manager
|
62
|
+
#
|
63
|
+
class ApiManager < AWS::ApiManager
|
64
|
+
|
65
|
+
# Default API version for ElasticBeanstalk service.
|
66
|
+
# To override the API version use :api_version key when instantiating a manager.
|
67
|
+
#
|
68
|
+
DEFAULT_API_VERSION = '2010-12-01'
|
69
|
+
|
70
|
+
error_pattern :abort_on_timeout, :path => /Action=(Create)/
|
71
|
+
error_pattern :retry, :response => /InternalError|Unavailable/i
|
72
|
+
error_pattern :disconnect_and_abort, :code => /5..|403|408/
|
73
|
+
error_pattern :disconnect_and_abort, :code => /4../, :if => Proc.new{ |opts| rand(100) < 10 }
|
74
|
+
|
75
|
+
set :response_error_parser => Parser::AWS::ResponseErrorV2
|
76
|
+
|
77
|
+
cache_pattern :verb => /get|post/,
|
78
|
+
:path => /Action=Describe|List/,
|
79
|
+
:if => Proc::new{ |o| (o[:params].keys - COMMON_QUERY_PARAMS)._blank? },
|
80
|
+
:key => Proc::new{ |o| o[:params]['Action'] },
|
81
|
+
:sign => Proc::new{ |o| o[:response].body.to_s.sub(%r{<RequestId>.+?</RequestId>}i,'') }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2013 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 NONINFRINGEMENT.
|
18
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
19
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
20
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
21
|
+
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
require "cloud/aws/base/manager"
|
25
|
+
|
26
|
+
module RightScale
|
27
|
+
module CloudApi
|
28
|
+
module AWS
|
29
|
+
|
30
|
+
# ElastiCache namespace
|
31
|
+
module EC
|
32
|
+
|
33
|
+
# Amazon ElastiCache (EC) compatible manager (thread safe).
|
34
|
+
#
|
35
|
+
# @example
|
36
|
+
# require "right_aws_api"
|
37
|
+
#
|
38
|
+
# eb = RightScale::CloudApi::AWS::EC::Manager::new(key, secret, 'https://elasticache.us-east-1.amazonaws.com')
|
39
|
+
#
|
40
|
+
# # Get information about all provisioned Cache Clusters if no Cache Cluster identifier is specified,
|
41
|
+
# # or about a specific Cache Cluster if a Cache Cluster identifier is supplied
|
42
|
+
# eb.DescribeCacheClusters #=>
|
43
|
+
# {"DescribeApplicationsResponse"=>
|
44
|
+
# {"@xmlns"=>"http://elasticbeanstalk.amazonaws.com/docs/2010-12-01/",
|
45
|
+
# "DescribeApplicationsResult"=>{"Applications"=>nil},
|
46
|
+
# "ResponseMetadata"=>{"RequestId"=>"b7c61b5a-4f69-11e2-a3d0-a772ddd49d31"}}}
|
47
|
+
#
|
48
|
+
# @example
|
49
|
+
# # Get a list of CacheSubnetGroup descriptions
|
50
|
+
# eb.DescribeCacheSubnetGroups #=>
|
51
|
+
# {"DescribeCacheSubnetGroupsResponse"=>
|
52
|
+
# {"@xmlns"=>"http://elasticache.amazonaws.com/doc/2012-11-15/",
|
53
|
+
# "DescribeCacheSubnetGroupsResult"=>{"CacheSubnetGroups"=>nil},
|
54
|
+
# "ResponseMetadata"=>{"RequestId"=>"ae3546cb-4f6e-11e2-b196-0b589a77da67"}}}
|
55
|
+
#
|
56
|
+
# @see ApiManager
|
57
|
+
# @see http://docs.aws.amazon.com/AmazonElastiCache/latest/APIReference/API_Operations.html
|
58
|
+
#
|
59
|
+
class Manager < AWS::Manager
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
# Amazon ElastiCache (EC) compatible manager (thread unsafe).
|
64
|
+
#
|
65
|
+
# @see Manager
|
66
|
+
#
|
67
|
+
class ApiManager < AWS::ApiManager
|
68
|
+
|
69
|
+
# Default API version for ElastiCache service.
|
70
|
+
# To override the API version use :api_version key when instantiating a manager.
|
71
|
+
#
|
72
|
+
DEFAULT_API_VERSION = '2012-11-15'
|
73
|
+
|
74
|
+
error_pattern :abort_on_timeout, :path => /Action=(Create|Purchase)/
|
75
|
+
error_pattern :retry, :response => /InternalError|Unavailable/i
|
76
|
+
error_pattern :disconnect_and_abort, :code => /5..|403|408/
|
77
|
+
error_pattern :disconnect_and_abort, :code => /4../, :if => Proc.new{ |opts| rand(100) < 10 }
|
78
|
+
|
79
|
+
set :response_error_parser => Parser::AWS::ResponseErrorV2
|
80
|
+
|
81
|
+
cache_pattern :verb => /get|post/,
|
82
|
+
:path => /Action=Describe/,
|
83
|
+
:if => Proc::new{ |o| (o[:params].keys - COMMON_QUERY_PARAMS)._blank? },
|
84
|
+
:key => Proc::new{ |o| o[:params]['Action'] },
|
85
|
+
:sign => Proc::new{ |o| o[:response].body.to_s.sub(%r{<RequestId>.+?</RequestId>}i,'') }
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,222 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2013 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 NONINFRINGEMENT.
|
18
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
19
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
20
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
21
|
+
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
require "cloud/aws/base/manager"
|
25
|
+
|
26
|
+
module RightScale
|
27
|
+
module CloudApi
|
28
|
+
module AWS
|
29
|
+
|
30
|
+
# Elastic Compute Cloud namespace
|
31
|
+
module EC2
|
32
|
+
# Amazon Elastic Compute Cloud (EC2) compatible manager (thread safe).
|
33
|
+
#
|
34
|
+
# @example
|
35
|
+
# require "right_aws_api"
|
36
|
+
#
|
37
|
+
# # Create a manager to access EC2.
|
38
|
+
# ec2 = RightScale::CloudApi::AWS::EC2::Manager::new(key, secret, 'https://us-east-1.ec2.amazonaws.com')
|
39
|
+
#
|
40
|
+
# ec2.ThisCallMustBeSupportedByEc2('Param.1' => 'A', 'Param.2' => 'B')
|
41
|
+
#
|
42
|
+
# If there is a new API version just pass it to the manager and woohoo!
|
43
|
+
#
|
44
|
+
# @example
|
45
|
+
# ec2 = RightScale::CloudApi::AWS::EC2::new(key, secret, 'https://us-east-1.ec2.amazonaws.com', :api_version => "2010-08-31" )
|
46
|
+
# ec2.DescribeInternetGateways # => Gateways list
|
47
|
+
#
|
48
|
+
# ec2 = RightScale::CloudApi::AWS::EC2::new(key, secret, 'https://us-east-1.ec2.amazonaws.com', :api_version => "2011-05-15" )
|
49
|
+
# ec2.DescribeInternetGateways # => Exception
|
50
|
+
#
|
51
|
+
# # Or even pass a different API version when making a call!
|
52
|
+
# ec2 = RightScale::CloudApi::AWS::EC2::new(key, secret, 'https://us-east-1.ec2.amazonaws.com', :api_version => "2010-08-31" )
|
53
|
+
# ec2.DescribeInternetGateways("InternetGatewayId"=>"igw-55660000") # => Exception
|
54
|
+
# ec2.DescribeInternetGateways("InternetGatewayId"=>"igw-55660000", :options => { :api_version => "2011-05-15" }) #=> Gateway data
|
55
|
+
#
|
56
|
+
# @example
|
57
|
+
# # Get a list of your instances
|
58
|
+
# ec2.DescribeInstances
|
59
|
+
#
|
60
|
+
# # Describe custom Instance(s)
|
61
|
+
# ec2.DescribeInstances('InstanceId' => "i-2ba7c640")
|
62
|
+
# ec2.DescribeInstances('InstanceId.1' => "i-2ba7c640",
|
63
|
+
# 'InstanceId.2' => "i-7db9101e")
|
64
|
+
# ec2.DescribeInstances('InstanceId' => ["i-2ba7c640", "i-7db9101e"])
|
65
|
+
#
|
66
|
+
# @example
|
67
|
+
# # Describe Instances with filtering:
|
68
|
+
# ec2.DescribeInstances( 'Filter.1.Name' => 'architecture',
|
69
|
+
# 'Filter.1.Value' => 'i386',
|
70
|
+
# 'Filter.2.Name' => 'availability-zone',
|
71
|
+
# 'Filter.2.Value.1' => 'us-east-1a',
|
72
|
+
# 'Filter.2.Value.2' => 'us-east-1d',
|
73
|
+
# 'Filter.3.Name' => 'instance-type',
|
74
|
+
# 'Filter.3.Value' => 'm1.small')
|
75
|
+
#
|
76
|
+
# # (produces the same result as the request above)
|
77
|
+
# ec2.DescribeInstances( 'Filter' => [{ 'Name' => 'architecture', 'Value' => 'i386'},
|
78
|
+
# { 'Name' => 'availability-zone', 'Value' => [ 'us-east-1a', 'us-east-1d' ]},
|
79
|
+
# { 'Name' => 'instance-type', 'Value' => 'm1.small'}] )
|
80
|
+
#
|
81
|
+
# @example
|
82
|
+
# # Run an instance:
|
83
|
+
# ec2.RunInstances( 'ImageId' => 'ami-8ef607e7',
|
84
|
+
# 'MinCount' => 1,
|
85
|
+
# 'MaxCount' => 1,
|
86
|
+
# 'KeyName' => 'kd: alex',
|
87
|
+
# 'UserData' => RightScale::CloudApi::Utils::base64en('Hehehehe!!!!'),
|
88
|
+
# 'InstanceType' => 'c1.medium',
|
89
|
+
# 'ClientToken' => RightScale::CloudApi::Utils::generate_token,
|
90
|
+
# 'SecurityGroupId.1' => 'sg-f71a089e',
|
91
|
+
# 'SecurityGroupId.2' => 'sg-c71a08ae',
|
92
|
+
# 'Placement.AvailabilityZone' => 'us-east-1d',
|
93
|
+
# 'Placement.Tenancy' => 'default',
|
94
|
+
# 'BlockDeviceMapping.1.DeviceName' => '/dev/sdb',
|
95
|
+
# 'BlockDeviceMapping.1.Ebs.SnapshotId' => 'snap-f338e591',
|
96
|
+
# 'BlockDeviceMapping.1.Ebs.VolumeSize' => 2,
|
97
|
+
# 'BlockDeviceMapping.1.Ebs.DeleteOnTermination' => true,
|
98
|
+
# 'BlockDeviceMapping.2.DeviceName' => '/dev/sdc',
|
99
|
+
# 'BlockDeviceMapping.2.Ebs.SnapshotId' => 'snap-e40fd188',
|
100
|
+
# 'BlockDeviceMapping.2.Ebs.VolumeSize' => 3,
|
101
|
+
# 'BlockDeviceMapping.2.Ebs.DeleteOnTermination' => true ) #=> see below
|
102
|
+
#
|
103
|
+
# # or run it like this:
|
104
|
+
# ec2.RunInstances(
|
105
|
+
# 'ImageId' => 'ami-8ef607e7',
|
106
|
+
# 'MinCount' => 1,
|
107
|
+
# 'MaxCount' => 1,
|
108
|
+
# 'KeyName' => 'kd: alex',
|
109
|
+
# 'UserData' => RightScale::CloudApi::Utils::base64en('Hehehehe!!!!'),
|
110
|
+
# 'InstanceType' => 'c1.medium',
|
111
|
+
# 'ClientToken' => RightScale::CloudApi::Utils::generate_token,
|
112
|
+
# 'SecurityGroupId' => [ 'sg-f71a089e', 'sg-c71a08ae' ],
|
113
|
+
# 'Placement+' => { 'AvailabilityZone' => 'us-east-1d',
|
114
|
+
# 'Tenancy' => 'default'},
|
115
|
+
# 'BlockDeviceMapping' => [ { 'DeviceName' => '/dev/sdb',
|
116
|
+
# 'Ebs.SnapshotId' => 'snap-f338e591', # way #1
|
117
|
+
# 'Ebs.VolumeSize' => 2,
|
118
|
+
# 'Ebs.DeleteOnTermination' => true },
|
119
|
+
# { 'DeviceName' => '/dev/sdc',
|
120
|
+
# 'Ebs' => { 'SnapshotId' => 'snap-e40fd188', # way #2
|
121
|
+
# 'VolumeSize' => 3,
|
122
|
+
# 'DeleteOnTermination' => true } } ] ) #=>
|
123
|
+
# {"RunInstancesResponse"=>
|
124
|
+
# {"reservationId"=>"r-c8ca9ca6",
|
125
|
+
# "requestId"=>"04632453-adbf-460b-b101-1d9c11df9a60",
|
126
|
+
# "groupSet"=>
|
127
|
+
# {"item"=>
|
128
|
+
# [{"groupName"=>"kd-hehehe", "groupId"=>"sg-f71a089e"},
|
129
|
+
# {"groupName"=>"kd-hehehe-1", "groupId"=>"sg-c71a08ae"}]},
|
130
|
+
# "instancesSet"=>
|
131
|
+
# {"item"=>
|
132
|
+
# {"keyName"=>"kd: alex",
|
133
|
+
# "stateReason"=>{"code"=>"pending", "message"=>"pending"},
|
134
|
+
# "hypervisor"=>"xen",
|
135
|
+
# "ramdiskId"=>"ari-a51cf9cc",
|
136
|
+
# "blockDeviceMapping"=>nil,
|
137
|
+
# "productCodes"=>nil,
|
138
|
+
# "groupSet"=>
|
139
|
+
# {"item"=>
|
140
|
+
# [{"groupName"=>"kd-hehehe", "groupId"=>"sg-f71a089e"},
|
141
|
+
# {"groupName"=>"kd-hehehe-1", "groupId"=>"sg-c71a08ae"}]},
|
142
|
+
# "clientToken"=>"5d8248d4d6653a1b5127222b7902854a93f7",
|
143
|
+
# "imageId"=>"ami-8ef607e7",
|
144
|
+
# "amiLaunchIndex"=>"0",
|
145
|
+
# "launchTime"=>"2011-11-07T19:45:34.000Z",
|
146
|
+
# "kernelId"=>"aki-a71cf9ce",
|
147
|
+
# "reason"=>nil,
|
148
|
+
# "instanceType"=>"c1.medium",
|
149
|
+
# "instanceId"=>"i-67c87504",
|
150
|
+
# "placement"=>
|
151
|
+
# {"groupName"=>nil,
|
152
|
+
# "tenancy"=>"default",
|
153
|
+
# "availabilityZone"=>"us-east-1d"},
|
154
|
+
# "rootDeviceType"=>"ebs",
|
155
|
+
# "rootDeviceName"=>"/dev/sda1",
|
156
|
+
# "privateDnsName"=>nil,
|
157
|
+
# "dnsName"=>nil,
|
158
|
+
# "instanceState"=>{"name"=>"pending", "code"=>"0"},
|
159
|
+
# "monitoring"=>{"state"=>"disabled"},
|
160
|
+
# "virtualizationType"=>"paravirtual"}},
|
161
|
+
# "ownerId"=>"826693181925",
|
162
|
+
# "@xmlns"=>"http://ec2.amazonaws.com/doc/2011-07-15/"}}
|
163
|
+
#
|
164
|
+
# @example
|
165
|
+
# # Terminate your instance:
|
166
|
+
# ec2.TerminateInstances( "InstanceId" => "i-67c87504") #=>
|
167
|
+
# {
|
168
|
+
# "TerminateInstancesResponse" => {
|
169
|
+
# "@xmlns" => "http://ec2.amazonaws.com/doc/2011-07-15/",
|
170
|
+
# "instancesSet" => {
|
171
|
+
# "item" => {
|
172
|
+
# "currentState" => {
|
173
|
+
# "code" => "48",
|
174
|
+
# "name" => "terminated"
|
175
|
+
# },
|
176
|
+
# "instanceId" => "i-67c87504",
|
177
|
+
# "previousState" => {
|
178
|
+
# "code" => "48",
|
179
|
+
# "name" => "terminated"
|
180
|
+
# }
|
181
|
+
# }
|
182
|
+
# },
|
183
|
+
# "requestId" => "bf966c52-ee28-4eb2-af1c-dceff7bff231"
|
184
|
+
# }
|
185
|
+
# }
|
186
|
+
#
|
187
|
+
# @see ApiManager
|
188
|
+
# @see http://docs.aws.amazon.com/AWSEC2/latest/APIReference
|
189
|
+
#
|
190
|
+
class Manager < AWS::Manager
|
191
|
+
end
|
192
|
+
|
193
|
+
|
194
|
+
# Amazon Elastic Compute Cloud (EC2) compatible manager (thread unsafe).
|
195
|
+
#
|
196
|
+
# @see Manager
|
197
|
+
#
|
198
|
+
class ApiManager < AWS::ApiManager
|
199
|
+
|
200
|
+
# Default API version for EC2 service.
|
201
|
+
# To override the API version use :api_version key when instantiating a manager.
|
202
|
+
#
|
203
|
+
DEFAULT_API_VERSION = '2013-02-01'
|
204
|
+
|
205
|
+
error_pattern :abort_on_timeout, :path => /Action=(Run|Create|Purchase)/
|
206
|
+
error_pattern :abort, :response => /InsufficientInstanceCapacity/i
|
207
|
+
error_pattern :retry, :response => /InternalError|Unavailable|Internal Server Error/i
|
208
|
+
error_pattern :retry, :response => /Please try again|no response from/i
|
209
|
+
error_pattern :disconnect_and_abort, :code => /5..|403|408/
|
210
|
+
error_pattern :disconnect_and_abort, :code => /4../, :if => Proc.new{ |opts| rand(100) < 10 }
|
211
|
+
|
212
|
+
cache_pattern :verb => /get|post/,
|
213
|
+
:path => /Action=Describe/,
|
214
|
+
:if => Proc::new{ |o| (o[:params].keys - COMMON_QUERY_PARAMS)._blank? },
|
215
|
+
:key => Proc::new{ |o| o[:params]['Action'] },
|
216
|
+
:sign => Proc::new{ |o| o[:response].body.to_s.sub(%r{<requestId>.+?</requestId>}i,'') }
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2013 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 NONINFRINGEMENT.
|
18
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
19
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
20
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
21
|
+
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
require "cloud/aws/base/manager"
|
25
|
+
|
26
|
+
module RightScale
|
27
|
+
module CloudApi
|
28
|
+
module AWS
|
29
|
+
|
30
|
+
# Elastic Load Balancing namespace
|
31
|
+
module ELB
|
32
|
+
|
33
|
+
# Amazon Elastic Load Balancing (ELB) compatible manager (thread safe).
|
34
|
+
#
|
35
|
+
# @example
|
36
|
+
# require "right_aws_api"
|
37
|
+
#
|
38
|
+
# elb = RightScale::CloudApi::AWS::ELB::Manager::new(key, secret, 'https://elasticloadbalancing.amazonaws.com')
|
39
|
+
#
|
40
|
+
# # List Load Balancers
|
41
|
+
# elb.DescribeLoadBalancers #=>
|
42
|
+
# {"DescribeLoadBalancersResponse"=>
|
43
|
+
# {"@xmlns"=>"http://elasticloadbalancing.amazonaws.com/doc/2011-11-15/",
|
44
|
+
# "DescribeLoadBalancersResult"=>
|
45
|
+
# {"LoadBalancerDescriptions"=>
|
46
|
+
# {"member"=>
|
47
|
+
# [{"SecurityGroups"=>nil,
|
48
|
+
# "CreatedTime"=>"2011-05-20T00:07:57.390Z",
|
49
|
+
# "LoadBalancerName"=>"test",
|
50
|
+
# "HealthCheck"=>
|
51
|
+
# {"Interval"=>"30",
|
52
|
+
# "Target"=>"TCP:80",
|
53
|
+
# "HealthyThreshold"=>"10",
|
54
|
+
# "Timeout"=>"5",
|
55
|
+
# "UnhealthyThreshold"=>"2"},
|
56
|
+
# "ListenerDescriptions"=>
|
57
|
+
# {"member"=>
|
58
|
+
# {"PolicyNames"=>nil,
|
59
|
+
# "Listener"=>
|
60
|
+
# {"Protocol"=>"HTTP",
|
61
|
+
# "LoadBalancerPort"=>"80",
|
62
|
+
# "InstanceProtocol"=>"HTTP",
|
63
|
+
# "InstancePort"=>"80"}}},
|
64
|
+
# "Instances"=>nil,
|
65
|
+
# "Policies"=>
|
66
|
+
# {"AppCookieStickinessPolicies"=>nil,
|
67
|
+
# "OtherPolicies"=>nil,
|
68
|
+
# "LBCookieStickinessPolicies"=>nil},
|
69
|
+
# "AvailabilityZones"=>
|
70
|
+
# {"member"=>
|
71
|
+
# ["us-east-1c", "us-east-1b", "us-east-1a", "us-east-1d"]},
|
72
|
+
# "CanonicalHostedZoneName"=>
|
73
|
+
# "test-1900221105.us-east-1.elb.amazonaws.com",
|
74
|
+
# "CanonicalHostedZoneNameID"=>"Z3DZXE0Q79N41H",
|
75
|
+
# "SourceSecurityGroup"=>
|
76
|
+
# {"OwnerAlias"=>"amazon-elb", "GroupName"=>"amazon-elb-sg"},
|
77
|
+
# "DNSName"=>"test-1900221105.us-east-1.elb.amazonaws.com",
|
78
|
+
# "BackendServerDescriptions"=>nil,
|
79
|
+
# "Subnets"=>nil}]}},
|
80
|
+
# "ResponseMetadata"=>{"RequestId"=>"a96cfe8c-4f70-11e2-a887-0189db71cd82"}}}
|
81
|
+
#
|
82
|
+
# @example
|
83
|
+
# # Delete a Load Balancer
|
84
|
+
# elb.DeleteLoadBalancer('LoadBalancerName' => 'MyLoadBalancere')
|
85
|
+
#
|
86
|
+
# @see ApiManager
|
87
|
+
# @see http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_Operations.html
|
88
|
+
#
|
89
|
+
class Manager < AWS::Manager
|
90
|
+
end
|
91
|
+
|
92
|
+
# Amazon Elastic Load Balancing (ELB) compatible manager (thread unsafe).
|
93
|
+
#
|
94
|
+
# @see Manager
|
95
|
+
#
|
96
|
+
class ApiManager < AWS::ApiManager
|
97
|
+
|
98
|
+
# Default API version for ELB service.
|
99
|
+
# To override the API version use :api_version key when instantiating a manager.
|
100
|
+
#
|
101
|
+
DEFAULT_API_VERSION = '2012-06-01'
|
102
|
+
|
103
|
+
error_pattern :abort_on_timeout, :path => /Action=(Create)/
|
104
|
+
error_pattern :retry, :response => /InternalError|Unavailable/i
|
105
|
+
error_pattern :disconnect_and_abort, :code => /5..|403|408/
|
106
|
+
error_pattern :disconnect_and_abort, :code => /4../, :if => Proc.new{ |opts| rand(100) < 10 }
|
107
|
+
|
108
|
+
set :response_error_parser => Parser::AWS::ResponseErrorV2
|
109
|
+
|
110
|
+
cache_pattern :verb => /get|post/,
|
111
|
+
:path => /Action=Describe/,
|
112
|
+
:if => Proc::new{ |o| (o[:params].keys - COMMON_QUERY_PARAMS)._blank? },
|
113
|
+
:key => Proc::new{ |o| o[:params]['Action'] },
|
114
|
+
:sign => Proc::new{ |o| o[:response].body.to_s.sub(%r{<RequestId>.+?</RequestId>}i,'') }
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|