예제 #1
0
    def on_get(self, req, res, alarm_id=None):

        if alarm_id is None:
            helpers.validate_authorization(req, self._default_authorized_roles)
            tenant_id = helpers.get_tenant_id(req)
            start_timestamp = helpers.get_query_starttime_timestamp(req, False)
            end_timestamp = helpers.get_query_endtime_timestamp(req, False)
            query_parms = falcon.uri.parse_query_string(req.query_string)
            offset = helpers.get_query_param(req, 'offset')
            limit = helpers.get_limit(req)

            result = self._alarm_history_list(tenant_id, start_timestamp,
                                              end_timestamp, query_parms,
                                              req.uri, offset, limit)

            res.body = helpers.dumpit_utf8(result)
            res.status = falcon.HTTP_200

        else:
            helpers.validate_authorization(req, self._default_authorized_roles)
            tenant_id = helpers.get_tenant_id(req)
            offset = helpers.get_query_param(req, 'offset')
            limit = helpers.get_limit(req)

            result = self._alarm_history(tenant_id, [alarm_id], req.uri,
                                         offset, limit)

            res.body = helpers.dumpit_utf8(result)
            res.status = falcon.HTTP_200
예제 #2
0
    def on_get(self, req, res):
        helpers.validate_authorization(req, self._get_metrics_authorized_roles)
        tenant_id = (
            helpers.get_x_tenant_or_tenant_id(req,
                                              self._delegate_authorized_roles))
        name = helpers.get_query_name(req, True)
        helpers.validate_query_name(name)
        dimensions = helpers.get_query_dimensions(req)
        helpers.validate_query_dimensions(dimensions)
        start_timestamp = helpers.get_query_starttime_timestamp(req)
        end_timestamp = helpers.get_query_endtime_timestamp(req, False)
        helpers.validate_start_end_timestamps(start_timestamp, end_timestamp)
        statistics = helpers.get_query_statistics(req)
        period = helpers.get_query_period(req)
        offset = helpers.get_query_param(req, 'offset')
        merge_metrics_flag = get_merge_metrics_flag(req)
        group_by = helpers.get_query_group_by(req)

        result = self._metric_statistics(tenant_id, name, dimensions,
                                         start_timestamp, end_timestamp,
                                         statistics, period, req.uri,
                                         offset, req.limit, merge_metrics_flag,
                                         group_by)

        res.body = helpers.dumpit_utf8(result)
        res.status = falcon.HTTP_200
예제 #3
0
    def on_get(self, req, res, alarm_id=None):

        if alarm_id is None:
            helpers.validate_authorization(req, self._get_alarms_authorized_roles)
            start_timestamp = helpers.get_query_starttime_timestamp(req, False)
            end_timestamp = helpers.get_query_endtime_timestamp(req, False)
            offset = helpers.get_query_param(req, 'offset')
            dimensions = helpers.get_query_dimensions(req)
            helpers.validate_query_dimensions(dimensions)

            result = self._alarm_history_list(req.project_id, start_timestamp,
                                              end_timestamp, dimensions,
                                              req.uri, offset, req.limit)

            res.body = helpers.to_json(result)
            res.status = falcon.HTTP_200

        else:
            helpers.validate_authorization(req, self._get_alarms_authorized_roles)
            offset = helpers.get_query_param(req, 'offset')

            result = self._alarm_history(req.project_id, alarm_id,
                                         req.uri, offset,
                                         req.limit)

            res.body = helpers.to_json(result)
            res.status = falcon.HTTP_200
예제 #4
0
 def on_get(self, req, res):
     helpers.validate_authorization(req, self._get_metrics_authorized_roles)
     tenant_id = (helpers.get_x_tenant_or_tenant_id(
         req, self._delegate_authorized_roles))
     name = helpers.get_query_name(req)
     helpers.validate_query_name(name)
     dimensions = helpers.get_query_dimensions(req)
     helpers.validate_query_dimensions(dimensions)
     offset = helpers.get_query_param(req, 'offset')
     start_timestamp = helpers.get_query_starttime_timestamp(req, False)
     end_timestamp = helpers.get_query_endtime_timestamp(req, False)
     helpers.validate_start_end_timestamps(start_timestamp, end_timestamp)
     result = self._list_metrics(tenant_id, name, dimensions, req.uri,
                                 offset, req.limit, start_timestamp,
                                 end_timestamp)
     res.body = helpers.dumpit_utf8(result)
     res.status = falcon.HTTP_200
