From b74053a95b114c3867d87bdb15d3878a9514d522 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Mon, 2 May 2016 19:05:53 +0200 Subject: [PATCH] Support getting /latest node type entry point --- pillarsdk/nodes.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pillarsdk/nodes.py b/pillarsdk/nodes.py index 4389839..016c902 100755 --- a/pillarsdk/nodes.py +++ b/pillarsdk/nodes.py @@ -64,6 +64,18 @@ class Node(List, Find, Create, Post, Update, Delete, Replace): return True return False + @classmethod + def latest(cls, node_type, api=None): + """Get list of latestnodes.""" + + api = api or Api.Default() + url = 'latest/%s' % node_type + + response = api.get(url) + for item in response['_items']: + utils.convert_datetime(item) + return cls.list_class(response) + class NodeType(List, Find, Create, Post, Delete): """NodeType class wrapping the REST node_types endpoint