1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Adding support for AWS CloudFormation list_stacks and list_stack_resources API calls

This commit is contained in:
Joe Kinsella 2013-05-04 21:32:57 -04:00
parent 07c4d64195
commit 35b25fd4fa
6 changed files with 151 additions and 0 deletions

View file

@ -17,6 +17,8 @@ module Fog
request :describe_stacks
request :get_template
request :validate_template
request :list_stacks
request :list_stack_resources
class Mock

View file

@ -0,0 +1,32 @@
module Fog
module Parsers
module AWS
module CloudFormation
class ListStackResources < Fog::Parsers::Base
def reset
@resource = {}
@response = { 'StackResourceSummaries' => [] }
end
def end_element(name)
case name
when 'ResourceStatus', 'LogicalResourceId', 'PhysicalResourceId', 'ResourceType'
@resource[name] = value
when 'member'
@response['StackResourceSummaries'] << @resource
@resource = {}
when 'LastUpdatedTimestamp'
@resource[name] = Time.parse(value)
when 'RequestId'
@response[name] = value
when 'NextToken'
@response[name] = value
end
end
end
end
end
end
end

View file

@ -0,0 +1,34 @@
module Fog
module Parsers
module AWS
module CloudFormation
class ListStacks < Fog::Parsers::Base
def reset
@stack = {}
@response = { 'StackSummaries' => [] }
end
def end_element(name)
case name
when 'StackId', 'StackStatus', 'StackName', 'TemplateDescription'
@stack[name] = value
when 'member'
@response['StackSummaries'] << @stack
@stack = {}
when 'RequestId'
@response[name] = value
when 'CreationTime'
@stack[name] = Time.parse(value)
when 'DeletionTime'
@stack[name] = Time.parse(value)
when 'NextToken'
@response[name] = value
end
end
end
end
end
end
end

View file

@ -0,0 +1,36 @@
module Fog
module AWS
class CloudFormation
class Real
require 'fog/aws/parsers/cloud_formation/list_stack_resources'
# List stack resources.
#
# @param options [Hash]
# @option options StackName [String] Name of the stack to describe.
#
# @return [Excon::Response]
# * body [Hash]:
# * StackResourceSummaries [Array] - Matching stacks
# * resources [Hash]:
# * ResourceStatus [String] -
# * LogicalResourceId [String] -
# * PhysicalResourceId [String] -
# * ResourceType [String] -
# * LastUpdatedTimestamp [Time] -
#
#
# @see http://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_ListStacks.html
def list_stack_resources(options = {})
request({
'Action' => 'ListStackResources',
:parser => Fog::Parsers::AWS::CloudFormation::ListStackResources.new
}.merge!(options))
end
end
end
end
end

View file

@ -0,0 +1,37 @@
module Fog
module AWS
class CloudFormation
class Real
require 'fog/aws/parsers/cloud_formation/list_stacks'
# List stacks.
#
# @param options [Hash]
#
# @return [Excon::Response]
# * body [Hash]:
# * StackSummaries [Array] - Matching stacks
# * stack [Hash]:
# * StackId [String] -
# * StackName [String] -
# * TemplateDescription [String] -
# * CreationTime [Time] -
# * DeletionTime [Time] -
# * StackStatus [String] -
# * DeletionTime [String] -
#
#
# @see http://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_ListStacks.html
def list_stacks(options = {})
request({
'Action' => 'ListStacks',
:parser => Fog::Parsers::AWS::CloudFormation::ListStacks.new
}.merge!(options))
end
end
end
end
end

View file

@ -144,6 +144,16 @@ Shindo.tests('AWS::CloudFormation | stack requests', ['aws', 'cloudformation'])
Fog::AWS[:cloud_formation].delete_stack(@stack_name)
end
tests("list_stacks").succeeds do
pending if Fog.mocking?
Fog::AWS[:cloud_formation].list_stacks.body
end
tests("list_stack_resources").succeeds do
pending if Fog.mocking?
Fog::AWS[:cloud_formation].list_stack_resources("StackName"=>@stack_name).body
end
unless Fog.mocking?
@keypair.destroy
end