Add list_exports to CloudFormationResponse
This commit is contained in:
parent
a0651ccde5
commit
de9ea10eb1
3 changed files with 113 additions and 0 deletions
|
|
@ -206,6 +206,17 @@ class CloudFormationBackend(BaseBackend):
|
|||
if stack.name == name_or_stack_id:
|
||||
self.delete_stack(stack.stack_id)
|
||||
|
||||
def list_exports(self, token):
|
||||
all_exports = [x for x in self.exports.values()]
|
||||
if token is None:
|
||||
exports = all_exports[0:100]
|
||||
next_token = '100' if len(all_exports) > 100 else None
|
||||
else:
|
||||
token = int(token)
|
||||
exports = all_exports[token:token + 100]
|
||||
next_token = str(token + 100) if len(all_exports) > token + 100 else None
|
||||
return exports, next_token
|
||||
|
||||
|
||||
cloudformation_backends = {}
|
||||
for region in boto.cloudformation.regions():
|
||||
|
|
|
|||
|
|
@ -210,6 +210,12 @@ class CloudFormationResponse(BaseResponse):
|
|||
template = self.response_template(DELETE_STACK_RESPONSE_TEMPLATE)
|
||||
return template.render()
|
||||
|
||||
def list_exports(self):
|
||||
token = self._get_param('NextToken')
|
||||
exports, next_token = self.cloudformation_backend.list_exports(token=token)
|
||||
template = self.response_template(LIST_EXPORTS_RESPONSE)
|
||||
return template.render(exports=exports, next_token=next_token)
|
||||
|
||||
|
||||
CREATE_STACK_RESPONSE_TEMPLATE = """<CreateStackResponse>
|
||||
<CreateStackResult>
|
||||
|
|
@ -410,3 +416,23 @@ DELETE_STACK_RESPONSE_TEMPLATE = """<DeleteStackResponse>
|
|||
</ResponseMetadata>
|
||||
</DeleteStackResponse>
|
||||
"""
|
||||
|
||||
LIST_EXPORTS_RESPONSE = """<ListExportsResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/">
|
||||
<ListExportsResult>
|
||||
<Exports>
|
||||
{% for export in exports %}
|
||||
<member>
|
||||
<ExportingStackId>{{ export.exporting_stack_id }}</ExportingStackId>
|
||||
<Name>{{ export.name }}</Name>
|
||||
<Value>{{ export.value }}</Value>
|
||||
</member>
|
||||
{% endfor %}
|
||||
</Exports>
|
||||
{% if next_token %}
|
||||
<NextToken>{{ next_token }}</NextToken>
|
||||
{% endif %}
|
||||
</ListExportsResult>
|
||||
<ResponseMetadata>
|
||||
<RequestId>5ccc7dcd-744c-11e5-be70-example</RequestId>
|
||||
</ResponseMetadata>
|
||||
</ListExportsResponse>"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue