diff --git a/.gitignore b/.gitignore index ef30da4d..2f81771c 100644 --- a/.gitignore +++ b/.gitignore @@ -114,3 +114,5 @@ venv.bak/ examples/debug bdd/ .version + +scripts/gen-apis.sh diff --git a/.travis.yml b/.travis.yml index 8bd1a95d..6f13dd71 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,7 @@ install: pip install -e .[ci] script: - make lint - make test-cov + - make release-check after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/Makefile b/Makefile index 208a5f28..85b2d163 100644 --- a/Makefile +++ b/Makefile @@ -78,16 +78,14 @@ clean-test: rm -f .coverage rm -fr htmlcov/ -gen: - ucloud-model sdk apis \ - --lang python3 \ - --type=public \ - --template ${UCLOUD_TEMPLATE_PATH}/scripts-api.tpl \ - --output ./scripts/gen-services.sh - ucloud-model sdk tests \ - --lang python3 \ - --template ${UCLOUD_TEMPLATE_PATH}/scripts-test.tpl \ - --output ./scripts/gen-tests.sh - version: @python -c 'from ucloud.version import version; print(version)' + +codegen: + @bash ./scripts/codegen.sh + +release-check: + @python scripts/release.py --dry-run + +release: + @python scripts/release.py diff --git a/docs/services.rst b/docs/services.rst index 74c0b81c..59d8fb53 100644 --- a/docs/services.rst +++ b/docs/services.rst @@ -73,8 +73,3 @@ USMS .. autoclass:: ucloud.services.usms.client.USMSClient :members: -VPC ---- - -.. autoclass:: ucloud.services.vpc.client.VPCClient - :members: diff --git a/scripts/codegen.sh b/scripts/codegen.sh new file mode 100644 index 00000000..5f5a0cfa --- /dev/null +++ b/scripts/codegen.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +#set -u +set -e + +if [ -n "$PRODUCT" ]; then + ucloud-model sync --lang python --product "$PRODUCT" + ucloud-model sdk apis --type public --product "$PRODUCT" --lang python --template "$U_MODEL_HOME"/providers/python/templates/scripts-api.tpl --output scripts/gen-apis.sh + bash ./scripts/gen-apis.sh +fi + +if [ -n "$TEST" ]; then + IFS=',' read -ra TL <<< "$TEST" + for i in "${TL[@]}"; do + ucloud-model sdk test --name "$i" --lang python --template "$U_MODEL_HOME"/providers/python/templates/testing.tpl --output tests/test_services/test_set_"$i".py + done +fi diff --git a/scripts/gen-services.sh b/scripts/gen-services.sh deleted file mode 100644 index 8fc62008..00000000 --- a/scripts/gen-services.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -# Code is generated by ucloud-model, DO NOT EDIT IT. - -ucloud-model sdk apis --lang python3 --type public --in-db --template ../ucloud-api-model-v2/apisdk/lang/python/templates/clients.tpl --output ./ucloud/client.py -ucloud-model sdk apis --lang python3 --type public --in-db --template ../ucloud-api-model-v2/apisdk/lang/python/templates/docs.tpl --output ./docs/services.rst - - -mkdir -p ./ucloud/services/ucdn/schemas -touch ./ucloud/services/ucdn/__init__.py -touch ./ucloud/services/ucdn/schemas/__init__.py -ucloud-model sdk apis --lang python3 --product UCDN --type public --template ../ucloud-api-model-v2/apisdk/lang/python/templates/schema.tpl --output ./ucloud/services/ucdn/schemas/apis.py -ucloud-model sdk apis --lang python3 --product UCDN --type public --template ../ucloud-api-model-v2/apisdk/lang/python/templates/model.tpl --output ./ucloud/services/ucdn/schemas/models.py -ucloud-model sdk apis --lang python3 --product UCDN --type public --template ../ucloud-api-model-v2/apisdk/lang/python/templates/client.tpl --output ./ucloud/services/ucdn/client.py -black ucloud/services/ucdn -python -m ucloud.services.ucdn.client diff --git a/scripts/gen-tests.sh b/scripts/gen-tests.sh deleted file mode 100644 index 79f947b7..00000000 --- a/scripts/gen-tests.sh +++ /dev/null @@ -1,253 +0,0 @@ -#!/usr/bin/env bash - -# Code is generated by ucloud-model, DO NOT EDIT IT. - - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_113.py \ - --name 113 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_179.py \ - --name 179 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_181.py \ - --name 181 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_207.py \ - --name 207 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_227.py \ - --name 227 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_230.py \ - --name 230 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_242.py \ - --name 242 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_245.py \ - --name 245 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_255.py \ - --name 255 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_268.py \ - --name 268 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_279.py \ - --name 279 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_283.py \ - --name 283 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_286.py \ - --name 286 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_289.py \ - --name 289 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_293.py \ - --name 293 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_302.py \ - --name 302 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_330.py \ - --name 330 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_333.py \ - --name 333 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_448.py \ - --name 448 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_449.py \ - --name 449 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_471.py \ - --name 471 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_488.py \ - --name 488 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_489.py \ - --name 489 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_490.py \ - --name 490 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_491.py \ - --name 491 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_499.py \ - --name 499 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_503.py \ - --name 503 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_687.py \ - --name 687 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_867.py \ - --name 867 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_1073.py \ - --name 1073 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_1201.py \ - --name 1201 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_1202.py \ - --name 1202 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_1203.py \ - --name 1203 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_2117.py \ - --name 2117 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_2174.py \ - --name 2174 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_2377.py \ - --name 2377 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_2457.py \ - --name 2457 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_2935.py \ - --name 2935 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_3278.py \ - --name 3278 - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_3279.py \ - --name 3279 - - -ucloud-model sdk test \ - --lang python3 \ - --template ../ucloud-api-model-v2/apisdk/lang/python/templates/testing.tpl \ - --output tests/test_services/test_set_4079.py \ - --name 4079 - -black tests/test_services/* diff --git a/scripts/release.py b/scripts/release.py new file mode 100644 index 00000000..84855a96 --- /dev/null +++ b/scripts/release.py @@ -0,0 +1,161 @@ +import logging +import subprocess +import copy +from datetime import datetime + +import ucloud.version + + +logger = logging.getLogger(__name__) + + +def shell(cmd): + print(cmd) + p = subprocess.check_output(cmd) + return p.decode().strip() + + +class Bumper: + def __init__(self, version): + self.version = version + versioned = version.split('.') + if len(versioned) != 3: + raise ValueError('invalid version {}'.format(version)) + + major, minor, patch = versioned + self.major = int(major) + self.minor = int(minor) + self.patch = int(patch) + + def bump_major(self): + clone = copy.deepcopy(self) + clone.major += 1 + clone.minor = 0 + clone.patch = 0 + return clone + + def bump_minor(self): + clone = copy.deepcopy(self) + clone.minor += 1 + clone.patch = 0 + return clone + + def bump_patch(self): + clone = copy.deepcopy(self) + clone.patch += 1 + return clone + + +class StepWriteChangelog: + classifier_tokens = ['FEATURES', 'ENHANCEMENTS', 'BUG FIXES'] + + def __init__(self, changelog_file='CHANGELOG.md', is_prerelease=True, is_dry_run=True): + self.state = '' + self.logs = {} + self.changelog_file = changelog_file + self.is_prerelease = is_prerelease + self.is_dry_run = is_dry_run + + @staticmethod + def get_git_logs(): + version = shell('git describe --tags --abbrev=0') + commit_sha = shell('git show-ref -s {}'.format(version)) + return shell('git log --format=%B {}..HEAD'.format(commit_sha)) + + def get_change_logs(self): + logs = {} + for line in self.get_git_logs().split('\n'): + line = line.strip() + if not line: + continue + + if line.strip(':') in self.classifier_tokens: + self.state = line + logs.setdefault(line, []) + continue + + if line.startswith('- ') and self.state: + logs[self.state].append(line) + else: + logger.warning('ignore changelog: {}'.format(line)) + + return logs + + def write_changelog(self, logs): + buffer_lines = [] + should_bump = None + + # render change logs + for i, token in enumerate(self.classifier_tokens): + items = logs.get(token) + if not items: + continue + + buffer_lines.append(token) + for item in items: + buffer_lines.append('- ' + item) + + if should_bump is None: + should_bump = i + + if should_bump is None: + raise ValueError('no content should be release') + + # auto increase version number + bumper = Bumper(ucloud.version.version) + if should_bump == 0: + if not self.is_prerelease: + bumper = bumper.bump_major() + else: + bumper = bumper.bump_minor() + elif should_bump == 1: + bumper = bumper.bump_minor() + else: + bumper = bumper.bump_patch() + + if not self.is_dry_run: + # insert change logs at the begin of changelog file + with open('CHANGELOG.md', 'rw') as f: + content = f.read() + f.write('\n\n'.join([ + '## {} ({})'.format(bumper.version, datetime.now().date().isoformat()), + '\n'.join(buffer_lines), + content, + ])) + + return bumper.version + + def write_version(self, version): + version_code = 'version = "{}"'.format(version) + if self.is_dry_run: + print(version_code) + return + + with open('./ucloud/version.py', 'w') as f: + f.write(version_code) + + +def main(): + import argparse + + parser = argparse.ArgumentParser(description='Process some integers.') + parser.add_argument('--changelog-file', default='CHANGELOG.md', + help='the file path of changelog file') + parser.add_argument('--production', default=False, action='store_true', help='is prerelease') + parser.add_argument('--dry-run', default=False, action='store_true', help='is dry run') + + args = parser.parse_args() + print(args) + + step1 = StepWriteChangelog( + changelog_file=args.changelog_file, + is_dry_run=args.dry_run, + is_prerelease=not args.production, + ) + logs = step1.get_change_logs() + version = step1.write_changelog(logs) + step1.write_version(version) + + +if __name__ == '__main__': + main() diff --git a/tests/test_services/test_set_4140.py b/tests/test_services/test_set_4140.py index f59a74ae..0afd8e3e 100644 --- a/tests/test_services/test_set_4140.py +++ b/tests/test_services/test_set_4140.py @@ -207,7 +207,7 @@ def get_new_ucdn_domain_hit_rate_06(client: utest.Client, variables: dict): } try: - resp = client.invoke("GetNewUcdnDomainHitRate", d) + resp = client.ucdn().get_new_ucdn_domain_hit_rate(d) except exc.RetCodeException as e: resp = e.json() @@ -351,7 +351,7 @@ def get_new_ucdn_domain_bandwidth_12(client: utest.Client, variables: dict): d = {"Type": variables.get("time_granule_type")} try: - resp = client.invoke("GetNewUcdnDomainBandwidth", d) + resp = client.ucdn().get_new_ucdn_domain_bandwidth(d) except exc.RetCodeException as e: resp = e.json() @@ -373,7 +373,7 @@ def get_ucdn_pass_bandwidth_13(client: utest.Client, variables: dict): d = {"Type": variables.get("time_granule_type")} try: - resp = client.invoke("GetUcdnPassBandwidth", d) + resp = client.ucdn().get_ucdn_pass_bandwidth(d) except exc.RetCodeException as e: resp = e.json() @@ -400,7 +400,7 @@ def get_ucdn_domain_request_num_v2_14(client: utest.Client, variables: dict): } try: - resp = client.invoke("GetUcdnDomainRequestNumV2", d) + resp = client.ucdn().get_ucdn_domain_request_num_v2(d) except exc.RetCodeException as e: resp = e.json() diff --git a/ucloud/_compat.py b/ucloud/_compat.py new file mode 100644 index 00000000..62fed4c1 --- /dev/null +++ b/ucloud/_compat.py @@ -0,0 +1,21 @@ +from ucloud.core import client + + +class CompactClient(client.Client): + def __init__(self, config: dict, transport=None, middleware=None): + self._config = config + super(CompactClient, self).__init__(config, transport, middleware) + + def pathx(self): + from ucloud.services.pathx.client import PathXClient + + return PathXClient( + self._config, self.transport, self.middleware, self.logger + ) + + def vpc(self): + from ucloud.services.vpc.client import VPCClient + + return VPCClient( + self._config, self.transport, self.middleware, self.logger + ) diff --git a/ucloud/client.py b/ucloud/client.py index b3696c4c..1126a980 100644 --- a/ucloud/client.py +++ b/ucloud/client.py @@ -1,20 +1,13 @@ """ Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core import client +from ucloud._compat import CompactClient -class Client(client.Client): +class Client(CompactClient): def __init__(self, config: dict, transport=None, middleware=None): self._config = config super(Client, self).__init__(config, transport, middleware) - def pathx(self): - from ucloud.services.pathx.client import PathXClient - - return PathXClient( - self._config, self.transport, self.middleware, self.logger - ) - def stepflow(self): from ucloud.services.stepflow.client import StepFlowClient @@ -98,10 +91,3 @@ def usms(self): return USMSClient( self._config, self.transport, self.middleware, self.logger ) - - def vpc(self): - from ucloud.services.vpc.client import VPCClient - - return VPCClient( - self._config, self.transport, self.middleware, self.logger - ) diff --git a/ucloud/services/ucdn/client.py b/ucloud/services/ucdn/client.py index 0c932463..9e135267 100644 --- a/ucloud/services/ucdn/client.py +++ b/ucloud/services/ucdn/client.py @@ -184,179 +184,75 @@ def describe_new_ucdn_refresh_cache_task( resp = self.invoke("DescribeNewUcdnRefreshCacheTask", d, **kwargs) return apis.DescribeNewUcdnRefreshCacheTaskResponseSchema().loads(resp) - def describe_prefetch_cache_task( + def get_new_ucdn_domain_bandwidth( self, req: typing.Optional[dict] = None, **kwargs ) -> dict: - """ DescribePrefetchCacheTask - 获取域名预取任务状态 + """ GetNewUcdnDomainBandwidth - 获取域名带宽数据 **Request** - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **DomainId** (str) - (Required) 域名ID,创建加速域名时生成。 - - **BeginTime** (int) - 查询的起始时间,格式为Unix Timestamp。如果有EndTime,BeginTime必须赋值。 + - **Type** (int) - (Required) 时间粒度(0表示按照5分钟粒度,1表示按照1小时粒度,2表示按照一天的粒度) + - **Areacode** (str) - 查询带宽区域 cn代表国内 abroad代表海外 不填默认为全部区域 + - **BeginTime** (int) - 查询的起始时间,格式为Unix Timestamp。如果有EndTime,BeginTime必须赋值。如没有赋值,则返回缺少参 数错误,如果没有EndTime,BeginTime也可以不赋值,EndTime默认当前时间,BeginTime 默认前一天的当前时间。 + - **DomainId** (list) - 域名id,创建域名时生成的id。默认全部域名 - **EndTime** (int) - 查询的结束时间,格式为Unix Timestamp。EndTime默认为当前时间,BeginTime默认为当前时间前一天时间。 - - **Limit** (int) - 返回数据的长度,默认20。 - - **Offset** (int) - 数据偏移量,默认为0 - - **Status** (str) - 需要获取的内容刷新的状态,枚举值:success:成功;wait:等待处理;process:正在处理;failure:失败; unknow:未知,默认选择所有状态 - - **TaskId** (str) - 提交任务时返回的任务ID **Response** - - **TaskSet** (list) - 见 **PrefetchCacheTaskSet** 模型定义 - - **TotalCount** (int) - 预取任务的总条数 + - **BandwidthList** (list) - 见 **BandwidthInfo** 模型定义 + - **Traffic** (str) - 从起始时间到结束时间内的所使用的CDN总流量,单位GB **Response Model** - **PrefetchCacheTaskSet** + **BandwidthInfo** - - **CheckTime** (int) - 任务状态查询时间,成功后不再查询。格式为Unix Timestamp - - **CreateTime** (int) - 预取任务创建的时间。格式为Unix Timestamp - - **Domain** (str) - 预取域名 - - **ErrorCode** (int) - 预取任务失败时返回,0未知原因,请联系技术支持 1源站无法连接 2源站禁止访问 3源站文件不存在 4源站返回 错误的请求 5源站服务器错误 6文件格式不支持 7源站网络不稳定 8任务重复 9文件路径包含特殊字符 - - **Percent** (int) - 预取任务执行的百分比。1代表1%,100代表100%。(大文件下载、点播不支持展示精确进度,只有成功或失败) - - **Status** (str) - 预取任务的当前状态,枚举值:success:成功;wait:等待处理;process:正在处理;failure:失败; unknow:未知 - - **TaskId** (str) - 任务ID,提交预取任务时返回。 - - **UrlLists** (list) - 预取提交的多条URL + - **CdnBandwidth** (str) - 返回值返回指定时间区间内CDN的带宽峰值,单位Mbps(如果请求参数Type为0,则Value是五分钟粒度的带宽值,如果Type为1,则Value是1小时的带宽峰值,如果Type为2,则Value是一天内的带宽峰值) + - **Time** (int) - 带宽获取的时间点。格式:时间戳 """ # build request d = {"ProjectId": self.config.project_id} req and d.update(req) - d = apis.DescribePrefetchCacheTaskRequestSchema().dumps(d) + d = apis.GetNewUcdnDomainBandwidthRequestSchema().dumps(d) - resp = self.invoke("DescribePrefetchCacheTask", d, **kwargs) - return apis.DescribePrefetchCacheTaskResponseSchema().loads(resp) + resp = self.invoke("GetNewUcdnDomainBandwidth", d, **kwargs) + return apis.GetNewUcdnDomainBandwidthResponseSchema().loads(resp) - def describe_refresh_cache_task( + def get_new_ucdn_domain_hit_rate( self, req: typing.Optional[dict] = None, **kwargs ) -> dict: - """ DescribeRefreshCacheTask - 获取域名刷新任务状态 + """ GetNewUcdnDomainHitRate - 获取域名命中率 **Request** - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **DomainId** (str) - (Required) 域名ID,创建加速域名时生成。 - - **BeginTime** (int) - 查询的起始时间,格式为Unix Timestamp。如果有EndTime,BeginTime必须赋值。 + - **Type** (int) - (Required) 时间粒度(0表示按照5分钟粒度,1表示按照1小时粒度,2表示按照一天的粒度) + - **Areacode** (str) - 查询带宽区域 cn代表国内 abroad代表海外,只支持国内 + - **BeginTime** (int) - 查询的起始时间,格式为Unix Timestamp。如果有EndTime,BeginTime必须赋值。如没有赋值,则返回缺少参 数错误,如果没有EndTime,BeginTime也可以不赋值,EndTime默认当前时间,BeginTime 默认前一天的当前时间。 + - **DomainId** (list) - 域名id,创建域名时生成的id。默认全部域名 - **EndTime** (int) - 查询的结束时间,格式为Unix Timestamp。EndTime默认为当前时间,BeginTime默认为当前时间前一天时间。 - - **Limit** (int) - 返回数据的长度,默认20。 - - **Offset** (int) - 数据偏移量,默认为0 - - **Status** (str) - 需要获取的内容刷新的状态,枚举值:success:成功;wait:等待处理;process:正在处理;failure:失败; unknow:未知,默认选择所有状态 - - **TaskId** (str) - 提交任务时返回的任务ID - - **Response** - - - **TaskSet** (list) - 见 **RefreshCacheTaskSet** 模型定义 - - **TotalCount** (int) - 刷新任务的总条数 - - **Response Model** - - **RefreshCacheTaskSet** - - - **CheckTime** (str) - 任务状态查询时间,成功后不再查询。格式为Unix Timestamp - - **CreateTime** (int) - 刷新任务创建的时间。格式为Unix Timestamp - - **Domain** (str) - 刷新域名 - - **Percent** (int) - 刷新任务执行的百分比。1代表1%,100代表100% - - **Status** (str) - 刷新任务的当前状态,枚举值:success:成功;wait:等待处理;process:正在处理;failure:失败; unknow:未知 - - **TaskId** (str) - 提交任务时返回的任务ID - - **UrlLists** (list) - 刷新提交的多条URL - - """ - # build request - d = {"ProjectId": self.config.project_id} - req and d.update(req) - d = apis.DescribeRefreshCacheTaskRequestSchema().dumps(d) - - resp = self.invoke("DescribeRefreshCacheTask", d, **kwargs) - return apis.DescribeRefreshCacheTaskResponseSchema().loads(resp) - - def describe_ucdn_domain( - self, req: typing.Optional[dict] = None, **kwargs - ) -> dict: - """ DescribeUcdnDomain - 获取加速域名详细信息 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **DomainId** (list) - 域名ID,创建加速域名时生成。默认获取账户下所有域名。 - - **Limit** (str) - 返回数据的长度,默认20。 - - **Offset** (int) - 返回数据的偏移量,默认0。 **Response** - - **ChargeType** (str) - 表示当前的计费方式,traffic代表按流量包计费,bandwidth按带宽付费 - - **DomainSet** (list) - 见 **UcdnDomainSet** 模型定义 - - **TotalCount** (int) - 满足条件的条目数 + - **HitRateList** (list) - 见 **HitRateInfo** 模型定义 **Response Model** - **UcdnDomainCacheConfSet** - - - **CacheBehavior** (bool) - 是否缓存(true为缓存,false为不缓存) - - **CacheTTL** (int) - 缓存时间 - - **CacheUnit** (str) - 缓存时间的单位。sec(秒),min(分钟),hour(小时),day(天) - - **Description** (str) - 描述 - - **PathPattern** (str) - 路径模式 - - **UcdnDomainSet** + **HitRateInfo** - - **Areacode** (list) - CDN加速区域,cn:国内;abroad:国外。[ cn, abroad]表示两者皆启用 - - **CacheConf** (list) - 见 **UcdnDomainCacheConfSet** 模型定义 - - **CdnType** (str) - 加速域名的业务类型,枚举值:web:网站;Stream:视频;download:下载; - - **ChargeType** (str) - 计费方式,枚举值为:traffic:按流量包计费; - - **Cname** (str) - cdn域名,创建加速域名时生成的cdn域名,用于设置CNAME记录 - - **CreateTime** (int) - 域名创建的时间。格式为Unix Timestamp - - **Domain** (str) - 域名,用户创建加速的域名 - - **DomainId** (str) - 加速域名ID,创建加速域名时生成 - - **SourceIp** (list) - 源站IP,即cdn服务器回源访问的IP地址。多个IP地址可以表述为:[1.1.1.1, 2.2.2.2] - - **Status** (str) - 加速域名的当前状态:check:审核中;checkSuccess:审核通过;checkFaile:审核失败; enable(ing):(正在)开启加速;disable(ing):(正在)停止加速;delete(ing):(正在)删除加速 - - **TestUrl** (str) - 测试URL,用于测试加速域名的可用性 - - **VaildTime** (int) - 开始分配Cname时间。格式为Unix Timestamp + - **FlowHitRate** (float) - 流量命中率,单位% + - **RequestHitRate** (float) - 请求数命中率,单位% + - **Time** (int) - 带宽获取的时间点。格式:时间戳 """ # build request d = {"ProjectId": self.config.project_id} req and d.update(req) - return self.invoke("DescribeUcdnDomain", d, **kwargs) - - def describe_ucdn_live_access( - self, req: typing.Optional[dict] = None, **kwargs - ) -> dict: - """ DescribeUcdnLiveAccess - 获取直播加速 + d = apis.GetNewUcdnDomainHitRateRequestSchema().dumps(d) - **Request** - - - **DomainId** (str) - 创建直播加速生成的Id,默认获取帐号下所有直播加速 - - **Response** - - - **ChargeType** (str) - 表示当前的计费方式,traffic代表按流量包计费 bandwidth按带宽付费 - - **DomainSet** (list) - 见 **UcdnLiveAccessDomainSet** 模型定义 - - **LastChargeType** (str) - 表示最后一次切换的计费方式,traffic代表按流 量包计费,bandwidth按带宽付费 - - **TotalCount** (int) - 满足条件的直播加速个数 - - **Response Model** - - **UcdnLiveAccessDomainSet** - - - **AccessPoint** (str) - 接入点 - - **CreateTime** (int) - 创建时间,格式:时间戳 - - **DomainId** (str) - 域名Id,创建直播加速生成的Id - - **HlsPlayCname** (str) - Hls播放CDN域名,客户CNAME到该域名播放hls流 - - **HlsPlayDomain** (str) - hls播放域名 - - **PublishCname** (str) - 推流CDN域名,客户推流域名需要CNAME到该域名 - - **PublishDomain** (str) - 推流域名 - - **RtmpPlayCname** (str) - Rtmp播放CDN域名,客户CNAME到该域名播放rtmp流 - - **RtmpPlayDomain** (str) - rtmp播放域名 - - **Status** (str) - 状态。checking:配置中;enabled:加速中; failed:失败;deleting:删除中; disabling:禁用中;disabled:禁用。 - - """ - # build request - d = {} - req and d.update(req) - d = apis.DescribeUcdnLiveAccessRequestSchema().dumps(d) - - resp = self.invoke("DescribeUcdnLiveAccess", d, **kwargs) - return apis.DescribeUcdnLiveAccessResponseSchema().loads(resp) + resp = self.invoke("GetNewUcdnDomainHitRate", d, **kwargs) + return apis.GetNewUcdnDomainHitRateResponseSchema().loads(resp) def get_new_ucdn_domain_http_code( self, req: typing.Optional[dict] = None, **kwargs @@ -485,41 +381,40 @@ def get_new_ucdn_domain_http_code_v2( resp = self.invoke("GetNewUcdnDomainHttpCodeV2", d, **kwargs) return apis.GetNewUcdnDomainHttpCodeV2ResponseSchema().loads(resp) - def get_ucdn_domain_bandwidth( + def get_new_ucdn_domain_request_num( self, req: typing.Optional[dict] = None, **kwargs ) -> dict: - """ GetUcdnDomainBandwidth - 获取加速域名带宽使用信息 + """ GetNewUcdnDomainRequestNum - 获取域名请求数 **Request** - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Areacode** (str) - CDN加速区域,查询带宽区域 cn代表国内 abroad代表海外 默认全部区域 + - **Type** (int) - (Required) 时间粒度(0表示按照5分钟粒度,1表示按照1小时粒度,2表示按照一天的粒度) + - **Areacode** (str) - 查询区域 cn代表国内 abroad代表海外,只支持国内 - **BeginTime** (int) - 查询的起始时间,格式为Unix Timestamp。如果有EndTime,BeginTime必须赋值。如没有赋值,则返回缺少参 数错误,如果没有EndTime,BeginTime也可以不赋值,EndTime默认当前时间,BeginTime 默认前一天的当前时间。 - - **DomainId** (list) - 域名ID,创建域名时生成的id。默认全部域名 + - **DomainId** (list) - 域名id,创建域名时生成的id。默认全部域名 - **EndTime** (int) - 查询的结束时间,格式为Unix Timestamp。EndTime默认为当前时间,BeginTime默认为当前时间前一天时间。 - - **Type** (int) - 时间粒度(0表示按照5分钟粒度,1表示按照1小时粒度,2表示按照一天的粒度) **Response** - - **BandWidthSet** (list) - 见 **CDNBandwidthSet** 模型定义 - - **Traffic** (float) - 从起始时间到结束时间内所使用的总流量,单位GB + - **RequestList** (list) - 见 **RequestInfo** 模型定义 **Response Model** - **CDNBandwidthSet** + **RequestInfo** - - **Time** (int) - 带宽获取的时间点,格式为Unix Timestamp - - **TopFluxTime** (int) - 峰值时间点,只有请求1小时粒度和1天粒度的时候返回 - - **Value** (float) - 返回值返回指定时间区间内的带宽峰值(如果请求参数Type为0, 则Value是五分钟粒度的带宽峰值,如果Type为1,则Value是1 小时的带宽峰值,如果Type为2,则Value是一天内的带宽峰值) + - **CdnRequest** (float) - 返回值返回指定时间区间内的cdn收到的请求次数之和 + - **OriginRequest** (float) - 返回值返回指定时间区间内的cdn回源的请求次数之和 + - **Time** (int) - 带宽获取的时间点。格式:时间戳 """ # build request d = {"ProjectId": self.config.project_id} req and d.update(req) - d = apis.GetUcdnDomainBandwidthRequestSchema().dumps(d) + d = apis.GetNewUcdnDomainRequestNumRequestSchema().dumps(d) - resp = self.invoke("GetUcdnDomainBandwidth", d, **kwargs) - return apis.GetUcdnDomainBandwidthResponseSchema().loads(resp) + resp = self.invoke("GetNewUcdnDomainRequestNum", d, **kwargs) + return apis.GetNewUcdnDomainRequestNumResponseSchema().loads(resp) def get_ucdn_domain_log( self, req: typing.Optional[dict] = None, **kwargs @@ -583,6 +478,41 @@ def get_ucdn_domain_prefetch_enable( resp = self.invoke("GetUcdnDomainPrefetchEnable", d, **kwargs) return apis.GetUcdnDomainPrefetchEnableResponseSchema().loads(resp) + def get_ucdn_domain_request_num_v2( + self, req: typing.Optional[dict] = None, **kwargs + ) -> dict: + """ GetUcdnDomainRequestNumV2 - 获取域名请求数 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **BeginTime** (int) - (Required) 查询的起始时间,格式为Unix Timestamp + - **EndTime** (int) - (Required) 查询的结束时间,格式为Unix Timestamp + - **Type** (int) - (Required) 时间粒度(0表示按照5分钟粒度,1表示按照1小时粒度,2表示按照一天的粒度, 3=按1分钟) + - **Areacode** (str) - 查询区域 cn代表国内 abroad代表海外,只支持国内 + - **DomainId** (list) - 域名id,创建域名时生成的id。默认全部域名 + + **Response** + + - **RequestList** (list) - 见 **RequestInfo** 模型定义 + + **Response Model** + + **RequestInfo** + + - **CdnRequest** (float) - 返回值返回指定时间区间内的cdn收到的请求次数之和 + - **OriginRequest** (float) - 返回值返回指定时间区间内的cdn回源的请求次数之和 + - **Time** (int) - 带宽获取的时间点。格式:时间戳 + + """ + # build request + d = {"ProjectId": self.config.project_id} + req and d.update(req) + d = apis.GetUcdnDomainRequestNumV2RequestSchema().dumps(d) + + resp = self.invoke("GetUcdnDomainRequestNumV2", d, **kwargs) + return apis.GetUcdnDomainRequestNumV2ResponseSchema().loads(resp) + def get_ucdn_domain_traffic( self, req: typing.Optional[dict] = None, **kwargs ) -> dict: @@ -616,40 +546,39 @@ def get_ucdn_domain_traffic( resp = self.invoke("GetUcdnDomainTraffic", d, **kwargs) return apis.GetUcdnDomainTrafficResponseSchema().loads(resp) - def get_ucdn_live_access_bandwidth( + def get_ucdn_pass_bandwidth( self, req: typing.Optional[dict] = None, **kwargs ) -> dict: - """ GetUcdnLiveAccessBandwidth - 获取直播加速带宽 + """ GetUcdnPassBandwidth - 获取回源带宽数据(cdn回客户源站部分) **Request** - - **DomainId** (list) - (Required) 域名ID,创建加速域名时生成。 - - **Type** (int) - (Required) 流量查询粒度,0:5分钟;1:1小时;2:1天 - - **BeginTime** (int) - 查询流量的起始时间,格式:时间戳 - - **EndTime** (int) - 查询流量的结束时间,格式:时间戳 - - **Protocol** (str) - 播放协议,rtmp/hls,不传则获取带宽总和 + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Type** (int) - (Required) 时间粒度(0表示按照5分钟粒度,1表示按照1小时粒度,2表示按照一天的粒度) + - **Areacode** (str) - 查询带宽区域 cn代表国内 abroad代表海外,只支持国内 + - **BeginTime** (int) - 查询的起始时间,格式为Unix Timestamp。如果有EndTime,BeginTime必须赋值。如没有赋值,则返回缺少参 数错误,如果没有EndTime,BeginTime也可以不赋值,EndTime默认当前时间,BeginTime 默认前一天的当前时间。 + - **DomainId** (list) - 域名id,创建域名时生成的id。默认全部域名 + - **EndTime** (int) - 查询的结束时间,格式为Unix Timestamp。EndTime默认为当前时间,BeginTime默认为当前时间前一天时间。 **Response** - - **BandwidthSet** (list) - 见 **UcdnLiveAccessBandwidthSet** 模型定义 - - **Traffic** (float) - 从起始时间到结束时间内所使用的总流量,单位GB + - **BandwidthDetail** (list) - 见 **BandwidthInfoDetail** 模型定义 **Response Model** - **UcdnLiveAccessBandwidthSet** + **BandwidthInfoDetail** - - **Time** (int) - 带宽获取的时间点。格式:时间戳 - - **TopFluxTime** (int) - 峰值时间点,只有请求1小时粒度和1天粒度的时候返回 - - **Value** (float) - 返回值返回指定时间区间内的带宽峰值(如果请求参数Type为0,则Value是五分 钟粒度的带宽峰值,如果Type为1,则Value是1小时的带宽峰值,如果Type为2, 则Value是一天内的带宽峰值) + - **Bandwidth** (float) - 返回值带宽值数据。 + - **Time** (int) - 宽获取的时间点。格式:时间戳 """ # build request - d = {} + d = {"ProjectId": self.config.project_id} req and d.update(req) - d = apis.GetUcdnLiveAccessBandwidthRequestSchema().dumps(d) + d = apis.GetUcdnPassBandwidthRequestSchema().dumps(d) - resp = self.invoke("GetUcdnLiveAccessBandwidth", d, **kwargs) - return apis.GetUcdnLiveAccessBandwidthResponseSchema().loads(resp) + resp = self.invoke("GetUcdnPassBandwidth", d, **kwargs) + return apis.GetUcdnPassBandwidthResponseSchema().loads(resp) def get_ucdn_traffic( self, req: typing.Optional[dict] = None, **kwargs @@ -682,30 +611,6 @@ def get_ucdn_traffic( resp = self.invoke("GetUcdnTraffic", d, **kwargs) return apis.GetUcdnTrafficResponseSchema().loads(resp) - def prefetch_domain_cache( - self, req: typing.Optional[dict] = None, **kwargs - ) -> dict: - """ PrefetchDomainCache - 预取文件 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **DomainId** (str) - (Required) 域名ID,创建加速域名时生成。 - - **UrlList** (list) - (Required) 要预取的多个url列表。一次最多提交10个,必须以“http://要预取的域名/”开始的全路径,格式即为(http://要预取的域名/”开始的全路径,格式即为): http://abc.ucloud.cn/a/img.png,提交错误url可能预取不成功。 - - **Response** - - - **TaskId** (str) - 本次提交的url对应的任务id,可用于任务状态查询 - - """ - # build request - d = {"ProjectId": self.config.project_id} - req and d.update(req) - d = apis.PrefetchDomainCacheRequestSchema().dumps(d) - - resp = self.invoke("PrefetchDomainCache", d, **kwargs) - return apis.PrefetchDomainCacheResponseSchema().loads(resp) - def prefetch_new_ucdn_domain_cache( self, req: typing.Optional[dict] = None, **kwargs ) -> dict: @@ -753,31 +658,6 @@ def refresh_new_ucdn_domain_cache( resp = self.invoke("RefreshNewUcdnDomainCache", d, **kwargs) return apis.RefreshNewUcdnDomainCacheResponseSchema().loads(resp) - def refresh_ucdn_domain_cache( - self, req: typing.Optional[dict] = None, **kwargs - ) -> dict: - """ RefreshUcdnDomainCache - 刷新加速缓存 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **DomainId** (str) - (Required) 域名ID,创建加速域名时生成。 - - **Type** (str) - (Required) 刷新类型,file代表文件刷新,dir代表路径刷新 - - **UrlList** (list) - (Required) 刷新多个URL列表时,一次最多提交30个。必须以" `http://域名/"开始。目录要以"/"结尾 `_ , 如刷新目录a下所有文件,格式为:http://abc.ucloud.cn/a/;如刷新文件目录a下面所有img.png文件, 格式为http://abc.ucloud.cn/a/img.png。请正确提交需要刷新的域名 - - **Response** - - - **TaskId** (str) - 本次提交的url对应的任务id,可用于任务状态查询 - - """ - # build request - d = {"ProjectId": self.config.project_id} - req and d.update(req) - d = apis.RefreshUcdnDomainCacheRequestSchema().dumps(d) - - resp = self.invoke("RefreshUcdnDomainCache", d, **kwargs) - return apis.RefreshUcdnDomainCacheResponseSchema().loads(resp) - def switch_ucdn_charge_type( self, req: typing.Optional[dict] = None, **kwargs ) -> dict: @@ -799,61 +679,3 @@ def switch_ucdn_charge_type( resp = self.invoke("SwitchUcdnChargeType", d, **kwargs) return apis.SwitchUcdnChargeTypeResponseSchema().loads(resp) - - def update_ucdn_domain( - self, req: typing.Optional[dict] = None, **kwargs - ) -> dict: - """ UpdateUcdnDomain - 更新加速域名配置 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **DomainId** (str) - (Required) 域名ID,创建加速域名时生成。 - - **CacheConf** (list) - 见 **UpdateUcdnDomainParamCacheConf** 模型定义 - - **SourceIp** (list) - 源站IP,即cdn服务器回源访问的IP地址。支持多个源站IP。多个源站IP可以表述为 :SourceIps.0=1.1.1.1,SourceIps.1=2.2.2.2 - - **TestUrl** (str) - 测试url,用于域名创建加速时的测试。 - - **Response** - - - **Request Model** - - **UpdateUcdnDomainParamCacheConf** - - - **CacheBehavior** (int) - 缓存配置 - 是否缓存(1为缓存,0为不缓存) - - **CacheTTL** (int) - 缓存配置 - 缓存时间 - - **CacheUnit** (str) - 缓存配置 - 缓存时间的单位。sec(秒),min(分钟),hour(小时),day(天) - - **Description** (str) - 缓存配置 - 缓存规则描述 - - **PathPattern** (str) - 缓存配置 - 路径模式 - - """ - # build request - d = {"ProjectId": self.config.project_id} - req and d.update(req) - d = apis.UpdateUcdnDomainRequestSchema().dumps(d) - - resp = self.invoke("UpdateUcdnDomain", d, **kwargs) - return apis.UpdateUcdnDomainResponseSchema().loads(resp) - - def update_ucdn_domain_status( - self, req: typing.Optional[dict] = None, **kwargs - ) -> dict: - """ UpdateUcdnDomainStatus - 更新加速域名状态 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **DomainId** (str) - (Required) 域名ID,创建加速域名时生成。 - - **Status** (str) - (Required) 域名状态,enable代表加速中,disable代表停止加速,delete代表删除。 - - **Response** - - - """ - # build request - d = {"ProjectId": self.config.project_id} - req and d.update(req) - d = apis.UpdateUcdnDomainStatusRequestSchema().dumps(d) - - resp = self.invoke("UpdateUcdnDomainStatus", d, **kwargs) - return apis.UpdateUcdnDomainStatusResponseSchema().loads(resp) diff --git a/ucloud/services/ucdn/schemas/apis.py b/ucloud/services/ucdn/schemas/apis.py index 26f2a753..5be59d6e 100644 --- a/ucloud/services/ucdn/schemas/apis.py +++ b/ucloud/services/ucdn/schemas/apis.py @@ -118,140 +118,69 @@ class DescribeNewUcdnRefreshCacheTaskResponseSchema(schema.ResponseSchema): """ -API: DescribePrefetchCacheTask +API: GetNewUcdnDomainBandwidth -获取域名预取任务状态 +获取域名带宽数据 """ -class DescribePrefetchCacheTaskRequestSchema(schema.RequestSchema): - """ DescribePrefetchCacheTask - 获取域名预取任务状态 +class GetNewUcdnDomainBandwidthRequestSchema(schema.RequestSchema): + """ GetNewUcdnDomainBandwidth - 获取域名带宽数据 """ fields = { + "Areacode": fields.Str(required=False, dump_to="Areacode"), "BeginTime": fields.Int(required=False, dump_to="BeginTime"), - "DomainId": fields.Str(required=True, dump_to="DomainId"), + "DomainId": fields.List(fields.Str()), "EndTime": fields.Int(required=False, dump_to="EndTime"), - "Limit": fields.Int(required=False, dump_to="Limit"), - "Offset": fields.Int(required=False, dump_to="Offset"), "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Status": fields.Str(required=False, dump_to="Status"), - "TaskId": fields.Str(required=False, dump_to="TaskId"), + "Type": fields.Int(required=True, dump_to="Type"), } -class DescribePrefetchCacheTaskResponseSchema(schema.ResponseSchema): - """ DescribePrefetchCacheTask - 获取域名预取任务状态 +class GetNewUcdnDomainBandwidthResponseSchema(schema.ResponseSchema): + """ GetNewUcdnDomainBandwidth - 获取域名带宽数据 """ fields = { - "TaskSet": fields.List( - models.PrefetchCacheTaskSetSchema(), + "BandwidthList": fields.List( + models.BandwidthInfoSchema(), required=False, - load_from="TaskSet", + load_from="BandwidthList", ), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), + "Traffic": fields.Str(required=False, load_from="Traffic"), } """ -API: DescribeRefreshCacheTask +API: GetNewUcdnDomainHitRate -获取域名刷新任务状态 +获取域名命中率 """ -class DescribeRefreshCacheTaskRequestSchema(schema.RequestSchema): - """ DescribeRefreshCacheTask - 获取域名刷新任务状态 +class GetNewUcdnDomainHitRateRequestSchema(schema.RequestSchema): + """ GetNewUcdnDomainHitRate - 获取域名命中率 """ fields = { + "Areacode": fields.Str(required=False, dump_to="Areacode"), "BeginTime": fields.Int(required=False, dump_to="BeginTime"), - "DomainId": fields.Str(required=True, dump_to="DomainId"), - "EndTime": fields.Int(required=False, dump_to="EndTime"), - "Limit": fields.Int(required=False, dump_to="Limit"), - "Offset": fields.Int(required=False, dump_to="Offset"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Status": fields.Str(required=False, dump_to="Status"), - "TaskId": fields.Str(required=False, dump_to="TaskId"), - } - - -class DescribeRefreshCacheTaskResponseSchema(schema.ResponseSchema): - """ DescribeRefreshCacheTask - 获取域名刷新任务状态 - """ - - fields = { - "TaskSet": fields.List( - models.RefreshCacheTaskSetSchema(), - required=False, - load_from="TaskSet", - ), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - } - - -""" -API: DescribeUcdnDomain - -获取加速域名详细信息 -""" - - -class DescribeUcdnDomainRequestSchema(schema.RequestSchema): - """ DescribeUcdnDomain - 获取加速域名详细信息 - """ - - fields = { "DomainId": fields.List(fields.Str()), - "Limit": fields.Str(required=False, dump_to="Limit"), - "Offset": fields.Int(required=False, dump_to="Offset"), + "EndTime": fields.Int(required=False, dump_to="EndTime"), "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Type": fields.Int(required=True, dump_to="Type"), } -class DescribeUcdnDomainResponseSchema(schema.ResponseSchema): - """ DescribeUcdnDomain - 获取加速域名详细信息 - """ - - fields = { - "ChargeType": fields.Str(required=False, load_from="ChargeType"), - "DomainSet": fields.List( - models.UcdnDomainSetSchema(), required=False, load_from="DomainSet" - ), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - } - - -""" -API: DescribeUcdnLiveAccess - -获取直播加速 -""" - - -class DescribeUcdnLiveAccessRequestSchema(schema.RequestSchema): - """ DescribeUcdnLiveAccess - 获取直播加速 - """ - - fields = {"DomainId": fields.Str(required=False, dump_to="DomainId")} - - -class DescribeUcdnLiveAccessResponseSchema(schema.ResponseSchema): - """ DescribeUcdnLiveAccess - 获取直播加速 +class GetNewUcdnDomainHitRateResponseSchema(schema.ResponseSchema): + """ GetNewUcdnDomainHitRate - 获取域名命中率 """ fields = { - "ChargeType": fields.Str(required=False, load_from="ChargeType"), - "DomainSet": fields.List( - models.UcdnLiveAccessDomainSetSchema(), - required=False, - load_from="DomainSet", - ), - "LastChargeType": fields.Str( - required=False, load_from="LastChargeType" - ), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), + "HitRateList": fields.List( + models.HitRateInfoSchema(), required=False, load_from="HitRateList" + ) } @@ -324,14 +253,14 @@ class GetNewUcdnDomainHttpCodeV2ResponseSchema(schema.ResponseSchema): """ -API: GetUcdnDomainBandwidth +API: GetNewUcdnDomainRequestNum -获取加速域名带宽使用信息 +获取域名请求数 """ -class GetUcdnDomainBandwidthRequestSchema(schema.RequestSchema): - """ GetUcdnDomainBandwidth - 获取加速域名带宽使用信息 +class GetNewUcdnDomainRequestNumRequestSchema(schema.RequestSchema): + """ GetNewUcdnDomainRequestNum - 获取域名请求数 """ fields = { @@ -340,21 +269,18 @@ class GetUcdnDomainBandwidthRequestSchema(schema.RequestSchema): "DomainId": fields.List(fields.Str()), "EndTime": fields.Int(required=False, dump_to="EndTime"), "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Type": fields.Int(required=False, dump_to="Type"), + "Type": fields.Int(required=True, dump_to="Type"), } -class GetUcdnDomainBandwidthResponseSchema(schema.ResponseSchema): - """ GetUcdnDomainBandwidth - 获取加速域名带宽使用信息 +class GetNewUcdnDomainRequestNumResponseSchema(schema.ResponseSchema): + """ GetNewUcdnDomainRequestNum - 获取域名请求数 """ fields = { - "BandWidthSet": fields.List( - models.CDNBandwidthSetSchema(), - required=False, - load_from="BandWidthSet", - ), - "Traffic": fields.Float(required=False, load_from="Traffic"), + "RequestList": fields.List( + models.RequestInfoSchema(), required=False, load_from="RequestList" + ) } @@ -413,6 +339,38 @@ class GetUcdnDomainPrefetchEnableResponseSchema(schema.ResponseSchema): fields = {"Enable": fields.Int(required=False, load_from="Enable")} +""" +API: GetUcdnDomainRequestNumV2 + +获取域名请求数 +""" + + +class GetUcdnDomainRequestNumV2RequestSchema(schema.RequestSchema): + """ GetUcdnDomainRequestNumV2 - 获取域名请求数 + """ + + fields = { + "Areacode": fields.Str(required=False, dump_to="Areacode"), + "BeginTime": fields.Int(required=True, dump_to="BeginTime"), + "DomainId": fields.List(fields.Str()), + "EndTime": fields.Int(required=True, dump_to="EndTime"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Type": fields.Int(required=True, dump_to="Type"), + } + + +class GetUcdnDomainRequestNumV2ResponseSchema(schema.ResponseSchema): + """ GetUcdnDomainRequestNumV2 - 获取域名请求数 + """ + + fields = { + "RequestList": fields.List( + models.RequestInfoSchema(), required=False, load_from="RequestList" + ) + } + + """ API: GetUcdnDomainTraffic @@ -447,36 +405,36 @@ class GetUcdnDomainTrafficResponseSchema(schema.ResponseSchema): """ -API: GetUcdnLiveAccessBandwidth +API: GetUcdnPassBandwidth -获取直播加速带宽 +获取回源带宽数据(cdn回客户源站部分) """ -class GetUcdnLiveAccessBandwidthRequestSchema(schema.RequestSchema): - """ GetUcdnLiveAccessBandwidth - 获取直播加速带宽 +class GetUcdnPassBandwidthRequestSchema(schema.RequestSchema): + """ GetUcdnPassBandwidth - 获取回源带宽数据(cdn回客户源站部分) """ fields = { + "Areacode": fields.Str(required=False, dump_to="Areacode"), "BeginTime": fields.Int(required=False, dump_to="BeginTime"), "DomainId": fields.List(fields.Str()), "EndTime": fields.Int(required=False, dump_to="EndTime"), - "Protocol": fields.Str(required=False, dump_to="Protocol"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), "Type": fields.Int(required=True, dump_to="Type"), } -class GetUcdnLiveAccessBandwidthResponseSchema(schema.ResponseSchema): - """ GetUcdnLiveAccessBandwidth - 获取直播加速带宽 +class GetUcdnPassBandwidthResponseSchema(schema.ResponseSchema): + """ GetUcdnPassBandwidth - 获取回源带宽数据(cdn回客户源站部分) """ fields = { - "BandwidthSet": fields.List( - models.UcdnLiveAccessBandwidthSetSchema(), + "BandwidthDetail": fields.List( + models.BandwidthInfoDetailSchema(), required=False, - load_from="BandwidthSet", - ), - "Traffic": fields.Float(required=False, load_from="Traffic"), + load_from="BandwidthDetail", + ) } @@ -505,31 +463,6 @@ class GetUcdnTrafficResponseSchema(schema.ResponseSchema): } -""" -API: PrefetchDomainCache - -预取文件 -""" - - -class PrefetchDomainCacheRequestSchema(schema.RequestSchema): - """ PrefetchDomainCache - 预取文件 - """ - - fields = { - "DomainId": fields.Str(required=True, dump_to="DomainId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "UrlList": fields.List(fields.Str()), - } - - -class PrefetchDomainCacheResponseSchema(schema.ResponseSchema): - """ PrefetchDomainCache - 预取文件 - """ - - fields = {"TaskId": fields.Str(required=False, load_from="TaskId")} - - """ API: PrefetchNewUcdnDomainCache @@ -579,32 +512,6 @@ class RefreshNewUcdnDomainCacheResponseSchema(schema.ResponseSchema): fields = {"TaskId": fields.Str(required=False, load_from="TaskId")} -""" -API: RefreshUcdnDomainCache - -刷新加速缓存 -""" - - -class RefreshUcdnDomainCacheRequestSchema(schema.RequestSchema): - """ RefreshUcdnDomainCache - 刷新加速缓存 - """ - - fields = { - "DomainId": fields.Str(required=True, dump_to="DomainId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Type": fields.Str(required=True, dump_to="Type"), - "UrlList": fields.List(fields.Str()), - } - - -class RefreshUcdnDomainCacheResponseSchema(schema.ResponseSchema): - """ RefreshUcdnDomainCache - 刷新加速缓存 - """ - - fields = {"TaskId": fields.Str(required=False, load_from="TaskId")} - - """ API: SwitchUcdnChargeType @@ -627,68 +534,3 @@ class SwitchUcdnChargeTypeResponseSchema(schema.ResponseSchema): """ fields = {} - - -""" -API: UpdateUcdnDomain - -更新加速域名配置 -""" - - -class UpdateUcdnDomainParamCacheConfSchema(schema.RequestSchema): - """ UpdateUcdnDomainParamCacheConf - - """ - - fields = { - "CacheBehavior": fields.Int(required=False, dump_to="CacheBehavior"), - "CacheTTL": fields.Int(required=False, dump_to="CacheTTL"), - "CacheUnit": fields.Str(required=False, dump_to="CacheUnit"), - "Description": fields.Str(required=False, dump_to="Description"), - "PathPattern": fields.Str(required=False, dump_to="PathPattern"), - } - - -class UpdateUcdnDomainRequestSchema(schema.RequestSchema): - """ UpdateUcdnDomain - 更新加速域名配置 - """ - - fields = { - "CacheConf": fields.List(UpdateUcdnDomainParamCacheConfSchema()), - "DomainId": fields.Str(required=True, dump_to="DomainId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "SourceIp": fields.List(fields.Str()), - "TestUrl": fields.Str(required=False, dump_to="TestUrl"), - } - - -class UpdateUcdnDomainResponseSchema(schema.ResponseSchema): - """ UpdateUcdnDomain - 更新加速域名配置 - """ - - fields = {} - - -""" -API: UpdateUcdnDomainStatus - -更新加速域名状态 -""" - - -class UpdateUcdnDomainStatusRequestSchema(schema.RequestSchema): - """ UpdateUcdnDomainStatus - 更新加速域名状态 - """ - - fields = { - "DomainId": fields.Str(required=True, dump_to="DomainId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Status": fields.Str(required=True, dump_to="Status"), - } - - -class UpdateUcdnDomainStatusResponseSchema(schema.ResponseSchema): - """ UpdateUcdnDomainStatus - 更新加速域名状态 - """ - - fields = {} diff --git a/ucloud/services/ucdn/schemas/models.py b/ucloud/services/ucdn/schemas/models.py index 76688ee8..6ab893a1 100644 --- a/ucloud/services/ucdn/schemas/models.py +++ b/ucloud/services/ucdn/schemas/models.py @@ -3,15 +3,6 @@ from ucloud.core.typesystem import schema, fields -class AccessConfSchema(schema.ResponseSchema): - """ AccessConf - 访问控制 - """ - - fields = { - "IpBlacklist": fields.Str(required=False, load_from="IpBlacklist") - } - - class CacheConfSchema(schema.ResponseSchema): """ CacheConf - 缓存配置 """ @@ -34,6 +25,15 @@ class CacheConfSchema(schema.ResponseSchema): } +class AccessConfSchema(schema.ResponseSchema): + """ AccessConf - 访问控制 + """ + + fields = { + "IpBlacklist": fields.Str(required=False, load_from="IpBlacklist") + } + + class DomainInfoSchema(schema.ResponseSchema): """ DomainInfo - 域名配置 """ @@ -97,87 +97,26 @@ class TaskInfoSchema(schema.ResponseSchema): } -class PrefetchCacheTaskSetSchema(schema.ResponseSchema): - """ PrefetchCacheTaskSet - DescribePrefetchCacheTask - """ - - fields = { - "CheckTime": fields.Int(required=False, load_from="CheckTime"), - "CreateTime": fields.Int(required=False, load_from="CreateTime"), - "Domain": fields.Str(required=False, load_from="Domain"), - "ErrorCode": fields.Int(required=False, load_from="ErrorCode"), - "Percent": fields.Int(required=False, load_from="Percent"), - "Status": fields.Str(required=False, load_from="Status"), - "TaskId": fields.Str(required=False, load_from="TaskId"), - "UrlLists": fields.List(fields.Str()), - } - - -class RefreshCacheTaskSetSchema(schema.ResponseSchema): - """ RefreshCacheTaskSet - DescribeRefreshCacheTask - """ - - fields = { - "CheckTime": fields.Str(required=False, load_from="CheckTime"), - "CreateTime": fields.Int(required=False, load_from="CreateTime"), - "Domain": fields.Str(required=False, load_from="Domain"), - "Percent": fields.Int(required=False, load_from="Percent"), - "Status": fields.Str(required=False, load_from="Status"), - "TaskId": fields.Str(required=False, load_from="TaskId"), - "UrlLists": fields.List(fields.Str()), - } - - -class UcdnDomainCacheConfSetSchema(schema.ResponseSchema): - """ UcdnDomainCacheConfSet - DescribeUcdnDomain - """ - - fields = { - "CacheBehavior": fields.Bool(required=False, load_from="CacheBehavior"), - "CacheTTL": fields.Int(required=False, load_from="CacheTTL"), - "CacheUnit": fields.Str(required=False, load_from="CacheUnit"), - "Description": fields.Str(required=False, load_from="Description"), - "PathPattern": fields.Str(required=False, load_from="PathPattern"), - } - - -class UcdnDomainSetSchema(schema.ResponseSchema): - """ UcdnDomainSet - DescribeUcdnDomain +class BandwidthInfoSchema(schema.ResponseSchema): + """ BandwidthInfo - BandwidthInfo """ fields = { - "Areacode": fields.List(fields.Str()), - "CacheConf": fields.List(UcdnDomainCacheConfSetSchema()), - "CdnType": fields.Str(required=False, load_from="CdnType"), - "ChargeType": fields.Str(required=False, load_from="ChargeType"), - "Cname": fields.Str(required=False, load_from="Cname"), - "CreateTime": fields.Int(required=False, load_from="CreateTime"), - "Domain": fields.Str(required=False, load_from="Domain"), - "DomainId": fields.Str(required=False, load_from="DomainId"), - "SourceIp": fields.List(fields.Str()), - "Status": fields.Str(required=False, load_from="Status"), - "TestUrl": fields.Str(required=False, load_from="TestUrl"), - "VaildTime": fields.Int(required=False, load_from="VaildTime"), + "CdnBandwidth": fields.Str(required=False, load_from="CdnBandwidth"), + "Time": fields.Int(required=False, load_from="Time"), } -class UcdnLiveAccessDomainSetSchema(schema.ResponseSchema): - """ UcdnLiveAccessDomainSet - DescribeUcdnLiveAccess +class HitRateInfoSchema(schema.ResponseSchema): + """ HitRateInfo - HitRateInfo """ fields = { - "AccessPoint": fields.Str(required=False, load_from="AccessPoint"), - "CreateTime": fields.Int(required=False, load_from="CreateTime"), - "DomainId": fields.Str(required=False, load_from="DomainId"), - "HlsPlayCname": fields.Str(required=False, load_from="HlsPlayCname"), - "HlsPlayDomain": fields.Str(required=False, load_from="HlsPlayDomain"), - "PublishCname": fields.Str(required=False, load_from="PublishCname"), - "PublishDomain": fields.Str(required=False, load_from="PublishDomain"), - "RtmpPlayCname": fields.Str(required=False, load_from="RtmpPlayCname"), - "RtmpPlayDomain": fields.Str( - required=False, load_from="RtmpPlayDomain" + "FlowHitRate": fields.Float(required=False, load_from="FlowHitRate"), + "RequestHitRate": fields.Float( + required=False, load_from="RequestHitRate" ), - "Status": fields.Str(required=False, load_from="Status"), + "Time": fields.Int(required=False, load_from="Time"), } @@ -260,14 +199,16 @@ class HttpCodeV2DetailSchema(schema.ResponseSchema): } -class CDNBandwidthSetSchema(schema.ResponseSchema): - """ CDNBandwidthSet - GetUcdnDomainBandwidth +class RequestInfoSchema(schema.ResponseSchema): + """ RequestInfo - RequestInfo """ fields = { + "CdnRequest": fields.Float(required=False, load_from="CdnRequest"), + "OriginRequest": fields.Float( + required=False, load_from="OriginRequest" + ), "Time": fields.Int(required=False, load_from="Time"), - "TopFluxTime": fields.Int(required=False, load_from="TopFluxTime"), - "Value": fields.Float(required=False, load_from="Value"), } @@ -302,14 +243,13 @@ class UcdnDomainTrafficSetSchema(schema.ResponseSchema): } -class UcdnLiveAccessBandwidthSetSchema(schema.ResponseSchema): - """ UcdnLiveAccessBandwidthSet - GetUcdnLiveAccessBandwidth +class BandwidthInfoDetailSchema(schema.ResponseSchema): + """ BandwidthInfoDetail - 带宽值信息模型(时间-带宽) """ fields = { - "Time": fields.Int(required=False, load_from="Time"), - "TopFluxTime": fields.Int(required=False, load_from="TopFluxTime"), - "Value": fields.Float(required=False, load_from="Value"), + "Bandwidth": fields.Float(required=True, load_from="Bandwidth"), + "Time": fields.Int(required=True, load_from="Time"), }