def do_post_notification_methods(self, req, res):
     helpers.validate_json_content_type(req)
     helpers.validate_authorization(req, self._default_authorized_roles)
     notification = helpers.read_http_resource(req)
     self._validate_notification(notification)
     tenant_id = helpers.get_tenant_id(req)
     result = self._create_notification(tenant_id, notification, req.uri)
     res.body = helpers.dumpit_utf8(result)
     res.status = falcon.HTTP_201
Exemple #2
0
 def do_post_notification_methods(self, req, res):
     helpers.validate_json_content_type(req)
     helpers.validate_authorization(req, self._default_authorized_roles)
     notification = helpers.read_http_resource(req)
     self._validate_notification(notification)
     tenant_id = helpers.get_tenant_id(req)
     result = self._create_notification(tenant_id, notification, req.uri)
     res.body = helpers.dumpit_utf8(result)
     res.status = falcon.HTTP_201
Exemple #3
0
 def do_post_events(self, req, res):
     helpers.validate_json_content_type(req)
     helpers.validate_authorization(req, self._post_events_authorized_roles)
     event = helpers.read_http_resource(req)
     self._validate_event(event)
     tenant_id = helpers.get_tenant_id(req)
     transformed_event = self._event_transform(event, tenant_id,
                                               self._region)
     self._send_event(transformed_event)
     res.status = falcon.HTTP_204
Exemple #4
0
 def do_post_transforms(self, req, res):
     helpers.validate_json_content_type(req)
     helpers.validate_authorization(req, self._default_authorized_roles)
     transform = helpers.read_http_resource(req)
     self._validate_transform(transform)
     id = uuidutils.generate_uuid()
     tenant_id = helpers.get_tenant_id(req)
     self._create_transform(id, tenant_id, transform)
     res.body = self._create_transform_response(id, transform)
     res.status = falcon.HTTP_200
Exemple #5
0
 def do_post_events(self, req, res):
     helpers.validate_json_content_type(req)
     helpers.validate_authorization(req, self._post_events_authorized_roles)
     event = helpers.read_http_resource(req)
     self._validate_event(event)
     tenant_id = helpers.get_tenant_id(req)
     transformed_event = self._event_transform(event, tenant_id,
                                               self._region)
     self._send_event(transformed_event)
     res.status = falcon.HTTP_204
 def do_post_transforms(self, req, res):
     helpers.validate_json_content_type(req)
     helpers.validate_authorization(req, self._default_authorized_roles)
     transform = helpers.read_http_resource(req)
     self._validate_transform(transform)
     id = uuidutils.generate_uuid()
     tenant_id = helpers.get_tenant_id(req)
     self._create_transform(id, tenant_id, transform)
     res.body = self._create_transform_response(id, transform)
     res.status = falcon.HTTP_200
Exemple #7
0
    def _get_alarm_state(self, req):

        json_msg = helpers.read_http_resource(req)
        if 'state' in json_msg:
            state = json_msg['state'].upper()
            if state not in ['OK', 'ALARM', 'UNDETERMINED']:
                raise falcon.HTTPBadRequest('Bad request', 'Invalid state')
            return state
        else:
            raise falcon.HTTPBadRequest('Bad request', 'Missing state')
Exemple #8
0
    def _get_alarm_state(self, req):

        json_msg = helpers.read_http_resource(req)
        if 'state' in json_msg:
            state = json_msg['state'].upper()
            if state not in ['OK', 'ALARM', 'UNDETERMINED']:
                raise falcon.HTTPBadRequest('Bad request', 'Invalid state')
            return state
        else:
            raise falcon.HTTPBadRequest('Bad request', 'Missing state')
 def do_put_notification_methods(self, req, res, id):
     helpers.validate_json_content_type(req)
     helpers.validate_authorization(req, self._default_authorized_roles)
     notification = helpers.read_http_resource(req)
     self._validate_notification(notification)
     tenant_id = helpers.get_tenant_id(req)
     self._update_notification(id, tenant_id, notification)
     res.body = self._create_notification_response(id, notification,
                                                   req.uri)
     res.status = falcon.HTTP_200
Exemple #10
0
 def do_post_metrics(self, req, res):
     helpers.validate_json_content_type(req)
     helpers.validate_authorization(req,
                                    self._post_metrics_authorized_roles)
     metrics = helpers.read_http_resource(req)
     self._validate_metrics(metrics)
     tenant_id = (helpers.get_x_tenant_or_tenant_id(
         req, self._delegate_authorized_roles))
     transformed_metrics = self._metrics_transform(metrics, tenant_id,
                                                   self._region)
     self._send_metrics(transformed_metrics)
     res.status = falcon.HTTP_204
Exemple #11
0
 def do_post_metrics(self, req, res):
     helpers.validate_json_content_type(req)
     helpers.validate_authorization(req,
                                    self._post_metrics_authorized_roles)
     metrics = helpers.read_http_resource(req)
     self._validate_metrics(metrics)
     tenant_id = \
         helpers.get_x_tenant_or_tenant_id(req,
                                           self._delegate_authorized_roles)
     transformed_metrics = self._metrics_transform(metrics, tenant_id,
                                                   self._region)
     self._send_metrics(transformed_metrics)
     res.status = falcon.HTTP_204