예제 #5
0
 def on_get(self, req, res):
     helpers.validate_authorization(req, self._get_metrics_authorized_roles)
     tenant_id = helpers.get_tenant_id(req)
     name = helpers.get_query_name(req)
     helpers.validate_query_name(name)
     dimensions = helpers.get_query_dimensions(req)
     helpers.validate_query_dimensions(dimensions)
     offset = helpers.get_query_param(req, 'offset')
     limit = helpers.get_limit(req)
     start_timestamp = helpers.get_query_starttime_timestamp(req, False)
     end_timestamp = helpers.get_query_endtime_timestamp(req, False)
     helpers.validate_start_end_timestamps(start_timestamp, end_timestamp)
     result = self._list_metrics(tenant_id, name, dimensions,
                                 req.uri, offset, limit,
                                 start_timestamp, end_timestamp)
     res.body = helpers.dumpit_utf8(result)
     res.status = falcon.HTTP_200
예제 #6
0
    def on_get(self, req, res):
        helpers.validate_authorization(req, self._default_authorized_roles)
        tenant_id = helpers.get_tenant_id(req)
        name = helpers.get_query_name(req, True)
        helpers.validate_query_name(name)
        dimensions = helpers.get_query_dimensions(req)
        helpers.validate_query_dimensions(dimensions)
        start_timestamp = helpers.get_query_starttime_timestamp(req)
        end_timestamp = helpers.get_query_endtime_timestamp(req, False)
        offset = helpers.get_query_param(req, 'offset')
        limit = helpers.get_limit(req)
        merge_metrics_flag = get_merge_metrics_flag(req)

        result = self._measurement_list(tenant_id, name, dimensions,
                                        start_timestamp, end_timestamp,
                                        req.uri, offset, limit,
                                        merge_metrics_flag)

        res.body = helpers.dumpit_utf8(result)
        res.status = falcon.HTTP_200
예제 #7
0
    def on_get(self, req, res, alarm_id=None):
        helpers.validate_authorization(req, ['api:alarms:state_history'])
        offset = helpers.get_query_param(req, 'offset')

        if alarm_id is None:
            start_timestamp = helpers.get_query_starttime_timestamp(req, False)
            end_timestamp = helpers.get_query_endtime_timestamp(req, False)

            dimensions = helpers.get_query_dimensions(req)
            helpers.validate_query_dimensions(dimensions)

            result = self._alarm_history_list(req.project_id, start_timestamp,
                                              end_timestamp, dimensions,
                                              req.uri, offset, req.limit)

        else:
            result = self._alarm_history(req.project_id, alarm_id, req.uri,
                                         offset, req.limit)

        res.body = helpers.to_json(result)
        res.status = falcon.HTTP_200
예제 #8
0
    def on_get(self, req, res):
        helpers.validate_authorization(req, ['api:metrics:get'])
        tenant_id = helpers.get_x_tenant_or_tenant_id(req, ['api:delegate'])
        name = helpers.get_query_name(req, True)
        helpers.validate_query_name(name)
        dimensions = helpers.get_query_dimensions(req)
        helpers.validate_query_dimensions(dimensions)
        start_timestamp = helpers.get_query_starttime_timestamp(req)
        end_timestamp = helpers.get_query_endtime_timestamp(req, False)
        helpers.validate_start_end_timestamps(start_timestamp, end_timestamp)
        offset = helpers.get_query_param(req, 'offset')
        merge_metrics_flag = get_merge_metrics_flag(req)
        group_by = helpers.get_query_group_by(req)

        result = self._measurement_list(tenant_id, name, dimensions,
                                        start_timestamp, end_timestamp,
                                        req.uri, offset, req.limit,
                                        merge_metrics_flag, group_by)

        res.body = helpers.to_json(result)
        res.status = falcon.HTTP_200