diff options
-rw-r--r-- | ick2/controllerapi.py | 10 | ||||
-rw-r--r-- | yarns/300-workers.yarn | 18 |
2 files changed, 19 insertions, 9 deletions
diff --git a/ick2/controllerapi.py b/ick2/controllerapi.py index aa0871b..6d25a7d 100644 --- a/ick2/controllerapi.py +++ b/ick2/controllerapi.py @@ -34,6 +34,7 @@ class ControllerAPI: apis = { '/version': VersionAPI, '/projects': ProjectAPI, + '/workers': WorkerAPI, } routes = [] @@ -208,6 +209,15 @@ class ProjectAPI(SubAPI): return resource['project'] +class WorkerAPI(SubAPI): # pragma: no cover + + def __init__(self, state): + super().__init__('workers', state) + + def get_resource_name(self, resource): + return resource['worker'] + + def response(status_code, body, headers): # pragma: no cover obj = { 'status': status_code, diff --git a/yarns/300-workers.yarn b/yarns/300-workers.yarn index 473dd29..6386ae9 100644 --- a/yarns/300-workers.yarn +++ b/yarns/300-workers.yarn @@ -64,11 +64,11 @@ controller API. It doesn't actually talk to the worker itself. WHEN user makes request GET /workers THEN result has status code 200 - AND body matches { "projects": [] } + AND body matches { "workers": [] } WHEN user makes request POST /workers ... { - ... "workers": "obelix", + ... "worker": "obelix", ... "protocol": "ssh", ... "address": "obelix.ick.example", ... "user": "ick", @@ -79,7 +79,7 @@ controller API. It doesn't actually talk to the worker itself. THEN result has status code 201 AND body matches ... { - ... "workers": "obelix", + ... "worker": "obelix", ... "protocol": "ssh", ... "address": "obelix.ick.example", ... "user": "ick", @@ -93,9 +93,9 @@ controller API. It doesn't actually talk to the worker itself. THEN result has status code 200 AND body matches ... { - ... "projects": [ + ... "workers": [ ... { - ... "workers": "obelix", + ... "worker": "obelix", ... "protocol": "ssh", ... "address": "obelix.ick.example", ... "user": "ick", @@ -112,7 +112,7 @@ controller API. It doesn't actually talk to the worker itself. THEN result has status code 200 AND body matches ... { - ... "workers": "obelix", + ... "worker": "obelix", ... "protocol": "ssh", ... "address": "obelix.ick.example", ... "user": "ick", @@ -123,7 +123,7 @@ controller API. It doesn't actually talk to the worker itself. WHEN user makes request PUT /workers/obelix ... { - ... "workers": "obelix", + ... "worker": "obelix", ... "protocol": "local", ... "keywords": { ... "debian_codename": "unstable" @@ -132,7 +132,7 @@ controller API. It doesn't actually talk to the worker itself. THEN result has status code 200 AND body matches ... { - ... "workers": "obelix", + ... "worker": "obelix", ... "protocol": "local", ... "keywords": { ... "debian_codename": "unstable" @@ -144,7 +144,7 @@ controller API. It doesn't actually talk to the worker itself. THEN result has status code 200 AND body matches ... { - ... "workers": "obelix", + ... "worker": "obelix", ... "protocol": "local", ... "keywords": { ... "debian_codename": "unstable" |