summaryrefslogtreecommitdiff
path: root/ick2/buildsapi.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2017-11-18 20:42:04 +0100
committerLars Wirzenius <liw@liw.fi>2017-11-18 20:42:04 +0100
commitab4060f964f4ec55d0bf671aa85c3f99af9fa21a (patch)
treee5cce9ea3ac040763e1c4aed45b7025739e40e63 /ick2/buildsapi.py
parent4e45654544c65741de49f2929664de84a76712e0 (diff)
downloadick2-ab4060f964f4ec55d0bf671aa85c3f99af9fa21a.tar.gz
Refactor: move BuildsAPI to its own module
Diffstat (limited to 'ick2/buildsapi.py')
-rw-r--r--ick2/buildsapi.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/ick2/buildsapi.py b/ick2/buildsapi.py
new file mode 100644
index 0000000..2d5b5f9
--- /dev/null
+++ b/ick2/buildsapi.py
@@ -0,0 +1,38 @@
+# Copyright (C) 2017 Lars Wirzenius
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+import ick2
+
+
+class BuildsAPI(ick2.ResourceApiBase): # pragma: no cover
+
+ def __init__(self, state):
+ super().__init__('builds', state)
+
+ def get_resource_name(self, resource):
+ return resource['build']
+
+ def create(self, body): # pragma: no cover
+ raise ick2.MethodNotAllowed('Creating builds directly is not allowed')
+
+ def update(self, body, name): # pragma: no cover
+ raise ick2.MethodNotAllowed('Updating builds directly is not allowed')
+
+ def list(self):
+ result = super().list()
+ items = result[self._type_name]
+ items.sort(key=lambda x: x.get('build_id'))
+ result[self._type_name] = items
+ return result