[aws|acs] Adds ACS#delete_cache_security_group
This commit is contained in:
parent
ae3573bb9b
commit
66ffefea26
|
@ -11,6 +11,7 @@ module Fog
|
||||||
service(:cloud_formation, 'aws/cloud_formation', 'CloudFormation')
|
service(:cloud_formation, 'aws/cloud_formation', 'CloudFormation')
|
||||||
service(:cloud_watch, 'aws/cloud_watch', 'CloudWatch')
|
service(:cloud_watch, 'aws/cloud_watch', 'CloudWatch')
|
||||||
service(:dns, 'aws/dns', 'DNS')
|
service(:dns, 'aws/dns', 'DNS')
|
||||||
|
service(:elasticache, 'aws/elasticache', 'Elasticache')
|
||||||
service(:elb, 'aws/elb', 'ELB')
|
service(:elb, 'aws/elb', 'ELB')
|
||||||
service(:iam, 'aws/iam', 'IAM')
|
service(:iam, 'aws/iam', 'IAM')
|
||||||
service(:rds, 'aws/rds', 'RDS')
|
service(:rds, 'aws/rds', 'RDS')
|
||||||
|
|
|
@ -0,0 +1,109 @@
|
||||||
|
module Fog
|
||||||
|
module AWS
|
||||||
|
class ACS < Fog::Service
|
||||||
|
|
||||||
|
requires :aws_access_key_id, :aws_secret_access_key
|
||||||
|
recognizes :region, :host, :path, :port, :scheme, :persistent
|
||||||
|
|
||||||
|
request_path 'fog/aws/requests/acs'
|
||||||
|
|
||||||
|
#request :authorize_cache_security_group_ingress
|
||||||
|
#request :revoke_cache_security_group_ingress
|
||||||
|
|
||||||
|
#request :create_cache_cluster
|
||||||
|
#request :delete_cache_cluster
|
||||||
|
#request :describe_cache_clusters
|
||||||
|
#request :modify_cache_cluster
|
||||||
|
#request :reboot_cache_cluster
|
||||||
|
|
||||||
|
#request :create_cache_parameter_group
|
||||||
|
#request :delete_cache_parameter_group
|
||||||
|
#request :describe_cache_parameter_groups
|
||||||
|
#request :modify_cache_parameter_group
|
||||||
|
#request :reset_cache_parameter_group
|
||||||
|
|
||||||
|
request :create_cache_security_group
|
||||||
|
#request :delete_cache_security_group
|
||||||
|
#request :describe_cache_security_groups
|
||||||
|
|
||||||
|
#request :describe_engine_default_parameters
|
||||||
|
|
||||||
|
#request :describe_events
|
||||||
|
|
||||||
|
# model_path 'fog/aws/models/acs'
|
||||||
|
# model :server
|
||||||
|
# collection :servers
|
||||||
|
# model :security_group
|
||||||
|
# collection :security_groups
|
||||||
|
# model :parameter_group
|
||||||
|
# collection :parameter_groups
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def initalize(options={})
|
||||||
|
Fog::Mock.not_implemented
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class Real
|
||||||
|
|
||||||
|
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 'us-east-1'
|
||||||
|
'acsvc.us-east-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 = Fog::AWS.signed_params(
|
||||||
|
params,
|
||||||
|
{
|
||||||
|
:aws_access_key_id => @aws_access_key_id,
|
||||||
|
:hmac => @hmac,
|
||||||
|
:host => @host,
|
||||||
|
:path => @path,
|
||||||
|
:port => @port,
|
||||||
|
:version => '2011-07-15'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
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
|
||||||
|
# TODO: handle not found errors
|
||||||
|
raise
|
||||||
|
end
|
||||||
|
|
||||||
|
response
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,38 @@
|
||||||
|
module Fog
|
||||||
|
module Parsers
|
||||||
|
module AWS
|
||||||
|
module ACS
|
||||||
|
|
||||||
|
require 'fog/aws/parsers/acs/security_group_parser'
|
||||||
|
|
||||||
|
class CreateCacheSecurityGroup < Fog::Parsers::AWS::ACS::SecurityGroupParser
|
||||||
|
|
||||||
|
def reset
|
||||||
|
super
|
||||||
|
@response = { 'ResponseMetadata' => {} }
|
||||||
|
end
|
||||||
|
|
||||||
|
def start_element(name, attrs = [])
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
|
def end_element(name)
|
||||||
|
case name
|
||||||
|
when 'CacheSecurityGroup' then
|
||||||
|
@response['CacheSecurityGroup'] = @security_group
|
||||||
|
reset_security_group
|
||||||
|
|
||||||
|
when 'RequestId'
|
||||||
|
@response['ResponseMetadata'][name] = value
|
||||||
|
else
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,39 @@
|
||||||
|
module Fog
|
||||||
|
module Parsers
|
||||||
|
module AWS
|
||||||
|
module ACS
|
||||||
|
|
||||||
|
class SecurityGroupParser < Fog::Parsers::Base
|
||||||
|
|
||||||
|
def reset
|
||||||
|
super
|
||||||
|
reset_security_group
|
||||||
|
end
|
||||||
|
|
||||||
|
def reset_security_group
|
||||||
|
@security_group = {'EC2SecurityGroups' => []}
|
||||||
|
end
|
||||||
|
|
||||||
|
def start_element(name, attrs = [])
|
||||||
|
super
|
||||||
|
case name
|
||||||
|
when 'EC2SecurityGroup'; then @ec2_group = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def end_element(name)
|
||||||
|
case name
|
||||||
|
when 'CacheSecurityGroupDescription', 'CacheSecurityGroupName', 'OwnerId'
|
||||||
|
@security_group[name] = value
|
||||||
|
when 'EC2SecurityGroup'
|
||||||
|
@security_group["#{name}s"] << @ec2_group unless @ec2_group.empty?
|
||||||
|
when 'EC2SecurityGroupName', 'EC2SecurityGroupOwnerId', 'Status'
|
||||||
|
@ec2_group[name] = value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,33 @@
|
||||||
|
module Fog
|
||||||
|
module AWS
|
||||||
|
class ACS
|
||||||
|
class Real
|
||||||
|
|
||||||
|
require 'fog/aws/parsers/acs/create_cache_security_group'
|
||||||
|
|
||||||
|
# creates a cache security group
|
||||||
|
#
|
||||||
|
# === Parameters
|
||||||
|
# * name <~String> - The name for the Cache Security Group
|
||||||
|
# * description <~String> - The description for the Cache Security Group
|
||||||
|
# === Returns
|
||||||
|
# * response <~Excon::Response>:
|
||||||
|
# * body <~Hash>
|
||||||
|
def create_cache_security_group(name, description = name)
|
||||||
|
request({
|
||||||
|
'Action' => 'CreateCacheSecurityGroup',
|
||||||
|
'CacheSecurityGroupName' => name,
|
||||||
|
'CacheSecurityGroupDescription' => description,
|
||||||
|
:parser => Fog::Parsers::AWS::ACS::CreateCacheSecurityGroup.new
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def create_cache_security_group(name, desciption=name)
|
||||||
|
Fog::Mock.not_implemented
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -3,6 +3,8 @@ class AWS < Fog::Bin
|
||||||
|
|
||||||
def class_for(key)
|
def class_for(key)
|
||||||
case key
|
case key
|
||||||
|
when :acs
|
||||||
|
Fog::AWS::ACS
|
||||||
when :auto_scaling
|
when :auto_scaling
|
||||||
Fog::AWS::AutoScaling
|
Fog::AWS::AutoScaling
|
||||||
when :cdn
|
when :cdn
|
||||||
|
@ -42,6 +44,8 @@ class AWS < Fog::Bin
|
||||||
def [](service)
|
def [](service)
|
||||||
@@connections ||= Hash.new do |hash, key|
|
@@connections ||= Hash.new do |hash, key|
|
||||||
hash[key] = case key
|
hash[key] = case key
|
||||||
|
when :acs
|
||||||
|
Fog::AWS::ACS.new
|
||||||
when :auto_scaling
|
when :auto_scaling
|
||||||
Fog::AWS::AutoScaling.new
|
Fog::AWS::AutoScaling.new
|
||||||
when :cdn
|
when :cdn
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
class AWS
|
||||||
|
module ACS
|
||||||
|
module Formats
|
||||||
|
|
||||||
|
BASIC = {
|
||||||
|
'ResponseMetadata' => {'RequestId' => String}
|
||||||
|
}
|
||||||
|
|
||||||
|
SECURITY_GROUP = {
|
||||||
|
'EC2SecurityGroups' => Array,
|
||||||
|
'CacheSecurityGroupName' => String,
|
||||||
|
'CacheSecurityGroupDescription' => String,
|
||||||
|
'OwnerId' => String
|
||||||
|
}
|
||||||
|
|
||||||
|
CREATE_SECURITY_GROUP = BASIC.merge('CacheSecurityGroup' => SECURITY_GROUP)
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,15 @@
|
||||||
|
Shindo.tests('AWS::ACS | instance requests', ['aws', 'acs']) do
|
||||||
|
|
||||||
|
@security_group_name = 'fog-test'
|
||||||
|
@security_group_description = 'Fog Test Group'
|
||||||
|
tests('success') do
|
||||||
|
pending if Fog.mocking?
|
||||||
|
|
||||||
|
tests('#create_cache_security_group').formats(AWS::ACS::Formats::CREATE_SECURITY_GROUP) do
|
||||||
|
body = AWS[:acs].create_cache_security_group(@security_group_name, @security_group_description).body
|
||||||
|
returns(@security_group_name) { body['CacheSecurityGroup']['CacheSecurityGroupName'] }
|
||||||
|
returns(@security_group_description) { body['CacheSecurityGroup']['CacheSecurityGroupDescription'] }
|
||||||
|
body
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue