322 lines
15 KiB
Python
322 lines
15 KiB
Python
|
# 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 CdnAsyncClient(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(CdnAsyncClient, self).__init__()
|
|||
|
self.model_package = importlib.import_module("huaweicloudsdkcdn.v2.model")
|
|||
|
self.preset_headers = {'User-Agent': 'HuaweiCloud-SDK-Python'}
|
|||
|
|
|||
|
@classmethod
|
|||
|
def new_builder(cls, clazz=None):
|
|||
|
if clazz is None:
|
|||
|
return ClientBuilder(cls, "GlobalCredentials")
|
|||
|
|
|||
|
if clazz.__name__ != "CdnClient":
|
|||
|
raise TypeError("client type error, support client type is CdnClient")
|
|||
|
|
|||
|
return ClientBuilder(clazz, "GlobalCredentials")
|
|||
|
|
|||
|
def show_domain_location_stats_async(self, request):
|
|||
|
"""查询域名统计区域运营商数据
|
|||
|
|
|||
|
- 支持查询90天内的数据。 - 支持多指标同时查询,不超过5个。 - 最多同时指定20个域名。 - 起始时间和结束时间需要同时指定,左闭右开,毫秒级时间戳,必须为5分钟整时刻点,如:0分、5分、10分、15分等,如果传的不是5分钟时刻点,返回数据可能与预期不一致。统一用开始时间表示一个时间段,如:2019-01-24 20:15:00 表示取 [20:15:00, 20:20:00)的统计数据,且左闭右开。 - action取值:location_detail,location_summary
|
|||
|
|
|||
|
:param ShowDomainLocationStatsRequest request
|
|||
|
:return: ShowDomainLocationStatsResponse
|
|||
|
"""
|
|||
|
return self.show_domain_location_stats_with_http_info(request)
|
|||
|
|
|||
|
def show_domain_location_stats_with_http_info(self, request):
|
|||
|
"""查询域名统计区域运营商数据
|
|||
|
|
|||
|
- 支持查询90天内的数据。 - 支持多指标同时查询,不超过5个。 - 最多同时指定20个域名。 - 起始时间和结束时间需要同时指定,左闭右开,毫秒级时间戳,必须为5分钟整时刻点,如:0分、5分、10分、15分等,如果传的不是5分钟时刻点,返回数据可能与预期不一致。统一用开始时间表示一个时间段,如:2019-01-24 20:15:00 表示取 [20:15:00, 20:20:00)的统计数据,且左闭右开。 - action取值:location_detail,location_summary
|
|||
|
|
|||
|
:param ShowDomainLocationStatsRequest request
|
|||
|
:return: ShowDomainLocationStatsResponse
|
|||
|
"""
|
|||
|
|
|||
|
all_params = ['action', 'start_time', 'end_time', 'domain_name', 'stat_type', 'interval', 'country', 'province', 'isp', 'group_by', 'enterprise_project_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 'action' in local_var_params:
|
|||
|
query_params.append(('action', local_var_params['action']))
|
|||
|
if 'start_time' in local_var_params:
|
|||
|
query_params.append(('start_time', local_var_params['start_time']))
|
|||
|
if 'end_time' in local_var_params:
|
|||
|
query_params.append(('end_time', local_var_params['end_time']))
|
|||
|
if 'domain_name' in local_var_params:
|
|||
|
query_params.append(('domain_name', local_var_params['domain_name']))
|
|||
|
if 'stat_type' in local_var_params:
|
|||
|
query_params.append(('stat_type', local_var_params['stat_type']))
|
|||
|
if 'interval' in local_var_params:
|
|||
|
query_params.append(('interval', local_var_params['interval']))
|
|||
|
if 'country' in local_var_params:
|
|||
|
query_params.append(('country', local_var_params['country']))
|
|||
|
if 'province' in local_var_params:
|
|||
|
query_params.append(('province', local_var_params['province']))
|
|||
|
if 'isp' in local_var_params:
|
|||
|
query_params.append(('isp', local_var_params['isp']))
|
|||
|
if 'group_by' in local_var_params:
|
|||
|
query_params.append(('group_by', local_var_params['group_by']))
|
|||
|
if 'enterprise_project_id' in local_var_params:
|
|||
|
query_params.append(('enterprise_project_id', local_var_params['enterprise_project_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.0/cdn/statistics/domain-location-stats',
|
|||
|
method='GET',
|
|||
|
path_params=path_params,
|
|||
|
query_params=query_params,
|
|||
|
header_params=header_params,
|
|||
|
body=body_params,
|
|||
|
post_params=form_params,
|
|||
|
response_type='ShowDomainLocationStatsResponse',
|
|||
|
response_headers=response_headers,
|
|||
|
auth_settings=auth_settings,
|
|||
|
collection_formats=collection_formats,
|
|||
|
request_type=request.__class__.__name__)
|
|||
|
|
|||
|
|
|||
|
def show_domain_stats_async(self, request):
|
|||
|
"""查询域名统计基础数据
|
|||
|
|
|||
|
- 支持查询90天内的数据。 - 支持多指标同时查询,不超过5个。 - 最多同时指定20个域名。 - 起始时间和结束时间需要同时指定,左闭右开,毫秒级时间戳,必须为5分钟整时刻点,如:0分、5分、10分、15分等,如果传的不是5分钟时刻点,返回数据可能与预期不一致。统一用开始时间表示一个时间段,如:2019-01-24 20:15:00 表示取 [20:15:00, 20:20:00)的统计数据,且左闭右开。 - action取值:detail,summary
|
|||
|
|
|||
|
:param ShowDomainStatsRequest request
|
|||
|
:return: ShowDomainStatsResponse
|
|||
|
"""
|
|||
|
return self.show_domain_stats_with_http_info(request)
|
|||
|
|
|||
|
def show_domain_stats_with_http_info(self, request):
|
|||
|
"""查询域名统计基础数据
|
|||
|
|
|||
|
- 支持查询90天内的数据。 - 支持多指标同时查询,不超过5个。 - 最多同时指定20个域名。 - 起始时间和结束时间需要同时指定,左闭右开,毫秒级时间戳,必须为5分钟整时刻点,如:0分、5分、10分、15分等,如果传的不是5分钟时刻点,返回数据可能与预期不一致。统一用开始时间表示一个时间段,如:2019-01-24 20:15:00 表示取 [20:15:00, 20:20:00)的统计数据,且左闭右开。 - action取值:detail,summary
|
|||
|
|
|||
|
:param ShowDomainStatsRequest request
|
|||
|
:return: ShowDomainStatsResponse
|
|||
|
"""
|
|||
|
|
|||
|
all_params = ['action', 'start_time', 'end_time', 'domain_name', 'stat_type', 'interval', 'group_by', 'service_area', 'enterprise_project_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 'action' in local_var_params:
|
|||
|
query_params.append(('action', local_var_params['action']))
|
|||
|
if 'start_time' in local_var_params:
|
|||
|
query_params.append(('start_time', local_var_params['start_time']))
|
|||
|
if 'end_time' in local_var_params:
|
|||
|
query_params.append(('end_time', local_var_params['end_time']))
|
|||
|
if 'domain_name' in local_var_params:
|
|||
|
query_params.append(('domain_name', local_var_params['domain_name']))
|
|||
|
if 'stat_type' in local_var_params:
|
|||
|
query_params.append(('stat_type', local_var_params['stat_type']))
|
|||
|
if 'interval' in local_var_params:
|
|||
|
query_params.append(('interval', local_var_params['interval']))
|
|||
|
if 'group_by' in local_var_params:
|
|||
|
query_params.append(('group_by', local_var_params['group_by']))
|
|||
|
if 'service_area' in local_var_params:
|
|||
|
query_params.append(('service_area', local_var_params['service_area']))
|
|||
|
if 'enterprise_project_id' in local_var_params:
|
|||
|
query_params.append(('enterprise_project_id', local_var_params['enterprise_project_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.0/cdn/statistics/domain-stats',
|
|||
|
method='GET',
|
|||
|
path_params=path_params,
|
|||
|
query_params=query_params,
|
|||
|
header_params=header_params,
|
|||
|
body=body_params,
|
|||
|
post_params=form_params,
|
|||
|
response_type='ShowDomainStatsResponse',
|
|||
|
response_headers=response_headers,
|
|||
|
auth_settings=auth_settings,
|
|||
|
collection_formats=collection_formats,
|
|||
|
request_type=request.__class__.__name__)
|
|||
|
|
|||
|
|
|||
|
def show_top_url_async(self, request):
|
|||
|
"""查询TOP100 URL明细
|
|||
|
|
|||
|
- 查询TOP100 URL明细。 - 支持查询90天内的数据。 - 查询跨度不能超过31天。 - 起始时间和结束时间,左闭右开,需要同时指定。如查询2021-10-24 00:00:00 到 2021-10-25 00:00:00 的数据,表示取 [2021-10-24 00:00:00, 2021-10-25 00:00:00)的统计数据。 - 开始时间、结束时间必须传毫秒级时间戳,且必须为凌晨0点整时刻点,如果传的不是凌晨0点整时刻点,返回数据可能与预期不一致。 - 流量类指标单位统一为Byte(字节)、请求数类指标单位统一为次数。用于查询指定域名、指定统计指标的明细数据。
|
|||
|
|
|||
|
:param ShowTopUrlRequest request
|
|||
|
:return: ShowTopUrlResponse
|
|||
|
"""
|
|||
|
return self.show_top_url_with_http_info(request)
|
|||
|
|
|||
|
def show_top_url_with_http_info(self, request):
|
|||
|
"""查询TOP100 URL明细
|
|||
|
|
|||
|
- 查询TOP100 URL明细。 - 支持查询90天内的数据。 - 查询跨度不能超过31天。 - 起始时间和结束时间,左闭右开,需要同时指定。如查询2021-10-24 00:00:00 到 2021-10-25 00:00:00 的数据,表示取 [2021-10-24 00:00:00, 2021-10-25 00:00:00)的统计数据。 - 开始时间、结束时间必须传毫秒级时间戳,且必须为凌晨0点整时刻点,如果传的不是凌晨0点整时刻点,返回数据可能与预期不一致。 - 流量类指标单位统一为Byte(字节)、请求数类指标单位统一为次数。用于查询指定域名、指定统计指标的明细数据。
|
|||
|
|
|||
|
:param ShowTopUrlRequest request
|
|||
|
:return: ShowTopUrlResponse
|
|||
|
"""
|
|||
|
|
|||
|
all_params = ['start_time', 'end_time', 'domain_name', 'stat_type', 'service_area', 'enterprise_project_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 'start_time' in local_var_params:
|
|||
|
query_params.append(('start_time', local_var_params['start_time']))
|
|||
|
if 'end_time' in local_var_params:
|
|||
|
query_params.append(('end_time', local_var_params['end_time']))
|
|||
|
if 'domain_name' in local_var_params:
|
|||
|
query_params.append(('domain_name', local_var_params['domain_name']))
|
|||
|
if 'stat_type' in local_var_params:
|
|||
|
query_params.append(('stat_type', local_var_params['stat_type']))
|
|||
|
if 'service_area' in local_var_params:
|
|||
|
query_params.append(('service_area', local_var_params['service_area']))
|
|||
|
if 'enterprise_project_id' in local_var_params:
|
|||
|
query_params.append(('enterprise_project_id', local_var_params['enterprise_project_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.0/cdn/statistics/top-url',
|
|||
|
method='GET',
|
|||
|
path_params=path_params,
|
|||
|
query_params=query_params,
|
|||
|
header_params=header_params,
|
|||
|
body=body_params,
|
|||
|
post_params=form_params,
|
|||
|
response_type='ShowTopUrlResponse',
|
|||
|
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,
|
|||
|
async_request=True)
|