mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge branch 'master' into rs_lb
This commit is contained in:
commit
fc39a18ae9
183 changed files with 2151 additions and 212 deletions
3
Rakefile
3
Rakefile
|
@ -236,9 +236,6 @@ task :changelog do
|
|||
file.write("\n\n")
|
||||
file.write(old_changelog)
|
||||
end
|
||||
|
||||
`echo "#{changelog.join("\n")}" | pbcopy`
|
||||
p 'changelog copied to clipboard'
|
||||
end
|
||||
|
||||
task :docs do
|
||||
|
|
5
bin/fog
5
bin/fog
|
@ -19,7 +19,10 @@ end
|
|||
|
||||
if ARGV.length > 1
|
||||
|
||||
puts(instance_eval(ARGV[1..-1].join(' ')).to_json)
|
||||
require 'multi_json'
|
||||
|
||||
result = instance_eval(ARGV[1..-1].join(' '))
|
||||
puts(MultiJson.encode(result))
|
||||
|
||||
else
|
||||
|
||||
|
|
|
@ -37,13 +37,13 @@ Gem::Specification.new do |s|
|
|||
## List your runtime dependencies here. Runtime dependencies are those
|
||||
## that are needed for an end user to actually USE your code.
|
||||
s.add_dependency('builder')
|
||||
s.add_dependency('excon', '~>0.6.4')
|
||||
s.add_dependency('formatador', '~>0.1.5')
|
||||
s.add_dependency('multi_json', '~> 1.0')
|
||||
s.add_dependency('excon', '~>0.6.5')
|
||||
s.add_dependency('formatador', '~>0.2.0')
|
||||
s.add_dependency('multi_json', '~>1.0.3')
|
||||
s.add_dependency('mime-types')
|
||||
s.add_dependency('net-scp', '~>1.0.4')
|
||||
s.add_dependency('net-ssh', '~>2.1.4')
|
||||
s.add_dependency('nokogiri', '~>1.4.4')
|
||||
s.add_dependency('nokogiri', '~>1.5.0')
|
||||
s.add_dependency('ruby-hmac')
|
||||
|
||||
## List your development dependencies here. Development dependencies are
|
||||
|
|
|
@ -144,34 +144,33 @@ module Fog
|
|||
:version => '2011-04-05'
|
||||
}
|
||||
)
|
||||
begin
|
||||
response = @connection.request({
|
||||
:body => body,
|
||||
:expects => 200,
|
||||
:headers => { 'Content-Type' => 'application/x-www-form-urlencoded' },
|
||||
:idempotent => idempotent,
|
||||
:host => @host,
|
||||
:method => 'POST',
|
||||
:parser => parser
|
||||
})
|
||||
rescue Excon::Errors::HTTPStatusError => error
|
||||
if match = error.message.match(/<Code>(.*)<\/Code>/m)
|
||||
case match[1]
|
||||
when 'LoadBalancerNotFound'
|
||||
raise Fog::AWS::ELB::NotFound
|
||||
when 'DuplicateLoadBalancerName'
|
||||
raise Fog::AWS::ELB::IdentifierTaken
|
||||
when 'InvalidInstance'
|
||||
raise Fog::AWS::ELB::InvalidInstance
|
||||
else
|
||||
raise
|
||||
end
|
||||
|
||||
response = @connection.request({
|
||||
:body => body,
|
||||
:expects => 200,
|
||||
:headers => { 'Content-Type' => 'application/x-www-form-urlencoded' },
|
||||
:idempotent => idempotent,
|
||||
:host => @host,
|
||||
:method => 'POST',
|
||||
:parser => parser
|
||||
})
|
||||
rescue Excon::Errors::HTTPStatusError => error
|
||||
if match = error.message.match(/<Code>(.*)<\/Code>(?:.*<Message>(.*)<\/Message>)?/m)
|
||||
case match[1]
|
||||
when 'CertificateNotFound'
|
||||
raise Fog::AWS::IAM::NotFound.slurp(error, match[2])
|
||||
when 'LoadBalancerNotFound'
|
||||
raise Fog::AWS::ELB::NotFound.slurp(error, match[2])
|
||||
when 'DuplicateLoadBalancerName'
|
||||
raise Fog::AWS::ELB::IdentifierTaken.slurp(error, match[2])
|
||||
when 'InvalidInstance'
|
||||
raise Fog::AWS::ELB::InvalidInstance.slurp(error, match[2])
|
||||
else
|
||||
raise
|
||||
end
|
||||
else
|
||||
raise
|
||||
end
|
||||
|
||||
response
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -31,6 +31,7 @@ module Fog
|
|||
request :get_user_policy
|
||||
request :get_group
|
||||
request :get_group_policy
|
||||
request :get_server_certificate
|
||||
request :list_access_keys
|
||||
request :list_account_aliases
|
||||
request :list_groups
|
||||
|
@ -152,7 +153,7 @@ module Fog
|
|||
rescue Excon::Errors::HTTPStatusError => error
|
||||
if match = error.message.match(/<Code>(.*)<\/Code>(?:.*<Message>(.*)<\/Message>)?/m)
|
||||
case match[1]
|
||||
when 'CertificateNotFound'
|
||||
when 'CertificateNotFound', 'NoSuchEntity'
|
||||
raise Fog::AWS::IAM::NotFound.slurp(error, match[2])
|
||||
when 'EntityAlreadyExists'
|
||||
raise Fog::AWS::IAM::EntityAlreadyExists.slurp(error, match[2])
|
||||
|
|
|
@ -11,8 +11,8 @@ module Fog
|
|||
attribute :ssl_id, :aliases => 'SSLCertificateId'
|
||||
|
||||
def initialize(attributes={})
|
||||
defaults = {:policy_names => [], :instance_port => 80, :lb_port => 80, :protocol => 'HTTP'}
|
||||
attributes = defaults.merge(attributes)
|
||||
# set defaults, which may be overridden in super
|
||||
merge_attributes(:policy_names => [], :instance_port => 80, :lb_port => 80, :protocol => 'HTTP')
|
||||
super
|
||||
end
|
||||
|
||||
|
|
24
lib/fog/aws/parsers/sns/add_permission.rb
Normal file
24
lib/fog/aws/parsers/sns/add_permission.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module AWS
|
||||
module SNS
|
||||
|
||||
class AddPermission < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = {}
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'RequestId'
|
||||
@response[name] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
24
lib/fog/aws/parsers/sns/confirm_subscription.rb
Normal file
24
lib/fog/aws/parsers/sns/confirm_subscription.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module AWS
|
||||
module SNS
|
||||
|
||||
class ConfirmSubscription < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = {}
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'SubscriptionArn', 'RequestId'
|
||||
@response[name] = @value.rstrip
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
24
lib/fog/aws/parsers/sns/create_topic.rb
Normal file
24
lib/fog/aws/parsers/sns/create_topic.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module AWS
|
||||
module SNS
|
||||
|
||||
class CreateTopic < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = {}
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'TopicArn', 'RequestId'
|
||||
@response[name] = @value.rstrip
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
24
lib/fog/aws/parsers/sns/delete_topic.rb
Normal file
24
lib/fog/aws/parsers/sns/delete_topic.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module AWS
|
||||
module SNS
|
||||
|
||||
class DeleteTopic < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = {}
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'RequestId'
|
||||
@response[name] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
32
lib/fog/aws/parsers/sns/get_topic_attributes.rb
Normal file
32
lib/fog/aws/parsers/sns/get_topic_attributes.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module AWS
|
||||
module SNS
|
||||
|
||||
class GetTopicAttributes < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = { 'Attributes' => {} }
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'key'
|
||||
@key = @value.rstrip
|
||||
when 'value'
|
||||
case @key
|
||||
when 'SubscriptionsConfirmed', 'SubscriptionsDeleted', 'SubscriptionsPending'
|
||||
@response['Attributes'][@key] = @value.rstrip.to_i
|
||||
else
|
||||
@response['Attributes'][@key] = @value.rstrip
|
||||
end
|
||||
when 'RequestId'
|
||||
@response[name] = @value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
29
lib/fog/aws/parsers/sns/list_subscriptions.rb
Normal file
29
lib/fog/aws/parsers/sns/list_subscriptions.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module AWS
|
||||
module SNS
|
||||
|
||||
class ListSubscriptions < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = { 'Subscriptions' => [] }
|
||||
@subscription = {}
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when "TopicArn", "Protocol", "SubscriptionArn", "Owner", "Endpoint"
|
||||
@subscription[name] = @value.rstrip
|
||||
when "member"
|
||||
@response['Subscriptions'] << @subscription
|
||||
@subscription = {}
|
||||
when 'RequestId', 'NextToken'
|
||||
@response[name] = @value.rstrip
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
26
lib/fog/aws/parsers/sns/list_topics.rb
Normal file
26
lib/fog/aws/parsers/sns/list_topics.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module AWS
|
||||
module SNS
|
||||
|
||||
class ListTopics < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = { 'Topics' => [] }
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'TopicArn'
|
||||
@response['Topics'] << @value
|
||||
when 'NextToken', 'RequestId'
|
||||
response[name] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
24
lib/fog/aws/parsers/sns/publish.rb
Normal file
24
lib/fog/aws/parsers/sns/publish.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module AWS
|
||||
module SNS
|
||||
|
||||
class Publish < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = {}
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'MessageId', 'RequestId'
|
||||
@response[name] = @value.rstrip
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
24
lib/fog/aws/parsers/sns/remove_permission.rb
Normal file
24
lib/fog/aws/parsers/sns/remove_permission.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module AWS
|
||||
module SNS
|
||||
|
||||
class RemovePermission < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = {}
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'RequestId'
|
||||
@response[name] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
24
lib/fog/aws/parsers/sns/set_topic_attributes.rb
Normal file
24
lib/fog/aws/parsers/sns/set_topic_attributes.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module AWS
|
||||
module SNS
|
||||
|
||||
class SetTopicAttributes < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = {}
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'RequestId'
|
||||
@response[name] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
24
lib/fog/aws/parsers/sns/subscribe.rb
Normal file
24
lib/fog/aws/parsers/sns/subscribe.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module AWS
|
||||
module SNS
|
||||
|
||||
class Subscribe < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = {}
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'SubscriptionArn', 'RequestId'
|
||||
@response[name] = @value.rstrip
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
24
lib/fog/aws/parsers/sns/unsubscribe.rb
Normal file
24
lib/fog/aws/parsers/sns/unsubscribe.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module AWS
|
||||
module SNS
|
||||
|
||||
class Unsubscribe < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = {}
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'RequestId'
|
||||
@response[name] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
23
lib/fog/aws/parsers/sqs/basic.rb
Normal file
23
lib/fog/aws/parsers/sqs/basic.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module AWS
|
||||
module SQS
|
||||
class Basic < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = { 'ResponseMetadata' => {} }
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'RequestId'
|
||||
@response['ResponseMetadata'][name] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
26
lib/fog/aws/parsers/sqs/create_queue.rb
Normal file
26
lib/fog/aws/parsers/sqs/create_queue.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module AWS
|
||||
module SQS
|
||||
|
||||
class CreateQueue < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = { 'ResponseMetadata' => {} }
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'RequestId'
|
||||
@response['ResponseMetadata'][name] = @value
|
||||
when 'QueueUrl'
|
||||
@response['QueueUrl'] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
35
lib/fog/aws/parsers/sqs/get_queue_attributes.rb
Normal file
35
lib/fog/aws/parsers/sqs/get_queue_attributes.rb
Normal file
|
@ -0,0 +1,35 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module AWS
|
||||
module SQS
|
||||
|
||||
class GetQueueAttributes < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = { 'ResponseMetadata' => {}, 'Attributes' => {}}
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'RequestId'
|
||||
@response['ResponseMetadata']['RequestId'] = @value
|
||||
when 'Name'
|
||||
@current_attribute_name = @value
|
||||
when 'Value'
|
||||
case @current_attribute_name
|
||||
when 'ApproximateNumberOfMessages', 'ApproximateNumberOfMessagesNotVisible', 'MaximumMessageSize', 'MessageRetentionPeriod', 'VisibilityTimeout'
|
||||
@response['Attributes'][@current_attribute_name] = @value.to_i
|
||||
when 'CreatedTimestamp', 'LastModifiedTimestamp'
|
||||
@response['Attributes'][@current_attribute_name] = Time.at(@value.to_i)
|
||||
else
|
||||
@response['Attributes'][@current_attribute_name] = @value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
25
lib/fog/aws/parsers/sqs/list_queues.rb
Normal file
25
lib/fog/aws/parsers/sqs/list_queues.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module AWS
|
||||
module SQS
|
||||
class ListQueues < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = { 'QueueUrls' => [], 'ResponseMetadata' => {} }
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'RequestId'
|
||||
@response['ResponseMetadata'][name] = @value
|
||||
when 'QueueUrl'
|
||||
@response['QueueUrls'] << @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
41
lib/fog/aws/parsers/sqs/receive_message.rb
Normal file
41
lib/fog/aws/parsers/sqs/receive_message.rb
Normal file
|
@ -0,0 +1,41 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module AWS
|
||||
module SQS
|
||||
|
||||
class ReceiveMessage < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@message = { 'Attributes' => {} }
|
||||
@response = { 'ResponseMetadata' => {}, 'Message' => []}
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'RequestId'
|
||||
@response['ResponseMetadata']['RequestId'] = @value
|
||||
when 'Message'
|
||||
@response['Message'] << @message
|
||||
@message = { 'Attributes' => {} }
|
||||
when 'Body', 'MD5OfBody', 'MessageId', 'ReceiptHandle'
|
||||
@message[name] = @value
|
||||
when 'Name'
|
||||
@current_attribute_name = @value
|
||||
when 'Value'
|
||||
case @current_attribute_name
|
||||
when 'ApproximateFirstReceiveTimestamp', 'SentTimestamp'
|
||||
@message['Attributes'][@current_attribute_name] = Time.at(@value.to_i)
|
||||
when 'ApproximateReceiveCount'
|
||||
@message['Attributes'][@current_attribute_name] = @value.to_i
|
||||
else
|
||||
@message['Attributes'][@current_attribute_name] = @value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
28
lib/fog/aws/parsers/sqs/send_message.rb
Normal file
28
lib/fog/aws/parsers/sqs/send_message.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module AWS
|
||||
module SQS
|
||||
|
||||
class SendMessage < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = { 'ResponseMetadata' => {} }
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'RequestId'
|
||||
@response['ResponseMetadata'][name] = @value
|
||||
when 'MessageId'
|
||||
@response['MessageId'] = @value
|
||||
when 'MD5OfMessageBody'
|
||||
@response['MD5OfMessageBody'] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -47,7 +47,6 @@ module Fog
|
|||
:parser => Fog::Parsers::AWS::ELB::CreateLoadBalancer.new
|
||||
}.merge!(params))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
@ -61,9 +60,7 @@ module Fog
|
|||
|
||||
listeners = [*listeners].map do |listener|
|
||||
if listener['SSLCertificateId'] and !certificate_ids.include? listener['SSLCertificateId']
|
||||
response.status = 400
|
||||
response.body = "<?xml version=\"1.0\"?><Response><Errors><Error><Code>CertificateNotFound</Code><Message>The specified SSL ID does not refer to a valid SSL certificate in the AWS Identity and Access Management Service..</Message></Error></Errors><RequestID>#{Fog::AWS::Mock.request_id}</RequestId></Response>"
|
||||
raise Excon::Errors.status_error({:expects => 200}, response)
|
||||
raise Fog::AWS::IAM::NotFound.new('CertificateNotFound')
|
||||
end
|
||||
{'Listener' => listener, 'PolicyNames' => []}
|
||||
end
|
||||
|
|
|
@ -56,9 +56,7 @@ module Fog
|
|||
|
||||
listeners.each do |listener|
|
||||
if listener['SSLCertificateId'] and !certificate_ids.include? listener['SSLCertificateId']
|
||||
response.status = 400
|
||||
response.body = "<?xml version=\"1.0\"?><Response><Errors><Error><Code>CertificateNotFound</Code><Message>The specified SSL ID does not refer to a valid SSL certificate in the AWS Identity and Access Management Service..</Message></Error></Errors><RequestID>#{Fog::AWS::Mock.request_id}</RequestId></Response>"
|
||||
raise Excon::Errors.status_error({:expects => 200}, response)
|
||||
raise Fog::AWS::IAM::NotFound.new('CertificateNotFound')
|
||||
end
|
||||
load_balancer['ListenerDescriptions'] << {'Listener' => listener, 'PolicyNames' => []}
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ module Fog
|
|||
# * 'ResponseMetadata'<~Hash>:
|
||||
# * 'RequestId'<~String> - Id of request
|
||||
def delete_load_balancer_listeners(lb_name, load_balancer_ports)
|
||||
params = Fog::AWS.indexed_param('LoadBalancerPorts.memeber.%d', load_balancer_ports)
|
||||
params = Fog::AWS.indexed_param('LoadBalancerPorts.member.%d', load_balancer_ports)
|
||||
|
||||
request({
|
||||
'Action' => 'DeleteLoadBalancerListeners',
|
||||
|
|
50
lib/fog/aws/requests/iam/get_server_certificate.rb
Normal file
50
lib/fog/aws/requests/iam/get_server_certificate.rb
Normal file
|
@ -0,0 +1,50 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class IAM
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/iam/upload_server_certificate'
|
||||
|
||||
# Gets the specified server certificate.
|
||||
#
|
||||
# ==== Parameters
|
||||
# * server_certificate_name<~String>: The name of the server certificate you want to get.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'RequestId'<~String> - Id of the request
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/IAM/latest/APIReference/API_GetServerCertificate.html
|
||||
#
|
||||
def get_server_certificate(server_certificate_name)
|
||||
request({
|
||||
'Action' => 'GetServerCertificate',
|
||||
'ServerCertificateName' => server_certificate_name,
|
||||
:parser => Fog::Parsers::AWS::IAM::UploadServerCertificate.new
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
def get_server_certificate(server_certificate_name)
|
||||
raise Fog::AWS::IAM::NotFound unless self.data[:server_certificates].key?(server_certificate_name)
|
||||
|
||||
response = Excon::Response.new
|
||||
response.status = 200
|
||||
response.body = {
|
||||
'Certificate' => self.data[:server_certificates][server_certificate_name],
|
||||
'RequestId' => Fog::AWS::Mock.request_id
|
||||
}
|
||||
|
||||
self.data[:server_certificates]
|
||||
|
||||
response
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -25,7 +25,7 @@ module Fog
|
|||
'Action' => 'PutGroupPolicy',
|
||||
'GroupName' => group_name,
|
||||
'PolicyName' => policy_name,
|
||||
'PolicyDocument' => policy_document.to_json,
|
||||
'PolicyDocument' => MultiJson.encode(policy_document),
|
||||
:parser => Fog::Parsers::AWS::IAM::Basic.new
|
||||
)
|
||||
end
|
||||
|
|
|
@ -24,7 +24,7 @@ module Fog
|
|||
request(
|
||||
'Action' => 'PutUserPolicy',
|
||||
'PolicyName' => policy_name,
|
||||
'PolicyDocument' => policy_document.to_json,
|
||||
'PolicyDocument' => MultiJson.encode(policy_document),
|
||||
'UserName' => user_name,
|
||||
:parser => Fog::Parsers::AWS::IAM::Basic.new
|
||||
)
|
||||
|
|
|
@ -48,7 +48,7 @@ module Fog
|
|||
class Mock
|
||||
|
||||
def get_attributes(domain_name, item_name, options = {})
|
||||
unless options.empty? || options['AttributeName']
|
||||
if options.is_a?(Array)
|
||||
Formatador.display_line("[yellow][WARN] get_attributes with array attributes param is deprecated, use 'AttributeName' => attributes) instead[/] [light_black](#{caller.first})[/]")
|
||||
options['AttributeName'] ||= options if options.is_a?(Array)
|
||||
end
|
||||
|
|
26
lib/fog/aws/requests/sns/add_permission.rb
Normal file
26
lib/fog/aws/requests/sns/add_permission.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SNS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/sns/add_permission'
|
||||
|
||||
def add_permission(options = {})
|
||||
request({
|
||||
'Action' => 'AddPermission',
|
||||
:parser => Fog::Parsers::AWS::SNS::AddPermission.new
|
||||
}.merge!(options))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def add_permission(options = {})
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
33
lib/fog/aws/requests/sns/confirm_subscription.rb
Normal file
33
lib/fog/aws/requests/sns/confirm_subscription.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SNS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/sns/confirm_subscription'
|
||||
|
||||
# Confirm a subscription
|
||||
#
|
||||
# ==== Parameters
|
||||
# * arn<~String> - Arn of topic to confirm subscription to
|
||||
# * token<~String> - Token sent to endpoint during subscribe action
|
||||
# * options<~Hash>:
|
||||
# * AuthenticateOnUnsubscribe<~Boolean> - whether or not unsubscription should be authenticated, defaults to false
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/sns/latest/api/API_ConfirmSubscription.html
|
||||
#
|
||||
|
||||
def confirm_subscription(arn, token, options = {})
|
||||
request({
|
||||
'Action' => 'ConfirmSubscription',
|
||||
'Token' => token,
|
||||
'TopicArn' => arn,
|
||||
:parser => Fog::Parsers::AWS::SNS::ConfirmSubscription.new
|
||||
}.merge!(options))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
29
lib/fog/aws/requests/sns/create_topic.rb
Normal file
29
lib/fog/aws/requests/sns/create_topic.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SNS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/sns/create_topic'
|
||||
|
||||
# Create a topic
|
||||
#
|
||||
# ==== Parameters
|
||||
# * name<~String> - Name of topic to create
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/sns/latest/api/API_CreateTopic.html
|
||||
#
|
||||
|
||||
def create_topic(name)
|
||||
request({
|
||||
'Action' => 'CreateTopic',
|
||||
'Name' => name,
|
||||
:parser => Fog::Parsers::AWS::SNS::CreateTopic.new
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
29
lib/fog/aws/requests/sns/delete_topic.rb
Normal file
29
lib/fog/aws/requests/sns/delete_topic.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SNS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/sns/delete_topic'
|
||||
|
||||
# Delete a topic
|
||||
#
|
||||
# ==== Parameters
|
||||
# * arn<~String> - The Arn of the topic to delete
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/sns/latest/api/API_DeleteTopic.html
|
||||
#
|
||||
|
||||
def delete_topic(arn)
|
||||
request({
|
||||
'Action' => 'DeleteTopic',
|
||||
'TopicArn' => arn,
|
||||
:parser => Fog::Parsers::AWS::SNS::DeleteTopic.new
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
29
lib/fog/aws/requests/sns/get_topic_attributes.rb
Normal file
29
lib/fog/aws/requests/sns/get_topic_attributes.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SNS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/sns/get_topic_attributes'
|
||||
|
||||
# Get attributes of a topic
|
||||
#
|
||||
# ==== Parameters
|
||||
# * arn<~Hash>: The Arn of the topic to get attributes for
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/sns/latest/api/API_GetTopicAttributes.html
|
||||
#
|
||||
|
||||
def get_topic_attributes(arn)
|
||||
request({
|
||||
'Action' => 'GetTopicAttributes',
|
||||
'TopicArn' => arn,
|
||||
:parser => Fog::Parsers::AWS::SNS::GetTopicAttributes.new
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
29
lib/fog/aws/requests/sns/list_subscriptions.rb
Normal file
29
lib/fog/aws/requests/sns/list_subscriptions.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SNS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/sns/list_subscriptions'
|
||||
|
||||
# List subscriptions
|
||||
#
|
||||
# ==== Parameters
|
||||
# * options<~Hash>:
|
||||
# * 'NextToken'<~String> - Token returned from previous request, used for pagination
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/sns/latest/api/API_ListSubscriptions.html
|
||||
#
|
||||
|
||||
def list_subscriptions(options = {})
|
||||
request({
|
||||
'Action' => 'ListSubscriptions',
|
||||
:parser => Fog::Parsers::AWS::SNS::ListSubscriptions.new
|
||||
}.merge!(options))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
31
lib/fog/aws/requests/sns/list_subscriptions_by_topic.rb
Normal file
31
lib/fog/aws/requests/sns/list_subscriptions_by_topic.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SNS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/sns/list_subscriptions'
|
||||
|
||||
# List subscriptions for a topic
|
||||
#
|
||||
# ==== Parameters
|
||||
# * arn<~String> - Arn of topic to list subscriptions for
|
||||
# * options<~Hash>:
|
||||
# * 'NextToken'<~String> - Token returned from previous request, used for pagination
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/sns/latest/api/API_ListSubscriptionsByTopic.html
|
||||
#
|
||||
|
||||
def list_subscriptions_by_topic(arn, options = {})
|
||||
request({
|
||||
'Action' => 'ListSubscriptionsByTopic',
|
||||
'TopicArn' => arn,
|
||||
:parser => Fog::Parsers::AWS::SNS::ListSubscriptions.new
|
||||
}.merge!(options))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
29
lib/fog/aws/requests/sns/list_topics.rb
Normal file
29
lib/fog/aws/requests/sns/list_topics.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SNS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/sns/list_topics'
|
||||
|
||||
# List topics
|
||||
#
|
||||
# ==== Parameters
|
||||
# * options<~Hash>:
|
||||
# * 'NextToken'<~String> - Token returned from previous request, used for pagination
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/sns/latest/api/API_ListTopics.html
|
||||
#
|
||||
|
||||
def list_topics(options = {})
|
||||
request({
|
||||
'Action' => 'ListTopics',
|
||||
:parser => Fog::Parsers::AWS::SNS::ListTopics.new
|
||||
}.merge!(options))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
34
lib/fog/aws/requests/sns/publish.rb
Normal file
34
lib/fog/aws/requests/sns/publish.rb
Normal file
|
@ -0,0 +1,34 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SNS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/sns/publish'
|
||||
|
||||
# Send a message to a topic
|
||||
#
|
||||
# ==== Parameters
|
||||
# * arn<~String> - Arn of topic to send message to
|
||||
# * message<~String> - Message to send to topic
|
||||
# * options<~Hash>:
|
||||
# * MessageStructure<~String> - message structure, in ['json']
|
||||
# * Subject<~String> - value to use for subject when delivering by email
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/sns/latest/api/API_Publish.html
|
||||
#
|
||||
|
||||
def publish(arn, message, options = {})
|
||||
request({
|
||||
'Action' => 'Publish',
|
||||
'Message' => message,
|
||||
'TopicArn' => arn,
|
||||
:parser => Fog::Parsers::AWS::SNS::Publish.new
|
||||
}.merge!(options))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
26
lib/fog/aws/requests/sns/remove_permission.rb
Normal file
26
lib/fog/aws/requests/sns/remove_permission.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SNS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/sns/remove_permission'
|
||||
|
||||
def remove_permission(options = {})
|
||||
request({
|
||||
'Action' => 'RemovePermission',
|
||||
:parser => Fog::Parsers::AWS::SNS::RemovePermission.new
|
||||
}.merge!(options))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def remove_permission(options = {})
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
33
lib/fog/aws/requests/sns/set_topic_attributes.rb
Normal file
33
lib/fog/aws/requests/sns/set_topic_attributes.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SNS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/sns/set_topic_attributes'
|
||||
|
||||
# Set attributes of a topic
|
||||
#
|
||||
# ==== Parameters
|
||||
# * arn<~Hash> - The Arn of the topic to get attributes for
|
||||
# * attribute_name<~String> - Name of attribute to set, in ['DisplayName', 'Policy']
|
||||
# * attribute_value<~String> - Value to set attribute to
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/sns/latest/api/API_SetTopicAttributes.html
|
||||
#
|
||||
|
||||
def set_topic_attributes(arn, attribute_name, attribute_value)
|
||||
request({
|
||||
'Action' => 'SetTopicAttributes',
|
||||
'AttributeName' => attribute_name,
|
||||
'AttributeValue' => attribute_value,
|
||||
'TopicArn' => arn,
|
||||
:parser => Fog::Parsers::AWS::SNS::SetTopicAttributes.new
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
33
lib/fog/aws/requests/sns/subscribe.rb
Normal file
33
lib/fog/aws/requests/sns/subscribe.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SNS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/sns/subscribe'
|
||||
|
||||
# Create a subscription
|
||||
#
|
||||
# ==== Parameters
|
||||
# * arn<~String> - Arn of topic to subscribe to
|
||||
# * endpoint<~String> - Endpoint to notify
|
||||
# * protocol<~String> - Protocol to notify endpoint with, in ['email', 'email-json', 'http', 'https', 'sqs']
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/sns/latest/api/API_Subscribe.html
|
||||
#
|
||||
|
||||
def subscribe(arn, endpoint, protocol)
|
||||
request({
|
||||
'Action' => 'Subscribe',
|
||||
'Endpoint' => endpoint,
|
||||
'Protocol' => protocol,
|
||||
'TopicArn' => arn,
|
||||
:parser => Fog::Parsers::AWS::SNS::Subscribe.new
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
29
lib/fog/aws/requests/sns/unsubscribe.rb
Normal file
29
lib/fog/aws/requests/sns/unsubscribe.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SNS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/sns/unsubscribe'
|
||||
|
||||
# Delete a subscription
|
||||
#
|
||||
# ==== Parameters
|
||||
# * arn<~String> - Arn of subscription to delete
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/sns/latest/api/API_Unsubscribe.html
|
||||
#
|
||||
|
||||
def unsubscribe(arn)
|
||||
request({
|
||||
'Action' => 'Unsubscribe',
|
||||
'SubscriptionArn' => arn,
|
||||
:parser => Fog::Parsers::AWS::SNS::Unsubscribe.new
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
33
lib/fog/aws/requests/sqs/change_message_visibility.rb
Normal file
33
lib/fog/aws/requests/sqs/change_message_visibility.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SQS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/sqs/basic'
|
||||
|
||||
# Change visibility timeout for a message
|
||||
#
|
||||
# ==== Parameters
|
||||
# * queue_url<~String> - Url of queue for message to update
|
||||
# * receipt_handle<~String> - Token from previous recieve message
|
||||
# * visibility_timeout<~Integer> - New visibility timeout in 0..43200
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/APIReference/Query_QueryChangeMessageVisibility.html
|
||||
#
|
||||
|
||||
def change_message_visibility(queue_url, receipt_handle, visibility_timeout)
|
||||
request({
|
||||
'Action' => 'ChangeMessageVisibility',
|
||||
'ReceiptHandle' => receipt_handle,
|
||||
'VisibilityTimeout' => visibility_timeout,
|
||||
:parser => Fog::Parsers::AWS::SQS::Basic.new,
|
||||
:path => path_from_queue_url(queue_url)
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
31
lib/fog/aws/requests/sqs/create_queue.rb
Normal file
31
lib/fog/aws/requests/sqs/create_queue.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SQS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/sqs/create_queue'
|
||||
|
||||
# Create a queue
|
||||
#
|
||||
# ==== Parameters
|
||||
# * name<~String> - Name of queue to create
|
||||
# * options<~Hash>:
|
||||
# * DefaultVisibilityTimeout<~String> - Time, in seconds, to hide a message after it has been received, in 0..43200, defaults to 30
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/APIReference/Query_QueryCreateQueue.html
|
||||
#
|
||||
|
||||
def create_queue(name, options = {})
|
||||
request({
|
||||
'Action' => 'CreateQueue',
|
||||
'QueueName' => name,
|
||||
:parser => Fog::Parsers::AWS::SQS::CreateQueue.new
|
||||
}.merge!(options))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
31
lib/fog/aws/requests/sqs/delete_message.rb
Normal file
31
lib/fog/aws/requests/sqs/delete_message.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SQS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/sqs/basic'
|
||||
|
||||
# Delete a message from a queue
|
||||
#
|
||||
# ==== Parameters
|
||||
# * queue_url<~String> - Url of queue to delete message from
|
||||
# * receipt_handle<~String> - Token from previous recieve message
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/APIReference/Query_QueryDeleteMessage.html
|
||||
#
|
||||
|
||||
def delete_message(queue_url, receipt_handle)
|
||||
request({
|
||||
'Action' => 'DeleteMessage',
|
||||
'ReceiptHandle' => receipt_handle,
|
||||
:parser => Fog::Parsers::AWS::SQS::Basic.new,
|
||||
:path => path_from_queue_url(queue_url),
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
29
lib/fog/aws/requests/sqs/delete_queue.rb
Normal file
29
lib/fog/aws/requests/sqs/delete_queue.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SQS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/sqs/basic'
|
||||
|
||||
# Delete a queue
|
||||
#
|
||||
# ==== Parameters
|
||||
# * queue_url<~String> - Url of queue to delete
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/APIReference/Query_QueryDeleteQueue.html
|
||||
#
|
||||
|
||||
def delete_queue(queue_url)
|
||||
request({
|
||||
'Action' => 'DeleteQueue',
|
||||
:parser => Fog::Parsers::AWS::SQS::Basic.new,
|
||||
:path => path_from_queue_url(queue_url),
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
31
lib/fog/aws/requests/sqs/get_queue_attributes.rb
Normal file
31
lib/fog/aws/requests/sqs/get_queue_attributes.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SQS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/sqs/get_queue_attributes'
|
||||
|
||||
# Get attributes of a queue
|
||||
#
|
||||
# ==== Parameters
|
||||
# * queue_url<~String> - Url of queue to get attributes for
|
||||
# * attribute_name<~Array> - Name of attribute to return, in ['All', 'ApproximateNumberOfMessages', 'ApproximateNumberOfMessagesNotVisible', 'CreatedTimestamp', 'LastModifiedTimestamp', 'MaximumMessageSize', 'MessageRetentionPeriod', 'Policy', 'QueueArn', 'VisibilityTimeout']
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/APIReference/Query_QueryGetQueueAttributes.html
|
||||
#
|
||||
|
||||
def get_queue_attributes(queue_url, attribute_name)
|
||||
request({
|
||||
'Action' => 'GetQueueAttributes',
|
||||
'AttributeName' => attribute_name,
|
||||
:path => path_from_queue_url(queue_url),
|
||||
:parser => Fog::Parsers::AWS::SQS::GetQueueAttributes.new
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
28
lib/fog/aws/requests/sqs/list_queues.rb
Normal file
28
lib/fog/aws/requests/sqs/list_queues.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SQS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/sqs/list_queues'
|
||||
|
||||
# List queues
|
||||
#
|
||||
# ==== Parameters
|
||||
# * options<~Hash>:
|
||||
# * QueueNamePrefix<~String> - String used to filter results to only those with matching prefixes
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/APIReference/Query_QueryListQueues.html
|
||||
#
|
||||
|
||||
def list_queues(options = {})
|
||||
request({
|
||||
'Action' => 'ListQueues',
|
||||
:parser => Fog::Parsers::AWS::SQS::ListQueues.new
|
||||
}.merge!(options))
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
34
lib/fog/aws/requests/sqs/receive_message.rb
Normal file
34
lib/fog/aws/requests/sqs/receive_message.rb
Normal file
|
@ -0,0 +1,34 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SQS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/sqs/receive_message'
|
||||
|
||||
# Get a message from a queue (marks it as unavailable temporarily, but does not remove from queue, see delete_message)
|
||||
#
|
||||
# ==== Parameters
|
||||
# * queue_url<~String> - Url of queue to get message from
|
||||
# * options<~Hash>:
|
||||
# * Attributes<~Array> - List of attributes to return, in ['All', 'ApproximateFirstReceiveTimestamp', 'ApproximateReceiveCount', 'SenderId', 'SentTimestamp'], defaults to 'All'
|
||||
# * MaxNumberOfMessages<~Integer> - Maximum number of messages to return, defaults to 1
|
||||
# * VisibilityTimeout<~Integer> - Duration, in seconds, to hide message from other receives. In 0..43200, defaults to visibility timeout for queue
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/APIReference/Query_QueryReceiveMessage.html
|
||||
#
|
||||
|
||||
def receive_message(queue_url, options = {})
|
||||
request({
|
||||
'Action' => 'ReceiveMessage',
|
||||
'AttributeName' => 'All',
|
||||
:path => path_from_queue_url(queue_url),
|
||||
:parser => Fog::Parsers::AWS::SQS::ReceiveMessage.new
|
||||
}.merge!(options))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
31
lib/fog/aws/requests/sqs/send_message.rb
Normal file
31
lib/fog/aws/requests/sqs/send_message.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SQS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/sqs/send_message'
|
||||
|
||||
# Add a message to a queue
|
||||
#
|
||||
# ==== Parameters
|
||||
# * queue_url<~String> - Url of queue to add message to
|
||||
# * message<~String> - Message to add to queue
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/APIReference/Query_QuerySendMessage.html
|
||||
#
|
||||
|
||||
def send_message(queue_url, message)
|
||||
request({
|
||||
'Action' => 'SendMessage',
|
||||
'MessageBody' => message,
|
||||
:path => path_from_queue_url(queue_url),
|
||||
:parser => Fog::Parsers::AWS::SQS::SendMessage.new
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
33
lib/fog/aws/requests/sqs/set_queue_attributes.rb
Normal file
33
lib/fog/aws/requests/sqs/set_queue_attributes.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SQS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/sqs/basic'
|
||||
|
||||
# Get attributes of a queue
|
||||
#
|
||||
# ==== Parameters
|
||||
# * queue_url<~String> - Url of queue to get attributes for
|
||||
# * attribute_name<~String> - Name of attribute to set, keys in ['MaximumMessageSize', 'MessageRetentionPeriod', 'Policy', 'VisibilityTimeout']
|
||||
# * attribute_value<~String> - Value to set for attribute
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/APIReference/Query_QuerySetQueueAttributes.html
|
||||
#
|
||||
|
||||
def set_queue_attributes(queue_url, attribute_name, attribute_value)
|
||||
request({
|
||||
'Action' => 'SetQueueAttributes',
|
||||
'Attribute.Name' => attribute_name,
|
||||
'Attribute.Value' => attribute_value,
|
||||
:path => path_from_queue_url(queue_url),
|
||||
:parser => Fog::Parsers::AWS::SQS::Basic.new
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
112
lib/fog/aws/sns.rb
Normal file
112
lib/fog/aws/sns.rb
Normal file
|
@ -0,0 +1,112 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SNS < Fog::Service
|
||||
|
||||
requires :aws_access_key_id, :aws_secret_access_key
|
||||
recognizes :host, :path, :port, :scheme, :persistent
|
||||
|
||||
request_path 'fog/aws/requests/sns'
|
||||
request :add_permission
|
||||
request :confirm_subscription
|
||||
request :create_topic
|
||||
request :delete_topic
|
||||
request :get_topic_attributes
|
||||
request :list_subscriptions
|
||||
request :list_subscriptions_by_topic
|
||||
request :list_topics
|
||||
request :publish
|
||||
request :remove_permission
|
||||
request :set_topic_attributes
|
||||
request :subscribe
|
||||
request :unsubscribe
|
||||
|
||||
class Mock
|
||||
|
||||
def initialize(options={})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Real
|
||||
|
||||
# Initialize connection to SNS
|
||||
#
|
||||
# ==== Notes
|
||||
# options parameter must include values for :aws_access_key_id and
|
||||
# :aws_secret_access_key in order to create a connection
|
||||
#
|
||||
# ==== Examples
|
||||
# sns = SNS.new(
|
||||
# :aws_access_key_id => your_aws_access_key_id,
|
||||
# :aws_secret_access_key => your_aws_secret_access_key
|
||||
# )
|
||||
#
|
||||
# ==== Parameters
|
||||
# * options<~Hash> - config arguments for connection. Defaults to {}.
|
||||
#
|
||||
# ==== Returns
|
||||
# * SNS object with connection to AWS.
|
||||
def initialize(options={})
|
||||
require 'multi_json'
|
||||
@aws_access_key_id = options[:aws_access_key_id]
|
||||
@aws_secret_access_key = options[:aws_secret_access_key]
|
||||
@hmac = Fog::HMAC.new('sha256', @aws_secret_access_key)
|
||||
|
||||
options[:region] ||= 'us-east-1'
|
||||
@host = options[:host] || case options[:region]
|
||||
when 'ap-southeast-1'
|
||||
'sns.ap-southeast-1.amazonaws.com'
|
||||
when 'eu-west-1'
|
||||
'sns.eu-west-1.amazonaws.com'
|
||||
when 'us-east-1'
|
||||
'sns.us-east-1.amazonaws.com'
|
||||
when 'us-west-1'
|
||||
'sns.us-west-1.amazonaws.com'
|
||||
else
|
||||
raise ArgumentError, "Unknown region: #{options[:region].inspect}"
|
||||
end
|
||||
|
||||
@path = options[:path] || '/'
|
||||
@port = options[:port] || 443
|
||||
@scheme = options[:scheme] || 'https'
|
||||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", options[:persistent])
|
||||
end
|
||||
|
||||
def reload
|
||||
@connection.reset
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def request(params)
|
||||
idempotent = params.delete(:idempotent)
|
||||
parser = params.delete(:parser)
|
||||
|
||||
body = AWS.signed_params(
|
||||
params,
|
||||
{
|
||||
:aws_access_key_id => @aws_access_key_id,
|
||||
:hmac => @hmac,
|
||||
:host => @host,
|
||||
:path => @path,
|
||||
:port => @port
|
||||
}
|
||||
)
|
||||
|
||||
response = @connection.request({
|
||||
:body => body,
|
||||
:expects => 200,
|
||||
:idempotent => idempotent,
|
||||
:headers => { 'Content-Type' => 'application/x-www-form-urlencoded' },
|
||||
:host => @host,
|
||||
:method => 'POST',
|
||||
:parser => parser
|
||||
})
|
||||
|
||||
response
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
115
lib/fog/aws/sqs.rb
Normal file
115
lib/fog/aws/sqs.rb
Normal file
|
@ -0,0 +1,115 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SQS < Fog::Service
|
||||
|
||||
requires :aws_access_key_id, :aws_secret_access_key
|
||||
recognizes :region, :host, :path, :port, :scheme, :persistent
|
||||
|
||||
request_path 'fog/aws/requests/sqs'
|
||||
request :change_message_visibility
|
||||
request :create_queue
|
||||
request :delete_message
|
||||
request :delete_queue
|
||||
request :get_queue_attributes
|
||||
request :list_queues
|
||||
request :receive_message
|
||||
request :send_message
|
||||
request :set_queue_attributes
|
||||
|
||||
class Mock
|
||||
|
||||
def initialize(options={})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Real
|
||||
|
||||
# Initialize connection to SQS
|
||||
#
|
||||
# ==== Notes
|
||||
# options parameter must include values for :aws_access_key_id and
|
||||
# :aws_secret_access_key in order to create a connection
|
||||
#
|
||||
# ==== Examples
|
||||
# sqs = SQS.new(
|
||||
# :aws_access_key_id => your_aws_access_key_id,
|
||||
# :aws_secret_access_key => your_aws_secret_access_key
|
||||
# )
|
||||
#
|
||||
# ==== Parameters
|
||||
# * options<~Hash> - config arguments for connection. Defaults to {}.
|
||||
# * region<~String> - optional region to use, in ['eu-west-1', 'us-east-1', 'us-west-1', 'ap-southeast-1']
|
||||
#
|
||||
# ==== Returns
|
||||
# * SQS object with connection to AWS.
|
||||
def initialize(options={})
|
||||
@aws_access_key_id = options[:aws_access_key_id]
|
||||
@aws_secret_access_key = options[:aws_secret_access_key]
|
||||
@hmac = Fog::HMAC.new('sha256', @aws_secret_access_key)
|
||||
options[:region] ||= 'us-east-1'
|
||||
@host = options[:host] || case options[:region]
|
||||
when 'ap-southeast-1'
|
||||
'ap-southeast-1.queue.amazonaws.com'
|
||||
when 'eu-west-1'
|
||||
'eu-west-1.queue.amazonaws.com'
|
||||
when 'us-east-1'
|
||||
'queue.amazonaws.com'
|
||||
when 'us-west-1'
|
||||
'us-west-1.queue.amazonaws.com'
|
||||
else
|
||||
raise ArgumentError, "Unknown region: #{options[:region].inspect}"
|
||||
end
|
||||
@path = options[:path] || '/'
|
||||
@port = options[:port] || 443
|
||||
@scheme = options[:scheme] || 'https'
|
||||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", options[:persistent])
|
||||
end
|
||||
|
||||
def reload
|
||||
@connection.reset
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def path_from_queue_url(queue_url)
|
||||
queue_url.split('.com', 2).last
|
||||
end
|
||||
|
||||
def request(params)
|
||||
idempotent = params.delete(:idempotent)
|
||||
parser = params.delete(:parser)
|
||||
path = params.delete(:path)
|
||||
|
||||
body = AWS.signed_params(
|
||||
params,
|
||||
{
|
||||
:aws_access_key_id => @aws_access_key_id,
|
||||
:hmac => @hmac,
|
||||
:host => @host,
|
||||
:path => path || @path,
|
||||
:port => @port,
|
||||
:version => '2009-02-01'
|
||||
}
|
||||
)
|
||||
|
||||
args = {
|
||||
:body => body,
|
||||
:expects => 200,
|
||||
:idempotent => idempotent,
|
||||
:headers => { 'Content-Type' => 'application/x-www-form-urlencoded' },
|
||||
:host => @host,
|
||||
:method => 'POST',
|
||||
:parser => parser
|
||||
}
|
||||
args.merge!(:path => path) if path
|
||||
|
||||
response = @connection.request(args)
|
||||
|
||||
response
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -23,10 +23,14 @@ class AWS < Fog::Bin
|
|||
Fog::AWS::SimpleDB
|
||||
when :ses
|
||||
Fog::AWS::SES
|
||||
when :sqs
|
||||
Fog::AWS::SQS
|
||||
when :eu_storage, :storage
|
||||
Fog::Storage::AWS
|
||||
when :rds
|
||||
Fog::AWS::RDS
|
||||
when :sns
|
||||
Fog::AWS::SNS
|
||||
else
|
||||
# @todo Replace most instances of ArgumentError with NotImplementedError
|
||||
# @todo For a list of widely supported Exceptions, see:
|
||||
|
@ -65,9 +69,13 @@ class AWS < Fog::Bin
|
|||
Fog::AWS::SimpleDB.new
|
||||
when :ses
|
||||
Fog::AWS::SES.new
|
||||
when :sqs
|
||||
Fog::AWS::SQS.new
|
||||
when :storage
|
||||
Formatador.display_line("[yellow][WARN] AWS[:storage] is deprecated, use Storage[:aws] instead[/]")
|
||||
Fog::Storage.new(:provider => 'AWS')
|
||||
when :sns
|
||||
Fog::AWS::SNS.new
|
||||
else
|
||||
raise ArgumentError, "Unrecognized service: #{key.inspect}"
|
||||
end
|
||||
|
|
|
@ -85,7 +85,7 @@ module Fog
|
|||
end
|
||||
end
|
||||
if !response.body.empty? && parse_json && response.headers['Content-Type'] =~ %r{application/json}
|
||||
response.body = ::MultiJson.decode(response.body)
|
||||
response.body = MultiJson.decode(response.body)
|
||||
end
|
||||
response
|
||||
end
|
||||
|
|
|
@ -24,6 +24,8 @@ module Fog
|
|||
collection :tags
|
||||
model :volume
|
||||
collection :volumes
|
||||
model :spot_request
|
||||
collection :spot_requests
|
||||
|
||||
request_path 'fog/compute/requests/aws'
|
||||
request :allocate_address
|
||||
|
|
|
@ -83,7 +83,7 @@ module Fog
|
|||
end
|
||||
end
|
||||
unless response.body.empty?
|
||||
response.body = ::MultiJson.decode(response.body)
|
||||
response.body = MultiJson.decode(response.body)
|
||||
end
|
||||
response
|
||||
end
|
||||
|
|
|
@ -106,7 +106,7 @@ module Fog
|
|||
response = authenticated_request(params)
|
||||
end
|
||||
unless response.body.empty?
|
||||
response = ::MultiJson.decode(response.body)
|
||||
response = MultiJson.decode(response.body)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -119,7 +119,7 @@ module Fog
|
|||
auth_url = options[:brightbox_auth_url] || @auth_url
|
||||
|
||||
connection = Fog::Connection.new(auth_url)
|
||||
@authentication_body = {'client_id' => @brightbox_client_id, 'grant_type' => 'none'}.to_json
|
||||
@authentication_body = MultiJson.encode({'client_id' => @brightbox_client_id, 'grant_type' => 'none'})
|
||||
|
||||
response = connection.request({
|
||||
:path => "/token",
|
||||
|
@ -131,7 +131,7 @@ module Fog
|
|||
:method => 'POST',
|
||||
:body => @authentication_body
|
||||
})
|
||||
@oauth_token = ::MultiJson.decode(response.body)["access_token"]
|
||||
@oauth_token = MultiJson.decode(response.body)["access_token"]
|
||||
return @oauth_token
|
||||
end
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ module Fog
|
|||
end
|
||||
|
||||
unless response.body.empty?
|
||||
response.body = ::MultiJson.decode(response.body)
|
||||
response.body = MultiJson.decode(response.body)
|
||||
end
|
||||
|
||||
response
|
||||
|
|
|
@ -96,7 +96,7 @@ module Fog
|
|||
response = @connection.request(params.merge!({:host => @host}))
|
||||
|
||||
unless response.body.empty?
|
||||
response.body = ::MultiJson.decode(response.body)
|
||||
response.body = MultiJson.decode(response.body)
|
||||
if data = response.body['ERRORARRAY'].first
|
||||
error = case data['ERRORCODE']
|
||||
when 5
|
||||
|
|
|
@ -177,7 +177,7 @@ module Fog
|
|||
commands = [
|
||||
%{mkdir .ssh},
|
||||
%{passwd -l #{username}},
|
||||
%{echo "#{attributes.to_json}" >> ~/attributes.json}
|
||||
%{echo "#{MultiJson.encode(attributes)}" >> ~/attributes.json}
|
||||
]
|
||||
if public_key
|
||||
commands << %{echo "#{public_key}" >> ~/.ssh/authorized_keys}
|
||||
|
|
93
lib/fog/compute/models/aws/spot_request.rb
Normal file
93
lib/fog/compute/models/aws/spot_request.rb
Normal file
|
@ -0,0 +1,93 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class AWS
|
||||
|
||||
class SpotRequest < Fog::Model
|
||||
|
||||
identity :id, :aliases => 'spotInstanceRequestId'
|
||||
|
||||
attribute :price, :aliases => 'spotPrice'
|
||||
attribute :request_type, :aliases => 'type'
|
||||
attribute :created_at, :aliases => 'createTime'
|
||||
attribute :instance_count, :aliases => 'instanceCount'
|
||||
attribute :instance_id, :aliases => 'instanceId'
|
||||
attribute :state
|
||||
|
||||
attribute :valid_from, :aliases => 'validFrom'
|
||||
attribute :valid_until, :aliases => 'validUntil'
|
||||
attribute :launch_group, :aliases => 'launchGroup'
|
||||
attribute :availability_zone_group, :aliases => 'availabilityZoneGroup'
|
||||
attribute :product_description, :aliases => 'productDescription'
|
||||
|
||||
attribute :groups, :aliases => 'LaunchSpecification.SecurityGroup'
|
||||
attribute :key_name, :aliases => 'LaunchSpecification.KeyName'
|
||||
attribute :availability_zone, :aliases => 'LaunchSpecification.Placement.AvailabilityZone'
|
||||
attribute :flavor_id, :aliases => 'LaunchSpecification.InstanceType'
|
||||
attribute :image_id, :aliases => 'LaunchSpecification.ImageId'
|
||||
attribute :monitoring, :aliases => 'LaunchSpecification.Monitoring'
|
||||
attribute :block_device_mapping, :aliases => 'LaunchSpecification.BlockDeviceMapping'
|
||||
attribute :tags, :aliases => 'tagSet'
|
||||
attribute :fault, :squash => 'message'
|
||||
attribute :user_data
|
||||
|
||||
attr_writer :username
|
||||
|
||||
def initialize(attributes={})
|
||||
self.groups ||= ["default"]
|
||||
self.flavor_id ||= 't1.micro'
|
||||
self.image_id ||= begin
|
||||
self.username = 'ubuntu'
|
||||
case attributes[:connection].instance_variable_get(:@region) # Ubuntu 10.04 LTS 64bit (EBS)
|
||||
when 'ap-northeast-1'
|
||||
'ami-5e0fa45f'
|
||||
when 'ap-southeast-1'
|
||||
'ami-f092eca2'
|
||||
when 'eu-west-1'
|
||||
'ami-3d1f2b49'
|
||||
when 'us-east-1'
|
||||
'ami-3202f25b'
|
||||
when 'us-west-1'
|
||||
'ami-f5bfefb0'
|
||||
end
|
||||
end
|
||||
super
|
||||
end
|
||||
|
||||
def save
|
||||
requires :image_id, :flavor_id, :price
|
||||
|
||||
options = {
|
||||
'AvailabilityZoneGroup' => availability_zone_group,
|
||||
'InstanceCount' => instance_count,
|
||||
'LaunchGroup' => launch_group,
|
||||
'LaunchSpecification.BlockDeviceMapping' => block_device_mapping,
|
||||
'LaunchSpecification.KeyName' => key_name,
|
||||
'LaunchSpecification.Monitoring.Enabled' => monitoring,
|
||||
'LaunchSpecification.Placement.AvailabilityZone' => availability_zone,
|
||||
'LaunchSpecification.SecurityGroup' => groups,
|
||||
'LaunchSpecification.UserData' => user_data,
|
||||
'Type' => request_type,
|
||||
'ValidFrom' => valid_from,
|
||||
'ValidUntil' => valid_until }
|
||||
options.delete_if {|key, value| value.nil?}
|
||||
|
||||
data = connection.request_spot_instances(image_id, flavor_id, price, options).body
|
||||
spot_instance_request = data['spotInstanceRequestSet'].first
|
||||
spot_instance_request['launchSpecification'].each do |name,value|
|
||||
spot_instance_request['LaunchSpecification.' + name[0,1].upcase + name[1..-1]] = value
|
||||
end
|
||||
spot_instance_request.merge(:groups => spot_instance_request['LaunchSpecification.GroupSet'])
|
||||
spot_instance_request.merge(options)
|
||||
merge_attributes( spot_instance_request )
|
||||
end
|
||||
|
||||
def ready?
|
||||
state == 'active'
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
48
lib/fog/compute/models/aws/spot_requests.rb
Normal file
48
lib/fog/compute/models/aws/spot_requests.rb
Normal file
|
@ -0,0 +1,48 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/compute/models/aws/spot_request'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class AWS
|
||||
class SpotRequests < Fog::Collection
|
||||
|
||||
attribute :filters
|
||||
|
||||
model Fog::Compute::AWS::SpotRequest
|
||||
|
||||
def initialize(attributes)
|
||||
self.filters ||= {}
|
||||
super
|
||||
end
|
||||
|
||||
def all(filters = self.filters)
|
||||
unless filters.is_a?(Hash)
|
||||
Formatador.display_line("[yellow][WARN] all with #{filters.class} param is deprecated, use all('spot-instance-request-id' => []) instead[/] [light_black](#{caller.first})[/]")
|
||||
filters = {'spot-instance-request-id' => [*filters]}
|
||||
end
|
||||
self.filters = filters
|
||||
data = connection.describe_spot_instance_requests(filters).body
|
||||
load(
|
||||
data['spotInstanceRequestSet'].map do |spot_instance_request|
|
||||
spot_instance_request['LaunchSpecification.Placement.AvailabilityZone'] = spot_instance_request['launchedAvailabilityZone']
|
||||
spot_instance_request['launchSpecification'].each do |name,value|
|
||||
spot_instance_request['LaunchSpecification.' + name[0,1].upcase + name[1..-1]] = value
|
||||
end
|
||||
spot_instance_request.merge(:groups => spot_instance_request['LaunchSpecification.GroupSet'])
|
||||
spot_instance_request
|
||||
end.flatten
|
||||
)
|
||||
end
|
||||
|
||||
def get(spot_request_id)
|
||||
if spot_request_id
|
||||
self.class.new(:connection => connection).all('spot-instance-request-id' => spot_request_id).first
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -113,7 +113,7 @@ module Fog
|
|||
%{mkdir .ssh},
|
||||
%{echo "#{public_key}" >> ~/.ssh/authorized_keys},
|
||||
%{passwd -l #{username}},
|
||||
%{echo "#{attributes.to_json}" >> ~/attributes.json}
|
||||
%{echo "#{MultiJson.encode(attributes)}" >> ~/attributes.json}
|
||||
])
|
||||
rescue Errno::ECONNREFUSED
|
||||
sleep(1)
|
||||
|
|
|
@ -92,8 +92,8 @@ module Fog
|
|||
%{mkdir .ssh},
|
||||
%{echo "#{public_key}" >> ~/.ssh/authorized_keys},
|
||||
%{passwd -l root},
|
||||
%{echo "#{attributes.to_json}" >> ~/attributes.json},
|
||||
%{echo "#{metadata.to_json}" >> ~/metadata.json}
|
||||
%{echo "#{MultiJson.encode(attributes)}" >> ~/attributes.json},
|
||||
%{echo "#{MultiJson.encode(metadata)}" >> ~/metadata.json}
|
||||
])
|
||||
rescue Errno::ECONNREFUSED
|
||||
sleep(1)
|
||||
|
|
|
@ -104,8 +104,8 @@ module Fog
|
|||
%{mkdir .ssh},
|
||||
%{echo "#{public_key}" >> ~/.ssh/authorized_keys},
|
||||
%{passwd -l #{username}},
|
||||
%{echo "#{attributes.to_json}" >> ~/attributes.json},
|
||||
%{echo "#{metadata.to_json}" >> ~/metadata.json}
|
||||
%{echo "#{MultiJson.encode(attributes)}" >> ~/attributes.json},
|
||||
%{echo "#{MultiJson.encode(metadata)}" >> ~/metadata.json}
|
||||
])
|
||||
rescue Errno::ECONNREFUSED
|
||||
sleep(1)
|
||||
|
|
|
@ -95,7 +95,7 @@ module Fog
|
|||
%{mkdir .ssh},
|
||||
%{echo "#{public_key}" >> ~/.ssh/authorized_keys},
|
||||
%{passwd -l #{username}},
|
||||
%{echo "#{attributes.to_json}" >> ~/attributes.json}
|
||||
%{echo "#{MultiJson.encode(attributes)}" >> ~/attributes.json}
|
||||
])
|
||||
rescue Errno::ECONNREFUSED
|
||||
sleep(1)
|
||||
|
|
|
@ -167,8 +167,8 @@ module Fog
|
|||
# %{mkdir .ssh},
|
||||
# %{echo "#{public_key}" >> ~/.ssh/authorized_keys},
|
||||
# %{passwd -l #{username}},
|
||||
# %{echo "#{attributes.to_json}" >> ~/attributes.json},
|
||||
# %{echo "#{metadata.to_json}" >> ~/metadata.json}
|
||||
# %{echo "#{MultiJson.encode(attributes)}" >> ~/attributes.json},
|
||||
# %{echo "#{MultiJson.encode(metadata)}" >> ~/metadata.json}
|
||||
# ])
|
||||
# rescue Errno::ECONNREFUSED
|
||||
# sleep(1)
|
||||
|
|
|
@ -104,7 +104,7 @@ module Fog
|
|||
# Because the response is some weird xml-json thing, we need to try and mung
|
||||
# the values out with a prefix, and if there is an empty data entry return an
|
||||
# empty version of the expected type (if provided)
|
||||
response = ::MultiJson.decode(response.body)
|
||||
response = MultiJson.decode(response.body)
|
||||
if options.has_key? :response_prefix
|
||||
keys = options[:response_prefix].split('/')
|
||||
keys.each do |k|
|
||||
|
|
|
@ -120,7 +120,7 @@ module Fog
|
|||
end
|
||||
end
|
||||
unless response.body.empty?
|
||||
response.body = ::MultiJson.decode(response.body)
|
||||
response.body = MultiJson.decode(response.body)
|
||||
end
|
||||
response
|
||||
end
|
||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
|||
:method => 'POST',
|
||||
:path => "/1.0/servers/#{identifier}/activate_console",
|
||||
:headers => {"Content-Type" => "application/json"},
|
||||
:body => options.to_json
|
||||
:body => MultiJson.encode(options)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
|||
:method => 'POST',
|
||||
:path => "/1.0/load_balancers/#{identifier}/add_listeners",
|
||||
:headers => {"Content-Type" => "application/json"},
|
||||
:body => options.to_json
|
||||
:body => MultiJson.encode(options)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
|||
:method => 'POST',
|
||||
:path => "/1.0/load_balancers/#{identifier}/add_nodes",
|
||||
:headers => {"Content-Type" => "application/json"},
|
||||
:body => options.to_json
|
||||
:body => MultiJson.encode(options)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ module Fog
|
|||
:method => 'POST',
|
||||
:path => "/1.0/api_clients",
|
||||
:headers => {"Content-Type" => "application/json"},
|
||||
:body => options.to_json
|
||||
:body => MultiJson.encode(options)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ module Fog
|
|||
:method => 'POST',
|
||||
:path => "/1.0/cloud_ips",
|
||||
:headers => {"Content-Type" => "application/json"},
|
||||
:body => options.to_json
|
||||
:body => MultiJson.encode(options)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ module Fog
|
|||
:method => 'POST',
|
||||
:path => "/1.0/images",
|
||||
:headers => {"Content-Type" => "application/json"},
|
||||
:body => options.to_json
|
||||
:body => MultiJson.encode(options)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ module Fog
|
|||
:method => 'POST',
|
||||
:path => "/1.0/load_balancers",
|
||||
:headers => {"Content-Type" => "application/json"},
|
||||
:body => options.to_json
|
||||
:body => MultiJson.encode(options)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ module Fog
|
|||
:method => 'POST',
|
||||
:path => "/1.0/servers",
|
||||
:headers => {"Content-Type" => "application/json"},
|
||||
:body => options.to_json
|
||||
:body => MultiJson.encode(options)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
|||
:method => 'DELETE',
|
||||
:path => "/1.0/api_clients/#{identifier}",
|
||||
:headers => {"Content-Type" => "application/json"},
|
||||
:body => options.to_json
|
||||
:body => MultiJson.encode(options)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
|||
:method => 'DELETE',
|
||||
:path => "/1.0/cloud_ips/#{identifier}",
|
||||
:headers => {"Content-Type" => "application/json"},
|
||||
:body => options.to_json
|
||||
:body => MultiJson.encode(options)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
|||
:method => 'DELETE',
|
||||
:path => "/1.0/images/#{identifier}",
|
||||
:headers => {"Content-Type" => "application/json"},
|
||||
:body => options.to_json
|
||||
:body => MultiJson.encode(options)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
|||
:method => 'DELETE',
|
||||
:path => "/1.0/load_balancers/#{identifier}",
|
||||
:headers => {"Content-Type" => "application/json"},
|
||||
:body => options.to_json
|
||||
:body => MultiJson.encode(options)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
|||
:method => 'DELETE',
|
||||
:path => "/1.0/servers/#{identifier}",
|
||||
:headers => {"Content-Type" => "application/json"},
|
||||
:body => options.to_json
|
||||
:body => MultiJson.encode(options)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ module Fog
|
|||
:method => 'GET',
|
||||
:path => "/1.0/account",
|
||||
:headers => {"Content-Type" => "application/json"},
|
||||
:body => options.to_json
|
||||
:body => MultiJson.encode(options)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
|||
:method => 'GET',
|
||||
:path => "/1.0/api_clients/#{identifier}",
|
||||
:headers => {"Content-Type" => "application/json"},
|
||||
:body => options.to_json
|
||||
:body => MultiJson.encode(options)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
|||
:method => 'GET',
|
||||
:path => "/1.0/cloud_ips/#{identifier}",
|
||||
:headers => {"Content-Type" => "application/json"},
|
||||
:body => options.to_json
|
||||
:body => MultiJson.encode(options)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
|||
:method => 'GET',
|
||||
:path => "/1.0/images/#{identifier}",
|
||||
:headers => {"Content-Type" => "application/json"},
|
||||
:body => options.to_json
|
||||
:body => MultiJson.encode(options)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
|||
:method => 'GET',
|
||||
:path => "/1.0/interfaces/#{identifier}",
|
||||
:headers => {"Content-Type" => "application/json"},
|
||||
:body => options.to_json
|
||||
:body => MultiJson.encode(options)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
|||
:method => 'GET',
|
||||
:path => "/1.0/load_balancers/#{identifier}",
|
||||
:headers => {"Content-Type" => "application/json"},
|
||||
:body => options.to_json
|
||||
:body => MultiJson.encode(options)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
|||
:method => 'GET',
|
||||
:path => "/1.0/servers/#{identifier}",
|
||||
:headers => {"Content-Type" => "application/json"},
|
||||
:body => options.to_json
|
||||
:body => MultiJson.encode(options)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
|||
:method => 'GET',
|
||||
:path => "/1.0/server_types/#{identifier}",
|
||||
:headers => {"Content-Type" => "application/json"},
|
||||
:body => options.to_json
|
||||
:body => MultiJson.encode(options)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
|||
:method => 'GET',
|
||||
:path => "/1.0/users/#{identifier}",
|
||||
:headers => {"Content-Type" => "application/json"},
|
||||
:body => options.to_json
|
||||
:body => MultiJson.encode(options)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
|||
:method => 'GET',
|
||||
:path => "/1.0/zones/#{identifier}",
|
||||
:headers => {"Content-Type" => "application/json"},
|
||||
:body => options.to_json
|
||||
:body => MultiJson.encode(options)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ module Fog
|
|||
:method => 'GET',
|
||||
:path => "/1.0/api_clients",
|
||||
:headers => {"Content-Type" => "application/json"},
|
||||
:body => options.to_json
|
||||
:body => MultiJson.encode(options)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ module Fog
|
|||
:method => 'GET',
|
||||
:path => "/1.0/cloud_ips",
|
||||
:headers => {"Content-Type" => "application/json"},
|
||||
:body => options.to_json
|
||||
:body => MultiJson.encode(options)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ module Fog
|
|||
:method => 'GET',
|
||||
:path => "/1.0/images",
|
||||
:headers => {"Content-Type" => "application/json"},
|
||||
:body => options.to_json
|
||||
:body => MultiJson.encode(options)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ module Fog
|
|||
:method => 'GET',
|
||||
:path => "/1.0/load_balancers",
|
||||
:headers => {"Content-Type" => "application/json"},
|
||||
:body => options.to_json
|
||||
:body => MultiJson.encode(options)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ module Fog
|
|||
:method => 'GET',
|
||||
:path => "/1.0/server_types",
|
||||
:headers => {"Content-Type" => "application/json"},
|
||||
:body => options.to_json
|
||||
:body => MultiJson.encode(options)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue