* `template_url` The URL of the template to validate
* `template` A JSON template to validate - this takes precendence over the `template_url` if both are supplied.
+List Valid Resource Types
+-------------------------
+
+```
+GET /v1/{tenant_id}/resource_types
+```
+
+Parameters:
+
+* `tenant_id` The unique identifier of the tenant or account
+
List Stack Resources
--------------------
"/validate",
action="validate_template",
conditions={'method': 'POST'})
+ stack_mapper.connect("resource_types",
+ "/resource_types",
+ action="list_resource_types",
+ conditions={'method': 'GET'})
# Stack collection
stack_mapper.connect("stack_index",
return result
+ @util.tenant_local
+ def list_resource_types(self, req):
+ """
+ Returns a list of valid resource types that may be used in a template.
+ """
+
+ try:
+ types = self.engine.list_resource_types(req.context)
+ except rpc_common.RemoteError as ex:
+ raise exc.HTTPInternalServerError(explanation=str(ex))
+
+ return types
+
def create_resource(options):
"""
req, tenant_id=self.tenant, body=body)
self.m.VerifyAll()
+ def test_list_resource_types(self):
+ req = self._get('/resource_types')
+
+ engine_response = ['AWS::EC2::Instance',
+ 'AWS::EC2::EIP',
+ 'AWS::EC2::EIPAssociation']
+
+ self.m.StubOutWithMock(rpc, 'call')
+ rpc.call(req.context, self.topic,
+ {'method': 'list_resource_types',
+ 'args': {},
+ 'version': self.api_version},
+ None).AndReturn(engine_response)
+ self.m.ReplayAll()
+ response = self.controller.list_resource_types(req,
+ tenant_id=self.tenant)
+ self.assertEqual(response, engine_response)
+ self.m.VerifyAll()
+
+ def test_list_resource_types_error(self):
+ req = self._get('/resource_types')
+
+ engine_response = ['AWS::EC2::Instance',
+ 'AWS::EC2::EIP',
+ 'AWS::EC2::EIPAssociation']
+
+ self.m.StubOutWithMock(rpc, 'call')
+ rpc.call(req.context, self.topic,
+ {'method': 'list_resource_types',
+ 'args': {},
+ 'version': self.api_version},
+ None).AndRaise(rpc_common.RemoteError("ValueError"))
+ self.m.ReplayAll()
+
+ self.assertRaises(webob.exc.HTTPInternalServerError,
+ self.controller.list_resource_types,
+ req, tenant_id=self.tenant)
+ self.m.VerifyAll()
+
@attr(tag=['unit', 'api-openstack-v1', 'ResourceController'])
@attr(speed='fast')