本文整理汇总了Python中monasca_api.v2.reference.helpers.get_query_dimensions函数的典型用法代码示例。如果您正苦于以下问题:Python get_query_dimensions函数的具体用法?Python get_query_dimensions怎么用?Python get_query_dimensions使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_query_dimensions函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: on_get
def on_get(self, req, res, alarm_definition_id=None):
if alarm_definition_id is None:
helpers.validate_authorization(req, self._default_authorized_roles)
tenant_id = helpers.get_tenant_id(req)
name = helpers.get_query_name(req)
dimensions = helpers.get_query_dimensions(req)
offset = helpers.get_query_param(req, 'offset')
limit = helpers.get_limit(req)
result = self._alarm_definition_list(tenant_id, name, dimensions,
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)
result = self._alarm_definition_show(tenant_id,
alarm_definition_id)
helpers.add_links_to_resource(result,
re.sub('/' + alarm_definition_id, '',
req.uri))
res.body = helpers.dumpit_utf8(result)
res.status = falcon.HTTP_200
开发者ID:nilwyh,项目名称:monasca-api,代码行数:27,代码来源:alarm_definitions.py
示例2: on_get
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
开发者ID:artur-ba,项目名称:monasca-api,代码行数:26,代码来源:metrics.py
示例3: on_get
def on_get(self, req, res):
helpers.validate_authorization(req, ['api:alarms:count'])
query_parms = falcon.uri.parse_query_string(req.query_string)
if 'state' in query_parms:
validation.validate_alarm_state(query_parms['state'])
query_parms['state'] = query_parms['state'].upper()
if 'severity' in query_parms:
validation.validate_severity_query(query_parms['severity'])
query_parms['severity'] = query_parms['severity'].upper()
if 'group_by' in query_parms:
if not isinstance(query_parms['group_by'], list):
query_parms['group_by'] = query_parms['group_by'].split(',')
self._validate_group_by(query_parms['group_by'])
query_parms['metric_dimensions'] = helpers.get_query_dimensions(req, 'metric_dimensions')
helpers.validate_query_dimensions(query_parms['metric_dimensions'])
offset = helpers.get_query_param(req, 'offset')
if offset is not None:
try:
offset = int(offset)
except Exception:
raise HTTPUnprocessableEntityError(
"Unprocessable Entity",
"Offset must be a valid integer, was {}".format(offset))
result = self._alarms_count(req.uri, req.project_id, query_parms, offset, req.limit)
res.body = helpers.to_json(result)
res.status = falcon.HTTP_200
开发者ID:openstack,项目名称:monasca-api,代码行数:34,代码来源:alarms.py
示例4: on_get
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
开发者ID:jgrassler,项目名称:monasca-api,代码行数:27,代码来源:alarms.py
示例5: test_one_dimensions
def test_one_dimensions(self):
req = Mock()
req.query_string = "foo=bar&dimensions=Dimension:Value"
result = helpers.get_query_dimensions(req)
self.assertEqual(result, {"Dimension": "Value"})
开发者ID:Missxiaoguo,项目名称:monasca-api,代码行数:8,代码来源:test_query_helpers.py
示例6: test_no_dimensions
def test_no_dimensions(self):
req = Mock()
req.query_string = "foo=bar"
result = helpers.get_query_dimensions(req)
self.assertEqual(result, {})
开发者ID:Missxiaoguo,项目名称:monasca-api,代码行数:8,代码来源:test_query_helpers.py
示例7: test_comma_sep_dimensions
def test_comma_sep_dimensions(self):
req = Mock()
req.query_string = ("foo=bar&"
"dimensions=Dimension:Value,Dimension-2:Value-2")
result = helpers.get_query_dimensions(req)
self.assertEqual(
result, {"Dimension": "Value", "Dimension-2": "Value-2"})
开发者ID:Missxiaoguo,项目名称:monasca-api,代码行数:10,代码来源:test_query_helpers.py
示例8: test_dimension_with_multi_colons
def test_dimension_with_multi_colons(self):
req = Mock()
req.query_string = ("foo=bar&dimensions=url:http://192.168.10.4:5601,"
"hostname:monasca,component:kibana,service:monitoring")
result = helpers.get_query_dimensions(req)
self.assertEqual(result, {"url": "http://192.168.10.4:5601",
"hostname": "monasca",
"component": "kibana",
"service": "monitoring"})
开发者ID:jgrassler,项目名称:monasca-api,代码行数:10,代码来源:test_query_helpers.py
示例9: on_get
def on_get(self, req, res):
helpers.validate_authorization(req, self._get_metrics_authorized_roles)
tenant_id = helpers.get_tenant_id(req)
dimensions = helpers.get_query_dimensions(req)
helpers.validate_query_dimensions(dimensions)
offset = helpers.get_query_param(req, 'offset')
limit = helpers.get_limit(req)
result = self._list_metric_names(tenant_id, dimensions,
req.uri, offset, limit)
res.body = helpers.dumpit_utf8(result)
res.status = falcon.HTTP_200
开发者ID:sapcc,项目名称:monasca-api,代码行数:11,代码来源:metrics.py
示例10: on_get
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))
dimensions = helpers.get_query_dimensions(req)
helpers.validate_query_dimensions(dimensions)
offset = helpers.get_query_param(req, 'offset')
result = self._list_metric_names(tenant_id, dimensions,
req.uri, offset, req.limit)
res.body = helpers.to_json(result)
res.status = falcon.HTTP_200
开发者ID:jgrassler,项目名称:monasca-api,代码行数:12,代码来源:metrics.py
示例11: on_get
def on_get(self, req, res, alarm_definition_id=None):
if alarm_definition_id is None:
helpers.validate_authorization(req, self._default_authorized_roles)
tenant_id = helpers.get_tenant_id(req)
name = helpers.get_query_name(req)
dimensions = helpers.get_query_dimensions(req)
severity = helpers.get_query_param(req, "severity", default_val=None)
if severity is not None:
validation.validate_severity_query(severity)
sort_by = helpers.get_query_param(req, 'sort_by', default_val=None)
if sort_by is not None:
if isinstance(sort_by, basestring):
sort_by = sort_by.split(',')
allowed_sort_by = {'id', 'name', 'severity',
'updated_at', 'created_at'}
validation.validate_sort_by(sort_by, allowed_sort_by)
offset = helpers.get_query_param(req, 'offset')
if offset is not None and not isinstance(offset, int):
try:
offset = int(offset)
except Exception:
raise HTTPUnprocessableEntityError('Unprocessable Entity',
'Offset value {} must be an integer'.format(offset))
limit = helpers.get_limit(req)
result = self._alarm_definition_list(tenant_id, name, dimensions, severity,
req.uri, sort_by, 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)
result = self._alarm_definition_show(tenant_id,
alarm_definition_id)
helpers.add_links_to_resource(result,
re.sub('/' + alarm_definition_id, '',
req.uri))
res.body = helpers.dumpit_utf8(result)
res.status = falcon.HTTP_200
开发者ID:bigluster,项目名称:monasca-api,代码行数:46,代码来源:alarm_definitions.py
示例12: test_dimension_multi_value
def test_dimension_multi_value(self):
req = Mock()
req.query_string = ("foo=bar&dimensions=Dimension_multi_value:one|two|three")
result = helpers.get_query_dimensions(req)
self.assertEqual(result, {"Dimension_multi_value": "one|two|three"})
开发者ID:Missxiaoguo,项目名称:monasca-api,代码行数:6,代码来源:test_query_helpers.py
示例13: test_empty_dimension
def test_empty_dimension(self):
req = Mock()
req.query_string = ("foo=bar&dimensions=")
result = helpers.get_query_dimensions(req)
self.assertEqual(result, {})
开发者ID:jgrassler,项目名称:monasca-api,代码行数:6,代码来源:test_query_helpers.py
注:本文中的monasca_api.v2.reference.helpers.get_query_dimensions函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论