示例#1
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
示例#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 test_valid_timestamps(self):
        start_time = '2015-01-01T00:00:00Z'
        end_time = '2015-01-01T00:00:01Z'
        start_timestamp = helpers._convert_time_string(start_time)
        end_timestamp = helpers._convert_time_string(end_time)

        try:
            helpers.validate_start_end_timestamps(start_timestamp,
                                                  end_timestamp)
        except:
            self.fail("shouldn't happen")
示例#4
0
    def test_valid_timestamps(self):
        start_time = '2015-01-01T00:00:00Z'
        end_time = '2015-01-01T00:00:01Z'
        start_timestamp = helpers._convert_time_string(start_time)
        end_timestamp = helpers._convert_time_string(end_time)

        try:
            helpers.validate_start_end_timestamps(start_timestamp,
                                                  end_timestamp)
        except:
            self.fail("shouldn't happen")
示例#5
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)
     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.to_json(result)
     res.status = falcon.HTTP_200
示例#6
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