huaweicloud-sdk-python-v3/huaweicloud-sdk-aom/huaweicloudsdkaom/v2/aom_client.py

724 lines
22 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# coding: utf-8
from __future__ import absolute_import
import datetime
import re
import importlib
import six
from huaweicloudsdkcore.client import Client, ClientBuilder
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkcore.utils import http_utils
from huaweicloudsdkcore.sdk_stream_request import SdkStreamRequest
class AomClient(Client):
"""
:param configuration: .Configuration object for this client
:param pool_threads: The number of threads to use for async requests
to the API. More threads means more concurrent API requests.
"""
PRIMITIVE_TYPES = (float, bool, bytes, six.text_type) + six.integer_types
NATIVE_TYPES_MAPPING = {
'int': int,
'long': int if six.PY3 else long,
'float': float,
'str': str,
'bool': bool,
'date': datetime.date,
'datetime': datetime.datetime,
'object': object,
}
def __init__(self):
super(AomClient, self).__init__()
self.model_package = importlib.import_module("huaweicloudsdkaom.v2.model")
self.preset_headers = {'User-Agent': 'HuaweiCloud-SDK-Python'}
@classmethod
def new_builder(cls, clazz=None):
if clazz is None:
return ClientBuilder(cls)
if clazz.__name__ != "AomClient":
raise TypeError("client type error, support client type is AomClient")
return ClientBuilder(clazz)
def add_alarm_rule(self, request):
"""add_alarm_rule
该接口用于添加一条阈值规则
:param AddAlarmRuleRequest request
:return: AddAlarmRuleResponse
"""
return self.add_alarm_rule_with_http_info(request)
def add_alarm_rule_with_http_info(self, request):
"""add_alarm_rule
该接口用于添加一条阈值规则
:param AddAlarmRuleRequest request
:return: AddAlarmRuleResponse
"""
all_params = ['add_alarm_rule_body']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json'])
auth_settings = []
return self.call_api(
resource_path='/v2/{project_id}/alarm-rules',
method='POST',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='AddAlarmRuleResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def add_metric_data(self, request):
"""添加监控数据
该接口用于向服务端添加一条或多条监控数据。
:param AddMetricDataRequest request
:return: AddMetricDataResponse
"""
return self.add_metric_data_with_http_info(request)
def add_metric_data_with_http_info(self, request):
"""添加监控数据
该接口用于向服务端添加一条或多条监控数据。
:param AddMetricDataRequest request
:return: AddMetricDataResponse
"""
all_params = ['metric_data_param']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json'])
auth_settings = []
return self.call_api(
resource_path='/v1/{project_id}/ams/report/metricdata',
method='POST',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='AddMetricDataResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def delete_alarm_rule(self, request):
"""delete_alarm_rule
该接口用于删除阈值规则。
:param DeleteAlarmRuleRequest request
:return: DeleteAlarmRuleResponse
"""
return self.delete_alarm_rule_with_http_info(request)
def delete_alarm_rule_with_http_info(self, request):
"""delete_alarm_rule
该接口用于删除阈值规则。
:param DeleteAlarmRuleRequest request
:return: DeleteAlarmRuleResponse
"""
all_params = ['alarm_rule_id']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
if 'alarm_rule_id' in local_var_params:
path_params['alarm_rule_id'] = local_var_params['alarm_rule_id']
query_params = []
header_params = {}
form_params = {}
body_params = None
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json'])
auth_settings = []
return self.call_api(
resource_path='/v2/{project_id}/alarm-rules/{alarm_rule_id}',
method='DELETE',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='DeleteAlarmRuleResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def deleteservice_discovery_rules(self, request):
"""删除服务发现规则
该接口用于删除服务发现规则。
:param DeleteserviceDiscoveryRulesRequest request
:return: DeleteserviceDiscoveryRulesResponse
"""
return self.deleteservice_discovery_rules_with_http_info(request)
def deleteservice_discovery_rules_with_http_info(self, request):
"""删除服务发现规则
该接口用于删除服务发现规则。
:param DeleteserviceDiscoveryRulesRequest request
:return: DeleteserviceDiscoveryRulesResponse
"""
all_params = ['app_rules_ids']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
query_params = []
if 'app_rules_ids' in local_var_params:
query_params.append(('appRulesIds', local_var_params['app_rules_ids']))
collection_formats['appRulesIds'] = 'csv'
header_params = {}
form_params = {}
body_params = None
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json'])
auth_settings = []
return self.call_api(
resource_path='/v1/{project_id}/inv/servicediscoveryrules',
method='DELETE',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='DeleteserviceDiscoveryRulesResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def list_alarm_rule(self, request):
"""list_alarm_rule
该接口用于查询阈值规则列表。
:param ListAlarmRuleRequest request
:return: ListAlarmRuleResponse
"""
return self.list_alarm_rule_with_http_info(request)
def list_alarm_rule_with_http_info(self, request):
"""list_alarm_rule
该接口用于查询阈值规则列表。
:param ListAlarmRuleRequest request
:return: ListAlarmRuleResponse
"""
all_params = ['offset', 'limit']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
query_params = []
if 'offset' in local_var_params:
query_params.append(('offset', local_var_params['offset']))
if 'limit' in local_var_params:
query_params.append(('limit', local_var_params['limit']))
header_params = {}
form_params = {}
body_params = None
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json'])
auth_settings = []
return self.call_api(
resource_path='/v2/{project_id}/alarm-rules',
method='GET',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='ListAlarmRuleResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def list_sample(self, request):
"""查询时序数据
该接口用于查询指定时间范围内的监控时序数据,可以通过参数指定需要查询的数据维度,数据周期等。
:param ListSampleRequest request
:return: ListSampleResponse
"""
return self.list_sample_with_http_info(request)
def list_sample_with_http_info(self, request):
"""查询时序数据
该接口用于查询指定时间范围内的监控时序数据,可以通过参数指定需要查询的数据维度,数据周期等。
:param ListSampleRequest request
:return: ListSampleResponse
"""
all_params = ['list_sample_request_body', 'fill_value']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
query_params = []
if 'fill_value' in local_var_params:
query_params.append(('fill_value', local_var_params['fill_value']))
header_params = {}
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json'])
auth_settings = []
return self.call_api(
resource_path='/v2/{project_id}/samples',
method='POST',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='ListSampleResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def list_series(self, request):
"""查询时间序列
该接口用于查询系统当前可监控的时间序列列表可以指定时间序列命名空间、名称、维度、所属资源的编号格式为resType_resId分页查询的起始位置和返回的最大记录条数。
:param ListSeriesRequest request
:return: ListSeriesResponse
"""
return self.list_series_with_http_info(request)
def list_series_with_http_info(self, request):
"""查询时间序列
该接口用于查询系统当前可监控的时间序列列表可以指定时间序列命名空间、名称、维度、所属资源的编号格式为resType_resId分页查询的起始位置和返回的最大记录条数。
:param ListSeriesRequest request
:return: ListSeriesResponse
"""
all_params = ['list_series_request_body', 'limit', 'offset']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
query_params = []
if 'limit' in local_var_params:
query_params.append(('limit', local_var_params['limit']))
if 'offset' in local_var_params:
query_params.append(('offset', local_var_params['offset']))
header_params = {}
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json'])
auth_settings = []
return self.call_api(
resource_path='/v2/{project_id}/series',
method='POST',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='ListSeriesResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def list_service_discovery_rules(self, request):
"""查询系统中已有服务发现规则
该接口用于查询系统当前已存在的服务发现规则。
:param ListServiceDiscoveryRulesRequest request
:return: ListServiceDiscoveryRulesResponse
"""
return self.list_service_discovery_rules_with_http_info(request)
def list_service_discovery_rules_with_http_info(self, request):
"""查询系统中已有服务发现规则
该接口用于查询系统当前已存在的服务发现规则。
:param ListServiceDiscoveryRulesRequest request
:return: ListServiceDiscoveryRulesResponse
"""
all_params = ['id']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
query_params = []
if 'id' in local_var_params:
query_params.append(('id', local_var_params['id']))
header_params = {}
form_params = {}
body_params = None
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json'])
auth_settings = []
return self.call_api(
resource_path='/v1/{project_id}/inv/servicediscoveryrules',
method='GET',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='ListServiceDiscoveryRulesResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def show_alarm_rule(self, request):
"""show_alarm_rule
查询单条阈值规则
:param ShowAlarmRuleRequest request
:return: ShowAlarmRuleResponse
"""
return self.show_alarm_rule_with_http_info(request)
def show_alarm_rule_with_http_info(self, request):
"""show_alarm_rule
查询单条阈值规则
:param ShowAlarmRuleRequest request
:return: ShowAlarmRuleResponse
"""
all_params = ['alarm_rule_id']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
if 'alarm_rule_id' in local_var_params:
path_params['alarm_rule_id'] = local_var_params['alarm_rule_id']
query_params = []
header_params = {}
form_params = {}
body_params = None
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json'])
auth_settings = []
return self.call_api(
resource_path='/v2/{project_id}/alarm-rules/{alarm_rule_id}',
method='GET',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='ShowAlarmRuleResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def update_alarm_rule(self, request):
"""update_alarm_rule
修改阈值规则
:param UpdateAlarmRuleRequest request
:return: UpdateAlarmRuleResponse
"""
return self.update_alarm_rule_with_http_info(request)
def update_alarm_rule_with_http_info(self, request):
"""update_alarm_rule
修改阈值规则
:param UpdateAlarmRuleRequest request
:return: UpdateAlarmRuleResponse
"""
all_params = ['update_alarm_rule_body']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json'])
auth_settings = []
return self.call_api(
resource_path='/v2/{project_id}/alarm-rules',
method='PUT',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='UpdateAlarmRuleResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def call_api(self, resource_path, method, path_params=None, query_params=None, header_params=None, body=None,
post_params=None, response_type=None, response_headers=None, auth_settings=None,
collection_formats=None, request_type=None):
"""Makes the HTTP request and returns deserialized data.
:param resource_path: Path to method endpoint.
:param method: Method to call.
:param path_params: Path parameters in the url.
:param query_params: Query parameters in the url.
:param header_params: Header parameters to be placed in the request header.
:param body: Request body.
:param post_params dict: Request post form parameters,
for `application/x-www-form-urlencoded`, `multipart/form-data`.
:param auth_settings list: Auth Settings names for the request.
:param response_type: Response data type.
:param response_headers: Header should be added to response data.
:param collection_formats: dict of collection formats for path, query,
header, and post parameters.
:param request_type: Request data type.
:return:
Return the response directly.
"""
return self.do_http_request(
method=method,
resource_path=resource_path,
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body,
post_params=post_params,
response_type=response_type,
response_headers=response_headers,
collection_formats=collection_formats,
request_type=request_type)