Browse Source

Merge "Modify vitrage api"

master
Zuul 1 week ago
parent
commit
c1e3e0e83e
2 changed files with 12 additions and 14 deletions
  1. 3
    2
      doc/source/contributor/vitrage-api.rst
  2. 9
    12
      vitrage/api/controllers/v1/alarm.py

+ 3
- 2
doc/source/contributor/vitrage-api.rst View File

@@ -197,7 +197,8 @@ Response Status Code
197 197
 ====================
198 198
 
199 199
 -  200 - OK
200
--  400 - Bad request
200
+-  403 - Forbidden
201
+-  404 - Not Found
201 202
 
202 203
 Response Body
203 204
 =============
@@ -1248,7 +1249,7 @@ Response Status code
1248 1249
 ====================
1249 1250
 
1250 1251
 -  200 - OK
1251
--  400 - Bad request
1252
+-  404 - Not Found
1252 1253
 
1253 1254
 Response Body
1254 1255
 =============

+ 9
- 12
vitrage/api/controllers/v1/alarm.py View File

@@ -57,22 +57,19 @@ class AlarmsController(BaseAlarmsController):
57 57
 
58 58
         LOG.info('returns show alarm with vitrage id %s', vitrage_id)
59 59
 
60
-        try:
61
-            return self._show_alarm(vitrage_id)
62
-        except Exception:
63
-            LOG.exception('Failed to load JSON.')
64
-            abort(404, "Failed to show alarm.")
60
+        return self._show_alarm(vitrage_id)
65 61
 
66 62
     @staticmethod
67 63
     def _show_alarm(vitrage_id):
68
-        alarm_json = pecan.request.client.call(pecan.request.context,
69
-                                               'show_alarm',
70
-                                               vitrage_id=vitrage_id)
71
-        LOG.info(alarm_json)
72
-
73 64
         try:
74
-            alarms_list = json.loads(alarm_json)
75
-            return alarms_list
65
+            alarm_json = pecan.request.client.call(pecan.request.context,
66
+                                                   'show_alarm',
67
+                                                   vitrage_id=vitrage_id)
68
+            LOG.info(alarm_json)
69
+            if not alarm_json:
70
+                abort(404, "Failed to find alarm %s" % vitrage_id)
71
+
72
+            return json.loads(alarm_json)
76 73
 
77 74
         except Exception:
78 75
             LOG.exception('Failed to load JSON.')

Loading…
Cancel
Save