summaryrefslogtreecommitdiff
path: root/ironic/api/controllers/v1/node.py
diff options
context:
space:
mode:
authorLucas Alvares Gomes <lucasagomes@gmail.com>2013-09-23 11:32:09 +0100
committerLucas Alvares Gomes <lucasagomes@gmail.com>2013-09-23 11:32:09 +0100
commit59c2862d6561b4a2fed807f5e120dc50867aae1b (patch)
tree79147fa245d869e5022d7edc666a3b1349315db8 /ironic/api/controllers/v1/node.py
parent92413d72460b1e664b6b21e1220d020cef32d62f (diff)
downloadironic-59c2862d6561b4a2fed807f5e120dc50867aae1b.tar.gz
Collection named based on resource type
To be more consistent with other existing OpenStack APIs, the collection name is now based on the requested resource type. Also, the link to the next subset of the collection is now an attribute on the root document of the request body. Change-Id: Ie0f99d975b691aad7cd39fddd7d141f95c7912f8 Closes-Bug: #1227928
Diffstat (limited to 'ironic/api/controllers/v1/node.py')
-rw-r--r--ironic/api/controllers/v1/node.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/ironic/api/controllers/v1/node.py b/ironic/api/controllers/v1/node.py
index b87108a11..54c8a22e7 100644
--- a/ironic/api/controllers/v1/node.py
+++ b/ironic/api/controllers/v1/node.py
@@ -245,15 +245,17 @@ class Node(base.APIBase):
class NodeCollection(collection.Collection):
"""API representation of a collection of nodes."""
- items = [Node]
+ nodes = [Node]
"A list containing nodes objects"
+ def __init__(self, **kwargs):
+ self._type = 'nodes'
+
@classmethod
def convert_with_links(cls, nodes, limit, **kwargs):
collection = NodeCollection()
- collection.type = 'node'
- collection.items = [Node.convert_with_links(n) for n in nodes]
- collection.links = collection.make_links(limit, 'nodes', **kwargs)
+ collection.nodes = [Node.convert_with_links(n) for n in nodes]
+ collection.next = collection.get_next(limit, **kwargs)
return collection
@@ -425,10 +427,9 @@ class NodesController(rest.RestController):
sort_key=sort_key,
sort_dir=sort_dir)
collection = port.PortCollection()
- collection.type = 'port'
- collection.items = [port.Port.convert_with_links(n) for n in ports]
+ collection.ports = [port.Port.convert_with_links(n) for n in ports]
resource_url = '/'.join(['nodes', node_uuid, 'ports'])
- collection.links = collection.make_links(limit, resource_url,
- sort_key=sort_key,
- sort_dir=sort_dir)
+ collection.next = collection.get_next(limit, url=resource_url,
+ sort_key=sort_key,
+ sort_dir=sort_dir)
return collection