"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "monasca_api/v2/reference/metrics.py" between
monasca-api-3.0.0.tar.gz and monasca-api-3.1.0.tar.gz

About: OpenStack Monasca API is a RESTful API server that is designed with a layered architecture and supports Monitoring as a Service (MONaaS).
The "Train" series (latest release).

metrics.py  (monasca-api-3.0.0):metrics.py  (monasca-api-3.1.0)
skipping to change at line 286 skipping to change at line 286
raise falcon.HTTPInternalServerError('Service unavailable', str(ex)) raise falcon.HTTPInternalServerError('Service unavailable', str(ex))
@resource.resource_try_catch_block @resource.resource_try_catch_block
def on_get(self, req, res): def on_get(self, req, res):
helpers.validate_authorization(req, ['api:metrics:dimension:values']) helpers.validate_authorization(req, ['api:metrics:dimension:values'])
tenant_id = helpers.get_x_tenant_or_tenant_id(req, ['api:delegate']) tenant_id = helpers.get_x_tenant_or_tenant_id(req, ['api:delegate'])
metric_name = helpers.get_query_param(req, 'metric_name') metric_name = helpers.get_query_param(req, 'metric_name')
dimension_name = helpers.get_query_param(req, 'dimension_name', dimension_name = helpers.get_query_param(req, 'dimension_name',
required=True) required=True)
offset = helpers.get_query_param(req, 'offset') 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)
result = self._dimension_values(tenant_id, req.uri, metric_name, result = self._dimension_values(tenant_id, req.uri, metric_name,
dimension_name, offset, req.limit) dimension_name, offset, req.limit,
start_timestamp, end_timestamp)
res.body = helpers.to_json(result) res.body = helpers.to_json(result)
res.status = falcon.HTTP_200 res.status = falcon.HTTP_200
def _dimension_values(self, tenant_id, req_uri, metric_name, def _dimension_values(self, tenant_id, req_uri, metric_name,
dimension_name, offset, limit): dimension_name, offset, limit, start_timestamp,
end_timestamp):
result = self._metrics_repo.list_dimension_values(tenant_id, result = self._metrics_repo.list_dimension_values(tenant_id,
self._region, self._region,
metric_name, metric_name,
dimension_name) dimension_name,
start_timestamp,
end_timestamp)
return helpers.paginate_with_no_id(result, req_uri, offset, limit) return helpers.paginate_with_no_id(result, req_uri, offset, limit)
class DimensionNames(metrics_api_v2.DimensionNamesV2API): class DimensionNames(metrics_api_v2.DimensionNamesV2API):
def __init__(self): def __init__(self):
try: try:
super(DimensionNames, self).__init__() super(DimensionNames, self).__init__()
self._region = cfg.CONF.region self._region = cfg.CONF.region
self._metrics_repo = simport.load( self._metrics_repo = simport.load(
cfg.CONF.repositories.metrics_driver)() cfg.CONF.repositories.metrics_driver)()
skipping to change at line 320 skipping to change at line 326
LOG.exception(ex) LOG.exception(ex)
raise falcon.HTTPInternalServerError('Service unavailable', raise falcon.HTTPInternalServerError('Service unavailable',
str(ex)) str(ex))
@resource.resource_try_catch_block @resource.resource_try_catch_block
def on_get(self, req, res): def on_get(self, req, res):
helpers.validate_authorization(req, ['api:metrics:dimension:names']) helpers.validate_authorization(req, ['api:metrics:dimension:names'])
tenant_id = helpers.get_x_tenant_or_tenant_id(req, ['api:delegate']) tenant_id = helpers.get_x_tenant_or_tenant_id(req, ['api:delegate'])
metric_name = helpers.get_query_param(req, 'metric_name') metric_name = helpers.get_query_param(req, 'metric_name')
offset = helpers.get_query_param(req, 'offset') 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)
result = self._dimension_names(tenant_id, req.uri, metric_name, result = self._dimension_names(tenant_id, req.uri, metric_name,
offset, req.limit) offset, req.limit,
start_timestamp, end_timestamp)
res.body = helpers.to_json(result) res.body = helpers.to_json(result)
res.status = falcon.HTTP_200 res.status = falcon.HTTP_200
def _dimension_names(self, tenant_id, req_uri, metric_name, offset, limit): def _dimension_names(self, tenant_id, req_uri, metric_name, offset, limit,
start_timestamp, end_timestamp):
result = self._metrics_repo.list_dimension_names(tenant_id, result = self._metrics_repo.list_dimension_names(tenant_id,
self._region, self._region,
metric_name) metric_name,
start_timestamp,
end_timestamp)
return helpers.paginate_with_no_id(result, req_uri, offset, limit) return helpers.paginate_with_no_id(result, req_uri, offset, limit)
 End of changes. 8 change blocks. 
6 lines changed or deleted 18 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)