Add the PATCH method for the monitoring API
[pti/o2.git] / o2ims / views / alarm_route.py
index 4f0b15c..8b0af04 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2021 Wind River Systems, Inc.
+# Copyright (C) 2021-2024 Wind River Systems, Inc.
 #
 #  Licensed under the Apache License, Version 2.0 (the "License");
 #  you may not use this file except in compliance with the License.
@@ -21,7 +21,8 @@ from o2common.views.route_exception import NotFoundException, \
     BadRequestException
 from o2ims.views import alarm_view
 from o2ims.views.api_ns import api_ims_monitoring as api_monitoring_v1
-from o2ims.views.alarm_dto import AlarmDTO, SubscriptionDTO
+from o2ims.views.alarm_dto import AlarmDTO, SubscriptionDTO, \
+    MonitoringApiV1DTO
 
 from o2common.helper import o2logging
 logger = o2logging.get_logger(__name__)
@@ -36,7 +37,10 @@ def configure_api_route():
 # ----------  API versions ---------- #
 @api_monitoring_v1.route("/v1/api_versions")
 class VersionRouter(Resource):
+    model = MonitoringApiV1DTO.api_version_info_get
+
     @api_monitoring_v1.doc('Get Monitoring API version')
+    @api_monitoring_v1.marshal_list_with(model)
     def get(self):
         return {
             'uriPrefix': request.base_url.rsplit('/', 1)[0],
@@ -136,6 +140,15 @@ class AlarmGetRouter(Resource):
         raise NotFoundException(
             "Alarm Event Record {} doesn't exist".format(alarmEventRecordId))
 
+    @api_monitoring_v1.doc('Patch Alarm Event Record Information')
+    @api_monitoring_v1.marshal_with(model)
+    def patch(self, alarmEventRecordId):
+        result = alarm_view.alarm_event_record_ack(alarmEventRecordId, bus.uow)
+        if result is not None:
+            return result
+        raise NotFoundException(
+            "Alarm Event Record {} doesn't exist".format(alarmEventRecordId))
+
 
 # ----------  Alarm Subscriptions ---------- #
 @api_monitoring_v1.route("/v1/alarmSubscriptions")