This repository has been archived by the owner on May 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
/
operation.py
80 lines (67 loc) · 2.86 KB
/
operation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import pecan
from pecan import rest
import six
import wsme
from wsme import types as wtypes
import wsmeext.pecan as wsme_pecan
from solum.api.controllers.v1.datamodel import operation
from solum.api.handlers import operation_handler
from solum.common import exception
from solum.openstack.common.gettextutils import _
class OperationController(rest.RestController):
"""Manages operations on a single operation."""
def __init__(self, operation_id):
super(OperationController, self).__init__()
self._id = operation_id
@exception.wrap_controller_exception
@wsme_pecan.wsexpose(operation.Operation, wtypes.text)
def get(self):
"""Return this operation."""
handler = operation_handler.OperationHandler(
pecan.request.security_context)
return handler.get(self._id)
@wsme_pecan.wsexpose(operation.Operation, wtypes.text,
body=operation.Operation)
def put(self, data):
"""Modify this operation."""
error = _("Not implemented")
pecan.response.translatable_error = error
raise wsme.exc.ClientSideError(six.text_type(error))
@wsme_pecan.wsexpose(None, wtypes.text, status_code=204)
def delete(self):
"""Delete this operation."""
error = _("Not implemented")
pecan.response.translatable_error = error
raise wsme.exc.ClientSideError(six.text_type(error))
class OperationsController(rest.RestController):
"""Manages operations on the operations collection."""
@pecan.expose()
def _lookup(self, operation_id, *remainder):
if remainder and not remainder[-1]:
remainder = remainder[:-1]
return OperationController(operation_id), remainder
@wsme_pecan.wsexpose(operation.Operation, body=operation.Operation,
status_code=201)
def post(self, data):
"""Create a new operation."""
error = _("Not implemented")
pecan.response.translatable_error = error
raise wsme.exc.ClientSideError(six.text_type(error))
@exception.wrap_controller_exception
@wsme_pecan.wsexpose([operation.Operation])
def get_all(self):
"""Return all operations, based on the query provided."""
handler = operation_handler.OperationHandler(
pecan.request.security_context)
return handler.get_all()