From 71777ff3b2c75b82e383bafb5f7171ccd909b9f6 Mon Sep 17 00:00:00 2001 From: Yufei Li Date: Wed, 21 Aug 2019 19:17:15 +0800 Subject: [PATCH] Improve acceptance testing & fix bug when project id is empty (#7) FEATURE: - Add testing framework supported `scenario` and `step`, inspire by *ThoughtWorks, Guage* - Add parameters encoding for array on general invoking ENHANCEMENT: - Add test scenario and improve the testing framework - Improve continuous deployment workflow, integration on a private cluster - Add unit testing cases to improving line coverage at core modules BUGFIX: - Fix unexpected error when project id is empty --- .gitignore | 3 + .travis.yml | 37 +- Makefile | 24 +- README.md | 22 + README.rst | 24 - docs/conf.py | 53 +- docs/core.rst | 2 + docs/helpers.rst | 2 + docs/index.rst | 5 +- docs/quick_start.rst | 2 + docs/services.rst | 56 +- docs/usage.rst | 2 + examples/two-tier/README.md | 2 + examples/two-tier/__init__.py | 1 + examples/two-tier/main.py | 134 +- examples/uhost/README.md | 2 + examples/uhost/__init__.py | 1 + examples/uhost/main.py | 99 +- pytest.ini | 4 +- scripts/migrate.py | 110 - scripts/migrate/__init__.py | 0 scripts/migrate/__main__.py | 29 + scripts/migrate/_migrate.py | 88 + scripts/migrate/_plugin_doc.py | 11 + scripts/migrate/_plugin_py3to2.py | 59 + scripts/migrate/config.json | 29 + scripts/{ => migrate}/requirements.txt | 2 +- scripts/migrate/test_migrate.py | 44 + setup.py | 13 +- tests/test_core/test_client.py | 71 +- tests/test_core/test_encoder.py | 23 + tests/test_core/test_exc.py | 15 + tests/test_core/test_fields.py | 60 + tests/test_core/test_schema.py | 82 +- tests/test_core/test_transport.py | 72 + tests/test_helpers/test_wait.py | 5 +- tests/test_services/conftest.py | 12 +- tests/test_services/test_set_1073.py | 381 +++ tests/test_services/test_set_113.py | 203 ++ tests/test_services/test_set_1201.py | 309 ++ tests/test_services/test_set_1202.py | 168 + tests/test_services/test_set_1203.py | 271 ++ tests/test_services/test_set_179.py | 405 +++ tests/test_services/test_set_181.py | 247 ++ tests/test_services/test_set_207.py | 564 ++++ tests/test_services/test_set_2117.py | 272 ++ tests/test_services/test_set_2174.py | 302 ++ tests/test_services/test_set_227.py | 199 ++ tests/test_services/test_set_230.py | 322 ++ tests/test_services/test_set_2377.py | 439 +++ tests/test_services/test_set_242.py | 292 ++ tests/test_services/test_set_245.py | 295 ++ tests/test_services/test_set_2457.py | 569 ++++ tests/test_services/test_set_268.py | 339 +++ tests/test_services/test_set_279.py | 452 +++ tests/test_services/test_set_283.py | 618 ++++ tests/test_services/test_set_286.py | 332 ++ tests/test_services/test_set_293.py | 616 ++++ tests/test_services/test_set_2935.py | 153 + tests/test_services/test_set_302.py | 477 +++ tests/test_services/test_set_3278.py | 331 ++ tests/test_services/test_set_330.py | 282 ++ tests/test_services/test_set_333.py | 618 ++++ tests/test_services/test_set_448.py | 378 +++ tests/test_services/test_set_449.py | 313 ++ tests/test_services/test_set_471.py | 284 ++ tests/test_services/test_set_488.py | 550 ++++ tests/test_services/test_set_489.py | 880 ++++++ tests/test_services/test_set_490.py | 713 +++++ tests/test_services/test_set_499.py | 554 ++++ tests/test_services/test_set_503.py | 391 +++ tests/test_services/test_set_687.py | 554 ++++ tests/test_services/test_set_867.py | 711 +++++ tests/test_testing/test_utest.py | 15 +- tox.ini | 21 - ucloud/__init__.py | 2 +- ucloud/client.py | 168 +- ucloud/core/__init__.py | 2 +- ucloud/core/auth/__init__.py | 10 +- ucloud/core/auth/_cfg.py | 144 +- ucloud/core/client/__init__.py | 18 +- ucloud/core/client/_cfg.py | 162 +- ucloud/core/client/_client.py | 230 +- ucloud/core/exc/__init__.py | 30 +- ucloud/core/exc/_exc.py | 106 +- ucloud/core/testing/__init__.py | 1 - ucloud/core/testing/env.py | 30 - ucloud/core/transport/__init__.py | 12 +- ucloud/core/transport/_requests.py | 190 +- ucloud/core/transport/http.py | 145 +- ucloud/core/transport/utils.py | 36 + ucloud/core/typesystem/__init__.py | 2 +- ucloud/core/typesystem/abstract.py | 125 +- ucloud/core/typesystem/encoder.py | 27 + ucloud/core/typesystem/fields.py | 23 +- ucloud/core/typesystem/schema.py | 199 +- ucloud/core/utils/__init__.py | 2 +- ucloud/core/utils/{compact.py => compat.py} | 28 +- ucloud/core/utils/log.py | 44 +- ucloud/core/utils/middleware.py | 106 +- ucloud/helpers/__init__.py | 2 +- ucloud/helpers/utils.py | 172 +- ucloud/helpers/wait.py | 200 +- ucloud/services/__init__.py | 2 +- ucloud/services/pathx/__init__.py | 2 +- ucloud/services/pathx/client.py | 318 +- ucloud/services/pathx/schemas/__init__.py | 2 +- ucloud/services/pathx/schemas/apis.py | 350 +-- ucloud/services/pathx/schemas/models.py | 66 +- ucloud/services/stepflow/__init__.py | 2 +- ucloud/services/stepflow/client.py | 166 +- ucloud/services/stepflow/schemas/__init__.py | 2 +- ucloud/services/stepflow/schemas/apis.py | 136 +- ucloud/services/stepflow/schemas/models.py | 82 +- ucloud/services/uaccount/__init__.py | 2 +- ucloud/services/uaccount/client.py | 326 +- ucloud/services/uaccount/schemas/__init__.py | 2 +- ucloud/services/uaccount/schemas/apis.py | 298 +- ucloud/services/uaccount/schemas/models.py | 116 +- ucloud/services/udb/__init__.py | 2 +- ucloud/services/udb/client.py | 2621 ++++++++-------- ucloud/services/udb/schemas/__init__.py | 2 +- ucloud/services/udb/schemas/apis.py | 2881 +++++++++--------- ucloud/services/udb/schemas/models.py | 404 +-- ucloud/services/udisk/__init__.py | 2 +- ucloud/services/udisk/client.py | 925 +++--- ucloud/services/udisk/schemas/__init__.py | 2 +- ucloud/services/udisk/schemas/apis.py | 1009 +++--- ucloud/services/udisk/schemas/models.py | 158 +- ucloud/services/udpn/__init__.py | 2 +- ucloud/services/udpn/client.py | 368 +-- ucloud/services/udpn/schemas/__init__.py | 2 +- ucloud/services/udpn/schemas/apis.py | 412 +-- ucloud/services/udpn/schemas/models.py | 64 +- ucloud/services/uhost/__init__.py | 2 +- ucloud/services/uhost/client.py | 1530 +++++----- ucloud/services/uhost/schemas/__init__.py | 2 +- ucloud/services/uhost/schemas/apis.py | 1698 ++++++----- ucloud/services/uhost/schemas/models.py | 262 +- ucloud/services/ulb/__init__.py | 2 +- ucloud/services/ulb/client.py | 1310 ++++---- ucloud/services/ulb/schemas/__init__.py | 2 +- ucloud/services/ulb/schemas/apis.py | 1220 ++++---- ucloud/services/ulb/schemas/models.py | 284 +- ucloud/services/umem/__init__.py | 2 +- ucloud/services/umem/client.py | 1430 ++++----- ucloud/services/umem/schemas/__init__.py | 2 +- ucloud/services/umem/schemas/apis.py | 1495 ++++----- ucloud/services/umem/schemas/models.py | 302 +- ucloud/services/unet/__init__.py | 2 +- ucloud/services/unet/client.py | 1860 +++++------ ucloud/services/unet/schemas/__init__.py | 2 +- ucloud/services/unet/schemas/apis.py | 1912 ++++++------ ucloud/services/unet/schemas/models.py | 490 +-- ucloud/services/uphost/__init__.py | 2 +- ucloud/services/uphost/client.py | 710 ++--- ucloud/services/uphost/schemas/__init__.py | 2 +- ucloud/services/uphost/schemas/apis.py | 694 ++--- ucloud/services/uphost/schemas/models.py | 216 +- ucloud/services/vpc/__init__.py | 2 +- ucloud/services/vpc/client.py | 1084 +++---- ucloud/services/vpc/schemas/__init__.py | 2 +- ucloud/services/vpc/schemas/apis.py | 1154 +++---- ucloud/services/vpc/schemas/models.py | 240 +- ucloud/testing/__init__.py | 2 +- ucloud/testing/env.py | 60 +- ucloud/testing/exc.py | 21 + ucloud/testing/funcs.py | 138 +- ucloud/testing/mock.py | 26 + ucloud/testing/op.py | 391 ++- ucloud/testing/utest.py | 281 +- ucloud/version.py | 6 +- 172 files changed, 31718 insertions(+), 16084 deletions(-) create mode 100644 README.md delete mode 100644 README.rst delete mode 100644 scripts/migrate.py create mode 100644 scripts/migrate/__init__.py create mode 100644 scripts/migrate/__main__.py create mode 100644 scripts/migrate/_migrate.py create mode 100644 scripts/migrate/_plugin_doc.py create mode 100644 scripts/migrate/_plugin_py3to2.py create mode 100644 scripts/migrate/config.json rename scripts/{ => migrate}/requirements.txt (85%) create mode 100644 scripts/migrate/test_migrate.py create mode 100644 tests/test_core/test_encoder.py create mode 100644 tests/test_core/test_exc.py create mode 100644 tests/test_core/test_fields.py create mode 100644 tests/test_core/test_transport.py create mode 100644 tests/test_services/test_set_1073.py create mode 100644 tests/test_services/test_set_113.py create mode 100644 tests/test_services/test_set_1201.py create mode 100644 tests/test_services/test_set_1202.py create mode 100644 tests/test_services/test_set_1203.py create mode 100644 tests/test_services/test_set_179.py create mode 100644 tests/test_services/test_set_181.py create mode 100644 tests/test_services/test_set_207.py create mode 100644 tests/test_services/test_set_2117.py create mode 100644 tests/test_services/test_set_2174.py create mode 100644 tests/test_services/test_set_227.py create mode 100644 tests/test_services/test_set_230.py create mode 100644 tests/test_services/test_set_2377.py create mode 100644 tests/test_services/test_set_242.py create mode 100644 tests/test_services/test_set_245.py create mode 100644 tests/test_services/test_set_2457.py create mode 100644 tests/test_services/test_set_268.py create mode 100644 tests/test_services/test_set_279.py create mode 100644 tests/test_services/test_set_283.py create mode 100644 tests/test_services/test_set_286.py create mode 100644 tests/test_services/test_set_293.py create mode 100644 tests/test_services/test_set_2935.py create mode 100644 tests/test_services/test_set_302.py create mode 100644 tests/test_services/test_set_3278.py create mode 100644 tests/test_services/test_set_330.py create mode 100644 tests/test_services/test_set_333.py create mode 100644 tests/test_services/test_set_448.py create mode 100644 tests/test_services/test_set_449.py create mode 100644 tests/test_services/test_set_471.py create mode 100644 tests/test_services/test_set_488.py create mode 100644 tests/test_services/test_set_489.py create mode 100644 tests/test_services/test_set_490.py create mode 100644 tests/test_services/test_set_499.py create mode 100644 tests/test_services/test_set_503.py create mode 100644 tests/test_services/test_set_687.py create mode 100644 tests/test_services/test_set_867.py delete mode 100644 tox.ini delete mode 100644 ucloud/core/testing/__init__.py delete mode 100644 ucloud/core/testing/env.py create mode 100644 ucloud/core/transport/utils.py create mode 100644 ucloud/core/typesystem/encoder.py rename ucloud/core/utils/{compact.py => compat.py} (88%) create mode 100644 ucloud/testing/exc.py create mode 100644 ucloud/testing/mock.py diff --git a/.gitignore b/.gitignore index 3a72b59..03276ca 100644 --- a/.gitignore +++ b/.gitignore @@ -107,3 +107,6 @@ venv.bak/ .idea/ .vscode/ ~* + +# UCloud +.migrate/ diff --git a/.travis.yml b/.travis.yml index 88e6162..26fd8c4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,40 +2,17 @@ language: python python: - - 2.7 + - 2.7 dist: xenial sudo: true # command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors -install: pip install -U tox-travis +install: pip install -e .[ci] # command to run tests, e.g. python setup.py test -script: tox +script: + - make lint + - make test-cov -before_deploy: - - pip install -e .[doc] - - make docs - - touch docs/build/html/.nojekyll - -# deploy new versions to PyPI / GithubIO -deploy: - - provider: pages - skip_cleanup: true - github_token: - secure: "hmzSJF/l5S0Wg5gne0EMg4949kCge+FsicBdpTrfARS22cWfhuoBw4U2/1g68vk3CrCDCWjY1MeS8KSnIL7/T1QEgXtiSj218sUmbJqQrw2zJwQ5D+PSih9YkefAH8Gxhnm0y5XNY7WdtxE243eDNBSahhYUvtb7rIH47nCvCP+Hfqwbe6Uh8sFhXyJoBIG48I66GHJ6ogQdSxbeVErGhyOjnhcgLbEDSj9c0CxkqGzaMjLr0eCJyGk11K8cFiJYlk4pL+rDYh6ySq+5gGIUlCPWwDc0eED2SYfPmuKUf36A8M+zOFXmB2MBu05EgVQy8B8pkuaEANOV8/fzRr4tEJkG6rrnfbECCMjMHb5kVzrPKhjJ+YXpoG4nO7uvILVB3F8H521BhDtEFA3bU2h7ptb5fUsGWovbLbA+Od8B5R2l63GrdGO1tp6rDYsOevrs4yt/nSQnY/3Arj558tVYy4nUCBPQu9ERPh1fqSPGGJ137fTPtaqSI2HNLWDMbXhuStda4Jst8NUtrF52lXiPQ1blFwQ6OTFKzF2lGLpAmYJ+IbbmcVZrif7hS163/h1vbthtdQ3DiAre0Zhy+iKLdVqvkO+FbRkY9UaYC94/xdYNOegzfTlrQbehxALbkAdLfIYfQN09Jqg41H1bGzIak9VWTHgPbrpzThVTrLIwCJg=" - local_dir: docs/build/html - on: - branch: master - repo: ucloud/ucloud-sdk-python2 - python: 2.7 - - provider: pypi - distributions: sdist bdist_wheel - skip_existing: true - user: ucloud - password: - secure: "t0uGtmntLkofMOwPHvaxhDnIEOsA/wgLejbq2Vf8yDueDpJ7mOhHsFEt7vn+PTFeilRf6N58z9P4eixMMxl6oDktSS1WbL5chaUtRljDeTBN8rL10lbalsc7nUFZL8VGKtf2XljhaSra+jcCGvTPaqEOisDiGJoNm6GPbyR9s+P2mfL0XDTwgyUMHpaG5LcvMU+zpns+uXHurBoCnQrstIah9ylrGnmIhNbN6fU2HLlhVaX9VB7QGwSxQuin3YkTdi1tFN7AToi2oMcg46mXRRf/K4jNTwPOEr0MYZ334PhFB1odaWidOObbxMiRudyGk3pTzH6NFxtgg6PviH999qgWgTBFwBjHvq1DkJatRGH/vDHmgE3t2yS2c1xE8Wgl9ONhUj8MOlaStDn9H4lhbuiT7754yS22ko4mvcxCrqzGqZSp2/vh9UyJ72YcqsvsqUPv5paSmSebsEPxCw3z646CuqGk5cPz3XGj4pxJdhqlvOV3Zl35O3mSRLkCfyNLOTfYsheAaK2sxtbcbJ5fPfQRLsvPdVtInmDBEACdHdVYJJSFw4em+gwnnLDGj74/nHJUAX781XetmWoyP9t5IP+cEuzhYApo4rO8JgaG7v/IZoXcl/h4tHsSev8PD6cqWx2vYIJFtMKej87YjbkU/RJEjQz5NychqL0U3FminTw=" - on: - branch: master - tags: true - repo: ucloud/ucloud-sdk-python2 - python: 2.7 +after_success: + - bash <(curl -s https://codecov.io/bash) diff --git a/Makefile b/Makefile index 5b7f526..3756938 100644 --- a/Makefile +++ b/Makefile @@ -13,8 +13,8 @@ endef export BROWSER_PYSCRIPT BROWSER := python -c "$$BROWSER_PYSCRIPT" -# UCloud Tools -GENERATE_TEMPLATE_PATH=../ucloud-api-model-v2/apisdk/lang/python/templates/bash.tpl +# UCloud Tools Path +UCLOUD_TEMPLATE_PATH=../ucloud-api-model-v2/apisdk/lang/python/templates help: @echo "clean - remove all build, test, coverage and Python artifacts" @@ -35,19 +35,19 @@ test: clean pytest test-cov: clean - pytest --cov=ucloud + pytest --cov=ucloud/core tests/test_core test-acc: clean - USDK_ACC=1 pytest --cov=ucloud + USDKACC=1 pytest --cov=ucloud test-all: clean tox lint: - black --check ucloud/ + @flake8 --exclude=ucloud/services ucloud --ignore=E501,F401 fmt: - @black ./ucloud + @black -l 80 ucloud tests examples dev: @pip install -e .[dev] @@ -80,11 +80,9 @@ clean-test: migrate: git clone https://github.com/ucloud/ucloud-sdk-python3.git .migrate - python scripts/migrate.py --source .migrate/ucloud --output ucloud - python scripts/migrate.py --source .migrate/tests --output tests + PYTHONPATH=. python scripts/migrate --source .migrate/ucloud --output ucloud + PYTHONPATH=. python scripts/migrate --source .migrate/tests --output tests + PYTHONPATH=. python scripts/migrate --source .migrate/docs --output docs + PYTHONPATH=. python scripts/migrate --source .migrate/examples --output examples + PYTHONPATH=. python scripts/migrate --source .migrate/README.md --output README.md rm -rf .migrate - black ucloud tests - -gen: - ucloud-model sdk apis --lang python2 --type=public --template - ${GENERATE_TEMPLATE_PATH} --output ./gen.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..f462a42 --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- + +

+ +

+ +

UCloud SDK Python 2

+ +

+Latest Stable Version +Travis CI Status +Codecov Status +Doc Status +

+ +UCloud SDK is a Python client library for accessing the UCloud API. + +This client can run on Linux, macOS and Windows. + +- Website: https://www.ucloud.cn/ +- Free software: Apache 2.0 license +- [Documentation](https://ucloud.github.io/ucloud-sdk-python2/) diff --git a/README.rst b/README.rst deleted file mode 100644 index 6845410..0000000 --- a/README.rst +++ /dev/null @@ -1,24 +0,0 @@ -UCloud SDK Python 2 -=================== - -UCloud SDK is a Python client library for accessing the UCloud API. - -This client can run on Linux, macOS and Windows. It requires Python 2.7 and -above. - -- Website: https://www.ucloud.cn/ -- Free software: Apache 2.0 license -- `Documentation `_ - -.. image:: https://img.shields.io/pypi/v/ucloud-sdk-python2.svg - :target: https://pypi.python.org/pypi/ucloud-sdk-python2/ - :alt: Latest Version -.. image:: https://travis-ci.org/ucloud/ucloud-sdk-python2.svg?branch=master - :target: https://travis-ci.org/ucloud/ucloud-sdk-python2 - :alt: Travis CI Status -.. image:: https://codecov.io/github/ucloud/ucloud-sdk-python2/coverage.svg?branch=master - :target: https://codecov.io/github/ucloud/ucloud-sdk-python2?branch=master - :alt: Codecov Status -.. image:: https://img.shields.io/badge/docs-passing-brightgreen.svg - :target: https://ucloud.github.io/ucloud-sdk-python2/ - :alt: Doc Status diff --git a/docs/conf.py b/docs/conf.py index 83ec3cc..947f332 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,56 +1,11 @@ -# Configuration file for the Sphinx documentation builder. -# -# This file only contains a selection of the most common options. For a full -# list see the documentation: -# http://www.sphinx-doc.org/en/master/config +# -*- coding: utf-8 -*- -# -- Path setup -------------------------------------------------------------- - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -# -# import os -# import sys -# sys.path.insert(0, os.path.abspath('.')) - - -# -- Project information ----------------------------------------------------- - -project = 'ucloud-sdk-python2' +project = 'ucloud-sdk-python3' copyright = '2019, ucloud' author = 'ucloud' - - -# -- General configuration --------------------------------------------------- - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.doctest', - 'sphinx.ext.todo', - 'sphinx.ext.viewcode', -] - -# Add any paths that contain templates here, relative to this directory. +extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.todo', + 'sphinx.ext.viewcode'] templates_path = ['_templates'] - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -# This pattern also affects html_static_path and html_extra_path. exclude_patterns = [] - - -# -- Options for HTML output ------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -# html_theme = 'alabaster' - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] diff --git a/docs/core.rst b/docs/core.rst index e6545e5..d9d7cb0 100644 --- a/docs/core.rst +++ b/docs/core.rst @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + Core ==== diff --git a/docs/helpers.rst b/docs/helpers.rst index e8192e1..530e036 100644 --- a/docs/helpers.rst +++ b/docs/helpers.rst @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + Helpers ======= diff --git a/docs/index.rst b/docs/index.rst index d84f307..0369d6f 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,10 +1,11 @@ +# -*- coding: utf-8 -*- + UCloud SDK Python 2 =================== UCloud SDK is a Python client library for accessing the UCloud API. -This client can run on Linux, macOS and Windows. It requires Python 2.7 and -above. +This client can run on Linux, macOS and Windows. - Website: https://www.ucloud.cn/ - Free software: Apache 2.0 license diff --git a/docs/quick_start.rst b/docs/quick_start.rst index bfc0176..0db589a 100644 --- a/docs/quick_start.rst +++ b/docs/quick_start.rst @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + QuickStart ========== diff --git a/docs/services.rst b/docs/services.rst index 59bfd45..446e90a 100644 --- a/docs/services.rst +++ b/docs/services.rst @@ -1,22 +1,24 @@ +# -*- coding: utf-8 -*- + UCloud SDK Services =================== -UDPN ----- +PathX +----- -.. autoclass:: ucloud.services.udpn.client.UDPNClient +.. autoclass:: ucloud.services.pathx.client.PathXClient :members: -UAccount +StepFlow -------- -.. autoclass:: ucloud.services.uaccount.client.UAccountClient +.. autoclass:: ucloud.services.stepflow.client.StepFlowClient :members: -UMem ----- +UAccount +-------- -.. autoclass:: ucloud.services.umem.client.UMemClient +.. autoclass:: ucloud.services.uaccount.client.UAccountClient :members: UDB @@ -25,10 +27,10 @@ UDB .. autoclass:: ucloud.services.udb.client.UDBClient :members: -UPHost ------- +UDPN +---- -.. autoclass:: ucloud.services.uphost.client.UPHostClient +.. autoclass:: ucloud.services.udpn.client.UDPNClient :members: UDisk @@ -37,33 +39,39 @@ UDisk .. autoclass:: ucloud.services.udisk.client.UDiskClient :members: -VPC +UHost +----- + +.. autoclass:: ucloud.services.uhost.client.UHostClient + :members: + +ULB --- -.. autoclass:: ucloud.services.vpc.client.VPCClient +.. autoclass:: ucloud.services.ulb.client.ULBClient :members: -UNet +UMem ---- -.. autoclass:: ucloud.services.unet.client.UNetClient +.. autoclass:: ucloud.services.umem.client.UMemClient :members: -ULB ---- +UNet +---- -.. autoclass:: ucloud.services.ulb.client.ULBClient +.. autoclass:: ucloud.services.unet.client.UNetClient :members: -PathX ------ +UPHost +------ -.. autoclass:: ucloud.services.pathx.client.PathXClient +.. autoclass:: ucloud.services.uphost.client.UPHostClient :members: -UHost ------ +VPC +--- -.. autoclass:: ucloud.services.uhost.client.UHostClient +.. autoclass:: ucloud.services.vpc.client.VPCClient :members: diff --git a/docs/usage.rst b/docs/usage.rst index 04986e5..4a922f3 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + Usage ===== diff --git a/examples/two-tier/README.md b/examples/two-tier/README.md index 371c7d4..1a3c645 100644 --- a/examples/two-tier/README.md +++ b/examples/two-tier/README.md @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + # UCloud SDK Two-Tier Example ## What is the goal diff --git a/examples/two-tier/__init__.py b/examples/two-tier/__init__.py index e69de29..40a96af 100644 --- a/examples/two-tier/__init__.py +++ b/examples/two-tier/__init__.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- diff --git a/examples/two-tier/main.py b/examples/two-tier/main.py index 2a0a350..4eb0eb9 100644 --- a/examples/two-tier/main.py +++ b/examples/two-tier/main.py @@ -1,133 +1,131 @@ +# -*- coding: utf-8 -*- + import os import logging import random - from ucloud.client import Client from ucloud.helpers import wait, utils -logger = logging.getLogger('ucloud') - -client = Client({ - "region": "cn-bj2", - "project_id": os.getenv("UCLOUD_PROJECT_ID"), - "public_key": os.getenv("UCLOUD_PUBLIC_KEY"), - "private_key": os.getenv("UCLOUD_PRIVATE_KEY"), -}) +logger = logging.getLogger("ucloud") +logger.setLevel(logging.DEBUG) +client = Client( + { + "region": "cn-bj2", + "project_id": os.getenv("UCLOUD_PROJECT_ID"), + "public_key": os.getenv("UCLOUD_PUBLIC_KEY"), + "private_key": os.getenv("UCLOUD_PRIVATE_KEY"), + } +) def main(): image_id = describe_image() - uhost_ids = create_uhost_batch(image_id, 2) - ulb_id = create_ulb() - vserver_id = create_vserver(ulb_id) - backend_ids = allocate_backend_batch(ulb_id, vserver_id, uhost_ids) - backend_ids and release_backend_batch(ulb_id, vserver_id, backend_ids) - vserver_id and delete_vserver(ulb_id, vserver_id) - ulb_id and delete_ulb(ulb_id) - uhost_ids and delete_uhost_batch(uhost_ids) def describe_image(): - images = client.uhost().describe_image({'ImageType': 'Base'}).get('ImageSet', []) + images = ( + client.uhost().describe_image({"ImageType": "Base"}).get("ImageSet", []) + ) if not images: return image = random.choice(images) - return image.get('ImageId') + return image.get("ImageId") def mget_uhost_states(uhost_ids): - resp = client.uhost().describe_uhost_instance({'UHostIds': uhost_ids}) - return [inst.get('State') for inst in resp.get('UHostSet')] + resp = client.uhost().describe_uhost_instance({"UHostIds": uhost_ids}) + return [inst.get("State") for inst in resp.get("UHostSet")] def create_uhost_batch(image_id, count): - resp = client.uhost().create_uhost_instance({ - 'Name': 'sdk-python2-example-two-tier', - 'Zone': 'cn-bj2-05', - 'ImageId': image_id, - 'LoginMode': "Password", - 'Password': utils.gen_password(20), - 'CPU': 1, - 'Memory': 1024, - 'MaxCount': count, - }) - uhost_ids = resp.get('UHostIds', []) + resp = client.uhost().create_uhost_instance( + { + "Name": "sdk-python3-example-two-tier", + "Zone": "cn-bj2-05", + "ImageId": image_id, + "LoginMode": "Password", + "Password": utils.gen_password(20), + "CPU": 1, + "Memory": 1024, + "MaxCount": count, + } + ) + uhost_ids = resp.get("UHostIds", []) wait.wait_for_state( - target=['running'], pending=['pending'], timeout=300, - refresh=lambda: ( - 'running' if all([state == 'Running' for state in mget_uhost_states(uhost_ids)]) else 'pending' - ), + target=["running"], + pending=["pending"], + timeout=300, + refresh=lambda: "running" + if all([(state == "Running") for state in mget_uhost_states(uhost_ids)]) + else "pending", ) return uhost_ids def create_ulb(): - resp = client.ulb().create_ulb({ - 'Name': 'sdk-python2-example-two-tier', - }) - return resp.get('ULBId') + resp = client.ulb().create_ulb({"Name": "sdk-python3-example-two-tier"}) + return resp.get("ULBId") def create_vserver(ulb_id): - resp = client.ulb().create_vserver({ - 'Name': 'sdk-python2-example-two-tier', - 'ULBId': ulb_id, - }) - return resp.get('VServerId') + resp = client.ulb().create_vserver( + {"Name": "sdk-python3-example-two-tier", "ULBId": ulb_id} + ) + return resp.get("VServerId") def allocate_backend_batch(ulb_id, vserver_id, uhost_ids): backend_ids = [] for uhost_id in uhost_ids: - resp = client.ulb().allocate_backend({ - 'ULBId': ulb_id, - 'VServerId': vserver_id, - 'ResourceId': uhost_id, - 'ResourceType': 'UHost', - }) - backend_ids.append(resp.get('BackendId')) + resp = client.ulb().allocate_backend( + { + "ULBId": ulb_id, + "VServerId": vserver_id, + "ResourceId": uhost_id, + "ResourceType": "UHost", + } + ) + backend_ids.append(resp.get("BackendId")) return backend_ids def release_backend_batch(ulb_id, vserver_id, backend_ids): for backend_id in backend_ids: - client.ulb().release_backend({ - 'ULBId': ulb_id, - 'VServerId': vserver_id, - 'BackendId': backend_id, - }) + client.ulb().release_backend( + {"ULBId": ulb_id, "VServerId": vserver_id, "BackendId": backend_id} + ) def delete_vserver(ulb_id, vserver_id): - client.ulb().delete_vserver({'ULBId': ulb_id, 'VServerId': vserver_id}) + client.ulb().delete_vserver({"ULBId": ulb_id, "VServerId": vserver_id}) def delete_ulb(ulb_id): - client.ulb().delete_ulb({'ULBId': ulb_id}) + client.ulb().delete_ulb({"ULBId": ulb_id}) def delete_uhost_batch(uhost_ids): for uhost_id in uhost_ids: - client.uhost().stop_uhost_instance({'UHostId': uhost_id}) - + client.uhost().stop_uhost_instance({"UHostId": uhost_id}) wait.wait_for_state( - target=['stopped'], pending=['pending'], timeout=300, - refresh=lambda: ( - 'stopped' if all([state == 'Stopped' for state in mget_uhost_states(uhost_ids)]) else 'pending' - ), + target=["stopped"], + pending=["pending"], + timeout=300, + refresh=lambda: "stopped" + if all([(state == "Stopped") for state in mget_uhost_states(uhost_ids)]) + else "pending", ) - for uhost_id in uhost_ids: - client.uhost().terminate_uhost_instance({'UHostId': uhost_id}) + client.uhost().terminate_uhost_instance({"UHostId": uhost_id}) -if __name__ == '__main__': +if __name__ == "__main__": main() diff --git a/examples/uhost/README.md b/examples/uhost/README.md index 9aabc7e..08b363e 100644 --- a/examples/uhost/README.md +++ b/examples/uhost/README.md @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + # UCloud SDK UHost Example ## What is the goal diff --git a/examples/uhost/__init__.py b/examples/uhost/__init__.py index e69de29..40a96af 100644 --- a/examples/uhost/__init__.py +++ b/examples/uhost/__init__.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- diff --git a/examples/uhost/main.py b/examples/uhost/main.py index 5e87696..1f9e346 100644 --- a/examples/uhost/main.py +++ b/examples/uhost/main.py @@ -1,74 +1,91 @@ +# -*- coding: utf-8 -*- + import os import logging import random - from ucloud.client import Client from ucloud.helpers import wait, utils -logger = logging.getLogger('ucloud') +logger = logging.getLogger("ucloud") +logger.setLevel(logging.DEBUG) def main(): - client = Client({ - "region": "cn-bj2", - "project_id": os.getenv("UCLOUD_PROJECT_ID"), - "public_key": os.getenv("UCLOUD_PUBLIC_KEY"), - "private_key": os.getenv("UCLOUD_PRIVATE_KEY"), - }) - + client = Client( + { + "region": "cn-bj2", + "project_id": os.getenv("UCLOUD_PROJECT_ID"), + "public_key": os.getenv("UCLOUD_PUBLIC_KEY"), + "private_key": os.getenv("UCLOUD_PRIVATE_KEY"), + } + ) logger.info("finding image, random choice one") - images = client.uhost().describe_image({ - 'ImageType': 'Base', 'OsType': 'Linux' - }).get('ImageSet', []) - + images = ( + client.uhost() + .describe_image({"ImageType": "Base", "OsType": "Linux"}) + .get("ImageSet", []) + ) assert len(images) > 0 - logger.info("creating uhost instance ...") image = random.choice(images) - - resp = client.uhost().create_uhost_instance({ - 'Name': 'sdk-python-example', - 'Zone': image["Zone"], - 'ImageId': image["ImageId"], - 'LoginMode': "Password", - 'Password': utils.gen_password(20), - 'CPU': 1, - 'Memory': 1024, - 'Disks': [{ - 'Size': image["ImageSize"], - 'Type': 'CLOUD_SSD', - 'IsBoot': 'True', - }], - }) + resp = client.uhost().create_uhost_instance( + { + "Name": "sdk-python-example", + "Zone": image["Zone"], + "ImageId": image["ImageId"], + "LoginMode": "Password", + "Password": utils.gen_password(20), + "CPU": 1, + "Memory": 1024, + "Disks": [ + { + "Size": image["ImageSize"], + "Type": "LOCAL_NORMAL", + "IsBoot": "True", + } + ], + } + ) uhost_id = utils.first(resp["UHostIds"]) logger.info("uhost instance is created") def refresh_state(): - uhost = utils.first(client.uhost().describe_uhost_instance({'UHostIds': [uhost_id]}).get('UHostSet', [])) - if uhost.get('State') in ['Running', 'Stopped']: - return uhost['State'].lower() - return 'pending' + uhost = utils.first( + client.uhost() + .describe_uhost_instance({"UHostIds": [uhost_id]}) + .get("UHostSet", []) + ) + if uhost.get("State") in ["Running", "Stopped"]: + return uhost["State"].lower() + return "pending" logger.info("wait uhost state is running ...") try: - wait.wait_for_state(pending=['pending'], target=['running'], timeout=300, refresh=refresh_state) + wait.wait_for_state( + pending=["pending"], + target=["running"], + timeout=300, + refresh=refresh_state, + ) except wait.WaitTimeoutException as e: logger.error(e) logger.info("uhost instance is running") - logger.info("stopping uhost for clean up resources ...") - client.uhost().stop_uhost_instance({'UHostId': uhost_id}) - + client.uhost().stop_uhost_instance({"UHostId": uhost_id}) try: - wait.wait_for_state(pending=['pending'], target=['stopped'], timeout=180, refresh=refresh_state) + wait.wait_for_state( + pending=["pending"], + target=["stopped"], + timeout=180, + refresh=refresh_state, + ) except wait.WaitTimeoutException as e: logger.error(e) else: logger.info("uhost instance is stopped") - logger.info("remove uhost instance from cloud") - client.uhost().terminate_uhost_instance({'UHostId': uhost_id}) + client.uhost().terminate_uhost_instance({"UHostId": uhost_id}) -if __name__ == '__main__': +if __name__ == "__main__": main() diff --git a/pytest.ini b/pytest.ini index d750e31..23d020e 100644 --- a/pytest.ini +++ b/pytest.ini @@ -2,7 +2,5 @@ log_cli = 1 log_cli_level = INFO log_cli_format = %(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s %(name)s) -log_cli_date_format=%Y-%m-%d %H:%M:%S -norecursedirs = scripts testpaths = ucloud tests -addopts = -s -v --doctest-modules +addopts = --doctest-modules diff --git a/scripts/migrate.py b/scripts/migrate.py deleted file mode 100644 index 4b5f55a..0000000 --- a/scripts/migrate.py +++ /dev/null @@ -1,110 +0,0 @@ -# -*- coding: utf-8 -*- - -import os -import ast -import astor -import logging - -logging.basicConfig() -logger = logging.getLogger(__name__) - - -class SDK3to2Transformer(ast.NodeTransformer): - def visit_Import(self, node): - is_typing = [alias for alias in node.names if alias.name == 'typing'] - return None if is_typing else node - - def visit_AnnAssign(self, node): - if node.value is None: - return node - return ast.Assign(targets=[node.target], value=node.value) - - def visit_FunctionDef(self, node): - body = [] - - # remove type hints - for arg in node.args.args: - arg.annotation = None - - if node.args.kwarg: - node.args.kwarg.annotation = None - - # visit children - for child in node.body: - if isinstance(child, ast.AnnAssign): - body.append(self.visit_AnnAssign(child)) - else: - body.append(child) - - node.body = body - node.returns = None - return node - - def visit_ClassDef(self, node): - body = [] - - # old-style class convert to new-style class - if not node.bases: - node.bases = [ast.Name(id='object', ctx=ast.Load())] - - # visit children - for child in node.body: - if isinstance(child, ast.FunctionDef): - body.append(self.visit_FunctionDef(child)) - else: - body.append(child) - - node.body = body - return node - - -UTF8_HEADER = '# -*- coding: utf-8 -*-\n\n' -UNICODE_HEADER = 'from __future__ import unicode_literals\n\n' - - -class Migrate(object): - def __init__(self, source, output=None): - self.source = source - self.output = output or source - self.transformer = SDK3to2Transformer() - - def convert(self, source): - ast_node = ast.parse(source) - ast_node = self.transformer.visit(ast_node) - return UTF8_HEADER + astor.to_source(ast_node) - - def find_python_files(self): - for folder, _, files in list(os.walk(self.source)): - for file in files: - yield folder + os.path.sep + file - - def run(self): - for path in self.find_python_files(): - logger.info('load {}'.format(path)) - relative_path = os.path.relpath(path, self.source) - with open(path, encoding='utf-8') as f: - source = f.read() - - code = self.convert(source) - - output_path = os.path.abspath( - os.path.join(self.output, relative_path)) - os.makedirs(os.path.dirname(output_path), exist_ok=True) - - with open(output_path, 'w', encoding='utf-8') as f: - f.write(code) - print('migrated {} to {}'.format(path, output_path)) - - -if __name__ == '__main__': - import argparse - - parser = argparse.ArgumentParser(description='argument parser') - parser.add_argument('--source', required=True, - help='source code file writen by python3') - parser.add_argument('--output', required=True, - help='output source code file writen by python2') - - args = parser.parse_args() - migrate = Migrate(args.source, args.output) - migrate.run() diff --git a/scripts/migrate/__init__.py b/scripts/migrate/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/scripts/migrate/__main__.py b/scripts/migrate/__main__.py new file mode 100644 index 0000000..85405cd --- /dev/null +++ b/scripts/migrate/__main__.py @@ -0,0 +1,29 @@ +import os +import json + +from scripts.migrate._migrate import Migrate, Config, PluginConfig + + +DEFAULT_CONFIG_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'config.json') + +if __name__ == '__main__': + import argparse + + parser = argparse.ArgumentParser(description='argument parser') + parser.add_argument('--source', required=True, + help='source code file writen by python3') + parser.add_argument('--output', required=True, + help='output source code file writen by python2') + parser.add_argument('--config', required=False, + help='the configuration file for migration processing') + + with open(DEFAULT_CONFIG_PATH) as f: + d = json.load(f) + + config = Config() + config.plugins = [PluginConfig(**plugin) for plugin in d['plugins']] + print(config.__dict__) + + args = parser.parse_args() + migrate = Migrate(config) + migrate.run(args.source, args.output) diff --git a/scripts/migrate/_migrate.py b/scripts/migrate/_migrate.py new file mode 100644 index 0000000..b2e8ac2 --- /dev/null +++ b/scripts/migrate/_migrate.py @@ -0,0 +1,88 @@ +# -*- coding: utf-8 -*- +import itertools +import os +import typing +import logging +import dataclasses + +from scripts.migrate._plugin_py3to2 import SDK3to2Transformer +from scripts.migrate._plugin_doc import DocTransformer + +logging.basicConfig() +logger = logging.getLogger(__name__) + + +@dataclasses.dataclass +class PluginConfig: + name: str + ext: typing.List[str] = None + options: dict = None + + +class Config: + paths: typing.List[str] = [] + plugins: typing.List[PluginConfig] = [] + + +class Migrate(object): + UTF8_HEADER = '# -*- coding: utf-8 -*-\n\n' + + default_plugins_classes = { + "py3to2": SDK3to2Transformer, + "doc": DocTransformer, + } + + def __init__(self, config: Config = None): + self.plugins = {} + self.ext = {} + for plugin in config.plugins: + plugin_cls = self.default_plugins_classes.get(plugin.name) + if plugin_cls is None: + continue + + plugin_inst = plugin_cls(**(plugin.options or {})) + self.plugins[plugin.name] = plugin_inst + + for ext in plugin.ext: + self.ext.setdefault(ext, list()) + self.ext[ext].append(plugin_inst) + + self.paths = config.paths + + def find_python_files(self, dir_or_file): + if os.path.isdir(dir_or_file): + for folder, _, files in list(os.walk(dir_or_file)): + for file in files: + yield folder + os.path.sep + file + else: + yield dir_or_file + + def run(self, source_path: str, output_path: str): + for path in self.find_python_files(source_path): + # find plugins by file extension + plugins = [plugins for ext, plugins in self.ext.items() if path.endswith(ext)] + plugins = plugins and plugins[0] + + # skip unexpected file by file extension + if not plugins: + continue + + # resolve path + relative_path = os.path.relpath(path, source_path) + result_path = os.path.abspath(os.path.join(output_path, relative_path)) + print('migrate {} to {}'.format(path, result_path)) + + # read source code + with open(path, encoding='utf-8') as f: + source_code = f.read() + + # convert destination code + output_code = source_code + for plugin in plugins: + output_code = self.UTF8_HEADER + plugin.convert(source_code) + + # output to file + os.makedirs(os.path.dirname(result_path), exist_ok=True) + + with open(result_path, 'w', encoding='utf-8') as f: + f.write(output_code) diff --git a/scripts/migrate/_plugin_doc.py b/scripts/migrate/_plugin_doc.py new file mode 100644 index 0000000..002b79f --- /dev/null +++ b/scripts/migrate/_plugin_doc.py @@ -0,0 +1,11 @@ + + +class DocTransformer: + def __init__(self, replaces=None): + self.replaces = replaces + + def convert(self, source: str) -> str: + result = source + for r in self.replaces: + result = result.replace(r['from'], r['to']) + return result diff --git a/scripts/migrate/_plugin_py3to2.py b/scripts/migrate/_plugin_py3to2.py new file mode 100644 index 0000000..4f3e424 --- /dev/null +++ b/scripts/migrate/_plugin_py3to2.py @@ -0,0 +1,59 @@ +import ast + +import astor + + +class SDK3to2Transformer(ast.NodeTransformer): + def visit_Import(self, node): + is_typing = [alias for alias in node.names if alias.name == 'typing'] + return None if is_typing else node + + def visit_AnnAssign(self, node): + if node.value is None: + return node + return ast.Assign(targets=[node.target], value=node.value) + + def visit_FunctionDef(self, node): + body = [] + + # remove type hints + for arg in node.args.args: + arg.annotation = None + + if node.args.kwarg: + node.args.kwarg.annotation = None + + # visit children + for child in node.body: + if isinstance(child, ast.FunctionDef): + body.append(self.visit_FunctionDef(child)) + elif isinstance(child, ast.AnnAssign): + body.append(self.visit_AnnAssign(child)) + else: + body.append(child) + + node.body = body + node.returns = None + return node + + def visit_ClassDef(self, node): + body = [] + + # old-style class convert to new-style class + if not node.bases: + node.bases = [ast.Name(id='object', ctx=ast.Load())] + + # visit children + for child in node.body: + if isinstance(child, ast.FunctionDef): + body.append(self.visit_FunctionDef(child)) + else: + body.append(child) + + node.body = body + return node + + def convert(self, source: str) -> str: + ast_node = ast.parse(source) + ast_node = self.visit(ast_node) + return astor.to_source(ast_node) diff --git a/scripts/migrate/config.json b/scripts/migrate/config.json new file mode 100644 index 0000000..3a33b19 --- /dev/null +++ b/scripts/migrate/config.json @@ -0,0 +1,29 @@ +{ + "plugins": [ + { + "name": "py3to2", + "ext": [ + ".py" + ] + }, + { + "name": "doc", + "ext": [ + ".md", + ".rst" + ], + "options": { + "replaces": [ + { + "from": "ucloud-sdk-python3", + "to": "ucloud-sdk-python2" + }, + { + "from": "UCloud SDK Python 3", + "to": "UCloud SDK Python 2" + } + ] + } + } + ] +} diff --git a/scripts/requirements.txt b/scripts/migrate/requirements.txt similarity index 85% rename from scripts/requirements.txt rename to scripts/migrate/requirements.txt index bc36c1d..7c41503 100644 --- a/scripts/requirements.txt +++ b/scripts/migrate/requirements.txt @@ -1 +1 @@ -astor +astor diff --git a/scripts/migrate/test_migrate.py b/scripts/migrate/test_migrate.py new file mode 100644 index 0000000..48460b0 --- /dev/null +++ b/scripts/migrate/test_migrate.py @@ -0,0 +1,44 @@ +import ast +import astor +import pytest + +from scripts.migrate._plugin_py3to2 import SDK3to2Transformer + + +@pytest.mark.parametrize( + "input_vector,expected", + [ + ("foo: int = 42", "foo = 42"), + ("def fn(foo: str) -> int: pass", "def fn(foo):\n pass"), + ("class Foo: pass", "class Foo(object):\n pass"), + ("import typing", ""), + ("str(value)", "unicode(value)"), + ("def deco(fn: typing.Callable[[Client, dict], dict]): pass", "def deco(fn):\n pass"), + (""" +def step(self, **kwargs): + def deco(fn: typing.Callable[[Client, dict], dict]): + return fn + return deco + """, """ +def step(self, **kwargs): + def deco(fn): + return fn + return deco + """), + ], +) +def test_transformer(input_vector, expected): + transformer = SDK3to2Transformer() + result = transformer.convert(input_vector) + assert result == astor.to_source(ast.parse(expected)) + + +def test_parse_ast(): + input_vector = """ +def step(self, **kwargs): + def deco(fn: typing.Callable[[Client, dict], dict]): + return fn + return deco + """ + node = ast.parse(input_vector) + print(astor.dump_tree(node)) diff --git a/setup.py b/setup.py index 437306f..90b7ff5 100644 --- a/setup.py +++ b/setup.py @@ -44,7 +44,7 @@ def load_version(): def load_long_description(): try: - with io.open("README.rst", encoding="utf-8") as f: + with io.open("README.md", encoding="utf-8") as f: return f.read() except IOError: return "" @@ -62,16 +62,15 @@ def load_requirements(requirements_file): dependencies_test = dependencies + [ 'flake8>=3.6.0', - 'tox', 'pytest', 'pytest-cov', ] -dependencies_doc = dependencies + ['sphinx==1.8.4'] +dependencies_doc = dependencies + ['sphinx'] -dependencies_dev = list(set( - dependencies_doc + dependencies_test -)) +dependencies_ci = list(set(dependencies_test + dependencies_doc)) + +dependencies_dev = list(set(dependencies_ci + ['black'])) def do_setup(): @@ -79,6 +78,7 @@ def do_setup(): name="ucloud-sdk-python2", description="UCloud Service Development Kit - Python", long_description=load_long_description(), + long_description_content_type='text/markdown', license="Apache License 2.0", version=load_version(), packages=find_packages(exclude=["tests*"]), @@ -90,6 +90,7 @@ def do_setup(): "test": dependencies_test, "doc": dependencies_doc, "dev": dependencies_dev, + "ci": dependencies_ci, }, classifiers=[ "Development Status :: 3 - Alpha", diff --git a/tests/test_core/test_client.py b/tests/test_core/test_client.py index 9872d02..08939db 100644 --- a/tests/test_core/test_client.py +++ b/tests/test_core/test_client.py @@ -3,8 +3,9 @@ import os import pytest import logging -from ucloud.core.client import Client -from ucloud.testing import env +from ucloud.client import Client +from ucloud.core import exc +from ucloud.testing.mock import MockedTransport logger = logging.getLogger(__name__) @@ -13,21 +14,63 @@ def client(): return Client( { - "region": os.getenv("UCLOUD_REGION"), - "project_id": os.getenv("UCLOUD_PROJECT_ID"), - "public_key": os.getenv("UCLOUD_PUBLIC_KEY"), - "private_key": os.getenv("UCLOUD_PRIVATE_KEY"), + "region": "cn-bj2", + "public_key": "foo", + "private_key": "foo", "timeout": 10, + "max_retries": 3, } ) -class TestAccClient(object): - @pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) - def test_pre_check(self, client): - env.pre_check_env() +@pytest.fixture(scope="function", autouse=True) +def transport(): + return MockedTransport() - @pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) - def test_client_invoke(self, client): - resp = client.invoke("DescribeUHostInstance") - assert resp["RetCode"] == 0 + +class TestClient(object): + def test_client_invoke(self, client, transport): + transport.mock_data(lambda _: {"RetCode": 0, "Action": "Foo"}) + client.transport = transport + assert client.invoke("Foo") == {"RetCode": 0, "Action": "Foo"} + + def test_client_invoke_code_error(self, client, transport): + transport.mock_data(lambda _: {"RetCode": 171, "Action": "Foo"}) + client.transport = transport + with pytest.raises(exc.RetCodeException): + try: + client.invoke("Foo") + except exc.RetCodeException as e: + assert str(e) + expected = {"RetCode": 171, "Action": "Foo", "Message": ""} + assert e.json() == expected + raise e + + def test_client_invoke_with_retryable_error(self, client, transport): + transport.mock_data(lambda _: {"RetCode": 10000, "Action": "Foo"}) + client.transport = transport + with pytest.raises(exc.RetCodeException): + client.invoke("Foo") + + def test_client_invoke_with_unexpected_error(self, client, transport): + def raise_error(_): + raise ValueError("temporary error") + + transport.mock_data(raise_error) + client.transport = transport + with pytest.raises(ValueError): + client.invoke("Foo") + + def test_client_try_import(self, client): + assert client.pathx() + assert client.stepflow() + assert client.uaccount() + assert client.udb() + assert client.udpn() + assert client.udisk() + assert client.uhost() + assert client.ulb() + assert client.umem() + assert client.unet() + assert client.uphost() + assert client.vpc() diff --git a/tests/test_core/test_encoder.py b/tests/test_core/test_encoder.py new file mode 100644 index 0000000..083bf5a --- /dev/null +++ b/tests/test_core/test_encoder.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- + +import pytest +from ucloud.core.typesystem import encoder + + +@pytest.mark.parametrize( + "input_vector,expected", + [ + ({"foo": "bar"}, {"foo": "bar"}), + ({"foo": 42}, {"foo": "42"}), + ({"foo": 42.42}, {"foo": "42.42"}), + ({"foo": 42.0}, {"foo": "42"}), + ({"foo": True}, {"foo": "true"}), + ({"foo": False}, {"foo": "false"}), + ({"IP": ["127.0.0.1"]}, {"IP.0": "127.0.0.1"}), + ({"IP": ["foo", "bar"]}, {"IP.0": "foo", "IP.1": "bar"}), + ({"IP": [{"foo": "bar"}]}, {"IP.0.foo": "bar"}), + ], +) +def test_params_encode(input_vector, expected): + result = encoder.encode(input_vector) + assert result == expected diff --git a/tests/test_core/test_exc.py b/tests/test_core/test_exc.py new file mode 100644 index 0000000..8777fd4 --- /dev/null +++ b/tests/test_core/test_exc.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- + +import pytest +from ucloud.core import exc + + +def test_ret_code_error(): + assert not exc.UCloudException().retryable + code_error = exc.RetCodeException("Foo", 1, "") + assert str(code_error) + assert not code_error.retryable + assert code_error.json() == {"Action": "Foo", "Message": "", "RetCode": 1} + validate_error = exc.ValidationException(ValueError("invalid type")) + assert not validate_error.retryable + assert str(validate_error) diff --git a/tests/test_core/test_fields.py b/tests/test_core/test_fields.py new file mode 100644 index 0000000..4742d07 --- /dev/null +++ b/tests/test_core/test_fields.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- + +import logging +import pytest +from ucloud.core import exc +from ucloud.core.typesystem import fields + +logger = logging.getLogger(__name__) + + +def test_field_str(): + s = fields.Str() + assert s.dumps(s.loads("foo")) == "foo" + with pytest.raises(exc.ValidationException): + fields.Str(strict=True).loads(42) + + +def test_field_int(): + i = fields.Int() + assert i.dumps(i.loads("42")) == 42 + with pytest.raises(exc.ValidationException): + fields.Int().dumps("foo") + with pytest.raises(exc.ValidationException): + fields.Int(strict=True).loads("42") + + +def test_field_float(): + f = fields.Float() + assert f.dumps(f.loads("42.0")) == 42.0 + with pytest.raises(exc.ValidationException): + fields.Float().dumps("foo") + with pytest.raises(exc.ValidationException): + fields.Float(strict=True).loads("42.0") + + +def test_field_bool(): + b = fields.Bool() + assert b.dumps(b.loads("true")) + assert not b.dumps(b.loads("false")) + with pytest.raises(exc.ValidationException): + fields.Bool().dumps("foo") + with pytest.raises(exc.ValidationException): + fields.Bool(strict=True).loads("true") + + +def test_field_list(): + l = fields.List(fields.Int()) + assert l.dumps(l.loads(["42"])) == [42] + with pytest.raises(exc.ValidationException): + fields.List(fields.Int(), strict=True).dumps(42) + with pytest.raises(exc.ValidationException): + fields.List(fields.Int()).dumps(["foo"]) + with pytest.raises(exc.ValidationException): + fields.List(fields.Int(strict=True)).loads(["42"]) + + +def test_field_base64(): + b64 = fields.Base64() + assert b64.loads("Zm9v") == "foo" + assert b64.dumps("foo") == "Zm9v" diff --git a/tests/test_core/test_schema.py b/tests/test_core/test_schema.py index 33ba2af..5271b19 100644 --- a/tests/test_core/test_schema.py +++ b/tests/test_core/test_schema.py @@ -8,14 +8,29 @@ logger = logging.getLogger(__name__) +def test_request_basic(): + class Schema(schema.RequestSchema): + fields = { + "Foo": fields.Int(required=True), + "Bar": fields.Int(required=False), + } + + assert Schema().dumps({"Foo": "42"}) == {"Foo": 42} + assert Schema().dumps({"Foo": "42"}) == {"Foo": 42} + with pytest.raises(exc.ValidationException): + Schema().dumps({}) + with pytest.raises(exc.ValidationException): + Schema().dumps({"Foo": "bar"}) + + def test_request_array(): class Schema(schema.RequestSchema): fields = {"IP": fields.List(fields.Str())} d = Schema().dumps({"IP": ["127.0.0.1"]}) - assert d == {"IP.0": "127.0.0.1"} + assert d == {"IP": ["127.0.0.1"]} d = Schema().dumps({}) - assert d == {} + assert d == {"IP": []} def test_request_array_with_default(): @@ -23,9 +38,9 @@ class Schema(schema.RequestSchema): fields = {"IP": fields.List(fields.Str(), default=["127.0.0.1"])} d = Schema().dumps({"IP": ["192.168.0.1"]}) - assert d == {"IP.0": "192.168.0.1"} + assert d == {"IP": ["192.168.0.1"]} d = Schema().dumps({}) - assert d == {"IP.0": "127.0.0.1"} + assert d == {"IP": ["127.0.0.1"]} def test_request_object_model(): @@ -36,7 +51,7 @@ class NestedObjectSchema(schema.RequestSchema): fields = {"Interface": Schema()} d = NestedObjectSchema().dumps({"Interface": {"IP": ["127.0.0.1"]}}) - assert d == {"Interface.IP.0": "127.0.0.1"} + assert d == {"Interface": {"IP": ["127.0.0.1"]}} with pytest.raises(exc.ValidationException): NestedObjectSchema().dumps({"Interface": 1}) @@ -54,16 +69,51 @@ class NestedArraySchema(schema.RequestSchema): } d = NestedArraySchema().dumps({}) - assert d == {"Interface.0.IP.0": "192.168.1.1"} - d = {"Interface": [{"IP": ["127.0.0.1", "192.168.0.1"]}, {"IP": ["172.16.0.1"]}]} + assert d == {"Interface": [{"IP": ["192.168.1.1"]}]} + d = { + "Interface": [ + {"IP": ["127.0.0.1", "192.168.0.1"]}, + {"IP": ["172.16.0.1"]}, + ] + } d = NestedArraySchema().dumps(d) assert d == { - "Interface.0.IP.0": "127.0.0.1", - "Interface.0.IP.1": "192.168.0.1", - "Interface.1.IP.0": "172.16.0.1", + "Interface": [ + {"IP": ["127.0.0.1", "192.168.0.1"]}, + {"IP": ["172.16.0.1"]}, + ] } +def test_response_basic(): + class Schema(schema.ResponseSchema): + fields = { + "Foo": fields.Int(required=True), + "Bar": fields.Int(required=False), + "Default": fields.Int(default=42), + "Call": fields.List(fields.Int(), default=list), + } + + assert Schema().dumps({"Foo": "42"}) == { + "Foo": 42, + "Default": 42, + "Call": [], + } + assert Schema().loads({"Foo": "42"}) == { + "Foo": 42, + "Default": 42, + "Call": [], + } + with pytest.raises(exc.ValidationException): + Schema().dumps({}) + with pytest.raises(exc.ValidationException): + Schema().dumps({"Foo": "bar"}) + with pytest.raises(exc.ValidationException): + Schema().dumps({}) + with pytest.raises(exc.ValidationException): + Schema().dumps({"Foo": "bar"}) + + def test_response_array(): class Schema(schema.ResponseSchema): fields = {"IP": fields.List(fields.Str())} @@ -124,8 +174,16 @@ class NestedArraySchema(schema.ResponseSchema): d = NestedArraySchema().dumps({}) assert d == {"Interface": [{"IP": ["192.168.1.1"]}]} - d = {"Interface": [{"IP": ["127.0.0.1", "192.168.0.1"]}, {"IP": ["172.16.0.1"]}]} + d = { + "Interface": [ + {"IP": ["127.0.0.1", "192.168.0.1"]}, + {"IP": ["172.16.0.1"]}, + ] + } d = NestedArraySchema().dumps(d) assert d == { - "Interface": [{"IP": ["127.0.0.1", "192.168.0.1"]}, {"IP": ["172.16.0.1"]}] + "Interface": [ + {"IP": ["127.0.0.1", "192.168.0.1"]}, + {"IP": ["172.16.0.1"]}, + ] } diff --git a/tests/test_core/test_transport.py b/tests/test_core/test_transport.py new file mode 100644 index 0000000..ec519fb --- /dev/null +++ b/tests/test_core/test_transport.py @@ -0,0 +1,72 @@ +# -*- coding: utf-8 -*- + +import pytest +import logging +from ucloud.core.transport import RequestsTransport, Request, Response, utils + +logger = logging.getLogger(__name__) + + +@pytest.fixture(scope="function", autouse=True) +def transport(): + return RequestsTransport() + + +class TestTransport(object): + def test_transport_send(self, transport): + req = Request( + url="http://httpbin.org/anything", + method="post", + json={"foo": "bar"}, + ) + resp = transport.send(req) + assert resp.text + assert resp.json()["json"] == {"foo": "bar"} + + def test_transport_handler(self, transport): + global_env = {} + + def request_handler(r): + global_env["req"] = r + return r + + def response_handler(r): + global_env["resp"] = r + return r + + transport.middleware.request(handler=request_handler) + transport.middleware.response(handler=response_handler) + req = Request( + url="http://httpbin.org/anything", + method="post", + json={"foo": "bar"}, + ) + resp = transport.send(req) + assert resp.text + assert resp.json()["json"] == {"foo": "bar"} + assert "req" in global_env + assert "resp" in global_env + + +class TestResponse(object): + def test_guess_json_utf(self): + import json + + encodings = [ + "utf-32", + "utf-8-sig", + "utf-16", + "utf-8", + "utf-16-be", + "utf-16-le", + "utf-32-be", + "utf-32-le", + ] + for e in encodings: + s = json.dumps("表意字符").encode(e) + assert utils.guess_json_utf(s) == e + + def test_response_empty_content(self): + r = Response("http://foo.bar", "post") + assert not r.text + assert r.json() is None diff --git a/tests/test_helpers/test_wait.py b/tests/test_helpers/test_wait.py index c6345cb..993ba31 100644 --- a/tests/test_helpers/test_wait.py +++ b/tests/test_helpers/test_wait.py @@ -13,5 +13,8 @@ def test_wait(): timeout=0.5, ) wait.wait_for_state( - pending=["pending"], target=["running"], refresh=lambda: "running", timeout=0.5 + pending=["pending"], + target=["running"], + refresh=lambda: "running", + timeout=0.5, ) diff --git a/tests/test_services/conftest.py b/tests/test_services/conftest.py index 675eaae..194e927 100644 --- a/tests/test_services/conftest.py +++ b/tests/test_services/conftest.py @@ -5,22 +5,22 @@ from ucloud.client import Client -@pytest.fixture(scope="session", autouse=True) -def client(): +@pytest.fixture(scope="session", autouse=True, name="client") +def client_factory(): return Client( { - "region": os.getenv("UCLOUD_REGION"), + "region": "cn-bj2", "project_id": os.getenv("UCLOUD_PROJECT_ID"), "public_key": os.getenv("UCLOUD_PUBLIC_KEY"), "private_key": os.getenv("UCLOUD_PRIVATE_KEY"), - "max_retries": 3, + "max_retries": 10, "timeout": 60, } ) -@pytest.fixture(scope="module", autouse=True) -def variables(): +@pytest.fixture(scope="module", autouse=True, name="variables") +def variables_factory(): return { "Region": "cn-bj2", "Zone": "cn-bj2-05", diff --git a/tests/test_services/test_set_1073.py b/tests/test_services/test_set_1073.py new file mode 100644 index 0000000..7265c3c --- /dev/null +++ b/tests/test_services/test_set_1073.py @@ -0,0 +1,381 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(1073) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_1073(client, variables): + scenario.initial(variables) + scenario.variables["Password"] = "dXFhQHVjbG91ZA==" + scenario.variables["Type"] = "SSD-2" + scenario.variables["Name"] = "test123123" + scenario.variables["Remark"] = "test123123" + scenario.variables["ChargeType"] = "Month" + scenario.variables["ProjectId"] = "ohrg-xbbyex" + scenario.run(client) + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribePHostImageResponse"), + ], + action="DescribePHostImage", +) +def describe_phost_image_00(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "ImageType": "Base", + } + try: + resp = client.uphost().describe_phost_image(d) + except exc.RetCodeException as e: + resp = e.json() + variables["ImageID1"] = utest.value_at_path(resp, "ImageSet.0.ImageId") + variables["ImageID2"] = utest.value_at_path(resp, "ImageSet.2.ImageId") + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "GetPHostPriceResponse"), + ], + action="GetPHostPrice", +) +def get_phost_price_01(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Quantity": 1, + "Count": 1, + "ChargeType": "Month", + } + try: + resp = client.uphost().get_phost_price(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribePHostTagsResponse"), + ], + action="DescribePHostTags", +) +def describe_phost_tags_02(client, variables): + d = {"Zone": variables.get("Zone"), "Region": variables.get("Region")} + try: + resp = client.uphost().describe_phost_tags(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "CreatePHostResponse"), + ], + action="CreatePHost", +) +def create_phost_03(client, variables): + d = { + "Zone": variables.get("Zone"), + "Remark": variables.get("Remark"), + "Region": variables.get("Region"), + "Password": variables.get("Password"), + "Name": variables.get("Name"), + "ImageId": variables.get("ImageID1"), + "ChargeType": variables.get("ChargeType"), + } + try: + resp = client.uphost().create_phost(d) + except exc.RetCodeException as e: + resp = e.json() + variables["PHost"] = utest.value_at_path(resp, "PHostId.0") + return resp + + +@scenario.step( + max_retries=60, + retry_interval=60, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribePHostResponse"), + ("str_eq", "PHostSet.0.PHostType", variables.get("Type")), + ("str_eq", "PHostSet.0.Name", variables.get("Name")), + ("str_eq", "PHostSet.0.PHostId", variables.get("PHost")), + ("str_eq", "PHostSet.0.Remark", variables.get("Remark")), + ("str_eq", "PHostSet.0.Zone", variables.get("Zone")), + ("str_eq", "PHostSet.0.PMStatus", "Running"), + ], + action="DescribePHost", +) +def describe_phost_04(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "PHostId": [variables.get("PHost")], + } + try: + resp = client.uphost().describe_phost(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=600, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "RebootPHostResponse"), + ], + action="RebootPHost", +) +def reboot_phost_05(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "ProjectId": variables.get("ProjectId"), + "PHostId": variables.get("PHost"), + } + try: + resp = client.uphost().reboot_phost(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=120, + retry_interval=60, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "PHostSet.0.PMStatus", "Running"), + ], + action="DescribePHost", +) +def describe_phost_06(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "PHostId": [variables.get("PHost")], + } + try: + resp = client.uphost().describe_phost(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=10, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "StopPHostResponse"), + ], + action="StopPHost", +) +def stop_phost_07(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "ProjectId": variables.get("ProjectId"), + "PHostId": variables.get("PHost"), + } + try: + resp = client.invoke("StopPHost", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=60, + startup_delay=10, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "PHostSet.0.PMStatus", "Stopped"), + ], + action="DescribePHost", +) +def describe_phost_08(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "PHostId": [variables.get("PHost")], + } + try: + resp = client.uphost().describe_phost(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=10, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "ReinstallPHostResponse"), + ], + action="ReinstallPHost", +) +def reinstall_phost_09(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Password": variables.get("Password"), + "PHostId": variables.get("PHost"), + "ImageId": variables.get("ImageID2"), + } + try: + resp = client.uphost().reinstall_phost(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=120, + retry_interval=60, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribePHostResponse"), + ("str_eq", "PHostSet.0.PHostType", variables.get("Type")), + ("str_eq", "PHostSet.0.Name", variables.get("Name")), + ("str_eq", "PHostSet.0.PHostId", variables.get("PHost")), + ("str_eq", "PHostSet.0.Remark", variables.get("Remark")), + ("str_eq", "PHostSet.0.Zone", variables.get("Zone")), + ("str_eq", "PHostSet.0.PMStatus", "Running"), + ], + action="DescribePHost", +) +def describe_phost_10(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "PHostId": [variables.get("PHost")], + } + try: + resp = client.uphost().describe_phost(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "PoweroffPHostResponse"), + ], + action="PoweroffPHost", +) +def poweroff_phost_11(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "ProjectId": variables.get("ProjectId"), + "PHostId": variables.get("PHost"), + } + try: + resp = client.uphost().poweroff_phost(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=60, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "PHostSet.0.PMStatus", "Stopped"), + ], + action="DescribePHost", +) +def describe_phost_12(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "PHostId": [variables.get("PHost")], + } + try: + resp = client.uphost().describe_phost(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=10, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "TerminatePHostResponse"), + ], + action="TerminatePHost", +) +def terminate_phost_13(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "ProjectId": variables.get("ProjectId"), + "PHostId": variables.get("PHost"), + } + try: + resp = client.uphost().terminate_phost(d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_113.py b/tests/test_services/test_set_113.py new file mode 100644 index 0000000..5bf1c3b --- /dev/null +++ b/tests/test_services/test_set_113.py @@ -0,0 +1,203 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(113) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_113(client, variables): + scenario.initial(variables) + scenario.variables["Region"] = "cn-bj2" + scenario.variables["Zone"] = "cn-bj2-02" + scenario.run(client) + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=3, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateUFSVolume", +) +def create_ufs_volume_00(client, variables): + d = { + "Zone": variables.get("Zone"), + "Size": 1024, + "Region": variables.get("Region"), + } + try: + resp = client.invoke("CreateUFSVolume", d) + except exc.RetCodeException as e: + resp = e.json() + variables["Volume_Id"] = utest.value_at_path(resp, "VolumeId") + variables["Volume_Name"] = utest.value_at_path(resp, "VolumeName") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUFSVolume", +) +def describe_ufs_volume_01(client, variables): + d = { + "Zone": variables.get("Zone"), + "VolumeId": variables.get("Volume_Id"), + "Region": variables.get("Region"), + } + try: + resp = client.invoke("DescribeUFSVolume", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUHostLite", +) +def describe_uhost_lite_02(client, variables): + d = {"Zone": variables.get("Zone"), "Region": variables.get("Region")} + try: + resp = client.invoke("DescribeUHostLite", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUFSVolume", +) +def describe_ufs_volume_03(client, variables): + d = { + "Zone": variables.get("Zone"), + "VolumeId": "Volume_Id", + "Region": variables.get("Region"), + } + try: + resp = client.invoke("DescribeUFSVolume", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="ClearUFSVolumeWhiteList", +) +def clear_ufs_volume_white_list_04(client, variables): + d = { + "VolumeId": variables.get("Volume_Id"), + "Region": variables.get("Region"), + } + try: + resp = client.invoke("ClearUFSVolumeWhiteList", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUFSVolume", +) +def describe_ufs_volume_05(client, variables): + d = { + "Zone": variables.get("Zone"), + "VolumeId": "Volume_Id", + "Region": variables.get("Region"), + } + try: + resp = client.invoke("DescribeUFSVolume", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="ExtendUFSVolume", +) +def extend_ufs_volume_06(client, variables): + d = { + "VolumeId": variables.get("Volume_Id"), + "Size": 2048, + "Region": variables.get("Region"), + } + try: + resp = client.invoke("ExtendUFSVolume", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUFSVolume", +) +def describe_ufs_volume_07(client, variables): + d = { + "Zone": variables.get("Zone"), + "VolumeId": "Volume_Id", + "Region": variables.get("Region"), + } + try: + resp = client.invoke("DescribeUFSVolume", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=30, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="RemoveUFSVolume", +) +def remove_ufs_volume_08(client, variables): + d = { + "VolumeId": variables.get("Volume_Id"), + "Region": variables.get("Region"), + } + try: + resp = client.invoke("RemoveUFSVolume", d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_1201.py b/tests/test_services/test_set_1201.py new file mode 100644 index 0000000..118c3bd --- /dev/null +++ b/tests/test_services/test_set_1201.py @@ -0,0 +1,309 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(1201) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_1201(client, variables): + scenario.initial(variables) + scenario.variables["ConfigId"] = "03f58ca9-b64d-4bdd-abc7-c6b9a46fd801" + scenario.variables["Password"] = "Z3VhbmxpeXVhbm1pbWE=" + scenario.variables["HighAvailability"] = "disable" + scenario.variables["Version"] = 3.2 + scenario.variables["Protocol"] = "redis" + scenario.variables["ResourceType"] = "single" + scenario.variables["Name"] = "single_redis" + scenario.run(client) + + +@scenario.step( + max_retries=60, + retry_interval=100, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateURedisGroup", +) +def create_uredis_group_00(client, variables): + d = { + "Zone": variables.get("Zone"), + "Version": variables.get("Version"), + "Size": 1, + "Region": variables.get("Region"), + "Quantity": 1, + "Protocol": variables.get("Protocol"), + "Name": variables.get("Name"), + "HighAvailability": variables.get("HighAvailability"), + "ConfigId": variables.get("ConfigId"), + "ChargeType": "Month", + "BackupTime": 3, + "AutoBackup": "enable", + } + try: + resp = client.umem().create_uredis_group(d) + except exc.RetCodeException as e: + resp = e.json() + variables["group_id"] = utest.value_at_path(resp, "GroupId") + return resp + + +@scenario.step( + max_retries=30, + retry_interval=10, + startup_delay=20, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.State", "Running"), + ], + action="DescribeUMem", +) +def describe_umem_01(client, variables): + d = { + "Zone": variables.get("Zone"), + "ResourceType": variables.get("ResourceType"), + "ResourceId": variables.get("group_id"), + "Region": variables.get("Region"), + "Protocol": variables.get("Protocol"), + "Offset": 0, + "Limit": 1000, + } + try: + resp = client.invoke("DescribeUMem", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=10, + startup_delay=20, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "ModifyURedisGroupNameResponse"), + ], + action="ModifyURedisGroupName", +) +def modify_uredis_group_name_02(client, variables): + d = { + "Region": variables.get("Region"), + "Name": "Redis_Change", + "GroupId": variables.get("group_id"), + } + try: + resp = client.umem().modify_uredis_group_name(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=10, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.State", "Running"), + ], + action="DescribeUMem", +) +def describe_umem_03(client, variables): + d = { + "Zone": variables.get("Zone"), + "ResourceType": variables.get("ResourceType"), + "ResourceId": variables.get("group_id"), + "Region": variables.get("Region"), + "Protocol": variables.get("Protocol"), + "Offset": 0, + "Limit": 1000, + } + try: + resp = client.invoke("DescribeUMem", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=30, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="ResizeURedisGroup", +) +def resize_uredis_group_04(client, variables): + d = { + "Zone": variables.get("Zone"), + "Size": 2, + "Region": variables.get("Region"), + "GroupId": variables.get("group_id"), + } + try: + resp = client.umem().resize_uredis_group(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=10, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.State", "Running"), + ], + action="DescribeUMem", +) +def describe_umem_05(client, variables): + d = { + "Zone": variables.get("Zone"), + "ResourceType": variables.get("ResourceType"), + "ResourceId": variables.get("group_id"), + "Region": variables.get("Region"), + "Protocol": variables.get("Protocol"), + "Offset": 0, + "Limit": 1000, + } + try: + resp = client.invoke("DescribeUMem", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=60, + startup_delay=60, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="ModifyURedisGroupPassword", +) +def modify_uredis_group_password_06(client, variables): + d = { + "Zone": variables.get("Zone"), + "ResourceType": variables.get("ResourceType"), + "Region": variables.get("Region"), + "Password": variables.get("Password"), + "GroupId": variables.get("group_id"), + } + try: + resp = client.invoke("ModifyURedisGroupPassword", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=10, + startup_delay=30, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.State", "Running"), + ], + action="DescribeUMem", +) +def describe_umem_07(client, variables): + d = { + "Zone": variables.get("Zone"), + "ResourceId": variables.get("group_id"), + "Region": variables.get("Region"), + "Protocol": variables.get("Protocol"), + "Offset": 0, + "Limit": 1000, + } + try: + resp = client.invoke("DescribeUMem", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=10, + startup_delay=30, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "CheckURedisAllowanceResponse"), + ], + action="CheckURedisAllowance", +) +def check_uredis_allowance_08(client, variables): + d = { + "Zone": variables.get("Zone"), + "SlaveZone": variables.get("Zone"), + "Size": 1, + "Region": variables.get("Region"), + "Count": 1, + } + try: + resp = client.invoke("CheckURedisAllowance", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=10, + startup_delay=15, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DeleteURedisGroupResponse"), + ], + action="DeleteURedisGroup", +) +def delete_uredis_group_09(client, variables): + d = { + "Region": variables.get("Region"), + "GroupId": variables.get("group_id"), + } + try: + resp = client.umem().delete_uredis_group(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeURedisGroupResponse"), + ("object_not_contains", "DataSet", variables.get("group_id")), + ], + action="DescribeURedisGroup", +) +def describe_uredis_group_10(client, variables): + d = { + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + "GroupId": variables.get("group_id"), + } + try: + resp = client.umem().describe_uredis_group(d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_1202.py b/tests/test_services/test_set_1202.py new file mode 100644 index 0000000..c0ce2a8 --- /dev/null +++ b/tests/test_services/test_set_1202.py @@ -0,0 +1,168 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(1202) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_1202(client, variables): + scenario.initial(variables) + scenario.variables["Protocol"] = "memcache" + scenario.variables["ResourceType"] = "distributed" + scenario.variables["Name"] = "distributed_memcache" + scenario.run(client) + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateUMemSpace", +) +def create_umem_space_00(client, variables): + d = { + "Zone": variables.get("Zone"), + "Size": 8, + "Region": variables.get("Region"), + "Quantity": 1, + "Protocol": variables.get("Protocol"), + "Name": variables.get("Name"), + "ChargeType": "Month", + } + try: + resp = client.umem().create_umem_space(d) + except exc.RetCodeException as e: + resp = e.json() + variables["Space_Id"] = utest.value_at_path(resp, "SpaceId") + return resp + + +@scenario.step( + max_retries=30, + retry_interval=10, + startup_delay=3, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.State", "Running"), + ], + action="DescribeUMem", +) +def describe_umem_01(client, variables): + d = { + "ResourceId": variables.get("Space_Id"), + "Region": variables.get("Region"), + "Protocol": variables.get("Protocol"), + "Offset": 0, + "Limit": 1000, + } + try: + resp = client.invoke("DescribeUMem", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="ResizeUMemSpace", +) +def resize_umem_space_02(client, variables): + d = { + "Zone": variables.get("Zone"), + "SpaceId": variables.get("Space_Id"), + "Size": 14, + "Region": variables.get("Region"), + } + try: + resp = client.umem().resize_umem_space(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=10, + startup_delay=3, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.State", "Running"), + ], + action="DescribeUMem", +) +def describe_umem_03(client, variables): + d = { + "ResourceId": variables.get("Space_Id"), + "Region": variables.get("Region"), + "Protocol": variables.get("Protocol"), + "Offset": 0, + "Limit": 1000, + } + try: + resp = client.invoke("DescribeUMem", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DeleteUMem", +) +def delete_umem_04(client, variables): + d = { + "Zone": variables.get("Zone"), + "ResourceType": variables.get("ResourceType"), + "ResourceId": variables.get("Space_Id"), + "Region": variables.get("Region"), + } + try: + resp = client.invoke("DeleteUMem", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeUMemSpaceResponse"), + ("object_not_contains", "DataSet", variables.get("Space_Id")), + ], + action="DescribeUMemSpace", +) +def describe_umem_space_05(client, variables): + d = { + "Zone": variables.get("Zone"), + "SpaceId": variables.get("Space_Id"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + } + try: + resp = client.umem().describe_umem_space(d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_1203.py b/tests/test_services/test_set_1203.py new file mode 100644 index 0000000..411894c --- /dev/null +++ b/tests/test_services/test_set_1203.py @@ -0,0 +1,271 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(1203) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_1203(client, variables): + scenario.initial(variables) + scenario.variables["Protocol"] = "redis" + scenario.variables["Type"] = "double" + scenario.variables["Name"] = "distributed_redis" + scenario.run(client) + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "CheckUMemSpaceAllowanceResponse"), + ], + action="CheckUMemSpaceAllowance", +) +def check_umem_space_allowance_00(client, variables): + d = { + "Zone": variables.get("Zone"), + "Size": 16, + "Region": variables.get("Region"), + "Count": 1, + } + try: + resp = client.invoke("CheckUMemSpaceAllowance", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=30, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateUMemSpace", +) +def create_umem_space_01(client, variables): + d = { + "Zone": variables.get("Zone"), + "Type": variables.get("Type"), + "Size": 16, + "Region": variables.get("Region"), + "Quantity": 1, + "Protocol": variables.get("Protocol"), + "Name": variables.get("Name"), + "ChargeType": "Month", + } + try: + resp = client.umem().create_umem_space(d) + except exc.RetCodeException as e: + resp = e.json() + variables["Space_Id"] = utest.value_at_path(resp, "SpaceId") + return resp + + +@scenario.step( + max_retries=30, + retry_interval=10, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.State", "Running"), + ], + action="DescribeUMem", +) +def describe_umem_02(client, variables): + d = { + "ResourceId": variables.get("Space_Id"), + "Region": variables.get("Region"), + "Protocol": variables.get("Protocol"), + "Offset": 0, + "Limit": 1000, + } + try: + resp = client.invoke("DescribeUMem", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "ModifyUMemSpaceNameResponse"), + ], + action="ModifyUMemSpaceName", +) +def modify_umem_space_name_03(client, variables): + d = { + "Zone": variables.get("Zone"), + "SpaceId": variables.get("Space_Id"), + "Region": variables.get("Region"), + "Name": "Rename_FBS", + } + try: + resp = client.umem().modify_umem_space_name(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.State", "Running"), + ], + action="DescribeUMem", +) +def describe_umem_04(client, variables): + d = { + "ResourceId": variables.get("Space_Id"), + "Region": variables.get("Region"), + "Protocol": variables.get("Protocol"), + "Offset": 0, + "Limit": 1000, + } + try: + resp = client.invoke("DescribeUMem", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "GetUMemSpaceStateResponse"), + ], + action="GetUMemSpaceState", +) +def get_umem_space_state_05(client, variables): + d = { + "Zone": variables.get("Zone"), + "SpaceId": variables.get("Space_Id"), + "Region": variables.get("Region"), + } + try: + resp = client.umem().get_umem_space_state(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=20, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="ResizeUMemSpace", +) +def resize_umem_space_06(client, variables): + d = { + "Zone": variables.get("Zone"), + "SpaceId": variables.get("Space_Id"), + "Size": 17, + "Region": variables.get("Region"), + } + try: + resp = client.umem().resize_umem_space(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=40, + retry_interval=10, + startup_delay=60, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.State", "Running"), + ], + action="DescribeUMem", +) +def describe_umem_07(client, variables): + d = { + "ResourceId": variables.get("Space_Id"), + "Region": variables.get("Region"), + "Protocol": variables.get("Protocol"), + "Offset": 0, + "Limit": 1000, + } + try: + resp = client.invoke("DescribeUMem", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=10, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DeleteUMemSpaceResponse"), + ], + action="DeleteUMemSpace", +) +def delete_umem_space_08(client, variables): + d = { + "Zone": variables.get("Zone"), + "SpaceId": variables.get("Space_Id"), + "Region": variables.get("Region"), + } + try: + resp = client.umem().delete_umem_space(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=10, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeUMemResponse"), + ("object_not_contains", "DataSet", variables.get("Space_Id")), + ], + action="DescribeUMem", +) +def describe_umem_09(client, variables): + d = { + "ResourceId": variables.get("Space_Id"), + "Region": variables.get("Region"), + "Protocol": variables.get("Protocol"), + "Offset": 0, + "Limit": 1000, + } + try: + resp = client.invoke("DescribeUMem", d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_179.py b/tests/test_services/test_set_179.py new file mode 100644 index 0000000..ad09177 --- /dev/null +++ b/tests/test_services/test_set_179.py @@ -0,0 +1,405 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(179) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_179(client, variables): + scenario.initial(variables) + scenario.variables["Region"] = "cn-bj2" + scenario.variables["Zone"] = "cn-bj2-02" + scenario.variables["DBTypeId"] = "mongodb-3.2" + scenario.variables["InstanceMode"] = "Normal" + scenario.variables["InstanceType"] = "Normal" + scenario.variables["Port"] = 27017 + scenario.variables["MemoryLimit"] = 600 + scenario.variables["DiskSpace"] = 20 + scenario.variables["DBName"] = "AUTO-" + scenario.variables["UseSSD"] = False + scenario.variables["GroupName"] = "mongodb3.2默认WiredTiger-configsvr配置" + scenario.variables["GroupNameMongos"] = "mongodb3.2默认mongos配置" + scenario.run(client) + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUDBType", +) +def describe_udb_type_00(client, variables): + d = {"Zone": variables.get("Zone"), "Region": variables.get("Region")} + try: + resp = client.udb().describe_udb_type(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=2, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeUDBParamGroupResponse"), + ], + action="DescribeUDBParamGroup", +) +def describe_udb_param_group_01(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + } + try: + resp = client.udb().describe_udb_param_group(d) + except exc.RetCodeException as e: + resp = e.json() + variables["DataSet_paramGroup"] = utest.value_at_path(resp, "DataSet") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateUDBInstance", +) +def create_udb_instance_02(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Quantity": 1, + "Port": variables.get("Port"), + "ParamGroupId": funcs.search_value( + variables.get("DataSet_paramGroup"), + "GroupName", + variables.get("GroupName"), + "GroupId", + ), + "Name": "auto-config3.2", + "MemoryLimit": variables.get("MemoryLimit"), + "InstanceType": "Normal", + "InstanceMode": "Configsvr", + "DiskSpace": variables.get("DiskSpace"), + "DBTypeId": variables.get("DBTypeId"), + "ChargeType": "Month", + "AdminUser": "root", + "AdminPassword": "guanliyuanmima", + } + try: + resp = client.udb().create_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + variables["configid"] = utest.value_at_path(resp, "DBId") + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=500, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "State", "Running"), + ], + action="DescribeUDBInstanceState", +) +def describe_udb_instance_state_03(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("configid"), + } + try: + resp = client.udb().describe_udb_instance_state(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "CreateUDBRouteInstanceResponse"), + ], + action="CreateUDBRouteInstance", +) +def create_udb_route_instance_04(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Port": variables.get("Port"), + "ParamGroupId": funcs.search_value( + variables.get("DataSet_paramGroup"), + "GroupName", + variables.get("GroupNameMongos"), + "GroupId", + ), + "Name": "mongos-auto", + "MemoryLimit": variables.get("MemoryLimit"), + "DiskSpace": variables.get("DiskSpace"), + "DBTypeId": variables.get("DBTypeId"), + "ConfigsvrId": [variables.get("configid")], + } + try: + resp = client.udb().create_udb_route_instance(d) + except exc.RetCodeException as e: + resp = e.json() + variables["DBId"] = utest.value_at_path(resp, "DBId") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=20, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="ModifyUDBInstanceName", +) +def modify_udb_instance_name_05(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Name": "Rename-auto-data3.0", + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().modify_udb_instance_name(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=180, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="RestartUDBInstance", +) +def restart_udb_instance_06(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().restart_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="BackupUDBInstanceErrorLog", +) +def backup_udb_instance_error_log_07(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + "BackupName": "errorlog-test", + } + try: + resp = client.udb().backup_udb_instance_error_log(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=1, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUDBLogPackage", +) +def describe_udb_log_package_08(client, variables): + d = { + "Zone": variables.get("Zone"), + "Type": 4, + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().describe_udb_log_package(d) + except exc.RetCodeException as e: + resp = e.json() + variables["backupidlog"] = utest.value_at_path(resp, "DataSet.0.BackupId") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=1, + fast_fail=False, + action="DescribeUDBBinlogBackupURL", +) +def describe_udb_binlog_backup_url_09(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + "BackupId": variables.get("backupidlog"), + } + try: + resp = client.udb().describe_udb_binlog_backup_url(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DeleteUDBLogPackage", +) +def delete_udb_log_package_10(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "BackupId": variables.get("backupidlog"), + } + try: + resp = client.udb().delete_udb_log_package(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=10, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="ClearUDBLog", +) +def clear_udb_log_11(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "LogType": 30, + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().clear_udb_log(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=60, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="StopUDBInstance", +) +def stop_udb_instance_12(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().stop_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=60, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="StopUDBInstance", +) +def stop_udb_instance_13(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("configid"), + } + try: + resp = client.udb().stop_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=90, + fast_fail=False, + action="DeleteUDBInstance", +) +def delete_udb_instance_14(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().delete_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=90, + fast_fail=False, + action="DeleteUDBInstance", +) +def delete_udb_instance_15(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("configid"), + } + try: + resp = client.udb().delete_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_181.py b/tests/test_services/test_set_181.py new file mode 100644 index 0000000..92226ea --- /dev/null +++ b/tests/test_services/test_set_181.py @@ -0,0 +1,247 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(181) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_181(client, variables): + scenario.initial(variables) + scenario.variables["Region"] = "cn-bj2" + scenario.variables["Zone"] = "cn-bj2-02" + scenario.variables["DBTypeId"] = "mongodb-3.0" + scenario.variables["InstanceMode"] = "Normal" + scenario.variables["InstanceType"] = "Normal" + scenario.variables["Port"] = 27017 + scenario.variables["MemoryLimit"] = 600 + scenario.variables["DiskSpace"] = 20 + scenario.variables["DBName"] = "AUTO" + scenario.variables["UseSSD"] = False + scenario.variables["GroupName"] = "mongodb3.0默认MMAPv1-shardsvr配置" + scenario.run(client) + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUDBType", +) +def describe_udb_type_00(client, variables): + d = {"Zone": variables.get("Zone"), "Region": variables.get("Region")} + try: + resp = client.udb().describe_udb_type(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=3, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeUDBParamGroupResponse"), + ], + action="DescribeUDBParamGroup", +) +def describe_udb_param_group_01(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + } + try: + resp = client.udb().describe_udb_param_group(d) + except exc.RetCodeException as e: + resp = e.json() + variables["DataSet_paramGroup"] = utest.value_at_path(resp, "DataSet") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=1, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CheckUDBInstanceAllowance", +) +def check_udb_instance_allowance_02(client, variables): + d = { + "Zone": variables.get("Zone"), + "UseSSD": True, + "Region": variables.get("Region"), + "MemoryLimit": 6000, + "DiskSpace": 200, + "Count": 1, + "ClassType": "sql", + } + try: + resp = client.invoke("CheckUDBInstanceAllowance", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateUDBInstance", +) +def create_udb_instance_03(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Quantity": 1, + "Port": variables.get("Port"), + "ParamGroupId": funcs.search_value( + variables.get("DataSet_paramGroup"), + "GroupName", + variables.get("GroupName"), + "GroupId", + ), + "Name": funcs.concat( + variables.get("DBName"), variables.get("DBTypeId") + ), + "MemoryLimit": variables.get("MemoryLimit"), + "InstanceType": variables.get("InstanceType"), + "InstanceMode": variables.get("InstanceMode"), + "DiskSpace": variables.get("DiskSpace"), + "DBTypeId": variables.get("DBTypeId"), + "ChargeType": "Month", + "AdminUser": "root", + "AdminPassword": "guanliyuanmima", + } + try: + resp = client.udb().create_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + variables["DBId"] = utest.value_at_path(resp, "DBId") + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=60, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateUDBReplicationInstance", +) +def create_udb_replication_instance_04(client, variables): + d = { + "Zone": variables.get("Zone"), + "SrcId": variables.get("DBId"), + "Region": variables.get("Region"), + "Port": variables.get("Port"), + "Name": "second-auto", + } + try: + resp = client.udb().create_udb_replication_instance(d) + except exc.RetCodeException as e: + resp = e.json() + variables["secondid"] = utest.value_at_path(resp, "DBId") + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=60, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "StopUDBInstanceResponse"), + ], + action="StopUDBInstance", +) +def stop_udb_instance_05(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().stop_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=60, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "StopUDBInstanceResponse"), + ], + action="StopUDBInstance", +) +def stop_udb_instance_06(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("secondid"), + } + try: + resp = client.udb().stop_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=60, + fast_fail=False, + action="DeleteUDBInstance", +) +def delete_udb_instance_07(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("secondid"), + } + try: + resp = client.udb().delete_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=5, + fast_fail=False, + action="DeleteUDBInstance", +) +def delete_udb_instance_08(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().delete_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_207.py b/tests/test_services/test_set_207.py new file mode 100644 index 0000000..2bd41ad --- /dev/null +++ b/tests/test_services/test_set_207.py @@ -0,0 +1,564 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(207) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_207(client, variables): + scenario.initial(variables) + scenario.variables["Region"] = "cn-bj2" + scenario.variables["Zone"] = "cn-bj2-02" + scenario.variables["DBTypeId"] = "percona-5.7" + scenario.variables["InstanceMode"] = "Normal" + scenario.variables["InstanceType"] = "Normal" + scenario.variables["Port"] = 3306 + scenario.variables["MemoryLimit"] = 1000 + scenario.variables["DiskSpace"] = 20 + scenario.variables["DBName"] = "auto_ptbz_" + scenario.variables["UseSSD"] = False + scenario.run(client) + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUDBType", +) +def describe_udb_type_00(client, variables): + d = {"Zone": variables.get("Zone"), "Region": variables.get("Region")} + try: + resp = client.udb().describe_udb_type(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUDBParamGroup", +) +def describe_udb_param_group_01(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + } + try: + resp = client.udb().describe_udb_param_group(d) + except exc.RetCodeException as e: + resp = e.json() + variables["DataSet_paramGroup"] = utest.value_at_path(resp, "DataSet") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUDBInstancePrice", +) +def describe_udb_instance_price_02(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "MemoryLimit": variables.get("MemoryLimit"), + "DiskSpace": variables.get("DiskSpace"), + "DBTypeId": variables.get("DBTypeId"), + "Count": 1, + } + try: + resp = client.udb().describe_udb_instance_price(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CheckUDBInstanceAllowance", +) +def check_udb_instance_allowance_03(client, variables): + d = { + "Zone": variables.get("Zone"), + "UseSSD": variables.get("UseSSD"), + "Region": variables.get("Region"), + "MemoryLimit": variables.get("MemoryLimit"), + "DiskSpace": variables.get("DiskSpace"), + "Count": 1, + "ClassType": "SQL", + } + try: + resp = client.invoke("CheckUDBInstanceAllowance", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=1, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateUDBInstance", +) +def create_udb_instance_04(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Quantity": 0, + "Port": variables.get("Port"), + "ParamGroupId": funcs.search_value( + variables.get("DataSet_paramGroup"), + "DBTypeId", + variables.get("DBTypeId"), + "GroupId", + ), + "Name": funcs.concat( + variables.get("DBName"), variables.get("DBTypeId") + ), + "MemoryLimit": variables.get("MemoryLimit"), + "InstanceType": variables.get("InstanceType"), + "InstanceMode": variables.get("InstanceMode"), + "DiskSpace": variables.get("DiskSpace"), + "DBTypeId": variables.get("DBTypeId"), + "ChargeType": "Month", + "AdminPassword": "guanliyuanmima", + } + try: + resp = client.udb().create_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + variables["DBId"] = utest.value_at_path(resp, "DBId") + return resp + + +@scenario.step( + max_retries=50, + retry_interval=10, + startup_delay=30, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "State", "Running"), + ], + action="DescribeUDBInstanceState", +) +def describe_udb_instance_state_05(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().describe_udb_instance_state(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=1, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="StopUDBInstance", +) +def stop_udb_instance_06(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().stop_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=20, + retry_interval=3, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ( + "str_eq", + "DataSet.0.Name", + funcs.concat(variables.get("DBName"), variables.get("DBTypeId")), + ), + ("str_eq", "DataSet.0.DBTypeId", variables.get("DBTypeId")), + ("str_eq", "DataSet.0.State", "Shutoff"), + ], + action="DescribeUDBInstance", +) +def describe_udb_instance_07(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + "DBId": variables.get("DBId"), + "ClassType": "sql", + } + try: + resp = client.udb().describe_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + variables["VirtualIP"] = utest.value_at_path(resp, "DataSet.0.VirtualIP") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUDBInstanceUpgradePrice", +) +def describe_udb_instance_upgrade_price_08(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "MemoryLimit": variables.get("MemoryLimit") + 1, + "DiskSpace": variables.get("DiskSpace") + 1, + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().describe_udb_instance_upgrade_price(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CheckUDBInstanceAllowance", +) +def check_udb_instance_allowance_09(client, variables): + d = { + "Zone": variables.get("Zone"), + "UseSSD": variables.get("UseSSD"), + "Region": variables.get("Region"), + "MemoryLimit": variables.get("MemoryLimit") + 1, + "DiskSpace": variables.get("DiskSpace") + 1, + "Count": 1, + "ClassType": "SQL", + } + try: + resp = client.invoke("CheckUDBInstanceAllowance", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=2, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "ResizeUDBInstanceResponse"), + ], + action="ResizeUDBInstance", +) +def resize_udb_instance_10(client, variables): + d = { + "Zone": variables.get("Zone"), + "UseSSD": variables.get("UseSSD"), + "StartAfterUpgrade": True, + "Region": variables.get("Region"), + "MemoryLimit": variables.get("MemoryLimit") + 1, + "DiskSpace": variables.get("DiskSpace") + 1, + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().resize_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=100, + retry_interval=10, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ( + "str_eq", + "DataSet.0.Name", + funcs.concat(variables.get("DBName"), variables.get("DBTypeId")), + ), + ("str_eq", "DataSet.0.DBTypeId", variables.get("DBTypeId")), + ("str_eq", "DataSet.0.State", "Running"), + ("str_eq", "DataSet.0.MemoryLimit", variables.get("MemoryLimit") + 1), + ("str_eq", "DataSet.0.DiskSpace", variables.get("DiskSpace") + 10), + ], + action="DescribeUDBInstance", +) +def describe_udb_instance_11(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + "DBId": variables.get("DBId"), + "ClassType": "sql", + } + try: + resp = client.udb().describe_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "CheckUDBInstanceToHAAllowanceResponse"), + ("str_eq", "Allowance", "Yes"), + ], + action="CheckUDBInstanceToHAAllowance", +) +def check_udb_instance_to_ha_allowance_12(client, variables): + d = {"Region": variables.get("Region"), "DBId": variables.get("DBId")} + try: + resp = client.udb().check_udb_instance_to_ha_allowance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribePromoteToHAPriceResponse"), + ], + action="DescribePromoteToHAPrice", +) +def describe_promote_to_ha_price_13(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.invoke("DescribePromoteToHAPrice", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "PromoteUDBInstanceToHAResponse"), + ], + action="PromoteUDBInstanceToHA", +) +def promote_udb_instance_to_ha_14(client, variables): + d = {"Region": variables.get("Region"), "DBId": variables.get("DBId")} + try: + resp = client.udb().promote_udb_instance_to_ha(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=10, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeUDBInstanceStateResponse"), + ("str_eq", "State", "WaitForSwitch"), + ], + action="DescribeUDBInstanceState", +) +def describe_udb_instance_state_15(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().describe_udb_instance_state(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=10, + startup_delay=20, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "SwitchUDBInstanceToHAResponse"), + ], + action="SwitchUDBInstanceToHA", +) +def switch_udb_instance_to_ha_16(client, variables): + d = {"Region": variables.get("Region"), "DBId": variables.get("DBId")} + try: + resp = client.udb().switch_udb_instance_to_ha(d) + except exc.RetCodeException as e: + resp = e.json() + variables["HADBId"] = utest.value_at_path(resp, "DBId") + return resp + + +@scenario.step( + max_retries=30, + retry_interval=10, + startup_delay=60, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ( + "str_eq", + "DataSet.0.Name", + funcs.concat(variables.get("DBName"), variables.get("DBTypeId")), + ), + ("str_eq", "DataSet.0.VirtualIP", variables.get("VirtualIP")), + ("str_eq", "DataSet.0.State", "Running"), + ], + action="DescribeUDBInstance", +) +def describe_udb_instance_17(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + "DBId": variables.get("HADBId"), + "ClassType": "sql", + } + try: + resp = client.udb().describe_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=60, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "StopUDBInstanceResponse"), + ], + action="StopUDBInstance", +) +def stop_udb_instance_18(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("HADBId"), + } + try: + resp = client.udb().stop_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=6, + retry_interval=10, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeUDBInstanceResponse"), + ("str_eq", "DataSet.0.State", "Shutoff"), + ], + action="DescribeUDBInstance", +) +def describe_udb_instance_19(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + "DBId": variables.get("HADBId"), + "ClassType": "sql", + } + try: + resp = client.udb().describe_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DeleteUDBInstanceResponse"), + ], + action="DeleteUDBInstance", +) +def delete_udb_instance_20(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("HADBId"), + } + try: + resp = client.udb().delete_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_2117.py b/tests/test_services/test_set_2117.py new file mode 100644 index 0000000..1aa89a0 --- /dev/null +++ b/tests/test_services/test_set_2117.py @@ -0,0 +1,272 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(2117) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_2117(client, variables): + scenario.initial(variables) + scenario.variables["ResourceType"] = "single" + scenario.variables["ConfigId"] = "9a891891-c245-4b66-bce8-67e59430d67c" + scenario.variables["Name"] = "single_memcache" + scenario.variables["Protocol"] = "memcache" + scenario.variables["Count"] = 1 + scenario.run(client) + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "CreateUMemcacheGroupResponse"), + ], + action="CreateUMemcacheGroup", +) +def create_umem_cache_group_00(client, variables): + d = { + "Zone": variables.get("Zone"), + "Size": 1, + "Region": variables.get("Region"), + "Quantity": 1, + "Name": variables.get("Name"), + "ConfigId": variables.get("ConfigId"), + "ChargeType": "Month", + } + try: + resp = client.umem().create_umem_cache_group(d) + except exc.RetCodeException as e: + resp = e.json() + variables["group_id"] = utest.value_at_path(resp, "GroupId") + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "CheckUMemcacheAllowanceResponse"), + ], + action="CheckUMemcacheAllowance", +) +def check_umem_cache_allowance_01(client, variables): + d = { + "Zone": variables.get("Zone"), + "Size": 1, + "Region": variables.get("Region"), + "Count": variables.get("Count"), + } + try: + resp = client.invoke("CheckUMemcacheAllowance", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=10, + startup_delay=20, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.State", "Running"), + ], + action="DescribeUMem", +) +def describe_umem_02(client, variables): + d = { + "ResourceId": variables.get("group_id"), + "Region": variables.get("Region"), + "Protocol": variables.get("Protocol"), + "Offset": 0, + "Limit": 1000, + } + try: + resp = client.invoke("DescribeUMem", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=100, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeUMemcacheGroupResponse"), + ], + action="DescribeUMemcacheGroup", +) +def describe_umem_cache_group_03(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + "GroupId": variables.get("group_id"), + } + try: + resp = client.umem().describe_umem_cache_group(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="ResizeUMemcacheGroup", +) +def resize_umem_cache_group_04(client, variables): + d = { + "Size": 2, + "Region": variables.get("Region"), + "GroupId": variables.get("group_id"), + } + try: + resp = client.invoke("ResizeUMemcacheGroup", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=10, + startup_delay=3, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.State", "Running"), + ], + action="DescribeUMem", +) +def describe_umem_05(client, variables): + d = { + "ResourceId": variables.get("group_id"), + "Region": variables.get("Region"), + "Protocol": variables.get("Protocol"), + "Offset": 0, + "Limit": 1000, + } + try: + resp = client.invoke("DescribeUMem", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="RestartUMemcacheGroup", +) +def restart_umem_cache_group_06(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "GroupId": variables.get("group_id"), + } + try: + resp = client.umem().restart_umem_cache_group(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=10, + startup_delay=60, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.State", "Running"), + ], + action="DescribeUMem", +) +def describe_umem_07(client, variables): + d = { + "ResourceId": variables.get("group_id"), + "Region": variables.get("Region"), + "Protocol": variables.get("Protocol"), + "Offset": 0, + "Limit": 1000, + } + try: + resp = client.invoke("DescribeUMem", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DeleteUMemcacheGroupResponse"), + ], + action="DeleteUMemcacheGroup", +) +def delete_umem_cache_group_08(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "GroupId": variables.get("group_id"), + } + try: + resp = client.umem().delete_umem_cache_group(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeUMemResponse"), + ("object_not_contains", "DataSet", variables.get("group_id")), + ], + action="DescribeUMem", +) +def describe_umem_09(client, variables): + d = { + "ResourceId": variables.get("group_id"), + "Region": variables.get("Region"), + "Protocol": variables.get("Protocol"), + "Offset": 0, + "Limit": 100, + } + try: + resp = client.invoke("DescribeUMem", d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_2174.py b/tests/test_services/test_set_2174.py new file mode 100644 index 0000000..68bb219 --- /dev/null +++ b/tests/test_services/test_set_2174.py @@ -0,0 +1,302 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(2174) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_2174(client, variables): + scenario.initial(variables) + scenario.variables["ConfigId"] = "03f58ca9-b64d-4bdd-abc7-c6b9a46fd801" + scenario.variables["Password"] = "Z3VhbmxpeXVhbm1pbWE=" + scenario.variables["HighAvailability"] = "disable" + scenario.variables["Version"] = 3.2 + scenario.variables["Protocol"] = "redis" + scenario.variables["ResourceType"] = "single" + scenario.variables["Name"] = "single_redis" + scenario.run(client) + + +@scenario.step( + max_retries=50, + retry_interval=10, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateURedisGroup", +) +def create_uredis_group_00(client, variables): + d = { + "Zone": variables.get("Zone"), + "Version": variables.get("Version"), + "Size": 1, + "Region": variables.get("Region"), + "Quantity": 1, + "Protocol": variables.get("Protocol"), + "Name": variables.get("Name"), + "HighAvailability": variables.get("HighAvailability"), + "ConfigId": variables.get("ConfigId"), + "ChargeType": "Month", + "BackupTime": 3, + "AutoBackup": "enable", + } + try: + resp = client.umem().create_uredis_group(d) + except exc.RetCodeException as e: + resp = e.json() + variables["group_id"] = utest.value_at_path(resp, "GroupId") + return resp + + +@scenario.step( + max_retries=30, + retry_interval=10, + startup_delay=20, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.State", "Running"), + ], + action="DescribeUMem", +) +def describe_umem_01(client, variables): + d = { + "ResourceType": variables.get("ResourceType"), + "ResourceId": variables.get("group_id"), + "Region": variables.get("Region"), + "Protocol": variables.get("Protocol"), + "Offset": 0, + "Limit": 1000, + } + try: + resp = client.invoke("DescribeUMem", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=10, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "CheckURedisAllowanceResponse"), + ], + action="CheckURedisAllowance", +) +def check_uredis_allowance_02(client, variables): + d = { + "Zone": variables.get("Zone"), + "SlaveZone": variables.get("Zone"), + "Size": 1, + "Region": variables.get("Region"), + "Count": 1, + } + try: + resp = client.invoke("CheckURedisAllowance", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "CreateURedisBackupResponse"), + ], + action="CreateURedisBackup", +) +def create_uredis_backup_03(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "GroupId": variables.get("group_id"), + "BackupName": "backup_Redis", + } + try: + resp = client.invoke("CreateURedisBackup", d) + except exc.RetCodeException as e: + resp = e.json() + variables["backup_id"] = utest.value_at_path(resp, "BackupId") + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.State", "Running"), + ], + action="DescribeUMem", +) +def describe_umem_04(client, variables): + d = { + "ResourceType": variables.get("ResourceType"), + "ResourceId": variables.get("group_id"), + "Region": variables.get("Region"), + "Protocol": variables.get("Protocol"), + "Offset": 0, + "Limit": 1000, + } + try: + resp = client.invoke("DescribeUMem", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeURedisBackupStateResponse"), + ], + action="DescribeURedisBackupState", +) +def describe_uredis_backup_state_05(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "GroupId": variables.get("group_id"), + "BackupId": variables.get("backup_id"), + } + try: + resp = client.invoke("DescribeURedisBackupState", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeURedisBackupResponse"), + ], + action="DescribeURedisBackup", +) +def describe_uredis_backup_06(client, variables): + d = {"Region": variables.get("Region")} + try: + resp = client.umem().describe_uredis_backup(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeURedisBackupURLResponse"), + ], + action="DescribeURedisBackupURL", +) +def describe_uredis_backup_url_07(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "BackupId": variables.get("backup_id"), + } + try: + resp = client.umem().describe_uredis_backup_url(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DeleteURedisBackupResponse"), + ], + action="DeleteURedisBackup", +) +def delete_uredis_backup_08(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "BackupId": variables.get("backup_id"), + } + try: + resp = client.invoke("DeleteURedisBackup", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=15, + retry_interval=5, + startup_delay=30, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DeleteURedisGroupResponse"), + ], + action="DeleteURedisGroup", +) +def delete_uredis_group_09(client, variables): + d = { + "Region": variables.get("Region"), + "GroupId": variables.get("group_id"), + } + try: + resp = client.umem().delete_uredis_group(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeURedisGroupResponse"), + ("object_not_contains", "DataSet", variables.get("group_id")), + ], + action="DescribeURedisGroup", +) +def describe_uredis_group_10(client, variables): + d = { + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + "GroupId": variables.get("group_id"), + } + try: + resp = client.umem().describe_uredis_group(d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_227.py b/tests/test_services/test_set_227.py new file mode 100644 index 0000000..541c251 --- /dev/null +++ b/tests/test_services/test_set_227.py @@ -0,0 +1,199 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(227) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_227(client, variables): + scenario.initial(variables) + scenario.run(client) + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateULB", +) +def create_ulb_00(client, variables): + d = { + "ULBName": "测试", + "Tag": "Default", + "Region": variables.get("Region"), + "OuterMode": "Yes", + "InnerMode": "No", + } + try: + resp = client.ulb().create_ulb(d) + except exc.RetCodeException as e: + resp = e.json() + variables["ULBId_outer"] = utest.value_at_path(resp, "ULBId") + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 4107)], + action="CreateVServer", +) +def create_vserver_01(client, variables): + d = { + "VServerName": "vserver-http", + "ULBId": variables.get("ULBId_outer"), + "Region": variables.get("Region"), + "Protocol": "HTTP", + "PersistenceType": "ServerInsert", + "Method": "Roundrobin", + "ListenType": "RequestProxy", + "FrontendPort": 80, + } + try: + resp = client.ulb().create_vserver(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeVServer", +) +def describe_vserver_02(client, variables): + d = { + "ULBId": variables.get("ULBId_outer"), + "Region": variables.get("Region"), + } + try: + resp = client.ulb().describe_vserver(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 4107)], + action="CreateVServer", +) +def create_vserver_03(client, variables): + d = { + "VServerName": "vserver-https", + "ULBId": variables.get("ULBId_outer"), + "Region": variables.get("Region"), + "Protocol": "HTTPS", + "PersistenceType": "UserDefined", + "PersistenceInfo": "huangchao", + "Method": "Source", + "ListenType": "RequestProxy", + "FrontendPort": 443, + "ClientTimeout": 60, + } + try: + resp = client.ulb().create_vserver(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeVServer", +) +def describe_vserver_04(client, variables): + d = { + "ULBId": variables.get("ULBId_outer"), + "Region": variables.get("Region"), + } + try: + resp = client.ulb().describe_vserver(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=20, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 4107)], + action="CreateVServer", +) +def create_vserver_05(client, variables): + d = { + "VServerName": "vserver-https", + "ULBId": variables.get("ULBId_outer"), + "Region": variables.get("Region"), + "Protocol": "TCP", + "PersistenceType": "None", + "Method": "Source", + "ListenType": "RequestProxy", + "FrontendPort": 1024, + } + try: + resp = client.ulb().create_vserver(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeVServer", +) +def describe_vserver_06(client, variables): + d = { + "ULBId": variables.get("ULBId_outer"), + "Region": variables.get("Region"), + } + try: + resp = client.ulb().describe_vserver(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=10, + fast_fail=False, + action="DeleteULB", +) +def delete_ulb_07(client, variables): + d = { + "ULBId": variables.get("ULBId_outer"), + "Region": variables.get("Region"), + } + try: + resp = client.ulb().delete_ulb(d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_230.py b/tests/test_services/test_set_230.py new file mode 100644 index 0000000..8cc36f5 --- /dev/null +++ b/tests/test_services/test_set_230.py @@ -0,0 +1,322 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(230) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_230(client, variables): + scenario.initial(variables) + scenario.variables["sbw_name"] = "sbw_api_auto" + scenario.variables["sbw_chargetype"] = "Month" + scenario.variables["sbw_bw"] = 20 + scenario.variables["resize_bw"] = 22 + scenario.variables["Region"] = "cn-bj2" + scenario.variables["eip_operatorname"] = "Bgp" + scenario.variables["eip_bw"] = 2 + scenario.run(client) + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="AllocateShareBandwidth", +) +def allocate_share_bandwidth_00(client, variables): + d = { + "ShareBandwidth": variables.get("sbw_bw"), + "Region": variables.get("Region"), + "Name": variables.get("sbw_name"), + "ChargeType": variables.get("sbw_chargetype"), + } + try: + resp = client.unet().allocate_share_bandwidth(d) + except exc.RetCodeException as e: + resp = e.json() + variables["sbw_id"] = utest.value_at_path(resp, "ShareBandwidthId") + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="AllocateEIP", +) +def allocate_eip_01(client, variables): + d = { + "Region": variables.get("Region"), + "PayMode": "Traffic", + "OperatorName": variables.get("eip_operatorname"), + "Name": "eip_auto", + "ChargeType": "Month", + "Bandwidth": variables.get("eip_bw"), + } + try: + resp = client.unet().allocate_eip(d) + except exc.RetCodeException as e: + resp = e.json() + variables["eip_id"] = utest.value_at_path(resp, "EIPSet.0.EIPId") + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=30, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="AssociateEIPWithShareBandwidth", +) +def associate_eip_with_share_bandwidth_02(client, variables): + d = { + "ShareBandwidthId": variables.get("sbw_id"), + "Region": variables.get("Region"), + "EIPIds": [variables.get("eip_id")], + } + try: + resp = client.unet().associate_eip_with_share_bandwidth(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("gt", "TotalPrice", 0), + ], + action="DescribeShareBandwidthPrice", +) +def describe_share_bandwidth_price_03(client, variables): + d = { + "ShareBandwidth": variables.get("sbw_bw"), + "Region": variables.get("Region"), + "Quantity": 1, + "ChargeType": variables.get("sbw_chargetype"), + } + try: + resp = client.invoke("DescribeShareBandwidthPrice", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.ShareBandwidthId", variables.get("sbw_id")), + ("str_eq", "DataSet.0.ShareBandwidth", variables.get("sbw_bw")), + ("str_eq", "DataSet.0.ChargeType", variables.get("sbw_chargetype")), + ("str_eq", "DataSet.0.Name", variables.get("sbw_name")), + ("str_eq", "TotalCount", 1), + ("str_eq", "DataSet.0.EIPSet.0.EIPId", variables.get("eip_id")), + ], + action="DescribeShareBandwidth", +) +def describe_share_bandwidth_04(client, variables): + d = { + "ShareBandwidthIds": [variables.get("sbw_id")], + "Region": variables.get("Region"), + } + try: + resp = client.unet().describe_share_bandwidth(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="ResizeShareBandwidth", +) +def resize_share_bandwidth_05(client, variables): + d = { + "ShareBandwidthId": variables.get("sbw_id"), + "ShareBandwidth": variables.get("resize_bw"), + "Region": variables.get("Region"), + } + try: + resp = client.unet().resize_share_bandwidth(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.ShareBandwidth", variables.get("resize_bw")), + ], + action="DescribeShareBandwidth", +) +def describe_share_bandwidth_06(client, variables): + d = { + "ShareBandwidthIds": [variables.get("sbw_id")], + "Region": variables.get("Region"), + } + try: + resp = client.unet().describe_share_bandwidth(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "EIPSet.0.BandwidthType", 1), + ("str_eq", "EIPSet.0.PayMode", "ShareBandwidth"), + ], + action="DescribeEIP", +) +def describe_eip_07(client, variables): + d = { + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + "EIPIds": [variables.get("eip_id")], + } + try: + resp = client.unet().describe_eip(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DisassociateEIPWithShareBandwidth", +) +def disassociate_eip_with_share_bandwidth_08(client, variables): + d = { + "ShareBandwidthId": variables.get("sbw_id"), + "Region": variables.get("Region"), + "EIPIds": [variables.get("eip_id")], + "Bandwidth": variables.get("eip_bw"), + } + try: + resp = client.unet().disassociate_eip_with_share_bandwidth(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=10, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "EIPSet.0.BandwidthType", 0), + ("str_eq", "EIPSet.0.PayMode", "Bandwidth"), + ], + action="DescribeEIP", +) +def describe_eip_09(client, variables): + d = { + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + "EIPIds": [variables.get("eip_id")], + } + try: + resp = client.unet().describe_eip(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("gt", "Info.BwOutSum", 0), + ("gt", "Info.BwOutShareSum", 0), + ("gt", "Info.BwOutAll", 0), + ], + action="GetBandwidthSum", +) +def get_bandwidth_sum_10(client, variables): + d = {"Region": variables.get("Region")} + try: + resp = client.invoke("GetBandwidthSum", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=0, + fast_fail=False, + action="ReleaseEIP", +) +def release_eip_11(client, variables): + d = {"Region": variables.get("Region"), "EIPId": variables.get("eip_id")} + try: + resp = client.unet().release_eip(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=3, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="ReleaseShareBandwidth", +) +def release_share_bandwidth_12(client, variables): + d = { + "ShareBandwidthId": variables.get("sbw_id"), + "Region": variables.get("Region"), + "EIPBandwidth": 2, + } + try: + resp = client.unet().release_share_bandwidth(d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_2377.py b/tests/test_services/test_set_2377.py new file mode 100644 index 0000000..5bbc8b2 --- /dev/null +++ b/tests/test_services/test_set_2377.py @@ -0,0 +1,439 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(2377) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_2377(client, variables): + scenario.initial(variables) + scenario.variables["Password"] = "YW4mODE1MDI5" + scenario.variables["Type"] = "GPU-2080-V5" + scenario.variables["ModifyName"] = "TestName" + scenario.variables["ModifyRemark"] = "TestRemark" + scenario.variables["Cluster"] = "10G" + scenario.variables["Raid"] = "NoRaid" + scenario.run(client) + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribePHostImageResponse"), + ], + action="DescribePHostImage", +) +def describe_phost_image_00(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "ImageType": "Base", + } + try: + resp = client.uphost().describe_phost_image(d) + except exc.RetCodeException as e: + resp = e.json() + variables["ImageID1"] = utest.value_at_path(resp, "ImageSet.0.ImageId") + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribePHostMachineTypeResponse"), + ], + action="DescribePHostMachineType", +) +def describe_phost_machine_type_01(client, variables): + d = {"Zone": variables.get("Zone"), "Region": variables.get("Region")} + try: + resp = client.invoke("DescribePHostMachineType", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribePHostResourceInfoResponse"), + ], + action="DescribePHostResourceInfo", +) +def describe_phost_resource_info_02(client, variables): + d = {"Zone": variables.get("Zone"), "Region": variables.get("Region")} + try: + resp = client.invoke("DescribePHostResourceInfo", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=10, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "CreatePHostResponse"), + ], + action="CreatePHost", +) +def create_phost_03(client, variables): + d = { + "Zone": variables.get("Zone"), + "Type": variables.get("Type"), + "Region": variables.get("Region"), + "Raid": variables.get("Raid"), + "Password": variables.get("Password"), + "ImageId": variables.get("ImageID1"), + "Cluster": variables.get("Cluster"), + } + try: + resp = client.uphost().create_phost(d) + except exc.RetCodeException as e: + resp = e.json() + variables["phostId"] = utest.value_at_path(resp, "PHostId.0") + return resp + + +@scenario.step( + max_retries=120, + retry_interval=30, + startup_delay=20, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribePHostResponse"), + ("str_eq", "PHostSet.0.PMStatus", "Running"), + ], + action="DescribePHost", +) +def describe_phost_04(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "PHostId": [variables.get("phostId")], + } + try: + resp = client.uphost().describe_phost(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "GetPHostKVMInfoResponse"), + ], + action="GetPHostKVMInfo", +) +def get_phost_kvm_info_05(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "PHostId": variables.get("phostId"), + } + try: + resp = client.invoke("GetPHostKVMInfo", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "ModifyPHostInfoResponse"), + ], + action="ModifyPHostInfo", +) +def modify_phost_info_06(client, variables): + d = { + "Zone": variables.get("Zone"), + "Remark": variables.get("ModifyRemark"), + "Region": variables.get("Region"), + "PHostId": variables.get("phostId"), + "Name": variables.get("ModifyName"), + } + try: + resp = client.uphost().modify_phost_info(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribePHostResponse"), + ("str_eq", "PHostSet.0.Name", variables.get("ModifyName")), + ("str_eq", "PHostSet.0.Remark", variables.get("ModifyRemark")), + ], + action="DescribePHost", +) +def describe_phost_07(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "PHostId": [variables.get("phostId")], + } + try: + resp = client.uphost().describe_phost(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=10, + startup_delay=10, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "StopPHostResponse"), + ], + action="StopPHost", +) +def stop_phost_08(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "PHostId": variables.get("phostId"), + } + try: + resp = client.invoke("StopPHost", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=30, + startup_delay=10, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribePHostResponse"), + ("str_eq", "PHostSet.0.PMStatus", "Stopped"), + ], + action="DescribePHost", +) +def describe_phost_09(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "PHostId": [variables.get("phostId")], + } + try: + resp = client.uphost().describe_phost(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "ReinstallPHostResponse"), + ], + action="ReinstallPHost", +) +def reinstall_phost_10(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Password": variables.get("Password"), + "PHostId": variables.get("phostId"), + "ImageId": variables.get("ImageID1"), + } + try: + resp = client.uphost().reinstall_phost(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=120, + retry_interval=60, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribePHostResponse"), + ("str_eq", "PHostSet.0.PMStatus", "Running"), + ], + action="DescribePHost", +) +def describe_phost_11(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "PHostId": [variables.get("phostId")], + } + try: + resp = client.uphost().describe_phost(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "PoweroffPHostResponse"), + ], + action="PoweroffPHost", +) +def poweroff_phost_12(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "PHostId": variables.get("phostId"), + } + try: + resp = client.uphost().poweroff_phost(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=120, + retry_interval=60, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribePHostResponse"), + ("str_eq", "PHostSet.0.PMStatus", "Stopped"), + ], + action="DescribePHost", +) +def describe_phost_13(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "PHostId": [variables.get("phostId")], + } + try: + resp = client.uphost().describe_phost(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=120, + retry_interval=30, + startup_delay=20, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "StartPHostResponse"), + ], + action="StartPHost", +) +def start_phost_14(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "PHostId": variables.get("phostId"), + } + try: + resp = client.uphost().start_phost(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=120, + retry_interval=30, + startup_delay=20, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribePHostResponse"), + ("str_eq", "PHostSet.0.PMStatus", "Running"), + ], + action="DescribePHost", +) +def describe_phost_15(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "PHostId": [variables.get("phostId")], + } + try: + resp = client.uphost().describe_phost(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=10, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "TerminatePHostResponse"), + ], + action="TerminatePHost", +) +def terminate_phost_16(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "PHostId": variables.get("phostId"), + } + try: + resp = client.uphost().terminate_phost(d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_242.py b/tests/test_services/test_set_242.py new file mode 100644 index 0000000..688e06d --- /dev/null +++ b/tests/test_services/test_set_242.py @@ -0,0 +1,292 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(242) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_242(client, variables): + scenario.initial(variables) + scenario.variables["Region"] = "cn-bj2" + scenario.variables["Zone"] = "cn-bj2-02" + scenario.run(client) + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeURedisPrice", +) +def describe_uredis_price_00(client, variables): + d = { + "Zone": variables.get("Zone"), + "Size": 1, + "Region": variables.get("Region"), + "Quantity": 1, + "ChargeType": "Month", + } + try: + resp = client.umem().describe_uredis_price(d) + except exc.RetCodeException as e: + resp = e.json() + variables["GetPrice"] = utest.value_at_path(resp, "DataSet.0.Price") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateURedisGroup", +) +def create_uredis_group_01(client, variables): + d = { + "Zone": variables.get("Zone"), + "Size": 1, + "Region": variables.get("Region"), + "Quantity": 1, + "Protocol": "redis", + "Name": "Redis_zb", + "HighAvailability": "disable", + "ChargeType": "Month", + } + try: + resp = client.umem().create_uredis_group(d) + except exc.RetCodeException as e: + resp = e.json() + variables["group_id"] = utest.value_at_path(resp, "GroupId") + return resp + + +@scenario.step( + max_retries=30, + retry_interval=10, + startup_delay=120, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.State", "Running"), + ], + action="DescribeUMem", +) +def describe_umem_02(client, variables): + d = { + "ResourceType": "single", + "ResourceId": variables.get("group_id"), + "Region": variables.get("Region"), + "Protocol": "redis", + } + try: + resp = client.invoke("DescribeUMem", d) + except exc.RetCodeException as e: + resp = e.json() + variables["CreateTime"] = utest.value_at_path(resp, "DataSet.0.CreateTime") + return resp + + +@scenario.step( + max_retries=5, + retry_interval=1, + startup_delay=100, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("float_eq", "OrderInfos.0.Amount", variables.get("GetPrice") / 100), + ], + action="DescribeOrderDetailInfo", +) +def describe_order_detail_info_03(client, variables): + d = { + "ResourceIds": [variables.get("group_id")], + "QueryAll": True, + "OrderTypes": ["OT_BUY"], + "OrderStates": ["OS_FINISHED"], + "EndTime": funcs.get_timestamp(10), + "BeginTime": funcs.get_timestamp(10) - 1200, + } + try: + resp = client.invoke("DescribeOrderDetailInfo", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeURedisUpgradePrice", +) +def describe_uredis_upgrade_price_04(client, variables): + d = { + "Zone": variables.get("Zone"), + "Size": 2, + "Region": variables.get("Region"), + "GroupId": variables.get("group_id"), + } + try: + resp = client.umem().describe_uredis_upgrade_price(d) + except exc.RetCodeException as e: + resp = e.json() + variables["UpgradePrice"] = utest.value_at_path(resp, "Price") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=2, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="ResizeURedisGroup", +) +def resize_uredis_group_05(client, variables): + d = { + "Size": 2, + "Region": variables.get("Region"), + "GroupId": variables.get("group_id"), + } + try: + resp = client.umem().resize_uredis_group(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=5, + retry_interval=1, + startup_delay=100, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ( + "lt", + "OrderInfos.0.Amount", + variables.get("UpgradePrice") / 100 + 0.1, + ), + ( + "gt", + "OrderInfos.0.Amount", + variables.get("UpgradePrice") / 100 - 0.1, + ), + ], + action="DescribeOrderDetailInfo", +) +def describe_order_detail_info_06(client, variables): + d = { + "ResourceIds": [variables.get("group_id")], + "QueryAll": True, + "OrderTypes": ["OT_UPGRADE"], + "OrderStates": ["OS_FINISHED"], + "EndTime": funcs.get_timestamp(10), + "ChargeTypes": ["Month"], + "BeginTime": funcs.get_timestamp(10) - 1200, + } + try: + resp = client.invoke("DescribeOrderDetailInfo", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=2, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="GetResourceRenewPrice", +) +def get_resource_renew_price_07(client, variables): + d = { + "ResourceIds": [variables.get("group_id")], + "Quantity": 1, + "ChargeType": "Month", + } + try: + resp = client.invoke("GetResourceRenewPrice", d) + except exc.RetCodeException as e: + resp = e.json() + variables["ReNewPrice"] = utest.value_at_path(resp, "RenewPriceSet.0.Price") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=2, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateRenew", +) +def create_renew_08(client, variables): + d = { + "ResourceId": variables.get("group_id"), + "Quantity": 1, + "ChargeType": "Month", + } + try: + resp = client.invoke("CreateRenew", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=60, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "OrderInfos.0.Amount", variables.get("ReNewPrice")) + ], + action="DescribeOrderDetailInfo", +) +def describe_order_detail_info_09(client, variables): + d = { + "ResourceIds": [variables.get("group_id")], + "QueryAll": True, + "OrderTypes": ["OT_RENEW"], + "OrderStates": ["OS_FINISHED"], + "EndTime": funcs.get_timestamp(10), + "ChargeTypes": ["Month"], + "BeginTime": funcs.get_timestamp(10) - 1200, + } + try: + resp = client.invoke("DescribeOrderDetailInfo", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=2, + fast_fail=False, + action="DeleteURedisGroup", +) +def delete_uredis_group_10(client, variables): + d = { + "Region": variables.get("Region"), + "GroupId": variables.get("group_id"), + } + try: + resp = client.umem().delete_uredis_group(d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_245.py b/tests/test_services/test_set_245.py new file mode 100644 index 0000000..e826a8f --- /dev/null +++ b/tests/test_services/test_set_245.py @@ -0,0 +1,295 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(245) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_245(client, variables): + scenario.initial(variables) + scenario.variables["Region"] = "cn-bj2" + scenario.variables["Zone"] = "cn-bj2-02" + scenario.run(client) + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateUMemSpace", +) +def create_umem_space_00(client, variables): + d = { + "Zone": variables.get("Zone"), + "Type": "double", + "Size": 16, + "Region": variables.get("Region"), + "Quantity": 1, + "Protocol": "redis", + "Name": "Redis_fbs", + "ChargeType": "Month", + } + try: + resp = client.umem().create_umem_space(d) + except exc.RetCodeException as e: + resp = e.json() + variables["Space_Id"] = utest.value_at_path(resp, "SpaceId") + return resp + + +@scenario.step( + max_retries=20, + retry_interval=10, + startup_delay=50, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUMem", +) +def describe_umem_01(client, variables): + d = { + "ResourceId": variables.get("Space_Id"), + "Region": variables.get("Region"), + "Protocol": "redis", + } + try: + resp = client.invoke("DescribeUMem", d) + except exc.RetCodeException as e: + resp = e.json() + variables["CreateTime"] = utest.value_at_path(resp, "DataSet.0.CreateTime") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUMemPrice", +) +def describe_umem_price_02(client, variables): + d = { + "Zone": variables.get("Zone"), + "Type": "double", + "Size": 16, + "Region": variables.get("Region"), + "Quantity": 1, + "ChargeType": "Month", + } + try: + resp = client.umem().describe_umem_price(d) + except exc.RetCodeException as e: + resp = e.json() + variables["GetPrice"] = utest.value_at_path(resp, "DataSet.0.Price") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=60, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("le", "OrderInfos.0.Amount", variables.get("GetPrice") / 100 + 0.6), + ("gt", "OrderInfos.0.Amount", variables.get("GetPrice") / 100 - 0.6), + ], + action="DescribeOrderDetailInfo", +) +def describe_order_detail_info_03(client, variables): + d = { + "ResourceIds": [variables.get("Space_Id")], + "QueryAll": True, + "OrderTypes": ["OT_BUY"], + "OrderStates": ["OS_FINISHED"], + "EndTime": funcs.get_timestamp(10), + "ChargeTypes": ["Month"], + "BeginTime": funcs.get_timestamp(10) - 1200, + } + try: + resp = client.invoke("DescribeOrderDetailInfo", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUMemUpgradePrice", +) +def describe_umem_upgrade_price_04(client, variables): + d = { + "Zone": variables.get("Zone"), + "Type": "double", + "SpaceId": variables.get("Space_Id"), + "Size": 18, + "Region": variables.get("Region"), + } + try: + resp = client.umem().describe_umem_upgrade_price(d) + except exc.RetCodeException as e: + resp = e.json() + variables["UpgradePrice"] = utest.value_at_path(resp, "Price") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="ResizeUMemSpace", +) +def resize_umem_space_05(client, variables): + d = { + "Zone": variables.get("Zone"), + "SpaceId": variables.get("Space_Id"), + "Size": 18, + "Region": variables.get("Region"), + } + try: + resp = client.umem().resize_umem_space(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=60, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ( + "lt", + "OrderInfos.0.Amount", + variables.get("UpgradePrice") / 100 + 0.1, + ), + ( + "gt", + "OrderInfos.0.Amount", + variables.get("UpgradePrice") / 100 - 0.1, + ), + ], + action="DescribeOrderDetailInfo", +) +def describe_order_detail_info_06(client, variables): + d = { + "ResourceIds": [variables.get("Space_Id")], + "QueryAll": True, + "OrderTypes": ["OT_UPGRADE"], + "OrderStates": ["OS_FINISHED"], + "EndTime": funcs.get_timestamp(10), + "ChargeTypes": ["Month"], + "BeginTime": funcs.get_timestamp(10) - 1200, + } + try: + resp = client.invoke("DescribeOrderDetailInfo", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=2, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="GetResourceRenewPrice", +) +def get_resource_renew_price_07(client, variables): + d = { + "ResourceIds": [variables.get("Space_Id")], + "Quantity": 1, + "ChargeType": "Month", + } + try: + resp = client.invoke("GetResourceRenewPrice", d) + except exc.RetCodeException as e: + resp = e.json() + variables["ReNewPrice"] = utest.value_at_path(resp, "RenewPriceSet.0.Price") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=2, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateRenew", +) +def create_renew_08(client, variables): + d = { + "ResourceId": variables.get("Space_Id"), + "Quantity": 1, + "ChargeType": "Month", + } + try: + resp = client.invoke("CreateRenew", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=60, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "OrderInfos.0.Amount", variables.get("ReNewPrice")), + ], + action="DescribeOrderDetailInfo", +) +def describe_order_detail_info_09(client, variables): + d = { + "ResourceIds": [variables.get("Space_Id")], + "QueryAll": True, + "OrderTypes": ["OT_RENEW"], + "OrderStates": ["OS_FINISHED"], + "EndTime": funcs.get_timestamp(10), + "ChargeTypes": ["Month"], + "BeginTime": funcs.get_timestamp(10) - 1200, + } + try: + resp = client.invoke("DescribeOrderDetailInfo", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=2, + fast_fail=False, + action="DeleteUMemSpace", +) +def delete_umem_space_10(client, variables): + d = { + "Zone": variables.get("Zone"), + "SpaceId": variables.get("Space_Id"), + "Region": variables.get("Region"), + } + try: + resp = client.umem().delete_umem_space(d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_2457.py b/tests/test_services/test_set_2457.py new file mode 100644 index 0000000..4123529 --- /dev/null +++ b/tests/test_services/test_set_2457.py @@ -0,0 +1,569 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(2457) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_2457(client, variables): + scenario.initial(variables) + scenario.run(client) + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateVPC", +) +def create_vpc_00(client, variables): + d = { + "Region": variables.get("Region"), + "Network": ["192.168.0.0/16"], + "Name": "ulb-ssl-vpc", + } + try: + resp = client.vpc().create_vpc(d) + except exc.RetCodeException as e: + resp = e.json() + variables["vpc_id"] = utest.value_at_path(resp, "VPCId") + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateSubnet", +) +def create_subnet_01(client, variables): + d = { + "VPCId": variables.get("vpc_id"), + "SubnetName": "ulb-ssl-subnet", + "Subnet": "192.168.111.0", + "Region": variables.get("Region"), + } + try: + resp = client.vpc().create_subnet(d) + except exc.RetCodeException as e: + resp = e.json() + variables["subnet_id"] = utest.value_at_path(resp, "SubnetId") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateULB", +) +def create_ulb_02(client, variables): + d = { + "VPCId": variables.get("vpc_id"), + "ULBName": "ulb-ssl-test", + "Tag": "Default", + "SubnetId": variables.get("subnet_id"), + "Region": variables.get("Region"), + "InnerMode": "No", + "ChargeType": "Dynamic", + } + try: + resp = client.ulb().create_ulb(d) + except exc.RetCodeException as e: + resp = e.json() + variables["ULBId"] = utest.value_at_path(resp, "ULBId") + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=30, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateVServer", +) +def create_vserver_03(client, variables): + d = { + "VServerName": "vserver-test", + "ULBId": variables.get("ULBId"), + "Region": variables.get("Region"), + "Protocol": "HTTPS", + "PersistenceType": "UserDefined", + "PersistenceInfo": "huangchao", + "Method": "Roundrobin", + "ListenType": "RequestProxy", + "FrontendPort": 443, + "ClientTimeout": 60, + } + try: + resp = client.ulb().create_vserver(d) + except exc.RetCodeException as e: + resp = e.json() + variables["VServerId"] = utest.value_at_path(resp, "VServerId") + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateSSL", +) +def create_ssl_04(client, variables): + d = { + "UserCert": """-----BEGIN CERTIFICATE----- +MIIFzTCCBLWgAwIBAgIQQ8IswmAhEIKfNhrKqb0F3DANBgkqhkiG9w0BAQsFADCB +lzELMAkGA1UEBhMCQ04xJTAjBgNVBAoTHFRydXN0QXNpYSBUZWNobm9sb2dpZXMs +IEluYy4xHzAdBgNVBAsTFlN5bWFudGVjIFRydXN0IE5ldHdvcmsxHTAbBgNVBAsT +FERvbWFpbiBWYWxpZGF0ZWQgU1NMMSEwHwYDVQQDExhUcnVzdEFzaWEgRFYgU1NM +IENBIC0gRzUwHhcNMTYxMjA2MDAwMDAwWhcNMTcxMjA2MjM1OTU5WjAgMR4wHAYD +VQQDDBVtLmVjb2xvZ3ktZW1vYmlsZS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IB +DwAwggEKAoIBAQDxBsuwGdCZdEUs40SQcvUt+9hlmLTgcfkq/h9f1QVPxLq/PC+O +sG76hOgy6N8f7k7x5XgtPKi9O4ydFl8ViYhEXRjYQcUrTm3lu7s9UT2AIUmK0dI+ +PZgFU5gDwh8fQLoL24T2lPfkD9TngCnDanfo3xbx/e9hsJkf7hKWix8zrxtYYCUT +t96pTpQeWjr7ggl2bDEfTayJNM+i5xoGBPiQFdxPnKWCjNmXi2dws0d2whi1euRW +gI5wIXji5WKfUf6EvzG0Uzz6i8vsSLGv8pL7C0AuUI4MrPNDesFeA2LEYclQkpHE +E49BkpQvCokCW9d8/r5ASUry+7SrJIncU6FxAgMBAAGjggKJMIIChTAgBgNVHREE +GTAXghVtLmVjb2xvZ3ktZW1vYmlsZS5jb20wCQYDVR0TBAIwADBhBgNVHSAEWjBY +MFYGBmeBDAECATBMMCMGCCsGAQUFBwIBFhdodHRwczovL2Quc3ltY2IuY29tL2Nw +czAlBggrBgEFBQcCAjAZDBdodHRwczovL2Quc3ltY2IuY29tL3JwYTAfBgNVHSME +GDAWgBRtWMd/GufhPy6mjJc1Qrv00zisPzAOBgNVHQ8BAf8EBAMCBaAwHQYDVR0l +BBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMIGbBggrBgEFBQcBAQSBjjCBizA8Bggr +BgEFBQcwAYYwaHR0cDovL3RydXN0YXNpYTItb2NzcC5kaWdpdGFsY2VydHZhbGlk +YXRpb24uY29tMEsGCCsGAQUFBzAChj9odHRwOi8vdHJ1c3Rhc2lhMi1haWEuZGln +aXRhbGNlcnR2YWxpZGF0aW9uLmNvbS90cnVzdGFzaWFnNS5jcnQwggEDBgorBgEE +AdZ5AgQCBIH0BIHxAO8AdQDd6x0reg1PpiCLga2BaHB+Lo6dAdVciI09EcTNtuy+ +zAAAAVjT7zdSAAAEAwBGMEQCIDCzWufc1q7hjmrrCetGyoA8EsEqpRSIhmZXStX5 +8b7zAiA6x5aAaDK+yMyeAgw71yi3tRVrWayHN+W0+4BxC8u5UQB2AO5Lvbd1zmC6 +4UJpH6vhnmajD35fsHLYgwDEe4l6qP3LAAABWNPvN4kAAAQDAEcwRQIgZ/LNgg7n +7AE4O2yZkrXNcqAOmJ3NU2nT6zcnBxPFTTsCIQCjyPbMfWMZTD3kxgxPQ1COw5zJ +sM0dfNmSr3MiU7EhqDANBgkqhkiG9w0BAQsFAAOCAQEAeyfgUhg9ZWVCaz0f+BQU +6fMMfmQ1BDzvVFu+ORoAqyJQogxwIdfjrlz/63YFee5qpUsW/aaz4ma3bb4dpE1K +GsgYe5N3o0xybYlOj+KB61sufYkzQS3HgDevCwjfUlGEbNl4dpO2xh5s5AANXlnz +s/X0+AJ33/bm+fWIjAbIjluaEoM6GETHTXi4Tlxy0j3nsXsB9tIIUibAdTtButef +JJRnikGRN+eHjrsLYe0RUmdKOQz1ik6teHt0MQX0aCe8OlXeyGDd9m8u7+y0nAnH +TVaNuT7vXMWyyXLVUcV898wkBo3Bo3hUiaw0QR0ttgDrf5ZwqPfqpytRW2K5GMZT +uw== +-----END CERTIFICATE----- + + +-----BEGIN CERTIFICATE----- +MIIFZTCCBE2gAwIBAgIQOhAOfxCeGsWcxf/2QNXkQjANBgkqhkiG9w0BAQsFADCB +yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL +ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJp +U2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxW +ZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0 +aG9yaXR5IC0gRzUwHhcNMTYwODExMDAwMDAwWhcNMjYwODEwMjM1OTU5WjCBlzEL +MAkGA1UEBhMCQ04xJTAjBgNVBAoTHFRydXN0QXNpYSBUZWNobm9sb2dpZXMsIElu +Yy4xHzAdBgNVBAsTFlN5bWFudGVjIFRydXN0IE5ldHdvcmsxHTAbBgNVBAsTFERv +bWFpbiBWYWxpZGF0ZWQgU1NMMSEwHwYDVQQDExhUcnVzdEFzaWEgRFYgU1NMIENB +IC0gRzUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC39aSJZG/97x3a +6Qmuc9+MubagegRAVUmFYHTYTs8IKB2pM7wXN7W8mekdZaEgUjDFxvRBK/DhTb7U +8ONLsKKdT86aOhzbz2noCTn9wPWnGwkg+/4YKg/dPQQdV9tMsSu0cwqInWHxSAkm +AI1hYFC9D7Sf7Hp/5cRcD+dK454YMRzNOGLQnCVI8JEqrz6o9SOvQNTqTcfqt6DC +0UlXG+MPD1eNPjlzf1Vwaab+VSTgySoC+Ikbq2VsdykeOiGXW/OIiASH7+2LcR05 +PmQ7GEOlM8yzoVojFpM8sHz+WxI05ZOPri5+vX3HhHHjWr5432G0dVmgohnZvlVZ +oy8XrlbpAgMBAAGjggF2MIIBcjASBgNVHRMBAf8ECDAGAQH/AgEAMC8GA1UdHwQo +MCYwJKAioCCGHmh0dHA6Ly9zLnN5bWNiLmNvbS9wY2EzLWc1LmNybDAOBgNVHQ8B +Af8EBAMCAQYwLgYIKwYBBQUHAQEEIjAgMB4GCCsGAQUFBzABhhJodHRwOi8vcy5z +eW1jZC5jb20wYQYDVR0gBFowWDBWBgZngQwBAgEwTDAjBggrBgEFBQcCARYXaHR0 +cHM6Ly9kLnN5bWNiLmNvbS9jcHMwJQYIKwYBBQUHAgIwGRoXaHR0cHM6Ly9kLnN5 +bWNiLmNvbS9ycGEwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMCkGA1Ud +EQQiMCCkHjAcMRowGAYDVQQDExFTeW1hbnRlY1BLSS0yLTYwMTAdBgNVHQ4EFgQU +bVjHfxrn4T8upoyXNUK79NM4rD8wHwYDVR0jBBgwFoAUf9Nlp8Ld7LvwMAnzQzn6 +Aq8zMTMwDQYJKoZIhvcNAQELBQADggEBABUphhBbeG7scE3EveIN0dOjXPgwgQi8 +I2ZAKYm6DawoGz1lEJVdvFmkyMbP973X80b7mKmn0nNbe1kjA4M0O0hHaMM1ZaEv +7e9vHEAoGyysMO6HzPWYMkyNxcCV7Nos2Uv4RvLDpQHh7P4Kt6fUU13ipcynrtQD +1lFUM0yoTzwwFsPu3Pk+94hL58ErqwqJQwxoHMgLIQeMVHeNKcWFy1bddSbIbCWU +Zs6cMxhrra062ZCpDCbxyEaFNGAtYQMqNz55Z/14XgSUONZ/cJTns6QKhpcgTOwB +fnNzRnk+aWreP7osKhXlz4zs+llP7goBDKFOMMtoEXx3YjJCKgpqmBU= +-----END CERTIFICATE-----""", + "SSLName": "证书-1", + "Region": variables.get("Region"), + "PrivateKey": "abc", + "CaCert": """-----BEGIN RSA PRIVATE KEY----- +MIIEowIBAAKCAQEA8QbLsBnQmXRFLONEkHL1LfvYZZi04HH5Kv4fX9UFT8S6vzwv +jrBu+oToMujfH+5O8eV4LTyovTuMnRZfFYmIRF0Y2EHFK05t5bu7PVE9gCFJitHS +Pj2YBVOYA8IfH0C6C9uE9pT35A/U54Apw2p36N8W8f3vYbCZH+4SlosfM68bWGAl +E7feqU6UHlo6+4IJdmwxH02siTTPoucaBgT4kBXcT5ylgozZl4tncLNHdsIYtXrk +VoCOcCF44uVin1H+hL8xtFM8+ovL7Eixr/KS+wtALlCODKzzQ3rBXgNixGHJUJKR +xBOPQZKULwqJAlvXfP6+QElK8vu0qySJ3FOhcQIDAQABAoIBAAPvZnfzk/JNcauv +8jihh9s+V2QhQCLB+Z14FK8N3U5WGe5xXx1nSAiTDu912d69l1BfvLyQVvjv9fXC +nb7ORglHs9YkDMIOP8EWdZIkt2pWIMtBbbtSah78JGk7TCLIfcEfzmXwPLPehk1Z +TFVCcb69lbRRvwzLQ1TAIFGQ5+uCEkW02KAl6kx+JnVpsE8/BjqZKG1Ne+sM6dOC +GRd44hgiNHKUT3Xtbw6jttiUFDLKYMYtb7PpRAkZFM8tgnBV6dWWJ3xTYW9kOjPh +XnScNARfphUZVibRhA04og5p1q/MUz9Sz9g2DURuSlo/MP3WZMbVRvZiUN1xhz5v +2WhsddkCgYEA+gWPFo0TbVbZXUrx9J/ptI9NXNx5zjyUrv87MDt1pnmMDgWrsCEI +RqQR4Lp2G11GA7IudiA/ipcZqgcRIIFvb+gu1kObox3BGGs59x+DqFeAPXt6dFG2 +W10f9k96/tcbdursurqwd3Zv3cqQqRTKgaP4xHFmexlcwGCF5YwewWMCgYEA9sos +2acNINXwcNRUPnpg82DOrG9Zjr1aiNo9PDJmwGEdC9QMOUWM85dq0M9g388ttiLU +Wr/U4r5yDuqWJPcKtff2BaxSsZpcQ4Id9eddD9L+sxaBGyD23RtOC+IOlkG6WS4g +iUYulQvW69tBHWiwxQu7YMSIE2B3EuySPOQYlBsCgYEAxNwvqB/4lfT2PUDPdj+b +cnILBf0LY1nL8GZCol2O6z91CW1pm8rGi2iQMxRd/nnYsPxRHO2TWnpS2M+rqp5/ +settRYQCPdMlwSZcg7oqnhgXf1GEP6Y/IX0Xt4cpXxLcKywarYRlggqdVlMyyA74 +zE7hhzuK5442u7rEctN7O+UCgYAoM78ipafp1XAZsT0YAG+Stg504J7CNe5tpL+c +8sjyRd+pcZ2cJsxTUjNAWMf7LZDQvtPBBMb1OPjznRtgYi4IfqBBRFUkQXUOOkAP +MuViEokTO3NErBYK5svL+8NMjuCAbpc2RYyJEyiru0fcNpW1Q7f+h4VzQp+jIY6h +BLdMSQKBgGauU7OQksZCEY2MVAcD5dShYYvWLxOkj4dVVwISN1M6ImCAHwXZ6Nak +6YlzCGT+NbRJbB2cPfsrKXtAJVX15I3iDCKAoGkb+9kiHnPj7Q71KVuWQE6BQx7E +vE88TSsshwtX1s+qU9UWUrMPodK32q5nO3p8N033NvS9wLNfbcdc +-----END RSA PRIVATE KEY-----""", + } + try: + resp = client.ulb().create_ssl(d) + except exc.RetCodeException as e: + resp = e.json() + variables["SSLId_01"] = utest.value_at_path(resp, "SSLId") + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateSSL", +) +def create_ssl_05(client, variables): + d = { + "UserCert": """-----BEGIN CERTIFICATE----- +MIIFzTCCBLWgAwIBAgIQQ8IswmAhEIKfNhrKqb0F3DANBgkqhkiG9w0BAQsFADCB +lzELMAkGA1UEBhMCQ04xJTAjBgNVBAoTHFRydXN0QXNpYSBUZWNobm9sb2dpZXMs +IEluYy4xHzAdBgNVBAsTFlN5bWFudGVjIFRydXN0IE5ldHdvcmsxHTAbBgNVBAsT +FERvbWFpbiBWYWxpZGF0ZWQgU1NMMSEwHwYDVQQDExhUcnVzdEFzaWEgRFYgU1NM +IENBIC0gRzUwHhcNMTYxMjA2MDAwMDAwWhcNMTcxMjA2MjM1OTU5WjAgMR4wHAYD +VQQDDBVtLmVjb2xvZ3ktZW1vYmlsZS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IB +DwAwggEKAoIBAQDxBsuwGdCZdEUs40SQcvUt+9hlmLTgcfkq/h9f1QVPxLq/PC+O +sG76hOgy6N8f7k7x5XgtPKi9O4ydFl8ViYhEXRjYQcUrTm3lu7s9UT2AIUmK0dI+ +PZgFU5gDwh8fQLoL24T2lPfkD9TngCnDanfo3xbx/e9hsJkf7hKWix8zrxtYYCUT +t96pTpQeWjr7ggl2bDEfTayJNM+i5xoGBPiQFdxPnKWCjNmXi2dws0d2whi1euRW +gI5wIXji5WKfUf6EvzG0Uzz6i8vsSLGv8pL7C0AuUI4MrPNDesFeA2LEYclQkpHE +E49BkpQvCokCW9d8/r5ASUry+7SrJIncU6FxAgMBAAGjggKJMIIChTAgBgNVHREE +GTAXghVtLmVjb2xvZ3ktZW1vYmlsZS5jb20wCQYDVR0TBAIwADBhBgNVHSAEWjBY +MFYGBmeBDAECATBMMCMGCCsGAQUFBwIBFhdodHRwczovL2Quc3ltY2IuY29tL2Nw +czAlBggrBgEFBQcCAjAZDBdodHRwczovL2Quc3ltY2IuY29tL3JwYTAfBgNVHSME +GDAWgBRtWMd/GufhPy6mjJc1Qrv00zisPzAOBgNVHQ8BAf8EBAMCBaAwHQYDVR0l +BBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMIGbBggrBgEFBQcBAQSBjjCBizA8Bggr +BgEFBQcwAYYwaHR0cDovL3RydXN0YXNpYTItb2NzcC5kaWdpdGFsY2VydHZhbGlk +YXRpb24uY29tMEsGCCsGAQUFBzAChj9odHRwOi8vdHJ1c3Rhc2lhMi1haWEuZGln +aXRhbGNlcnR2YWxpZGF0aW9uLmNvbS90cnVzdGFzaWFnNS5jcnQwggEDBgorBgEE +AdZ5AgQCBIH0BIHxAO8AdQDd6x0reg1PpiCLga2BaHB+Lo6dAdVciI09EcTNtuy+ +zAAAAVjT7zdSAAAEAwBGMEQCIDCzWufc1q7hjmrrCetGyoA8EsEqpRSIhmZXStX5 +8b7zAiA6x5aAaDK+yMyeAgw71yi3tRVrWayHN+W0+4BxC8u5UQB2AO5Lvbd1zmC6 +4UJpH6vhnmajD35fsHLYgwDEe4l6qP3LAAABWNPvN4kAAAQDAEcwRQIgZ/LNgg7n +7AE4O2yZkrXNcqAOmJ3NU2nT6zcnBxPFTTsCIQCjyPbMfWMZTD3kxgxPQ1COw5zJ +sM0dfNmSr3MiU7EhqDANBgkqhkiG9w0BAQsFAAOCAQEAeyfgUhg9ZWVCaz0f+BQU +6fMMfmQ1BDzvVFu+ORoAqyJQogxwIdfjrlz/63YFee5qpUsW/aaz4ma3bb4dpE1K +GsgYe5N3o0xybYlOj+KB61sufYkzQS3HgDevCwjfUlGEbNl4dpO2xh5s5AANXlnz +s/X0+AJ33/bm+fWIjAbIjluaEoM6GETHTXi4Tlxy0j3nsXsB9tIIUibAdTtButef +JJRnikGRN+eHjrsLYe0RUmdKOQz1ik6teHt0MQX0aCe8OlXeyGDd9m8u7+y0nAnH +TVaNuT7vXMWyyXLVUcV898wkBo3Bo3hUiaw0QR0ttgDrf5ZwqPfqpytRW2K5GMZT +uw== +-----END CERTIFICATE----- + + +-----BEGIN CERTIFICATE----- +MIIFZTCCBE2gAwIBAgIQOhAOfxCeGsWcxf/2QNXkQjANBgkqhkiG9w0BAQsFADCB +yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL +ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJp +U2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxW +ZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0 +aG9yaXR5IC0gRzUwHhcNMTYwODExMDAwMDAwWhcNMjYwODEwMjM1OTU5WjCBlzEL +MAkGA1UEBhMCQ04xJTAjBgNVBAoTHFRydXN0QXNpYSBUZWNobm9sb2dpZXMsIElu +Yy4xHzAdBgNVBAsTFlN5bWFudGVjIFRydXN0IE5ldHdvcmsxHTAbBgNVBAsTFERv +bWFpbiBWYWxpZGF0ZWQgU1NMMSEwHwYDVQQDExhUcnVzdEFzaWEgRFYgU1NMIENB +IC0gRzUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC39aSJZG/97x3a +6Qmuc9+MubagegRAVUmFYHTYTs8IKB2pM7wXN7W8mekdZaEgUjDFxvRBK/DhTb7U +8ONLsKKdT86aOhzbz2noCTn9wPWnGwkg+/4YKg/dPQQdV9tMsSu0cwqInWHxSAkm +AI1hYFC9D7Sf7Hp/5cRcD+dK454YMRzNOGLQnCVI8JEqrz6o9SOvQNTqTcfqt6DC +0UlXG+MPD1eNPjlzf1Vwaab+VSTgySoC+Ikbq2VsdykeOiGXW/OIiASH7+2LcR05 +PmQ7GEOlM8yzoVojFpM8sHz+WxI05ZOPri5+vX3HhHHjWr5432G0dVmgohnZvlVZ +oy8XrlbpAgMBAAGjggF2MIIBcjASBgNVHRMBAf8ECDAGAQH/AgEAMC8GA1UdHwQo +MCYwJKAioCCGHmh0dHA6Ly9zLnN5bWNiLmNvbS9wY2EzLWc1LmNybDAOBgNVHQ8B +Af8EBAMCAQYwLgYIKwYBBQUHAQEEIjAgMB4GCCsGAQUFBzABhhJodHRwOi8vcy5z +eW1jZC5jb20wYQYDVR0gBFowWDBWBgZngQwBAgEwTDAjBggrBgEFBQcCARYXaHR0 +cHM6Ly9kLnN5bWNiLmNvbS9jcHMwJQYIKwYBBQUHAgIwGRoXaHR0cHM6Ly9kLnN5 +bWNiLmNvbS9ycGEwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMCkGA1Ud +EQQiMCCkHjAcMRowGAYDVQQDExFTeW1hbnRlY1BLSS0yLTYwMTAdBgNVHQ4EFgQU +bVjHfxrn4T8upoyXNUK79NM4rD8wHwYDVR0jBBgwFoAUf9Nlp8Ld7LvwMAnzQzn6 +Aq8zMTMwDQYJKoZIhvcNAQELBQADggEBABUphhBbeG7scE3EveIN0dOjXPgwgQi8 +I2ZAKYm6DawoGz1lEJVdvFmkyMbP973X80b7mKmn0nNbe1kjA4M0O0hHaMM1ZaEv +7e9vHEAoGyysMO6HzPWYMkyNxcCV7Nos2Uv4RvLDpQHh7P4Kt6fUU13ipcynrtQD +1lFUM0yoTzwwFsPu3Pk+94hL58ErqwqJQwxoHMgLIQeMVHeNKcWFy1bddSbIbCWU +Zs6cMxhrra062ZCpDCbxyEaFNGAtYQMqNz55Z/14XgSUONZ/cJTns6QKhpcgTOwB +fnNzRnk+aWreP7osKhXlz4zs+llP7goBDKFOMMtoEXx3YjJCKgpqmBU= +-----END CERTIFICATE-----""", + "SSLName": "证书-2", + "Region": variables.get("Region"), + "PrivateKey": "abc", + "CaCert": """-----BEGIN RSA PRIVATE KEY----- +MIIEowIBAAKCAQEA8QbLsBnQmXRFLONEkHL1LfvYZZi04HH5Kv4fX9UFT8S6vzwv +jrBu+oToMujfH+5O8eV4LTyovTuMnRZfFYmIRF0Y2EHFK05t5bu7PVE9gCFJitHS +Pj2YBVOYA8IfH0C6C9uE9pT35A/U54Apw2p36N8W8f3vYbCZH+4SlosfM68bWGAl +E7feqU6UHlo6+4IJdmwxH02siTTPoucaBgT4kBXcT5ylgozZl4tncLNHdsIYtXrk +VoCOcCF44uVin1H+hL8xtFM8+ovL7Eixr/KS+wtALlCODKzzQ3rBXgNixGHJUJKR +xBOPQZKULwqJAlvXfP6+QElK8vu0qySJ3FOhcQIDAQABAoIBAAPvZnfzk/JNcauv +8jihh9s+V2QhQCLB+Z14FK8N3U5WGe5xXx1nSAiTDu912d69l1BfvLyQVvjv9fXC +nb7ORglHs9YkDMIOP8EWdZIkt2pWIMtBbbtSah78JGk7TCLIfcEfzmXwPLPehk1Z +TFVCcb69lbRRvwzLQ1TAIFGQ5+uCEkW02KAl6kx+JnVpsE8/BjqZKG1Ne+sM6dOC +GRd44hgiNHKUT3Xtbw6jttiUFDLKYMYtb7PpRAkZFM8tgnBV6dWWJ3xTYW9kOjPh +XnScNARfphUZVibRhA04og5p1q/MUz9Sz9g2DURuSlo/MP3WZMbVRvZiUN1xhz5v +2WhsddkCgYEA+gWPFo0TbVbZXUrx9J/ptI9NXNx5zjyUrv87MDt1pnmMDgWrsCEI +RqQR4Lp2G11GA7IudiA/ipcZqgcRIIFvb+gu1kObox3BGGs59x+DqFeAPXt6dFG2 +W10f9k96/tcbdursurqwd3Zv3cqQqRTKgaP4xHFmexlcwGCF5YwewWMCgYEA9sos +2acNINXwcNRUPnpg82DOrG9Zjr1aiNo9PDJmwGEdC9QMOUWM85dq0M9g388ttiLU +Wr/U4r5yDuqWJPcKtff2BaxSsZpcQ4Id9eddD9L+sxaBGyD23RtOC+IOlkG6WS4g +iUYulQvW69tBHWiwxQu7YMSIE2B3EuySPOQYlBsCgYEAxNwvqB/4lfT2PUDPdj+b +cnILBf0LY1nL8GZCol2O6z91CW1pm8rGi2iQMxRd/nnYsPxRHO2TWnpS2M+rqp5/ +settRYQCPdMlwSZcg7oqnhgXf1GEP6Y/IX0Xt4cpXxLcKywarYRlggqdVlMyyA74 +zE7hhzuK5442u7rEctN7O+UCgYAoM78ipafp1XAZsT0YAG+Stg504J7CNe5tpL+c +8sjyRd+pcZ2cJsxTUjNAWMf7LZDQvtPBBMb1OPjznRtgYi4IfqBBRFUkQXUOOkAP +MuViEokTO3NErBYK5svL+8NMjuCAbpc2RYyJEyiru0fcNpW1Q7f+h4VzQp+jIY6h +BLdMSQKBgGauU7OQksZCEY2MVAcD5dShYYvWLxOkj4dVVwISN1M6ImCAHwXZ6Nak +6YlzCGT+NbRJbB2cPfsrKXtAJVX15I3iDCKAoGkb+9kiHnPj7Q71KVuWQE6BQx7E +vE88TSsshwtX1s+qU9UWUrMPodK32q5nO3p8N033NvS9wLNfbcdc +-----END RSA PRIVATE KEY-----""", + } + try: + resp = client.ulb().create_ssl(d) + except exc.RetCodeException as e: + resp = e.json() + variables["SSLId_02"] = utest.value_at_path(resp, "SSLId") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.SSLId", variables.get("SSLId_01")), + ], + action="DescribeSSL", +) +def describe_ssl_06(client, variables): + d = {"SSLId": variables.get("SSLId_01"), "Region": variables.get("Region")} + try: + resp = client.ulb().describe_ssl(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.SSLId", variables.get("SSLId_02")), + ], + action="DescribeSSL", +) +def describe_ssl_07(client, variables): + d = {"SSLId": variables.get("SSLId_02"), "Region": variables.get("Region")} + try: + resp = client.ulb().describe_ssl(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="BindSSL", +) +def bind_ssl_08(client, variables): + d = { + "VServerId": variables.get("VServerId"), + "ULBId": variables.get("ULBId"), + "SSLId": variables.get("SSLId_01"), + "Region": variables.get("Region"), + } + try: + resp = client.ulb().bind_ssl(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=30, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="UpdateSSLBinding", +) +def update_ssl_binding_09(client, variables): + d = { + "VServerId": variables.get("VServerId"), + "ULBId": variables.get("ULBId"), + "Region": variables.get("Region"), + "OldSSLId": variables.get("SSLId_01"), + "NewSSLId": variables.get("SSLId_02"), + } + try: + resp = client.invoke("UpdateSSLBinding", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="UnbindSSL", +) +def unbind_ssl_10(client, variables): + d = { + "VServerId": variables.get("VServerId"), + "ULBId": variables.get("ULBId"), + "SSLId": variables.get("SSLId_02"), + "Region": variables.get("Region"), + } + try: + resp = client.ulb().unbind_ssl(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DeleteSSL", +) +def delete_ssl_11(client, variables): + d = { + "VServerId": variables.get("VServerId"), + "ULBId": variables.get("ULBId"), + "SSLId": variables.get("SSLId_01"), + "Region": variables.get("Region"), + } + try: + resp = client.ulb().delete_ssl(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DeleteSSL", +) +def delete_ssl_12(client, variables): + d = {"SSLId": variables.get("SSLId_02"), "Region": variables.get("Region")} + try: + resp = client.ulb().delete_ssl(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DeleteVServer", +) +def delete_vserver_13(client, variables): + d = { + "VServerId": variables.get("VServerId"), + "ULBId": variables.get("ULBId"), + "Region": variables.get("Region"), + } + try: + resp = client.ulb().delete_vserver(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DeleteULB", +) +def delete_ulb_14(client, variables): + d = {"ULBId": variables.get("ULBId"), "Region": variables.get("Region")} + try: + resp = client.ulb().delete_ulb(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DeleteSubnet", +) +def delete_subnet_15(client, variables): + d = { + "SubnetId": variables.get("subnet_id"), + "Region": variables.get("Region"), + } + try: + resp = client.vpc().delete_subnet(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DeleteVPC", +) +def delete_vpc_16(client, variables): + d = {"VPCId": variables.get("vpc_id"), "Region": variables.get("Region")} + try: + resp = client.vpc().delete_vpc(d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_268.py b/tests/test_services/test_set_268.py new file mode 100644 index 0000000..4f92fa4 --- /dev/null +++ b/tests/test_services/test_set_268.py @@ -0,0 +1,339 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(268) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_268(client, variables): + scenario.initial(variables) + scenario.variables["Region"] = "cn-bj2" + scenario.variables["eip_bw"] = 2 + scenario.variables["bwp1_bw"] = 3 + scenario.variables["eip_operatorname"] = "Bgp" + scenario.variables["bwp2_bw"] = 4 + scenario.variables["Image_Id"] = "#{u_get_image_resource($Region,$Zone)}" + scenario.run(client) + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeImageResponse"), + ], + action="DescribeImage", +) +def describe_image_00(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "OsType": "Linux", + "ImageType": "Base", + } + try: + resp = client.uhost().describe_image(d) + except exc.RetCodeException as e: + resp = e.json() + variables["Image_Id"] = utest.value_at_path(resp, "ImageSet.0.ImageId") + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="AllocateEIP", +) +def allocate_eip_01(client, variables): + d = { + "Region": variables.get("Region"), + "PayMode": "Bandwidth", + "OperatorName": variables.get("eip_operatorname"), + "Name": "eip_auto", + "ChargeType": "Month", + "Bandwidth": variables.get("eip_bw"), + } + try: + resp = client.unet().allocate_eip(d) + except exc.RetCodeException as e: + resp = e.json() + variables["eip_id"] = utest.value_at_path(resp, "EIPSet.0.EIPId") + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("len_ge", "UHostIds", 0), + ], + action="CreateUHostInstance", +) +def create_uhost_instance_02(client, variables): + d = { + "Zone": variables.get("Zone"), + "TimemachineFeature": "No", + "Tag": "Default", + "Region": variables.get("Region"), + "Password": "VXFhNzg5VGVzdCFAIyQ7LA==", + "Name": "packet-s1-bgp", + "Memory": 1024, + "LoginMode": "Password", + "ImageId": variables.get("Image_Id"), + "HotplugFeature": False, + "DiskSpace": 0, + "CPU": 1, + } + try: + resp = client.uhost().create_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + variables["UHostId"] = utest.value_at_path(resp, "UHostIds.0") + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=180, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="BindEIP", +) +def bind_eip_03(client, variables): + d = { + "ResourceType": "uhost", + "ResourceId": variables.get("UHostId"), + "Region": variables.get("Region"), + "EIPId": variables.get("eip_id"), + } + try: + resp = client.unet().bind_eip(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateBandwidthPackage", +) +def create_bandwidth_package_04(client, variables): + d = { + "TimeRange": 2, + "Region": variables.get("Region"), + "EnableTime": 30 + funcs.get_timestamp(10), + "EIPId": variables.get("eip_id"), + "Bandwidth": variables.get("bwp1_bw"), + } + try: + resp = client.unet().create_bandwidth_package(d) + except exc.RetCodeException as e: + resp = e.json() + variables["bwp_id1"] = utest.value_at_path(resp, "BandwidthPackageId") + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=30, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSets.0.EIPId", variables.get("eip_id")), + ("str_eq", "DataSets.0.Bandwidth", variables.get("bwp1_bw")), + ("str_eq", "DataSets.0.BandwidthPackageId", variables.get("bwp_id1")), + ], + action="DescribeBandwidthPackage", +) +def describe_bandwidth_package_05(client, variables): + d = {"Region": variables.get("Region"), "Offset": 0, "Limit": 1} + try: + resp = client.unet().describe_bandwidth_package(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=3, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DeleteBandwidthPackage", +) +def delete_bandwidth_package_06(client, variables): + d = { + "Region": variables.get("Region"), + "BandwidthPackageId": variables.get("bwp_id1"), + } + try: + resp = client.unet().delete_bandwidth_package(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateBandwidthPackage", +) +def create_bandwidth_package_07(client, variables): + d = { + "TimeRange": 1, + "Region": variables.get("Region"), + "EIPId": variables.get("eip_id"), + "Bandwidth": variables.get("bwp2_bw"), + } + try: + resp = client.unet().create_bandwidth_package(d) + except exc.RetCodeException as e: + resp = e.json() + variables["bwp_id2"] = utest.value_at_path(resp, "BandwidthPackageId") + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=30, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSets.0.EIPId", variables.get("eip_id")), + ("str_eq", "DataSets.0.Bandwidth", variables.get("bwp2_bw")), + ("str_eq", "DataSets.0.BandwidthPackageId", variables.get("bwp_id2")), + ], + action="DescribeBandwidthPackage", +) +def describe_bandwidth_package_08(client, variables): + d = {"Region": variables.get("Region"), "Offset": 0, "Limit": 1} + try: + resp = client.unet().describe_bandwidth_package(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=3, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DeleteBandwidthPackage", +) +def delete_bandwidth_package_09(client, variables): + d = { + "Region": variables.get("Region"), + "BandwidthPackageId": variables.get("bwp_id2"), + } + try: + resp = client.unet().delete_bandwidth_package(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="UnBindEIP", +) +def un_bind_eip_10(client, variables): + d = { + "ResourceType": "uhost", + "ResourceId": variables.get("UHostId"), + "Region": variables.get("Region"), + "EIPId": variables.get("eip_id"), + } + try: + resp = client.unet().un_bind_eip(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="ReleaseEIP", +) +def release_eip_11(client, variables): + d = {"Region": variables.get("Region"), "EIPId": variables.get("eip_id")} + try: + resp = client.unet().release_eip(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=5, + fast_fail=False, + action="PoweroffUHostInstance", +) +def poweroff_uhost_instance_12(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("UHostId"), + "Region": variables.get("Region"), + } + try: + resp = client.uhost().poweroff_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=60, + fast_fail=False, + action="TerminateUHostInstance", +) +def terminate_uhost_instance_13(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("UHostId"), + "Region": variables.get("Region"), + } + try: + resp = client.uhost().terminate_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_279.py b/tests/test_services/test_set_279.py new file mode 100644 index 0000000..2c8644a --- /dev/null +++ b/tests/test_services/test_set_279.py @@ -0,0 +1,452 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(279) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_279(client, variables): + scenario.initial(variables) + scenario.variables["Image_Id"] = "#{u_get_image_resource($Region,$Zone)}" + scenario.run(client) + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeImageResponse"), + ], + action="DescribeImage", +) +def describe_image_00(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "OsType": "Linux", + "ImageType": "Base", + } + try: + resp = client.uhost().describe_image(d) + except exc.RetCodeException as e: + resp = e.json() + variables["Image_Id"] = utest.value_at_path(resp, "ImageSet.0.ImageId") + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("len_ge", "UHostIds", 0), + ], + action="CreateUHostInstance", +) +def create_uhost_instance_01(client, variables): + d = { + "Zone": variables.get("Zone"), + "TimemachineFeature": "No", + "Tag": "Default", + "Region": variables.get("Region"), + "Password": "VXFhNzg5VGVzdCFAIyQ7LA==", + "Name": "eip-s1-bgp", + "Memory": 1024, + "LoginMode": "Password", + "ImageId": variables.get("Image_Id"), + "HotplugFeature": False, + "DiskSpace": 0, + "CPU": 1, + } + try: + resp = client.uhost().create_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + variables["UHostId"] = utest.value_at_path(resp, "UHostIds.0") + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=120, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="AllocateEIP", +) +def allocate_eip_02(client, variables): + d = { + "Tag": "Default", + "Remark": "test", + "Region": variables.get("Region"), + "Quantity": 1, + "PayMode": "Bandwidth", + "OperatorName": "Bgp", + "Name": "eip-bgp-01", + "ChargeType": "Dynamic", + "Bandwidth": 2, + } + try: + resp = client.unet().allocate_eip(d) + except exc.RetCodeException as e: + resp = e.json() + variables["EIPId_01"] = utest.value_at_path(resp, "EIPSet.0.EIPId") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "EIPSet.0.EIPId", variables.get("EIPId_01")), + ], + action="DescribeEIP", +) +def describe_eip_03(client, variables): + d = { + "Region": variables.get("Region"), + "EIPIds": [variables.get("EIPId_01")], + } + try: + resp = client.unet().describe_eip(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="UpdateEIPAttribute", +) +def update_eip_attribute_04(client, variables): + d = { + "Tag": "huangchao", + "Remark": "test-gai", + "Region": variables.get("Region"), + "Name": "eip-auto-gai", + "EIPId": variables.get("EIPId_01"), + } + try: + resp = client.unet().update_eip_attribute(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="GetEIPPrice", +) +def get_eip_price_05(client, variables): + d = { + "Region": variables.get("Region"), + "OperatorName": "Bgp", + "Bandwidth": 2, + } + try: + resp = client.unet().get_eip_price(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="BindEIP", +) +def bind_eip_06(client, variables): + d = { + "ResourceType": "uhost", + "ResourceId": variables.get("UHostId"), + "Region": variables.get("Region"), + "EIPId": variables.get("EIPId_01"), + } + try: + resp = client.unet().bind_eip(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "EIPSet.0.Resource.ResourceID", variables.get("UHostId")), + ], + action="DescribeEIP", +) +def describe_eip_07(client, variables): + d = { + "Region": variables.get("Region"), + "EIPIds": [variables.get("EIPId_01")], + } + try: + resp = client.unet().describe_eip(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="ModifyEIPBandwidth", +) +def modify_eip_bandwidth_08(client, variables): + d = { + "Region": variables.get("Region"), + "EIPId": variables.get("EIPId_01"), + "Bandwidth": 3, + } + try: + resp = client.unet().modify_eip_bandwidth(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="SetEIPPayMode", +) +def set_eip_pay_mode_09(client, variables): + d = { + "Region": variables.get("Region"), + "PayMode": "Traffic", + "EIPId": variables.get("EIPId_01"), + "Bandwidth": 2, + } + try: + resp = client.unet().set_eip_pay_mode(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="ModifyEIPWeight", +) +def modify_eip_weight_10(client, variables): + d = { + "Weight": 100, + "Region": variables.get("Region"), + "EIPId": variables.get("EIPId_01"), + } + try: + resp = client.unet().modify_eip_weight(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "UnBindEIPResponse"), + ], + action="UnBindEIP", +) +def un_bind_eip_11(client, variables): + d = { + "ResourceType": "uhost", + "ResourceId": variables.get("UHostId"), + "Region": variables.get("Region"), + "EIPId": variables.get("EIPId_01"), + } + try: + resp = client.unet().un_bind_eip(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="AllocateEIP", +) +def allocate_eip_12(client, variables): + d = { + "Tag": "Default", + "Remark": "test", + "Region": variables.get("Region"), + "Quantity": 1, + "PayMode": "Bandwidth", + "OperatorName": "Bgp", + "Name": "eip-bgp-01", + "ChargeType": "Dynamic", + "Bandwidth": 2, + } + try: + resp = client.unet().allocate_eip(d) + except exc.RetCodeException as e: + resp = e.json() + variables["EIPId_02"] = utest.value_at_path(resp, "EIPSet.0.EIPId") + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("gt", "TotalCount", 1), + ("len_eq", "EIPSet", 1), + ], + action="DescribeEIP", +) +def describe_eip_13(client, variables): + d = {"Region": variables.get("Region"), "Limit": 1} + try: + resp = client.unet().describe_eip(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 8039)], + action="ReleaseEIP", +) +def release_eip_14(client, variables): + d = {"Region": variables.get("Region"), "EIPId": variables.get("EIPId_01")} + try: + resp = client.unet().release_eip(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "TotalCount", 0), + ], + action="DescribeEIP", +) +def describe_eip_15(client, variables): + d = { + "Region": variables.get("Region"), + "EIPIds": [variables.get("EIPId_01")], + } + try: + resp = client.unet().describe_eip(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="ReleaseEIP", +) +def release_eip_16(client, variables): + d = {"Region": variables.get("Region"), "EIPId": variables.get("EIPId_02")} + try: + resp = client.unet().release_eip(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=5, + fast_fail=False, + action="PoweroffUHostInstance", +) +def poweroff_uhost_instance_17(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("UHostId"), + "Region": variables.get("Region"), + } + try: + resp = client.uhost().poweroff_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=60, + fast_fail=False, + action="TerminateUHostInstance", +) +def terminate_uhost_instance_18(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("UHostId"), + "Region": variables.get("Region"), + } + try: + resp = client.uhost().terminate_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_283.py b/tests/test_services/test_set_283.py new file mode 100644 index 0000000..807b2b9 --- /dev/null +++ b/tests/test_services/test_set_283.py @@ -0,0 +1,618 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(283) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_283(client, variables): + scenario.initial(variables) + scenario.variables["HostName"] = "auto_host_test1" + scenario.variables["Password"] = "Z3VhbmxpeXVhbm1pbWExMjMhQCM=" + scenario.variables["ChargeType"] = "Month" + scenario.variables["CreateCPU"] = 1 + scenario.variables["CreateMem"] = 1024 + scenario.variables["ImageId"] = "#{u_get_image_resource($Region,$Zone)}" + scenario.variables["BootSize"] = 20 + scenario.variables["BootType"] = "CLOUD_SSD" + scenario.variables["BootBackup"] = "NONE" + scenario.variables["DiskSize"] = 20 + scenario.variables["DiskType"] = "CLOUD_NORMAL" + scenario.variables["DiskBackup"] = "NONE" + scenario.variables["UHostType"] = "N2" + scenario.variables["UDiskType"] = "DataDisk" + scenario.variables["UDiskName"] = "auto_udisk_noArk" + scenario.variables["UDataArkMode"] = "No" + scenario.variables["Size"] = 1 + scenario.run(client) + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeImageResponse"), + ], + action="DescribeImage", +) +def describe_image_00(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "OsType": "Linux", + "ImageType": "Base", + } + try: + resp = client.uhost().describe_image(d) + except exc.RetCodeException as e: + resp = e.json() + variables["ImageId"] = utest.value_at_path(resp, "ImageSet.0.ImageId") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUDiskPrice", +) +def describe_udisk_price_01(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDataArkMode": variables.get("UDataArkMode"), + "Size": variables.get("Size"), + "Region": variables.get("Region"), + "Quantity": 1, + "DiskType": variables.get("UDiskType"), + "ChargeType": "Month", + } + try: + resp = client.udisk().describe_udisk_price(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CheckUDiskAllowance", +) +def check_udisk_allowance_02(client, variables): + d = { + "Zone": variables.get("Zone"), + "Size": variables.get("Size"), + "Region": variables.get("Region"), + "Count": 1, + } + try: + resp = client.invoke("CheckUDiskAllowance", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=1, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateUDisk", +) +def create_udisk_03(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDataArkMode": variables.get("UDataArkMode"), + "Size": variables.get("Size"), + "Region": variables.get("Region"), + "Quantity": 0, + "Name": variables.get("UDiskName"), + "DiskType": variables.get("UDiskType"), + "ChargeType": "Month", + } + try: + resp = client.udisk().create_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + variables["udisk_noArk_id"] = utest.value_at_path(resp, "UDiskId.0") + return resp + + +@scenario.step( + max_retries=20, + retry_interval=3, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeUDiskResponse"), + ("str_eq", "DataSet.0.Status", "Available"), + ("str_eq", "DataSet.0.Tag", "Default"), + ], + action="DescribeUDisk", +) +def describe_udisk_04(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDiskId": variables.get("udisk_noArk_id"), + "Region": variables.get("Region"), + } + try: + resp = client.udisk().describe_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="RenameUDisk", +) +def rename_udisk_05(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDiskName": funcs.concat("re_", variables.get("UDiskName")), + "UDiskId": variables.get("udisk_noArk_id"), + "Region": variables.get("Region"), + } + try: + resp = client.udisk().rename_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ( + "str_eq", + "DataSet.0.Name", + funcs.concat("re_", variables.get("UDiskName")), + ), + ], + action="DescribeUDisk", +) +def describe_udisk_06(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDiskId": variables.get("udisk_noArk_id"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + } + try: + resp = client.udisk().describe_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeUDiskUpgradePriceResponse"), + ], + action="DescribeUDiskUpgradePrice", +) +def describe_udisk_upgrade_price_07(client, variables): + d = { + "Zone": variables.get("Zone"), + "SourceId": variables.get("udisk_noArk_id"), + "Size": variables.get("Size") + 1, + "Region": variables.get("Region"), + } + try: + resp = client.udisk().describe_udisk_upgrade_price(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "ResizeUDiskResponse"), + ], + action="ResizeUDisk", +) +def resize_udisk_08(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDiskId": variables.get("udisk_noArk_id"), + "Size": variables.get("Size") + 1, + "Region": variables.get("Region"), + } + try: + resp = client.udisk().resize_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeUDiskResponse"), + ("str_eq", "DataSet.0.Size", variables.get("Size") + 1), + ], + action="DescribeUDisk", +) +def describe_udisk_09(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDiskId": variables.get("udisk_noArk_id"), + "Region": variables.get("Region"), + } + try: + resp = client.udisk().describe_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeImageResponse"), + ], + action="DescribeImage", +) +def describe_image_10(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "OsType": "Linux", + "ImageType": "Base", + } + try: + resp = client.uhost().describe_image(d) + except exc.RetCodeException as e: + resp = e.json() + variables["ImageId"] = utest.value_at_path(resp, "ImageSet.0.ImageId") + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "CreateUHostInstanceResponse"), + ], + action="CreateUHostInstance", +) +def create_uhost_instance_11(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostType": variables.get("UHostType"), + "TimemachineFeature": "No", + "Tag": "Default", + "Region": variables.get("Region"), + "Quantity": 1, + "Password": "VGVzdDEyMzRUZXN0MTIzNA==", + "NetCapability": "Normal", + "Name": variables.get("HostName"), + "Memory": variables.get("CreateMem"), + "LoginMode": "Password", + "ImageId": variables.get("ImageId"), + "HotplugFeature": False, + "GPU": False, + "Disks": [ + { + "BackupType": variables.get("BootBackup"), + "IsBoot": True, + "Size": variables.get("BootSize"), + "Type": variables.get("BootType"), + } + ], + "ChargeType": variables.get("ChargeType"), + "CPU": variables.get("CreateCPU"), + } + try: + resp = client.uhost().create_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + variables["uhost_id"] = utest.value_at_path(resp, "UHostIds.0") + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=30, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "UHostSet.0.UHostId", variables.get("uhost_id")), + ], + action="DescribeUHostInstance", +) +def describe_uhost_instance_12(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostIds": [variables.get("uhost_id")], + "Region": variables.get("Region"), + } + try: + resp = client.uhost().describe_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=120, + retry_interval=5, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "UHostSet.0.State", "Running"), + ], + action="DescribeUHostInstance", +) +def describe_uhost_instance_13(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostIds": [variables.get("uhost_id")], + "Region": variables.get("Region"), + } + try: + resp = client.uhost().describe_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=1, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("ne", "TotalCount", 0), + ], + action="DescribeUHostLite", +) +def describe_uhost_lite_14(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 60, + } + try: + resp = client.invoke("DescribeUHostLite", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=60, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="AttachUDisk", +) +def attach_udisk_15(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("uhost_id"), + "UDiskId": variables.get("udisk_noArk_id"), + "Region": variables.get("Region"), + } + try: + resp = client.udisk().attach_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=200, + retry_interval=3, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.Status", "InUse"), + ], + action="DescribeUDisk", +) +def describe_udisk_16(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDiskId": variables.get("udisk_noArk_id"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + } + try: + resp = client.udisk().describe_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "UDiskId", variables.get("udisk_noArk_id")), + ("str_eq", "UHostId", variables.get("uhost_id")), + ], + action="DetachUDisk", +) +def detach_udisk_17(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("uhost_id"), + "UDiskId": variables.get("udisk_noArk_id"), + "Region": variables.get("Region"), + } + try: + resp = client.udisk().detach_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=60, + retry_interval=5, + startup_delay=60, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.Status", "Available"), + ], + action="DescribeUDisk", +) +def describe_udisk_18(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDiskId": variables.get("udisk_noArk_id"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + } + try: + resp = client.udisk().describe_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DeleteUDisk", +) +def delete_udisk_19(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDiskId": variables.get("udisk_noArk_id"), + "Region": variables.get("Region"), + } + try: + resp = client.udisk().delete_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="PoweroffUHostInstance", +) +def poweroff_uhost_instance_20(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("uhost_id"), + "Region": variables.get("Region"), + } + try: + resp = client.uhost().poweroff_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=20, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "UHostSet.0.State", "Stopped"), + ], + action="DescribeUHostInstance", +) +def describe_uhost_instance_21(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostIds": [variables.get("uhost_id")], + "Region": variables.get("Region"), + } + try: + resp = client.uhost().describe_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=3, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="TerminateUHostInstance", +) +def terminate_uhost_instance_22(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("uhost_id"), + "Region": variables.get("Region"), + } + try: + resp = client.uhost().terminate_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_286.py b/tests/test_services/test_set_286.py new file mode 100644 index 0000000..dc7af7b --- /dev/null +++ b/tests/test_services/test_set_286.py @@ -0,0 +1,332 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(286) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_286(client, variables): + scenario.initial(variables) + scenario.variables["UDiskType"] = "DataDisk" + scenario.variables["Size"] = 1 + scenario.variables["UDataArkMode"] = "No" + scenario.variables["UDiskName"] = "auto_udisk_noArk" + scenario.variables["UDiskCloneName"] = "auto_udisk_noArk_Clone" + scenario.run(client) + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUDiskPrice", +) +def describe_udisk_price_00(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDataArkMode": variables.get("UDataArkMode"), + "Size": variables.get("Size"), + "Region": variables.get("Region"), + "Quantity": 1, + "DiskType": variables.get("UDiskType"), + "ChargeType": "Month", + } + try: + resp = client.udisk().describe_udisk_price(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "CheckUDiskAllowanceResponse"), + ], + action="CheckUDiskAllowance", +) +def check_udisk_allowance_01(client, variables): + d = { + "Zone": variables.get("Zone"), + "Size": 10, + "Region": variables.get("Region"), + } + try: + resp = client.invoke("CheckUDiskAllowance", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=1, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateUDisk", +) +def create_udisk_02(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDataArkMode": variables.get("UDataArkMode"), + "Tag": "test", + "Size": variables.get("Size"), + "Region": variables.get("Region"), + "Quantity": 0, + "Name": variables.get("UDiskName"), + "DiskType": variables.get("UDiskType"), + "ChargeType": "Month", + } + try: + resp = client.udisk().create_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + variables["udisk_noArk_id"] = utest.value_at_path(resp, "UDiskId.0") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.Status", "Available"), + ("str_eq", "DataSet.0.Tag", "test"), + ], + action="DescribeUDisk", +) +def describe_udisk_03(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDiskId": variables.get("udisk_noArk_id"), + "Region": variables.get("Region"), + } + try: + resp = client.udisk().describe_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=2, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "CloneUDiskResponse"), + ], + action="CloneUDisk", +) +def clone_udisk_04(client, variables): + d = { + "Zone": variables.get("Zone"), + "SourceId": variables.get("udisk_noArk_id"), + "Region": variables.get("Region"), + "Quantity": 0, + "Name": variables.get("UDiskCloneName"), + "ChargeType": "Month", + } + try: + resp = client.udisk().clone_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + variables["udisk_noArk_id_clone"] = utest.value_at_path(resp, "UDiskId.0") + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUDiskUpgradePrice", +) +def describe_udisk_upgrade_price_05(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDataArkMode": variables.get("UDataArkMode"), + "SourceId": variables.get("udisk_noArk_id"), + "Size": variables.get("Size") + 1, + "Region": variables.get("Region"), + } + try: + resp = client.udisk().describe_udisk_upgrade_price(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=80, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="ResizeUDisk", +) +def resize_udisk_06(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDiskId": variables.get("udisk_noArk_id"), + "Size": variables.get("Size") + 1, + "Region": variables.get("Region"), + } + try: + resp = client.udisk().resize_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.Size", variables.get("Size") + 1), + ], + action="DescribeUDisk", +) +def describe_udisk_07(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDiskId": variables.get("udisk_noArk_id"), + "Region": variables.get("Region"), + } + try: + resp = client.udisk().describe_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=40, + retry_interval=3, + startup_delay=60, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeUDiskResponse"), + ("str_eq", "DataSet.0.Status", "Available"), + ], + action="DescribeUDisk", +) +def describe_udisk_08(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDiskId": variables.get("udisk_noArk_id_clone"), + "Region": variables.get("Region"), + } + try: + resp = client.udisk().describe_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DeleteUDisk", +) +def delete_udisk_09(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDiskId": variables.get("udisk_noArk_id"), + "Region": variables.get("Region"), + } + try: + resp = client.udisk().delete_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=20, + retry_interval=3, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUDisk", +) +def describe_udisk_10(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDiskId": variables.get("udisk_noArk_id"), + "Region": variables.get("Region"), + } + try: + resp = client.udisk().describe_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DeleteUDiskResponse"), + ], + action="DeleteUDisk", +) +def delete_udisk_11(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDiskId": variables.get("udisk_noArk_id_clone"), + "Region": variables.get("Region"), + } + try: + resp = client.udisk().delete_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=20, + retry_interval=3, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUDisk", +) +def describe_udisk_12(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDiskId": variables.get("udisk_noArk_id_clone"), + "Region": variables.get("Region"), + } + try: + resp = client.udisk().describe_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_293.py b/tests/test_services/test_set_293.py new file mode 100644 index 0000000..59cbd9d --- /dev/null +++ b/tests/test_services/test_set_293.py @@ -0,0 +1,616 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(293) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_293(client, variables): + scenario.initial(variables) + scenario.variables["HostName"] = "auto_host_test4" + scenario.variables["Password"] = "Z3VhbmxpeXVhbm1pbWExMjMhQCM=" + scenario.variables["ChargeType"] = "Month" + scenario.variables["CreateCPU"] = 1 + scenario.variables["CreateMem"] = 1024 + scenario.variables["ImageId"] = "#{u_get_image_resource($Region,$Zone)}" + scenario.variables["BootSize"] = 20 + scenario.variables["BootType"] = "CLOUD_SSD" + scenario.variables["BootBackup"] = "NONE" + scenario.variables["DiskSize"] = 20 + scenario.variables["DiskType"] = "CLOUD_NORMAL" + scenario.variables["DiskBackup"] = "NONE" + scenario.variables["UHostType"] = "N2" + scenario.variables["UDiskType"] = "DataDisk" + scenario.variables["UDiskName"] = "auto_udisk_noArk4" + scenario.variables["UDataArkMode"] = "No" + scenario.variables["Size"] = 1 + scenario.run(client) + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUDiskPrice", +) +def describe_udisk_price_00(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDataArkMode": variables.get("UDataArkMode"), + "Size": variables.get("Size"), + "Region": variables.get("Region"), + "Quantity": 1, + "DiskType": variables.get("UDiskType"), + "ChargeType": "Month", + } + try: + resp = client.udisk().describe_udisk_price(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "CheckUDiskAllowanceResponse"), + ], + action="CheckUDiskAllowance", +) +def check_udisk_allowance_01(client, variables): + d = { + "Zone": variables.get("Zone"), + "Size": 100, + "Region": variables.get("Region"), + "Count": 1, + } + try: + resp = client.invoke("CheckUDiskAllowance", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=1, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "CreateUDiskResponse"), + ], + action="CreateUDisk", +) +def create_udisk_02(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDataArkMode": variables.get("UDataArkMode"), + "Size": variables.get("Size"), + "Region": variables.get("Region"), + "Quantity": 0, + "Name": variables.get("UDiskName"), + "DiskType": variables.get("UDiskType"), + "ChargeType": "Month", + } + try: + resp = client.udisk().create_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + variables["udisk_noArk_id"] = utest.value_at_path(resp, "UDiskId.0") + return resp + + +@scenario.step( + max_retries=5, + retry_interval=1, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.Status", "Available"), + ], + action="DescribeUDisk", +) +def describe_udisk_03(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDiskId": variables.get("udisk_noArk_id"), + "Region": variables.get("Region"), + } + try: + resp = client.udisk().describe_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "SetUDiskUDataArkModeResponse"), + ], + action="SetUDiskUDataArkMode", +) +def set_udisk__udataark_mode_04(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDiskId": variables.get("udisk_noArk_id"), + "UDataArkMode": "Yes", + "Region": variables.get("Region"), + } + try: + resp = client.udisk().set_udisk__udataark_mode(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=5, + startup_delay=60, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.UDataArkMode", "Yes"), + ], + action="DescribeUDisk", +) +def describe_udisk_05(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDiskId": variables.get("udisk_noArk_id"), + "Region": variables.get("Region"), + } + try: + resp = client.udisk().describe_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=300, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "CreateUDiskSnapshotResponse"), + ], + action="CreateUDiskSnapshot", +) +def create_udisk_snapshot_06(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDiskId": variables.get("udisk_noArk_id"), + "Region": variables.get("Region"), + "Name": "snapshot_01_Ark", + "Comment": "comment_01_Ark", + } + try: + resp = client.udisk().create_udisk_snapshot(d) + except exc.RetCodeException as e: + resp = e.json() + variables["snapshot_id"] = utest.value_at_path(resp, "SnapshotId.0") + return resp + + +@scenario.step( + max_retries=10, + retry_interval=3, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.SnapshotLimit", 3), + ("str_eq", "DataSet.0.Status", "Available"), + ("str_eq", "DataSet.0.SnapshotCount", 1), + ], + action="DescribeUDisk", +) +def describe_udisk_07(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDiskId": variables.get("udisk_noArk_id"), + "Region": variables.get("Region"), + } + try: + resp = client.udisk().describe_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=20, + retry_interval=3, + startup_delay=20, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeUDiskSnapshotResponse"), + ("str_eq", "DataSet.0.UDiskId", variables.get("udisk_noArk_id")), + ("str_eq", "DataSet.0.Status", "Normal"), + ], + action="DescribeUDiskSnapshot", +) +def describe_udisk_snapshot_08(client, variables): + d = { + "Zone": variables.get("Zone"), + "SnapshotId": variables.get("snapshot_id"), + "Region": variables.get("Region"), + } + try: + resp = client.udisk().describe_udisk_snapshot(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "CloneUDiskSnapshotResponse"), + ], + action="CloneUDiskSnapshot", +) +def clone_udisk_snapshot_09(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDataArkMode": "Yes", + "SourceId": variables.get("snapshot_id"), + "Size": variables.get("Size"), + "Region": variables.get("Region"), + "Quantity": 0, + "Name": "snap1_clone_Ark", + "ChargeType": "Month", + } + try: + resp = client.udisk().clone_udisk_snapshot(d) + except exc.RetCodeException as e: + resp = e.json() + variables["snapClone1_udisk_id"] = utest.value_at_path(resp, "UDiskId.0") + return resp + + +@scenario.step( + max_retries=60, + retry_interval=5, + startup_delay=120, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.Status", "Available"), + ("str_eq", "DataSet.0.Name", "snap1_clone_Ark"), + ], + action="DescribeUDisk", +) +def describe_udisk_10(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDiskId": variables.get("snapClone1_udisk_id"), + "Region": variables.get("Region"), + } + try: + resp = client.udisk().describe_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CloneUDiskSnapshot", +) +def clone_udisk_snapshot_11(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDataArkMode": "No", + "SourceId": variables.get("snapshot_id"), + "Size": variables.get("Size"), + "Region": variables.get("Region"), + "Quantity": 0, + "Name": "snap1_clone_noArk", + "ChargeType": "Month", + } + try: + resp = client.udisk().clone_udisk_snapshot(d) + except exc.RetCodeException as e: + resp = e.json() + variables["snapClone2_udisk_id"] = utest.value_at_path(resp, "UDiskId.0") + return resp + + +@scenario.step( + max_retries=60, + retry_interval=5, + startup_delay=120, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.Status", "Available"), + ("str_eq", "DataSet.0.Name", "snap1_clone_noArk"), + ], + action="DescribeUDisk", +) +def describe_udisk_12(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDiskId": variables.get("snapClone2_udisk_id"), + "Region": variables.get("Region"), + } + try: + resp = client.udisk().describe_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=30, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "RestoreUDiskResponse"), + ], + action="RestoreUDisk", +) +def restore_udisk_13(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDiskId": variables.get("udisk_noArk_id"), + "SnapshotId": variables.get("snapshot_id"), + "Region": variables.get("Region"), + } + try: + resp = client.udisk().restore_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=5, + retry_interval=1, + startup_delay=120, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeUDiskResponse"), + ("str_eq", "DataSet.0.Status", "Available"), + ], + action="DescribeUDisk", +) +def describe_udisk_14(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDiskId": variables.get("udisk_noArk_id"), + "Region": variables.get("Region"), + } + try: + resp = client.udisk().describe_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DeleteSnapshotResponse"), + ("str_eq", "SnapshotId", variables.get("snapshot_id")), + ], + action="DeleteSnapshot", +) +def delete_snapshot_15(client, variables): + d = { + "Zone": variables.get("Zone"), + "SnapshotId": variables.get("snapshot_id"), + "Region": variables.get("Region"), + } + try: + resp = client.invoke("DeleteSnapshot", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=5, + retry_interval=1, + startup_delay=1, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeUDiskSnapshotResponse"), + ("str_eq", "TotalCount", 0), + ], + action="DescribeUDiskSnapshot", +) +def describe_udisk_snapshot_16(client, variables): + d = { + "Zone": variables.get("Zone"), + "SnapshotId": variables.get("snapshot_id"), + "Region": variables.get("Region"), + } + try: + resp = client.udisk().describe_udisk_snapshot(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=2, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.Status", "Available"), + ], + action="DescribeUDisk", +) +def describe_udisk_17(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDiskId": variables.get("udisk_noArk_id"), + "Region": variables.get("Region"), + } + try: + resp = client.udisk().describe_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DeleteUDiskResponse"), + ], + action="DeleteUDisk", +) +def delete_udisk_18(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDiskId": variables.get("udisk_noArk_id"), + "Region": variables.get("Region"), + } + try: + resp = client.udisk().delete_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.Status", "Available"), + ], + action="DescribeUDisk", +) +def describe_udisk_19(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDiskId": variables.get("snapClone1_udisk_id"), + "Region": variables.get("Region"), + } + try: + resp = client.udisk().describe_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DeleteUDiskResponse"), + ], + action="DeleteUDisk", +) +def delete_udisk_20(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDiskId": variables.get("snapClone1_udisk_id"), + "Region": variables.get("Region"), + } + try: + resp = client.udisk().delete_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.Status", "Available"), + ], + action="DescribeUDisk", +) +def describe_udisk_21(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDiskId": variables.get("snapClone2_udisk_id"), + "Region": variables.get("Region"), + } + try: + resp = client.udisk().describe_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=2, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DeleteUDiskResponse"), + ], + action="DeleteUDisk", +) +def delete_udisk_22(client, variables): + d = { + "Zone": variables.get("Zone"), + "UDiskId": variables.get("snapClone2_udisk_id"), + "Region": variables.get("Region"), + } + try: + resp = client.udisk().delete_udisk(d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_2935.py b/tests/test_services/test_set_2935.py new file mode 100644 index 0000000..103c045 --- /dev/null +++ b/tests/test_services/test_set_2935.py @@ -0,0 +1,153 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(2935) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_2935(client, variables): + scenario.initial(variables) + scenario.variables[ + "Image_Id_ucloud" + ] = "#{u_get_image_resource($Region,$Zone)}" + scenario.variables["saopaulo_image"] = "uimage-1bkjka" + scenario.run(client) + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeImageResponse"), + ], + action="DescribeImage", +) +def describe_image_00(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "OsType": "Linux", + "ImageType": "Base", + } + try: + resp = client.uhost().describe_image(d) + except exc.RetCodeException as e: + resp = e.json() + variables["Image_Id_ucloud"] = utest.value_at_path( + resp, "ImageSet.0.ImageId" + ) + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateULB", +) +def create_ulb_01(client, variables): + d = { + "ULBName": "测试", + "Tag": "Default", + "Region": variables.get("Region"), + "InnerMode": "No", + } + try: + resp = client.ulb().create_ulb(d) + except exc.RetCodeException as e: + resp = e.json() + variables["ULBId"] = utest.value_at_path(resp, "ULBId") + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("len_ge", "DataSet", 1), + ], + action="DescribeULBSimple", +) +def describe_ulb_simple_02(client, variables): + d = {"Region": variables.get("Region")} + try: + resp = client.invoke("DescribeULBSimple", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("len_eq", "DataSet", 1), + ], + action="DescribeULBSimple", +) +def describe_ulb_simple_03(client, variables): + d = {"ULBId": variables.get("ULBId"), "Region": variables.get("Region")} + try: + resp = client.invoke("DescribeULBSimple", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=3, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.ULBId", variables.get("ULBId")), + ], + action="DescribeULB", +) +def describe_ulb_04(client, variables): + d = { + "ULBId": variables.get("ULBId"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 60, + } + try: + resp = client.ulb().describe_ulb(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DeleteULB", +) +def delete_ulb_05(client, variables): + d = {"ULBId": variables.get("ULBId"), "Region": variables.get("Region")} + try: + resp = client.ulb().delete_ulb(d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_302.py b/tests/test_services/test_set_302.py new file mode 100644 index 0000000..53ced59 --- /dev/null +++ b/tests/test_services/test_set_302.py @@ -0,0 +1,477 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(302) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_302(client, variables): + scenario.initial(variables) + scenario.variables["tag"] = "tag_api_test" + scenario.variables["remark"] = "remark_api_test" + scenario.variables["fw_name_1"] = funcs.concat( + "fw_A_", funcs.get_timestamp(13), "_" + ) + scenario.variables["fw_rule_1_protocol"] = "TCP" + scenario.variables["fw_rule_1_port"] = 1111 + scenario.variables["fw_rule_1_srcip"] = "0.0.0.0/0" + scenario.variables["fw_rule_1_action"] = "ACCEPT" + scenario.variables["fw_rule_1_priority"] = "HIGH" + scenario.variables["uhost_name_1"] = "firewall_api_test" + scenario.variables["fw_rule_2_protocol"] = "UDP" + scenario.variables["fw_rule_2_port"] = 2222 + scenario.variables["fw_rule_2_srcip"] = "10.0.0.0/8" + scenario.variables["fw_rule_2_action"] = "DROP" + scenario.variables["fw_rule_2_priority"] = "LOW" + scenario.variables["fw_name_2"] = funcs.concat( + "fw_B_", funcs.get_timestamp(13), "_" + ) + scenario.variables["tag_2"] = "tag_api_test_3" + scenario.variables["remark_2"] = "remark_api_test_3" + scenario.variables["Image_Id"] = "#{u_get_image_resource($Region,$Zone)}" + scenario.variables["recommend_web"] = "recommend web" + scenario.variables["fw_rule_1"] = "TCP|1111|0.0.0.0/0|ACCEPT|HIGH" + scenario.variables["fw_rule_2"] = "UDP|2222|10.0.0.0/8|DROP|LOW" + scenario.run(client) + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeImageResponse"), + ], + action="DescribeImage", +) +def describe_image_00(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "OsType": "Linux", + "ImageType": "Base", + } + try: + resp = client.uhost().describe_image(d) + except exc.RetCodeException as e: + resp = e.json() + variables["Image_Id"] = utest.value_at_path(resp, "ImageSet.0.ImageId") + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeFirewall", +) +def describe_firewall_01(client, variables): + d = {"Region": variables.get("Region")} + try: + resp = client.unet().describe_firewall(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateUHostInstance", +) +def create_uhost_instance_02(client, variables): + d = { + "Zone": variables.get("Zone"), + "Tag": variables.get("tag"), + "Region": variables.get("Region"), + "Password": "VXFhNzg5VGVzdCFAIyQ7LA==", + "Name": variables.get("uhost_name_1"), + "Memory": 1024, + "LoginMode": "Password", + "ImageId": variables.get("Image_Id"), + "DiskSpace": 0, + "CPU": 1, + } + try: + resp = client.uhost().create_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + variables["uhost_id1"] = utest.value_at_path(resp, "UHostIds.0") + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=180, + fast_fail=True, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateFirewall", +) +def create_firewall_03(client, variables): + d = { + "Tag": variables.get("tag"), + "Rule": [variables.get("fw_rule_1")], + "Remark": variables.get("remark"), + "Region": variables.get("Region"), + "Name": funcs.concat(variables.get("fw_name_1"), variables.get("Zone")), + } + try: + resp = client.unet().create_firewall(d) + except exc.RetCodeException as e: + resp = e.json() + variables["fw_id1"] = utest.value_at_path(resp, "FWId") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=3, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.FWId", variables.get("fw_id1")), + ( + "str_eq", + "DataSet.0.Name", + funcs.concat(variables.get("fw_name_1"), variables.get("Zone")), + ), + ("str_eq", "DataSet.0.Tag", variables.get("tag")), + ("str_eq", "DataSet.0.Remark", variables.get("remark")), + ("str_eq", "DataSet.0.ResourceCount", 0), + ("str_eq", "DataSet.0.Type", "user defined"), + ( + "str_eq", + "DataSet.0.Rule.0.ProtocolType", + variables.get("fw_rule_1_protocol"), + ), + ("str_eq", "DataSet.0.Rule.0.DstPort", variables.get("fw_rule_1_port")), + ("str_eq", "DataSet.0.Rule.0.SrcIP", variables.get("fw_rule_1_srcip")), + ( + "str_eq", + "DataSet.0.Rule.0.RuleAction", + variables.get("fw_rule_1_action"), + ), + ( + "str_eq", + "DataSet.0.Rule.0.Priority", + variables.get("fw_rule_1_priority"), + ), + ], + action="DescribeFirewall", +) +def describe_firewall_04(client, variables): + d = {"Region": variables.get("Region"), "FWId": variables.get("fw_id1")} + try: + resp = client.unet().describe_firewall(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=3, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeFirewall", +) +def describe_firewall_05(client, variables): + d = {"Region": variables.get("Region")} + try: + resp = client.unet().describe_firewall(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=3, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="GrantFirewall", +) +def grant_firewall_06(client, variables): + d = { + "ResourceType": "UHost", + "ResourceId": variables.get("uhost_id1"), + "Region": variables.get("Region"), + "FWId": variables.get("fw_id1"), + } + try: + resp = client.unet().grant_firewall(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=3, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "ResourceSet.0.Name", variables.get("uhost_name_1")), + ("str_eq", "ResourceSet.0.ResourceType", "uhost"), + ("str_eq", "ResourceSet.0.ResourceID", variables.get("uhost_id1")), + ("str_eq", "TotalCount", 1), + ("str_eq", "ResourceSet.0.Tag", variables.get("tag")), + ], + action="DescribeFirewallResource", +) +def describe_firewall_resource_07(client, variables): + d = {"Region": variables.get("Region"), "FWId": variables.get("fw_id1")} + try: + resp = client.unet().describe_firewall_resource(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="UpdateFirewall", +) +def update_firewall_08(client, variables): + d = { + "Rule": [variables.get("fw_rule_2")], + "Region": variables.get("Region"), + "FWId": variables.get("fw_id1"), + } + try: + resp = client.unet().update_firewall(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="UpdateFirewallAttribute", +) +def update_firewall_attribute_09(client, variables): + d = { + "Tag": variables.get("tag_2"), + "Remark": variables.get("remark_2"), + "Region": variables.get("Region"), + "Name": funcs.concat(variables.get("fw_name_2"), variables.get("Zone")), + "FWId": variables.get("fw_id1"), + } + try: + resp = client.unet().update_firewall_attribute(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=3, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.FWId", variables.get("fw_id1")), + ( + "str_eq", + "DataSet.0.Name", + funcs.concat(variables.get("fw_name_2"), variables.get("Zone")), + ), + ("str_eq", "DataSet.0.Tag", variables.get("tag_2")), + ("str_eq", "DataSet.0.Remark", variables.get("remark_2")), + ("str_eq", "DataSet.0.ResourceCount", 1), + ("str_eq", "DataSet.0.Type", "user defined"), + ( + "str_eq", + "DataSet.0.Rule.0.ProtocolType", + variables.get("fw_rule_2_protocol"), + ), + ("str_eq", "DataSet.0.Rule.0.DstPort", variables.get("fw_rule_2_port")), + ("str_eq", "DataSet.0.Rule.0.SrcIP", variables.get("fw_rule_2_srcip")), + ( + "str_eq", + "DataSet.0.Rule.0.RuleAction", + variables.get("fw_rule_2_action"), + ), + ( + "str_eq", + "DataSet.0.Rule.0.Priority", + variables.get("fw_rule_2_priority"), + ), + ], + action="DescribeFirewall", +) +def describe_firewall_10(client, variables): + d = {"Region": variables.get("Region"), "FWId": variables.get("fw_id1")} + try: + resp = client.unet().describe_firewall(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + action="DescribeFirewall", +) +def describe_firewall_11(client, variables): + d = {"Region": variables.get("Region"), "Offset": 0, "Limit": 20} + try: + resp = client.unet().describe_firewall(d) + except exc.RetCodeException as e: + resp = e.json() + variables["fw_dataset"] = utest.value_at_path(resp, "DataSet") + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="GrantFirewall", +) +def grant_firewall_12(client, variables): + d = { + "ResourceType": "UHost", + "ResourceId": variables.get("uhost_id1"), + "Region": variables.get("Region"), + "FWId": funcs.search_value( + variables.get("fw_dataset"), + "Type", + variables.get("recommend_web"), + "FWId", + ), + } + try: + resp = client.unet().grant_firewall(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=60, + startup_delay=30, + fast_fail=False, + action="PoweroffUHostInstance", +) +def poweroff_uhost_instance_13(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("uhost_id1"), + "Region": variables.get("Region"), + } + try: + resp = client.uhost().poweroff_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=10, + startup_delay=90, + fast_fail=False, + action="TerminateUHostInstance", +) +def terminate_uhost_instance_14(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("uhost_id1"), + "Region": variables.get("Region"), + } + try: + resp = client.uhost().terminate_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=60, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.ResourceCount", 0), + ], + action="DescribeFirewall", +) +def describe_firewall_15(client, variables): + d = {"Region": variables.get("Region"), "FWId": variables.get("fw_id1")} + try: + resp = client.unet().describe_firewall(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=1, + startup_delay=30, + fast_fail=True, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DeleteFirewall", +) +def delete_firewall_16(client, variables): + d = {"Region": variables.get("Region"), "FWId": variables.get("fw_id1")} + try: + resp = client.unet().delete_firewall(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("object_not_contains", "DataSet", variables.get("fw_id1")), + ], + action="DescribeFirewall", +) +def describe_firewall_17(client, variables): + d = {"Region": variables.get("Region"), "Offset": 0, "Limit": 10} + try: + resp = client.unet().describe_firewall(d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_3278.py b/tests/test_services/test_set_3278.py new file mode 100644 index 0000000..05ddaa7 --- /dev/null +++ b/tests/test_services/test_set_3278.py @@ -0,0 +1,331 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(3278) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_3278(client, variables): + scenario.initial(variables) + scenario.variables[ + "Image_Id_cloud" + ] = "#{u_get_image_resource($Region,$Zone)}" + scenario.variables["saopaulo_image"] = "uimage-1bkjka" + scenario.run(client) + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeImageResponse"), + ], + action="DescribeImage", +) +def describe_image_00(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "OsType": "Linux", + "ImageType": "Base", + } + try: + resp = client.uhost().describe_image(d) + except exc.RetCodeException as e: + resp = e.json() + variables["Image_Id_cloud"] = utest.value_at_path( + resp, "ImageSet.0.ImageId" + ) + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateUHostInstance", +) +def create_uhost_instance_01(client, variables): + d = { + "Zone": variables.get("Zone"), + "TimemachineFeature": "No", + "Tag": "Default", + "Region": variables.get("Region"), + "Password": "VXFhNzg5VGVzdCFAIyQ7LA==", + "Name": "ulb-host", + "Memory": 1024, + "LoginMode": "Password", + "ImageId": variables.get("Image_Id_cloud"), + "HotplugFeature": False, + "DiskSpace": 0, + "CPU": 1, + } + try: + resp = client.uhost().create_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + variables["UHostId_01"] = utest.value_at_path(resp, "UHostIds.0") + variables["IP_01"] = utest.value_at_path(resp, "IPs.0") + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=180, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateULB", +) +def create_ulb_02(client, variables): + d = { + "ULBName": "测试", + "Tag": "Default", + "Region": variables.get("Region"), + "InnerMode": "No", + } + try: + resp = client.ulb().create_ulb(d) + except exc.RetCodeException as e: + resp = e.json() + variables["ULBId"] = utest.value_at_path(resp, "ULBId") + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 4107)], + action="CreateVServer", +) +def create_vserver_03(client, variables): + d = { + "VServerName": "vserver-test", + "ULBId": variables.get("ULBId"), + "Region": variables.get("Region"), + "Protocol": "HTTP", + "PersistenceType": "UserDefined", + "PersistenceInfo": "huangchao", + "Method": "Roundrobin", + "ListenType": "RequestProxy", + "FrontendPort": 80, + "ClientTimeout": 60, + } + try: + resp = client.ulb().create_vserver(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("len_eq", "DataSet", 1), + ], + action="DescribeVServer", +) +def describe_vserver_04(client, variables): + d = {"ULBId": variables.get("ULBId"), "Region": variables.get("Region")} + try: + resp = client.ulb().describe_vserver(d) + except exc.RetCodeException as e: + resp = e.json() + variables["VServerId"] = utest.value_at_path(resp, "DataSet.0.VServerId") + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=30, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 63016)], + action="AllocateBackend", +) +def allocate_backend_05(client, variables): + d = { + "VServerId": variables.get("VServerId"), + "ULBId": variables.get("ULBId"), + "ResourceType": "UHost", + "ResourceId": variables.get("UHostId_01"), + "Region": variables.get("Region"), + "Port": 80, + "Enabled": 1, + } + try: + resp = client.ulb().allocate_backend(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("len_eq", "DataSet.0.BackendSet", 1), + ], + action="DescribeVServer", +) +def describe_vserver_06(client, variables): + d = { + "VServerId": variables.get("VServerId"), + "ULBId": variables.get("ULBId"), + "Region": variables.get("Region"), + } + try: + resp = client.ulb().describe_vserver(d) + except exc.RetCodeException as e: + resp = e.json() + variables["BackendId"] = utest.value_at_path( + resp, "DataSet.0.BackendSet.0.BackendId" + ) + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=30, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreatePolicy", +) +def create_policy_07(client, variables): + d = { + "VServerId": variables.get("VServerId"), + "ULBId": variables.get("ULBId"), + "Type": "Domain", + "Region": variables.get("Region"), + "Match": "www.test.com", + "BackendId": [variables.get("BackendId")], + } + try: + resp = client.ulb().create_policy(d) + except exc.RetCodeException as e: + resp = e.json() + variables["PolicyId"] = utest.value_at_path(resp, "PolicyId") + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="UpdatePolicy", +) +def update_policy_08(client, variables): + d = { + "VServerId": variables.get("VServerId"), + "ULBId": variables.get("ULBId"), + "Type": "Domain", + "Region": variables.get("Region"), + "PolicyId": variables.get("PolicyId"), + "Match": "www.testgai.com", + "BackendId": [variables.get("BackendId")], + } + try: + resp = client.ulb().update_policy(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DeletePolicy", +) +def delete_policy_09(client, variables): + d = { + "VServerId": variables.get("VServerId"), + "Region": variables.get("Region"), + "PolicyId": variables.get("PolicyId"), + } + try: + resp = client.ulb().delete_policy(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=30, + fast_fail=False, + action="DeleteULB", +) +def delete_ulb_10(client, variables): + d = {"ULBId": variables.get("ULBId"), "Region": variables.get("Region")} + try: + resp = client.ulb().delete_ulb(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=30, + startup_delay=5, + fast_fail=False, + action="PoweroffUHostInstance", +) +def poweroff_uhost_instance_11(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("UHostId_01"), + "Region": variables.get("Region"), + } + try: + resp = client.uhost().poweroff_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=60, + fast_fail=False, + action="TerminateUHostInstance", +) +def terminate_uhost_instance_12(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("UHostId_01"), + "Region": variables.get("Region"), + } + try: + resp = client.uhost().terminate_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_330.py b/tests/test_services/test_set_330.py new file mode 100644 index 0000000..864e2dd --- /dev/null +++ b/tests/test_services/test_set_330.py @@ -0,0 +1,282 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(330) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_330(client, variables): + scenario.initial(variables) + scenario.variables["Region"] = "cn-bj2" + scenario.variables["Zone"] = "cn-bj2-02" + scenario.run(client) + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateUMemcacheGroup", +) +def create_umem_cache_group_00(client, variables): + d = { + "Zone": variables.get("Zone"), + "Size": 1, + "Region": variables.get("Region"), + "Quantity": 1, + "Name": "umem_charge", + "ChargeType": "Month", + } + try: + resp = client.umem().create_umem_cache_group(d) + except exc.RetCodeException as e: + resp = e.json() + variables["group_id"] = utest.value_at_path(resp, "GroupId") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=30, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUMem", +) +def describe_umem_01(client, variables): + d = { + "ResourceId": variables.get("group_id"), + "Region": variables.get("Region"), + "Protocol": "memcache", + "Offset": 0, + "Limit": 1000, + } + try: + resp = client.invoke("DescribeUMem", d) + except exc.RetCodeException as e: + resp = e.json() + variables["CreateTime"] = utest.value_at_path(resp, "DataSet.0.CreateTime") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUMemcachePrice", +) +def describe_umem_cache_price_02(client, variables): + d = { + "Zone": variables.get("Zone"), + "Size": 1, + "Region": variables.get("Region"), + "Quantity": 1, + "ChargeType": "Month", + } + try: + resp = client.umem().describe_umem_cache_price(d) + except exc.RetCodeException as e: + resp = e.json() + variables["GetPrice"] = utest.value_at_path(resp, "DataSet.0.Price") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=60, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("float_eq", "OrderInfos.0.Amount", variables.get("GetPrice") / 100), + ], + action="DescribeOrderDetailInfo", +) +def describe_order_detail_info_03(client, variables): + d = { + "ResourceIds": [variables.get("group_id")], + "QueryAll": True, + "OrderTypes": ["OT_BUY"], + "OrderStates": ["OS_FINISHED"], + "EndTime": funcs.get_timestamp(10), + "ChargeTypes": ["Month"], + "BeginTime": funcs.get_timestamp(10) - 1200, + } + try: + resp = client.invoke("DescribeOrderDetailInfo", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUMemcacheUpgradePrice", +) +def describe_umem_cache_upgrade_price_04(client, variables): + d = { + "Size": 2, + "Region": variables.get("Region"), + "GroupId": variables.get("group_id"), + } + try: + resp = client.umem().describe_umem_cache_upgrade_price(d) + except exc.RetCodeException as e: + resp = e.json() + variables["UpgradePrice"] = utest.value_at_path(resp, "Price") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=2, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="ResizeUMemcacheGroup", +) +def resize_umem_cache_group_05(client, variables): + d = { + "Size": 2, + "Region": variables.get("Region"), + "GroupId": variables.get("group_id"), + } + try: + resp = client.invoke("ResizeUMemcacheGroup", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("float_eq", "OrderInfos.0.Amount", variables.get("GetPrice") / 100), + ], + action="DescribeOrderDetailInfo", +) +def describe_order_detail_info_06(client, variables): + d = { + "ResourceIds": [variables.get("group_id")], + "QueryAll": True, + "OrderTypes": ["OT_BUY"], + "OrderStates": ["OS_FINISHED"], + "EndTime": funcs.get_timestamp(10), + "ChargeTypes": ["Month"], + "BeginTime": funcs.get_timestamp(10) - 1200, + } + try: + resp = client.invoke("DescribeOrderDetailInfo", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="GetResourceRenewPrice", +) +def get_resource_renew_price_07(client, variables): + d = { + "ResourceIds": [variables.get("group_id")], + "Quantity": 1, + "ChargeType": "Month", + } + try: + resp = client.invoke("GetResourceRenewPrice", d) + except exc.RetCodeException as e: + resp = e.json() + variables["ReNewPrice"] = utest.value_at_path(resp, "RenewPriceSet.0.Price") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=2, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateRenew", +) +def create_renew_08(client, variables): + d = { + "ResourceId": variables.get("group_id"), + "Quantity": 1, + "ChargeType": "Month", + } + try: + resp = client.invoke("CreateRenew", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=60, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "OrderInfos.0.Amount", variables.get("ReNewPrice")), + ], + action="DescribeOrderDetailInfo", +) +def describe_order_detail_info_09(client, variables): + d = { + "ResourceIds": [variables.get("group_id")], + "QueryAll": True, + "OrderTypes": ["OT_RENEW"], + "OrderStates": ["OS_FINISHED"], + "EndTime": funcs.get_timestamp(10), + "ChargeTypes": ["Month"], + "BeginTime": funcs.get_timestamp(10) - 1200, + } + try: + resp = client.invoke("DescribeOrderDetailInfo", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=2, + fast_fail=False, + action="DeleteUMem", +) +def delete_umem_10(client, variables): + d = { + "Zone": variables.get("Zone"), + "ResourceType": "single", + "ResourceId": variables.get("group_id"), + "Region": variables.get("Region"), + } + try: + resp = client.invoke("DeleteUMem", d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_333.py b/tests/test_services/test_set_333.py new file mode 100644 index 0000000..80eba24 --- /dev/null +++ b/tests/test_services/test_set_333.py @@ -0,0 +1,618 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(333) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_333(client, variables): + scenario.initial(variables) + scenario.variables["Password"] = "Z3VhbmxpeXVhbm1pbWExMjMhQCM=" + scenario.variables["ImageName"] = "ImageTest" + scenario.variables["TargetImageName"] = "ImageCopyTest" + scenario.variables["TargetRegion"] = "cn-sh2" + scenario.variables["TargetZone"] = "cn-sh2-01" + scenario.variables["myImage"] = "#{u_get_image_resource($Region,$Zone)}" + scenario.run(client) + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeImageResponse"), + ], + action="DescribeImage", +) +def describe_image_00(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "OsType": "Linux", + "ImageType": "Base", + } + try: + resp = client.uhost().describe_image(d) + except exc.RetCodeException as e: + resp = e.json() + variables["myImage"] = utest.value_at_path(resp, "ImageSet.0.ImageId") + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateUHostInstance", +) +def create_uhost_instance_01(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Password": "VXFhNzg5VGVzdCFAIyQ7LA==", + "Memory": 1024, + "LoginMode": "Password", + "ImageId": variables.get("myImage"), + "DiskSpace": 0, + "CPU": 1, + } + try: + resp = client.uhost().create_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + variables["hostId"] = utest.value_at_path(resp, "UHostIds.0") + return resp + + +@scenario.step( + max_retries=60, + retry_interval=60, + startup_delay=400, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeUHostInstanceResponse"), + ("str_eq", "UHostSet.0.State", "Running"), + ("str_eq", "UHostSet.0.BootDiskState", "Normal"), + ], + action="DescribeUHostInstance", +) +def describe_uhost_instance_02(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostIds": [variables.get("hostId")], + "Region": variables.get("Region"), + } + try: + resp = client.uhost().describe_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=30, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "StopUHostInstanceResponse"), + ], + action="StopUHostInstance", +) +def stop_uhost_instance_03(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("hostId"), + "Region": variables.get("Region"), + } + try: + resp = client.uhost().stop_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=30, + startup_delay=30, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeUHostInstanceResponse"), + ("str_eq", "UHostSet.0.State", "Stopped"), + ("str_eq", "UHostSet.0.BootDiskState", "Normal"), + ], + action="DescribeUHostInstance", +) +def describe_uhost_instance_04(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostIds": [variables.get("hostId")], + "Region": variables.get("Region"), + } + try: + resp = client.uhost().describe_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=10, + fast_fail=True, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateCustomImage", +) +def create_custom_image_05(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("hostId"), + "Region": variables.get("Region"), + "ImageName": variables.get("ImageName"), + } + try: + resp = client.uhost().create_custom_image(d) + except exc.RetCodeException as e: + resp = e.json() + variables["newImageId"] = utest.value_at_path(resp, "ImageId") + return resp + + +@scenario.step( + max_retries=100, + retry_interval=30, + startup_delay=60, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeImageResponse"), + ("str_eq", "ImageSet.0.State", "Available"), + ("str_eq", "ImageSet.0.ImageId", variables.get("newImageId")), + ], + action="DescribeImage", +) +def describe_image_06(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "ImageId": variables.get("newImageId"), + } + try: + resp = client.uhost().describe_image(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateUHostInstance", +) +def create_uhost_instance_07(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Password": "VXFhNzg5VGVzdCFAIyQ7LA==", + "Memory": 1024, + "LoginMode": "Password", + "ImageId": variables.get("newImageId"), + "DiskSpace": 0, + "CPU": 1, + } + try: + resp = client.uhost().create_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + variables["hostId2"] = utest.value_at_path(resp, "UHostIds.0") + return resp + + +@scenario.step( + max_retries=100, + retry_interval=30, + startup_delay=60, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeUHostInstanceResponse"), + ("str_eq", "UHostSet.0.State", "Running"), + ("str_eq", "UHostSet.0.BootDiskState", "Normal"), + ], + action="DescribeUHostInstance", +) +def describe_uhost_instance_08(client, variables): + d = { + "UHostIds": [variables.get("hostId2")], + "Region": variables.get("Region"), + } + try: + resp = client.uhost().describe_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "GetProjectListResponse"), + ], + action="GetProjectList", +) +def get_project_list_09(client, variables): + d = {} + try: + resp = client.uaccount().get_project_list(d) + except exc.RetCodeException as e: + resp = e.json() + variables["TargetProjectID"] = utest.value_at_path( + resp, "ProjectSet.0.ProjectId" + ) + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=10, + fast_fail=True, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CopyCustomImage", +) +def copy_custom_image_10(client, variables): + d = { + "Zone": variables.get("Zone"), + "TargetRegion": variables.get("TargetRegion"), + "TargetProjectId": variables.get("TargetProjectID"), + "TargetImageName": variables.get("TargetImageName"), + "SourceImageId": variables.get("newImageId"), + "Region": variables.get("Region"), + } + try: + resp = client.uhost().copy_custom_image(d) + except exc.RetCodeException as e: + resp = e.json() + variables["cpImageId"] = utest.value_at_path(resp, "TargetImageId") + return resp + + +@scenario.step( + max_retries=60, + retry_interval=30, + startup_delay=60, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("float_eq", "ProgressInfo", 100), + ], + action="GetImageCopyProgress", +) +def get_image_copy_progress_11(client, variables): + d = { + "Region": variables.get("TargetRegion"), + "ProjectId": variables.get("TargetProjectID"), + "ImageId": variables.get("cpImageId"), + } + try: + resp = client.invoke("GetImageCopyProgress", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=30, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeImageResponse"), + ("str_eq", "ImageSet.0.State", "Available"), + ], + action="DescribeImage", +) +def describe_image_12(client, variables): + d = { + "Region": variables.get("TargetRegion"), + "ProjectId": variables.get("TargetProjectID"), + "ImageId": variables.get("cpImageId"), + } + try: + resp = client.uhost().describe_image(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateUHostInstance", +) +def create_uhost_instance_13(client, variables): + d = { + "Zone": variables.get("TargetZone"), + "Region": variables.get("TargetRegion"), + "ProjectId": variables.get("TargetProjectID"), + "Password": "VXFhNzg5VGVzdCFAIyQ7LA==", + "Memory": 1024, + "LoginMode": "Password", + "ImageId": variables.get("cpImageId"), + "DiskSpace": 0, + "CPU": 1, + } + try: + resp = client.uhost().create_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + variables["hostId_new"] = utest.value_at_path(resp, "UHostIds.0") + return resp + + +@scenario.step( + max_retries=60, + retry_interval=60, + startup_delay=10, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeUHostInstanceResponse"), + ("str_eq", "UHostSet.0.State", "Running"), + ("str_eq", "UHostSet.0.BootDiskState", "Normal"), + ], + action="DescribeUHostInstance", +) +def describe_uhost_instance_14(client, variables): + d = { + "Zone": variables.get("TargetZone"), + "UHostIds": [variables.get("hostId_new")], + "Region": variables.get("TargetRegion"), + "ProjectId": variables.get("TargetProjectID"), + } + try: + resp = client.uhost().describe_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="TerminateCustomImage", +) +def terminate_custom_image_15(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "ImageId": variables.get("newImageId"), + } + try: + resp = client.uhost().terminate_custom_image(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="StopUHostInstance", +) +def stop_uhost_instance_16(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("hostId"), + "Region": variables.get("Region"), + } + try: + resp = client.uhost().stop_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="StopUHostInstance", +) +def stop_uhost_instance_17(client, variables): + d = {"UHostId": variables.get("hostId2"), "Region": variables.get("Region")} + try: + resp = client.uhost().stop_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=10, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeUHostInstanceResponse"), + ("str_eq", "UHostSet.0.State", "Stopped"), + ("str_eq", "UHostSet.1.State", "Stopped"), + ], + action="DescribeUHostInstance", +) +def describe_uhost_instance_18(client, variables): + d = { + "UHostIds": [variables.get("hostId")], + "Region": variables.get("Region"), + } + try: + resp = client.uhost().describe_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=5, + fast_fail=True, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="TerminateUHostInstance", +) +def terminate_uhost_instance_19(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("hostId"), + "Region": variables.get("Region"), + } + try: + resp = client.uhost().terminate_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="TerminateUHostInstance", +) +def terminate_uhost_instance_20(client, variables): + d = {"UHostId": variables.get("hostId2"), "Region": variables.get("Region")} + try: + resp = client.uhost().terminate_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=100, + fast_fail=True, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="TerminateCustomImage", +) +def terminate_custom_image_21(client, variables): + d = { + "Zone": variables.get("TargetZone"), + "Region": variables.get("TargetRegion"), + "ProjectId": variables.get("TargetProjectID"), + "ImageId": variables.get("cpImageId"), + } + try: + resp = client.uhost().terminate_custom_image(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="StopUHostInstance", +) +def stop_uhost_instance_22(client, variables): + d = { + "Zone": variables.get("TargetZone"), + "UHostId": variables.get("hostId_new"), + "Region": variables.get("TargetRegion"), + "ProjectId": variables.get("TargetProjectID"), + } + try: + resp = client.uhost().stop_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=10, + startup_delay=10, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeUHostInstanceResponse"), + ("str_eq", "UHostSet.0.State", "Stopped"), + ], + action="DescribeUHostInstance", +) +def describe_uhost_instance_23(client, variables): + d = { + "Zone": variables.get("TargetZone"), + "UHostIds": [variables.get("hostId_new")], + "Region": variables.get("TargetRegion"), + "ProjectId": variables.get("TargetProjectID"), + } + try: + resp = client.uhost().describe_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="TerminateUHostInstance", +) +def terminate_uhost_instance_24(client, variables): + d = { + "Zone": variables.get("TargetZone"), + "UHostId": variables.get("hostId_new"), + "Region": variables.get("TargetRegion"), + "ProjectId": variables.get("TargetProjectID"), + } + try: + resp = client.uhost().terminate_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_448.py b/tests/test_services/test_set_448.py new file mode 100644 index 0000000..19c558a --- /dev/null +++ b/tests/test_services/test_set_448.py @@ -0,0 +1,378 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(448) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_448(client, variables): + scenario.initial(variables) + scenario.variables["Password"] = "Z3VhbmxpeXVhbm1pbWExMjMhQCM=" + scenario.variables["CreateBootDisk"] = 20 + scenario.variables["ChargeType"] = "Month" + scenario.variables["CreateCPU"] = 1 + scenario.variables["CreateMem"] = 1024 + scenario.variables["CreateDiskspace"] = 20 + scenario.variables["UpgradeDiskSpace"] = 30 + scenario.variables["NewPassword"] = "Z3VhbmxpeXVhbm1pbWExMjMhQCM=" + scenario.variables["Name"] = "uhost-basic-api-N2-Normal-LocalDisk-1" + scenario.variables["ImageID"] = "#{u_get_image_resource($Region,$Zone)}" + scenario.variables["UpgradeBootDisk"] = 40 + scenario.variables["UpgradeCPU"] = 2 + scenario.run(client) + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeImageResponse"), + ], + action="DescribeImage", +) +def describe_image_00(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "OsType": "Linux", + "ImageType": "Base", + } + try: + resp = client.uhost().describe_image(d) + except exc.RetCodeException as e: + resp = e.json() + variables["ImageID"] = utest.value_at_path(resp, "ImageSet.0.ImageId") + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateUHostInstance", +) +def create_uhost_instance_01(client, variables): + d = { + "Zone": variables.get("Zone"), + "TimemachineFeature": "No", + "Tag": "Default", + "StorageType": "LocalDisk", + "Region": variables.get("Region"), + "Quantity": 1, + "Password": "VXFhNzg5VGVzdCFAIyQ7LA==", + "NetCapability": "Normal", + "Name": variables.get("Name"), + "Memory": variables.get("CreateMem"), + "LoginMode": "Password", + "ImageId": variables.get("ImageID"), + "HotplugFeature": False, + "HostType": "N2", + "GPU": False, + "DiskSpace": variables.get("CreateDiskspace"), + "ChargeType": variables.get("ChargeType"), + "CPU": variables.get("CreateCPU"), + "BootDiskSpace": variables.get("CreateBootDisk"), + } + try: + resp = client.uhost().create_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + variables["hostId"] = utest.value_at_path(resp, "UHostIds.0") + return resp + + +@scenario.step( + max_retries=200, + retry_interval=30, + startup_delay=10, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "UHostSet.0.CPU", variables.get("CreateCPU")), + ("str_eq", "UHostSet.0.Memory", variables.get("CreateMem")), + ("str_eq", "UHostSet.0.UHostId", variables.get("hostId")), + ("str_eq", "UHostSet.0.Name", variables.get("Name")), + ( + "str_eq", + "UHostSet.0.TotalDiskSpace", + variables.get("CreateDiskspace"), + ), + ("str_eq", "UHostSet.0.HostType", "N2"), + ("str_eq", "UHostSet.0.UHostType", "Normal"), + ("str_eq", "UHostSet.0.StorageType", "LocalDisk"), + ("str_eq", "UHostSet.0.BasicImageId", variables.get("ImageID")), + ("str_eq", "UHostSet.0.State", "Running"), + ("str_eq", "UHostSet.0.BootDiskState", "Normal"), + ], + action="DescribeUHostInstance", +) +def describe_uhost_instance_02(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostIds": [variables.get("hostId")], + "Region": variables.get("Region"), + } + try: + resp = client.uhost().describe_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=5, + retry_interval=60, + startup_delay=10, + fast_fail=True, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="RebootUHostInstance", +) +def reboot_uhost_instance_03(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("hostId"), + "Region": variables.get("Region"), + } + try: + resp = client.uhost().reboot_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=10, + startup_delay=10, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "UHostSet.0.CPU", variables.get("CreateCPU")), + ("str_eq", "UHostSet.0.Memory", variables.get("CreateMem")), + ("str_eq", "UHostSet.0.UHostId", variables.get("hostId")), + ("str_eq", "UHostSet.0.Name", variables.get("Name")), + ( + "str_eq", + "UHostSet.0.TotalDiskSpace", + variables.get("CreateDiskspace"), + ), + ("str_eq", "UHostSet.0.HostType", "N2"), + ("str_eq", "UHostSet.0.UHostType", "Normal"), + ("str_eq", "UHostSet.0.StorageType", "LocalDisk"), + ("str_eq", "UHostSet.0.BasicImageId", variables.get("ImageID")), + ("str_eq", "UHostSet.0.State", "Running"), + ], + action="DescribeUHostInstance", +) +def describe_uhost_instance_04(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostIds": [variables.get("hostId")], + "Region": variables.get("Region"), + } + try: + resp = client.uhost().describe_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=5, + retry_interval=30, + startup_delay=10, + fast_fail=True, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="StopUHostInstance", +) +def stop_uhost_instance_05(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("hostId"), + "Region": variables.get("Region"), + } + try: + resp = client.uhost().stop_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=10, + startup_delay=10, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "UHostSet.0.State", "Stopped"), + ], + action="DescribeUHostInstance", +) +def describe_uhost_instance_06(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostIds": [variables.get("hostId")], + "Region": variables.get("Region"), + } + try: + resp = client.uhost().describe_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "GetRestResourceResponse"), + ("str_eq", "UpgradeStatus", True), + ], + action="GetRestResource", +) +def get_rest_resource_07(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("hostId"), + "Region": variables.get("Region"), + "CPU": variables.get("UpgradeCPU"), + } + try: + resp = client.invoke("GetRestResource", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=5, + retry_interval=45, + startup_delay=10, + fast_fail=True, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="ResizeUHostInstance", +) +def resize_uhost_instance_08(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("hostId"), + "Region": variables.get("Region"), + "CPU": variables.get("UpgradeCPU"), + } + try: + resp = client.uhost().resize_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=60, + retry_interval=30, + startup_delay=30, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "UHostSet.0.Memory", variables.get("CreateMem")), + ("str_eq", "UHostSet.0.UHostId", variables.get("hostId")), + ("str_eq", "UHostSet.0.Name", variables.get("Name")), + ("str_eq", "UHostSet.0.CPU", variables.get("UpgradeCPU")), + ("str_eq", "UHostSet.0.HostType", "N2"), + ("str_eq", "UHostSet.0.UHostType", "Normal"), + ("str_eq", "UHostSet.0.StorageType", "LocalDisk"), + ("str_eq", "UHostSet.0.BasicImageId", variables.get("ImageID")), + ("str_eq", "UHostSet.0.State", "Stopped"), + ], + action="DescribeUHostInstance", +) +def describe_uhost_instance_09(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostIds": [variables.get("hostId")], + "Region": variables.get("Region"), + } + try: + resp = client.uhost().describe_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=5, + retry_interval=30, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="PoweroffUHostInstance", +) +def poweroff_uhost_instance_10(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("hostId"), + "Region": variables.get("Region"), + } + try: + resp = client.uhost().poweroff_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=10, + startup_delay=10, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "UHostSet.0.State", "Stopped"), + ], + action="DescribeUHostInstance", +) +def describe_uhost_instance_11(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostIds": [variables.get("hostId")], + "Region": variables.get("Region"), + } + try: + resp = client.uhost().describe_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=10, + fast_fail=False, + action="TerminateUHostInstance", +) +def terminate_uhost_instance_12(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("hostId"), + "Region": variables.get("Region"), + } + try: + resp = client.uhost().terminate_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_449.py b/tests/test_services/test_set_449.py new file mode 100644 index 0000000..35da0c9 --- /dev/null +++ b/tests/test_services/test_set_449.py @@ -0,0 +1,313 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(449) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_449(client, variables): + scenario.initial(variables) + scenario.variables["Password"] = "Z3VhbmxpeXVhbm1pbWExMjMhQCM=" + scenario.variables["CreateBootDisk"] = 20 + scenario.variables["ChargeType"] = "Month" + scenario.variables["CreateCPU"] = 1 + scenario.variables["CreateMem"] = 1024 + scenario.variables["CreateDiskspace"] = 0 + scenario.variables["NewPassword"] = "Z3VhbmxpeXVhbm1pbWExMjMhQCM=" + scenario.variables["Name"] = "uhost-basic-api" + scenario.variables["ImageID"] = "#{u_get_image_resource($Region,$Zone)}" + scenario.run(client) + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeImageResponse"), + ], + action="DescribeImage", +) +def describe_image_00(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "OsType": "Linux", + "ImageType": "Base", + } + try: + resp = client.uhost().describe_image(d) + except exc.RetCodeException as e: + resp = e.json() + variables["ImageID"] = utest.value_at_path(resp, "ImageSet.0.ImageId") + return resp + + +@scenario.step( + max_retries=3, + retry_interval=10, + startup_delay=20, + fast_fail=True, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateUHostInstance", +) +def create_uhost_instance_01(client, variables): + d = { + "Zone": variables.get("Zone"), + "TimemachineFeature": "No", + "Tag": "Default", + "StorageType": "LocalDisk", + "Region": variables.get("Region"), + "Quantity": 1, + "Password": "VXFhNzg5VGVzdCFAIyQ7LA==", + "NetCapability": "Normal", + "Name": variables.get("Name"), + "Memory": variables.get("CreateMem"), + "LoginMode": "Password", + "ImageId": variables.get("ImageID"), + "HotplugFeature": False, + "HostType": "N2", + "GPU": False, + "DiskSpace": variables.get("CreateDiskspace"), + "ChargeType": variables.get("ChargeType"), + "CPU": variables.get("CreateCPU"), + "BootDiskSpace": variables.get("CreateBootDisk"), + } + try: + resp = client.uhost().create_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + variables["hostId"] = utest.value_at_path(resp, "UHostIds.0") + return resp + + +@scenario.step( + max_retries=200, + retry_interval=30, + startup_delay=60, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "UHostSet.0.BasicImageId", variables.get("ImageID")), + ("str_eq", "UHostSet.0.CPU", variables.get("CreateCPU")), + ("str_eq", "UHostSet.0.Memory", variables.get("CreateMem")), + ("str_eq", "UHostSet.0.UHostId", variables.get("hostId")), + ("str_eq", "UHostSet.0.Name", variables.get("Name")), + ( + "str_eq", + "UHostSet.0.TotalDiskSpace", + variables.get("CreateDiskspace"), + ), + ("str_eq", "UHostSet.0.HostType", "N2"), + ("str_eq", "UHostSet.0.UHostType", "Normal"), + ("str_eq", "UHostSet.0.StorageType", "LocalDisk"), + ("str_eq", "UHostSet.0.State", "Running"), + ("str_eq", "UHostSet.0.BootDiskState", "Normal"), + ], + action="DescribeUHostInstance", +) +def describe_uhost_instance_02(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostIds": [variables.get("hostId")], + "Region": variables.get("Region"), + } + try: + resp = client.uhost().describe_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=5, + retry_interval=30, + startup_delay=10, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "StopUHostInstanceResponse"), + ], + action="StopUHostInstance", +) +def stop_uhost_instance_03(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("hostId"), + "Region": variables.get("Region"), + } + try: + resp = client.uhost().stop_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=10, + startup_delay=10, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "UHostSet.0.BasicImageId", variables.get("ImageID")), + ("str_eq", "UHostSet.0.CPU", variables.get("CreateCPU")), + ("str_eq", "UHostSet.0.Memory", variables.get("CreateMem")), + ("str_eq", "UHostSet.0.UHostId", variables.get("hostId")), + ("str_eq", "UHostSet.0.Name", variables.get("Name")), + ( + "str_eq", + "UHostSet.0.TotalDiskSpace", + variables.get("CreateDiskspace"), + ), + ("str_eq", "UHostSet.0.HostType", "N2"), + ("str_eq", "UHostSet.0.UHostType", "Normal"), + ("str_eq", "UHostSet.0.StorageType", "LocalDisk"), + ("str_eq", "UHostSet.0.State", "Stopped"), + ], + action="DescribeUHostInstance", +) +def describe_uhost_instance_04(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostIds": [variables.get("hostId")], + "Region": variables.get("Region"), + } + try: + resp = client.uhost().describe_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=5, + retry_interval=60, + startup_delay=30, + fast_fail=True, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="ReinstallUHostInstance", +) +def reinstall_uhost_instance_05(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("hostId"), + "Region": variables.get("Region"), + "Password": variables.get("NewPassword"), + "ImageId": variables.get("ImageID"), + } + try: + resp = client.uhost().reinstall_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=200, + retry_interval=30, + startup_delay=30, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "UHostSet.0.BasicImageId", variables.get("ImageID")), + ("str_eq", "UHostSet.0.Memory", variables.get("CreateMem")), + ("str_eq", "UHostSet.0.UHostId", variables.get("hostId")), + ( + "str_eq", + "UHostSet.0.TotalDiskSpace", + variables.get("CreateDiskspace"), + ), + ("str_eq", "UHostSet.0.Name", variables.get("Name")), + ("str_eq", "UHostSet.0.CPU", variables.get("CreateCPU")), + ("str_eq", "UHostSet.0.HostType", "N2"), + ("str_eq", "UHostSet.0.UHostType", "Normal"), + ("str_eq", "UHostSet.0.StorageType", "LocalDisk"), + ("str_eq", "UHostSet.0.State", "Running"), + ], + action="DescribeUHostInstance", +) +def describe_uhost_instance_06(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostIds": [variables.get("hostId")], + "Region": variables.get("Region"), + } + try: + resp = client.uhost().describe_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=60, + startup_delay=30, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="PoweroffUHostInstance", +) +def poweroff_uhost_instance_07(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("hostId"), + "Region": variables.get("Region"), + } + try: + resp = client.uhost().poweroff_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=10, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "UHostSet.0.State", "Stopped"), + ], + action="DescribeUHostInstance", +) +def describe_uhost_instance_08(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostIds": [variables.get("hostId")], + "Region": variables.get("Region"), + } + try: + resp = client.uhost().describe_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=60, + fast_fail=False, + action="TerminateUHostInstance", +) +def terminate_uhost_instance_09(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("hostId"), + "Region": variables.get("Region"), + } + try: + resp = client.uhost().terminate_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_471.py b/tests/test_services/test_set_471.py new file mode 100644 index 0000000..ffeaced --- /dev/null +++ b/tests/test_services/test_set_471.py @@ -0,0 +1,284 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(471) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_471(client, variables): + scenario.initial(variables) + scenario.variables["Password"] = "Z3VhbmxpeXVhbm1pbWExMjMhQCM=" + scenario.variables["CreateBootDisk"] = 20 + scenario.variables["ChargeType"] = "Month" + scenario.variables["CreateCPU"] = 1 + scenario.variables["CreateMem"] = 1024 + scenario.variables["CreateDiskspace"] = 0 + scenario.variables["NewPassword"] = "Z3VhbmxpeXVhbm1pbWExMjMhQCM=" + scenario.variables["Name"] = "uhost-basic-api-ResetPassword" + scenario.variables["ImageID"] = "#{u_get_image_resource($Region,$Zone)}" + scenario.run(client) + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeImageResponse"), + ], + action="DescribeImage", +) +def describe_image_00(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "OsType": "Linux", + "ImageType": "Base", + } + try: + resp = client.uhost().describe_image(d) + except exc.RetCodeException as e: + resp = e.json() + variables["ImageID"] = utest.value_at_path(resp, "ImageSet.0.ImageId") + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateUHostInstance", +) +def create_uhost_instance_01(client, variables): + d = { + "Zone": variables.get("Zone"), + "TimemachineFeature": "No", + "Tag": "Default", + "StorageType": "LocalDisk", + "Region": variables.get("Region"), + "Quantity": 1, + "Password": "VXFhNzg5VGVzdCFAIyQ7LA==", + "NetCapability": "Normal", + "Name": variables.get("Name"), + "Memory": variables.get("CreateMem"), + "LoginMode": "Password", + "ImageId": variables.get("ImageID"), + "HotplugFeature": False, + "GPU": False, + "DiskSpace": variables.get("CreateDiskspace"), + "ChargeType": variables.get("ChargeType"), + "CPU": variables.get("CreateCPU"), + "BootDiskSpace": variables.get("CreateBootDisk"), + } + try: + resp = client.uhost().create_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + variables["hostId"] = utest.value_at_path(resp, "UHostIds.0") + return resp + + +@scenario.step( + max_retries=120, + retry_interval=30, + startup_delay=30, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "UHostSet.0.CPU", variables.get("CreateCPU")), + ("str_eq", "UHostSet.0.Memory", variables.get("CreateMem")), + ("str_eq", "UHostSet.0.UHostId", variables.get("hostId")), + ("str_eq", "UHostSet.0.Name", variables.get("Name")), + ( + "str_eq", + "UHostSet.0.TotalDiskSpace", + variables.get("CreateDiskspace"), + ), + ("str_eq", "UHostSet.0.StorageType", "LocalDisk"), + ("str_eq", "UHostSet.0.BasicImageId", variables.get("ImageID")), + ("str_eq", "UHostSet.0.BootDiskState", "Normal"), + ("str_eq", "UHostSet.0.State", "Running"), + ], + action="DescribeUHostInstance", +) +def describe_uhost_instance_02(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostIds": [variables.get("hostId")], + "Region": variables.get("Region"), + } + try: + resp = client.uhost().describe_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=5, + retry_interval=30, + startup_delay=10, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "StopUHostInstanceResponse"), + ], + action="StopUHostInstance", +) +def stop_uhost_instance_03(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("hostId"), + "Region": variables.get("Region"), + } + try: + resp = client.uhost().stop_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=100, + retry_interval=60, + startup_delay=10, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "UHostSet.0.State", "Stopped"), + ("str_eq", "UHostSet.0.BootDiskState", "Normal"), + ], + action="DescribeUHostInstance", +) +def describe_uhost_instance_04(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostIds": [variables.get("hostId")], + "Region": variables.get("Region"), + } + try: + resp = client.uhost().describe_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=30, + startup_delay=20, + fast_fail=True, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="ResetUHostInstancePassword", +) +def reset_uhost_instance_password_05(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("hostId"), + "Region": variables.get("Region"), + "Password": variables.get("NewPassword"), + } + try: + resp = client.uhost().reset_uhost_instance_password(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=60, + retry_interval=30, + startup_delay=10, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "UHostSet.0.State", "Stopped"), + ], + action="DescribeUHostInstance", +) +def describe_uhost_instance_06(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostIds": [variables.get("hostId")], + "Region": variables.get("Region"), + } + try: + resp = client.uhost().describe_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=60, + startup_delay=30, + fast_fail=True, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="PoweroffUHostInstance", +) +def poweroff_uhost_instance_07(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("hostId"), + "Region": variables.get("Region"), + } + try: + resp = client.uhost().poweroff_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=10, + startup_delay=30, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "UHostSet.0.State", "Stopped"), + ], + action="DescribeUHostInstance", +) +def describe_uhost_instance_08(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostIds": [variables.get("hostId")], + "Region": variables.get("Region"), + } + try: + resp = client.uhost().describe_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=30, + fast_fail=True, + action="TerminateUHostInstance", +) +def terminate_uhost_instance_09(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("hostId"), + "Region": variables.get("Region"), + } + try: + resp = client.uhost().terminate_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_488.py b/tests/test_services/test_set_488.py new file mode 100644 index 0000000..66f8474 --- /dev/null +++ b/tests/test_services/test_set_488.py @@ -0,0 +1,550 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(488) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_488(client, variables): + scenario.initial(variables) + scenario.variables["Region"] = "cn-bj2" + scenario.variables["Zone"] = "cn-bj2-02" + scenario.variables["DBTypeId"] = "percona-5.6" + scenario.variables["InstanceMode"] = "HA" + scenario.variables["InstanceType"] = "Normal" + scenario.variables["Port"] = 3306 + scenario.variables["MemoryLimit"] = 1000 + scenario.variables["DiskSpace"] = 20 + scenario.variables["DBName"] = "auto_habz_" + scenario.variables["UseSSD"] = False + scenario.run(client) + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUDBInstance", +) +def describe_udb_instance_00(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + "ClassType": "sql", + } + try: + resp = client.udb().describe_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=1, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUDBType", +) +def describe_udb_type_01(client, variables): + d = {"Zone": variables.get("Zone"), "Region": variables.get("Region")} + try: + resp = client.udb().describe_udb_type(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=2, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUDBParamGroup", +) +def describe_udb_param_group_02(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + } + try: + resp = client.udb().describe_udb_param_group(d) + except exc.RetCodeException as e: + resp = e.json() + variables["DataSet_paramGroup"] = utest.value_at_path(resp, "DataSet") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=1, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUDBInstancePrice", +) +def describe_udb_instance_price_03(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "MemoryLimit": variables.get("MemoryLimit"), + "DiskSpace": variables.get("DiskSpace"), + "DBTypeId": variables.get("DBTypeId"), + "Count": 1, + } + try: + resp = client.udb().describe_udb_instance_price(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=1, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CheckUDBInstanceAllowance", +) +def check_udb_instance_allowance_04(client, variables): + d = { + "Zone": variables.get("Zone"), + "UseSSD": variables.get("UseSSD"), + "Region": variables.get("Region"), + "MemoryLimit": variables.get("MemoryLimit"), + "DiskSpace": variables.get("DiskSpace"), + "Count": 1, + "ClassType": "SQL", + } + try: + resp = client.invoke("CheckUDBInstanceAllowance", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=1, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateUDBInstance", +) +def create_udb_instance_05(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Quantity": 0, + "Port": variables.get("Port"), + "ParamGroupId": funcs.search_value( + variables.get("DataSet_paramGroup"), + "DBTypeId", + variables.get("DBTypeId"), + "GroupId", + ), + "Name": funcs.concat( + variables.get("DBName"), variables.get("DBTypeId") + ), + "MemoryLimit": variables.get("MemoryLimit"), + "InstanceType": variables.get("InstanceType"), + "InstanceMode": variables.get("InstanceMode"), + "DiskSpace": variables.get("DiskSpace"), + "DBTypeId": variables.get("DBTypeId"), + "ChargeType": "Month", + "AdminPassword": "guanliyuanmima", + } + try: + resp = client.udb().create_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + variables["DBId"] = utest.value_at_path(resp, "DBId") + return resp + + +@scenario.step( + max_retries=60, + retry_interval=3, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ( + "str_eq", + "DataSet.0.Name", + funcs.concat(variables.get("DBName"), variables.get("DBTypeId")), + ), + ("str_eq", "DataSet.0.DBTypeId", variables.get("DBTypeId")), + ], + action="DescribeUDBInstance", +) +def describe_udb_instance_06(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + "DBId": variables.get("DBId"), + "ClassType": "sql", + } + try: + resp = client.udb().describe_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=50, + retry_interval=10, + startup_delay=30, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "State", "Running"), + ], + action="DescribeUDBInstanceState", +) +def describe_udb_instance_state_07(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().describe_udb_instance_state(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeUDBInstancePhpMyAdminURLResponse"), + ("ne", "PMAPath", ""), + ], + action="DescribeUDBInstancePhpMyAdminURL", +) +def describe_udb_instance_php_my_admin_url_08(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.invoke("DescribeUDBInstancePhpMyAdminURL", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="ModifyUDBInstanceName", +) +def modify_udb_instance_name_09(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Name": funcs.concat("rename_", variables.get("DBTypeId")), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().modify_udb_instance_name(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=20, + retry_interval=3, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ( + "str_eq", + "DataSet.0.Name", + funcs.concat("rename_", variables.get("DBTypeId")), + ), + ("str_eq", "DataSet.0.DBTypeId", variables.get("DBTypeId")), + ], + action="DescribeUDBInstance", +) +def describe_udb_instance_10(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + "DBId": variables.get("DBId"), + "ClassType": "sql", + } + try: + resp = client.udb().describe_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=1, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="ModifyUDBInstancePassword", +) +def modify_udb_instance_password_11(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Password": "Guanliyuanmima", + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().modify_udb_instance_password(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=2, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="RestartUDBInstance", +) +def restart_udb_instance_12(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().restart_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=100, + retry_interval=3, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.DBTypeId", variables.get("DBTypeId")), + ("str_eq", "DataSet.0.State", "Running"), + ], + action="DescribeUDBInstance", +) +def describe_udb_instance_13(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + "DBId": variables.get("DBId"), + "ClassType": "sql", + } + try: + resp = client.udb().describe_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="StopUDBInstance", +) +def stop_udb_instance_14(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().stop_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=100, + retry_interval=3, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.DBTypeId", variables.get("DBTypeId")), + ("str_eq", "DataSet.0.State", "Shutoff"), + ], + action="DescribeUDBInstance", +) +def describe_udb_instance_15(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + "DBId": variables.get("DBId"), + "ClassType": "sql", + } + try: + resp = client.udb().describe_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="StartUDBInstance", +) +def start_udb_instance_16(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().start_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=100, + retry_interval=3, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.DBTypeId", variables.get("DBTypeId")), + ("str_eq", "DataSet.0.State", "Running"), + ], + action="DescribeUDBInstance", +) +def describe_udb_instance_17(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + "DBId": variables.get("DBId"), + "ClassType": "sql", + } + try: + resp = client.udb().describe_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="StopUDBInstance", +) +def stop_udb_instance_18(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().stop_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=100, + retry_interval=3, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.DBTypeId", variables.get("DBTypeId")), + ("str_eq", "DataSet.0.State", "Shutoff"), + ], + action="DescribeUDBInstance", +) +def describe_udb_instance_19(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + "DBId": variables.get("DBId"), + "ClassType": "sql", + } + try: + resp = client.udb().describe_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=10, + fast_fail=False, + action="DeleteUDBInstance", +) +def delete_udb_instance_20(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().delete_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_489.py b/tests/test_services/test_set_489.py new file mode 100644 index 0000000..f30580c --- /dev/null +++ b/tests/test_services/test_set_489.py @@ -0,0 +1,880 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(489) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_489(client, variables): + scenario.initial(variables) + scenario.variables["Region"] = "cn-bj2" + scenario.variables["Zone"] = "cn-bj2-02" + scenario.variables["DBTypeId"] = "mysql-5.6" + scenario.variables["InstanceMode"] = "HA" + scenario.variables["InstanceType"] = "SATA_SSD" + scenario.variables["Port"] = 3306 + scenario.variables["MemoryLimit"] = 1000 + scenario.variables["DiskSpace"] = 20 + scenario.variables["DBName"] = "auto_hassd_" + scenario.variables["BackupName"] = "handbf_test_02" + scenario.variables["UseSSD"] = True + scenario.run(client) + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUDBType", +) +def describe_udb_type_00(client, variables): + d = {"Zone": variables.get("Zone"), "Region": variables.get("Region")} + try: + resp = client.udb().describe_udb_type(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUDBParamGroup", +) +def describe_udb_param_group_01(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + } + try: + resp = client.udb().describe_udb_param_group(d) + except exc.RetCodeException as e: + resp = e.json() + variables["DataSet_paramGroup"] = utest.value_at_path(resp, "DataSet") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUDBInstancePrice", +) +def describe_udb_instance_price_02(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "MemoryLimit": variables.get("MemoryLimit"), + "DiskSpace": variables.get("DiskSpace"), + "DBTypeId": variables.get("DBTypeId"), + "Count": 1, + } + try: + resp = client.udb().describe_udb_instance_price(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CheckUDBInstanceAllowance", +) +def check_udb_instance_allowance_03(client, variables): + d = { + "Zone": variables.get("Zone"), + "UseSSD": variables.get("UseSSD"), + "Region": variables.get("Region"), + "MemoryLimit": variables.get("MemoryLimit"), + "DiskSpace": variables.get("DiskSpace"), + "Count": 1, + "ClassType": "SQL", + } + try: + resp = client.invoke("CheckUDBInstanceAllowance", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=1, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateUDBInstance", +) +def create_udb_instance_04(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Quantity": 0, + "Port": variables.get("Port"), + "ParamGroupId": funcs.search_value( + variables.get("DataSet_paramGroup"), + "DBTypeId", + variables.get("DBTypeId"), + "GroupId", + ), + "Name": funcs.concat( + variables.get("DBName"), variables.get("DBTypeId") + ), + "MemoryLimit": variables.get("MemoryLimit"), + "InstanceType": variables.get("InstanceType"), + "InstanceMode": variables.get("InstanceMode"), + "DiskSpace": variables.get("DiskSpace"), + "DBTypeId": variables.get("DBTypeId"), + "ChargeType": "Month", + "AdminPassword": "guanliyuanmima", + } + try: + resp = client.udb().create_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + variables["DBId"] = utest.value_at_path(resp, "DBId") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=2, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ( + "str_eq", + "DataSet.0.Name", + funcs.concat(variables.get("DBName"), variables.get("DBTypeId")), + ), + ("str_eq", "DataSet.0.DBTypeId", variables.get("DBTypeId")), + ], + action="DescribeUDBInstance", +) +def describe_udb_instance_05(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + "DBId": variables.get("DBId"), + "ClassType": "sql", + } + try: + resp = client.udb().describe_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=50, + retry_interval=10, + startup_delay=30, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "State", "Running"), + ], + action="DescribeUDBInstanceState", +) +def describe_udb_instance_state_06(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().describe_udb_instance_state(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=2, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="UpdateUDBInstanceBackupStrategy", +) +def update_udb_instance_backup_strategy_07(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + "BackupTime": 13, + "BackupDate": 1111110, + } + try: + resp = client.udb().update_udb_instance_backup_strategy(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=1, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="EditUDBBackupBlacklist", +) +def edit_udb_backup_blacklist_08(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + "Blacklist": "test.%", + } + try: + resp = client.udb().edit_udb_backup_blacklist(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=20, + retry_interval=3, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Blacklist", "test.%"), + ], + action="DescribeUDBBackupBlacklist", +) +def describe_udb_backup_blacklist_09(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().describe_udb_backup_blacklist(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=2, + retry_interval=1, + startup_delay=15, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="BackupUDBInstance", +) +def backup_udb_instance_10(client, variables): + d = { + "Zone": variables.get("Zone"), + "UseBlacklist": True, + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + "BackupName": variables.get("BackupName"), + } + try: + resp = client.udb().backup_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=50, + retry_interval=3, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.State", "Success"), + ], + action="DescribeUDBBackup", +) +def describe_udb_backup_11(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().describe_udb_backup(d) + except exc.RetCodeException as e: + resp = e.json() + variables["BackupId"] = utest.value_at_path(resp, "DataSet.0.BackupId") + return resp + + +@scenario.step( + max_retries=20, + retry_interval=3, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "State", "Success"), + ("ne", "BackupSize", 0), + ("ne", "BackupEndTime", 0), + ], + action="DescribeUDBInstanceBackupState", +) +def describe_udb_instance_backup_state_12(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "BackupId": variables.get("BackupId"), + } + try: + resp = client.udb().describe_udb_instance_backup_state(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=1, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CheckUDBInstanceAllowance", +) +def check_udb_instance_allowance_13(client, variables): + d = { + "Zone": variables.get("Zone"), + "UseSSD": variables.get("UseSSD"), + "Region": variables.get("Region"), + "MemoryLimit": variables.get("MemoryLimit"), + "DiskSpace": variables.get("DiskSpace"), + "Count": 1, + "ClassType": "SQL", + } + try: + resp = client.invoke("CheckUDBInstanceAllowance", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=1, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("contains", "BackupPath", "http://"), + ], + action="DescribeUDBInstanceBackupURL", +) +def describe_udb_instance_backup_url_14(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + "BackupId": variables.get("BackupId"), + } + try: + resp = client.udb().describe_udb_instance_backup_url(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CheckUDBInstanceAllowance", +) +def check_udb_instance_allowance_15(client, variables): + d = { + "Zone": variables.get("Zone"), + "UseSSD": variables.get("UseSSD"), + "Region": variables.get("Region"), + "MemoryLimit": variables.get("MemoryLimit"), + "DiskSpace": variables.get("DiskSpace"), + "Count": 1, + "ClassType": "SQL", + } + try: + resp = client.invoke("CheckUDBInstanceAllowance", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=1, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateUDBInstance", +) +def create_udb_instance_16(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Quantity": 0, + "Port": 3306, + "ParamGroupId": funcs.search_value( + variables.get("DataSet_paramGroup"), + "DBTypeId", + "mysql-5.6", + "GroupId", + ), + "Name": "frombf-hassd-56", + "MemoryLimit": variables.get("MemoryLimit"), + "InstanceType": variables.get("InstanceType"), + "InstanceMode": variables.get("InstanceMode"), + "DiskSpace": variables.get("DiskSpace"), + "DBTypeId": "mysql-5.6", + "ChargeType": "Month", + "BackupId": variables.get("BackupId"), + "AdminPassword": "guanliyuanmima", + } + try: + resp = client.udb().create_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + variables["DBId_frombf_56"] = utest.value_at_path(resp, "DBId") + return resp + + +@scenario.step( + max_retries=100, + retry_interval=3, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "State", "Running"), + ], + action="DescribeUDBInstanceState", +) +def describe_udb_instance_state_17(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId_frombf_56"), + } + try: + resp = client.udb().describe_udb_instance_state(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=100, + retry_interval=5, + startup_delay=3, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeUDBInstanceResponse"), + ("str_eq", "DataSet.0.State", "Running"), + ], + action="DescribeUDBInstance", +) +def describe_udb_instance_18(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + "DBId": variables.get("DBId_frombf_56"), + "ClassType": "sql", + } + try: + resp = client.udb().describe_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=2, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "StopUDBInstanceResponse"), + ], + action="StopUDBInstance", +) +def stop_udb_instance_19(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId_frombf_56"), + } + try: + resp = client.udb().stop_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=20, + retry_interval=3, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeUDBInstanceResponse"), + ("str_eq", "DataSet.0.State", "Shutoff"), + ], + action="DescribeUDBInstance", +) +def describe_udb_instance_20(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId_frombf_56"), + } + try: + resp = client.udb().describe_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=20, + retry_interval=3, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("ne", "EarliestTime", 0), + ], + action="FetchUDBInstanceEarliestRecoverTime", +) +def fetch_udb_instance_earliest_recover_time_21(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().fetch_udb_instance_earliest_recover_time(d) + except exc.RetCodeException as e: + resp = e.json() + variables["EarliestTime"] = utest.value_at_path(resp, "EarliestTime") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CheckUDBInstanceAllowance", +) +def check_udb_instance_allowance_22(client, variables): + d = { + "Zone": variables.get("Zone"), + "UseSSD": variables.get("UseSSD"), + "Region": variables.get("Region"), + "MemoryLimit": variables.get("MemoryLimit"), + "DiskSpace": variables.get("DiskSpace"), + "Count": 1, + "ClassType": "sql", + } + try: + resp = client.invoke("CheckUDBInstanceAllowance", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateUDBInstanceByRecovery", +) +def create_udb_instance_by_recovery_23(client, variables): + d = { + "Zone": variables.get("Zone"), + "SrcDBId": variables.get("DBId"), + "Region": variables.get("Region"), + "RecoveryTime": variables.get("EarliestTime"), + "Quantity": 0, + "Name": "56-hd-frombf", + "ChargeType": "Month", + } + try: + resp = client.udb().create_udb_instance_by_recovery(d) + except exc.RetCodeException as e: + resp = e.json() + variables["HD_DBId"] = utest.value_at_path(resp, "DBId") + return resp + + +@scenario.step( + max_retries=100, + retry_interval=3, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "State", "Running"), + ], + action="DescribeUDBInstanceState", +) +def describe_udb_instance_state_24(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("HD_DBId"), + } + try: + resp = client.udb().describe_udb_instance_state(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=100, + retry_interval=5, + startup_delay=3, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeUDBInstanceResponse"), + ("str_eq", "DataSet.0.State", "Running"), + ], + action="DescribeUDBInstance", +) +def describe_udb_instance_25(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + "DBId": variables.get("HD_DBId"), + "ClassType": "sql", + } + try: + resp = client.udb().describe_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "StopUDBInstanceResponse"), + ], + action="StopUDBInstance", +) +def stop_udb_instance_26(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("HD_DBId"), + } + try: + resp = client.udb().stop_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=20, + retry_interval=3, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeUDBInstanceResponse"), + ("str_eq", "DataSet.0.State", "Shutoff"), + ], + action="DescribeUDBInstance", +) +def describe_udb_instance_27(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("HD_DBId"), + } + try: + resp = client.udb().describe_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DeleteUDBBackup", +) +def delete_udb_backup_28(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "BackupId": variables.get("BackupId"), + } + try: + resp = client.udb().delete_udb_backup(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "StopUDBInstanceResponse"), + ], + action="StopUDBInstance", +) +def stop_udb_instance_29(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().stop_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=20, + retry_interval=3, + startup_delay=30, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeUDBInstanceResponse"), + ("str_eq", "DataSet.0.State", "Shutoff"), + ], + action="DescribeUDBInstance", +) +def describe_udb_instance_30(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().describe_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=2, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DeleteUDBInstance", +) +def delete_udb_instance_31(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId_frombf_56"), + } + try: + resp = client.udb().delete_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=2, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DeleteUDBInstance", +) +def delete_udb_instance_32(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("HD_DBId"), + } + try: + resp = client.udb().delete_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=2, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DeleteUDBInstance", +) +def delete_udb_instance_33(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().delete_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_490.py b/tests/test_services/test_set_490.py new file mode 100644 index 0000000..cbed224 --- /dev/null +++ b/tests/test_services/test_set_490.py @@ -0,0 +1,713 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(490) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_490(client, variables): + scenario.initial(variables) + scenario.variables["Region"] = "cn-bj2" + scenario.variables["Zone"] = "cn-bj2-02" + scenario.variables["DBTypeId"] = "mysql-5.7" + scenario.variables["InstanceMode"] = "HA" + scenario.variables["InstanceType"] = "SATA_SSD" + scenario.variables["Port"] = 3306 + scenario.variables["MemoryLimit"] = 1000 + scenario.variables["DiskSpace"] = 20 + scenario.variables["DBName"] = "auto_hassd_" + scenario.variables["UseSSD"] = True + scenario.run(client) + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUDBType", +) +def describe_udb_type_00(client, variables): + d = {"Zone": variables.get("Zone"), "Region": variables.get("Region")} + try: + resp = client.udb().describe_udb_type(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUDBParamGroup", +) +def describe_udb_param_group_01(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + } + try: + resp = client.udb().describe_udb_param_group(d) + except exc.RetCodeException as e: + resp = e.json() + variables["DataSet_paramGroup"] = utest.value_at_path(resp, "DataSet") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUDBInstancePrice", +) +def describe_udb_instance_price_02(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "MemoryLimit": variables.get("MemoryLimit"), + "DiskSpace": variables.get("DiskSpace"), + "DBTypeId": variables.get("DBTypeId"), + "Count": 1, + } + try: + resp = client.udb().describe_udb_instance_price(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CheckUDBInstanceAllowance", +) +def check_udb_instance_allowance_03(client, variables): + d = { + "Zone": variables.get("Zone"), + "UseSSD": variables.get("UseSSD"), + "Region": variables.get("Region"), + "MemoryLimit": variables.get("MemoryLimit"), + "InstanceMode": variables.get("InstanceMode"), + "DiskSpace": variables.get("DiskSpace"), + "Count": 1, + "ClassType": "SQL", + } + try: + resp = client.invoke("CheckUDBInstanceAllowance", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=1, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateUDBInstance", +) +def create_udb_instance_04(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Quantity": 0, + "Port": variables.get("Port"), + "ParamGroupId": funcs.search_value( + variables.get("DataSet_paramGroup"), + "DBTypeId", + variables.get("DBTypeId"), + "GroupId", + ), + "Name": funcs.concat( + variables.get("DBName"), variables.get("DBTypeId") + ), + "MemoryLimit": variables.get("MemoryLimit"), + "InstanceType": variables.get("InstanceType"), + "InstanceMode": variables.get("InstanceMode"), + "DiskSpace": variables.get("DiskSpace"), + "DBTypeId": variables.get("DBTypeId"), + "ChargeType": "Month", + "AdminPassword": "guanliyuanmima", + } + try: + resp = client.udb().create_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + variables["DBId"] = utest.value_at_path(resp, "DBId") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ( + "str_eq", + "DataSet.0.Name", + funcs.concat(variables.get("DBName"), variables.get("DBTypeId")), + ), + ("str_eq", "DataSet.0.DBTypeId", variables.get("DBTypeId")), + ], + action="DescribeUDBInstance", +) +def describe_udb_instance_05(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + "DBId": variables.get("DBId"), + "ClassType": "sql", + } + try: + resp = client.udb().describe_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=50, + retry_interval=10, + startup_delay=30, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "State", "Running"), + ], + action="DescribeUDBInstanceState", +) +def describe_udb_instance_state_06(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().describe_udb_instance_state(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=1, + fast_fail=True, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CheckUDBInstanceAllowance", +) +def check_udb_instance_allowance_07(client, variables): + d = { + "Zone": variables.get("Zone"), + "UseSSD": variables.get("UseSSD"), + "Region": variables.get("Region"), + "MemoryLimit": variables.get("MemoryLimit"), + "DiskSpace": variables.get("DiskSpace"), + "Count": 1, + "ClassType": "sql", + } + try: + resp = client.invoke("CheckUDBInstanceAllowance", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=1, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CheckUDBInstanceConnection", +) +def check_udb_instance_connection_08(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.invoke("CheckUDBInstanceConnection", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "CheckUDBEngineResponse"), + ("str_eq", "Used", False), + ], + action="CheckUDBEngine", +) +def check_udb_engine_09(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "EngineType": "MyISAM", + "DBId": variables.get("DBId"), + } + try: + resp = client.invoke("CheckUDBEngine", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=1, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateUDBSlave", +) +def create_udb_slave_10(client, variables): + d = { + "Zone": variables.get("Zone"), + "UseSSD": variables.get("UseSSD"), + "SrcId": variables.get("DBId"), + "Region": variables.get("Region"), + "Port": 3307, + "Name": "auto_slave-create_3307", + "IsLock": True, + } + try: + resp = client.udb().create_udb_slave(d) + except exc.RetCodeException as e: + resp = e.json() + variables["slave_dbid"] = utest.value_at_path(resp, "DBId") + return resp + + +@scenario.step( + max_retries=90, + retry_interval=2, + startup_delay=30, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "State", "Running"), + ], + action="DescribeUDBInstanceState", +) +def describe_udb_instance_state_11(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("slave_dbid"), + } + try: + resp = client.udb().describe_udb_instance_state(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "UpdateUDBInstanceSlaveBackupSwitchResponse"), + ], + action="UpdateUDBInstanceSlaveBackupSwitch", +) +def update_udb_instance_slave_backup_switch_12(client, variables): + d = { + "Zone": variables.get("Zone"), + "SlaveDBId": variables.get("slave_dbid"), + "Region": variables.get("Region"), + "MasterDBId": variables.get("DBId"), + "BackupSwitch": 1, + } + try: + resp = client.udb().update_udb_instance_slave_backup_switch(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=1, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUDBSlaveOrSecondaryInstance", +) +def describe_udb_slave_or_secondary_instance_13(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + "ClassType": "mysql", + } + try: + resp = client.invoke("DescribeUDBSlaveOrSecondaryInstance", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="RestartUDBInstance", +) +def restart_udb_instance_14(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("slave_dbid"), + } + try: + resp = client.udb().restart_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=35, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "State", "Running"), + ], + action="DescribeUDBInstanceState", +) +def describe_udb_instance_state_15(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("slave_dbid"), + } + try: + resp = client.udb().describe_udb_instance_state(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="StopUDBInstance", +) +def stop_udb_instance_16(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("slave_dbid"), + } + try: + resp = client.udb().stop_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "State", "Shutoff"), + ], + action="DescribeUDBInstanceState", +) +def describe_udb_instance_state_17(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("slave_dbid"), + } + try: + resp = client.udb().describe_udb_instance_state(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="StartUDBInstance", +) +def start_udb_instance_18(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("slave_dbid"), + } + try: + resp = client.udb().start_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "State", "Running"), + ], + action="DescribeUDBInstanceState", +) +def describe_udb_instance_state_19(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("slave_dbid"), + } + try: + resp = client.udb().describe_udb_instance_state(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="PromoteUDBSlave", +) +def promote_udb_slave_20(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "IsForce": True, + "DBId": variables.get("slave_dbid"), + } + try: + resp = client.udb().promote_udb_slave(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=20, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "StopUDBInstanceResponse"), + ], + action="StopUDBInstance", +) +def stop_udb_instance_21(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("slave_dbid"), + } + try: + resp = client.udb().stop_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=20, + retry_interval=3, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.DBTypeId", variables.get("DBTypeId")), + ("str_eq", "DataSet.0.State", "Shutoff"), + ], + action="DescribeUDBInstance", +) +def describe_udb_instance_22(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + "DBId": variables.get("slave_dbid"), + "ClassType": "sql", + } + try: + resp = client.udb().describe_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "StopUDBInstanceResponse"), + ], + action="StopUDBInstance", +) +def stop_udb_instance_23(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().stop_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=45, + retry_interval=2, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ( + "str_eq", + "DataSet.0.Name", + funcs.concat(variables.get("DBName"), variables.get("DBTypeId")), + ), + ("str_eq", "DataSet.0.DBTypeId", variables.get("DBTypeId")), + ("str_eq", "DataSet.0.State", "Shutoff"), + ], + action="DescribeUDBInstance", +) +def describe_udb_instance_24(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + "DBId": variables.get("DBId"), + "ClassType": "sql", + } + try: + resp = client.udb().describe_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "ListMonitorItemsResponse"), + ], + action="ListMonitorItems", +) +def list_monitor_items_25(client, variables): + d = { + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + "ClassType": "sql", + } + try: + resp = client.invoke("ListMonitorItems", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=10, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DeleteUDBInstance", +) +def delete_udb_instance_26(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("slave_dbid"), + } + try: + resp = client.udb().delete_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=20, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DeleteUDBInstance", +) +def delete_udb_instance_27(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().delete_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_499.py b/tests/test_services/test_set_499.py new file mode 100644 index 0000000..933876f --- /dev/null +++ b/tests/test_services/test_set_499.py @@ -0,0 +1,554 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(499) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_499(client, variables): + scenario.initial(variables) + scenario.variables["Region"] = "cn-bj2" + scenario.variables["Zone"] = "cn-bj2-02" + scenario.variables["DBTypeId"] = "percona-5.5" + scenario.variables["InstanceMode"] = "HA" + scenario.variables["InstanceType"] = "SATA_SSD" + scenario.variables["Port"] = 3306 + scenario.variables["MemoryLimit"] = 1000 + scenario.variables["DiskSpace"] = 20 + scenario.variables["DBName"] = "auto_hassd_" + scenario.variables["UseSSD"] = True + scenario.run(client) + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUDBType", +) +def describe_udb_type_00(client, variables): + d = {"Zone": variables.get("Zone"), "Region": variables.get("Region")} + try: + resp = client.udb().describe_udb_type(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUDBParamGroup", +) +def describe_udb_param_group_01(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + } + try: + resp = client.udb().describe_udb_param_group(d) + except exc.RetCodeException as e: + resp = e.json() + variables["DataSet_paramGroup"] = utest.value_at_path(resp, "DataSet") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUDBInstancePrice", +) +def describe_udb_instance_price_02(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "MemoryLimit": variables.get("MemoryLimit"), + "DiskSpace": variables.get("DiskSpace"), + "DBTypeId": variables.get("DBTypeId"), + "Count": 1, + } + try: + resp = client.udb().describe_udb_instance_price(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CheckUDBInstanceAllowance", +) +def check_udb_instance_allowance_03(client, variables): + d = { + "Zone": variables.get("Zone"), + "UseSSD": variables.get("UseSSD"), + "Region": variables.get("Region"), + "MemoryLimit": variables.get("MemoryLimit"), + "DiskSpace": variables.get("DiskSpace"), + "Count": 1, + "ClassType": "SQL", + } + try: + resp = client.invoke("CheckUDBInstanceAllowance", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=1, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateUDBInstance", +) +def create_udb_instance_04(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Quantity": 0, + "Port": variables.get("Port"), + "ParamGroupId": funcs.search_value( + variables.get("DataSet_paramGroup"), + "DBTypeId", + variables.get("DBTypeId"), + "GroupId", + ), + "Name": funcs.concat( + variables.get("DBName"), variables.get("DBTypeId") + ), + "MemoryLimit": variables.get("MemoryLimit"), + "InstanceType": variables.get("InstanceType"), + "InstanceMode": variables.get("InstanceMode"), + "DiskSpace": variables.get("DiskSpace"), + "DBTypeId": variables.get("DBTypeId"), + "ChargeType": "Month", + "AdminPassword": "guanliyuanmima", + } + try: + resp = client.udb().create_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + variables["DBId"] = utest.value_at_path(resp, "DBId") + return resp + + +@scenario.step( + max_retries=50, + retry_interval=10, + startup_delay=30, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "State", "Running"), + ], + action="DescribeUDBInstanceState", +) +def describe_udb_instance_state_05(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().describe_udb_instance_state(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=2, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ( + "str_eq", + "DataSet.0.Name", + funcs.concat(variables.get("DBName"), variables.get("DBTypeId")), + ), + ("str_eq", "DataSet.0.DBTypeId", variables.get("DBTypeId")), + ], + action="DescribeUDBInstance", +) +def describe_udb_instance_06(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + "DBId": variables.get("DBId"), + "ClassType": "sql", + } + try: + resp = client.udb().describe_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=1, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateUDBParamGroup", +) +def create_udb_param_group_07(client, variables): + d = { + "Zone": variables.get("Zone"), + "SrcGroupId": funcs.search_value( + variables.get("DataSet_paramGroup"), + "DBTypeId", + variables.get("DBTypeId"), + "GroupId", + ), + "Region": variables.get("Region"), + "GroupName": "auto_config_create", + "Description": "self_create", + "DBTypeId": variables.get("DBTypeId"), + } + try: + resp = client.udb().create_udb_param_group(d) + except exc.RetCodeException as e: + resp = e.json() + variables["create_config_id"] = utest.value_at_path(resp, "GroupId") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=1, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="UpdateUDBParamGroup", +) +def update_udb_param_group_08(client, variables): + d = { + "Zone": variables.get("Zone"), + "Value": 2, + "Region": variables.get("Region"), + "Key": "auto_increment_increment", + "GroupId": variables.get("create_config_id"), + } + try: + resp = client.udb().update_udb_param_group(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=1, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="UploadUDBParamGroup", +) +def upload_udb_param_group_09(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "GroupName": "auto_config_upload", + "Description": "self_upload", + "DBTypeId": variables.get("DBTypeId"), + "Content": "W215c3FsZF0KYXV0b19pbmNyZW1lbnRfaW5jcmVtZW50ID0gMgpiYWNrX2xvZyA9IDIwMDAKYmlubG9nLWZvcm1hdCA9IE1JWEVECmNoYXJhY3Rlcl9zZXRfc2VydmVyID0gdXRmOApldmVudF9zY2hlZHVsZXIgPSBPTgpleHBpcmVfbG9nc19kYXlzID0gNwppbm5vZGJfYnVmZmVyX3Bvb2xfc2l6ZSA9IDUzNjg3MDkxMjAwCmlubm9kYl9maWxlX3Blcl90YWJsZSA9IDEKaW5ub2RiX2ZsdXNoX2xvZ19hdF90cnhfY29tbWl0ID0gMgppbm5vZGJfZmx1c2hfbWV0aG9kID0gT19ESVJFQ1QKaW5ub2RiX2lvX2NhcGFjaXR5ID0gMjAwMAppbm5vZGJfbG9nX2J1ZmZlcl9zaXplID0gODM4ODYwOAppbm5vZGJfbWF4X2RpcnR5X3BhZ2VzX3BjdCA9IDUwCmlubm9kYl9vcGVuX2ZpbGVzID0gMTAyNAppbm5vZGJfcmVhZF9pb190aHJlYWRzID0gOAppbm5vZGJfc29ydF9idWZmZXJfc2l6ZSA9IDEwNDg1NzYKaW5ub2RiX3RocmVhZF9jb25jdXJyZW5jeSA9IDIwCmlubm9kYl93cml0ZV9pb190aHJlYWRzID0gOAprZXlfYnVmZmVyX3NpemUgPSAzMzU1NDQzMgpsb2NhbF9pbmZpbGUgPSAxCmxvZ19iaW5fdHJ1c3RfZnVuY3Rpb25fY3JlYXRvcnMgPSAxCmxvbmdfcXVlcnlfdGltZSA9IDMKbWF4X2FsbG93ZWRfcGFja2V0ID0gMTY3NzcyMTYKbWF4X2Nvbm5lY3RfZXJyb3JzID0gMTAwMDAwMAptYXhfY29ubmVjdGlvbnMgPSAyMDAwCm15aXNhbV9zb3J0X2J1ZmZlcl9zaXplID0gODM4ODYwOApuZXRfYnVmZmVyX2xlbmd0aCA9IDgxOTIKcGVyZm9ybWFuY2Vfc2NoZW1hID0gMApwZXJmb3JtYW5jZV9zY2hlbWFfbWF4X3RhYmxlX2luc3RhbmNlcyA9IDIwMApxdWVyeV9jYWNoZV9zaXplID0gMApxdWVyeV9jYWNoZV90eXBlID0gMApyZWFkX2J1ZmZlcl9zaXplID0gMjYyMTQ0CnJlYWRfcm5kX2J1ZmZlcl9zaXplID0gNTI0Mjg4CnNraXBfbmFtZV9yZXNvbHZlID0gMQpzb3J0X2J1ZmZlcl9zaXplID0gNTI0Mjg4CnN5bmNfYmlubG9nID0gMQp0YWJsZV9vcGVuX2NhY2hlID0gMTI4CnRocmVhZF9jYWNoZV9zaXplID0gNTA=", + } + try: + resp = client.udb().upload_udb_param_group(d) + except exc.RetCodeException as e: + resp = e.json() + variables["upload_config_id"] = utest.value_at_path(resp, "GroupId") + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "ExtractUDBParamGroupResponse"), + ], + action="ExtractUDBParamGroup", +) +def extract_udb_param_group_10(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "GroupId": variables.get("upload_config_id"), + } + try: + resp = client.invoke("ExtractUDBParamGroup", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "ChangeUDBParamGroupResponse"), + ], + action="ChangeUDBParamGroup", +) +def change_udb_param_group_11(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "GroupId": variables.get("upload_config_id"), + "DBId": variables.get("DBId"), + } + try: + resp = client.invoke("ChangeUDBParamGroup", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=3, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeUDBInstanceResponse"), + ("str_eq", "DataSet.0.ParamGroupId", variables.get("upload_config_id")), + ], + action="DescribeUDBInstance", +) +def describe_udb_instance_12(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().describe_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "RestartUDBInstanceResponse"), + ], + action="RestartUDBInstance", +) +def restart_udb_instance_13(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().restart_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=100, + retry_interval=3, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeUDBInstanceResponse"), + ("str_eq", "DataSet.0.State", "Running"), + ], + action="DescribeUDBInstance", +) +def describe_udb_instance_14(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().describe_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeUDBInstanceByParamGroupResponse"), + ( + "str_eq", + "DataSet.0.Name", + funcs.concat(variables.get("DBName"), variables.get("DBTypeId")), + ), + ], + action="DescribeUDBInstanceByParamGroup", +) +def describe_udb_instance_by_param_group_15(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "GroupId": variables.get("upload_config_id"), + } + try: + resp = client.invoke("DescribeUDBInstanceByParamGroup", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=1, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 7064)], + action="DeleteUDBParamGroup", +) +def delete_udb_param_group_16(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "GroupId": variables.get("upload_config_id"), + } + try: + resp = client.udb().delete_udb_param_group(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "StopUDBInstanceResponse"), + ], + action="StopUDBInstance", +) +def stop_udb_instance_17(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().stop_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=100, + retry_interval=3, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.DBTypeId", variables.get("DBTypeId")), + ("str_eq", "DataSet.0.State", "Shutoff"), + ], + action="DescribeUDBInstance", +) +def describe_udb_instance_18(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + "DBId": variables.get("DBId"), + "ClassType": "sql", + } + try: + resp = client.udb().describe_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=10, + fast_fail=False, + action="DeleteUDBInstance", +) +def delete_udb_instance_19(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().delete_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DeleteUDBParamGroup", +) +def delete_udb_param_group_20(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "GroupId": variables.get("create_config_id"), + } + try: + resp = client.udb().delete_udb_param_group(d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_503.py b/tests/test_services/test_set_503.py new file mode 100644 index 0000000..e9c6fa0 --- /dev/null +++ b/tests/test_services/test_set_503.py @@ -0,0 +1,391 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(503) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_503(client, variables): + scenario.initial(variables) + scenario.variables["Region"] = "cn-bj2" + scenario.variables["Zone"] = "cn-bj2-02" + scenario.variables["DBTypeId"] = "mysql-5.7" + scenario.variables["InstanceMode"] = "HA" + scenario.variables["InstanceType"] = "Normal" + scenario.variables["Port"] = 3306 + scenario.variables["MemoryLimit"] = 1000 + scenario.variables["DiskSpace"] = 20 + scenario.variables["DBName"] = "auto_habz_" + scenario.variables["UseSSD"] = False + scenario.run(client) + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUDBType", +) +def describe_udb_type_00(client, variables): + d = {"Zone": variables.get("Zone"), "Region": variables.get("Region")} + try: + resp = client.udb().describe_udb_type(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUDBParamGroup", +) +def describe_udb_param_group_01(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + } + try: + resp = client.udb().describe_udb_param_group(d) + except exc.RetCodeException as e: + resp = e.json() + variables["DataSet_paramGroup"] = utest.value_at_path(resp, "DataSet") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUDBInstancePrice", +) +def describe_udb_instance_price_02(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "MemoryLimit": variables.get("MemoryLimit"), + "DiskSpace": variables.get("DiskSpace"), + "DBTypeId": variables.get("DBTypeId"), + "Count": 1, + } + try: + resp = client.udb().describe_udb_instance_price(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CheckUDBInstanceAllowance", +) +def check_udb_instance_allowance_03(client, variables): + d = { + "Zone": variables.get("Zone"), + "UseSSD": variables.get("UseSSD"), + "Region": variables.get("Region"), + "MemoryLimit": variables.get("MemoryLimit"), + "DiskSpace": variables.get("DiskSpace"), + "Count": 1, + "ClassType": "SQL", + } + try: + resp = client.invoke("CheckUDBInstanceAllowance", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=1, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateUDBInstance", +) +def create_udb_instance_04(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Quantity": 0, + "Port": variables.get("Port"), + "ParamGroupId": funcs.search_value( + variables.get("DataSet_paramGroup"), + "DBTypeId", + variables.get("DBTypeId"), + "GroupId", + ), + "Name": funcs.concat( + variables.get("DBName"), variables.get("DBTypeId") + ), + "MemoryLimit": variables.get("MemoryLimit"), + "InstanceType": variables.get("InstanceType"), + "InstanceMode": variables.get("InstanceMode"), + "DiskSpace": variables.get("DiskSpace"), + "DBTypeId": variables.get("DBTypeId"), + "ChargeType": "Month", + "AdminPassword": "guanliyuanmima", + } + try: + resp = client.udb().create_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + variables["DBId"] = utest.value_at_path(resp, "DBId") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=2, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ( + "str_eq", + "DataSet.0.Name", + funcs.concat(variables.get("DBName"), variables.get("DBTypeId")), + ), + ("str_eq", "DataSet.0.DBTypeId", variables.get("DBTypeId")), + ], + action="DescribeUDBInstance", +) +def describe_udb_instance_05(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + "DBId": variables.get("DBId"), + "ClassType": "sql", + } + try: + resp = client.udb().describe_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=50, + retry_interval=10, + startup_delay=30, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "State", "Running"), + ], + action="DescribeUDBInstanceState", +) +def describe_udb_instance_state_06(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().describe_udb_instance_state(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeUDBInstanceUpgradePrice", +) +def describe_udb_instance_upgrade_price_07(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "MemoryLimit": variables.get("MemoryLimit") + 1, + "DiskSpace": variables.get("DiskSpace") + 1, + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().describe_udb_instance_upgrade_price(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CheckUDBInstanceAllowance", +) +def check_udb_instance_allowance_08(client, variables): + d = { + "Zone": variables.get("Zone"), + "UseSSD": variables.get("UseSSD"), + "Region": variables.get("Region"), + "MemoryLimit": variables.get("MemoryLimit") + 1, + "DiskSpace": variables.get("DiskSpace") + 1, + "Count": 1, + "ClassType": "SQL", + } + try: + resp = client.invoke("CheckUDBInstanceAllowance", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=60, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="ResizeUDBInstance", +) +def resize_udb_instance_09(client, variables): + d = { + "Zone": variables.get("Zone"), + "UseSSD": variables.get("UseSSD"), + "Region": variables.get("Region"), + "MemoryLimit": variables.get("MemoryLimit") + 1, + "DiskSpace": variables.get("DiskSpace") + 1, + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().resize_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=90, + retry_interval=10, + startup_delay=240, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ( + "str_eq", + "DataSet.0.Name", + funcs.concat(variables.get("DBName"), variables.get("DBTypeId")), + ), + ("str_eq", "DataSet.0.DBTypeId", variables.get("DBTypeId")), + ("str_eq", "DataSet.0.State", "Running"), + ("str_eq", "DataSet.0.MemoryLimit", variables.get("MemoryLimit") + 1), + ("str_eq", "DataSet.0.DiskSpace", variables.get("DiskSpace") + 10), + ], + action="DescribeUDBInstance", +) +def describe_udb_instance_10(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + "DBId": variables.get("DBId"), + "ClassType": "sql", + } + try: + resp = client.udb().describe_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=5, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="StopUDBInstance", +) +def stop_udb_instance_11(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().stop_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=100, + retry_interval=3, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ( + "str_eq", + "DataSet.0.Name", + funcs.concat(variables.get("DBName"), variables.get("DBTypeId")), + ), + ("str_eq", "DataSet.0.DBTypeId", variables.get("DBTypeId")), + ("str_eq", "DataSet.0.State", "Shutoff"), + ], + action="DescribeUDBInstance", +) +def describe_udb_instance_12(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 100, + "DBId": variables.get("DBId"), + "ClassType": "sql", + } + try: + resp = client.udb().describe_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=10, + fast_fail=False, + action="DeleteUDBInstance", +) +def delete_udb_instance_13(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "DBId": variables.get("DBId"), + } + try: + resp = client.udb().delete_udb_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_687.py b/tests/test_services/test_set_687.py new file mode 100644 index 0000000..3ac0902 --- /dev/null +++ b/tests/test_services/test_set_687.py @@ -0,0 +1,554 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(687) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_687(client, variables): + scenario.initial(variables) + scenario.variables["VPC_name_1"] = "VPC_api_test_1" + scenario.variables["remark"] = "remark_api_test" + scenario.variables["tag"] = "tag_api_test" + scenario.variables["Subnet_name_1_1"] = "subnet_1_1" + scenario.variables["subnet_netmask"] = 24 + scenario.variables["project_id"] = "org-achi1o" + scenario.run(client) + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "GetProjectListResponse"), + ], + action="GetProjectList", +) +def get_project_list_00(client, variables): + d = {} + try: + resp = client.uaccount().get_project_list(d) + except exc.RetCodeException as e: + resp = e.json() + variables["project_list"] = utest.value_at_path(resp, "ProjectSet") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=2, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateVPC", +) +def create_vpc_01(client, variables): + d = { + "Tag": variables.get("tag"), + "Remark": variables.get("remark"), + "Region": variables.get("Region"), + "Network": ["172.16.16.0/20"], + "Name": variables.get("VPC_name_1"), + } + try: + resp = client.vpc().create_vpc(d) + except exc.RetCodeException as e: + resp = e.json() + variables["VPCId_1"] = utest.value_at_path(resp, "VPCId") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=2, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateSubnet", +) +def create_subnet_02(client, variables): + d = { + "VPCId": variables.get("VPCId_1"), + "Tag": variables.get("tag"), + "SubnetName": variables.get("Subnet_name_1_1"), + "Subnet": "172.16.17.0", + "Remark": variables.get("remark"), + "Region": variables.get("Region"), + "Netmask": variables.get("subnet_netmask"), + } + try: + resp = client.vpc().create_subnet(d) + except exc.RetCodeException as e: + resp = e.json() + variables["SubnetId_1_1"] = utest.value_at_path(resp, "SubnetId") + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=2, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "UpdateSubnetAttributeResponse"), + ], + action="UpdateSubnetAttribute", +) +def update_subnet_attribute_03(client, variables): + d = { + "Tag": "qa", + "SubnetId": variables.get("SubnetId_1_1"), + "Region": variables.get("Region"), + } + try: + resp = client.vpc().update_subnet_attribute(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=2, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DescribeSubnet", +) +def describe_subnet_04(client, variables): + d = { + "SubnetId": variables.get("SubnetId_1_1"), + "Region": variables.get("Region"), + "Offset": 1, + "Limit": 1, + } + try: + resp = client.vpc().describe_subnet(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + action="CreateVPC", +) +def create_vpc_05(client, variables): + d = { + "Region": variables.get("Region"), + "Network": ["192.168.16.0/20"], + "Name": "vpc_2", + } + try: + resp = client.vpc().create_vpc(d) + except exc.RetCodeException as e: + resp = e.json() + variables["VPCId_2"] = utest.value_at_path(resp, "VPCId") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=2, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateSubnet", +) +def create_subnet_06(client, variables): + d = { + "VPCId": variables.get("VPCId_2"), + "SubnetName": "Subnet_2_1", + "Subnet": "192.168.17.0", + "Region": variables.get("Region"), + "Netmask": variables.get("subnet_netmask"), + } + try: + resp = client.vpc().create_subnet(d) + except exc.RetCodeException as e: + resp = e.json() + variables["SubnetId_2_1"] = utest.value_at_path(resp, "SubnetId") + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=2, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "CreateSubnetResponse"), + ], + action="CreateSubnet", +) +def create_subnet_07(client, variables): + d = { + "VPCId": variables.get("VPCId_2"), + "Tag": "Subnet_2_2", + "SubnetName": "Subnet_2_2", + "Subnet": "192.168.18.0", + "Region": variables.get("Region"), + "Netmask": variables.get("subnet_netmask"), + } + try: + resp = client.vpc().create_subnet(d) + except exc.RetCodeException as e: + resp = e.json() + variables["SubnetId_2_2"] = utest.value_at_path(resp, "SubnetId") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=2, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.VPCId", variables.get("VPCId_1")), + ("str_eq", "DataSet.0.VPCName", variables.get("VPC_name_1")), + ("str_eq", "DataSet.0.SubnetId", variables.get("SubnetId_1_1")), + ("str_eq", "DataSet.0.SubnetName", variables.get("Subnet_name_1_1")), + ("str_eq", "DataSet.0.Tag", "qa"), + ("str_eq", "DataSet.0.Remark", variables.get("remark")), + ("str_eq", "DataSet.0.SubnetType", 2), + ("str_eq", "DataSet.0.Netmask", 24), + ], + action="DescribeSubnet", +) +def describe_subnet_08(client, variables): + d = { + "VPCId": variables.get("VPCId_1"), + "SubnetId": variables.get("SubnetId_1_1"), + "Region": variables.get("Region"), + } + try: + resp = client.vpc().describe_subnet(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="AllocateVIP", +) +def allocate_vip_09(client, variables): + d = { + "Zone": variables.get("Zone"), + "VPCId": variables.get("VPCId_1"), + "SubnetId": variables.get("SubnetId_1_1"), + "Remark": "vip_tag1", + "Region": variables.get("Region"), + "Name": "vip_api_auto", + } + try: + resp = client.unet().allocate_vip(d) + except exc.RetCodeException as e: + resp = e.json() + variables["VIPId_1"] = utest.value_at_path(resp, "VIPSet.0.VIPId") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=2, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "VIPSet.0.VPCId", variables.get("VPCId_1")), + ("str_eq", "VIPSet.0.VIPId", variables.get("VIPId_1")), + ("str_eq", "VIPSet.0.SubnetId", variables.get("SubnetId_1_1")), + ], + action="DescribeVIP", +) +def describe_vip_10(client, variables): + d = { + "Zone": variables.get("Zone"), + "VPCId": variables.get("VPCId_1"), + "SubnetId": variables.get("SubnetId_1_1"), + "Region": variables.get("Region"), + } + try: + resp = client.unet().describe_vip(d) + except exc.RetCodeException as e: + resp = e.json() + variables["VIP_ip_1"] = utest.value_at_path(resp, "DataSet.0") + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "TotalCount", 1), + ("str_eq", "DataSet.0.ResourceId", variables.get("VIPId_1")), + ("str_eq", "DataSet.0.IP", variables.get("VIP_ip_1")), + ], + action="DescribeSubnetResource", +) +def describe_subnet_resource_11(client, variables): + d = { + "SubnetId": variables.get("SubnetId_1_1"), + "Region": variables.get("Region"), + "Offset": 0, + "Limit": 20, + } + try: + resp = client.vpc().describe_subnet_resource(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="ReleaseVIP", +) +def release_vip_12(client, variables): + d = { + "Zone": variables.get("Zone"), + "VIPId": variables.get("VIPId_1"), + "Region": variables.get("Region"), + } + try: + resp = client.unet().release_vip(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=1, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DeleteSubnet", +) +def delete_subnet_13(client, variables): + d = { + "SubnetId": variables.get("SubnetId_1_1"), + "Region": variables.get("Region"), + } + try: + resp = client.vpc().delete_subnet(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=1, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DeleteSubnet", +) +def delete_subnet_14(client, variables): + d = { + "SubnetId": variables.get("SubnetId_2_1"), + "Region": variables.get("Region"), + } + try: + resp = client.vpc().delete_subnet(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=1, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DeleteSubnet", +) +def delete_subnet_15(client, variables): + d = { + "SubnetId": variables.get("SubnetId_2_2"), + "Region": variables.get("Region"), + } + try: + resp = client.vpc().delete_subnet(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "AddVPCNetworkResponse"), + ], + action="AddVPCNetwork", +) +def add_vpc_network_16(client, variables): + d = { + "VPCId": variables.get("VPCId_1"), + "Region": variables.get("Region"), + "Network": ["10.100.96.0/20"], + } + try: + resp = client.vpc().add_vpc_network(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=2, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeVPCResponse"), + ], + action="DescribeVPC", +) +def describe_vpc_17(client, variables): + d = { + "VPCIds": [variables.get("VPCId_1")], + "Region": variables.get("Region"), + } + try: + resp = client.vpc().describe_vpc(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateVPCIntercom", +) +def create_vpc_intercom_18(client, variables): + d = { + "VPCId": variables.get("VPCId_1"), + "Region": variables.get("Region"), + "DstVPCId": variables.get("VPCId_2"), + "DstRegion": variables.get("Region"), + "DstProjectId": funcs.search_value( + variables.get("project_list"), "IsDefault", True, "ProjectId" + ), + } + try: + resp = client.vpc().create_vpc_intercom(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=2, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "DataSet.0.VPCId", variables.get("VPCId_2")), + ], + action="DescribeVPCIntercom", +) +def describe_vpc_intercom_19(client, variables): + d = {"VPCId": variables.get("VPCId_1"), "Region": variables.get("Region")} + try: + resp = client.vpc().describe_vpc_intercom(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=0, + retry_interval=0, + startup_delay=2, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DeleteVPCIntercom", +) +def delete_vpc_intercom_20(client, variables): + d = { + "VPCId": variables.get("VPCId_1"), + "Region": variables.get("Region"), + "DstVPCId": variables.get("VPCId_2"), + "DstRegion": variables.get("Region"), + "DstProjectId": funcs.search_value( + variables.get("project_list"), "IsDefault", True, "ProjectId" + ), + } + try: + resp = client.vpc().delete_vpc_intercom(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=2, + fast_fail=False, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="DeleteVPC", +) +def delete_vpc_21(client, variables): + d = {"VPCId": variables.get("VPCId_1"), "Region": variables.get("Region")} + try: + resp = client.vpc().delete_vpc(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=2, + fast_fail=False, + action="DeleteVPC", +) +def delete_vpc_22(client, variables): + d = {"VPCId": variables.get("VPCId_2"), "Region": variables.get("Region")} + try: + resp = client.vpc().delete_vpc(d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_services/test_set_867.py b/tests/test_services/test_set_867.py new file mode 100644 index 0000000..032be42 --- /dev/null +++ b/tests/test_services/test_set_867.py @@ -0,0 +1,711 @@ +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +import pytest +import logging +from ucloud.core import exc +from ucloud.testing import env, funcs, op, utest + +logger = logging.getLogger(__name__) +scenario = utest.Scenario(867) + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_set_867(client, variables): + scenario.initial(variables) + scenario.variables["Password"] = "Z3VhbmxpeXVhbm1pbWExMjMhQCM=" + scenario.variables["SnapshotSysName"] = "snapshot-ARK-SYS-01" + scenario.variables["SnapshotSysDesc"] = "snapshot-ARK-SYS-01-desc" + scenario.variables["SnapDiskType"] = "LocalBoot" + scenario.variables["SnapshotDataNameModify"] = "snapshot-ARK-DATA-01-modify" + scenario.variables[ + "SnapshotDataDescModify" + ] = "snapshot-ARK-DATA-01-desc-Modify" + scenario.variables["UhostName"] = "uhost-snapshot-ARK-auto-api-1" + scenario.variables["SnapshotDataName"] = "snapshot-ARK-DATA-01" + scenario.variables["SnapshotDataDesc"] = "snapshot-ARK-DATA-01-desc" + scenario.variables[ + "CreateFromTimeMachinePassword" + ] = "Z3VhbmxpeXVhbm1pbWExMjMhQCM=" + scenario.variables["ImageID"] = "#{u_get_image_resource($Region,$Zone)}" + scenario.run(client) + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=False, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeImageResponse"), + ], + action="DescribeImage", +) +def describe_image_00(client, variables): + d = { + "Zone": variables.get("Zone"), + "Region": variables.get("Region"), + "OsType": "Linux", + "ImageType": "Base", + } + try: + resp = client.uhost().describe_image(d) + except exc.RetCodeException as e: + resp = e.json() + variables["ImageID"] = utest.value_at_path(resp, "ImageSet.0.ImageId") + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [("str_eq", "RetCode", 0)], + action="CreateUHostInstance", +) +def create_uhost_instance_01(client, variables): + d = { + "Zone": variables.get("Zone"), + "TimemachineFeature": "no", + "Region": variables.get("Region"), + "Password": "VXFhNzg5VGVzdCFAIyQ7LA==", + "Name": variables.get("UhostName"), + "Memory": 1024, + "LoginMode": "Password", + "ImageId": variables.get("ImageID"), + "HotplugFeature": False, + "GPU": False, + "DiskSpace": 10, + "CPU": 1, + } + try: + resp = client.uhost().create_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + variables["hostId"] = utest.value_at_path(resp, "UHostIds.0") + return resp + + +@scenario.step( + max_retries=100, + retry_interval=30, + startup_delay=10, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "UHostSet.0.State", "Running"), + ("str_eq", "UHostSet.0.TimemachineFeature", "no"), + ("str_eq", "UHostSet.0.BootDiskState", "Normal"), + ], + action="DescribeUHostInstance", +) +def describe_uhost_instance_02(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostIds": [variables.get("hostId")], + "Region": variables.get("Region"), + } + try: + resp = client.uhost().describe_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "StopUHostInstanceResponse"), + ], + action="StopUHostInstance", +) +def stop_uhost_instance_03(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("hostId"), + "Region": variables.get("Region"), + } + try: + resp = client.uhost().stop_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=10, + retry_interval=10, + startup_delay=10, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "UHostSet.0.State", "Stopped"), + ], + action="DescribeUHostInstance", +) +def describe_uhost_instance_04(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostIds": [variables.get("hostId")], + "Region": variables.get("Region"), + } + try: + resp = client.uhost().describe_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "UpgradeToArkUHostInstanceResponse"), + ], + action="UpgradeToArkUHostInstance", +) +def upgrade_to_ark_uhost_instance_05(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostIds": [variables.get("hostId")], + "Region": variables.get("Region"), + } + try: + resp = client.uhost().upgrade_to_ark_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=200, + retry_interval=30, + startup_delay=100, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "UHostSet.0.State", "Stopped"), + ("str_eq", "UHostSet.0.TimemachineFeature", "yes"), + ("str_eq", "UHostSet.0.BootDiskState", "Normal"), + ("str_eq", "UHostSet.0.DiskSet.0.BackupType", "DATAARK"), + ], + action="DescribeUHostInstance", +) +def describe_uhost_instance_06(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostIds": [variables.get("hostId")], + "Region": variables.get("Region"), + } + try: + resp = client.uhost().describe_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "StartUHostInstanceResponse"), + ], + action="StartUHostInstance", +) +def start_uhost_instance_07(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("hostId"), + "Region": variables.get("Region"), + } + try: + resp = client.uhost().start_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=30, + startup_delay=10, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "UHostSet.0.State", "Running"), + ("str_eq", "UHostSet.0.TimemachineFeature", "yes"), + ("str_eq", "UHostSet.0.DiskSet.0.BackupType", "DATAARK"), + ], + action="DescribeUHostInstance", +) +def describe_uhost_instance_08(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostIds": [variables.get("hostId")], + "Region": variables.get("Region"), + } + try: + resp = client.uhost().describe_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=60, + retry_interval=60, + startup_delay=100, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeUhostTmMetaResponse"), + ("str_eq", "UtmStatus", "normal"), + ], + action="DescribeUhostTmMeta", +) +def describe_uhost_tm_meta_09(client, variables): + d = { + "Zone": variables.get("Zone"), + "UhostId": variables.get("hostId"), + "Region": variables.get("Region"), + } + try: + resp = client.invoke("DescribeUhostTmMeta", d) + except exc.RetCodeException as e: + resp = e.json() + variables["VdiskIdSys"] = utest.value_at_path(resp, "DataSet.0.VdiskId") + variables["VdiskIdData"] = utest.value_at_path(resp, "DataSet.1.VdiskId") + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeVDiskTmListResponse"), + ], + action="DescribeVDiskTmList", +) +def describe_v_disk_tm_list_10(client, variables): + d = { + "Zone": variables.get("Zone"), + "VDiskId": variables.get("VdiskIdSys"), + "SnapshotType": "all", + "Region": variables.get("Region"), + } + try: + resp = client.invoke("DescribeVDiskTmList", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeVDiskTmListResponse"), + ], + action="DescribeVDiskTmList", +) +def describe_v_disk_tm_list_11(client, variables): + d = { + "Zone": variables.get("Zone"), + "VDiskId": variables.get("VdiskIdData"), + "SnapshotType": "all", + "Region": variables.get("Region"), + } + try: + resp = client.invoke("DescribeVDiskTmList", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "CreateUserVDiskSnapshotResponse"), + ], + action="CreateUserVDiskSnapshot", +) +def create_user_v_disk_snapshot_12(client, variables): + d = { + "Zone": variables.get("Zone"), + "VDiskId": variables.get("VdiskIdSys"), + "Region": variables.get("Region"), + "Name": variables.get("SnapshotSysName"), + "Comment": variables.get("SnapshotSysDesc"), + } + try: + resp = client.invoke("CreateUserVDiskSnapshot", d) + except exc.RetCodeException as e: + resp = e.json() + variables["VdiskSnapIDSys"] = utest.value_at_path(resp, "SnapshotId.0") + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "CreateUserVDiskSnapshotResponse"), + ], + action="CreateUserVDiskSnapshot", +) +def create_user_v_disk_snapshot_13(client, variables): + d = { + "Zone": variables.get("Zone"), + "VDiskId": variables.get("VdiskIdData"), + "Region": variables.get("Region"), + "Name": variables.get("SnapshotDataName"), + "Comment": variables.get("SnapshotDataDesc"), + } + try: + resp = client.invoke("CreateUserVDiskSnapshot", d) + except exc.RetCodeException as e: + resp = e.json() + variables["VdiskSnapIDData"] = utest.value_at_path(resp, "SnapshotId.0") + return resp + + +@scenario.step( + max_retries=30, + retry_interval=30, + startup_delay=10, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeSnapshotResponse"), + ( + "str_eq", + "UHostSnapshotSet.0.SnapshotId", + variables.get("VdiskSnapIDSys"), + ), + ( + "str_eq", + "UHostSnapshotSet.0.SnapshotName", + variables.get("SnapshotSysName"), + ), + ("str_eq", "UHostSnapshotSet.0.DiskType", "LocalBoot"), + ( + "str_eq", + "UHostSnapshotSet.0.ResourceName", + variables.get("UhostName"), + ), + ( + "str_eq", + "UHostSnapshotSet.0.SnapshotDescription", + variables.get("SnapshotSysDesc"), + ), + ("str_eq", "UHostSnapshotSet.0.State", "Normal"), + ], + action="DescribeSnapshot", +) +def describe_snapshot_14(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("hostId"), + "SnapshotIds": [variables.get("VdiskSnapIDSys")], + "Region": variables.get("Region"), + } + try: + resp = client.invoke("DescribeSnapshot", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=10, + startup_delay=10, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeSnapshotResponse"), + ( + "str_eq", + "UHostSnapshotSet.0.SnapshotId", + variables.get("VdiskSnapIDData"), + ), + ( + "str_eq", + "UHostSnapshotSet.0.SnapshotName", + variables.get("SnapshotDataName"), + ), + ("str_eq", "UHostSnapshotSet.0.DiskType", "LocalData"), + ( + "str_eq", + "UHostSnapshotSet.0.ResourceName", + variables.get("UhostName"), + ), + ( + "str_eq", + "UHostSnapshotSet.0.SnapshotDescription", + variables.get("SnapshotDataDesc"), + ), + ("str_eq", "UHostSnapshotSet.0.State", "Normal"), + ], + action="DescribeSnapshot", +) +def describe_snapshot_15(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("hostId"), + "SnapshotIds": [variables.get("VdiskSnapIDData")], + "Region": variables.get("Region"), + } + try: + resp = client.invoke("DescribeSnapshot", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "ModifySnapshotResponse"), + ], + action="ModifySnapshot", +) +def modify_snapshot_16(client, variables): + d = { + "Zone": variables.get("Zone"), + "SnapshotName": variables.get("SnapshotDataNameModify"), + "SnapshotId": variables.get("VdiskSnapIDData"), + "SnapshotDescription": variables.get("SnapshotDataDescModify"), + "Region": variables.get("Region"), + } + try: + resp = client.invoke("ModifySnapshot", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=10, + startup_delay=10, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeSnapshotResponse"), + ( + "str_eq", + "UHostSnapshotSet.0.SnapshotId", + variables.get("VdiskSnapIDData"), + ), + ( + "str_eq", + "UHostSnapshotSet.0.SnapshotName", + variables.get("SnapshotDataNameModify"), + ), + ("str_eq", "UHostSnapshotSet.0.DiskType", "LocalData"), + ( + "str_eq", + "UHostSnapshotSet.0.ResourceName", + variables.get("UhostName"), + ), + ( + "str_eq", + "UHostSnapshotSet.0.SnapshotDescription", + variables.get("SnapshotDataDescModify"), + ), + ("str_eq", "UHostSnapshotSet.0.State", "Normal"), + ], + action="DescribeSnapshot", +) +def describe_snapshot_17(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("hostId"), + "SnapshotIds": [variables.get("VdiskSnapIDData")], + "Region": variables.get("Region"), + } + try: + resp = client.invoke("DescribeSnapshot", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DeleteSnapshotResponse"), + ], + action="DeleteSnapshot", +) +def delete_snapshot_18(client, variables): + d = { + "Zone": variables.get("Zone"), + "SnapshotId": variables.get("VdiskSnapIDSys"), + "Region": variables.get("Region"), + } + try: + resp = client.invoke("DeleteSnapshot", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DeleteSnapshotResponse"), + ], + action="DeleteSnapshot", +) +def delete_snapshot_19(client, variables): + d = { + "Zone": variables.get("Zone"), + "SnapshotId": variables.get("VdiskSnapIDData"), + "Region": variables.get("Region"), + } + try: + resp = client.invoke("DeleteSnapshot", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=30, + startup_delay=10, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "DescribeSnapshotResponse"), + ( + "object_not_contains", + "UHostSnapshotSet", + variables.get("VdiskSnapIDSys"), + ), + ( + "object_not_contains", + "UHostSnapshotSet", + variables.get("VdiskSnapIDData"), + ), + ], + action="DescribeSnapshot", +) +def describe_snapshot_20(client, variables): + d = {"Zone": variables.get("Zone"), "Region": variables.get("Region")} + try: + resp = client.invoke("DescribeSnapshot", d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "StopUHostInstanceResponse"), + ], + action="StopUHostInstance", +) +def stop_uhost_instance_21(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("hostId"), + "Region": variables.get("Region"), + } + try: + resp = client.uhost().stop_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=30, + retry_interval=10, + startup_delay=10, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "UHostSet.0.State", "Stopped"), + ], + action="DescribeUHostInstance", +) +def describe_uhost_instance_22(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostIds": [variables.get("hostId")], + "Region": variables.get("Region"), + } + try: + resp = client.uhost().describe_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp + + +@scenario.step( + max_retries=3, + retry_interval=1, + startup_delay=0, + fast_fail=True, + validators=lambda variables: [ + ("str_eq", "RetCode", 0), + ("str_eq", "Action", "TerminateUHostInstanceResponse"), + ], + action="TerminateUHostInstance", +) +def terminate_uhost_instance_23(client, variables): + d = { + "Zone": variables.get("Zone"), + "UHostId": variables.get("hostId"), + "Region": variables.get("Region"), + } + try: + resp = client.uhost().terminate_uhost_instance(d) + except exc.RetCodeException as e: + resp = e.json() + return resp diff --git a/tests/test_testing/test_utest.py b/tests/test_testing/test_utest.py index d2c4135..a75429f 100644 --- a/tests/test_testing/test_utest.py +++ b/tests/test_testing/test_utest.py @@ -1,7 +1,15 @@ # -*- coding: utf-8 -*- import pytest -from ucloud.testing import utest +from ucloud.testing import utest, env + + +@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason()) +def test_acc_pre_check(client): + assert str(client) + assert client.config.to_dict() + assert client.credential.to_dict() + env.pre_check_env() def test_value_at_path(): @@ -21,4 +29,7 @@ def test_value_at_path(): "TotalBandwidth": 6, "TotalCount": 3, } - assert utest.value_at_path(d, "EIPSet.0.Resource.ResourceID") == "uhost-war3png3" + assert ( + utest.value_at_path(d, "EIPSet.0.Resource.ResourceID") + == "uhost-war3png3" + ) diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 1170d17..0000000 --- a/tox.ini +++ /dev/null @@ -1,21 +0,0 @@ -[tox] -skipsdist = True - -[global] -wheel_dir = {homedir}/.wheelhouse -find_links = - {homedir}/.wheelhouse - {homedir}/.pip-cache - -[testenv] -deps = - wheel - -basepython = - py27: python2.7 - -passenv = * - -commands = - pip install -e .[test] - pytest -v . diff --git a/ucloud/__init__.py b/ucloud/__init__.py index 4c48b5a..40a96af 100644 --- a/ucloud/__init__.py +++ b/ucloud/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- diff --git a/ucloud/client.py b/ucloud/client.py index 2fcdc0d..b73fc01 100644 --- a/ucloud/client.py +++ b/ucloud/client.py @@ -1,74 +1,94 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core import client - - -class Client(client.Client): - def __init__(self, config, 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 - - return StepFlowClient( - self._config, self.transport, self.middleware, self.logger - ) - - def uaccount(self): - from ucloud.services.uaccount.client import UAccountClient - - return UAccountClient( - self._config, self.transport, self.middleware, self.logger - ) - - def udb(self): - from ucloud.services.udb.client import UDBClient - - return UDBClient(self._config, self.transport, self.middleware, self.logger) - - def udpn(self): - from ucloud.services.udpn.client import UDPNClient - - return UDPNClient(self._config, self.transport, self.middleware, self.logger) - - def udisk(self): - from ucloud.services.udisk.client import UDiskClient - - return UDiskClient(self._config, self.transport, self.middleware, self.logger) - - def uhost(self): - from ucloud.services.uhost.client import UHostClient - - return UHostClient(self._config, self.transport, self.middleware, self.logger) - - def ulb(self): - from ucloud.services.ulb.client import ULBClient - - return ULBClient(self._config, self.transport, self.middleware, self.logger) - - def umem(self): - from ucloud.services.umem.client import UMemClient - - return UMemClient(self._config, self.transport, self.middleware, self.logger) - - def unet(self): - from ucloud.services.unet.client import UNetClient - - return UNetClient(self._config, self.transport, self.middleware, self.logger) - - def uphost(self): - from ucloud.services.uphost.client import UPHostClient - - return UPHostClient(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) +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core import client + + +class Client(client.Client): + def __init__(self, config, 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 + + return StepFlowClient( + self._config, self.transport, self.middleware, self.logger + ) + + def uaccount(self): + from ucloud.services.uaccount.client import UAccountClient + + return UAccountClient( + self._config, self.transport, self.middleware, self.logger + ) + + def udb(self): + from ucloud.services.udb.client import UDBClient + + return UDBClient( + self._config, self.transport, self.middleware, self.logger + ) + + def udpn(self): + from ucloud.services.udpn.client import UDPNClient + + return UDPNClient( + self._config, self.transport, self.middleware, self.logger + ) + + def udisk(self): + from ucloud.services.udisk.client import UDiskClient + + return UDiskClient( + self._config, self.transport, self.middleware, self.logger + ) + + def uhost(self): + from ucloud.services.uhost.client import UHostClient + + return UHostClient( + self._config, self.transport, self.middleware, self.logger + ) + + def ulb(self): + from ucloud.services.ulb.client import ULBClient + + return ULBClient( + self._config, self.transport, self.middleware, self.logger + ) + + def umem(self): + from ucloud.services.umem.client import UMemClient + + return UMemClient( + self._config, self.transport, self.middleware, self.logger + ) + + def unet(self): + from ucloud.services.unet.client import UNetClient + + return UNetClient( + self._config, self.transport, self.middleware, self.logger + ) + + def uphost(self): + from ucloud.services.uphost.client import UPHostClient + + return UPHostClient( + 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/core/__init__.py b/ucloud/core/__init__.py index 4c48b5a..40a96af 100644 --- a/ucloud/core/__init__.py +++ b/ucloud/core/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- diff --git a/ucloud/core/auth/__init__.py b/ucloud/core/auth/__init__.py index 1abbd15..09e1eff 100644 --- a/ucloud/core/auth/__init__.py +++ b/ucloud/core/auth/__init__.py @@ -1,5 +1,5 @@ -# -*- coding: utf-8 -*- - -from ucloud.core.auth._cfg import Credential - -__all__ = ["Credential"] +# -*- coding: utf-8 -*- + +from ucloud.core.auth._cfg import Credential + +__all__ = ["Credential"] diff --git a/ucloud/core/auth/_cfg.py b/ucloud/core/auth/_cfg.py index ae7b4d5..7b2264f 100644 --- a/ucloud/core/auth/_cfg.py +++ b/ucloud/core/auth/_cfg.py @@ -1,72 +1,72 @@ -# -*- coding: utf-8 -*- - -import hashlib -from collections import OrderedDict -from ucloud.core.typesystem import schema, fields - - -class CredentialSchema(schema.Schema): - fields = { - "public_key": fields.Str(required=True), - "private_key": fields.Str(required=True), - } - - -def verify_ac(private_key, params): - """ calculate signature by private_key/public_key - - the keys can be found on `APIKey documentation `__ - - >>> verify_ac("my_private_key", {"foo": "bar"}) - '634edc1bb957c0d65e5ab5494cf3b7784fbc87af' - - >>> verify_ac("my_private_key", {"foo": "bar"}) - '634edc1bb957c0d65e5ab5494cf3b7784fbc87af' - - :param private_key: private key - :param params: - :return: - """ - params = OrderedDict(sorted(params.items(), key=lambda item: item[0])) - simplified = "" - for key, value in params.items(): - simplified += str(key) + str(value) - simplified += private_key - hash_new = hashlib.sha1() - hash_new.update(simplified.encode("utf-8")) - hash_value = hash_new.hexdigest() - return hash_value - - -class Credential(object): - """ credential is the object to store credential information - - the keys can be found on `APIKey documentation `__ - - it can calculate signature for OpenAPI: - - >>> cred = Credential('my_public_key', 'my_private_key') - >>> cred.verify_ac({"foo": "bar"}) - 'd4411ab30953fb0bbcb1e7313081f05e4e91a394' - - :param public_key: - :param private_key: - """ - - PUBLIC_KEY_NAME = "PublicKey" - - def __init__(self, public_key, private_key, **kwargs): - self.public_key = public_key - self.private_key = private_key - - def verify_ac(self, args): - args[Credential.PUBLIC_KEY_NAME] = self.public_key - return verify_ac(self.private_key, args) - - @classmethod - def from_dict(cls, d): - parsed = CredentialSchema().dumps(d) - return cls(**parsed) - - def to_dict(self): - return {"public_key": self.public_key, "private_key": self.private_key} +# -*- coding: utf-8 -*- + +import hashlib +from collections import OrderedDict +from ucloud.core.typesystem import schema, fields, encoder + + +class CredentialSchema(schema.Schema): + fields = { + "public_key": fields.Str(required=True), + "private_key": fields.Str(required=True), + } + + +def verify_ac(private_key, params): + """ calculate signature by private_key/public_key + + the keys can be found on `APIKey documentation `__ + + >>> verify_ac("my_private_key", {"foo": "bar"}) + '634edc1bb957c0d65e5ab5494cf3b7784fbc87af' + + >>> verify_ac("my_private_key", {"foo": "bar"}) + '634edc1bb957c0d65e5ab5494cf3b7784fbc87af' + + :param private_key: private key + :param params: + :return: + """ + params = OrderedDict(sorted(params.items(), key=lambda item: item[0])) + simplified = "" + for key, value in params.items(): + simplified += str(key) + encoder.encode_value(value) + simplified += private_key + hash_new = hashlib.sha1() + hash_new.update(simplified.encode("utf-8")) + hash_value = hash_new.hexdigest() + return hash_value + + +class Credential(object): + """ credential is the object to store credential information + + the keys can be found on `APIKey documentation `__ + + it can calculate signature for OpenAPI: + + >>> cred = Credential('my_public_key', 'my_private_key') + >>> cred.verify_ac({"foo": "bar"}) + 'd4411ab30953fb0bbcb1e7313081f05e4e91a394' + + :param public_key: + :param private_key: + """ + + PUBLIC_KEY_NAME = "PublicKey" + + def __init__(self, public_key, private_key, **kwargs): + self.public_key = public_key + self.private_key = private_key + + def verify_ac(self, args): + args[Credential.PUBLIC_KEY_NAME] = self.public_key + return verify_ac(self.private_key, args) + + @classmethod + def from_dict(cls, d): + parsed = CredentialSchema().dumps(d) + return cls(**parsed) + + def to_dict(self): + return {"public_key": self.public_key, "private_key": self.private_key} diff --git a/ucloud/core/client/__init__.py b/ucloud/core/client/__init__.py index 3a5f8b7..7db5e85 100644 --- a/ucloud/core/client/__init__.py +++ b/ucloud/core/client/__init__.py @@ -1,9 +1,9 @@ -# -*- coding: utf-8 -*- - -""" -Client -""" -from ucloud.core.client._cfg import Config -from ucloud.core.client._client import Client - -__all__ = ["Config", "Client"] +# -*- coding: utf-8 -*- + +""" +Client +""" +from ucloud.core.client._cfg import Config +from ucloud.core.client._client import Client + +__all__ = ["Config", "Client"] diff --git a/ucloud/core/client/_cfg.py b/ucloud/core/client/_cfg.py index c263d8d..4314822 100644 --- a/ucloud/core/client/_cfg.py +++ b/ucloud/core/client/_cfg.py @@ -1,81 +1,81 @@ -# -*- coding: utf-8 -*- - -import logging -from ucloud.core.typesystem import schema, fields - - -class ConfigSchema(schema.Schema): - fields = { - "region": fields.Str(required=True), - "project_id": fields.Str(), - "base_url": fields.Str(default="https://api.ucloud.cn"), - "user_agent": fields.Str(), - "timeout": fields.Int(default=30), - "max_retries": fields.Int(default=3), - "log_level": fields.Int(default=logging.INFO), - "validate_request": fields.Bool(default=True), - } - - -class Config(object): - """ - Config is the config of ucloud sdk, use for setting up - - :type region: str - :param region: Region is the region of backend service, - See also `Region list Documentation `_ - :type project_id: str - :param project_id: ProjectId is the unique identify of project, used for organize resources, - Most of resources should belong to a project. Sub-Account must have an project id. - See also `Project list Documentation `_ - :type base_url: str - :param base_url: BaseUrl is the url of backend api - :param user_agent: UserAgent is an attribute for sdk client, used for distinguish who is using sdk. - See also `User Agent `_ - It will be appended to the end of sdk user-agent. - eg. "MyAPP/0.10.1" -> "Python/3.7.0 Python-SDK/0.1.0 MyAPP/0.10.1" - :type timeout: int - :param timeout: Timeout is timeout for every request. - :type max_retries: int - :param max_retries: MaxRetries is the number of max retry times. - Set MaxRetries more than 0 to enable auto-retry for network and service availability problem - if auto-retry is enabled, it will enable default retry policy using exponential backoff. - :type log_level: int - :param log_level: LogLevel is equal to builtin logging level, - if logLevel not be set, use INFO level as default. - """ - - def __init__( - self, - region, - project_id=None, - base_url="https://api.ucloud.cn", - user_agent=None, - timeout=30, - max_retries=3, - log_level=logging.INFO, - **kwargs - ): - self.region = region - self.project_id = project_id - self.base_url = base_url - self.user_agent = user_agent - self.timeout = timeout - self.max_retries = max_retries - self.log_level = log_level - - @classmethod - def from_dict(cls, d): - parsed = ConfigSchema().dumps(d) - return cls(**parsed) - - def to_dict(self): - return { - "region": self.region, - "project_id": self.project_id, - "base_url": self.base_url, - "user_agent": self.user_agent, - "timeout": self.timeout, - "max_retries": self.max_retries, - "log_level": self.log_level, - } +# -*- coding: utf-8 -*- + +import logging +from ucloud.core.typesystem import schema, fields + + +class ConfigSchema(schema.Schema): + fields = { + "region": fields.Str(required=True), + "project_id": fields.Str(), + "base_url": fields.Str(default="https://api.ucloud.cn"), + "user_agent": fields.Str(), + "timeout": fields.Int(default=30), + "max_retries": fields.Int(default=3), + "log_level": fields.Int(default=logging.INFO), + "validate_request": fields.Bool(default=True), + } + + +class Config(object): + """ + Config is the config of ucloud sdk, use for setting up + + :type region: str + :param region: Region is the region of backend service, + See also `Region list Documentation `_ + :type project_id: str + :param project_id: ProjectId is the unique identify of project, used for organize resources, + Most of resources should belong to a project. Sub-Account must have an project id. + See also `Project list Documentation `_ + :type base_url: str + :param base_url: BaseUrl is the url of backend api + :param user_agent: UserAgent is an attribute for sdk client, used for distinguish who is using sdk. + See also `User Agent `_ + It will be appended to the end of sdk user-agent. + eg. "MyAPP/0.10.1" -> "Python/3.7.0 Python-SDK/0.1.0 MyAPP/0.10.1" + :type timeout: int + :param timeout: Timeout is timeout for every request. + :type max_retries: int + :param max_retries: MaxRetries is the number of max retry times. + Set MaxRetries more than 0 to enable auto-retry for network and service availability problem + if auto-retry is enabled, it will enable default retry policy using exponential backoff. + :type log_level: int + :param log_level: LogLevel is equal to builtin logging level, + if logLevel not be set, use INFO level as default. + """ + + def __init__( + self, + region, + project_id=None, + base_url="https://api.ucloud.cn", + user_agent=None, + timeout=30, + max_retries=3, + log_level=logging.INFO, + **kwargs + ): + self.region = region + self.project_id = project_id + self.base_url = base_url + self.user_agent = user_agent + self.timeout = timeout + self.max_retries = max_retries + self.log_level = log_level + + @classmethod + def from_dict(cls, d): + parsed = ConfigSchema().dumps(d) + return cls(**parsed) + + def to_dict(self): + return { + "region": self.region, + "project_id": self.project_id, + "base_url": self.base_url, + "user_agent": self.user_agent, + "timeout": self.timeout, + "max_retries": self.max_retries, + "log_level": self.log_level, + } diff --git a/ucloud/core/client/_client.py b/ucloud/core/client/_client.py index d60405c..236b68d 100644 --- a/ucloud/core/client/_client.py +++ b/ucloud/core/client/_client.py @@ -1,111 +1,119 @@ -# -*- coding: utf-8 -*- - -import logging -import sys -from ucloud import version -from ucloud.core.client._cfg import Config -from ucloud.core.transport import Transport, RequestsTransport, Request, Response -from ucloud.core.utils import log -from ucloud.core.utils.middleware import Middleware -from ucloud.core import auth, exc - -default_transport = RequestsTransport() - - -class Client(object): - def __init__(self, config, transport=None, middleware=None, logger=None): - cfg, cred = self._parse_dict_config(config) - self.config = cfg - self.credential = cred - self.transport = transport or default_transport - self.logger = logger or log.default_logger - if middleware is None: - middleware = Middleware() - middleware.response(self.logged_response_handler) - middleware.request(self.logged_request_handler) - self._middleware = middleware - - def invoke(self, action, args=None, **options): - """ invoke will invoke the action with arguments data and options - - :param str action: the api action, like `CreateUHostInstance` - :param dict args: arguments of api(action), see doc: `UCloud API Documentation `__ - :return: - """ - retries = 0 - max_retries = options.get("max_retries") or self.config.max_retries - while retries <= max_retries: - try: - return self._send(action, args or {}, **options) - except exc.UCloudException as e: - if e.retryable and retries != max_retries: - logging.info( - "Retrying {action}: {args}".format(action=action, args=args) - ) - retries += 1 - continue - raise e - except Exception as e: - raise e - raise exc.RetryTimeoutException("max retries is reached") - - @property - def middleware(self): - return self._middleware - - def logged_request_handler(self, req): - self.logger.info("[request] {} {}".format(req.get("Action", ""), req)) - return req - - def logged_response_handler(self, resp): - self.logger.info("[response] {} {}".format(resp.get("Action", ""), resp)) - return resp - - def __enter__(self): - yield self - - @staticmethod - def _parse_dict_config(config): - return Config.from_dict(config), auth.Credential.from_dict(config) - - def _send(self, action, args, **options): - args["Action"] = action - for handler in self.middleware.request_handlers: - args = handler(args) - req = self._build_http_request(args) - max_retries = options.get("max_retries") or self.config.max_retries - timeout = options.get("timeout") or self.config.timeout - resp = self.transport.send(req, timeout=timeout, max_retries=max_retries).json() - for handler in self.middleware.response_handlers: - resp = handler(resp) - if int(resp.get("RetCode", -1)) != 0: - raise exc.RetCodeException( - action=req.data.get("Action"), - code=int(resp.get("RetCode")), - message=resp.get("Message"), - ) - return resp - - def _build_http_request(self, args): - payload = {"Region": self.config.region, "ProjectId": self.config.project_id} - payload.update({k: v for k, v in args.items() if v is not None}) - payload["Signature"] = self.credential.verify_ac(payload) - return Request( - url=self.config.base_url, - method="post", - data=payload, - headers={ - "User-Agent": self._build_user_agent(), - "Content-Type": "application/x-www-form-urlencoded", - }, - ) - - def _build_user_agent(self): - python_version = "{v[0]}.{v[1]}.{v[2]}".format(v=sys.version_info) - user_agent = "Python/{python_version} Python-SDK/{sdk_version}".format( - python_version=python_version, sdk_version=version.version - ) + (self.config.user_agent or "") - return user_agent - - def __repr__(self): - return "<{}('{}')>".format(self.__class__.__name__, self.config.region) +# -*- coding: utf-8 -*- + +import logging +import sys +from ucloud import version +from ucloud.core.client._cfg import Config +from ucloud.core.transport import Transport, RequestsTransport, Request +from ucloud.core.typesystem import encoder +from ucloud.core.utils import log +from ucloud.core.utils.middleware import Middleware +from ucloud.core import auth, exc + +default_transport = RequestsTransport() + + +class Client(object): + def __init__(self, config, transport=None, middleware=None, logger=None): + cfg, cred = self._parse_dict_config(config) + self.config = cfg + self.credential = cred + self.transport = transport or default_transport + self.logger = logger or log.default_logger + if middleware is None: + middleware = Middleware() + middleware.response(self.logged_response_handler) + middleware.request(self.logged_request_handler) + self._middleware = middleware + + def invoke(self, action, args=None, **options): + """ invoke will invoke the action with arguments data and options + + :param str action: the api action, like `CreateUHostInstance` + :param dict args: arguments of api(action), see doc: `UCloud API Documentation `__ + :return: + """ + retries = 0 + max_retries = options.get("max_retries") or self.config.max_retries + while retries <= max_retries: + try: + return self._send(action, args or {}, **options) + except exc.UCloudException as e: + if e.retryable and retries != max_retries: + logging.info( + "Retrying {action}: {args}".format( + action=action, args=args + ) + ) + retries += 1 + continue + raise e + except Exception as e: + raise e + + @property + def middleware(self): + return self._middleware + + def logged_request_handler(self, req): + self.logger.info("[request] {} {}".format(req.get("Action", ""), req)) + return req + + def logged_response_handler(self, resp): + self.logger.info( + "[response] {} {}".format(resp.get("Action", ""), resp) + ) + return resp + + @staticmethod + def _parse_dict_config(config): + return Config.from_dict(config), auth.Credential.from_dict(config) + + def _send(self, action, args, **options): + args["Action"] = action + for handler in self.middleware.request_handlers: + args = handler(args) + req = self._build_http_request(args) + max_retries = options.get("max_retries") or self.config.max_retries + timeout = options.get("timeout") or self.config.timeout + resp = self.transport.send( + req, timeout=timeout, max_retries=max_retries + ).json() + for handler in self.middleware.response_handlers: + resp = handler(resp) + if int(resp.get("RetCode", -1)) != 0: + raise exc.RetCodeException( + action=req.data.get("Action"), + code=int(resp.get("RetCode")), + message=resp.get("Message"), + ) + return resp + + def _build_http_request(self, args): + config = { + "Region": self.config.region, + "ProjectId": self.config.project_id, + } + payload = {k: v for k, v in config.items() if v is not None} + payload.update({k: v for k, v in args.items() if v is not None}) + payload = encoder.encode(payload) + payload["Signature"] = self.credential.verify_ac(payload) + return Request( + url=self.config.base_url, + method="post", + data=payload, + headers={ + "User-Agent": self._build_user_agent(), + "Content-Type": "application/x-www-form-urlencoded", + }, + ) + + def _build_user_agent(self): + python_version = "{v[0]}.{v[1]}.{v[2]}".format(v=sys.version_info) + user_agent = "Python/{python_version} Python-SDK/{sdk_version}".format( + python_version=python_version, sdk_version=version.version + ) + (self.config.user_agent or "") + return user_agent + + def __repr__(self): + return '<{}("{}")>'.format(self.__class__.__name__, self.config.region) diff --git a/ucloud/core/exc/__init__.py b/ucloud/core/exc/__init__.py index 91c86f3..65bf867 100644 --- a/ucloud/core/exc/__init__.py +++ b/ucloud/core/exc/__init__.py @@ -1,15 +1,15 @@ -# -*- coding: utf-8 -*- - -from ucloud.core.exc._exc import ( - UCloudException, - ValidationException, - RetCodeException, - RetryTimeoutException, -) - -__all__ = [ - "UCloudException", - "ValidationException", - "RetCodeException", - "RetryTimeoutException", -] +# -*- coding: utf-8 -*- + +from ucloud.core.exc._exc import ( + UCloudException, + ValidationException, + RetCodeException, + RetryTimeoutException, +) + +__all__ = [ + "UCloudException", + "ValidationException", + "RetCodeException", + "RetryTimeoutException", +] diff --git a/ucloud/core/exc/_exc.py b/ucloud/core/exc/_exc.py index d916edd..7c8af49 100644 --- a/ucloud/core/exc/_exc.py +++ b/ucloud/core/exc/_exc.py @@ -1,51 +1,55 @@ -# -*- coding: utf-8 -*- - -import collections -from ucloud.core.utils import compact - - -class UCloudException(Exception): - @property - def retryable(self): - return False - - -MAX_COMMON_RET_CODE = 2000 - - -class RetCodeException(UCloudException): - def __init__(self, action, code, message): - self.action = action - self.code = code - self.message = message - - @property - def retryable(self): - return self.code > MAX_COMMON_RET_CODE - - def __str__(self): - return "{self.action} - {self.code}: {self.message}".format(self=self) - - def json(self): - return {"RetCode": self.code, "Message": self.message, "Action": self.action} - - -class RetryTimeoutException(UCloudException): - pass - - -class ValidationException(UCloudException): - def __init__(self, e=None): - if isinstance(e, compact.string_types): - self.errors = [e] - elif isinstance(e, collections.Iterable): - self.errors = e or [] - else: - self.errors = [e] - - @property - def retryable(self): - return False - - def __str__(self): - return str([str(e) for e in self.errors]) +# -*- coding: utf-8 -*- + +import collections +from ucloud.core.utils import compat + + +class UCloudException(Exception): + @property + def retryable(self): + return False + + +MAX_COMMON_RET_CODE = 2000 + + +class RetCodeException(UCloudException): + def __init__(self, action, code, message): + self.action = action + self.code = code + self.message = message + + @property + def retryable(self): + return self.code > MAX_COMMON_RET_CODE + + def __str__(self): + return "{self.action} - {self.code}: {self.message}".format(self=self) + + def json(self): + return { + "RetCode": self.code, + "Message": self.message or "", + "Action": self.action or "", + } + + +class RetryTimeoutException(UCloudException): + pass + + +class ValidationException(UCloudException): + def __init__(self, e=None): + if isinstance(e, compat.string_types): + self.errors = [e] + elif isinstance(e, collections.Iterable): + self.errors = e or [] + else: + self.errors = [e] + + @property + def retryable(self): + return False + + def __str__(self): + return str([str(e) for e in self.errors]) diff --git a/ucloud/core/testing/__init__.py b/ucloud/core/testing/__init__.py deleted file mode 100644 index 4c48b5a..0000000 --- a/ucloud/core/testing/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- diff --git a/ucloud/core/testing/env.py b/ucloud/core/testing/env.py deleted file mode 100644 index 5d3df19..0000000 --- a/ucloud/core/testing/env.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- coding: utf-8 -*- - -import os - -ACC_ENV_KEY = "USDK_ACC" -ACC_SKIP_REASON = "skip test for non-acc environment" - - -def get_skip_reason(): - return ACC_SKIP_REASON - - -def is_acc(): - """ check test env is acceptance testing or not """ - return os.getenv(ACC_ENV_KEY) - - -def is_ut(): - """ check test env is unit testing or not """ - return not is_acc() - - -def pre_check_env(): - """ pre check environment for testing - - NOTE: system environment variables credential is required for test environment - """ - assert os.getenv("UCLOUD_PUBLIC_KEY"), "invalid public key" - assert os.getenv("UCLOUD_PRIVATE_KEY"), "invalid private key" - assert os.getenv("UCLOUD_REGION"), "invalid region" diff --git a/ucloud/core/transport/__init__.py b/ucloud/core/transport/__init__.py index 8fd22de..0980f2a 100644 --- a/ucloud/core/transport/__init__.py +++ b/ucloud/core/transport/__init__.py @@ -1,6 +1,6 @@ -# -*- coding: utf-8 -*- - -from ucloud.core.transport.http import Request, Response, Transport -from ucloud.core.transport._requests import RequestsTransport - -__all__ = ["Request", "Response", "Transport", "RequestsTransport"] +# -*- coding: utf-8 -*- + +from ucloud.core.transport.http import Request, Response, Transport +from ucloud.core.transport._requests import RequestsTransport + +__all__ = ["Request", "Response", "Transport", "RequestsTransport"] diff --git a/ucloud/core/transport/_requests.py b/ucloud/core/transport/_requests.py index 29d5bf9..bed881e 100644 --- a/ucloud/core/transport/_requests.py +++ b/ucloud/core/transport/_requests.py @@ -1,93 +1,97 @@ -# -*- coding: utf-8 -*- - -import requests -from urllib3.util.retry import Retry -from requests.adapters import HTTPAdapter -from ucloud.core.transport import http -from ucloud.core.transport.http import Request, Response -from ucloud.core.utils.middleware import Middleware - - -class RequestsTransport(http.Transport): - """ transport is the implementation of http client, use for send a request and return a http response - - :type max_retries: int - :param max_retries: max retries is the max number of transport request when occur http error - :type backoff_factor: float - :param backoff_factor: backoff factor will calculate the backoff delay during retrying, - the backoff delay = {backoff factor} * (2 ^ ({number of total retries} - 1)) - :type status_forcelist: tuple - :param status_forcelist: the status code list that could be retried - """ - - def __init__( - self, max_retries=3, backoff_factor=0.3, status_forcelist=(500, 502, 504) - ): - self.max_retries = max_retries - self.backoff_factor = backoff_factor - self.status_forcelist = status_forcelist - self._adapter = self._load_adapter(max_retries) - self._middleware = Middleware() - - def send(self, req, **options): - """ send request and return the response - - :param req: the full http request descriptor - :return: the response of http request - """ - for handler in self.middleware.request_handlers: - req = handler(req) - resp = self._send(req, **options) - for handler in self.middleware.response_handlers: - resp = handler(resp) - return resp - - @property - def middleware(self): - """ the middleware object, see :mod: - - :return: the transport middleware - """ - return self._middleware - - def _send(self, req, **options): - with requests.Session() as session: - adapter = self._load_adapter(options.get("max_retries")) - session.mount("http://", adapter=adapter) - session.mount("https://", adapter=adapter) - session_resp = session.request( - method=req.method.upper(), - url=req.url, - json=req.json, - data=req.data, - params=req.params, - headers=req.headers, - ) - resp = self.convert_response(session_resp) - resp.request = req - return resp - - def _load_adapter(self, max_retries=None): - if max_retries is None and self._adapter is not None: - return self._adapter - max_retries = max_retries or 0 - adapter = HTTPAdapter() - adapter.max_retries = Retry( - total=max_retries, - read=max_retries, - connect=max_retries, - backoff_factor=self.backoff_factor, - status_forcelist=self.status_forcelist, - ) - return adapter - - @staticmethod - def convert_response(r): - return Response( - url=r.url, - method=r.request.method, - status_code=r.status_code, - reason=r.reason, - headers=r.headers, - content=r.content, - ) +# -*- coding: utf-8 -*- + +import requests +from urllib3.util.retry import Retry +from requests.adapters import HTTPAdapter +from ucloud.core.transport import http +from ucloud.core.transport.http import Request, Response +from ucloud.core.utils.middleware import Middleware + + +class RequestsTransport(http.Transport): + """ transport is the implementation of http client, use for send a request and return a http response + + :type max_retries: int + :param max_retries: max retries is the max number of transport request when occur http error + :type backoff_factor: float + :param backoff_factor: backoff factor will calculate the backoff delay during retrying, + the backoff delay = {backoff factor} * (2 ^ ({number of total retries} - 1)) + :type status_forcelist: tuple + :param status_forcelist: the status code list that could be retried + """ + + def __init__( + self, + max_retries=3, + backoff_factor=0.3, + status_forcelist=(500, 502, 504), + ): + self.max_retries = max_retries + self.backoff_factor = backoff_factor + self.status_forcelist = status_forcelist + self._adapter = self._load_adapter(max_retries) + self._middleware = Middleware() + + def send(self, req, **options): + """ send request and return the response + + :param req: the full http request descriptor + :return: the response of http request + """ + for handler in self.middleware.request_handlers: + req = handler(req) + resp = self._send(req, **options) + for handler in self.middleware.response_handlers: + resp = handler(resp) + return resp + + @property + def middleware(self): + """ the middleware object, see :mod: + + :return: the transport middleware + """ + return self._middleware + + def _send(self, req, **options): + with requests.Session() as session: + adapter = self._load_adapter(options.get("max_retries")) + session.mount("http://", adapter=adapter) + session.mount("https://", adapter=adapter) + session_resp = session.request( + method=req.method.upper(), + url=req.url, + json=req.json, + data=req.data, + params=req.params, + headers=req.headers, + ) + resp = self.convert_response(session_resp) + resp.request = req + return resp + + def _load_adapter(self, max_retries=None): + if max_retries is None and self._adapter is not None: + return self._adapter + max_retries = max_retries or 0 + adapter = HTTPAdapter() + adapter.max_retries = Retry( + total=max_retries, + read=max_retries, + connect=max_retries, + backoff_factor=self.backoff_factor, + status_forcelist=self.status_forcelist, + ) + return adapter + + @staticmethod + def convert_response(r): + return Response( + url=r.url, + method=r.request.method, + status_code=r.status_code, + reason=r.reason, + headers=r.headers, + content=r.content, + encoding=r.encoding or r.apparent_encoding, + ) diff --git a/ucloud/core/transport/http.py b/ucloud/core/transport/http.py index a1fccb9..d6d3182 100644 --- a/ucloud/core/transport/http.py +++ b/ucloud/core/transport/http.py @@ -1,56 +1,89 @@ -# -*- coding: utf-8 -*- - -import logging -import json as json_mod - -logger = logging.getLogger(__name__) - - -class Request(object): - def __init__( - self, - url, - method="GET", - params=None, - data=None, - json=None, - headers=None, - **kwargs - ): - self.url = url - self.method = method - self.params = params - self.data = data - self.json = json - self.headers = headers - - -class Response(object): - def __init__( - self, - url, - method, - request=None, - status_code=None, - reason=None, - headers=None, - content=None, - **kwargs - ): - self.url = url - self.method = method - self.request = request - self.status_code = status_code - self.reason = reason - self.headers = headers - self.content = content - - def json(self): - return json_mod.loads(self.content) - - -class Transport(object): - """ the abstract class of transport implementation """ - - def send(self, req, **options): - raise NotImplementedError +# -*- coding: utf-8 -*- + +import logging +import json as json_mod +from ucloud.core.transport import utils +from ucloud.core.utils.compat import str + +logger = logging.getLogger(__name__) + + +class Request(object): + def __init__( + self, + url, + method="GET", + params=None, + data=None, + json=None, + headers=None, + **kwargs + ): + self.url = url + self.method = method + self.params = params + self.data = data + self.json = json + self.headers = headers + + def payload(self): + payload = (self.params or {}).copy() + payload.update(self.data or {}) + payload.update(self.json or {}) + return payload + + +class Response(object): + def __init__( + self, + url, + method, + request=None, + status_code=None, + reason=None, + headers=None, + content=None, + encoding=None, + **kwargs + ): + self.url = url + self.method = method + self.request = request + self.status_code = status_code + self.reason = reason + self.headers = headers + self.content = content + self.encoding = encoding + + def json(self, **kwargs): + """ json will return the bytes of content + """ + if not self.content: + return None + encoding = utils.guess_json_utf(self.content) + if encoding is not None: + try: + return json_mod.loads(self.content.decode(encoding), **kwargs) + except UnicodeDecodeError: + pass + return json_mod.loads(self.text, **kwargs) + + @property + def text(self): + """ text will return the unicode string of content, + see `requests.Response.text` + """ + if not self.content: + return str("") + try: + content = str(self.content, self.encoding, errors="replace") + except (LookupError, TypeError): + content = str(self.content, errors="replace") + return content + + +class Transport(object): + """ the abstract class of transport implementation """ + + def send(self, req, **options): + raise NotImplementedError diff --git a/ucloud/core/transport/utils.py b/ucloud/core/transport/utils.py new file mode 100644 index 0000000..a538bc9 --- /dev/null +++ b/ucloud/core/transport/utils.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- + +import codecs + +_null = "\x00".encode("ascii") +_null2 = _null * 2 +_null3 = _null * 3 + + +def guess_json_utf(data): + """ guess_json_utf will detect the encoding of bytes, + see `requests.utils.guess_json_utf` + + :rtype: str + """ + sample = data[:4] + if sample in (codecs.BOM_UTF32_LE, codecs.BOM_UTF32_BE): + return "utf-32" + if sample[:3] == codecs.BOM_UTF8: + return "utf-8-sig" + if sample[:2] in (codecs.BOM_UTF16_LE, codecs.BOM_UTF16_BE): + return "utf-16" + nullcount = sample.count(_null) + if nullcount == 0: + return "utf-8" + if nullcount == 2: + if sample[::2] == _null2: + return "utf-16-be" + if sample[1::2] == _null2: + return "utf-16-le" + if nullcount == 3: + if sample[:3] == _null3: + return "utf-32-be" + if sample[1:] == _null3: + return "utf-32-le" + return None diff --git a/ucloud/core/typesystem/__init__.py b/ucloud/core/typesystem/__init__.py index 4c48b5a..40a96af 100644 --- a/ucloud/core/typesystem/__init__.py +++ b/ucloud/core/typesystem/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- diff --git a/ucloud/core/typesystem/abstract.py b/ucloud/core/typesystem/abstract.py index d2eec8d..7d36ada 100644 --- a/ucloud/core/typesystem/abstract.py +++ b/ucloud/core/typesystem/abstract.py @@ -1,65 +1,60 @@ -# -*- coding: utf-8 -*- - -from ucloud.core import exc - - -class Field(object): - def __init__( - self, - required=False, - default=None, - dump_to=None, - load_from=None, - strict=None, - **kwargs - ): - self.required = required - self.default = default - self.dump_to = dump_to - self.load_from = load_from - self.options = kwargs - self.strict = bool(strict) - - def dumps(self, value, **kwargs): - raise NotImplementedError - - def loads(self, value, **kwargs): - raise NotImplementedError - - @staticmethod - def fail(name, expected, got): - msg = "invalid field {}, expect {}, got {}".format(name, expected, got) - raise exc.ValidationException(msg) - - -class Schema(object): - fields = {} - - def __init__( - self, - required=False, - default=dict, - dump_to=None, - load_from=None, - strict=False, - case_sensitive=False, - **kwargs - ): - self.required = required - self.default = default - self.dump_to = dump_to - self.load_from = load_from - self.options = kwargs - self.strict = strict - self.case_sensitive = case_sensitive - - def dumps(self, d): - raise NotImplementedError - - def loads(self, d): - raise NotImplementedError - - @staticmethod - def fail(name, expected, got): - msg = "invalid schema {}, expect {}, got {}".format(name, expected, got) - raise exc.ValidationException(msg) +# -*- coding: utf-8 -*- + +from ucloud.core import exc + + +class Field(object): + def __init__( + self, + required=False, + default=None, + dump_to=None, + load_from=None, + strict=None, + **kwargs + ): + self.required = required + self.default = default + self.dump_to = dump_to + self.load_from = load_from + self.options = kwargs + self.strict = bool(strict) + + def dumps(self, value, **kwargs): + raise NotImplementedError + + def loads(self, value, **kwargs): + raise NotImplementedError + + @staticmethod + def fail(name, expected, got): + msg = "invalid field {}, expect {}, got {}".format(name, expected, got) + raise exc.ValidationException(msg) + + +class Schema(object): + fields = {} + + def __init__( + self, + required=False, + default=dict, + dump_to=None, + load_from=None, + strict=False, + case_sensitive=False, + **kwargs + ): + self.required = required + self.default = default + self.dump_to = dump_to + self.load_from = load_from + self.options = kwargs + self.strict = strict + self.case_sensitive = case_sensitive + + def dumps(self, d): + raise NotImplementedError + + def loads(self, d): + raise NotImplementedError diff --git a/ucloud/core/typesystem/encoder.py b/ucloud/core/typesystem/encoder.py new file mode 100644 index 0000000..1962f09 --- /dev/null +++ b/ucloud/core/typesystem/encoder.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- + + +def encode(d): + result = {} + for k, v in d.items(): + if isinstance(v, dict): + for ek, ev in encode(v).items(): + result["{}.{}".format(k, ek)] = encode_value(ev) + elif isinstance(v, list): + for i, item in enumerate(v): + if isinstance(item, dict): + for ek, ev in encode(item).items(): + result["{}.{}.{}".format(k, i, ek)] = encode_value(ev) + else: + result["{}.{}".format(k, i)] = encode_value(item) + else: + result[k] = encode_value(v) + return result + + +def encode_value(v): + if isinstance(v, bool): + return "true" if v else "false" + if isinstance(v, float): + return str(int(v)) if v % 1 == 0 else str(v) + return str(v) diff --git a/ucloud/core/typesystem/fields.py b/ucloud/core/typesystem/fields.py index 71b1fde..9398cf2 100644 --- a/ucloud/core/typesystem/fields.py +++ b/ucloud/core/typesystem/fields.py @@ -4,6 +4,7 @@ import collections from ucloud.core.typesystem import abstract from ucloud.core.exc import ValidationException +from ucloud.core.utils.compat import str class List(abstract.Field): @@ -21,7 +22,9 @@ def __init__(self, item, default=list, **kwargs): def dumps(self, value, name=None, **kwargs): if not isinstance(value, collections.Iterable): raise ValidationException( - "invalid field {}, expect list, got {}".format(name, type(value)) + "invalid field {}, expect list, got {}".format( + name, type(value) + ) ) errors = [] values = [] @@ -39,7 +42,9 @@ def dumps(self, value, name=None, **kwargs): def loads(self, value, name=None, **kwargs): if not isinstance(value, collections.Iterable): raise ValidationException( - "invalid field {}, expect list, got {}".format(name, type(value)) + "invalid field {}, expect list, got {}".format( + name, type(value) + ) ) errors = [] values = [] @@ -65,10 +70,7 @@ def loads(self, value, name=None, **kwargs): def _convert(self, value, name=None): if self.strict and not isinstance(value, str): self.fail(name, "str", type(value)) - try: - return unicode(value) - except ValueError: - self.fail(name, "str", type(value)) + return str(value) class Base64(Str): @@ -123,7 +125,8 @@ def loads(self, value, name=None, **kwargs): def _convert(self, value, name=None): if self.strict and not isinstance(value, bool): self.fail(name, "bool", type(value)) - try: - return bool(value) - except ValueError: - self.fail(name, "bool", type(value)) + if value == "true" or value is True: + return True + if value == "false" or value is False: + return False + self.fail(name, "bool", type(value)) diff --git a/ucloud/core/typesystem/schema.py b/ucloud/core/typesystem/schema.py index d3f3c99..1400291 100644 --- a/ucloud/core/typesystem/schema.py +++ b/ucloud/core/typesystem/schema.py @@ -1,117 +1,82 @@ -# -*- coding: utf-8 -*- - -import logging -from ucloud.core.typesystem import abstract, fields -from ucloud.core.exc import ValidationException -from ucloud.core.utils import compact - -logger = logging.getLogger(__name__) - - -class Schema(abstract.Schema): - fields = {} - - def dumps(self, d, name=None, **kwargs): - result = {} - errors = [] - for k, field in self.fields.items(): - v = d.get(k) - if v is None: - if field.required: - errors.append( - ValidationException("the field {k} is required".format(k=k)) - ) - continue - if field.default is None: - continue - if isinstance(field.default, compact.Callable): - v = field.default() - else: - v = field.default - try: - serialized = field.dumps(v, name=k) - except ValidationException as e: - errors.extend(e.errors) - continue - result[field.dump_to or k] = serialized - if len(errors) > 0: - raise ValidationException(errors) - return result - - def loads(self, d, name=None, **kwargs): - result = {} - errors = [] - if not self.case_sensitive: - d = {k.lower(): v for k, v in d.items()} - for k, field in self.fields.items(): - load_key = field.load_from or k - v = d.get(load_key if self.case_sensitive else load_key.lower()) - if v is None: - if field.default is None: - continue - if isinstance(field.default, compact.Callable): - v = field.default() - else: - v = field.default - try: - serialized = field.loads(v, name=k) - except ValidationException as e: - errors.extend(e.errors) - continue - result[k] = serialized - if len(errors) > 0: - raise ValidationException(errors) - return result - - -class RequestSchema(Schema): - fields = {} - - def dumps(self, d, name=None, **kwargs): - if not isinstance(d, dict): - raise ValidationException( - "invalid field {}, expect dict, got {}".format(name, type(d)) - ) - result = {} - errors = [] - for k, field in self.fields.items(): - v = d.get(k) - if v is None: - if field.required: - errors.append( - ValidationException("the field {k} is required".format(k=k)) - ) - continue - if field.default is None: - continue - if isinstance(field.default, compact.Callable): - v = field.default() - else: - v = field.default - try: - serialized = field.dumps(v, name=k) - except ValidationException as e: - errors.extend(e.errors) - continue - k = field.dump_to or k - if isinstance(field, fields.List): - for i, item in enumerate(serialized): - if not isinstance(field.item, RequestSchema): - result["{k}.{i}".format(k=k, i=i)] = item - continue - for item_k, item_v in item.items(): - result[ - "{k}.{i}.{item_k}".format(k=k, i=i, item_k=item_k) - ] = item_v - elif isinstance(field, RequestSchema): - for dk, dv in serialized.items(): - result["{k}.{dk}".format(k=k, dk=dk)] = dv - else: - result[k] = serialized - if len(errors) > 0: - raise ValidationException(errors) - return result - - -class ResponseSchema(Schema): - pass +# -*- coding: utf-8 -*- + +import logging +from ucloud.core.typesystem import abstract +from ucloud.core.exc import ValidationException +from ucloud.core.utils import compat + +logger = logging.getLogger(__name__) + + +class Schema(abstract.Schema): + fields = {} + + def dumps(self, d, name=None, **kwargs): + result = {} + errors = [] + for k, field in self.fields.items(): + v = d.get(k) + if v is None: + if field.required: + errors.append( + ValidationException( + "the field {k} is required".format(k=k) + ) + ) + continue + if field.default is None: + continue + if isinstance(field.default, compat.Callable): + v = field.default() + else: + v = field.default + try: + serialized = field.dumps(v, name=k) + except ValidationException as e: + errors.extend(e.errors) + continue + result[field.dump_to or k] = serialized + if len(errors) > 0: + raise ValidationException(errors) + return result + + def loads(self, d, name=None, **kwargs): + result = {} + errors = [] + if not self.case_sensitive: + d = {k.lower(): v for k, v in d.items()} + for k, field in self.fields.items(): + load_key = field.load_from or k + v = d.get(load_key if self.case_sensitive else load_key.lower()) + if v is None: + if field.default is None: + continue + if isinstance(field.default, compat.Callable): + v = field.default() + else: + v = field.default + try: + serialized = field.loads(v, name=k) + except ValidationException as e: + errors.extend(e.errors) + continue + result[k] = serialized + if len(errors) > 0: + raise ValidationException(errors) + return result + + +class RequestSchema(Schema): + fields = {} + + def dumps(self, d, name=None, **kwargs): + if not isinstance(d, dict): + raise ValidationException( + "invalid field {}, expect dict, got {}".format(name, type(d)) + ) + result = super(RequestSchema, self).dumps(d, name=name, **kwargs) + return result + + +class ResponseSchema(Schema): + pass diff --git a/ucloud/core/utils/__init__.py b/ucloud/core/utils/__init__.py index 4c48b5a..40a96af 100644 --- a/ucloud/core/utils/__init__.py +++ b/ucloud/core/utils/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- diff --git a/ucloud/core/utils/compact.py b/ucloud/core/utils/compat.py similarity index 88% rename from ucloud/core/utils/compact.py rename to ucloud/core/utils/compat.py index 31b33e4..33e9dbc 100644 --- a/ucloud/core/utils/compact.py +++ b/ucloud/core/utils/compat.py @@ -1,13 +1,15 @@ -# -*- coding: utf-8 -*- - -import sys - -PY3 = sys.version_info[0] == 3 -if PY3: - string_types = (str,) - from collections.abc import Callable -else: - import types - - string_types = types.StringTypes - from collections import Callable +# -*- coding: utf-8 -*- + +import sys + +PY3 = sys.version_info[0] == 3 +if PY3: + str = str + string_types = (str,) + from collections.abc import Callable +else: + import types + + str = unicode + string_types = types.StringTypes + from collections import Callable diff --git a/ucloud/core/utils/log.py b/ucloud/core/utils/log.py index 1dbd6ef..402758c 100644 --- a/ucloud/core/utils/log.py +++ b/ucloud/core/utils/log.py @@ -1,22 +1,22 @@ -# -*- coding: utf-8 -*- - -import logging - -DEFAULT_LOGGER_NAME = "ucloud" -DEFAULT_FORMAT = "%(asctime)s - %(name)s - %(levelname)s - %(message)s" -DEFAULT_LEVEL = logging.INFO - - -def init_default_logger(): - logger = logging.getLogger(DEFAULT_LOGGER_NAME) - logger.setLevel(DEFAULT_LEVEL) - ch = logging.StreamHandler() - ch.setLevel(DEFAULT_LEVEL) - formatter = logging.Formatter(DEFAULT_FORMAT) - ch.setFormatter(formatter) - logger.removeHandler(ch) - logger.addHandler(ch) - return logger - - -default_logger = init_default_logger() +# -*- coding: utf-8 -*- + +import logging + +DEFAULT_LOGGER_NAME = "ucloud" +DEFAULT_FORMAT = "%(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s %(name)s)" +DEFAULT_LEVEL = logging.INFO + + +def init_default_logger(): + logger = logging.getLogger(DEFAULT_LOGGER_NAME) + logger.setLevel(DEFAULT_LEVEL) + ch = logging.StreamHandler() + ch.setLevel(DEFAULT_LEVEL) + formatter = logging.Formatter(DEFAULT_FORMAT) + ch.setFormatter(formatter) + logger.removeHandler(ch) + logger.addHandler(ch) + return logger + + +default_logger = init_default_logger() diff --git a/ucloud/core/utils/middleware.py b/ucloud/core/utils/middleware.py index 73e574f..9cfa8e1 100644 --- a/ucloud/core/utils/middleware.py +++ b/ucloud/core/utils/middleware.py @@ -1,53 +1,53 @@ -# -*- coding: utf-8 -*- - - -class Middleware(object): - """ middleware is the object to store request/response handlers - - >>> middleware = Middleware() - - Add a request handler to prepare the request - - >>> @middleware.request - ... def prepare(req): - ... req['Region'] = 'cn-bj2' - ... return req - - Add a response handler to log the response detail - - >>> @middleware.response - ... def logged(resp): - ... print(resp) - ... return resp - - >>> len(middleware.request_handlers), len(middleware.response_handlers) - (1, 1) - """ - - def __init__(self): - self.request_handlers = [] - self.response_handlers = [] - - def request(self, handler, index=-1): - """ request is the request handler register to add request handler. - - :param handler: request handler function, receive request object - and return a new request - :param int index: the position of request in the handler list, - default is append it to end - :return: - """ - self.request_handlers.insert(index, handler) - return handler - - def response(self, handler, index=-1): - """ response is the response handler register to add response handler. - - :param handler: response handler function, receive response object - and return a new response - :param int index: the position of response in the handler list, - default is append it to end - :return: - """ - self.response_handlers.insert(index, handler) - return handler +# -*- coding: utf-8 -*- + + +class Middleware(object): + """ middleware is the object to store request/response handlers + + >>> middleware = Middleware() + + Add a request handler to prepare the request + + >>> @middleware.request + ... def prepare(req): + ... req['Region'] = 'cn-bj2' + ... return req + + Add a response handler to log the response detail + + >>> @middleware.response + ... def logged(resp): + ... print(resp) + ... return resp + + >>> len(middleware.request_handlers), len(middleware.response_handlers) + (1, 1) + """ + + def __init__(self): + self.request_handlers = [] + self.response_handlers = [] + + def request(self, handler, index=-1): + """ request is the request handler register to add request handler. + + :param handler: request handler function, receive request object + and return a new request + :param int index: the position of request in the handler list, + default is append it to end + :return: + """ + self.request_handlers.insert(index, handler) + return handler + + def response(self, handler, index=-1): + """ response is the response handler register to add response handler. + + :param handler: response handler function, receive response object + and return a new response + :param int index: the position of response in the handler list, + default is append it to end + :return: + """ + self.response_handlers.insert(index, handler) + return handler diff --git a/ucloud/helpers/__init__.py b/ucloud/helpers/__init__.py index 4c48b5a..40a96af 100644 --- a/ucloud/helpers/__init__.py +++ b/ucloud/helpers/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- diff --git a/ucloud/helpers/utils.py b/ucloud/helpers/utils.py index 34ef18c..337e5e6 100644 --- a/ucloud/helpers/utils.py +++ b/ucloud/helpers/utils.py @@ -1,86 +1,86 @@ -# -*- coding: utf-8 -*- - -import random -import base64 - -_lowercase = "abcdefghijklmnopqrstuvwxyz" -_uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" -_numbers = "0123456789" -_specials = "_" - - -def gen_password( - n, - lower_letters=_lowercase, - upper_letters=_uppercase, - number_letters=_numbers, - special_letters=_specials, - min_lower=1, - min_upper=1, - min_number=1, - min_specials=1, -): - """ generate password for any resource - - >>> len(gen_password(20)) - 20 - - :param int n: password total length - :param str lower_letters: all lowercase letters - :param str upper_letters: all uppercase letters - :param str number_letters: all number letters - :param str special_letters: all special letters - :param int min_lower: minimal number of lowercase letters - :param int min_upper: minimal number of uppercase letters - :param int min_number: minimal number of number letters - :param int min_specials: minimal number of special letters - :return: - """ - all_letters = "".join( - [lower_letters, upper_letters, number_letters, special_letters] - ) - minimal_total = min_lower + min_upper + min_number + min_specials - if n < minimal_total: - raise ValueError( - "the length of password must be larger than total minimal letters number" - ) - minimal_letters = "".join( - [ - gen_string(lower_letters, min_lower), - gen_string(upper_letters, min_upper), - gen_string(number_letters, min_number), - gen_string(special_letters, min_specials), - ] - ) - additional_letters = random.sample(all_letters, n - minimal_total) - results = list(minimal_letters) + additional_letters - random.shuffle(results) - return "".join(results) - - -def gen_string(letters, length): - return "".join([random.choice(letters) for i in range(length)]) - - -def first(l): - if len(l) == 0: - return None - return l[0] - - -def b64encode(s): - """ base64 encode - - :param str s: input string - :return: base64 string - """ - return base64.b64encode(s.encode()).decode() - - -def b64decode(s): - """ base64 decode - - :param str s: base64 string - :return: output string - """ - return base64.b64decode(s.encode()).decode() +# -*- coding: utf-8 -*- + +import random +import base64 + +_lowercase = "abcdefghijklmnopqrstuvwxyz" +_uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +_numbers = "0123456789" +_specials = "_" + + +def gen_password( + n, + lower_letters=_lowercase, + upper_letters=_uppercase, + number_letters=_numbers, + special_letters=_specials, + min_lower=1, + min_upper=1, + min_number=1, + min_specials=1, +): + """ generate password for any resource + + >>> len(gen_password(20)) + 20 + + :param int n: password total length + :param str lower_letters: all lowercase letters + :param str upper_letters: all uppercase letters + :param str number_letters: all number letters + :param str special_letters: all special letters + :param int min_lower: minimal number of lowercase letters + :param int min_upper: minimal number of uppercase letters + :param int min_number: minimal number of number letters + :param int min_specials: minimal number of special letters + :return: + """ + all_letters = "".join( + [lower_letters, upper_letters, number_letters, special_letters] + ) + minimal_total = min_lower + min_upper + min_number + min_specials + if n < minimal_total: + raise ValueError( + "the length of password must be larger than total minimal letters number" + ) + minimal_letters = "".join( + [ + gen_string(lower_letters, min_lower), + gen_string(upper_letters, min_upper), + gen_string(number_letters, min_number), + gen_string(special_letters, min_specials), + ] + ) + additional_letters = random.sample(all_letters, n - minimal_total) + results = list(minimal_letters) + additional_letters + random.shuffle(results) + return "".join(results) + + +def gen_string(letters, length): + return "".join([random.choice(letters) for i in range(length)]) + + +def first(l): + if len(l) == 0: + return None + return l[0] + + +def b64encode(s): + """ base64 encode + + :param str s: input string + :return: base64 string + """ + return base64.b64encode(s.encode()).decode() + + +def b64decode(s): + """ base64 decode + + :param str s: base64 string + :return: output string + """ + return base64.b64decode(s.encode()).decode() diff --git a/ucloud/helpers/wait.py b/ucloud/helpers/wait.py index 9ce0148..a10d3b5 100644 --- a/ucloud/helpers/wait.py +++ b/ucloud/helpers/wait.py @@ -1,100 +1,100 @@ -# -*- coding: utf-8 -*- - -import time -import logging -from ucloud.core import exc - -MAX_BACKOFF_INTERVAL = 10 -logger = logging.getLogger(__name__) - - -class WaitTimeoutException(exc.UCloudException): - pass - - -class StateConf(object): - """ StateConf is the utilities class to wait the state return by refresh function achieve the specific state, - the generally usage is wait the cloud resource, such as uhost, udb ... is - ready after created. - """ - - def __init__( - self, - pending, - target, - refresh, - timeout, - startup_delay=0, - min_backoff_interval=0.1, - max_backoff_interval=MAX_BACKOFF_INTERVAL, - ): - self.pending = pending - self.target = target - self.refresh = refresh - self.timeout = timeout - self.startup_delay = startup_delay - self.min_backoff_interval = min_backoff_interval - self.max_backoff_interval = max_backoff_interval - - def wait(self): - start_time = time.time() - interval = self.min_backoff_interval - time.sleep(self.startup_delay) - while time.time() - start_time < self.timeout: - state = self.refresh() - if state in self.pending: - time.sleep(interval) - interval *= 2 - if interval > self.max_backoff_interval: - interval = self.max_backoff_interval - logger.info( - "waiting state for {self.refresh}, got state {state}".format( - self=self, state=state - ) - ) - continue - if state in self.target: - return - raise WaitTimeoutException( - "wait timeout {self.timeout}s for {self.refresh}".format(self=self) - ) - - -def wait_for_state( - pending, - target, - refresh, - timeout, - startup_delay=0, - min_backoff_interval=0.1, - max_backoff_interval=MAX_BACKOFF_INTERVAL, -): - """ wait_for_state is a utilities function to wait the state return by refresh function achieve the specific state, - the generally usage is wait the cloud resource, such as uhost, udb ... is - ready after created. - - >>> wait_for_state( - ... pending=["pending"], - ... target=["running"], - ... refresh=lambda: "running", - ... timeout=0.5, - ... ) - - :param pending: pending is the list of pending state, the state is returned by refresh function - :param target: target is the list of target state, it is usually the terminate state, eg. running and fail - :param refresh: the customized refresh function, expect no arguments and return a state - :param timeout: timeout is the total time to wait state is achieved - :param startup_delay: the time to wait before first refresh function is called - :param min_backoff_interval: the backoff time for first refresh interval - :param max_backoff_interval: the max backoff time for refresh interval - """ - conf = StateConf( - pending=pending, - target=target, - refresh=refresh, - timeout=timeout, - startup_delay=startup_delay, - min_backoff_interval=min_backoff_interval, - max_backoff_interval=max_backoff_interval, - ) - return conf.wait() +# -*- coding: utf-8 -*- + +import time +import logging +from ucloud.core import exc + +MAX_BACKOFF_INTERVAL = 10 +logger = logging.getLogger(__name__) + + +class WaitTimeoutException(exc.UCloudException): + pass + + +class StateConf(object): + """ StateConf is the utilities class to wait the state return by refresh function achieve the specific state, + the generally usage is wait the cloud resource, such as uhost, udb ... is + ready after created. + """ + + def __init__( + self, + pending, + target, + refresh, + timeout, + startup_delay=0, + min_backoff_interval=0.1, + max_backoff_interval=MAX_BACKOFF_INTERVAL, + ): + self.pending = pending + self.target = target + self.refresh = refresh + self.timeout = timeout + self.startup_delay = startup_delay + self.min_backoff_interval = min_backoff_interval + self.max_backoff_interval = max_backoff_interval + + def wait(self): + start_time = time.time() + interval = self.min_backoff_interval + time.sleep(self.startup_delay) + while time.time() - start_time < self.timeout: + state = self.refresh() + if state in self.pending: + time.sleep(interval) + interval *= 2 + if interval > self.max_backoff_interval: + interval = self.max_backoff_interval + logger.info( + "waiting state for {self.refresh}, got state {state}".format( + self=self, state=state + ) + ) + continue + if state in self.target: + return + raise WaitTimeoutException( + "wait timeout {self.timeout}s for {self.refresh}".format(self=self) + ) + + +def wait_for_state( + pending, + target, + refresh, + timeout, + startup_delay=0, + min_backoff_interval=0.1, + max_backoff_interval=MAX_BACKOFF_INTERVAL, +): + """ wait_for_state is a utilities function to wait the state return by refresh function achieve the specific state, + the generally usage is wait the cloud resource, such as uhost, udb ... is + ready after created. + + >>> wait_for_state( + ... pending=["pending"], + ... target=["running"], + ... refresh=lambda: "running", + ... timeout=0.5, + ... ) + + :param pending: pending is the list of pending state, the state is returned by refresh function + :param target: target is the list of target state, it is usually the terminate state, eg. running and fail + :param refresh: the customized refresh function, expect no arguments and return a state + :param timeout: timeout is the total time to wait state is achieved + :param startup_delay: the time to wait before first refresh function is called + :param min_backoff_interval: the backoff time for first refresh interval + :param max_backoff_interval: the max backoff time for refresh interval + """ + conf = StateConf( + pending=pending, + target=target, + refresh=refresh, + timeout=timeout, + startup_delay=startup_delay, + min_backoff_interval=min_backoff_interval, + max_backoff_interval=max_backoff_interval, + ) + return conf.wait() diff --git a/ucloud/services/__init__.py b/ucloud/services/__init__.py index 4c48b5a..40a96af 100644 --- a/ucloud/services/__init__.py +++ b/ucloud/services/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- diff --git a/ucloud/services/pathx/__init__.py b/ucloud/services/pathx/__init__.py index 4c48b5a..40a96af 100644 --- a/ucloud/services/pathx/__init__.py +++ b/ucloud/services/pathx/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- diff --git a/ucloud/services/pathx/client.py b/ucloud/services/pathx/client.py index 010c09e..f279007 100644 --- a/ucloud/services/pathx/client.py +++ b/ucloud/services/pathx/client.py @@ -1,159 +1,159 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.client import Client -from ucloud.services.pathx.schemas import apis - - -class PathXClient(Client): - def __init__(self, config, transport=None, middleware=None, logger=None): - super(PathXClient, self).__init__(config, transport, middleware, logger) - - def create_global_ssh_instance(self, req=None, **kwargs): - """ CreateGlobalSSHInstance - 创建GlobalSSH实例 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID,如org-xxxx。请参考 `GetProjectList接口 `_ - - **Area** (str) - (Required) 填写支持SSH访问IP的地区名称,如“洛杉矶”,“新加坡”,“香港”,“东京”,“华盛顿”,“法兰克福”。Area和AreaCode两者必填一个 - - **AreaCode** (str) - (Required) AreaCode, 区域航空港国际通用代码。Area和AreaCode两者必填一个 - - **Port** (int) - (Required) SSH端口,1-65535且不能使用80,443端口 - - **TargetIP** (str) - (Required) 被SSH访问的IP - - **ChargeType** (str) - 支付方式,如按月、按年、按时 - - **CouponId** (str) - 使用代金券可冲抵部分费用 - - **Quantity** (int) - 购买数量 - - **Remark** (str) - 备注信息 - - **Response** - - - **AcceleratingDomain** (str) - 加速域名,访问该域名可就近接入 - - **InstanceId** (str) - 实例ID,资源唯一标识 - - **Message** (str) - 提示信息 - - """ - d = {"ProjectId": self.config.project_id} - req and d.update(req) - d = apis.CreateGlobalSSHInstanceRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("CreateGlobalSSHInstance", d, **kwargs) - return apis.CreateGlobalSSHInstanceResponseSchema().loads(resp) - - def delete_global_ssh_instance(self, req=None, **kwargs): - """ DeleteGlobalSSHInstance - 删除GlobalSSH实例 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID,如org-xxxx。请参考 `GetProjectList接口 `_ - - **InstanceId** (str) - (Required) 实例Id,资源的唯一标识 - - **Response** - - - **Message** (str) - 提示信息 - - """ - d = {"ProjectId": self.config.project_id} - req and d.update(req) - d = apis.DeleteGlobalSSHInstanceRequestSchema().dumps(d) - resp = self.invoke("DeleteGlobalSSHInstance", d, **kwargs) - return apis.DeleteGlobalSSHInstanceResponseSchema().loads(resp) - - def describe_global_ssh_area(self, req=None, **kwargs): - """ DescribeGlobalSSHArea - 获取GlobalSSH覆盖的地区列表 用于控制显示哪些机房地域可以使用SSH特性 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID,如org-xxxx。请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 机房地域代号,如hk、 us-ca、 us-ws等。不填默认为空,返回所有支持地区。 - - **Response** - - - **AreaSet** (list) - 见 **GlobalSSHArea** 模型定义 - - **Message** (str) - 提示信息 - - **Response Model** - - **GlobalSSHArea** - - - **Area** (str) - GlobalSSH覆盖的地区,如香港、东京、洛杉矶等 - - **AreaCode** (str) - 地区代号,以地区AirPort Code - - **RegionSet** (list) - ucloud机房代号构成的数组,如["hk","us-ca"] - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeGlobalSSHAreaRequestSchema().dumps(d) - resp = self.invoke("DescribeGlobalSSHArea", d, **kwargs) - return apis.DescribeGlobalSSHAreaResponseSchema().loads(resp) - - def describe_global_ssh_instance(self, req=None, **kwargs): - """ DescribeGlobalSSHInstance - 获取GlobalSSH实例列表(传实例ID获取单个实例信息,不传获取项目下全部实例) - - **Request** - - - **ProjectId** (str) - (Config) 项目ID,如org-xxxx。请参考 `GetProjectList接口 `_ - - **InstanceId** (str) - 实例ID,资源唯一标识 - - **Response** - - - **InstanceSet** (list) - 见 **GlobalSSHInfo** 模型定义 - - **Response Model** - - **GlobalSSHInfo** - - - **AcceleratingDomain** (str) - 加速域名 - - **Area** (str) - 被SSH访问的IP所在地区 - - **ChargeType** (str) - 支付周期,如Month,Year等 - - **CreateTime** (int) - 资源创建时间戳 - - **ExpireTime** (int) - 资源过期时间戳 - - **InstanceId** (str) - 实例ID,资源唯一标识 - - **Port** (int) - SSH登陆端口 - - **Remark** (str) - 备注信息 - - **TargetIP** (str) - 被SSH访问的EIP - - """ - d = {"ProjectId": self.config.project_id} - req and d.update(req) - d = apis.DescribeGlobalSSHInstanceRequestSchema().dumps(d) - resp = self.invoke("DescribeGlobalSSHInstance", d, **kwargs) - return apis.DescribeGlobalSSHInstanceResponseSchema().loads(resp) - - def modify_global_ssh_port(self, req=None, **kwargs): - """ ModifyGlobalSSHPort - 修改GlobalSSH端口 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID,如org-xxxx。请参考 `GetProjectList接口 `_ - - **InstanceId** (str) - (Required) 实例ID,资源唯一标识 - - **Port** (int) - (Required) 调整后的SSH登陆端口 - - **Response** - - - **Message** (str) - 提示信息 - - """ - d = {"ProjectId": self.config.project_id} - req and d.update(req) - d = apis.ModifyGlobalSSHPortRequestSchema().dumps(d) - resp = self.invoke("ModifyGlobalSSHPort", d, **kwargs) - return apis.ModifyGlobalSSHPortResponseSchema().loads(resp) - - def modify_global_ssh_remark(self, req=None, **kwargs): - """ ModifyGlobalSSHRemark - 修改GlobalSSH备注 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID,如org-xxxx。请参考 `GetProjectList接口 `_ - - **InstanceId** (str) - (Required) 实例ID,资源唯一标识 - - **Remark** (str) - 备注信息,不填默认为空字符串 - - **Response** - - - **Message** (str) - 接口返回消息 - - """ - d = {"ProjectId": self.config.project_id} - req and d.update(req) - d = apis.ModifyGlobalSSHRemarkRequestSchema().dumps(d) - resp = self.invoke("ModifyGlobalSSHRemark", d, **kwargs) - return apis.ModifyGlobalSSHRemarkResponseSchema().loads(resp) +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.client import Client +from ucloud.services.pathx.schemas import apis + + +class PathXClient(Client): + def __init__(self, config, transport=None, middleware=None, logger=None): + super(PathXClient, self).__init__(config, transport, middleware, logger) + + def create_global_ssh_instance(self, req=None, **kwargs): + """ CreateGlobalSSHInstance - 创建GlobalSSH实例 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID,如org-xxxx。请参考 `GetProjectList接口 `_ + - **Area** (str) - (Required) 填写支持SSH访问IP的地区名称,如“洛杉矶”,“新加坡”,“香港”,“东京”,“华盛顿”,“法兰克福”。Area和AreaCode两者必填一个 + - **AreaCode** (str) - (Required) AreaCode, 区域航空港国际通用代码。Area和AreaCode两者必填一个 + - **Port** (int) - (Required) SSH端口,1-65535且不能使用80,443端口 + - **TargetIP** (str) - (Required) 被SSH访问的IP + - **ChargeType** (str) - 支付方式,如按月、按年、按时 + - **CouponId** (str) - 使用代金券可冲抵部分费用 + - **Quantity** (int) - 购买数量 + - **Remark** (str) - 备注信息 + + **Response** + + - **AcceleratingDomain** (str) - 加速域名,访问该域名可就近接入 + - **InstanceId** (str) - 实例ID,资源唯一标识 + - **Message** (str) - 提示信息 + + """ + d = {"ProjectId": self.config.project_id} + req and d.update(req) + d = apis.CreateGlobalSSHInstanceRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("CreateGlobalSSHInstance", d, **kwargs) + return apis.CreateGlobalSSHInstanceResponseSchema().loads(resp) + + def delete_global_ssh_instance(self, req=None, **kwargs): + """ DeleteGlobalSSHInstance - 删除GlobalSSH实例 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID,如org-xxxx。请参考 `GetProjectList接口 `_ + - **InstanceId** (str) - (Required) 实例Id,资源的唯一标识 + + **Response** + + - **Message** (str) - 提示信息 + + """ + d = {"ProjectId": self.config.project_id} + req and d.update(req) + d = apis.DeleteGlobalSSHInstanceRequestSchema().dumps(d) + resp = self.invoke("DeleteGlobalSSHInstance", d, **kwargs) + return apis.DeleteGlobalSSHInstanceResponseSchema().loads(resp) + + def describe_global_ssh_area(self, req=None, **kwargs): + """ DescribeGlobalSSHArea - 获取GlobalSSH覆盖的地区列表 用于控制显示哪些机房地域可以使用SSH特性 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID,如org-xxxx。请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 机房地域代号,如hk、 us-ca、 us-ws等。不填默认为空,返回所有支持地区。 + + **Response** + + - **AreaSet** (list) - 见 **GlobalSSHArea** 模型定义 + - **Message** (str) - 提示信息 + + **Response Model** + + **GlobalSSHArea** + + - **Area** (str) - GlobalSSH覆盖的地区,如香港、东京、洛杉矶等 + - **AreaCode** (str) - 地区代号,以地区AirPort Code + - **RegionSet** (list) - ucloud机房代号构成的数组,如["hk","us-ca"] + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeGlobalSSHAreaRequestSchema().dumps(d) + resp = self.invoke("DescribeGlobalSSHArea", d, **kwargs) + return apis.DescribeGlobalSSHAreaResponseSchema().loads(resp) + + def describe_global_ssh_instance(self, req=None, **kwargs): + """ DescribeGlobalSSHInstance - 获取GlobalSSH实例列表(传实例ID获取单个实例信息,不传获取项目下全部实例) + + **Request** + + - **ProjectId** (str) - (Config) 项目ID,如org-xxxx。请参考 `GetProjectList接口 `_ + - **InstanceId** (str) - 实例ID,资源唯一标识 + + **Response** + + - **InstanceSet** (list) - 见 **GlobalSSHInfo** 模型定义 + + **Response Model** + + **GlobalSSHInfo** + + - **AcceleratingDomain** (str) - 加速域名 + - **Area** (str) - 被SSH访问的IP所在地区 + - **ChargeType** (str) - 支付周期,如Month,Year等 + - **CreateTime** (int) - 资源创建时间戳 + - **ExpireTime** (int) - 资源过期时间戳 + - **InstanceId** (str) - 实例ID,资源唯一标识 + - **Port** (int) - SSH登陆端口 + - **Remark** (str) - 备注信息 + - **TargetIP** (str) - 被SSH访问的EIP + + """ + d = {"ProjectId": self.config.project_id} + req and d.update(req) + d = apis.DescribeGlobalSSHInstanceRequestSchema().dumps(d) + resp = self.invoke("DescribeGlobalSSHInstance", d, **kwargs) + return apis.DescribeGlobalSSHInstanceResponseSchema().loads(resp) + + def modify_global_ssh_port(self, req=None, **kwargs): + """ ModifyGlobalSSHPort - 修改GlobalSSH端口 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID,如org-xxxx。请参考 `GetProjectList接口 `_ + - **InstanceId** (str) - (Required) 实例ID,资源唯一标识 + - **Port** (int) - (Required) 调整后的SSH登陆端口 + + **Response** + + - **Message** (str) - 提示信息 + + """ + d = {"ProjectId": self.config.project_id} + req and d.update(req) + d = apis.ModifyGlobalSSHPortRequestSchema().dumps(d) + resp = self.invoke("ModifyGlobalSSHPort", d, **kwargs) + return apis.ModifyGlobalSSHPortResponseSchema().loads(resp) + + def modify_global_ssh_remark(self, req=None, **kwargs): + """ ModifyGlobalSSHRemark - 修改GlobalSSH备注 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID,如org-xxxx。请参考 `GetProjectList接口 `_ + - **InstanceId** (str) - (Required) 实例ID,资源唯一标识 + - **Remark** (str) - 备注信息,不填默认为空字符串 + + **Response** + + - **Message** (str) - 接口返回消息 + + """ + d = {"ProjectId": self.config.project_id} + req and d.update(req) + d = apis.ModifyGlobalSSHRemarkRequestSchema().dumps(d) + resp = self.invoke("ModifyGlobalSSHRemark", d, **kwargs) + return apis.ModifyGlobalSSHRemarkResponseSchema().loads(resp) diff --git a/ucloud/services/pathx/schemas/__init__.py b/ucloud/services/pathx/schemas/__init__.py index 4c48b5a..40a96af 100644 --- a/ucloud/services/pathx/schemas/__init__.py +++ b/ucloud/services/pathx/schemas/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- diff --git a/ucloud/services/pathx/schemas/apis.py b/ucloud/services/pathx/schemas/apis.py index a6786fe..266e759 100644 --- a/ucloud/services/pathx/schemas/apis.py +++ b/ucloud/services/pathx/schemas/apis.py @@ -1,174 +1,176 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.typesystem import schema, fields -from ucloud.services.pathx.schemas import models - -""" PathX API Schema -""" -""" -API: CreateGlobalSSHInstance - -创建GlobalSSH实例 -""" - - -class CreateGlobalSSHInstanceRequestSchema(schema.RequestSchema): - """ CreateGlobalSSHInstance - 创建GlobalSSH实例 - """ - - fields = { - "Area": fields.Str(required=True, dump_to="Area"), - "AreaCode": fields.Str(required=True, dump_to="AreaCode"), - "ChargeType": fields.Str(required=False, dump_to="ChargeType"), - "CouponId": fields.Str(required=False, dump_to="CouponId"), - "Port": fields.Int(required=True, dump_to="Port"), - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Quantity": fields.Int(required=False, dump_to="Quantity"), - "Remark": fields.Str(required=False, dump_to="Remark"), - "TargetIP": fields.Str(required=True, dump_to="TargetIP"), - } - - -class CreateGlobalSSHInstanceResponseSchema(schema.ResponseSchema): - """ CreateGlobalSSHInstance - 创建GlobalSSH实例 - """ - - fields = { - "AcceleratingDomain": fields.Str( - required=False, load_from="AcceleratingDomain" - ), - "InstanceId": fields.Str(required=True, load_from="InstanceId"), - "Message": fields.Str(required=False, load_from="Message"), - } - - -""" -API: DeleteGlobalSSHInstance - -删除GlobalSSH实例 -""" - - -class DeleteGlobalSSHInstanceRequestSchema(schema.RequestSchema): - """ DeleteGlobalSSHInstance - 删除GlobalSSH实例 - """ - - fields = { - "InstanceId": fields.Str(required=True, dump_to="InstanceId"), - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - } - - -class DeleteGlobalSSHInstanceResponseSchema(schema.ResponseSchema): - """ DeleteGlobalSSHInstance - 删除GlobalSSH实例 - """ - - fields = {"Message": fields.Str(required=False, load_from="Message")} - - -""" -API: DescribeGlobalSSHArea - -获取GlobalSSH覆盖的地区列表 用于控制显示哪些机房地域可以使用SSH特性 -""" - - -class DescribeGlobalSSHAreaRequestSchema(schema.RequestSchema): - """ DescribeGlobalSSHArea - 获取GlobalSSH覆盖的地区列表 用于控制显示哪些机房地域可以使用SSH特性 - """ - - fields = { - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=False, dump_to="Region"), - } - - -class DescribeGlobalSSHAreaResponseSchema(schema.ResponseSchema): - """ DescribeGlobalSSHArea - 获取GlobalSSH覆盖的地区列表 用于控制显示哪些机房地域可以使用SSH特性 - """ - - fields = { - "AreaSet": fields.List( - models.GlobalSSHAreaSchema(), required=False, load_from="AreaSet" - ), - "Message": fields.Str(required=False, load_from="Message"), - } - - -""" -API: DescribeGlobalSSHInstance - -获取GlobalSSH实例列表(传实例ID获取单个实例信息,不传获取项目下全部实例) -""" - - -class DescribeGlobalSSHInstanceRequestSchema(schema.RequestSchema): - """ DescribeGlobalSSHInstance - 获取GlobalSSH实例列表(传实例ID获取单个实例信息,不传获取项目下全部实例) - """ - - fields = { - "InstanceId": fields.Str(required=False, dump_to="InstanceId"), - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - } - - -class DescribeGlobalSSHInstanceResponseSchema(schema.ResponseSchema): - """ DescribeGlobalSSHInstance - 获取GlobalSSH实例列表(传实例ID获取单个实例信息,不传获取项目下全部实例) - """ - - fields = { - "InstanceSet": fields.List( - models.GlobalSSHInfoSchema(), required=False, load_from="InstanceSet" - ) - } - - -""" -API: ModifyGlobalSSHPort - -修改GlobalSSH端口 -""" - - -class ModifyGlobalSSHPortRequestSchema(schema.RequestSchema): - """ ModifyGlobalSSHPort - 修改GlobalSSH端口 - """ - - fields = { - "InstanceId": fields.Str(required=True, dump_to="InstanceId"), - "Port": fields.Int(required=True, dump_to="Port"), - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - } - - -class ModifyGlobalSSHPortResponseSchema(schema.ResponseSchema): - """ ModifyGlobalSSHPort - 修改GlobalSSH端口 - """ - - fields = {"Message": fields.Str(required=False, load_from="Message")} - - -""" -API: ModifyGlobalSSHRemark - -修改GlobalSSH备注 -""" - - -class ModifyGlobalSSHRemarkRequestSchema(schema.RequestSchema): - """ ModifyGlobalSSHRemark - 修改GlobalSSH备注 - """ - - fields = { - "InstanceId": fields.Str(required=True, dump_to="InstanceId"), - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Remark": fields.Str(required=False, dump_to="Remark"), - } - - -class ModifyGlobalSSHRemarkResponseSchema(schema.ResponseSchema): - """ ModifyGlobalSSHRemark - 修改GlobalSSH备注 - """ - - fields = {"Message": fields.Str(required=False, load_from="Message")} +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.typesystem import schema, fields +from ucloud.services.pathx.schemas import models + +""" PathX API Schema +""" +""" +API: CreateGlobalSSHInstance + +创建GlobalSSH实例 +""" + + +class CreateGlobalSSHInstanceRequestSchema(schema.RequestSchema): + """ CreateGlobalSSHInstance - 创建GlobalSSH实例 + """ + + fields = { + "Area": fields.Str(required=True, dump_to="Area"), + "AreaCode": fields.Str(required=True, dump_to="AreaCode"), + "ChargeType": fields.Str(required=False, dump_to="ChargeType"), + "CouponId": fields.Str(required=False, dump_to="CouponId"), + "Port": fields.Int(required=True, dump_to="Port"), + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Quantity": fields.Int(required=False, dump_to="Quantity"), + "Remark": fields.Str(required=False, dump_to="Remark"), + "TargetIP": fields.Str(required=True, dump_to="TargetIP"), + } + + +class CreateGlobalSSHInstanceResponseSchema(schema.ResponseSchema): + """ CreateGlobalSSHInstance - 创建GlobalSSH实例 + """ + + fields = { + "AcceleratingDomain": fields.Str( + required=False, load_from="AcceleratingDomain" + ), + "InstanceId": fields.Str(required=True, load_from="InstanceId"), + "Message": fields.Str(required=False, load_from="Message"), + } + + +""" +API: DeleteGlobalSSHInstance + +删除GlobalSSH实例 +""" + + +class DeleteGlobalSSHInstanceRequestSchema(schema.RequestSchema): + """ DeleteGlobalSSHInstance - 删除GlobalSSH实例 + """ + + fields = { + "InstanceId": fields.Str(required=True, dump_to="InstanceId"), + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + } + + +class DeleteGlobalSSHInstanceResponseSchema(schema.ResponseSchema): + """ DeleteGlobalSSHInstance - 删除GlobalSSH实例 + """ + + fields = {"Message": fields.Str(required=False, load_from="Message")} + + +""" +API: DescribeGlobalSSHArea + +获取GlobalSSH覆盖的地区列表 用于控制显示哪些机房地域可以使用SSH特性 +""" + + +class DescribeGlobalSSHAreaRequestSchema(schema.RequestSchema): + """ DescribeGlobalSSHArea - 获取GlobalSSH覆盖的地区列表 用于控制显示哪些机房地域可以使用SSH特性 + """ + + fields = { + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=False, dump_to="Region"), + } + + +class DescribeGlobalSSHAreaResponseSchema(schema.ResponseSchema): + """ DescribeGlobalSSHArea - 获取GlobalSSH覆盖的地区列表 用于控制显示哪些机房地域可以使用SSH特性 + """ + + fields = { + "AreaSet": fields.List( + models.GlobalSSHAreaSchema(), required=False, load_from="AreaSet" + ), + "Message": fields.Str(required=False, load_from="Message"), + } + + +""" +API: DescribeGlobalSSHInstance + +获取GlobalSSH实例列表(传实例ID获取单个实例信息,不传获取项目下全部实例) +""" + + +class DescribeGlobalSSHInstanceRequestSchema(schema.RequestSchema): + """ DescribeGlobalSSHInstance - 获取GlobalSSH实例列表(传实例ID获取单个实例信息,不传获取项目下全部实例) + """ + + fields = { + "InstanceId": fields.Str(required=False, dump_to="InstanceId"), + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + } + + +class DescribeGlobalSSHInstanceResponseSchema(schema.ResponseSchema): + """ DescribeGlobalSSHInstance - 获取GlobalSSH实例列表(传实例ID获取单个实例信息,不传获取项目下全部实例) + """ + + fields = { + "InstanceSet": fields.List( + models.GlobalSSHInfoSchema(), + required=False, + load_from="InstanceSet", + ) + } + + +""" +API: ModifyGlobalSSHPort + +修改GlobalSSH端口 +""" + + +class ModifyGlobalSSHPortRequestSchema(schema.RequestSchema): + """ ModifyGlobalSSHPort - 修改GlobalSSH端口 + """ + + fields = { + "InstanceId": fields.Str(required=True, dump_to="InstanceId"), + "Port": fields.Int(required=True, dump_to="Port"), + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + } + + +class ModifyGlobalSSHPortResponseSchema(schema.ResponseSchema): + """ ModifyGlobalSSHPort - 修改GlobalSSH端口 + """ + + fields = {"Message": fields.Str(required=False, load_from="Message")} + + +""" +API: ModifyGlobalSSHRemark + +修改GlobalSSH备注 +""" + + +class ModifyGlobalSSHRemarkRequestSchema(schema.RequestSchema): + """ ModifyGlobalSSHRemark - 修改GlobalSSH备注 + """ + + fields = { + "InstanceId": fields.Str(required=True, dump_to="InstanceId"), + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Remark": fields.Str(required=False, dump_to="Remark"), + } + + +class ModifyGlobalSSHRemarkResponseSchema(schema.ResponseSchema): + """ ModifyGlobalSSHRemark - 修改GlobalSSH备注 + """ + + fields = {"Message": fields.Str(required=False, load_from="Message")} diff --git a/ucloud/services/pathx/schemas/models.py b/ucloud/services/pathx/schemas/models.py index 5e724a5..e85ea28 100644 --- a/ucloud/services/pathx/schemas/models.py +++ b/ucloud/services/pathx/schemas/models.py @@ -1,32 +1,34 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.typesystem import schema, fields - - -class GlobalSSHAreaSchema(schema.ResponseSchema): - """ GlobalSSHArea - GlobalSSH覆盖地区,包括关联的UCloud机房信息 - """ - - fields = { - "Area": fields.Str(required=True, load_from="Area"), - "AreaCode": fields.Str(required=True, load_from="AreaCode"), - "RegionSet": fields.List(fields.Str()), - } - - -class GlobalSSHInfoSchema(schema.ResponseSchema): - """ GlobalSSHInfo - GlobalSSH实例信息 - """ - - fields = { - "AcceleratingDomain": fields.Str(required=True, load_from="AcceleratingDomain"), - "Area": fields.Str(required=True, load_from="Area"), - "ChargeType": fields.Str(required=True, load_from="ChargeType"), - "CreateTime": fields.Int(required=True, load_from="CreateTime"), - "ExpireTime": fields.Int(required=True, load_from="ExpireTime"), - "InstanceId": fields.Str(required=True, load_from="InstanceId"), - "Port": fields.Int(required=True, load_from="Port"), - "Remark": fields.Str(required=True, load_from="Remark"), - "TargetIP": fields.Str(required=True, load_from="TargetIP"), - } +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.typesystem import schema, fields + + +class GlobalSSHAreaSchema(schema.ResponseSchema): + """ GlobalSSHArea - GlobalSSH覆盖地区,包括关联的UCloud机房信息 + """ + + fields = { + "Area": fields.Str(required=True, load_from="Area"), + "AreaCode": fields.Str(required=True, load_from="AreaCode"), + "RegionSet": fields.List(fields.Str()), + } + + +class GlobalSSHInfoSchema(schema.ResponseSchema): + """ GlobalSSHInfo - GlobalSSH实例信息 + """ + + fields = { + "AcceleratingDomain": fields.Str( + required=True, load_from="AcceleratingDomain" + ), + "Area": fields.Str(required=True, load_from="Area"), + "ChargeType": fields.Str(required=True, load_from="ChargeType"), + "CreateTime": fields.Int(required=True, load_from="CreateTime"), + "ExpireTime": fields.Int(required=True, load_from="ExpireTime"), + "InstanceId": fields.Str(required=True, load_from="InstanceId"), + "Port": fields.Int(required=True, load_from="Port"), + "Remark": fields.Str(required=True, load_from="Remark"), + "TargetIP": fields.Str(required=True, load_from="TargetIP"), + } diff --git a/ucloud/services/stepflow/__init__.py b/ucloud/services/stepflow/__init__.py index 4c48b5a..40a96af 100644 --- a/ucloud/services/stepflow/__init__.py +++ b/ucloud/services/stepflow/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- diff --git a/ucloud/services/stepflow/client.py b/ucloud/services/stepflow/client.py index 3685949..dfda061 100644 --- a/ucloud/services/stepflow/client.py +++ b/ucloud/services/stepflow/client.py @@ -1,82 +1,84 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.client import Client -from ucloud.services.stepflow.schemas import apis - - -class StepFlowClient(Client): - def __init__(self, config, transport=None, middleware=None, logger=None): - super(StepFlowClient, self).__init__(config, transport, middleware, logger) - - def create_sf_workflow_from_template(self, req=None, **kwargs): - """ CreateSFWorkflowFromTemplate - 导入工作流定义 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Namespace** (str) - (Required) 需要创建的工作流namespace - - **Workflow** (str) - (Required) 描述工作流定义的base64字符串 - - **WorkflowName** (str) - (Required) 需要创建的工作流名称 - - **Response** - - - **Message** (str) - 返回消息 - - **Version** (int) - 创建的工作流版本号 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.CreateSFWorkflowFromTemplateRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("CreateSFWorkflowFromTemplate", d, **kwargs) - return apis.CreateSFWorkflowFromTemplateResponseSchema().loads(resp) - - def get_sf_workflow_template(self, req=None, **kwargs): - """ GetSFWorkflowTemplate - 导出工作流定义 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **WorkflowId** (str) - (Required) 被导出工作流的Id - - **WorkflowVersion** (int) - 被导出工作流的版本号。取值范围:WorkflowVersion >= 1;默认会获取发布版本对应的workflow;超过最大版本会返回错误 - - **Response** - - - **Message** (str) - 返回消息 - - **Version** (int) - 导出工作流的版本号 - - **Workflow** (dict) - 见 **WorkflowTemplate** 模型定义 - - **WorkflowId** (str) - 导出工作流的Id - - **Response Model** - - **Param** - - - **Name** (str) - 参数名称 - - **Type** (str) - 参数类型 - - **Value** (str) - 参数值 - - **ActivityTemplate** - - - **Input** (dict) - Activity的输入 - - **Name** (str) - Activity的名字 - - **Next** (str) - 下一个Activity的名字 - - **Output** (list) - Activity的输出,详见Param - - **RetryTimes** (str) - Activity的重试次数 - - **Timeout** (str) - Activity的超时时间 - - **Type** (str) - Activity的类型 - - **WorkflowTemplate** - - - **Activites** (list) - 见 **ActivityTemplate** 模型定义 - - **Input** (list) - 见 **Param** 模型定义 - - **Output** (list) - 见 **Param** 模型定义 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.GetSFWorkflowTemplateRequestSchema().dumps(d) - resp = self.invoke("GetSFWorkflowTemplate", d, **kwargs) - return apis.GetSFWorkflowTemplateResponseSchema().loads(resp) +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.client import Client +from ucloud.services.stepflow.schemas import apis + + +class StepFlowClient(Client): + def __init__(self, config, transport=None, middleware=None, logger=None): + super(StepFlowClient, self).__init__( + config, transport, middleware, logger + ) + + def create_sf_workflow_from_template(self, req=None, **kwargs): + """ CreateSFWorkflowFromTemplate - 导入工作流定义 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Namespace** (str) - (Required) 需要创建的工作流namespace + - **Workflow** (str) - (Required) 描述工作流定义的base64字符串 + - **WorkflowName** (str) - (Required) 需要创建的工作流名称 + + **Response** + + - **Message** (str) - 返回消息 + - **Version** (int) - 创建的工作流版本号 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.CreateSFWorkflowFromTemplateRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("CreateSFWorkflowFromTemplate", d, **kwargs) + return apis.CreateSFWorkflowFromTemplateResponseSchema().loads(resp) + + def get_sf_workflow_template(self, req=None, **kwargs): + """ GetSFWorkflowTemplate - 导出工作流定义 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **WorkflowId** (str) - (Required) 被导出工作流的Id + - **WorkflowVersion** (int) - 被导出工作流的版本号。取值范围:WorkflowVersion >= 1;默认会获取发布版本对应的workflow;超过最大版本会返回错误 + + **Response** + + - **Message** (str) - 返回消息 + - **Version** (int) - 导出工作流的版本号 + - **Workflow** (dict) - 见 **WorkflowTemplate** 模型定义 + - **WorkflowId** (str) - 导出工作流的Id + + **Response Model** + + **Param** + + - **Name** (str) - 参数名称 + - **Type** (str) - 参数类型 + - **Value** (str) - 参数值 + + **ActivityTemplate** + + - **Input** (dict) - Activity的输入 + - **Name** (str) - Activity的名字 + - **Next** (str) - 下一个Activity的名字 + - **Output** (list) - Activity的输出,详见Param + - **RetryTimes** (str) - Activity的重试次数 + - **Timeout** (str) - Activity的超时时间 + - **Type** (str) - Activity的类型 + + **WorkflowTemplate** + + - **Activites** (list) - 见 **ActivityTemplate** 模型定义 + - **Input** (list) - 见 **Param** 模型定义 + - **Output** (list) - 见 **Param** 模型定义 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.GetSFWorkflowTemplateRequestSchema().dumps(d) + resp = self.invoke("GetSFWorkflowTemplate", d, **kwargs) + return apis.GetSFWorkflowTemplateResponseSchema().loads(resp) diff --git a/ucloud/services/stepflow/schemas/__init__.py b/ucloud/services/stepflow/schemas/__init__.py index 4c48b5a..40a96af 100644 --- a/ucloud/services/stepflow/schemas/__init__.py +++ b/ucloud/services/stepflow/schemas/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- diff --git a/ucloud/services/stepflow/schemas/apis.py b/ucloud/services/stepflow/schemas/apis.py index 9fa5d40..20037c4 100644 --- a/ucloud/services/stepflow/schemas/apis.py +++ b/ucloud/services/stepflow/schemas/apis.py @@ -1,67 +1,69 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.typesystem import schema, fields -from ucloud.services.stepflow.schemas import models - -""" StepFlow API Schema -""" -""" -API: CreateSFWorkflowFromTemplate - -导入工作流定义 -""" - - -class CreateSFWorkflowFromTemplateRequestSchema(schema.RequestSchema): - """ CreateSFWorkflowFromTemplate - 导入工作流定义 - """ - - fields = { - "Namespace": fields.Str(required=True, dump_to="Namespace"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Workflow": fields.Base64(required=True, dump_to="Workflow"), - "WorkflowName": fields.Str(required=True, dump_to="WorkflowName"), - } - - -class CreateSFWorkflowFromTemplateResponseSchema(schema.ResponseSchema): - """ CreateSFWorkflowFromTemplate - 导入工作流定义 - """ - - fields = { - "Message": fields.Str(required=True, load_from="Message"), - "Version": fields.Int(required=True, load_from="Version"), - } - - -""" -API: GetSFWorkflowTemplate - -导出工作流定义 -""" - - -class GetSFWorkflowTemplateRequestSchema(schema.RequestSchema): - """ GetSFWorkflowTemplate - 导出工作流定义 - """ - - fields = { - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "WorkflowId": fields.Str(required=True, dump_to="WorkflowId"), - "WorkflowVersion": fields.Int(required=False, dump_to="WorkflowVersion"), - } - - -class GetSFWorkflowTemplateResponseSchema(schema.ResponseSchema): - """ GetSFWorkflowTemplate - 导出工作流定义 - """ - - fields = { - "Message": fields.Str(required=False, load_from="Message"), - "Version": fields.Int(required=True, load_from="Version"), - "Workflow": models.WorkflowTemplateSchema(), - "WorkflowId": fields.Str(required=True, load_from="WorkflowId"), - } +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.typesystem import schema, fields +from ucloud.services.stepflow.schemas import models + +""" StepFlow API Schema +""" +""" +API: CreateSFWorkflowFromTemplate + +导入工作流定义 +""" + + +class CreateSFWorkflowFromTemplateRequestSchema(schema.RequestSchema): + """ CreateSFWorkflowFromTemplate - 导入工作流定义 + """ + + fields = { + "Namespace": fields.Str(required=True, dump_to="Namespace"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Workflow": fields.Base64(required=True, dump_to="Workflow"), + "WorkflowName": fields.Str(required=True, dump_to="WorkflowName"), + } + + +class CreateSFWorkflowFromTemplateResponseSchema(schema.ResponseSchema): + """ CreateSFWorkflowFromTemplate - 导入工作流定义 + """ + + fields = { + "Message": fields.Str(required=True, load_from="Message"), + "Version": fields.Int(required=True, load_from="Version"), + } + + +""" +API: GetSFWorkflowTemplate + +导出工作流定义 +""" + + +class GetSFWorkflowTemplateRequestSchema(schema.RequestSchema): + """ GetSFWorkflowTemplate - 导出工作流定义 + """ + + fields = { + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "WorkflowId": fields.Str(required=True, dump_to="WorkflowId"), + "WorkflowVersion": fields.Int( + required=False, dump_to="WorkflowVersion" + ), + } + + +class GetSFWorkflowTemplateResponseSchema(schema.ResponseSchema): + """ GetSFWorkflowTemplate - 导出工作流定义 + """ + + fields = { + "Message": fields.Str(required=False, load_from="Message"), + "Version": fields.Int(required=True, load_from="Version"), + "Workflow": models.WorkflowTemplateSchema(), + "WorkflowId": fields.Str(required=True, load_from="WorkflowId"), + } diff --git a/ucloud/services/stepflow/schemas/models.py b/ucloud/services/stepflow/schemas/models.py index b6d5122..bac8e96 100644 --- a/ucloud/services/stepflow/schemas/models.py +++ b/ucloud/services/stepflow/schemas/models.py @@ -1,41 +1,41 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.typesystem import schema, fields - - -class ParamSchema(schema.ResponseSchema): - """ Param - 工作流参数 - """ - - fields = { - "Name": fields.Str(required=False, load_from="Name"), - "Type": fields.Str(required=False, load_from="Type"), - "Value": fields.Str(required=False, load_from="Value"), - } - - -class ActivityTemplateSchema(schema.ResponseSchema): - """ ActivityTemplate - 工作流的Activity定义 - """ - - fields = { - "Input": fields.Str(), - "Name": fields.Str(required=False, load_from="Name"), - "Next": fields.Str(required=False, load_from="Next"), - "Output": fields.List(fields.Str()), - "RetryTimes": fields.Str(required=False, load_from="RetryTimes"), - "Timeout": fields.Str(required=False, load_from="Timeout"), - "Type": fields.Str(required=False, load_from="Type"), - } - - -class WorkflowTemplateSchema(schema.ResponseSchema): - """ WorkflowTemplate - Workflow对象定义 - """ - - fields = { - "Activites": fields.List(ActivityTemplateSchema()), - "Input": fields.List(ParamSchema()), - "Output": fields.List(ParamSchema()), - } +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.typesystem import schema, fields + + +class ParamSchema(schema.ResponseSchema): + """ Param - 工作流参数 + """ + + fields = { + "Name": fields.Str(required=False, load_from="Name"), + "Type": fields.Str(required=False, load_from="Type"), + "Value": fields.Str(required=False, load_from="Value"), + } + + +class ActivityTemplateSchema(schema.ResponseSchema): + """ ActivityTemplate - 工作流的Activity定义 + """ + + fields = { + "Input": fields.Str(), + "Name": fields.Str(required=False, load_from="Name"), + "Next": fields.Str(required=False, load_from="Next"), + "Output": fields.List(fields.Str()), + "RetryTimes": fields.Str(required=False, load_from="RetryTimes"), + "Timeout": fields.Str(required=False, load_from="Timeout"), + "Type": fields.Str(required=False, load_from="Type"), + } + + +class WorkflowTemplateSchema(schema.ResponseSchema): + """ WorkflowTemplate - Workflow对象定义 + """ + + fields = { + "Activites": fields.List(ActivityTemplateSchema()), + "Input": fields.List(ParamSchema()), + "Output": fields.List(ParamSchema()), + } diff --git a/ucloud/services/uaccount/__init__.py b/ucloud/services/uaccount/__init__.py index 4c48b5a..40a96af 100644 --- a/ucloud/services/uaccount/__init__.py +++ b/ucloud/services/uaccount/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- diff --git a/ucloud/services/uaccount/client.py b/ucloud/services/uaccount/client.py index b6ab9dc..99b43ff 100644 --- a/ucloud/services/uaccount/client.py +++ b/ucloud/services/uaccount/client.py @@ -1,162 +1,164 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.client import Client -from ucloud.services.uaccount.schemas import apis - - -class UAccountClient(Client): - def __init__(self, config, transport=None, middleware=None, logger=None): - super(UAccountClient, self).__init__(config, transport, middleware, logger) - - def create_project(self, req=None, **kwargs): - """ CreateProject - 创建项目 - - **Request** - - - **ProjectName** (str) - (Required) 项目名称 - - **Response** - - - **ProjectId** (str) - 所创建项目的Id - - """ - d = {} - req and d.update(req) - d = apis.CreateProjectRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("CreateProject", d, **kwargs) - return apis.CreateProjectResponseSchema().loads(resp) - - def get_project_list(self, req=None, **kwargs): - """ GetProjectList - 获取项目列表 - - **Request** - - - **IsFinance** (str) - 是否是财务账号 - - **Response** - - - **ProjectCount** (int) - 项目总数 - - **ProjectSet** (list) - 见 **ProjectListInfo** 模型定义 - - **Response Model** - - **ProjectListInfo** - - - **CreateTime** (int) - 创建时间(Unix时间戳) - - **IsDefault** (bool) - 是否为默认项目 - - **MemberCount** (int) - 项目下成员数量 - - **ParentId** (str) - 父项目ID - - **ParentName** (str) - 父项目名称 - - **ProjectId** (str) - 项目ID - - **ProjectName** (str) - 项目名称 - - **ResourceCount** (int) - 项目下资源数量 - - """ - d = {} - req and d.update(req) - d = apis.GetProjectListRequestSchema().dumps(d) - resp = self.invoke("GetProjectList", d, **kwargs) - return apis.GetProjectListResponseSchema().loads(resp) - - def get_region(self, req=None, **kwargs): - """ GetRegion - 获取用户在各数据中心的权限等信息 - - **Request** - - - **Response** - - - **Regions** (list) - 见 **RegionInfo** 模型定义 - - **Response Model** - - **RegionInfo** - - - **BitMaps** (str) - 用户在此数据中心的权限位 - - **IsDefault** (bool) - 是否用户当前默认数据中心 - - **Region** (str) - 地域名字,如cn-bj - - **RegionId** (int) - 数据中心ID - - **RegionName** (str) - 数据中心名称 - - **Zone** (str) - 可用区名字,如cn-bj-01 - - """ - d = {} - req and d.update(req) - d = apis.GetRegionRequestSchema().dumps(d) - resp = self.invoke("GetRegion", d, **kwargs) - return apis.GetRegionResponseSchema().loads(resp) - - def get_user_info(self, req=None, **kwargs): - """ GetUserInfo - 获取用户信息 - - **Request** - - - **Response** - - - **DataSet** (list) - 见 **UserInfo** 模型定义 - - **Response Model** - - **UserInfo** - - - **Admin** (int) - 是否超级管理员 0:否 1:是 - - **Administrator** (str) - 管理员 - - **AuthState** (str) - 实名认证状态 - - **City** (str) - 城市 - - **CompanyName** (str) - 公司名称 - - **Finance** (int) - 是否有财务权限 0:否 1:是 - - **IndustryType** (int) - 所属行业 - - **PhonePrefix** (str) - 国际号码前缀 - - **Province** (str) - 省份 - - **UserAddress** (str) - 公司地址 - - **UserEmail** (str) - 用户邮箱 - - **UserId** (int) - 用户Id - - **UserName** (str) - 称呼 - - **UserPhone** (str) - 用户手机 - - **UserType** (int) - 会员类型 - - **UserVersion** (int) - 是否子帐户(大于100为子帐户) - - """ - d = {} - req and d.update(req) - d = apis.GetUserInfoRequestSchema().dumps(d) - resp = self.invoke("GetUserInfo", d, **kwargs) - return apis.GetUserInfoResponseSchema().loads(resp) - - def modify_project(self, req=None, **kwargs): - """ ModifyProject - 修改项目 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **ProjectName** (str) - (Required) 新的项目名称 - - **Response** - - - """ - d = {"ProjectId": self.config.project_id} - req and d.update(req) - d = apis.ModifyProjectRequestSchema().dumps(d) - resp = self.invoke("ModifyProject", d, **kwargs) - return apis.ModifyProjectResponseSchema().loads(resp) - - def terminate_project(self, req=None, **kwargs): - """ TerminateProject - 删除项目 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID,不填写为默认项目,子帐号必须填写。 - - **Response** - - - """ - d = {"ProjectId": self.config.project_id} - req and d.update(req) - d = apis.TerminateProjectRequestSchema().dumps(d) - resp = self.invoke("TerminateProject", d, **kwargs) - return apis.TerminateProjectResponseSchema().loads(resp) +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.client import Client +from ucloud.services.uaccount.schemas import apis + + +class UAccountClient(Client): + def __init__(self, config, transport=None, middleware=None, logger=None): + super(UAccountClient, self).__init__( + config, transport, middleware, logger + ) + + def create_project(self, req=None, **kwargs): + """ CreateProject - 创建项目 + + **Request** + + - **ProjectName** (str) - (Required) 项目名称 + + **Response** + + - **ProjectId** (str) - 所创建项目的Id + + """ + d = {} + req and d.update(req) + d = apis.CreateProjectRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("CreateProject", d, **kwargs) + return apis.CreateProjectResponseSchema().loads(resp) + + def get_project_list(self, req=None, **kwargs): + """ GetProjectList - 获取项目列表 + + **Request** + + - **IsFinance** (str) - 是否是财务账号 + + **Response** + + - **ProjectCount** (int) - 项目总数 + - **ProjectSet** (list) - 见 **ProjectListInfo** 模型定义 + + **Response Model** + + **ProjectListInfo** + + - **CreateTime** (int) - 创建时间(Unix时间戳) + - **IsDefault** (bool) - 是否为默认项目 + - **MemberCount** (int) - 项目下成员数量 + - **ParentId** (str) - 父项目ID + - **ParentName** (str) - 父项目名称 + - **ProjectId** (str) - 项目ID + - **ProjectName** (str) - 项目名称 + - **ResourceCount** (int) - 项目下资源数量 + + """ + d = {} + req and d.update(req) + d = apis.GetProjectListRequestSchema().dumps(d) + resp = self.invoke("GetProjectList", d, **kwargs) + return apis.GetProjectListResponseSchema().loads(resp) + + def get_region(self, req=None, **kwargs): + """ GetRegion - 获取用户在各数据中心的权限等信息 + + **Request** + + + **Response** + + - **Regions** (list) - 见 **RegionInfo** 模型定义 + + **Response Model** + + **RegionInfo** + + - **BitMaps** (str) - 用户在此数据中心的权限位 + - **IsDefault** (bool) - 是否用户当前默认数据中心 + - **Region** (str) - 地域名字,如cn-bj + - **RegionId** (int) - 数据中心ID + - **RegionName** (str) - 数据中心名称 + - **Zone** (str) - 可用区名字,如cn-bj-01 + + """ + d = {} + req and d.update(req) + d = apis.GetRegionRequestSchema().dumps(d) + resp = self.invoke("GetRegion", d, **kwargs) + return apis.GetRegionResponseSchema().loads(resp) + + def get_user_info(self, req=None, **kwargs): + """ GetUserInfo - 获取用户信息 + + **Request** + + + **Response** + + - **DataSet** (list) - 见 **UserInfo** 模型定义 + + **Response Model** + + **UserInfo** + + - **Admin** (int) - 是否超级管理员 0:否 1:是 + - **Administrator** (str) - 管理员 + - **AuthState** (str) - 实名认证状态 + - **City** (str) - 城市 + - **CompanyName** (str) - 公司名称 + - **Finance** (int) - 是否有财务权限 0:否 1:是 + - **IndustryType** (int) - 所属行业 + - **PhonePrefix** (str) - 国际号码前缀 + - **Province** (str) - 省份 + - **UserAddress** (str) - 公司地址 + - **UserEmail** (str) - 用户邮箱 + - **UserId** (int) - 用户Id + - **UserName** (str) - 称呼 + - **UserPhone** (str) - 用户手机 + - **UserType** (int) - 会员类型 + - **UserVersion** (int) - 是否子帐户(大于100为子帐户) + + """ + d = {} + req and d.update(req) + d = apis.GetUserInfoRequestSchema().dumps(d) + resp = self.invoke("GetUserInfo", d, **kwargs) + return apis.GetUserInfoResponseSchema().loads(resp) + + def modify_project(self, req=None, **kwargs): + """ ModifyProject - 修改项目 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **ProjectName** (str) - (Required) 新的项目名称 + + **Response** + + + """ + d = {"ProjectId": self.config.project_id} + req and d.update(req) + d = apis.ModifyProjectRequestSchema().dumps(d) + resp = self.invoke("ModifyProject", d, **kwargs) + return apis.ModifyProjectResponseSchema().loads(resp) + + def terminate_project(self, req=None, **kwargs): + """ TerminateProject - 删除项目 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID,不填写为默认项目,子帐号必须填写。 + + **Response** + + + """ + d = {"ProjectId": self.config.project_id} + req and d.update(req) + d = apis.TerminateProjectRequestSchema().dumps(d) + resp = self.invoke("TerminateProject", d, **kwargs) + return apis.TerminateProjectResponseSchema().loads(resp) diff --git a/ucloud/services/uaccount/schemas/__init__.py b/ucloud/services/uaccount/schemas/__init__.py index 4c48b5a..40a96af 100644 --- a/ucloud/services/uaccount/schemas/__init__.py +++ b/ucloud/services/uaccount/schemas/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- diff --git a/ucloud/services/uaccount/schemas/apis.py b/ucloud/services/uaccount/schemas/apis.py index b3631ee..ad5aac2 100644 --- a/ucloud/services/uaccount/schemas/apis.py +++ b/ucloud/services/uaccount/schemas/apis.py @@ -1,148 +1,150 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.typesystem import schema, fields -from ucloud.services.uaccount.schemas import models - -""" UAccount API Schema -""" -""" -API: CreateProject - -创建项目 -""" - - -class CreateProjectRequestSchema(schema.RequestSchema): - """ CreateProject - 创建项目 - """ - - fields = {"ProjectName": fields.Str(required=True, dump_to="ProjectName")} - - -class CreateProjectResponseSchema(schema.ResponseSchema): - """ CreateProject - 创建项目 - """ - - fields = {"ProjectId": fields.Str(required=True, load_from="ProjectId")} - - -""" -API: GetProjectList - -获取项目列表 -""" - - -class GetProjectListRequestSchema(schema.RequestSchema): - """ GetProjectList - 获取项目列表 - """ - - fields = {"IsFinance": fields.Str(required=False, dump_to="IsFinance")} - - -class GetProjectListResponseSchema(schema.ResponseSchema): - """ GetProjectList - 获取项目列表 - """ - - fields = { - "ProjectCount": fields.Int(required=True, load_from="ProjectCount"), - "ProjectSet": fields.List( - models.ProjectListInfoSchema(), required=True, load_from="ProjectSet" - ), - } - - -""" -API: GetRegion - -获取用户在各数据中心的权限等信息 -""" - - -class GetRegionRequestSchema(schema.RequestSchema): - """ GetRegion - 获取用户在各数据中心的权限等信息 - """ - - fields = {} - - -class GetRegionResponseSchema(schema.ResponseSchema): - """ GetRegion - 获取用户在各数据中心的权限等信息 - """ - - fields = { - "Regions": fields.List( - models.RegionInfoSchema(), required=False, load_from="Regions" - ) - } - - -""" -API: GetUserInfo - -获取用户信息 -""" - - -class GetUserInfoRequestSchema(schema.RequestSchema): - """ GetUserInfo - 获取用户信息 - """ - - fields = {} - - -class GetUserInfoResponseSchema(schema.ResponseSchema): - """ GetUserInfo - 获取用户信息 - """ - - fields = { - "DataSet": fields.List( - models.UserInfoSchema(), required=True, load_from="DataSet" - ) - } - - -""" -API: ModifyProject - -修改项目 -""" - - -class ModifyProjectRequestSchema(schema.RequestSchema): - """ ModifyProject - 修改项目 - """ - - fields = { - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "ProjectName": fields.Str(required=True, dump_to="ProjectName"), - } - - -class ModifyProjectResponseSchema(schema.ResponseSchema): - """ ModifyProject - 修改项目 - """ - - fields = {} - - -""" -API: TerminateProject - -删除项目 -""" - - -class TerminateProjectRequestSchema(schema.RequestSchema): - """ TerminateProject - 删除项目 - """ - - fields = {"ProjectId": fields.Str(required=False, dump_to="ProjectId")} - - -class TerminateProjectResponseSchema(schema.ResponseSchema): - """ TerminateProject - 删除项目 - """ - - fields = {} +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.typesystem import schema, fields +from ucloud.services.uaccount.schemas import models + +""" UAccount API Schema +""" +""" +API: CreateProject + +创建项目 +""" + + +class CreateProjectRequestSchema(schema.RequestSchema): + """ CreateProject - 创建项目 + """ + + fields = {"ProjectName": fields.Str(required=True, dump_to="ProjectName")} + + +class CreateProjectResponseSchema(schema.ResponseSchema): + """ CreateProject - 创建项目 + """ + + fields = {"ProjectId": fields.Str(required=True, load_from="ProjectId")} + + +""" +API: GetProjectList + +获取项目列表 +""" + + +class GetProjectListRequestSchema(schema.RequestSchema): + """ GetProjectList - 获取项目列表 + """ + + fields = {"IsFinance": fields.Str(required=False, dump_to="IsFinance")} + + +class GetProjectListResponseSchema(schema.ResponseSchema): + """ GetProjectList - 获取项目列表 + """ + + fields = { + "ProjectCount": fields.Int(required=True, load_from="ProjectCount"), + "ProjectSet": fields.List( + models.ProjectListInfoSchema(), + required=True, + load_from="ProjectSet", + ), + } + + +""" +API: GetRegion + +获取用户在各数据中心的权限等信息 +""" + + +class GetRegionRequestSchema(schema.RequestSchema): + """ GetRegion - 获取用户在各数据中心的权限等信息 + """ + + fields = {} + + +class GetRegionResponseSchema(schema.ResponseSchema): + """ GetRegion - 获取用户在各数据中心的权限等信息 + """ + + fields = { + "Regions": fields.List( + models.RegionInfoSchema(), required=False, load_from="Regions" + ) + } + + +""" +API: GetUserInfo + +获取用户信息 +""" + + +class GetUserInfoRequestSchema(schema.RequestSchema): + """ GetUserInfo - 获取用户信息 + """ + + fields = {} + + +class GetUserInfoResponseSchema(schema.ResponseSchema): + """ GetUserInfo - 获取用户信息 + """ + + fields = { + "DataSet": fields.List( + models.UserInfoSchema(), required=True, load_from="DataSet" + ) + } + + +""" +API: ModifyProject + +修改项目 +""" + + +class ModifyProjectRequestSchema(schema.RequestSchema): + """ ModifyProject - 修改项目 + """ + + fields = { + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "ProjectName": fields.Str(required=True, dump_to="ProjectName"), + } + + +class ModifyProjectResponseSchema(schema.ResponseSchema): + """ ModifyProject - 修改项目 + """ + + fields = {} + + +""" +API: TerminateProject + +删除项目 +""" + + +class TerminateProjectRequestSchema(schema.RequestSchema): + """ TerminateProject - 删除项目 + """ + + fields = {"ProjectId": fields.Str(required=False, dump_to="ProjectId")} + + +class TerminateProjectResponseSchema(schema.ResponseSchema): + """ TerminateProject - 删除项目 + """ + + fields = {} diff --git a/ucloud/services/uaccount/schemas/models.py b/ucloud/services/uaccount/schemas/models.py index 8279748..ce08652 100644 --- a/ucloud/services/uaccount/schemas/models.py +++ b/ucloud/services/uaccount/schemas/models.py @@ -1,58 +1,58 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.typesystem import schema, fields - - -class ProjectListInfoSchema(schema.ResponseSchema): - """ ProjectListInfo - 项目信息 - """ - - fields = { - "CreateTime": fields.Int(required=True, load_from="CreateTime"), - "IsDefault": fields.Bool(required=True, load_from="IsDefault"), - "MemberCount": fields.Int(required=True, load_from="MemberCount"), - "ParentId": fields.Str(required=True, load_from="ParentId"), - "ParentName": fields.Str(required=True, load_from="ParentName"), - "ProjectId": fields.Str(required=True, load_from="ProjectId"), - "ProjectName": fields.Str(required=True, load_from="ProjectName"), - "ResourceCount": fields.Int(required=True, load_from="ResourceCount"), - } - - -class RegionInfoSchema(schema.ResponseSchema): - """ RegionInfo - 数据中心信息 - """ - - fields = { - "BitMaps": fields.Str(required=True, load_from="BitMaps"), - "IsDefault": fields.Bool(required=True, load_from="IsDefault"), - "Region": fields.Str(required=True, load_from="Region"), - "RegionId": fields.Int(required=True, load_from="RegionId"), - "RegionName": fields.Str(required=True, load_from="RegionName"), - "Zone": fields.Str(required=True, load_from="Zone"), - } - - -class UserInfoSchema(schema.ResponseSchema): - """ UserInfo - 用户信息 - """ - - fields = { - "Admin": fields.Int(required=True, load_from="Admin"), - "Administrator": fields.Str(required=True, load_from="Administrator"), - "AuthState": fields.Str(required=True, load_from="AuthState"), - "City": fields.Str(required=True, load_from="City"), - "CompanyName": fields.Str(required=True, load_from="CompanyName"), - "Finance": fields.Int(required=True, load_from="Finance"), - "IndustryType": fields.Int(required=True, load_from="IndustryType"), - "PhonePrefix": fields.Str(required=True, load_from="PhonePrefix"), - "Province": fields.Str(required=True, load_from="Province"), - "UserAddress": fields.Str(required=True, load_from="UserAddress"), - "UserEmail": fields.Str(required=True, load_from="UserEmail"), - "UserId": fields.Int(required=True, load_from="UserId"), - "UserName": fields.Str(required=True, load_from="UserName"), - "UserPhone": fields.Str(required=True, load_from="UserPhone"), - "UserType": fields.Int(required=True, load_from="UserType"), - "UserVersion": fields.Int(required=True, load_from="UserVersion"), - } +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.typesystem import schema, fields + + +class ProjectListInfoSchema(schema.ResponseSchema): + """ ProjectListInfo - 项目信息 + """ + + fields = { + "CreateTime": fields.Int(required=True, load_from="CreateTime"), + "IsDefault": fields.Bool(required=True, load_from="IsDefault"), + "MemberCount": fields.Int(required=True, load_from="MemberCount"), + "ParentId": fields.Str(required=True, load_from="ParentId"), + "ParentName": fields.Str(required=True, load_from="ParentName"), + "ProjectId": fields.Str(required=True, load_from="ProjectId"), + "ProjectName": fields.Str(required=True, load_from="ProjectName"), + "ResourceCount": fields.Int(required=True, load_from="ResourceCount"), + } + + +class RegionInfoSchema(schema.ResponseSchema): + """ RegionInfo - 数据中心信息 + """ + + fields = { + "BitMaps": fields.Str(required=True, load_from="BitMaps"), + "IsDefault": fields.Bool(required=True, load_from="IsDefault"), + "Region": fields.Str(required=True, load_from="Region"), + "RegionId": fields.Int(required=True, load_from="RegionId"), + "RegionName": fields.Str(required=True, load_from="RegionName"), + "Zone": fields.Str(required=True, load_from="Zone"), + } + + +class UserInfoSchema(schema.ResponseSchema): + """ UserInfo - 用户信息 + """ + + fields = { + "Admin": fields.Int(required=True, load_from="Admin"), + "Administrator": fields.Str(required=True, load_from="Administrator"), + "AuthState": fields.Str(required=True, load_from="AuthState"), + "City": fields.Str(required=True, load_from="City"), + "CompanyName": fields.Str(required=True, load_from="CompanyName"), + "Finance": fields.Int(required=True, load_from="Finance"), + "IndustryType": fields.Int(required=True, load_from="IndustryType"), + "PhonePrefix": fields.Str(required=True, load_from="PhonePrefix"), + "Province": fields.Str(required=True, load_from="Province"), + "UserAddress": fields.Str(required=True, load_from="UserAddress"), + "UserEmail": fields.Str(required=True, load_from="UserEmail"), + "UserId": fields.Int(required=True, load_from="UserId"), + "UserName": fields.Str(required=True, load_from="UserName"), + "UserPhone": fields.Str(required=True, load_from="UserPhone"), + "UserType": fields.Int(required=True, load_from="UserType"), + "UserVersion": fields.Int(required=True, load_from="UserVersion"), + } diff --git a/ucloud/services/udb/__init__.py b/ucloud/services/udb/__init__.py index 4c48b5a..40a96af 100644 --- a/ucloud/services/udb/__init__.py +++ b/ucloud/services/udb/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- diff --git a/ucloud/services/udb/client.py b/ucloud/services/udb/client.py index 9d23f60..03b1c62 100644 --- a/ucloud/services/udb/client.py +++ b/ucloud/services/udb/client.py @@ -1,1306 +1,1315 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.client import Client -from ucloud.services.udb.schemas import apis - - -class UDBClient(Client): - def __init__(self, config, transport=None, middleware=None, logger=None): - super(UDBClient, self).__init__(config, transport, middleware, logger) - - def backup_udb_instance(self, req=None, **kwargs): - """ BackupUDBInstance - 备份UDB实例 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **BackupName** (str) - (Required) 备份名称 - - **DBId** (str) - (Required) DB实例Id,该值可以通过DescribeUDBInstance获取 - - **BackupMethod** (str) - 使用的备份方式。(快照备份即物理备份。注意只有SSD版本的mysql实例支持设置为snapshot) - - **Blacklist** (str) - 备份黑名单列表,以 ; 分隔。注意:只有逻辑备份下备份黑名单才生效,快照备份备份黑名单下无效 - - **ForceBackup** (bool) - true表示逻辑备份时是使用 --force 参数,false表示不使用 --force 参数。物理备份此参数无效。 - - **UseBlacklist** (bool) - 是否使用黑名单备份,默认false - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.BackupUDBInstanceRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("BackupUDBInstance", d, **kwargs) - return apis.BackupUDBInstanceResponseSchema().loads(resp) - - def backup_udb_instance_binlog(self, req=None, **kwargs): - """ BackupUDBInstanceBinlog - 备份UDB指定时间段的binlog列表 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **BackupFile** (str) - (Required) 需要备份文件,可通过DescribeUDBInstanceBinlog获得 如果要传入多个文件名,以空格键分割,用单引号包含. - - **DBId** (str) - (Required) DB实例Id,该值可以通过DescribeUDBInstance获取 - - **BackupName** (str) - DB备份文件名称 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.BackupUDBInstanceBinlogRequestSchema().dumps(d) - resp = self.invoke("BackupUDBInstanceBinlog", d, **kwargs) - return apis.BackupUDBInstanceBinlogResponseSchema().loads(resp) - - def backup_udb_instance_error_log(self, req=None, **kwargs): - """ BackupUDBInstanceErrorLog - 备份UDB指定时间段的errorlog - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **BackupName** (str) - (Required) 备份名称 - - **DBId** (str) - (Required) DB实例Id,该值可以通过DescribeUDBInstance获取 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.BackupUDBInstanceErrorLogRequestSchema().dumps(d) - resp = self.invoke("BackupUDBInstanceErrorLog", d, **kwargs) - return apis.BackupUDBInstanceErrorLogResponseSchema().loads(resp) - - def backup_udb_instance_slow_log(self, req=None, **kwargs): - """ BackupUDBInstanceSlowLog - 备份UDB指定时间段的slowlog分析结果 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **BackupName** (str) - (Required) 备份文件名称 - - **BeginTime** (int) - (Required) 过滤条件:起始时间(时间戳) - - **DBId** (str) - (Required) DB实例Id,该值可以通过DescribeUDBInstance获取 - - **EndTime** (int) - (Required) 过滤条件:结束时间(时间戳) - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.BackupUDBInstanceSlowLogRequestSchema().dumps(d) - resp = self.invoke("BackupUDBInstanceSlowLog", d, **kwargs) - return apis.BackupUDBInstanceSlowLogResponseSchema().loads(resp) - - def check_recover_udb_instance(self, req=None, **kwargs): - """ CheckRecoverUDBInstance - 核查db是否可以使用回档功能 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **SrcDBId** (str) - (Required) 源实例的Id(只支持普通版DB不支持高可用) - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **LastestTime** (int) - 核查成功返回值为可以回档到的最近时刻,核查失败不返回 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.CheckRecoverUDBInstanceRequestSchema().dumps(d) - resp = self.invoke("CheckRecoverUDBInstance", d, **kwargs) - return apis.CheckRecoverUDBInstanceResponseSchema().loads(resp) - - def check_udb_instance_to_ha_allowance(self, req=None, **kwargs): - """ CheckUDBInstanceToHAAllowance - 核查db是否可以升级为高可用 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **DBId** (str) - (Required) 实例的Id,该值可以通过DescribeUDBInstance获取 - - **Response** - - - **Allowance** (str) - Yes ,No ,Yes即可以升级,No为不可以升级 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.CheckUDBInstanceToHAAllowanceRequestSchema().dumps(d) - resp = self.invoke("CheckUDBInstanceToHAAllowance", d, **kwargs) - return apis.CheckUDBInstanceToHAAllowanceResponseSchema().loads(resp) - - def clear_udb_log(self, req=None, **kwargs): - """ ClearUDBLog - 清除UDB实例的log - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **DBId** (str) - (Required) DB实例的id,该值可以通过DescribeUDBInstance获取 - - **LogType** (int) - (Required) 日志类型,10-error(暂不支持)、20-slow(暂不支持 )、30-binlog - - **BeforeTime** (int) - 删除时间点(至少前一天)之前log,采用时间戳(秒),默认当 前时间点前一天 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.ClearUDBLogRequestSchema().dumps(d) - resp = self.invoke("ClearUDBLog", d, **kwargs) - return apis.ClearUDBLogResponseSchema().loads(resp) - - def create_udb_instance(self, req=None, **kwargs): - """ CreateUDBInstance - 创建UDB实例(包括创建mysql master节点、mongodb primary/configsvr节点和从备份恢复实例) - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **AdminPassword** (str) - (Required) 管理员密码 - - **DBTypeId** (str) - (Required) DB类型id,mysql/mongodb/postgesql按版本细分 1:mysql-5.1,2:mysql-5.5,3:percona-5.5,4:mysql-5.6,5:percona-5.6,6:mysql-5.7,7:percona-5.7,8:mariadb-10.0,9:mongodb-2.4,10:mongodb-2.6,11:mongodb-3.0,12:mongodb-3.2,13:postgresql-9.4,14:postgresql-9.6,14:postgresql-10.4 - - **DiskSpace** (int) - (Required) 磁盘空间(GB), 暂时支持20G - 3000G - - **MemoryLimit** (int) - (Required) 内存限制(MB),目前支持以下几档 1000M/2000M/4000M/ 6000M/8000M/12000M/16000M/ 24000M/32000M/48000M/ 64000M/96000M - - **Name** (str) - (Required) 实例名称,至少6位 - - **ParamGroupId** (int) - (Required) DB实例使用的配置参数组id - - **Port** (int) - (Required) 端口号,mysql默认3306,mongodb默认27017,postgresql默认5432 - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **AdminUser** (str) - 管理员帐户名,默认root - - **BackupCount** (int) - 备份策略,每周备份数量,默认7次 - - **BackupDuration** (int) - 备份策略,备份时间间隔,单位小时计,默认24小时 - - **BackupId** (int) - 备份id,如果指定,则表明从备份恢复实例 - - **BackupTime** (int) - 备份策略,备份开始时间,单位小时计,默认1点 - - **BackupZone** (str) - 跨可用区高可用备库所在可用区,参见 `可用区列表 `_ - - **CPU** (int) - cpu核数 - - **ChargeType** (str) - Year, Month, Dynamic,Trial,默认: Month - - **ClusterRole** (str) - 当DB类型(DBTypeId)为mongodb时,需要指定mongo的角色,可选值为configsrv (配置节点),shardsrv (数据节点) - - **CouponId** (str) - 使用的代金券id - - **DisableSemisync** (bool) - 是否开启异步高可用,默认不填,可置为true - - **HAArch** (str) - 高可用架构:1) haproxy(默认): 当前仅支持mysql。2) sentinel: 基于vip和哨兵节点的架构,当前支持mysql和pg。 - - **InstanceMode** (str) - UDB实例模式类型, 可选值如下: "Normal": 普通版UDB实例 "HA": 高可用版UDB实例 默认是"Normal" - - **InstanceType** (str) - UDB数据库机型 - - **Quantity** (int) - 购买时长,默认值1 - - **SSDType** (str) - SSD类型,可选值为"SATA"、"PCI-E",如果UseSSD为true ,则必选 - - **SubnetId** (str) - 子网ID - - **Tag** (str) - - - **UDBCId** (str) - 专区ID信息(如果这个参数存在这说明是在专区中创建DB) - - **UseSSD** (bool) - 是否使用SSD,默认为false。目前主要可用区、海外机房、新机房只提供SSD资源,非SSD资源不再提供。 - - **VPCId** (str) - VPC的ID - - **Response** - - - **DBId** (str) - BD实例id - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.CreateUDBInstanceRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("CreateUDBInstance", d, **kwargs) - return apis.CreateUDBInstanceResponseSchema().loads(resp) - - def create_udb_instance_by_recovery(self, req=None, **kwargs): - """ CreateUDBInstanceByRecovery - 创建db,将新创建的db恢复到指定db某个指定时间点 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Name** (str) - (Required) 实例名称,至少6位 - - **RecoveryTime** (int) - (Required) 恢复到某个时间点的时间戳(UTC时间格式,默认单位秒) - - **SrcDBId** (str) - (Required) 源实例的Id - - **ChargeType** (str) - Year, Month, Dynamic,Trial,默认: Dynamic - - **CouponId** (str) - 使用的代金券id - - **Quantity** (int) - 购买时长,默认值1 - - **SubnetId** (str) - 子网ID - - **UDBCId** (str) - 专区的Id - - **UseSSD** (bool) - 指定是否是否使用SSD,默认使用主库的配置 - - **VPCId** (str) - VPC的ID - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **DBId** (str) - db实例id - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.CreateUDBInstanceByRecoveryRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("CreateUDBInstanceByRecovery", d, **kwargs) - return apis.CreateUDBInstanceByRecoveryResponseSchema().loads(resp) - - def create_udb_param_group(self, req=None, **kwargs): - """ CreateUDBParamGroup - 从已有配置文件创建新配置文件 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **DBTypeId** (str) - (Required) DB类型id,mysql/mongodb/postgesql按版本细分 1:mysql-5.1,2:mysql-5.5,3:percona-5.5,4:mysql-5.6,5:percona-5.6,6:mysql-5.7,7:percona-5.7,8:mariadb-10.0,9:mongodb-2.4,10:mongodb-2.6,11:mongodb-3.0,12:mongodb-3.2,13:postgresql-9.4,14:postgresql-9.6 - - **Description** (str) - (Required) 参数组描述 - - **GroupName** (str) - (Required) 新配置参数组名称 - - **SrcGroupId** (int) - (Required) 源参数组id - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **RegionFlag** (bool) - 是否是地域级别的配置文件,默认是false - - **Response** - - - **GroupId** (int) - 新配置参数组id - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.CreateUDBParamGroupRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("CreateUDBParamGroup", d, **kwargs) - return apis.CreateUDBParamGroupResponseSchema().loads(resp) - - def create_udb_replication_instance(self, req=None, **kwargs): - """ CreateUDBReplicationInstance - 创建MongoDB的副本节点(包括仲裁) - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Name** (str) - (Required) 实例名称,至少6位 - - **SrcId** (str) - (Required) primary节点的DBId,该值可以通过DescribeUDBInstance获取 - - **CouponId** (str) - 使用的代金券id - - **IsArbiter** (bool) - 是否是仲裁节点,默认false,仲裁节点按最小机型创建 - - **Port** (int) - 端口号,默认27017,取值范围3306至65535。 - - **UseSSD** (bool) - 是否使用SSD,默认不使用 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **DBId** (str) - 创建从节点的DBId - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.CreateUDBReplicationInstanceRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("CreateUDBReplicationInstance", d, **kwargs) - return apis.CreateUDBReplicationInstanceResponseSchema().loads(resp) - - def create_udb_route_instance(self, req=None, **kwargs): - """ CreateUDBRouteInstance - 创建mongos实例 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **ConfigsvrId** (list) - (Required) 配置服务器的dbid,允许一个或者三个。 - - **DBTypeId** (str) - (Required) DB类型id,mongodb按版本细分有1:mongodb-2.4,2:mongodb-2.6,3:mongodb-3.0,4:mongodb-3.2 - - **DiskSpace** (int) - (Required) 磁盘空间(GB), 暂时支持20G - 500G - - **MemoryLimit** (int) - (Required) 内存限制(MB),目前支持以下几档 600M/1500M/3000M /6000M/15000M/30000M - - **Name** (str) - (Required) 实例名称,至少6位 - - **ParamGroupId** (int) - (Required) DB实例使用的配置参数组id - - **Port** (int) - (Required) 端口号,mongodb默认27017 - - **ChargeType** (str) - Year, Month, Dynamic,Trial,默认: Month - - **CouponId** (str) - 使用的代金券id - - **Quantity** (int) - 购买时长,默认值1 - - **UseSSD** (bool) - 是否使用SSD,默认为false - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **DBId** (str) - db实例id - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.CreateUDBRouteInstanceRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("CreateUDBRouteInstance", d, **kwargs) - return apis.CreateUDBRouteInstanceResponseSchema().loads(resp) - - def create_udb_slave(self, req=None, **kwargs): - """ CreateUDBSlave - 创建UDB实例的slave - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Name** (str) - (Required) 实例名称,至少6位 - - **SrcId** (str) - (Required) master实例的DBId,该值可以通过DescribeUDBInstance获取 - - **CouponId** (str) - 使用的代金券id - - **DiskSpace** (int) - 磁盘空间(GB), 暂时支持20G - 3000G(API支持,前端暂时只开放内存定制) - - **InstanceMode** (str) - UDB实例部署模式,可选值如下:Normal: 普通单点实例HA: 高可用部署实例 - - **InstanceType** (str) - UDB实例类型:Normal和SATA_SSD - - **IsLock** (bool) - 是否锁主库,默认为true - - **MemoryLimit** (int) - 内存限制(MB),目前支持以下几档 1000M/2000M/4000M/ 6000M/8000M/12000M/16000M/ 24000M/32000M/48000M/ 64000M/96000M - - **Port** (int) - 端口号,mysql默认3306 - - **SSDType** (str) - SSD类型,可选值为"SATA"、"PCI-E",如果UseSSD为true ,则必选 - - **UseSSD** (bool) - 是否使用SSD,默认为false - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **DBId** (str) - 创建slave的DBId - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.CreateUDBSlaveRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("CreateUDBSlave", d, **kwargs) - return apis.CreateUDBSlaveResponseSchema().loads(resp) - - def delete_udb_backup(self, req=None, **kwargs): - """ DeleteUDBBackup - 删除UDB实例备份 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **BackupId** (int) - (Required) 备份id,可通过DescribeUDBBackup获得 - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **BackupZone** (str) - 跨可用区高可用备库所在可用区,参见[可用区列表] - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DeleteUDBBackupRequestSchema().dumps(d) - resp = self.invoke("DeleteUDBBackup", d, **kwargs) - return apis.DeleteUDBBackupResponseSchema().loads(resp) - - def delete_udb_instance(self, req=None, **kwargs): - """ DeleteUDBInstance - 删除UDB实例 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **DBId** (str) - (Required) DB实例的id,该值可以通过DescribeUDBInstance获取 - - **UDBCId** (str) - 专区ID - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DeleteUDBInstanceRequestSchema().dumps(d) - resp = self.invoke("DeleteUDBInstance", d, **kwargs) - return apis.DeleteUDBInstanceResponseSchema().loads(resp) - - def delete_udb_log_package(self, req=None, **kwargs): - """ DeleteUDBLogPackage - 删除UDB日志包 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **BackupId** (int) - (Required) 日志包id,可通过DescribeUDBLogPackage获得 - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **BackupZone** (str) - 跨可用区高可用备库所在可用区 - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DeleteUDBLogPackageRequestSchema().dumps(d) - resp = self.invoke("DeleteUDBLogPackage", d, **kwargs) - return apis.DeleteUDBLogPackageResponseSchema().loads(resp) - - def delete_udb_param_group(self, req=None, **kwargs): - """ DeleteUDBParamGroup - 删除配置参数组 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **GroupId** (int) - (Required) 参数组id,可通过DescribeUDBParamGroup获取 - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **RegionFlag** (bool) - 是否属于地域级别 - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DeleteUDBParamGroupRequestSchema().dumps(d) - resp = self.invoke("DeleteUDBParamGroup", d, **kwargs) - return apis.DeleteUDBParamGroupResponseSchema().loads(resp) - - def describe_udb_backup(self, req=None, **kwargs): - """ DescribeUDBBackup - 列表UDB实例备份信息.Zone不填表示多可用区,填代表单可用区 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Limit** (int) - (Required) 分页显示的条目数,列表操作则指定 - - **Offset** (int) - (Required) 分页显示的起始偏移,列表操作则指定 - - **BackupId** (int) - 如果填了BackupId, 那么只拉取这个备份的记录 - - **BackupType** (int) - 备份类型,取值为0或1,0表示自动,1表示手动 - - **BeginTime** (int) - 过滤条件:起始时间(Unix时间戳) - - **ClassType** (str) - 如果未指定GroupId,则可选是否选取特定DB类型的配置(sql, nosql, postgresql, sqlserver) - - **DBId** (str) - DB实例Id,如果指定,则只获取该db的备份信息 该值可以通过DescribeUDBInstance获取 - - **EndTime** (int) - 过滤条件:结束时间(Unix时间戳) - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **DataSet** (list) - 见 **UDBBackupSet** 模型定义 - - **TotalCount** (int) - 满足条件备份总数,如果指定dbid,则是该db备份总数 - - **Response Model** - - **UDBBackupSet** - - - **BackupEndTime** (int) - 备份完成时间(Unix时间戳) - - **BackupId** (int) - 备份id - - **BackupName** (str) - 备份名称 - - **BackupSize** (int) - 备份文件大小(字节) - - **BackupTime** (int) - 备份时间(Unix时间戳) - - **BackupType** (int) - 备份类型,取值为0或1,0表示自动,1表示手动 - - **BackupZone** (str) - 跨机房高可用备库所在可用区 - - **DBId** (str) - dbid - - **DBName** (str) - 对应的db名称 - - **ErrorInfo** (str) - 备份错误信息 - - **State** (str) - 备份状态 Backuping // 备份中 Success // 备份成功 Failed // 备份失败 Expired // 备份过期 - - **Zone** (str) - 备份所在可用区 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeUDBBackupRequestSchema().dumps(d) - resp = self.invoke("DescribeUDBBackup", d, **kwargs) - return apis.DescribeUDBBackupResponseSchema().loads(resp) - - def describe_udb_backup_blacklist(self, req=None, **kwargs): - """ DescribeUDBBackupBlacklist - 获取UDB实例的备份黑名单 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **DBId** (str) - (Required) DB实例Id,该值可以通过DescribeUDBInstance获取 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **Blacklist** (str) - DB的黑名单列表, db.%为指定库 dbname.tablename为指定表 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeUDBBackupBlacklistRequestSchema().dumps(d) - resp = self.invoke("DescribeUDBBackupBlacklist", d, **kwargs) - return apis.DescribeUDBBackupBlacklistResponseSchema().loads(resp) - - def describe_udb_binlog_backup_url(self, req=None, **kwargs): - """ DescribeUDBBinlogBackupURL - 获取UDB的Binlog备份地址 - - **Request** - - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **BackupId** (int) - (Required) DB实例备份ID - - **DBId** (str) - (Required) DB实例Id - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **BackupPath** (str) - DB实例备份文件的公网地址 - - **InnerBackupPath** (str) - DB实例备份文件的内网地址 - - """ - d = {"Region": self.config.region} - req and d.update(req) - d = apis.DescribeUDBBinlogBackupURLRequestSchema().dumps(d) - resp = self.invoke("DescribeUDBBinlogBackupURL", d, **kwargs) - return apis.DescribeUDBBinlogBackupURLResponseSchema().loads(resp) - - def describe_udb_instance(self, req=None, **kwargs): - """ DescribeUDBInstance - 获取UDB实例信息,支持两类操作:(1)指定DBId用于获取该db的信息;(2)指定ClassType、Offset、Limit用于列表操作,查询某一个类型db。 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **ClassType** (str) - (Required) DB种类,如果是列表操作,则需要指定,不区分大小写,其取值如下:mysql: SQL;mongo: NOSQL;postgresql: postgresql - - **Limit** (int) - (Required) 分页显示数量,列表操作则指定 - - **Offset** (int) - (Required) 分页显示起始偏移位置,列表操作则指定 - - **DBId** (str) - DB实例id,如果指定则获取描述,否则为列表操作, 指定Offset/Limit/ClassType DBId可通过DescribeUDBInstance获取 - - **IncludeSlaves** (bool) - 当只获取这个特定DBId的信息时,如果有该选项,那么把这个DBId实例的所有从库信息一起拉取并返回 - - **IsInUDBC** (bool) - 是否查看专区里面DB - - **UDBCId** (str) - IsInUDBC为True,UDBCId为空,说明查看整个可用区的专区的db,如果UDBId不为空则只查看此专区下面的db - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **DataSet** (list) - 见 **UDBInstanceSet** 模型定义 - - **TotalCount** (int) - 用户db组的数量,对于 mysql: 主从结对数量,没有slave,则只有master mongodb: 副本集数量 - - **Response Model** - - **UDBSlaveInstanceSet** - - - **AdminUser** (str) - 管理员帐户名,默认root - - **BackupBeginTime** (int) - 备份策略,不可修改,开始时间,单位小时计,默认3点 - - **BackupBlacklist** (str) - 备份策略,备份黑名单,mongodb则不适用 - - **BackupCount** (int) - 备份策略,不可修改,备份文件保留的数量,默认7次 - - **BackupDate** (str) - 备份日期标记位。共7位,每一位为一周中一天的备份情况 0表示关闭当天备份,1表示打开当天备份。最右边的一位 为星期天的备份开关,其余从右到左依次为星期一到星期 六的备份配置开关,每周必须至少设置两天备份。 例如:1100000 表示打开星期六和星期五的自动备份功能 - - **BackupDuration** (int) - 备份策略,一天内备份时间间隔,单位小时,默认24小时 - - **ChargeType** (str) - Year, Month, Dynamic,Trial,默认: Dynamic - - **ClusterRole** (str) - 当DB类型为mongodb时,返回该实例所在集群中的角色,包括:mongos、configsrv_sccc、configsrv_csrs、shardsrv_datanode、shardsrv_arbiter,其中congfigsrv分为sccc和csrs两种模式,shardsrv分为datanode和arbiter两种模式 - - **CreateTime** (int) - DB实例创建时间,采用UTC计时时间戳 - - **DBId** (str) - DB实例id - - **DBTypeId** (str) - DB类型id,mysql/mongodb按版本细分各有一个id 目前id的取值范围为[1,7],数值对应的版本如下: 1:mysql-5.5,2:mysql-5.1,3:percona-5.5 4:mongodb-2.4,5:mongodb-2.6,6:mysql-5.6, 7:percona-5.6 - - **DataFileSize** (float) - DB实例数据文件大小,单位GB - - **DiskSpace** (int) - 磁盘空间(GB), 默认根据配置机型 - - **DiskUsedSize** (float) - DB实例磁盘已使用空间,单位GB - - **ExpiredTime** (int) - DB实例过期时间,采用UTC计时时间戳 - - **InstanceMode** (str) - UDB实例模式类型, 可选值如下: "Normal": 普通版UDB实例;"HA": 高可用版UDB实例 - - **InstanceType** (str) - UDB数据库机型 - - **InstanceTypeId** (int) - UDB数据库机型ID - - **LogFileSize** (float) - DB实例日志文件大小,单位GB - - **MemoryLimit** (int) - 内存限制(MB),默认根据配置机型 - - **ModifyTime** (int) - DB实例修改时间,采用UTC计时时间戳 - - **Name** (str) - 实例名称,至少6位 - - **ParamGroupId** (int) - DB实例使用的配置参数组id - - **Port** (int) - 端口号,mysql默认3306,mongodb默认27017 - - **Role** (str) - DB实例角色,mysql区分master/slave,mongodb多种角色 - - **SSDType** (str) - SSD类型,SATA/PCI-E - - **SrcDBId** (str) - 对mysql的slave而言是master的DBId,对master则为空, 对mongodb则是副本集id - - **State** (str) - DB状态标记 Init:初始化中,Fail:安装失败,Starting:启动中,Running:运行,Shutdown:关闭中,Shutoff:已关闭,Delete:已删除,Upgrading:升级中,Promoting:提升为独库进行中,Recovering:恢复中,Recover fail:恢复失败 - - **SubnetId** (str) - 子网ID - - **SystemFileSize** (float) - DB实例系统文件大小,单位GB - - **Tag** (str) - 获取资源其他信息 - - **UseSSD** (bool) - 是否使用SSD - - **VPCId** (str) - VPC的ID - - **VirtualIP** (str) - DB实例虚ip - - **VirtualIPMac** (str) - DB实例虚ip的mac地址 - - **Zone** (str) - 可用区 - - **UDBInstanceSet** - - - **AdminUser** (str) - 管理员帐户名,默认root - - **BackupBeginTime** (int) - 备份策略,不可修改,开始时间,单位小时计,默认3点 - - **BackupBlacklist** (str) - 备份策略,备份黑名单,mongodb则不适用 - - **BackupCount** (int) - 备份策略,不可修改,备份文件保留的数量,默认7次 - - **BackupDate** (str) - 备份日期标记位。共7位,每一位为一周中一天的备份情况 0表示关闭当天备份,1表示打开当天备份。最右边的一位 为星期天的备份开关,其余从右到左依次为星期一到星期 六的备份配置开关,每周必须至少设置两天备份。 例如:1100000 表示打开星期六和星期五的自动备份功能 - - **BackupDuration** (int) - 备份策略,一天内备份时间间隔,单位小时,默认24小时 - - **BackupZone** (str) - 跨可用区高可用备库所在可用区 - - **ChargeType** (str) - Year, Month, Dynamic,Trial,默认: Dynamic - - **CluserRole** (str) - 当DB类型为mongodb时,返回该实例所在集群中的角色,包括:mongos、configsrv_sccc、configsrv_csrs、shardsrv_datanode、shardsrv_arbiter,其中congfigsrv分为sccc和csrs两种模式,shardsrv分为datanode和arbiter两种模式 - - **CreateTime** (int) - DB实例创建时间,采用UTC计时时间戳 - - **DBId** (str) - DB实例id - - **DBTypeId** (str) - DB类型id,mysql/mongodb按版本细分各有一个id 目前id的取值范围为[1,7],数值对应的版本如下: 1:mysql-5.5,2:mysql-5.1,3:percona-5.5 4:mongodb-2.4,5:mongodb-2.6,6:mysql-5.6, 7:percona-5.6 - - **DataFileSize** (float) - DB实例数据文件大小,单位GB - - **DataSet** (list) - 见 **UDBSlaveInstanceSet** 模型定义 - - **DiskSpace** (int) - 磁盘空间(GB), 默认根据配置机型 - - **DiskUsedSize** (float) - DB实例磁盘已使用空间,单位GB - - **ExpiredTime** (int) - DB实例过期时间,采用UTC计时时间戳 - - **InstanceMode** (str) - UDB实例模式类型, 可选值如下: “Normal”: 普通版UDB实例 “HA”: 高可用版UDB实例 - - **InstanceType** (str) - UDB数据库机型 - - **InstanceTypeId** (int) - UDB数据库机型ID - - **LogFileSize** (float) - DB实例日志文件大小,单位GB - - **MemoryLimit** (int) - 内存限制(MB),默认根据配置机型 - - **ModifyTime** (int) - DB实例修改时间,采用UTC计时时间戳 - - **Name** (str) - 实例名称,至少6位 - - **ParamGroupId** (int) - DB实例使用的配置参数组id - - **Port** (int) - 端口号,mysql默认3306,mongodb默认27017 - - **Role** (str) - DB实例角色,mysql区分master/slave,mongodb多种角色 - - **SSDType** (str) - SSD类型,SATA/PCI-E - - **SrcDBId** (str) - 对mysql的slave而言是master的DBId,对master则为空, 对mongodb则是副本集id - - **State** (str) - DB状态标记 Init:初始化中,Fail:安装失败,Starting:启动中,Running:运行,Shutdown:关闭中,Shutoff:已关闭,Delete:已删除,Upgrading:升级中,Promoting:提升为独库进行中,Recovering:恢复中,Recover fail:恢复失败 - - **SubnetId** (str) - 子网ID - - **SystemFileSize** (float) - DB实例系统文件大小,单位GB - - **Tag** (str) - 获取资源其他信息 - - **UseSSD** (bool) - 是否使用SSD - - **VPCId** (str) - VPC的ID - - **VirtualIP** (str) - DB实例虚ip - - **VirtualIPMac** (str) - DB实例虚ip的mac地址 - - **Zone** (str) - DB实例所在可用区 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeUDBInstanceRequestSchema().dumps(d) - resp = self.invoke("DescribeUDBInstance", d, **kwargs) - return apis.DescribeUDBInstanceResponseSchema().loads(resp) - - def describe_udb_instance_backup_state(self, req=None, **kwargs): - """ DescribeUDBInstanceBackupState - 获取UDB实例备份状态 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **BackupId** (int) - (Required) 备份记录ID - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **BackupZone** (str) - 跨可用区高可用备库所在可用区,参见[可用区列表] - - **Response** - - - **BackupEndTime** (int) - - - **BackupSize** (int) - - - **State** (str) - 备份状态 0 Backuping // 备份中 1 Success // 备份成功 2 Failed // 备份失败 3 Expired // 备份过期 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeUDBInstanceBackupStateRequestSchema().dumps(d) - resp = self.invoke("DescribeUDBInstanceBackupState", d, **kwargs) - return apis.DescribeUDBInstanceBackupStateResponseSchema().loads(resp) - - def describe_udb_instance_backup_url(self, req=None, **kwargs): - """ DescribeUDBInstanceBackupURL - 获取UDB备份下载地址 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **BackupId** (int) - (Required) DB实例备份ID,该值可以通过DescribeUDBBackup获取 - - **DBId** (str) - (Required) DB实例Id,该值可通过DescribeUDBInstance获取 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **BackupPath** (str) - DB实例备份文件公网的地址 - - **InnerBackupPath** (str) - DB实例备份文件内网的地址 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeUDBInstanceBackupURLRequestSchema().dumps(d) - resp = self.invoke("DescribeUDBInstanceBackupURL", d, **kwargs) - return apis.DescribeUDBInstanceBackupURLResponseSchema().loads(resp) - - def describe_udb_instance_binlog(self, req=None, **kwargs): - """ DescribeUDBInstanceBinlog - 获取UDB指定时间段的binlog列表 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **BeginTime** (int) - (Required) 过滤条件:起始时间(时间戳) - - **DBId** (str) - (Required) DB实例Id - - **EndTime** (int) - (Required) 过滤条件:结束时间(时间戳) - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **DataSet** (list) - 见 **UDBInstanceBinlogSet** 模型定义 - - **Response Model** - - **UDBInstanceBinlogSet** - - - **BeginTime** (int) - Binlog文件生成时间(时间戳) - - **EndTime** (int) - Binlog文件结束时间(时间戳) - - **Name** (str) - Binlog文件名 - - **Size** (int) - Binlog文件大小 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeUDBInstanceBinlogRequestSchema().dumps(d) - resp = self.invoke("DescribeUDBInstanceBinlog", d, **kwargs) - return apis.DescribeUDBInstanceBinlogResponseSchema().loads(resp) - - def describe_udb_instance_binlog_backup_state(self, req=None, **kwargs): - """ DescribeUDBInstanceBinlogBackupState - 获取udb实例备份状态 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **BackupId** (int) - (Required) 备份记录ID - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **BackupZone** (str) - 跨可用区高可用备库所在可用区 - - **Response** - - - **BackupSize** (int) - 备份文件大小(字节) - - **State** (str) - 备份状态 0 Backuping // 备份中 1 Success // 备份成功 2 Failed // 备份失败 3 Expired // 备份过期 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeUDBInstanceBinlogBackupStateRequestSchema().dumps(d) - resp = self.invoke("DescribeUDBInstanceBinlogBackupState", d, **kwargs) - return apis.DescribeUDBInstanceBinlogBackupStateResponseSchema().loads(resp) - - def describe_udb_instance_price(self, req=None, **kwargs): - """ DescribeUDBInstancePrice - 获取UDB实例价格信息 - - **Request** - - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **DBTypeId** (str) - (Required) UDB实例的DB版本字符串 - - **DiskSpace** (int) - (Required) 磁盘空间(GB),暂时支持20(GB) - 3000(GB), 输入不带单位 - - **MemoryLimit** (int) - (Required) 内存限制(MB),单位为MB.目前支持:1000-96000 - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **ChargeType** (str) - Year,按年付费; Month,按月付费 Dynamic,按需付费(需开启权限) Trial,试用(需开启权限)默认为月付 - - **Count** (int) - 购买DB实例数量,最大数量为10台, 默认为1台 - - **InstanceMode** (str) - 实例的部署类型。可选值为:Normal: 普通单点实例,Slave: 从库实例,HA: 高可用部署实例,默认是Normal - - **Quantity** (int) - DB购买多少个"计费时间单位",默认值为1。比如:买2个月,Quantity就是2。如果计费单位是“按月”,并且Quantity为0,表示“购买到月底” - - **SSDType** (str) - SSD类型,可选值为"SATA"、"PCI-E",如果UseSSD为true ,则必填 - - **UseSSD** (bool) - 是否使用SSD,默认为false - - **Response** - - - **DataSet** (list) - 见 **UDBInstancePriceSet** 模型定义 - - **Response Model** - - **UDBInstancePriceSet** - - - **ChargeType** (str) - Year, Month, Dynamic,Trial - - **Price** (float) - 价格,单位为分,保留小数点后两位 - - """ - d = {"Region": self.config.region} - req and d.update(req) - d = apis.DescribeUDBInstancePriceRequestSchema().dumps(d) - resp = self.invoke("DescribeUDBInstancePrice", d, **kwargs) - return apis.DescribeUDBInstancePriceResponseSchema().loads(resp) - - def describe_udb_instance_state(self, req=None, **kwargs): - """ DescribeUDBInstanceState - 获取UDB实例状态 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **DBId** (str) - (Required) 实例的Id,该值可以通过DescribeUDBInstance获取 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **State** (str) - DB状态标记 Init:初始化中;Fail:安装失败; Starting:启动中; Running : 运行 ;Shutdown:关闭中; Shutoff :已关闭; Delete:已删除; Upgrading:升级中; Promoting: 提升为独库进行中; Recovering: 恢复中; Recover fail:恢复失败。 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeUDBInstanceStateRequestSchema().dumps(d) - resp = self.invoke("DescribeUDBInstanceState", d, **kwargs) - return apis.DescribeUDBInstanceStateResponseSchema().loads(resp) - - def describe_udb_instance_upgrade_price(self, req=None, **kwargs): - """ DescribeUDBInstanceUpgradePrice - 获取UDB实例升降级价格信息 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **DBId** (str) - (Required) 实例的Id - - **DiskSpace** (int) - (Required) 磁盘空间(GB), 暂时支持20G - 500G - - **MemoryLimit** (int) - (Required) 内存限制(MB) - - **SSDType** (str) - SSD类型,可选值为"SATA"、"PCI-E",如果UseSSD为true ,则必选 - - **UseSSD** (bool) - 是否使用SSD,默认为false - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **Price** (float) - 价格,单位分 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeUDBInstanceUpgradePriceRequestSchema().dumps(d) - resp = self.invoke("DescribeUDBInstanceUpgradePrice", d, **kwargs) - return apis.DescribeUDBInstanceUpgradePriceResponseSchema().loads(resp) - - def describe_udb_log_backup_url(self, req=None, **kwargs): - """ DescribeUDBLogBackupURL - 获取UDB的slowlog备份地址 - - **Request** - - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **BackupId** (int) - (Required) DB实例备份ID - - **DBId** (str) - (Required) DB实例Id - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **BackupPath** (str) - 备份外网URL - - **UsernetPath** (str) - 备份用户网URL - - """ - d = {"Region": self.config.region} - req and d.update(req) - d = apis.DescribeUDBLogBackupURLRequestSchema().dumps(d) - resp = self.invoke("DescribeUDBLogBackupURL", d, **kwargs) - return apis.DescribeUDBLogBackupURLResponseSchema().loads(resp) - - def describe_udb_log_package(self, req=None, **kwargs): - """ DescribeUDBLogPackage - 列表UDB实例binlog或slowlog或errorlog备份信息 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Limit** (int) - (Required) 分页显示的条目数,列表操作则指定 - - **Offset** (int) - (Required) 分页显示的起始偏移,列表操作则指定 - - **BeginTime** (int) - 过滤条件:起始时间(时间戳) - - **DBId** (str) - DB实例Id,如果指定,则只获取该db的备份信息 - - **EndTime** (int) - 过滤条件:结束时间(时间戳) - - **Type** (int) - 需要列出的备份文件类型,每种文件的值如下 2 : BINLOG\\_BACKUP 3 : SLOW\\_QUERY\\_BACKUP 4 : ERRORLOG\\_BACKUP - - **Types** (list) - Types作为Type的补充,支持多值传入,可以获取多个类型的日志记录,如:Types.0=2&Types.1=3 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **DataSet** (list) - 见 **LogPackageDataSet** 模型定义 - - **TotalCount** (int) - 备份总数,如果指定dbid,则是该db备份总数 - - **Response Model** - - **LogPackageDataSet** - - - **BackupId** (int) - 备份id - - **BackupName** (str) - 备份名称 - - **BackupSize** (int) - 备份文件大小 - - **BackupTime** (int) - 备份时间 - - **BackupType** (int) - 备份类型,包括2-binlog备份,3-slowlog备份 - - **BackupZone** (str) - 跨可用区高可用备库所在可用区 - - **DBId** (str) - dbid - - **DBName** (str) - 对应的db名称 - - **State** (str) - 备份状态 Backuping // 备份中 Success // 备份成功 Failed // 备份失败 Expired // 备份过期 - - **Zone** (str) - 所在可用区 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeUDBLogPackageRequestSchema().dumps(d) - resp = self.invoke("DescribeUDBLogPackage", d, **kwargs) - return apis.DescribeUDBLogPackageResponseSchema().loads(resp) - - def describe_udb_param_group(self, req=None, **kwargs): - """ DescribeUDBParamGroup - 获取参数组详细参数信息 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Limit** (int) - (Required) 分页显示的条目数,列表操作则指定 - - **Offset** (int) - (Required) 分页显示的起始偏移,列表操作则指定 - - **ClassType** (str) - 如果未指定GroupId,则可选是否选取特定DB类型的配置(sql, nosql, postgresql, sqlserver) - - **GroupId** (int) - 参数组id,如果指定则获取描述,否则是列表操作,需要 指定Offset/Limit - - **IsInUDBC** (bool) - 是否选取专区中配置 - - **RegionFlag** (bool) - 当请求没有填写Zone时,如果指定为true,表示只拉取跨可用区的相关配置文件,否则,拉取所有机房的配置文件(包括每个单可用区和跨可用区) - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **DataSet** (list) - 见 **UDBParamGroupSet** 模型定义 - - **TotalCount** (int) - 参数组总数,列表操作时才会有该参数 - - **Response Model** - - **UDBParamMemberSet** - - - **AllowedVal** (str) - 允许的值(根据参数类型,用分隔符表示) - - **ApplyType** (int) - 参数值应用类型,取值范围为{0,10,20},各值代表 意义为0-unknown、10-static、20-dynamic - - **FormatType** (int) - 允许值的格式类型,取值范围为{0,10,20},意义分 别为PVFT_UNKOWN=0,PVFT_RANGE=10, PVFT_ENUM=20 - - **Key** (str) - 参数名称 - - **Modifiable** (bool) - 是否可更改,默认为false - - **Value** (str) - 参数值 - - **ValueType** (int) - 参数值应用类型,取值范围为{0,10,20,30},各值 代表意义为 0-unknown、10-int、20-string、 30-bool - - **UDBParamGroupSet** - - - **DBTypeId** (str) - DB类型id,mysql/mongodb按版本细分各有一个id 目前id的取值范围为[1,7],数值对应的版本如下 1:mysql-5.5,2:mysql-5.1,3:percona-5.5 4:mongodb-2.4,5:mongodb-2.6,6:mysql-5.6 7:percona-5.6 - - **Description** (str) - 参数组描述 - - **GroupId** (int) - 参数组id - - **GroupName** (str) - 参数组名称 - - **Modifiable** (bool) - 参数组是否可修改 - - **ParamMember** (list) - 见 **UDBParamMemberSet** 模型定义 - - **RegionFlag** (bool) - - - **Zone** (str) - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeUDBParamGroupRequestSchema().dumps(d) - resp = self.invoke("DescribeUDBParamGroup", d, **kwargs) - return apis.DescribeUDBParamGroupResponseSchema().loads(resp) - - def describe_udb_type(self, req=None, **kwargs): - """ DescribeUDBType - 获取UDB支持的类型信息 - - **Request** - - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **DBClusterType** (str) - DB实例类型,如mysql,sqlserver,mongo,postgresql - - **DiskType** (str) - 返回支持某种磁盘类型的DB类型。如果没传,则表示任何磁盘类型均可。 - - **InstanceMode** (str) - 返回支持某种实例类型的DB类型。如果没传,则表示任何实例类型均可。normal:单点,ha:高可用,sharded_cluster:分片集群 - - **Response** - - - **DataSet** (list) - 见 **UDBTypeSet** 模型定义 - - **Response Model** - - **UDBTypeSet** - - - **DBTypeId** (str) - DB类型id,mysql/mongodb按版本细分各有一个id, 目前id的取值范围为[1,7],数值对应的版本如下: 1:mysql-5.5,2:mysql-5.1,3:percona-5.5 4:mongodb-2.4,5:mongodb-2.6,6:mysql-5.6, 7:percona-5.6 - - """ - d = {"Region": self.config.region} - req and d.update(req) - d = apis.DescribeUDBTypeRequestSchema().dumps(d) - resp = self.invoke("DescribeUDBType", d, **kwargs) - return apis.DescribeUDBTypeResponseSchema().loads(resp) - - def edit_udb_backup_blacklist(self, req=None, **kwargs): - """ EditUDBBackupBlacklist - 编辑UDB实例的备份黑名单 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Blacklist** (str) - (Required) 黑名单,规范示例,指定库mysql.%;test.%; 指定表city.address; - - **DBId** (str) - (Required) DB实例Id,该值可以通过DescribeUDBInstance获取 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.EditUDBBackupBlacklistRequestSchema().dumps(d) - resp = self.invoke("EditUDBBackupBlacklist", d, **kwargs) - return apis.EditUDBBackupBlacklistResponseSchema().loads(resp) - - def fetch_udb_instance_earliest_recover_time(self, req=None, **kwargs): - """ FetchUDBInstanceEarliestRecoverTime - 获取UDB最早可回档的时间点 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **DBId** (str) - (Required) DB实例Id - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **EarliestTime** (int) - 获取最早可回档时间点 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.FetchUDBInstanceEarliestRecoverTimeRequestSchema().dumps(d) - resp = self.invoke("FetchUDBInstanceEarliestRecoverTime", d, **kwargs) - return apis.FetchUDBInstanceEarliestRecoverTimeResponseSchema().loads(resp) - - def modify_udb_instance_name(self, req=None, **kwargs): - """ ModifyUDBInstanceName - 重命名UDB实例 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **DBId** (str) - (Required) 实例的Id,该值可以通过DescribeUDBInstance获取 - - **Name** (str) - (Required) 实例的新名字, 长度要求为6~63位 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.ModifyUDBInstanceNameRequestSchema().dumps(d) - resp = self.invoke("ModifyUDBInstanceName", d, **kwargs) - return apis.ModifyUDBInstanceNameResponseSchema().loads(resp) - - def modify_udb_instance_password(self, req=None, **kwargs): - """ ModifyUDBInstancePassword - 修改DB实例的管理员密码 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **DBId** (str) - (Required) 实例的ID,该值可以通过DescribeUDBInstance获取 - - **Password** (str) - (Required) 实例的新密码 - - **AccountName** (str) - sqlserver帐号,仅在sqlserver的情况下填该参数 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.ModifyUDBInstancePasswordRequestSchema().dumps(d) - resp = self.invoke("ModifyUDBInstancePassword", d, **kwargs) - return apis.ModifyUDBInstancePasswordResponseSchema().loads(resp) - - def promote_udb_instance_to_ha(self, req=None, **kwargs): - """ PromoteUDBInstanceToHA - 普通db升级为高可用(只针对mysql5.5及以上版本) - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **DBId** (str) - (Required) 实例的Id,该值可以通过DescribeUDBInstance获取 - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.PromoteUDBInstanceToHARequestSchema().dumps(d) - resp = self.invoke("PromoteUDBInstanceToHA", d, **kwargs) - return apis.PromoteUDBInstanceToHAResponseSchema().loads(resp) - - def promote_udb_slave(self, req=None, **kwargs): - """ PromoteUDBSlave - 从库提升为独立库 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **DBId** (str) - (Required) 实例的Id,该值可以通过DescribeUDBInstance获取 - - **IsForce** (bool) - 是否强制(如果从库落后可能会禁止提升),默认false 如果落后情况下,强制提升丢失数据 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.PromoteUDBSlaveRequestSchema().dumps(d) - resp = self.invoke("PromoteUDBSlave", d, **kwargs) - return apis.PromoteUDBSlaveResponseSchema().loads(resp) - - def resize_udb_instance(self, req=None, **kwargs): - """ ResizeUDBInstance - 修改(升级和降级)UDB实例的配置,包括内存和磁盘的配置,对于内存升级无需关闭实例,其他场景需要事先关闭实例。两套参数可以配置升降机:1.配置UseSSD和SSDType 2.配置InstanceType,不需要配置InstanceMode。这两套第二套参数的优先级更高 - - **Request** - - - **ProjectId** (int) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **DBId** (str) - (Required) 实例的Id - - **DiskSpace** (int) - (Required) 磁盘空间(GB), 暂时支持20G-3000G - - **MemoryLimit** (int) - (Required) 内存限制(MB),目前支持以下几档 1000M/2000M/4000M/ 6000M/8000M/ 12000M/16000M/ 24000M/32000M/ 48000M/64000M/96000M。 - - **CouponId** (str) - 使用的代金券id - - **InstanceMode** (str) - UDB实例模式类型, 可选值如下: "Normal": 普通版UDB实例 "HA": 高可用版UDB实例 默认是"Normal" - - **InstanceType** (str) - UDB数据库机型: "Normal": "标准机型" , "SATA_SSD": "SSD机型" , "PCIE_SSD": "SSD高性能机型" , "Normal_Volume": "标准大容量机型", "SATA_SSD_Volume": "SSD大容量机型" , "PCIE_SSD_Volume": "SSD高性能大容量机型" - - **SSDType** (str) - SSD类型,可选值为"SATA"、"PCI-E",如果UseSSD为true ,则必选 - - **StartAfterUpgrade** (bool) - DB关闭状态下升降级,升降级后是否启动DB,默认为false - - **UDBCId** (str) - 专区的ID,如果有值表示专区中的DB配置升降级 - - **UseSSD** (bool) - 是否使用SSD,默认为false - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.ResizeUDBInstanceRequestSchema().dumps(d) - resp = self.invoke("ResizeUDBInstance", d, **kwargs) - return apis.ResizeUDBInstanceResponseSchema().loads(resp) - - def restart_udb_instance(self, req=None, **kwargs): - """ RestartUDBInstance - 重启UDB实例 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **DBId** (str) - (Required) 实例的Id,该值可以通过DescribeUDBInstance获取 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.RestartUDBInstanceRequestSchema().dumps(d) - resp = self.invoke("RestartUDBInstance", d, **kwargs) - return apis.RestartUDBInstanceResponseSchema().loads(resp) - - def start_udb_instance(self, req=None, **kwargs): - """ StartUDBInstance - 启动UDB实例 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **DBId** (str) - (Required) 实例的Id,该值可以通过DescribeUDBInstance获取 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.StartUDBInstanceRequestSchema().dumps(d) - resp = self.invoke("StartUDBInstance", d, **kwargs) - return apis.StartUDBInstanceResponseSchema().loads(resp) - - def stop_udb_instance(self, req=None, **kwargs): - """ StopUDBInstance - 关闭UDB实例 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **DBId** (str) - (Required) 实例的Id,该值可以通过DescribeUDBInstance获取 - - **ForceToKill** (bool) - 是否使用强制手段关闭DB,默认是false - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.StopUDBInstanceRequestSchema().dumps(d) - resp = self.invoke("StopUDBInstance", d, **kwargs) - return apis.StopUDBInstanceResponseSchema().loads(resp) - - def switch_udb_instance_to_ha(self, req=None, **kwargs): - """ SwitchUDBInstanceToHA - 普通UDB切换为高可用,原db状态为WaitForSwitch时,调用该api - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **DBId** (str) - (Required) 实例的Id,该值可以通过DescribeUDBInstance获取 - - **ChargeType** (str) - Year, Month, Dynamic,Trial,不填则按现在单点计费执行 - - **Quantity** (str) - 购买时长,需要和 ChargeType 搭配使用,否则使用单点计费策略的值 - - **Tag** (str) - 业务组 - - **Response** - - - **DBId** (str) - 切换后高可用db实例的Id - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.SwitchUDBInstanceToHARequestSchema().dumps(d) - resp = self.invoke("SwitchUDBInstanceToHA", d, **kwargs) - return apis.SwitchUDBInstanceToHAResponseSchema().loads(resp) - - def update_udb_instance_backup_strategy(self, req=None, **kwargs): - """ UpdateUDBInstanceBackupStrategy - 修改UDB自动备份策略 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **DBId** (str) - (Required) 主节点的Id - - **BackupDate** (str) - 备份时期标记位。共7位,每一位为一周中一天的备份情况,0表示关闭当天备份,1表示打开当天备份。最右边的一位为星期天的备份开关,其余从右到左依次为星期一到星期六的备份配置开关,每周必须至少设置两天备份。例如:1100000表示打开星期六和星期五的备份功能 - - **BackupMethod** (str) - 选择默认的备份方式,可选 snapshot 表示使用快照/物理备份,填 logic 表示使用逻辑备份。需要同时设置BackupDate字段。(注意现在只有SSD 版本的 MySQL实例支持物理备份) - - **BackupTime** (int) - 备份的整点时间,范围[0,23] - - **ForceDump** (bool) - 当导出某些数据遇到问题后,是否强制导出其他剩余数据默认是false需要同时设置BackupDate字段 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.UpdateUDBInstanceBackupStrategyRequestSchema().dumps(d) - resp = self.invoke("UpdateUDBInstanceBackupStrategy", d, **kwargs) - return apis.UpdateUDBInstanceBackupStrategyResponseSchema().loads(resp) - - def update_udb_instance_slave_backup_switch(self, req=None, **kwargs): - """ UpdateUDBInstanceSlaveBackupSwitch - 开启或者关闭UDB从库备份 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **BackupSwitch** (int) - (Required) 从库的备份开关,范围[0,1],0表示从库备份功能关闭,1 表示从库备份开关打开。 - - **MasterDBId** (str) - (Required) 主库的Id - - **SlaveDBId** (str) - 从库的Id,如果从库备份开关设定为打开,则必须赋值。 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.UpdateUDBInstanceSlaveBackupSwitchRequestSchema().dumps(d) - resp = self.invoke("UpdateUDBInstanceSlaveBackupSwitch", d, **kwargs) - return apis.UpdateUDBInstanceSlaveBackupSwitchResponseSchema().loads(resp) - - def update_udb_param_group(self, req=None, **kwargs): - """ UpdateUDBParamGroup - 更新UDB配置参数项 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **GroupId** (int) - (Required) 配置参数组id,使用DescribeUDBParamGroup获得 - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **Description** (str) - 参数组的描述 - - **Key** (str) - 参数名称(与Value配合使用) - - **Name** (str) - 参数组的名字 - - **RegionFlag** (bool) - 该配置文件是否是地域级别配置文件,默认是false - - **Value** (str) - 参数值(与Key配合使用) - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.UpdateUDBParamGroupRequestSchema().dumps(d) - resp = self.invoke("UpdateUDBParamGroup", d, **kwargs) - return apis.UpdateUDBParamGroupResponseSchema().loads(resp) - - def upload_udb_param_group(self, req=None, **kwargs): - """ UploadUDBParamGroup - 导入UDB配置 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Content** (str) - (Required) 配置内容,导入的配置内容采用base64编码 - - **DBTypeId** (str) - (Required) DB类型id,DB类型id,mysql/mongodb/postgesql按版本细分 1:mysql-5.1,2:mysql-5.5,3:percona-5.5,4:mysql-5.6,5:percona-5.6,6:mysql-5.7,7:percona-5.7,8:mariadb-10.0,9:mongodb-2.4,10:mongodb-2.6,11:mongodb-3.0,12:mongodb-3.2,13:postgresql-9.4,14:postgresql-9.6 - - **Description** (str) - (Required) 参数组描述 - - **GroupName** (str) - (Required) 配置参数组名称 - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **ParamGroupTypeId** (int) - 配置文件子类型 0-未知, 1-Shardsvr-MMAPv1, 2-Shardsvr-WiredTiger, 3-Configsvr-MMAPv1, 4-Configsvr-WiredTiger, 5-Mongos - - **RegionFlag** (bool) - 该配置文件是否是地域级别配置文件,默认是false - - **Response** - - - **GroupId** (int) - 配置参数组id - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.UploadUDBParamGroupRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("UploadUDBParamGroup", d, **kwargs) - return apis.UploadUDBParamGroupResponseSchema().loads(resp) +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.client import Client +from ucloud.services.udb.schemas import apis + + +class UDBClient(Client): + def __init__(self, config, transport=None, middleware=None, logger=None): + super(UDBClient, self).__init__(config, transport, middleware, logger) + + def backup_udb_instance(self, req=None, **kwargs): + """ BackupUDBInstance - 备份UDB实例 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **BackupName** (str) - (Required) 备份名称 + - **DBId** (str) - (Required) DB实例Id,该值可以通过DescribeUDBInstance获取 + - **BackupMethod** (str) - 使用的备份方式。(快照备份即物理备份。注意只有SSD版本的mysql实例支持设置为snapshot) + - **Blacklist** (str) - 备份黑名单列表,以 ; 分隔。注意:只有逻辑备份下备份黑名单才生效,快照备份备份黑名单下无效 + - **ForceBackup** (bool) - true表示逻辑备份时是使用 --force 参数,false表示不使用 --force 参数。物理备份此参数无效。 + - **UseBlacklist** (bool) - 是否使用黑名单备份,默认false + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.BackupUDBInstanceRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("BackupUDBInstance", d, **kwargs) + return apis.BackupUDBInstanceResponseSchema().loads(resp) + + def backup_udb_instance_binlog(self, req=None, **kwargs): + """ BackupUDBInstanceBinlog - 备份UDB指定时间段的binlog列表 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **BackupFile** (str) - (Required) 需要备份文件,可通过DescribeUDBInstanceBinlog获得 如果要传入多个文件名,以空格键分割,用单引号包含. + - **DBId** (str) - (Required) DB实例Id,该值可以通过DescribeUDBInstance获取 + - **BackupName** (str) - DB备份文件名称 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.BackupUDBInstanceBinlogRequestSchema().dumps(d) + resp = self.invoke("BackupUDBInstanceBinlog", d, **kwargs) + return apis.BackupUDBInstanceBinlogResponseSchema().loads(resp) + + def backup_udb_instance_error_log(self, req=None, **kwargs): + """ BackupUDBInstanceErrorLog - 备份UDB指定时间段的errorlog + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **BackupName** (str) - (Required) 备份名称 + - **DBId** (str) - (Required) DB实例Id,该值可以通过DescribeUDBInstance获取 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.BackupUDBInstanceErrorLogRequestSchema().dumps(d) + resp = self.invoke("BackupUDBInstanceErrorLog", d, **kwargs) + return apis.BackupUDBInstanceErrorLogResponseSchema().loads(resp) + + def backup_udb_instance_slow_log(self, req=None, **kwargs): + """ BackupUDBInstanceSlowLog - 备份UDB指定时间段的slowlog分析结果 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **BackupName** (str) - (Required) 备份文件名称 + - **BeginTime** (int) - (Required) 过滤条件:起始时间(时间戳) + - **DBId** (str) - (Required) DB实例Id,该值可以通过DescribeUDBInstance获取 + - **EndTime** (int) - (Required) 过滤条件:结束时间(时间戳) + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.BackupUDBInstanceSlowLogRequestSchema().dumps(d) + resp = self.invoke("BackupUDBInstanceSlowLog", d, **kwargs) + return apis.BackupUDBInstanceSlowLogResponseSchema().loads(resp) + + def check_recover_udb_instance(self, req=None, **kwargs): + """ CheckRecoverUDBInstance - 核查db是否可以使用回档功能 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **SrcDBId** (str) - (Required) 源实例的Id(只支持普通版DB不支持高可用) + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **LastestTime** (int) - 核查成功返回值为可以回档到的最近时刻,核查失败不返回 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.CheckRecoverUDBInstanceRequestSchema().dumps(d) + resp = self.invoke("CheckRecoverUDBInstance", d, **kwargs) + return apis.CheckRecoverUDBInstanceResponseSchema().loads(resp) + + def check_udb_instance_to_ha_allowance(self, req=None, **kwargs): + """ CheckUDBInstanceToHAAllowance - 核查db是否可以升级为高可用 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **DBId** (str) - (Required) 实例的Id,该值可以通过DescribeUDBInstance获取 + + **Response** + + - **Allowance** (str) - Yes ,No ,Yes即可以升级,No为不可以升级 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.CheckUDBInstanceToHAAllowanceRequestSchema().dumps(d) + resp = self.invoke("CheckUDBInstanceToHAAllowance", d, **kwargs) + return apis.CheckUDBInstanceToHAAllowanceResponseSchema().loads(resp) + + def clear_udb_log(self, req=None, **kwargs): + """ ClearUDBLog - 清除UDB实例的log + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **DBId** (str) - (Required) DB实例的id,该值可以通过DescribeUDBInstance获取 + - **LogType** (int) - (Required) 日志类型,10-error(暂不支持)、20-slow(暂不支持 )、30-binlog + - **BeforeTime** (int) - 删除时间点(至少前一天)之前log,采用时间戳(秒),默认当 前时间点前一天 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.ClearUDBLogRequestSchema().dumps(d) + resp = self.invoke("ClearUDBLog", d, **kwargs) + return apis.ClearUDBLogResponseSchema().loads(resp) + + def create_udb_instance(self, req=None, **kwargs): + """ CreateUDBInstance - 创建UDB实例(包括创建mysql master节点、mongodb primary/configsvr节点和从备份恢复实例) + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **AdminPassword** (str) - (Required) 管理员密码 + - **DBTypeId** (str) - (Required) DB类型id,mysql/mongodb/postgesql按版本细分 1:mysql-5.1,2:mysql-5.5,3:percona-5.5,4:mysql-5.6,5:percona-5.6,6:mysql-5.7,7:percona-5.7,8:mariadb-10.0,9:mongodb-2.4,10:mongodb-2.6,11:mongodb-3.0,12:mongodb-3.2,13:postgresql-9.4,14:postgresql-9.6,14:postgresql-10.4 + - **DiskSpace** (int) - (Required) 磁盘空间(GB), 暂时支持20G - 3000G + - **MemoryLimit** (int) - (Required) 内存限制(MB),目前支持以下几档 1000M/2000M/4000M/ 6000M/8000M/12000M/16000M/ 24000M/32000M/48000M/ 64000M/96000M + - **Name** (str) - (Required) 实例名称,至少6位 + - **ParamGroupId** (int) - (Required) DB实例使用的配置参数组id + - **Port** (int) - (Required) 端口号,mysql默认3306,mongodb默认27017,postgresql默认5432 + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + - **AdminUser** (str) - 管理员帐户名,默认root + - **BackupCount** (int) - 备份策略,每周备份数量,默认7次 + - **BackupDuration** (int) - 备份策略,备份时间间隔,单位小时计,默认24小时 + - **BackupId** (int) - 备份id,如果指定,则表明从备份恢复实例 + - **BackupTime** (int) - 备份策略,备份开始时间,单位小时计,默认1点 + - **BackupZone** (str) - 跨可用区高可用备库所在可用区,参见 `可用区列表 `_ + - **CPU** (int) - cpu核数 + - **ChargeType** (str) - Year, Month, Dynamic,Trial,默认: Month + - **ClusterRole** (str) - 当DB类型(DBTypeId)为mongodb时,需要指定mongo的角色,可选值为configsrv (配置节点),shardsrv (数据节点) + - **CouponId** (str) - 使用的代金券id + - **DisableSemisync** (bool) - 是否开启异步高可用,默认不填,可置为true + - **HAArch** (str) - 高可用架构:1) haproxy(默认): 当前仅支持mysql。2) sentinel: 基于vip和哨兵节点的架构,当前支持mysql和pg。 + - **InstanceMode** (str) - UDB实例模式类型, 可选值如下: "Normal": 普通版UDB实例 "HA": 高可用版UDB实例 默认是"Normal" + - **InstanceType** (str) - UDB数据库机型 + - **Quantity** (int) - 购买时长,默认值1 + - **SSDType** (str) - SSD类型,可选值为"SATA"、"PCI-E",如果UseSSD为true ,则必选 + - **SubnetId** (str) - 子网ID + - **Tag** (str) - 实例所在的业务组名称 + - **UDBCId** (str) - 专区ID信息(如果这个参数存在这说明是在专区中创建DB) + - **UseSSD** (bool) - 是否使用SSD,默认为false。目前主要可用区、海外机房、新机房只提供SSD资源,非SSD资源不再提供。 + - **VPCId** (str) - VPC的ID + + **Response** + + - **DBId** (str) - BD实例id + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.CreateUDBInstanceRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("CreateUDBInstance", d, **kwargs) + return apis.CreateUDBInstanceResponseSchema().loads(resp) + + def create_udb_instance_by_recovery(self, req=None, **kwargs): + """ CreateUDBInstanceByRecovery - 创建db,将新创建的db恢复到指定db某个指定时间点 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Name** (str) - (Required) 实例名称,至少6位 + - **RecoveryTime** (int) - (Required) 恢复到某个时间点的时间戳(UTC时间格式,默认单位秒) + - **SrcDBId** (str) - (Required) 源实例的Id + - **ChargeType** (str) - Year, Month, Dynamic,Trial,默认: Dynamic + - **CouponId** (str) - 使用的代金券id + - **Quantity** (int) - 购买时长,默认值1 + - **SubnetId** (str) - 子网ID + - **UDBCId** (str) - 专区的Id + - **UseSSD** (bool) - 指定是否是否使用SSD,默认使用主库的配置 + - **VPCId** (str) - VPC的ID + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **DBId** (str) - db实例id + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.CreateUDBInstanceByRecoveryRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("CreateUDBInstanceByRecovery", d, **kwargs) + return apis.CreateUDBInstanceByRecoveryResponseSchema().loads(resp) + + def create_udb_param_group(self, req=None, **kwargs): + """ CreateUDBParamGroup - 从已有配置文件创建新配置文件 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **DBTypeId** (str) - (Required) DB类型id,mysql/mongodb/postgesql按版本细分 1:mysql-5.1,2:mysql-5.5,3:percona-5.5,4:mysql-5.6,5:percona-5.6,6:mysql-5.7,7:percona-5.7,8:mariadb-10.0,9:mongodb-2.4,10:mongodb-2.6,11:mongodb-3.0,12:mongodb-3.2,13:postgresql-9.4,14:postgresql-9.6 + - **Description** (str) - (Required) 参数组描述 + - **GroupName** (str) - (Required) 新配置参数组名称 + - **SrcGroupId** (int) - (Required) 源参数组id + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + - **RegionFlag** (bool) - 是否是地域级别的配置文件,默认是false + + **Response** + + - **GroupId** (int) - 新配置参数组id + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.CreateUDBParamGroupRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("CreateUDBParamGroup", d, **kwargs) + return apis.CreateUDBParamGroupResponseSchema().loads(resp) + + def create_udb_replication_instance(self, req=None, **kwargs): + """ CreateUDBReplicationInstance - 创建MongoDB的副本节点(包括仲裁) + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Name** (str) - (Required) 实例名称,至少6位 + - **SrcId** (str) - (Required) primary节点的DBId,该值可以通过DescribeUDBInstance获取 + - **CouponId** (str) - 使用的代金券id + - **IsArbiter** (bool) - 是否是仲裁节点,默认false,仲裁节点按最小机型创建 + - **Port** (int) - 端口号,默认27017,取值范围3306至65535。 + - **UseSSD** (bool) - 是否使用SSD,默认不使用 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **DBId** (str) - 创建从节点的DBId + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.CreateUDBReplicationInstanceRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("CreateUDBReplicationInstance", d, **kwargs) + return apis.CreateUDBReplicationInstanceResponseSchema().loads(resp) + + def create_udb_route_instance(self, req=None, **kwargs): + """ CreateUDBRouteInstance - 创建mongos实例 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **ConfigsvrId** (list) - (Required) 配置服务器的dbid,允许一个或者三个。 + - **DBTypeId** (str) - (Required) DB类型id,mongodb按版本细分有1:mongodb-2.4,2:mongodb-2.6,3:mongodb-3.0,4:mongodb-3.2 + - **DiskSpace** (int) - (Required) 磁盘空间(GB), 暂时支持20G - 500G + - **MemoryLimit** (int) - (Required) 内存限制(MB),目前支持以下几档 600M/1500M/3000M /6000M/15000M/30000M + - **Name** (str) - (Required) 实例名称,至少6位 + - **ParamGroupId** (int) - (Required) DB实例使用的配置参数组id + - **Port** (int) - (Required) 端口号,mongodb默认27017 + - **ChargeType** (str) - Year, Month, Dynamic,Trial,默认: Month + - **CouponId** (str) - 使用的代金券id + - **Quantity** (int) - 购买时长,默认值1 + - **UseSSD** (bool) - 是否使用SSD,默认为false + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **DBId** (str) - db实例id + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.CreateUDBRouteInstanceRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("CreateUDBRouteInstance", d, **kwargs) + return apis.CreateUDBRouteInstanceResponseSchema().loads(resp) + + def create_udb_slave(self, req=None, **kwargs): + """ CreateUDBSlave - 创建UDB实例的slave + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Name** (str) - (Required) 实例名称,至少6位 + - **SrcId** (str) - (Required) master实例的DBId,该值可以通过DescribeUDBInstance获取 + - **CouponId** (str) - 使用的代金券id + - **DiskSpace** (int) - 磁盘空间(GB), 暂时支持20G - 3000G(API支持,前端暂时只开放内存定制) + - **InstanceMode** (str) - UDB实例部署模式,可选值如下:Normal: 普通单点实例HA: 高可用部署实例 + - **InstanceType** (str) - UDB实例类型:Normal和SATA_SSD + - **IsLock** (bool) - 是否锁主库,默认为true + - **MemoryLimit** (int) - 内存限制(MB),目前支持以下几档 1000M/2000M/4000M/ 6000M/8000M/12000M/16000M/ 24000M/32000M/48000M/ 64000M/96000M + - **Port** (int) - 端口号,mysql默认3306 + - **SSDType** (str) - SSD类型,可选值为"SATA"、"PCI-E",如果UseSSD为true ,则必选 + - **UseSSD** (bool) - 是否使用SSD,默认为false + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **DBId** (str) - 创建slave的DBId + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.CreateUDBSlaveRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("CreateUDBSlave", d, **kwargs) + return apis.CreateUDBSlaveResponseSchema().loads(resp) + + def delete_udb_backup(self, req=None, **kwargs): + """ DeleteUDBBackup - 删除UDB实例备份 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **BackupId** (int) - (Required) 备份id,可通过DescribeUDBBackup获得 + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + - **BackupZone** (str) - 跨可用区高可用备库所在可用区,参见[可用区列表] + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DeleteUDBBackupRequestSchema().dumps(d) + resp = self.invoke("DeleteUDBBackup", d, **kwargs) + return apis.DeleteUDBBackupResponseSchema().loads(resp) + + def delete_udb_instance(self, req=None, **kwargs): + """ DeleteUDBInstance - 删除UDB实例 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **DBId** (str) - (Required) DB实例的id,该值可以通过DescribeUDBInstance获取 + - **UDBCId** (str) - 专区ID + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DeleteUDBInstanceRequestSchema().dumps(d) + resp = self.invoke("DeleteUDBInstance", d, **kwargs) + return apis.DeleteUDBInstanceResponseSchema().loads(resp) + + def delete_udb_log_package(self, req=None, **kwargs): + """ DeleteUDBLogPackage - 删除UDB日志包 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **BackupId** (int) - (Required) 日志包id,可通过DescribeUDBLogPackage获得 + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + - **BackupZone** (str) - 跨可用区高可用备库所在可用区 + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DeleteUDBLogPackageRequestSchema().dumps(d) + resp = self.invoke("DeleteUDBLogPackage", d, **kwargs) + return apis.DeleteUDBLogPackageResponseSchema().loads(resp) + + def delete_udb_param_group(self, req=None, **kwargs): + """ DeleteUDBParamGroup - 删除配置参数组 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **GroupId** (int) - (Required) 参数组id,可通过DescribeUDBParamGroup获取 + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + - **RegionFlag** (bool) - 是否属于地域级别 + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DeleteUDBParamGroupRequestSchema().dumps(d) + resp = self.invoke("DeleteUDBParamGroup", d, **kwargs) + return apis.DeleteUDBParamGroupResponseSchema().loads(resp) + + def describe_udb_backup(self, req=None, **kwargs): + """ DescribeUDBBackup - 列表UDB实例备份信息.Zone不填表示多可用区,填代表单可用区 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Limit** (int) - (Required) 分页显示的条目数,列表操作则指定 + - **Offset** (int) - (Required) 分页显示的起始偏移,列表操作则指定 + - **BackupId** (int) - 如果填了BackupId, 那么只拉取这个备份的记录 + - **BackupType** (int) - 备份类型,取值为0或1,0表示自动,1表示手动 + - **BeginTime** (int) - 过滤条件:起始时间(Unix时间戳) + - **ClassType** (str) - 如果未指定GroupId,则可选是否选取特定DB类型的配置(sql, nosql, postgresql, sqlserver) + - **DBId** (str) - DB实例Id,如果指定,则只获取该db的备份信息 该值可以通过DescribeUDBInstance获取 + - **EndTime** (int) - 过滤条件:结束时间(Unix时间戳) + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **DataSet** (list) - 见 **UDBBackupSet** 模型定义 + - **TotalCount** (int) - 满足条件备份总数,如果指定dbid,则是该db备份总数 + + **Response Model** + + **UDBBackupSet** + + - **BackupEndTime** (int) - 备份完成时间(Unix时间戳) + - **BackupId** (int) - 备份id + - **BackupName** (str) - 备份名称 + - **BackupSize** (int) - 备份文件大小(字节) + - **BackupTime** (int) - 备份时间(Unix时间戳) + - **BackupType** (int) - 备份类型,取值为0或1,0表示自动,1表示手动 + - **BackupZone** (str) - 跨机房高可用备库所在可用区 + - **DBId** (str) - dbid + - **DBName** (str) - 对应的db名称 + - **ErrorInfo** (str) - 备份错误信息 + - **State** (str) - 备份状态 Backuping // 备份中 Success // 备份成功 Failed // 备份失败 Expired // 备份过期 + - **Zone** (str) - 备份所在可用区 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeUDBBackupRequestSchema().dumps(d) + resp = self.invoke("DescribeUDBBackup", d, **kwargs) + return apis.DescribeUDBBackupResponseSchema().loads(resp) + + def describe_udb_backup_blacklist(self, req=None, **kwargs): + """ DescribeUDBBackupBlacklist - 获取UDB实例的备份黑名单 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **DBId** (str) - (Required) DB实例Id,该值可以通过DescribeUDBInstance获取 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **Blacklist** (str) - DB的黑名单列表, db.%为指定库 dbname.tablename为指定表 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeUDBBackupBlacklistRequestSchema().dumps(d) + resp = self.invoke("DescribeUDBBackupBlacklist", d, **kwargs) + return apis.DescribeUDBBackupBlacklistResponseSchema().loads(resp) + + def describe_udb_binlog_backup_url(self, req=None, **kwargs): + """ DescribeUDBBinlogBackupURL - 获取UDB的Binlog备份地址 + + **Request** + + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **BackupId** (int) - (Required) DB实例binlog备份ID,可以从DescribeUDBLogPackage结果当中获得 + - **DBId** (str) - (Required) DB实例Id + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **BackupPath** (str) - DB实例备份文件的公网地址 + - **InnerBackupPath** (str) - DB实例备份文件的内网地址 + + """ + d = {"Region": self.config.region} + req and d.update(req) + d = apis.DescribeUDBBinlogBackupURLRequestSchema().dumps(d) + resp = self.invoke("DescribeUDBBinlogBackupURL", d, **kwargs) + return apis.DescribeUDBBinlogBackupURLResponseSchema().loads(resp) + + def describe_udb_instance(self, req=None, **kwargs): + """ DescribeUDBInstance - 获取UDB实例信息,支持两类操作:(1)指定DBId用于获取该db的信息;(2)指定ClassType、Offset、Limit用于列表操作,查询某一个类型db。 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **ClassType** (str) - DB种类,如果是列表操作,则需要指定,不区分大小写,其取值如下:mysql: SQL;mongo: NOSQL;postgresql: postgresql + - **DBId** (str) - DB实例id,如果指定则获取单个db实例的描述,否则为列表操作。 指定DBId时无需填写ClassType、Offset、Limit + - **IncludeSlaves** (bool) - 当只获取这个特定DBId的信息时,如果有该选项,那么把这个DBId实例的所有从库信息一起拉取并返回 + - **IsInUDBC** (bool) - 是否查看专区里面DB + - **Limit** (int) - 分页显示数量,列表操作时必填 + - **Offset** (int) - 分页显示起始偏移位置,列表操作时必填 + - **UDBCId** (str) - IsInUDBC为True,UDBCId为空,说明查看整个可用区的专区的db,如果UDBId不为空则只查看此专区下面的db + - **Zone** (str) - 可用区,不填时默认全部可用区。参见 `可用区列表 `_ + + **Response** + + - **DataSet** (list) - 见 **UDBInstanceSet** 模型定义 + - **TotalCount** (int) - 用户db组的数量,对于 mysql: 主从结对数量,没有slave,则只有master mongodb: 副本集数量 + + **Response Model** + + **UDBSlaveInstanceSet** + + - **AdminUser** (str) - 管理员帐户名,默认root + - **BackupBeginTime** (int) - 备份策略,不可修改,开始时间,单位小时计,默认3点 + - **BackupBlacklist** (str) - 备份策略,备份黑名单,mongodb则不适用 + - **BackupCount** (int) - 备份策略,不可修改,备份文件保留的数量,默认7次 + - **BackupDate** (str) - 备份日期标记位。共7位,每一位为一周中一天的备份情况 0表示关闭当天备份,1表示打开当天备份。最右边的一位 为星期天的备份开关,其余从右到左依次为星期一到星期 六的备份配置开关,每周必须至少设置两天备份。 例如:1100000 表示打开星期六和星期五的自动备份功能 + - **BackupDuration** (int) - 备份策略,一天内备份时间间隔,单位小时,默认24小时 + - **ChargeType** (str) - Year, Month, Dynamic,Trial,默认: Dynamic + - **ClusterRole** (str) - 当DB类型为mongodb时,返回该实例所在集群中的角色,包括:mongos、configsrv_sccc、configsrv_csrs、shardsrv_datanode、shardsrv_arbiter,其中congfigsrv分为sccc和csrs两种模式,shardsrv分为datanode和arbiter两种模式 + - **CreateTime** (int) - DB实例创建时间,采用UTC计时时间戳 + - **DBId** (str) - DB实例id + - **DBTypeId** (str) - DB类型id,mysql/mongodb按版本细分各有一个id 目前id的取值范围为[1,7],数值对应的版本如下: 1:mysql-5.5,2:mysql-5.1,3:percona-5.5 4:mongodb-2.4,5:mongodb-2.6,6:mysql-5.6, 7:percona-5.6 + - **DataFileSize** (float) - DB实例数据文件大小,单位GB + - **DiskSpace** (int) - 磁盘空间(GB), 默认根据配置机型 + - **DiskUsedSize** (float) - DB实例磁盘已使用空间,单位GB + - **ExpiredTime** (int) - DB实例过期时间,采用UTC计时时间戳 + - **InstanceMode** (str) - UDB实例模式类型, 可选值如下: "Normal": 普通版UDB实例;"HA": 高可用版UDB实例 + - **InstanceType** (str) - UDB数据库机型 + - **InstanceTypeId** (int) - UDB数据库机型ID + - **LogFileSize** (float) - DB实例日志文件大小,单位GB + - **MemoryLimit** (int) - 内存限制(MB),默认根据配置机型 + - **ModifyTime** (int) - DB实例修改时间,采用UTC计时时间戳 + - **Name** (str) - 实例名称,至少6位 + - **ParamGroupId** (int) - DB实例使用的配置参数组id + - **Port** (int) - 端口号,mysql默认3306,mongodb默认27017 + - **Role** (str) - DB实例角色,mysql区分master/slave,mongodb多种角色 + - **SSDType** (str) - SSD类型,SATA/PCI-E + - **SrcDBId** (str) - 对mysql的slave而言是master的DBId,对master则为空, 对mongodb则是副本集id + - **State** (str) - DB状态标记 Init:初始化中,Fail:安装失败,Starting:启动中,Running:运行,Shutdown:关闭中,Shutoff:已关闭,Delete:已删除,Upgrading:升级中,Promoting:提升为独库进行中,Recovering:恢复中,Recover fail:恢复失败 + - **SubnetId** (str) - 子网ID + - **SystemFileSize** (float) - DB实例系统文件大小,单位GB + - **Tag** (str) - 获取资源其他信息 + - **UseSSD** (bool) - 是否使用SSD + - **VPCId** (str) - VPC的ID + - **VirtualIP** (str) - DB实例虚ip + - **VirtualIPMac** (str) - DB实例虚ip的mac地址 + - **Zone** (str) - 可用区 + + **UDBInstanceSet** + + - **AdminUser** (str) - 管理员帐户名,默认root + - **BackupBeginTime** (int) - 备份策略,不可修改,开始时间,单位小时计,默认3点 + - **BackupBlacklist** (str) - 备份策略,备份黑名单,mongodb则不适用 + - **BackupCount** (int) - 备份策略,不可修改,备份文件保留的数量,默认7次 + - **BackupDate** (str) - 备份日期标记位。共7位,每一位为一周中一天的备份情况 0表示关闭当天备份,1表示打开当天备份。最右边的一位 为星期天的备份开关,其余从右到左依次为星期一到星期 六的备份配置开关,每周必须至少设置两天备份。 例如:1100000 表示打开星期六和星期五的自动备份功能 + - **BackupDuration** (int) - 备份策略,一天内备份时间间隔,单位小时,默认24小时 + - **BackupZone** (str) - 跨可用区高可用备库所在可用区 + - **ChargeType** (str) - Year, Month, Dynamic,Trial,默认: Dynamic + - **CluserRole** (str) - 当DB类型为mongodb时,返回该实例所在集群中的角色,包括:mongos、configsrv_sccc、configsrv_csrs、shardsrv_datanode、shardsrv_arbiter,其中congfigsrv分为sccc和csrs两种模式,shardsrv分为datanode和arbiter两种模式 + - **CreateTime** (int) - DB实例创建时间,采用UTC计时时间戳 + - **DBId** (str) - DB实例id + - **DBTypeId** (str) - DB类型id,mysql/mongodb按版本细分各有一个id 目前id的取值范围为[1,7],数值对应的版本如下: 1:mysql-5.5,2:mysql-5.1,3:percona-5.5 4:mongodb-2.4,5:mongodb-2.6,6:mysql-5.6, 7:percona-5.6 + - **DataFileSize** (float) - DB实例数据文件大小,单位GB + - **DataSet** (list) - 见 **UDBSlaveInstanceSet** 模型定义 + - **DiskSpace** (int) - 磁盘空间(GB), 默认根据配置机型 + - **DiskUsedSize** (float) - DB实例磁盘已使用空间,单位GB + - **ExpiredTime** (int) - DB实例过期时间,采用UTC计时时间戳 + - **InstanceMode** (str) - UDB实例模式类型, 可选值如下: “Normal”: 普通版UDB实例 “HA”: 高可用版UDB实例 + - **InstanceType** (str) - UDB数据库机型 + - **InstanceTypeId** (int) - UDB数据库机型ID + - **LogFileSize** (float) - DB实例日志文件大小,单位GB + - **MemoryLimit** (int) - 内存限制(MB),默认根据配置机型 + - **ModifyTime** (int) - DB实例修改时间,采用UTC计时时间戳 + - **Name** (str) - 实例名称,至少6位 + - **ParamGroupId** (int) - DB实例使用的配置参数组id + - **Port** (int) - 端口号,mysql默认3306,mongodb默认27017 + - **Role** (str) - DB实例角色,mysql区分master/slave,mongodb多种角色 + - **SSDType** (str) - SSD类型,SATA/PCI-E + - **SrcDBId** (str) - 对mysql的slave而言是master的DBId,对master则为空, 对mongodb则是副本集id + - **State** (str) - DB状态标记 Init:初始化中,Fail:安装失败,Starting:启动中,Running:运行,Shutdown:关闭中,Shutoff:已关闭,Delete:已删除,Upgrading:升级中,Promoting:提升为独库进行中,Recovering:恢复中,Recover fail:恢复失败 + - **SubnetId** (str) - 子网ID + - **SystemFileSize** (float) - DB实例系统文件大小,单位GB + - **Tag** (str) - 获取资源其他信息 + - **UseSSD** (bool) - 是否使用SSD + - **VPCId** (str) - VPC的ID + - **VirtualIP** (str) - DB实例虚ip + - **VirtualIPMac** (str) - DB实例虚ip的mac地址 + - **Zone** (str) - DB实例所在可用区 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeUDBInstanceRequestSchema().dumps(d) + resp = self.invoke("DescribeUDBInstance", d, **kwargs) + return apis.DescribeUDBInstanceResponseSchema().loads(resp) + + def describe_udb_instance_backup_state(self, req=None, **kwargs): + """ DescribeUDBInstanceBackupState - 获取UDB实例备份状态 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **BackupId** (int) - (Required) 备份记录ID + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + - **BackupZone** (str) - 跨可用区高可用备库所在可用区,参见[可用区列表] + + **Response** + + - **BackupEndTime** (int) - + - **BackupSize** (int) - + - **State** (str) - 备份状态 0 Backuping // 备份中 1 Success // 备份成功 2 Failed // 备份失败 3 Expired // 备份过期 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeUDBInstanceBackupStateRequestSchema().dumps(d) + resp = self.invoke("DescribeUDBInstanceBackupState", d, **kwargs) + return apis.DescribeUDBInstanceBackupStateResponseSchema().loads(resp) + + def describe_udb_instance_backup_url(self, req=None, **kwargs): + """ DescribeUDBInstanceBackupURL - 获取UDB备份下载地址 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **BackupId** (int) - (Required) DB实例备份ID,该值可以通过DescribeUDBBackup获取 + - **DBId** (str) - (Required) DB实例Id,该值可通过DescribeUDBInstance获取 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **BackupPath** (str) - DB实例备份文件公网的地址 + - **InnerBackupPath** (str) - DB实例备份文件内网的地址 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeUDBInstanceBackupURLRequestSchema().dumps(d) + resp = self.invoke("DescribeUDBInstanceBackupURL", d, **kwargs) + return apis.DescribeUDBInstanceBackupURLResponseSchema().loads(resp) + + def describe_udb_instance_binlog(self, req=None, **kwargs): + """ DescribeUDBInstanceBinlog - 获取UDB指定时间段的binlog列表 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **BeginTime** (int) - (Required) 过滤条件:起始时间(时间戳) + - **DBId** (str) - (Required) DB实例Id + - **EndTime** (int) - (Required) 过滤条件:结束时间(时间戳) + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **DataSet** (list) - 见 **UDBInstanceBinlogSet** 模型定义 + + **Response Model** + + **UDBInstanceBinlogSet** + + - **BeginTime** (int) - Binlog文件生成时间(时间戳) + - **EndTime** (int) - Binlog文件结束时间(时间戳) + - **Name** (str) - Binlog文件名 + - **Size** (int) - Binlog文件大小 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeUDBInstanceBinlogRequestSchema().dumps(d) + resp = self.invoke("DescribeUDBInstanceBinlog", d, **kwargs) + return apis.DescribeUDBInstanceBinlogResponseSchema().loads(resp) + + def describe_udb_instance_binlog_backup_state(self, req=None, **kwargs): + """ DescribeUDBInstanceBinlogBackupState - 获取udb实例备份状态 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **BackupId** (int) - (Required) 备份记录ID + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + - **BackupZone** (str) - 跨可用区高可用备库所在可用区 + + **Response** + + - **BackupSize** (int) - 备份文件大小(字节) + - **State** (str) - 备份状态 0 Backuping // 备份中 1 Success // 备份成功 2 Failed // 备份失败 3 Expired // 备份过期 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeUDBInstanceBinlogBackupStateRequestSchema().dumps(d) + resp = self.invoke("DescribeUDBInstanceBinlogBackupState", d, **kwargs) + return apis.DescribeUDBInstanceBinlogBackupStateResponseSchema().loads( + resp + ) + + def describe_udb_instance_price(self, req=None, **kwargs): + """ DescribeUDBInstancePrice - 获取UDB实例价格信息 + + **Request** + + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **DBTypeId** (str) - (Required) UDB实例的DB版本字符串 + - **DiskSpace** (int) - (Required) 磁盘空间(GB),暂时支持20(GB) - 3000(GB), 输入不带单位 + - **MemoryLimit** (int) - (Required) 内存限制(MB),单位为MB.目前支持:1000-96000 + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + - **ChargeType** (str) - Year,按年付费; Month,按月付费 Dynamic,按需付费(需开启权限) Trial,试用(需开启权限)默认为月付 + - **Count** (int) - 购买DB实例数量,最大数量为10台, 默认为1台 + - **InstanceMode** (str) - 实例的部署类型。可选值为:Normal: 普通单点实例,Slave: 从库实例,HA: 高可用部署实例,默认是Normal + - **Quantity** (int) - DB购买多少个"计费时间单位",默认值为1。比如:买2个月,Quantity就是2。如果计费单位是“按月”,并且Quantity为0,表示“购买到月底” + - **SSDType** (str) - SSD类型,可选值为"SATA"、"PCI-E",如果UseSSD为true ,则必填 + - **UseSSD** (str) - 是否使用SSD,只能填true或false,默认为false + + **Response** + + - **DataSet** (list) - 见 **UDBInstancePriceSet** 模型定义 + + **Response Model** + + **UDBInstancePriceSet** + + - **ChargeType** (str) - Year, Month, Dynamic,Trial + - **Price** (int) - 价格,单位为分 + + """ + d = {"Region": self.config.region} + req and d.update(req) + d = apis.DescribeUDBInstancePriceRequestSchema().dumps(d) + resp = self.invoke("DescribeUDBInstancePrice", d, **kwargs) + return apis.DescribeUDBInstancePriceResponseSchema().loads(resp) + + def describe_udb_instance_state(self, req=None, **kwargs): + """ DescribeUDBInstanceState - 获取UDB实例状态 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **DBId** (str) - (Required) 实例的Id,该值可以通过DescribeUDBInstance获取 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **State** (str) - DB状态标记 Init:初始化中;Fail:安装失败; Starting:启动中; Running : 运行 ;Shutdown:关闭中; Shutoff :已关闭; Delete:已删除; Upgrading:升级中; Promoting: 提升为独库进行中; Recovering: 恢复中; Recover fail:恢复失败。 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeUDBInstanceStateRequestSchema().dumps(d) + resp = self.invoke("DescribeUDBInstanceState", d, **kwargs) + return apis.DescribeUDBInstanceStateResponseSchema().loads(resp) + + def describe_udb_instance_upgrade_price(self, req=None, **kwargs): + """ DescribeUDBInstanceUpgradePrice - 获取UDB实例升降级价格信息 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **DBId** (str) - (Required) 实例的Id + - **DiskSpace** (int) - (Required) 磁盘空间(GB), 暂时支持20G - 500G + - **MemoryLimit** (int) - (Required) 内存限制(MB) + - **SSDType** (str) - SSD类型,可选值为"SATA"、"PCI-E",如果UseSSD为true ,则必选 + - **UseSSD** (bool) - 是否使用SSD,默认为false + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **Price** (int) - 价格,单位为分 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeUDBInstanceUpgradePriceRequestSchema().dumps(d) + resp = self.invoke("DescribeUDBInstanceUpgradePrice", d, **kwargs) + return apis.DescribeUDBInstanceUpgradePriceResponseSchema().loads(resp) + + def describe_udb_log_backup_url(self, req=None, **kwargs): + """ DescribeUDBLogBackupURL - 获取UDB的slowlog备份地址 + + **Request** + + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **BackupId** (int) - (Required) DB实例备份ID + - **DBId** (str) - (Required) DB实例Id + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **BackupPath** (str) - 备份外网URL + - **UsernetPath** (str) - 备份用户网URL + + """ + d = {"Region": self.config.region} + req and d.update(req) + d = apis.DescribeUDBLogBackupURLRequestSchema().dumps(d) + resp = self.invoke("DescribeUDBLogBackupURL", d, **kwargs) + return apis.DescribeUDBLogBackupURLResponseSchema().loads(resp) + + def describe_udb_log_package(self, req=None, **kwargs): + """ DescribeUDBLogPackage - 列表UDB实例binlog或slowlog或errorlog备份信息 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Limit** (int) - (Required) 分页显示的条目数,列表操作则指定 + - **Offset** (int) - (Required) 分页显示的起始偏移,列表操作则指定 + - **BeginTime** (int) - 过滤条件:起始时间(时间戳) + - **DBId** (str) - DB实例Id,如果指定,则只获取该db的备份信息 + - **EndTime** (int) - 过滤条件:结束时间(时间戳) + - **Type** (int) - 需要列出的备份文件类型,每种文件的值如下 2 : BINLOG\\_BACKUP 3 : SLOW\\_QUERY\\_BACKUP 4 : ERRORLOG\\_BACKUP + - **Types** (list) - Types作为Type的补充,支持多值传入,可以获取多个类型的日志记录,如:Types.0=2&Types.1=3 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **DataSet** (list) - 见 **LogPackageDataSet** 模型定义 + - **TotalCount** (int) - 备份总数,如果指定dbid,则是该db备份总数 + + **Response Model** + + **LogPackageDataSet** + + - **BackupId** (int) - 备份id + - **BackupName** (str) - 备份名称 + - **BackupSize** (int) - 备份文件大小 + - **BackupTime** (int) - 备份时间 + - **BackupType** (int) - 备份类型,包括2-binlog备份,3-slowlog备份 + - **BackupZone** (str) - 跨可用区高可用备库所在可用区 + - **DBId** (str) - dbid + - **DBName** (str) - 对应的db名称 + - **State** (str) - 备份状态 Backuping // 备份中 Success // 备份成功 Failed // 备份失败 Expired // 备份过期 + - **Zone** (str) - 所在可用区 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeUDBLogPackageRequestSchema().dumps(d) + resp = self.invoke("DescribeUDBLogPackage", d, **kwargs) + return apis.DescribeUDBLogPackageResponseSchema().loads(resp) + + def describe_udb_param_group(self, req=None, **kwargs): + """ DescribeUDBParamGroup - 获取参数组详细参数信息 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Limit** (int) - (Required) 分页显示的条目数,列表操作则指定 + - **Offset** (int) - (Required) 分页显示的起始偏移,列表操作则指定 + - **ClassType** (str) - 如果未指定GroupId,则可选是否选取特定DB类型的配置(sql, nosql, postgresql, sqlserver) + - **GroupId** (int) - 参数组id,如果指定则获取描述,否则是列表操作,需要 指定Offset/Limit + - **IsInUDBC** (bool) - 是否选取专区中配置 + - **RegionFlag** (bool) - 当请求没有填写Zone时,如果指定为true,表示只拉取跨可用区的相关配置文件,否则,拉取所有机房的配置文件(包括每个单可用区和跨可用区) + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **DataSet** (list) - 见 **UDBParamGroupSet** 模型定义 + - **TotalCount** (int) - 参数组总数,列表操作时才会有该参数 + + **Response Model** + + **UDBParamMemberSet** + + - **AllowedVal** (str) - 允许的值(根据参数类型,用分隔符表示) + - **ApplyType** (int) - 参数值应用类型,取值范围为{0,10,20},各值代表 意义为0-unknown、10-static、20-dynamic + - **FormatType** (int) - 允许值的格式类型,取值范围为{0,10,20},意义分 别为PVFT_UNKOWN=0,PVFT_RANGE=10, PVFT_ENUM=20 + - **Key** (str) - 参数名称 + - **Modifiable** (bool) - 是否可更改,默认为false + - **Value** (str) - 参数值 + - **ValueType** (int) - 参数值应用类型,取值范围为{0,10,20,30},各值 代表意义为 0-unknown、10-int、20-string、 30-bool + + **UDBParamGroupSet** + + - **DBTypeId** (str) - DB类型id,mysql/mongodb按版本细分各有一个id 目前id的取值范围为[1,7],数值对应的版本如下 1:mysql-5.5,2:mysql-5.1,3:percona-5.5 4:mongodb-2.4,5:mongodb-2.6,6:mysql-5.6 7:percona-5.6 + - **Description** (str) - 参数组描述 + - **GroupId** (int) - 参数组id + - **GroupName** (str) - 参数组名称 + - **Modifiable** (bool) - 参数组是否可修改 + - **ParamMember** (list) - 见 **UDBParamMemberSet** 模型定义 + - **RegionFlag** (bool) - + - **Zone** (str) - + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeUDBParamGroupRequestSchema().dumps(d) + resp = self.invoke("DescribeUDBParamGroup", d, **kwargs) + return apis.DescribeUDBParamGroupResponseSchema().loads(resp) + + def describe_udb_type(self, req=None, **kwargs): + """ DescribeUDBType - 获取UDB支持的类型信息 + + **Request** + + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + - **BackupZone** (str) - 跨可用区高可用DB的备库所在区域,仅当该可用区支持跨可用区高可用时填入。参见 `可用区列表 `_ + - **DBClusterType** (str) - DB实例类型,如mysql,sqlserver,mongo,postgresql + - **DiskType** (str) - 返回支持某种磁盘类型的DB类型。如果没传,则表示任何磁盘类型均可。 + - **InstanceMode** (str) - 返回支持某种实例类型的DB类型。如果没传,则表示任何实例类型均可。normal:单点,ha:高可用,sharded_cluster:分片集群 + + **Response** + + - **Action** (str) - 操作名称 + - **DataSet** (list) - 见 **UDBTypeSet** 模型定义 + - **RetCode** (int) - 返回码 + + **Response Model** + + **UDBTypeSet** + + - **DBTypeId** (str) - DB类型id,mysql/mongodb按版本细分各有一个id, 目前id的取值范围为[1,7],数值对应的版本如下: 1:mysql-5.5,2:mysql-5.1,3:percona-5.5 4:mongodb-2.4,5:mongodb-2.6,6:mysql-5.6, 7:percona-5.6 + + """ + d = {"Region": self.config.region} + req and d.update(req) + d = apis.DescribeUDBTypeRequestSchema().dumps(d) + resp = self.invoke("DescribeUDBType", d, **kwargs) + return apis.DescribeUDBTypeResponseSchema().loads(resp) + + def edit_udb_backup_blacklist(self, req=None, **kwargs): + """ EditUDBBackupBlacklist - 编辑UDB实例的备份黑名单 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Blacklist** (str) - (Required) 黑名单,规范示例,指定库mysql.%;test.%; 指定表city.address; + - **DBId** (str) - (Required) DB实例Id,该值可以通过DescribeUDBInstance获取 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.EditUDBBackupBlacklistRequestSchema().dumps(d) + resp = self.invoke("EditUDBBackupBlacklist", d, **kwargs) + return apis.EditUDBBackupBlacklistResponseSchema().loads(resp) + + def fetch_udb_instance_earliest_recover_time(self, req=None, **kwargs): + """ FetchUDBInstanceEarliestRecoverTime - 获取UDB最早可回档的时间点 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **DBId** (str) - (Required) DB实例Id + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **EarliestTime** (int) - 获取最早可回档时间点 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.FetchUDBInstanceEarliestRecoverTimeRequestSchema().dumps(d) + resp = self.invoke("FetchUDBInstanceEarliestRecoverTime", d, **kwargs) + return apis.FetchUDBInstanceEarliestRecoverTimeResponseSchema().loads( + resp + ) + + def modify_udb_instance_name(self, req=None, **kwargs): + """ ModifyUDBInstanceName - 重命名UDB实例 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **DBId** (str) - (Required) 实例的Id,该值可以通过DescribeUDBInstance获取 + - **Name** (str) - (Required) 实例的新名字, 长度要求为6~63位 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.ModifyUDBInstanceNameRequestSchema().dumps(d) + resp = self.invoke("ModifyUDBInstanceName", d, **kwargs) + return apis.ModifyUDBInstanceNameResponseSchema().loads(resp) + + def modify_udb_instance_password(self, req=None, **kwargs): + """ ModifyUDBInstancePassword - 修改DB实例的管理员密码 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **DBId** (str) - (Required) 实例的ID,该值可以通过DescribeUDBInstance获取 + - **Password** (str) - (Required) 实例的新密码 + - **AccountName** (str) - sqlserver帐号,仅在sqlserver的情况下填该参数 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.ModifyUDBInstancePasswordRequestSchema().dumps(d) + resp = self.invoke("ModifyUDBInstancePassword", d, **kwargs) + return apis.ModifyUDBInstancePasswordResponseSchema().loads(resp) + + def promote_udb_instance_to_ha(self, req=None, **kwargs): + """ PromoteUDBInstanceToHA - 普通db升级为高可用(只针对mysql5.5及以上版本) + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **DBId** (str) - (Required) 实例的Id,该值可以通过DescribeUDBInstance获取 + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.PromoteUDBInstanceToHARequestSchema().dumps(d) + resp = self.invoke("PromoteUDBInstanceToHA", d, **kwargs) + return apis.PromoteUDBInstanceToHAResponseSchema().loads(resp) + + def promote_udb_slave(self, req=None, **kwargs): + """ PromoteUDBSlave - 从库提升为独立库 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **DBId** (str) - (Required) 实例的Id,该值可以通过DescribeUDBInstance获取 + - **IsForce** (bool) - 是否强制(如果从库落后可能会禁止提升),默认false 如果落后情况下,强制提升丢失数据 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.PromoteUDBSlaveRequestSchema().dumps(d) + resp = self.invoke("PromoteUDBSlave", d, **kwargs) + return apis.PromoteUDBSlaveResponseSchema().loads(resp) + + def resize_udb_instance(self, req=None, **kwargs): + """ ResizeUDBInstance - 修改(升级和降级)UDB实例的配置,包括内存和磁盘的配置,对于内存升级无需关闭实例,其他场景需要事先关闭实例。两套参数可以配置升降机:1.配置UseSSD和SSDType 2.配置InstanceType,不需要配置InstanceMode。这两套第二套参数的优先级更高 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **DBId** (str) - (Required) 实例的Id + - **DiskSpace** (int) - (Required) 磁盘空间(GB), 暂时支持20G-3000G + - **MemoryLimit** (int) - (Required) 内存限制(MB),目前支持以下几档 1000M/2000M/4000M/ 6000M/8000M/ 12000M/16000M/ 24000M/32000M/ 48000M/64000M/96000M。 + - **CouponId** (str) - 使用的代金券id + - **InstanceMode** (str) - UDB实例模式类型, 可选值如下: "Normal": 普通版UDB实例 "HA": 高可用版UDB实例 默认是"Normal" + - **InstanceType** (str) - UDB数据库机型: "Normal": "标准机型" , "SATA_SSD": "SSD机型" , "PCIE_SSD": "SSD高性能机型" , "Normal_Volume": "标准大容量机型", "SATA_SSD_Volume": "SSD大容量机型" , "PCIE_SSD_Volume": "SSD高性能大容量机型" + - **SSDType** (str) - SSD类型,可选值为"SATA"、"PCI-E",如果UseSSD为true ,则必选 + - **StartAfterUpgrade** (bool) - DB关闭状态下升降级,升降级后是否启动DB,默认为false + - **UDBCId** (str) - 专区的ID,如果有值表示专区中的DB配置升降级 + - **UseSSD** (bool) - 是否使用SSD,默认为false + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.ResizeUDBInstanceRequestSchema().dumps(d) + resp = self.invoke("ResizeUDBInstance", d, **kwargs) + return apis.ResizeUDBInstanceResponseSchema().loads(resp) + + def restart_udb_instance(self, req=None, **kwargs): + """ RestartUDBInstance - 重启UDB实例 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **DBId** (str) - (Required) 实例的Id,该值可以通过DescribeUDBInstance获取 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.RestartUDBInstanceRequestSchema().dumps(d) + resp = self.invoke("RestartUDBInstance", d, **kwargs) + return apis.RestartUDBInstanceResponseSchema().loads(resp) + + def start_udb_instance(self, req=None, **kwargs): + """ StartUDBInstance - 启动UDB实例 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **DBId** (str) - (Required) 实例的Id,该值可以通过DescribeUDBInstance获取 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.StartUDBInstanceRequestSchema().dumps(d) + resp = self.invoke("StartUDBInstance", d, **kwargs) + return apis.StartUDBInstanceResponseSchema().loads(resp) + + def stop_udb_instance(self, req=None, **kwargs): + """ StopUDBInstance - 关闭UDB实例 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **DBId** (str) - (Required) 实例的Id,该值可以通过DescribeUDBInstance获取 + - **ForceToKill** (bool) - 是否使用强制手段关闭DB,默认是false + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.StopUDBInstanceRequestSchema().dumps(d) + resp = self.invoke("StopUDBInstance", d, **kwargs) + return apis.StopUDBInstanceResponseSchema().loads(resp) + + def switch_udb_instance_to_ha(self, req=None, **kwargs): + """ SwitchUDBInstanceToHA - 普通UDB切换为高可用,原db状态为WaitForSwitch时,调用该api + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **DBId** (str) - (Required) 实例的Id,该值可以通过DescribeUDBInstance获取 + - **ChargeType** (str) - Year, Month, Dynamic,Trial,不填则按现在单点计费执行 + - **Quantity** (str) - 购买时长,需要和 ChargeType 搭配使用,否则使用单点计费策略的值 + - **Tag** (str) - 业务组 + + **Response** + + - **DBId** (str) - 切换后高可用db实例的Id + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.SwitchUDBInstanceToHARequestSchema().dumps(d) + resp = self.invoke("SwitchUDBInstanceToHA", d, **kwargs) + return apis.SwitchUDBInstanceToHAResponseSchema().loads(resp) + + def update_udb_instance_backup_strategy(self, req=None, **kwargs): + """ UpdateUDBInstanceBackupStrategy - 修改UDB自动备份策略 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **DBId** (str) - (Required) 主节点的Id + - **BackupDate** (str) - 备份时期标记位。共7位,每一位为一周中一天的备份情况,0表示关闭当天备份,1表示打开当天备份。最右边的一位为星期天的备份开关,其余从右到左依次为星期一到星期六的备份配置开关,每周必须至少设置两天备份。例如:1100000表示打开星期六和星期五的备份功能 + - **BackupMethod** (str) - 选择默认的备份方式,可选 snapshot 表示使用快照/物理备份,填 logic 表示使用逻辑备份。需要同时设置BackupDate字段。(注意现在只有SSD 版本的 MySQL实例支持物理备份) + - **BackupTime** (int) - 备份的整点时间,范围[0,23] + - **ForceDump** (bool) - 当导出某些数据遇到问题后,是否强制导出其他剩余数据默认是false需要同时设置BackupDate字段 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.UpdateUDBInstanceBackupStrategyRequestSchema().dumps(d) + resp = self.invoke("UpdateUDBInstanceBackupStrategy", d, **kwargs) + return apis.UpdateUDBInstanceBackupStrategyResponseSchema().loads(resp) + + def update_udb_instance_slave_backup_switch(self, req=None, **kwargs): + """ UpdateUDBInstanceSlaveBackupSwitch - 开启或者关闭UDB从库备份 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **BackupSwitch** (int) - (Required) 从库的备份开关,范围[0,1],0表示从库备份功能关闭,1 表示从库备份开关打开。 + - **MasterDBId** (str) - (Required) 主库的Id + - **SlaveDBId** (str) - 从库的Id,如果从库备份开关设定为打开,则必须赋值。 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.UpdateUDBInstanceSlaveBackupSwitchRequestSchema().dumps(d) + resp = self.invoke("UpdateUDBInstanceSlaveBackupSwitch", d, **kwargs) + return apis.UpdateUDBInstanceSlaveBackupSwitchResponseSchema().loads( + resp + ) + + def update_udb_param_group(self, req=None, **kwargs): + """ UpdateUDBParamGroup - 更新UDB配置参数项 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **GroupId** (int) - (Required) 配置参数组id,使用DescribeUDBParamGroup获得 + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + - **Description** (str) - 配置文件的描述,不传时认为不修改 + - **Key** (str) - 参数名称(与Value配合使用) + - **Name** (str) - 配置文件的名字,不传时认为不修改名字,传了则不能为空 + - **RegionFlag** (bool) - 该配置文件是否是地域级别配置文件,默认是false + - **Value** (str) - 参数值(与Key配合使用) + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.UpdateUDBParamGroupRequestSchema().dumps(d) + resp = self.invoke("UpdateUDBParamGroup", d, **kwargs) + return apis.UpdateUDBParamGroupResponseSchema().loads(resp) + + def upload_udb_param_group(self, req=None, **kwargs): + """ UploadUDBParamGroup - 导入UDB配置 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Content** (str) - (Required) 配置内容,导入的配置内容采用base64编码 + - **DBTypeId** (str) - (Required) DB类型id,DB类型id,mysql/mongodb/postgesql按版本细分 1:mysql-5.1,2:mysql-5.5,3:percona-5.5,4:mysql-5.6,5:percona-5.6,6:mysql-5.7,7:percona-5.7,8:mariadb-10.0,9:mongodb-2.4,10:mongodb-2.6,11:mongodb-3.0,12:mongodb-3.2,13:postgresql-9.4,14:postgresql-9.6 + - **Description** (str) - (Required) 参数组描述 + - **GroupName** (str) - (Required) 配置参数组名称 + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + - **ParamGroupTypeId** (int) - 配置文件子类型 0-未知, 1-Shardsvr-MMAPv1, 2-Shardsvr-WiredTiger, 3-Configsvr-MMAPv1, 4-Configsvr-WiredTiger, 5-Mongos + - **RegionFlag** (bool) - 该配置文件是否是地域级别配置文件,默认是false + + **Response** + + - **GroupId** (int) - 配置参数组id + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.UploadUDBParamGroupRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("UploadUDBParamGroup", d, **kwargs) + return apis.UploadUDBParamGroupResponseSchema().loads(resp) diff --git a/ucloud/services/udb/schemas/__init__.py b/ucloud/services/udb/schemas/__init__.py index 4c48b5a..40a96af 100644 --- a/ucloud/services/udb/schemas/__init__.py +++ b/ucloud/services/udb/schemas/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- diff --git a/ucloud/services/udb/schemas/apis.py b/ucloud/services/udb/schemas/apis.py index 67808ad..77989f9 100644 --- a/ucloud/services/udb/schemas/apis.py +++ b/ucloud/services/udb/schemas/apis.py @@ -1,1429 +1,1452 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.typesystem import schema, fields -from ucloud.services.udb.schemas import models - -""" UDB API Schema -""" -""" -API: BackupUDBInstance - -备份UDB实例 -""" - - -class BackupUDBInstanceRequestSchema(schema.RequestSchema): - """ BackupUDBInstance - 备份UDB实例 - """ - - fields = { - "BackupMethod": fields.Str(required=False, dump_to="BackupMethod"), - "BackupName": fields.Str(required=True, dump_to="BackupName"), - "Blacklist": fields.Str(required=False, dump_to="Blacklist"), - "DBId": fields.Str(required=True, dump_to="DBId"), - "ForceBackup": fields.Bool(required=False, dump_to="ForceBackup"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "UseBlacklist": fields.Bool(required=False, dump_to="UseBlacklist"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class BackupUDBInstanceResponseSchema(schema.ResponseSchema): - """ BackupUDBInstance - 备份UDB实例 - """ - - fields = {} - - -""" -API: BackupUDBInstanceBinlog - -备份UDB指定时间段的binlog列表 -""" - - -class BackupUDBInstanceBinlogRequestSchema(schema.RequestSchema): - """ BackupUDBInstanceBinlog - 备份UDB指定时间段的binlog列表 - """ - - fields = { - "BackupFile": fields.Str(required=True, dump_to="BackupFile"), - "BackupName": fields.Str(required=False, dump_to="BackupName"), - "DBId": fields.Str(required=True, dump_to="DBId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class BackupUDBInstanceBinlogResponseSchema(schema.ResponseSchema): - """ BackupUDBInstanceBinlog - 备份UDB指定时间段的binlog列表 - """ - - fields = {} - - -""" -API: BackupUDBInstanceErrorLog - -备份UDB指定时间段的errorlog -""" - - -class BackupUDBInstanceErrorLogRequestSchema(schema.RequestSchema): - """ BackupUDBInstanceErrorLog - 备份UDB指定时间段的errorlog - """ - - fields = { - "BackupName": fields.Str(required=True, dump_to="BackupName"), - "DBId": fields.Str(required=True, dump_to="DBId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class BackupUDBInstanceErrorLogResponseSchema(schema.ResponseSchema): - """ BackupUDBInstanceErrorLog - 备份UDB指定时间段的errorlog - """ - - fields = {} - - -""" -API: BackupUDBInstanceSlowLog - -备份UDB指定时间段的slowlog分析结果 -""" - - -class BackupUDBInstanceSlowLogRequestSchema(schema.RequestSchema): - """ BackupUDBInstanceSlowLog - 备份UDB指定时间段的slowlog分析结果 - """ - - fields = { - "BackupName": fields.Str(required=True, dump_to="BackupName"), - "BeginTime": fields.Int(required=True, dump_to="BeginTime"), - "DBId": fields.Str(required=True, dump_to="DBId"), - "EndTime": fields.Int(required=True, dump_to="EndTime"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - } - - -class BackupUDBInstanceSlowLogResponseSchema(schema.ResponseSchema): - """ BackupUDBInstanceSlowLog - 备份UDB指定时间段的slowlog分析结果 - """ - - fields = {} - - -""" -API: CheckRecoverUDBInstance - -核查db是否可以使用回档功能 -""" - - -class CheckRecoverUDBInstanceRequestSchema(schema.RequestSchema): - """ CheckRecoverUDBInstance - 核查db是否可以使用回档功能 - """ - - fields = { - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "SrcDBId": fields.Str(required=True, dump_to="SrcDBId"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class CheckRecoverUDBInstanceResponseSchema(schema.ResponseSchema): - """ CheckRecoverUDBInstance - 核查db是否可以使用回档功能 - """ - - fields = {"LastestTime": fields.Int(required=False, load_from="LastestTime")} - - -""" -API: CheckUDBInstanceToHAAllowance - -核查db是否可以升级为高可用 -""" - - -class CheckUDBInstanceToHAAllowanceRequestSchema(schema.RequestSchema): - """ CheckUDBInstanceToHAAllowance - 核查db是否可以升级为高可用 - """ - - fields = { - "DBId": fields.Str(required=True, dump_to="DBId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - } - - -class CheckUDBInstanceToHAAllowanceResponseSchema(schema.ResponseSchema): - """ CheckUDBInstanceToHAAllowance - 核查db是否可以升级为高可用 - """ - - fields = {"Allowance": fields.Str(required=False, load_from="Allowance")} - - -""" -API: ClearUDBLog - -清除UDB实例的log -""" - - -class ClearUDBLogRequestSchema(schema.RequestSchema): - """ ClearUDBLog - 清除UDB实例的log - """ - - fields = { - "BeforeTime": fields.Int(required=False, dump_to="BeforeTime"), - "DBId": fields.Str(required=True, dump_to="DBId"), - "LogType": fields.Int(required=True, dump_to="LogType"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class ClearUDBLogResponseSchema(schema.ResponseSchema): - """ ClearUDBLog - 清除UDB实例的log - """ - - fields = {} - - -""" -API: CreateUDBInstance - -创建UDB实例(包括创建mysql master节点、mongodb primary/configsvr节点和从备份恢复实例) -""" - - -class CreateUDBInstanceRequestSchema(schema.RequestSchema): - """ CreateUDBInstance - 创建UDB实例(包括创建mysql master节点、mongodb primary/configsvr节点和从备份恢复实例) - """ - - fields = { - "AdminPassword": fields.Str(required=True, dump_to="AdminPassword"), - "AdminUser": fields.Str(required=False, dump_to="AdminUser"), - "BackupCount": fields.Int(required=False, dump_to="BackupCount"), - "BackupDuration": fields.Int(required=False, dump_to="BackupDuration"), - "BackupId": fields.Int(required=False, dump_to="BackupId"), - "BackupTime": fields.Int(required=False, dump_to="BackupTime"), - "BackupZone": fields.Str(required=False, dump_to="BackupZone"), - "CPU": fields.Int(required=False, dump_to="CPU"), - "ChargeType": fields.Str(required=False, dump_to="ChargeType"), - "ClusterRole": fields.Str(required=False, dump_to="ClusterRole"), - "CouponId": fields.Str(required=False, dump_to="CouponId"), - "DBTypeId": fields.Str(required=True, dump_to="DBTypeId"), - "DisableSemisync": fields.Bool(required=False, dump_to="DisableSemisync"), - "DiskSpace": fields.Int(required=True, dump_to="DiskSpace"), - "HAArch": fields.Str(required=False, dump_to="HAArch"), - "InstanceMode": fields.Str(required=False, dump_to="InstanceMode"), - "InstanceType": fields.Str(required=False, dump_to="InstanceType"), - "MemoryLimit": fields.Int(required=True, dump_to="MemoryLimit"), - "Name": fields.Str(required=True, dump_to="Name"), - "ParamGroupId": fields.Int(required=True, dump_to="ParamGroupId"), - "Port": fields.Int(required=True, dump_to="Port"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Quantity": fields.Int(required=False, dump_to="Quantity"), - "Region": fields.Str(required=True, dump_to="Region"), - "SSDType": fields.Str(required=False, dump_to="SSDType"), - "SubnetId": fields.Str(required=False, dump_to="SubnetId"), - "Tag": fields.Str(required=False, dump_to="Tag"), - "UDBCId": fields.Str(required=False, dump_to="UDBCId"), - "UseSSD": fields.Bool(required=False, dump_to="UseSSD"), - "VPCId": fields.Str(required=False, dump_to="VPCId"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class CreateUDBInstanceResponseSchema(schema.ResponseSchema): - """ CreateUDBInstance - 创建UDB实例(包括创建mysql master节点、mongodb primary/configsvr节点和从备份恢复实例) - """ - - fields = {"DBId": fields.Str(required=False, load_from="DBId")} - - -""" -API: CreateUDBInstanceByRecovery - -创建db,将新创建的db恢复到指定db某个指定时间点 -""" - - -class CreateUDBInstanceByRecoveryRequestSchema(schema.RequestSchema): - """ CreateUDBInstanceByRecovery - 创建db,将新创建的db恢复到指定db某个指定时间点 - """ - - fields = { - "ChargeType": fields.Str(required=False, dump_to="ChargeType"), - "CouponId": fields.Str(required=False, dump_to="CouponId"), - "Name": fields.Str(required=True, dump_to="Name"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Quantity": fields.Int(required=False, dump_to="Quantity"), - "RecoveryTime": fields.Int(required=True, dump_to="RecoveryTime"), - "Region": fields.Str(required=True, dump_to="Region"), - "SrcDBId": fields.Str(required=True, dump_to="SrcDBId"), - "SubnetId": fields.Str(required=False, dump_to="SubnetId"), - "UDBCId": fields.Str(required=False, dump_to="UDBCId"), - "UseSSD": fields.Bool(required=False, dump_to="UseSSD"), - "VPCId": fields.Str(required=False, dump_to="VPCId"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class CreateUDBInstanceByRecoveryResponseSchema(schema.ResponseSchema): - """ CreateUDBInstanceByRecovery - 创建db,将新创建的db恢复到指定db某个指定时间点 - """ - - fields = {"DBId": fields.Str(required=False, load_from="DBId")} - - -""" -API: CreateUDBParamGroup - -从已有配置文件创建新配置文件 -""" - - -class CreateUDBParamGroupRequestSchema(schema.RequestSchema): - """ CreateUDBParamGroup - 从已有配置文件创建新配置文件 - """ - - fields = { - "DBTypeId": fields.Str(required=True, dump_to="DBTypeId"), - "Description": fields.Str(required=True, dump_to="Description"), - "GroupName": fields.Str(required=True, dump_to="GroupName"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "RegionFlag": fields.Bool(required=False, dump_to="RegionFlag"), - "SrcGroupId": fields.Int(required=True, dump_to="SrcGroupId"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class CreateUDBParamGroupResponseSchema(schema.ResponseSchema): - """ CreateUDBParamGroup - 从已有配置文件创建新配置文件 - """ - - fields = {"GroupId": fields.Int(required=False, load_from="GroupId")} - - -""" -API: CreateUDBReplicationInstance - -创建MongoDB的副本节点(包括仲裁) -""" - - -class CreateUDBReplicationInstanceRequestSchema(schema.RequestSchema): - """ CreateUDBReplicationInstance - 创建MongoDB的副本节点(包括仲裁) - """ - - fields = { - "CouponId": fields.Str(required=False, dump_to="CouponId"), - "IsArbiter": fields.Bool(required=False, dump_to="IsArbiter"), - "Name": fields.Str(required=True, dump_to="Name"), - "Port": fields.Int(required=False, dump_to="Port"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "SrcId": fields.Str(required=True, dump_to="SrcId"), - "UseSSD": fields.Bool(required=False, dump_to="UseSSD"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class CreateUDBReplicationInstanceResponseSchema(schema.ResponseSchema): - """ CreateUDBReplicationInstance - 创建MongoDB的副本节点(包括仲裁) - """ - - fields = {"DBId": fields.Str(required=False, load_from="DBId")} - - -""" -API: CreateUDBRouteInstance - -创建mongos实例 -""" - - -class CreateUDBRouteInstanceRequestSchema(schema.RequestSchema): - """ CreateUDBRouteInstance - 创建mongos实例 - """ - - fields = { - "ChargeType": fields.Str(required=False, dump_to="ChargeType"), - "ConfigsvrId": fields.List(fields.Str()), - "CouponId": fields.Str(required=False, dump_to="CouponId"), - "DBTypeId": fields.Str(required=True, dump_to="DBTypeId"), - "DiskSpace": fields.Int(required=True, dump_to="DiskSpace"), - "MemoryLimit": fields.Int(required=True, dump_to="MemoryLimit"), - "Name": fields.Str(required=True, dump_to="Name"), - "ParamGroupId": fields.Int(required=True, dump_to="ParamGroupId"), - "Port": fields.Int(required=True, dump_to="Port"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Quantity": fields.Int(required=False, dump_to="Quantity"), - "Region": fields.Str(required=True, dump_to="Region"), - "UseSSD": fields.Bool(required=False, dump_to="UseSSD"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class CreateUDBRouteInstanceResponseSchema(schema.ResponseSchema): - """ CreateUDBRouteInstance - 创建mongos实例 - """ - - fields = {"DBId": fields.Str(required=False, load_from="DBId")} - - -""" -API: CreateUDBSlave - -创建UDB实例的slave -""" - - -class CreateUDBSlaveRequestSchema(schema.RequestSchema): - """ CreateUDBSlave - 创建UDB实例的slave - """ - - fields = { - "CouponId": fields.Str(required=False, dump_to="CouponId"), - "DiskSpace": fields.Int(required=False, dump_to="DiskSpace"), - "InstanceMode": fields.Str(required=False, dump_to="InstanceMode"), - "InstanceType": fields.Str(required=False, dump_to="InstanceType"), - "IsLock": fields.Bool(required=False, dump_to="IsLock"), - "MemoryLimit": fields.Int(required=False, dump_to="MemoryLimit"), - "Name": fields.Str(required=True, dump_to="Name"), - "Port": fields.Int(required=False, dump_to="Port"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "SSDType": fields.Str(required=False, dump_to="SSDType"), - "SrcId": fields.Str(required=True, dump_to="SrcId"), - "UseSSD": fields.Bool(required=False, dump_to="UseSSD"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class CreateUDBSlaveResponseSchema(schema.ResponseSchema): - """ CreateUDBSlave - 创建UDB实例的slave - """ - - fields = {"DBId": fields.Str(required=False, load_from="DBId")} - - -""" -API: DeleteUDBBackup - -删除UDB实例备份 -""" - - -class DeleteUDBBackupRequestSchema(schema.RequestSchema): - """ DeleteUDBBackup - 删除UDB实例备份 - """ - - fields = { - "BackupId": fields.Int(required=True, dump_to="BackupId"), - "BackupZone": fields.Str(required=False, dump_to="BackupZone"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class DeleteUDBBackupResponseSchema(schema.ResponseSchema): - """ DeleteUDBBackup - 删除UDB实例备份 - """ - - fields = {} - - -""" -API: DeleteUDBInstance - -删除UDB实例 -""" - - -class DeleteUDBInstanceRequestSchema(schema.RequestSchema): - """ DeleteUDBInstance - 删除UDB实例 - """ - - fields = { - "DBId": fields.Str(required=True, dump_to="DBId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "UDBCId": fields.Str(required=False, dump_to="UDBCId"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class DeleteUDBInstanceResponseSchema(schema.ResponseSchema): - """ DeleteUDBInstance - 删除UDB实例 - """ - - fields = {} - - -""" -API: DeleteUDBLogPackage - -删除UDB日志包 -""" - - -class DeleteUDBLogPackageRequestSchema(schema.RequestSchema): - """ DeleteUDBLogPackage - 删除UDB日志包 - """ - - fields = { - "BackupId": fields.Int(required=True, dump_to="BackupId"), - "BackupZone": fields.Str(required=False, dump_to="BackupZone"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class DeleteUDBLogPackageResponseSchema(schema.ResponseSchema): - """ DeleteUDBLogPackage - 删除UDB日志包 - """ - - fields = {} - - -""" -API: DeleteUDBParamGroup - -删除配置参数组 -""" - - -class DeleteUDBParamGroupRequestSchema(schema.RequestSchema): - """ DeleteUDBParamGroup - 删除配置参数组 - """ - - fields = { - "GroupId": fields.Int(required=True, dump_to="GroupId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "RegionFlag": fields.Bool(required=False, dump_to="RegionFlag"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class DeleteUDBParamGroupResponseSchema(schema.ResponseSchema): - """ DeleteUDBParamGroup - 删除配置参数组 - """ - - fields = {} - - -""" -API: DescribeUDBBackup - -列表UDB实例备份信息.Zone不填表示多可用区,填代表单可用区 -""" - - -class DescribeUDBBackupRequestSchema(schema.RequestSchema): - """ DescribeUDBBackup - 列表UDB实例备份信息.Zone不填表示多可用区,填代表单可用区 - """ - - fields = { - "BackupId": fields.Int(required=False, dump_to="BackupId"), - "BackupType": fields.Int(required=False, dump_to="BackupType"), - "BeginTime": fields.Int(required=False, dump_to="BeginTime"), - "ClassType": fields.Str(required=False, dump_to="ClassType"), - "DBId": fields.Str(required=False, dump_to="DBId"), - "EndTime": fields.Int(required=False, dump_to="EndTime"), - "Limit": fields.Int(required=True, dump_to="Limit"), - "Offset": fields.Int(required=True, dump_to="Offset"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class DescribeUDBBackupResponseSchema(schema.ResponseSchema): - """ DescribeUDBBackup - 列表UDB实例备份信息.Zone不填表示多可用区,填代表单可用区 - """ - - fields = { - "DataSet": fields.List( - models.UDBBackupSetSchema(), required=False, load_from="DataSet" - ), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - } - - -""" -API: DescribeUDBBackupBlacklist - -获取UDB实例的备份黑名单 -""" - - -class DescribeUDBBackupBlacklistRequestSchema(schema.RequestSchema): - """ DescribeUDBBackupBlacklist - 获取UDB实例的备份黑名单 - """ - - fields = { - "DBId": fields.Str(required=True, dump_to="DBId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class DescribeUDBBackupBlacklistResponseSchema(schema.ResponseSchema): - """ DescribeUDBBackupBlacklist - 获取UDB实例的备份黑名单 - """ - - fields = {"Blacklist": fields.Str(required=False, load_from="Blacklist")} - - -""" -API: DescribeUDBBinlogBackupURL - -获取UDB的Binlog备份地址 -""" - - -class DescribeUDBBinlogBackupURLRequestSchema(schema.RequestSchema): - """ DescribeUDBBinlogBackupURL - 获取UDB的Binlog备份地址 - """ - - fields = { - "BackupId": fields.Int(required=True, dump_to="BackupId"), - "DBId": fields.Str(required=True, dump_to="DBId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class DescribeUDBBinlogBackupURLResponseSchema(schema.ResponseSchema): - """ DescribeUDBBinlogBackupURL - 获取UDB的Binlog备份地址 - """ - - fields = { - "BackupPath": fields.Str(required=False, load_from="BackupPath"), - "InnerBackupPath": fields.Str(required=False, load_from="InnerBackupPath"), - } - - -""" -API: DescribeUDBInstance - -获取UDB实例信息,支持两类操作:(1)指定DBId用于获取该db的信息;(2)指定ClassType、Offset、Limit用于列表操作,查询某一个类型db。 -""" - - -class DescribeUDBInstanceRequestSchema(schema.RequestSchema): - """ DescribeUDBInstance - 获取UDB实例信息,支持两类操作:(1)指定DBId用于获取该db的信息;(2)指定ClassType、Offset、Limit用于列表操作,查询某一个类型db。 - """ - - fields = { - "ClassType": fields.Str(required=True, dump_to="ClassType"), - "DBId": fields.Str(required=False, dump_to="DBId"), - "IncludeSlaves": fields.Bool(required=False, dump_to="IncludeSlaves"), - "IsInUDBC": fields.Bool(required=False, dump_to="IsInUDBC"), - "Limit": fields.Int(required=True, dump_to="Limit"), - "Offset": fields.Int(required=True, dump_to="Offset"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "UDBCId": fields.Str(required=False, dump_to="UDBCId"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class DescribeUDBInstanceResponseSchema(schema.ResponseSchema): - """ DescribeUDBInstance - 获取UDB实例信息,支持两类操作:(1)指定DBId用于获取该db的信息;(2)指定ClassType、Offset、Limit用于列表操作,查询某一个类型db。 - """ - - fields = { - "DataSet": fields.List( - models.UDBInstanceSetSchema(), required=False, load_from="DataSet" - ), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - } - - -""" -API: DescribeUDBInstanceBackupState - -获取UDB实例备份状态 -""" - - -class DescribeUDBInstanceBackupStateRequestSchema(schema.RequestSchema): - """ DescribeUDBInstanceBackupState - 获取UDB实例备份状态 - """ - - fields = { - "BackupId": fields.Int(required=True, dump_to="BackupId"), - "BackupZone": fields.Str(required=False, dump_to="BackupZone"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class DescribeUDBInstanceBackupStateResponseSchema(schema.ResponseSchema): - """ DescribeUDBInstanceBackupState - 获取UDB实例备份状态 - """ - - fields = { - "BackupEndTime": fields.Int(required=False, load_from="BackupEndTime"), - "BackupSize": fields.Int(required=False, load_from="BackupSize"), - "State": fields.Str(required=False, load_from="State"), - } - - -""" -API: DescribeUDBInstanceBackupURL - -获取UDB备份下载地址 -""" - - -class DescribeUDBInstanceBackupURLRequestSchema(schema.RequestSchema): - """ DescribeUDBInstanceBackupURL - 获取UDB备份下载地址 - """ - - fields = { - "BackupId": fields.Int(required=True, dump_to="BackupId"), - "DBId": fields.Str(required=True, dump_to="DBId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class DescribeUDBInstanceBackupURLResponseSchema(schema.ResponseSchema): - """ DescribeUDBInstanceBackupURL - 获取UDB备份下载地址 - """ - - fields = { - "BackupPath": fields.Str(required=False, load_from="BackupPath"), - "InnerBackupPath": fields.Str(required=False, load_from="InnerBackupPath"), - } - - -""" -API: DescribeUDBInstanceBinlog - -获取UDB指定时间段的binlog列表 -""" - - -class DescribeUDBInstanceBinlogRequestSchema(schema.RequestSchema): - """ DescribeUDBInstanceBinlog - 获取UDB指定时间段的binlog列表 - """ - - fields = { - "BeginTime": fields.Int(required=True, dump_to="BeginTime"), - "DBId": fields.Str(required=True, dump_to="DBId"), - "EndTime": fields.Int(required=True, dump_to="EndTime"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class DescribeUDBInstanceBinlogResponseSchema(schema.ResponseSchema): - """ DescribeUDBInstanceBinlog - 获取UDB指定时间段的binlog列表 - """ - - fields = { - "DataSet": fields.List( - models.UDBInstanceBinlogSetSchema(), required=False, load_from="DataSet" - ) - } - - -""" -API: DescribeUDBInstanceBinlogBackupState - -获取udb实例备份状态 -""" - - -class DescribeUDBInstanceBinlogBackupStateRequestSchema(schema.RequestSchema): - """ DescribeUDBInstanceBinlogBackupState - 获取udb实例备份状态 - """ - - fields = { - "BackupId": fields.Int(required=True, dump_to="BackupId"), - "BackupZone": fields.Str(required=False, dump_to="BackupZone"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class DescribeUDBInstanceBinlogBackupStateResponseSchema(schema.ResponseSchema): - """ DescribeUDBInstanceBinlogBackupState - 获取udb实例备份状态 - """ - - fields = { - "BackupSize": fields.Int(required=False, load_from="BackupSize"), - "State": fields.Str(required=False, load_from="State"), - } - - -""" -API: DescribeUDBInstancePrice - -获取UDB实例价格信息 -""" - - -class DescribeUDBInstancePriceRequestSchema(schema.RequestSchema): - """ DescribeUDBInstancePrice - 获取UDB实例价格信息 - """ - - fields = { - "ChargeType": fields.Str(required=False, dump_to="ChargeType"), - "Count": fields.Int(required=False, dump_to="Count"), - "DBTypeId": fields.Str(required=True, dump_to="DBTypeId"), - "DiskSpace": fields.Int(required=True, dump_to="DiskSpace"), - "InstanceMode": fields.Str(required=False, dump_to="InstanceMode"), - "MemoryLimit": fields.Int(required=True, dump_to="MemoryLimit"), - "Quantity": fields.Int(required=False, dump_to="Quantity"), - "Region": fields.Str(required=True, dump_to="Region"), - "SSDType": fields.Str(required=False, dump_to="SSDType"), - "UseSSD": fields.Bool(required=False, dump_to="UseSSD"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class DescribeUDBInstancePriceResponseSchema(schema.ResponseSchema): - """ DescribeUDBInstancePrice - 获取UDB实例价格信息 - """ - - fields = { - "DataSet": fields.List( - models.UDBInstancePriceSetSchema(), required=False, load_from="DataSet" - ) - } - - -""" -API: DescribeUDBInstanceState - -获取UDB实例状态 -""" - - -class DescribeUDBInstanceStateRequestSchema(schema.RequestSchema): - """ DescribeUDBInstanceState - 获取UDB实例状态 - """ - - fields = { - "DBId": fields.Str(required=True, dump_to="DBId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class DescribeUDBInstanceStateResponseSchema(schema.ResponseSchema): - """ DescribeUDBInstanceState - 获取UDB实例状态 - """ - - fields = {"State": fields.Str(required=False, load_from="State")} - - -""" -API: DescribeUDBInstanceUpgradePrice - -获取UDB实例升降级价格信息 -""" - - -class DescribeUDBInstanceUpgradePriceRequestSchema(schema.RequestSchema): - """ DescribeUDBInstanceUpgradePrice - 获取UDB实例升降级价格信息 - """ - - fields = { - "DBId": fields.Str(required=True, dump_to="DBId"), - "DiskSpace": fields.Int(required=True, dump_to="DiskSpace"), - "MemoryLimit": fields.Int(required=True, dump_to="MemoryLimit"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "SSDType": fields.Str(required=False, dump_to="SSDType"), - "UseSSD": fields.Bool(required=False, dump_to="UseSSD"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class DescribeUDBInstanceUpgradePriceResponseSchema(schema.ResponseSchema): - """ DescribeUDBInstanceUpgradePrice - 获取UDB实例升降级价格信息 - """ - - fields = {"Price": fields.Float(required=False, load_from="Price")} - - -""" -API: DescribeUDBLogBackupURL - -获取UDB的slowlog备份地址 -""" - - -class DescribeUDBLogBackupURLRequestSchema(schema.RequestSchema): - """ DescribeUDBLogBackupURL - 获取UDB的slowlog备份地址 - """ - - fields = { - "BackupId": fields.Int(required=True, dump_to="BackupId"), - "DBId": fields.Str(required=True, dump_to="DBId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class DescribeUDBLogBackupURLResponseSchema(schema.ResponseSchema): - """ DescribeUDBLogBackupURL - 获取UDB的slowlog备份地址 - """ - - fields = { - "BackupPath": fields.Str(required=False, load_from="BackupPath"), - "UsernetPath": fields.Str(required=False, load_from="UsernetPath"), - } - - -""" -API: DescribeUDBLogPackage - -列表UDB实例binlog或slowlog或errorlog备份信息 -""" - - -class DescribeUDBLogPackageRequestSchema(schema.RequestSchema): - """ DescribeUDBLogPackage - 列表UDB实例binlog或slowlog或errorlog备份信息 - """ - - fields = { - "BeginTime": fields.Int(required=False, dump_to="BeginTime"), - "DBId": fields.Str(required=False, dump_to="DBId"), - "EndTime": fields.Int(required=False, dump_to="EndTime"), - "Limit": fields.Int(required=True, dump_to="Limit"), - "Offset": fields.Int(required=True, dump_to="Offset"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Type": fields.Int(required=False, dump_to="Type"), - "Types": fields.List(fields.Int()), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class DescribeUDBLogPackageResponseSchema(schema.ResponseSchema): - """ DescribeUDBLogPackage - 列表UDB实例binlog或slowlog或errorlog备份信息 - """ - - fields = { - "DataSet": fields.List( - models.LogPackageDataSetSchema(), required=False, load_from="DataSet" - ), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - } - - -""" -API: DescribeUDBParamGroup - -获取参数组详细参数信息 -""" - - -class DescribeUDBParamGroupRequestSchema(schema.RequestSchema): - """ DescribeUDBParamGroup - 获取参数组详细参数信息 - """ - - fields = { - "ClassType": fields.Str(required=False, dump_to="ClassType"), - "GroupId": fields.Int(required=False, dump_to="GroupId"), - "IsInUDBC": fields.Bool(required=False, dump_to="IsInUDBC"), - "Limit": fields.Int(required=True, dump_to="Limit"), - "Offset": fields.Int(required=True, dump_to="Offset"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "RegionFlag": fields.Bool(required=False, dump_to="RegionFlag"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class DescribeUDBParamGroupResponseSchema(schema.ResponseSchema): - """ DescribeUDBParamGroup - 获取参数组详细参数信息 - """ - - fields = { - "DataSet": fields.List( - models.UDBParamGroupSetSchema(), required=False, load_from="DataSet" - ), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - } - - -""" -API: DescribeUDBType - -获取UDB支持的类型信息 -""" - - -class DescribeUDBTypeRequestSchema(schema.RequestSchema): - """ DescribeUDBType - 获取UDB支持的类型信息 - """ - - fields = { - "DBClusterType": fields.Str(required=False, dump_to="DBClusterType"), - "DiskType": fields.Str(required=False, dump_to="DiskType"), - "InstanceMode": fields.Str(required=False, dump_to="InstanceMode"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class DescribeUDBTypeResponseSchema(schema.ResponseSchema): - """ DescribeUDBType - 获取UDB支持的类型信息 - """ - - fields = { - "DataSet": fields.List( - models.UDBTypeSetSchema(), required=False, load_from="DataSet" - ) - } - - -""" -API: EditUDBBackupBlacklist - -编辑UDB实例的备份黑名单 -""" - - -class EditUDBBackupBlacklistRequestSchema(schema.RequestSchema): - """ EditUDBBackupBlacklist - 编辑UDB实例的备份黑名单 - """ - - fields = { - "Blacklist": fields.Str(required=True, dump_to="Blacklist"), - "DBId": fields.Str(required=True, dump_to="DBId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class EditUDBBackupBlacklistResponseSchema(schema.ResponseSchema): - """ EditUDBBackupBlacklist - 编辑UDB实例的备份黑名单 - """ - - fields = {} - - -""" -API: FetchUDBInstanceEarliestRecoverTime - -获取UDB最早可回档的时间点 -""" - - -class FetchUDBInstanceEarliestRecoverTimeRequestSchema(schema.RequestSchema): - """ FetchUDBInstanceEarliestRecoverTime - 获取UDB最早可回档的时间点 - """ - - fields = { - "DBId": fields.Str(required=True, dump_to="DBId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class FetchUDBInstanceEarliestRecoverTimeResponseSchema(schema.ResponseSchema): - """ FetchUDBInstanceEarliestRecoverTime - 获取UDB最早可回档的时间点 - """ - - fields = {"EarliestTime": fields.Int(required=False, load_from="EarliestTime")} - - -""" -API: ModifyUDBInstanceName - -重命名UDB实例 -""" - - -class ModifyUDBInstanceNameRequestSchema(schema.RequestSchema): - """ ModifyUDBInstanceName - 重命名UDB实例 - """ - - fields = { - "DBId": fields.Str(required=True, dump_to="DBId"), - "Name": fields.Str(required=True, dump_to="Name"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class ModifyUDBInstanceNameResponseSchema(schema.ResponseSchema): - """ ModifyUDBInstanceName - 重命名UDB实例 - """ - - fields = {} - - -""" -API: ModifyUDBInstancePassword - -修改DB实例的管理员密码 -""" - - -class ModifyUDBInstancePasswordRequestSchema(schema.RequestSchema): - """ ModifyUDBInstancePassword - 修改DB实例的管理员密码 - """ - - fields = { - "AccountName": fields.Str(required=False, dump_to="AccountName"), - "DBId": fields.Str(required=True, dump_to="DBId"), - "Password": fields.Str(required=True, dump_to="Password"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class ModifyUDBInstancePasswordResponseSchema(schema.ResponseSchema): - """ ModifyUDBInstancePassword - 修改DB实例的管理员密码 - """ - - fields = {} - - -""" -API: PromoteUDBInstanceToHA - -普通db升级为高可用(只针对mysql5.5及以上版本) -""" - - -class PromoteUDBInstanceToHARequestSchema(schema.RequestSchema): - """ PromoteUDBInstanceToHA - 普通db升级为高可用(只针对mysql5.5及以上版本) - """ - - fields = { - "DBId": fields.Str(required=True, dump_to="DBId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - } - - -class PromoteUDBInstanceToHAResponseSchema(schema.ResponseSchema): - """ PromoteUDBInstanceToHA - 普通db升级为高可用(只针对mysql5.5及以上版本) - """ - - fields = {} - - -""" -API: PromoteUDBSlave - -从库提升为独立库 -""" - - -class PromoteUDBSlaveRequestSchema(schema.RequestSchema): - """ PromoteUDBSlave - 从库提升为独立库 - """ - - fields = { - "DBId": fields.Str(required=True, dump_to="DBId"), - "IsForce": fields.Bool(required=False, dump_to="IsForce"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class PromoteUDBSlaveResponseSchema(schema.ResponseSchema): - """ PromoteUDBSlave - 从库提升为独立库 - """ - - fields = {} - - -""" -API: ResizeUDBInstance - -修改(升级和降级)UDB实例的配置,包括内存和磁盘的配置,对于内存升级无需关闭实例,其他场景需要事先关闭实例。两套参数可以配置升降机:1.配置UseSSD和SSDType 2.配置InstanceType,不需要配置InstanceMode。这两套第二套参数的优先级更高 -""" - - -class ResizeUDBInstanceRequestSchema(schema.RequestSchema): - """ ResizeUDBInstance - 修改(升级和降级)UDB实例的配置,包括内存和磁盘的配置,对于内存升级无需关闭实例,其他场景需要事先关闭实例。两套参数可以配置升降机:1.配置UseSSD和SSDType 2.配置InstanceType,不需要配置InstanceMode。这两套第二套参数的优先级更高 - """ - - fields = { - "CouponId": fields.Str(required=False, dump_to="CouponId"), - "DBId": fields.Str(required=True, dump_to="DBId"), - "DiskSpace": fields.Int(required=True, dump_to="DiskSpace"), - "InstanceMode": fields.Str(required=False, dump_to="InstanceMode"), - "InstanceType": fields.Str(required=False, dump_to="InstanceType"), - "MemoryLimit": fields.Int(required=True, dump_to="MemoryLimit"), - "ProjectId": fields.Int(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "SSDType": fields.Str(required=False, dump_to="SSDType"), - "StartAfterUpgrade": fields.Bool(required=False, dump_to="StartAfterUpgrade"), - "UDBCId": fields.Str(required=False, dump_to="UDBCId"), - "UseSSD": fields.Bool(required=False, dump_to="UseSSD"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class ResizeUDBInstanceResponseSchema(schema.ResponseSchema): - """ ResizeUDBInstance - 修改(升级和降级)UDB实例的配置,包括内存和磁盘的配置,对于内存升级无需关闭实例,其他场景需要事先关闭实例。两套参数可以配置升降机:1.配置UseSSD和SSDType 2.配置InstanceType,不需要配置InstanceMode。这两套第二套参数的优先级更高 - """ - - fields = {} - - -""" -API: RestartUDBInstance - -重启UDB实例 -""" - - -class RestartUDBInstanceRequestSchema(schema.RequestSchema): - """ RestartUDBInstance - 重启UDB实例 - """ - - fields = { - "DBId": fields.Str(required=True, dump_to="DBId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class RestartUDBInstanceResponseSchema(schema.ResponseSchema): - """ RestartUDBInstance - 重启UDB实例 - """ - - fields = {} - - -""" -API: StartUDBInstance - -启动UDB实例 -""" - - -class StartUDBInstanceRequestSchema(schema.RequestSchema): - """ StartUDBInstance - 启动UDB实例 - """ - - fields = { - "DBId": fields.Str(required=True, dump_to="DBId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class StartUDBInstanceResponseSchema(schema.ResponseSchema): - """ StartUDBInstance - 启动UDB实例 - """ - - fields = {} - - -""" -API: StopUDBInstance - -关闭UDB实例 -""" - - -class StopUDBInstanceRequestSchema(schema.RequestSchema): - """ StopUDBInstance - 关闭UDB实例 - """ - - fields = { - "DBId": fields.Str(required=True, dump_to="DBId"), - "ForceToKill": fields.Bool(required=False, dump_to="ForceToKill"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class StopUDBInstanceResponseSchema(schema.ResponseSchema): - """ StopUDBInstance - 关闭UDB实例 - """ - - fields = {} - - -""" -API: SwitchUDBInstanceToHA - -普通UDB切换为高可用,原db状态为WaitForSwitch时,调用该api -""" - - -class SwitchUDBInstanceToHARequestSchema(schema.RequestSchema): - """ SwitchUDBInstanceToHA - 普通UDB切换为高可用,原db状态为WaitForSwitch时,调用该api - """ - - fields = { - "ChargeType": fields.Str(required=False, dump_to="ChargeType"), - "DBId": fields.Str(required=True, dump_to="DBId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Quantity": fields.Str(required=False, dump_to="Quantity"), - "Region": fields.Str(required=True, dump_to="Region"), - "Tag": fields.Str(required=False, dump_to="Tag"), - } - - -class SwitchUDBInstanceToHAResponseSchema(schema.ResponseSchema): - """ SwitchUDBInstanceToHA - 普通UDB切换为高可用,原db状态为WaitForSwitch时,调用该api - """ - - fields = {"DBId": fields.Str(required=False, load_from="DBId")} - - -""" -API: UpdateUDBInstanceBackupStrategy - -修改UDB自动备份策略 -""" - - -class UpdateUDBInstanceBackupStrategyRequestSchema(schema.RequestSchema): - """ UpdateUDBInstanceBackupStrategy - 修改UDB自动备份策略 - """ - - fields = { - "BackupDate": fields.Str(required=False, dump_to="BackupDate"), - "BackupMethod": fields.Str(required=False, dump_to="BackupMethod"), - "BackupTime": fields.Int(required=False, dump_to="BackupTime"), - "DBId": fields.Str(required=True, dump_to="DBId"), - "ForceDump": fields.Bool(required=False, dump_to="ForceDump"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class UpdateUDBInstanceBackupStrategyResponseSchema(schema.ResponseSchema): - """ UpdateUDBInstanceBackupStrategy - 修改UDB自动备份策略 - """ - - fields = {} - - -""" -API: UpdateUDBInstanceSlaveBackupSwitch - -开启或者关闭UDB从库备份 -""" - - -class UpdateUDBInstanceSlaveBackupSwitchRequestSchema(schema.RequestSchema): - """ UpdateUDBInstanceSlaveBackupSwitch - 开启或者关闭UDB从库备份 - """ - - fields = { - "BackupSwitch": fields.Int(required=True, dump_to="BackupSwitch"), - "MasterDBId": fields.Str(required=True, dump_to="MasterDBId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "SlaveDBId": fields.Str(required=False, dump_to="SlaveDBId"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class UpdateUDBInstanceSlaveBackupSwitchResponseSchema(schema.ResponseSchema): - """ UpdateUDBInstanceSlaveBackupSwitch - 开启或者关闭UDB从库备份 - """ - - fields = {} - - -""" -API: UpdateUDBParamGroup - -更新UDB配置参数项 -""" - - -class UpdateUDBParamGroupRequestSchema(schema.RequestSchema): - """ UpdateUDBParamGroup - 更新UDB配置参数项 - """ - - fields = { - "Description": fields.Str(required=False, dump_to="Description"), - "GroupId": fields.Int(required=True, dump_to="GroupId"), - "Key": fields.Str(required=False, dump_to="Key"), - "Name": fields.Str(required=False, dump_to="Name"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "RegionFlag": fields.Bool(required=False, dump_to="RegionFlag"), - "Value": fields.Str(required=False, dump_to="Value"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class UpdateUDBParamGroupResponseSchema(schema.ResponseSchema): - """ UpdateUDBParamGroup - 更新UDB配置参数项 - """ - - fields = {} - - -""" -API: UploadUDBParamGroup - -导入UDB配置 -""" - - -class UploadUDBParamGroupRequestSchema(schema.RequestSchema): - """ UploadUDBParamGroup - 导入UDB配置 - """ - - fields = { - "Content": fields.Str(required=True, dump_to="Content"), - "DBTypeId": fields.Str(required=True, dump_to="DBTypeId"), - "Description": fields.Str(required=True, dump_to="Description"), - "GroupName": fields.Str(required=True, dump_to="GroupName"), - "ParamGroupTypeId": fields.Int(required=False, dump_to="ParamGroupTypeId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "RegionFlag": fields.Bool(required=False, dump_to="RegionFlag"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class UploadUDBParamGroupResponseSchema(schema.ResponseSchema): - """ UploadUDBParamGroup - 导入UDB配置 - """ - - fields = {"GroupId": fields.Int(required=False, load_from="GroupId")} +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.typesystem import schema, fields +from ucloud.services.udb.schemas import models + +""" UDB API Schema +""" +""" +API: BackupUDBInstance + +备份UDB实例 +""" + + +class BackupUDBInstanceRequestSchema(schema.RequestSchema): + """ BackupUDBInstance - 备份UDB实例 + """ + + fields = { + "BackupMethod": fields.Str(required=False, dump_to="BackupMethod"), + "BackupName": fields.Str(required=True, dump_to="BackupName"), + "Blacklist": fields.Str(required=False, dump_to="Blacklist"), + "DBId": fields.Str(required=True, dump_to="DBId"), + "ForceBackup": fields.Bool(required=False, dump_to="ForceBackup"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "UseBlacklist": fields.Bool(required=False, dump_to="UseBlacklist"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class BackupUDBInstanceResponseSchema(schema.ResponseSchema): + """ BackupUDBInstance - 备份UDB实例 + """ + + fields = {} + + +""" +API: BackupUDBInstanceBinlog + +备份UDB指定时间段的binlog列表 +""" + + +class BackupUDBInstanceBinlogRequestSchema(schema.RequestSchema): + """ BackupUDBInstanceBinlog - 备份UDB指定时间段的binlog列表 + """ + + fields = { + "BackupFile": fields.Str(required=True, dump_to="BackupFile"), + "BackupName": fields.Str(required=False, dump_to="BackupName"), + "DBId": fields.Str(required=True, dump_to="DBId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class BackupUDBInstanceBinlogResponseSchema(schema.ResponseSchema): + """ BackupUDBInstanceBinlog - 备份UDB指定时间段的binlog列表 + """ + + fields = {} + + +""" +API: BackupUDBInstanceErrorLog + +备份UDB指定时间段的errorlog +""" + + +class BackupUDBInstanceErrorLogRequestSchema(schema.RequestSchema): + """ BackupUDBInstanceErrorLog - 备份UDB指定时间段的errorlog + """ + + fields = { + "BackupName": fields.Str(required=True, dump_to="BackupName"), + "DBId": fields.Str(required=True, dump_to="DBId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class BackupUDBInstanceErrorLogResponseSchema(schema.ResponseSchema): + """ BackupUDBInstanceErrorLog - 备份UDB指定时间段的errorlog + """ + + fields = {} + + +""" +API: BackupUDBInstanceSlowLog + +备份UDB指定时间段的slowlog分析结果 +""" + + +class BackupUDBInstanceSlowLogRequestSchema(schema.RequestSchema): + """ BackupUDBInstanceSlowLog - 备份UDB指定时间段的slowlog分析结果 + """ + + fields = { + "BackupName": fields.Str(required=True, dump_to="BackupName"), + "BeginTime": fields.Int(required=True, dump_to="BeginTime"), + "DBId": fields.Str(required=True, dump_to="DBId"), + "EndTime": fields.Int(required=True, dump_to="EndTime"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + } + + +class BackupUDBInstanceSlowLogResponseSchema(schema.ResponseSchema): + """ BackupUDBInstanceSlowLog - 备份UDB指定时间段的slowlog分析结果 + """ + + fields = {} + + +""" +API: CheckRecoverUDBInstance + +核查db是否可以使用回档功能 +""" + + +class CheckRecoverUDBInstanceRequestSchema(schema.RequestSchema): + """ CheckRecoverUDBInstance - 核查db是否可以使用回档功能 + """ + + fields = { + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "SrcDBId": fields.Str(required=True, dump_to="SrcDBId"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class CheckRecoverUDBInstanceResponseSchema(schema.ResponseSchema): + """ CheckRecoverUDBInstance - 核查db是否可以使用回档功能 + """ + + fields = { + "LastestTime": fields.Int(required=False, load_from="LastestTime") + } + + +""" +API: CheckUDBInstanceToHAAllowance + +核查db是否可以升级为高可用 +""" + + +class CheckUDBInstanceToHAAllowanceRequestSchema(schema.RequestSchema): + """ CheckUDBInstanceToHAAllowance - 核查db是否可以升级为高可用 + """ + + fields = { + "DBId": fields.Str(required=True, dump_to="DBId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + } + + +class CheckUDBInstanceToHAAllowanceResponseSchema(schema.ResponseSchema): + """ CheckUDBInstanceToHAAllowance - 核查db是否可以升级为高可用 + """ + + fields = {"Allowance": fields.Str(required=False, load_from="Allowance")} + + +""" +API: ClearUDBLog + +清除UDB实例的log +""" + + +class ClearUDBLogRequestSchema(schema.RequestSchema): + """ ClearUDBLog - 清除UDB实例的log + """ + + fields = { + "BeforeTime": fields.Int(required=False, dump_to="BeforeTime"), + "DBId": fields.Str(required=True, dump_to="DBId"), + "LogType": fields.Int(required=True, dump_to="LogType"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class ClearUDBLogResponseSchema(schema.ResponseSchema): + """ ClearUDBLog - 清除UDB实例的log + """ + + fields = {} + + +""" +API: CreateUDBInstance + +创建UDB实例(包括创建mysql master节点、mongodb primary/configsvr节点和从备份恢复实例) +""" + + +class CreateUDBInstanceRequestSchema(schema.RequestSchema): + """ CreateUDBInstance - 创建UDB实例(包括创建mysql master节点、mongodb primary/configsvr节点和从备份恢复实例) + """ + + fields = { + "AdminPassword": fields.Str(required=True, dump_to="AdminPassword"), + "AdminUser": fields.Str(required=False, dump_to="AdminUser"), + "BackupCount": fields.Int(required=False, dump_to="BackupCount"), + "BackupDuration": fields.Int(required=False, dump_to="BackupDuration"), + "BackupId": fields.Int(required=False, dump_to="BackupId"), + "BackupTime": fields.Int(required=False, dump_to="BackupTime"), + "BackupZone": fields.Str(required=False, dump_to="BackupZone"), + "CPU": fields.Int(required=False, dump_to="CPU"), + "ChargeType": fields.Str(required=False, dump_to="ChargeType"), + "ClusterRole": fields.Str(required=False, dump_to="ClusterRole"), + "CouponId": fields.Str(required=False, dump_to="CouponId"), + "DBTypeId": fields.Str(required=True, dump_to="DBTypeId"), + "DisableSemisync": fields.Bool( + required=False, dump_to="DisableSemisync" + ), + "DiskSpace": fields.Int(required=True, dump_to="DiskSpace"), + "HAArch": fields.Str(required=False, dump_to="HAArch"), + "InstanceMode": fields.Str(required=False, dump_to="InstanceMode"), + "InstanceType": fields.Str(required=False, dump_to="InstanceType"), + "MemoryLimit": fields.Int(required=True, dump_to="MemoryLimit"), + "Name": fields.Str(required=True, dump_to="Name"), + "ParamGroupId": fields.Int(required=True, dump_to="ParamGroupId"), + "Port": fields.Int(required=True, dump_to="Port"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Quantity": fields.Int(required=False, dump_to="Quantity"), + "Region": fields.Str(required=True, dump_to="Region"), + "SSDType": fields.Str(required=False, dump_to="SSDType"), + "SubnetId": fields.Str(required=False, dump_to="SubnetId"), + "Tag": fields.Str(required=False, dump_to="Tag"), + "UDBCId": fields.Str(required=False, dump_to="UDBCId"), + "UseSSD": fields.Bool(required=False, dump_to="UseSSD"), + "VPCId": fields.Str(required=False, dump_to="VPCId"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class CreateUDBInstanceResponseSchema(schema.ResponseSchema): + """ CreateUDBInstance - 创建UDB实例(包括创建mysql master节点、mongodb primary/configsvr节点和从备份恢复实例) + """ + + fields = {"DBId": fields.Str(required=False, load_from="DBId")} + + +""" +API: CreateUDBInstanceByRecovery + +创建db,将新创建的db恢复到指定db某个指定时间点 +""" + + +class CreateUDBInstanceByRecoveryRequestSchema(schema.RequestSchema): + """ CreateUDBInstanceByRecovery - 创建db,将新创建的db恢复到指定db某个指定时间点 + """ + + fields = { + "ChargeType": fields.Str(required=False, dump_to="ChargeType"), + "CouponId": fields.Str(required=False, dump_to="CouponId"), + "Name": fields.Str(required=True, dump_to="Name"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Quantity": fields.Int(required=False, dump_to="Quantity"), + "RecoveryTime": fields.Int(required=True, dump_to="RecoveryTime"), + "Region": fields.Str(required=True, dump_to="Region"), + "SrcDBId": fields.Str(required=True, dump_to="SrcDBId"), + "SubnetId": fields.Str(required=False, dump_to="SubnetId"), + "UDBCId": fields.Str(required=False, dump_to="UDBCId"), + "UseSSD": fields.Bool(required=False, dump_to="UseSSD"), + "VPCId": fields.Str(required=False, dump_to="VPCId"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class CreateUDBInstanceByRecoveryResponseSchema(schema.ResponseSchema): + """ CreateUDBInstanceByRecovery - 创建db,将新创建的db恢复到指定db某个指定时间点 + """ + + fields = {"DBId": fields.Str(required=False, load_from="DBId")} + + +""" +API: CreateUDBParamGroup + +从已有配置文件创建新配置文件 +""" + + +class CreateUDBParamGroupRequestSchema(schema.RequestSchema): + """ CreateUDBParamGroup - 从已有配置文件创建新配置文件 + """ + + fields = { + "DBTypeId": fields.Str(required=True, dump_to="DBTypeId"), + "Description": fields.Str(required=True, dump_to="Description"), + "GroupName": fields.Str(required=True, dump_to="GroupName"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "RegionFlag": fields.Bool(required=False, dump_to="RegionFlag"), + "SrcGroupId": fields.Int(required=True, dump_to="SrcGroupId"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class CreateUDBParamGroupResponseSchema(schema.ResponseSchema): + """ CreateUDBParamGroup - 从已有配置文件创建新配置文件 + """ + + fields = {"GroupId": fields.Int(required=False, load_from="GroupId")} + + +""" +API: CreateUDBReplicationInstance + +创建MongoDB的副本节点(包括仲裁) +""" + + +class CreateUDBReplicationInstanceRequestSchema(schema.RequestSchema): + """ CreateUDBReplicationInstance - 创建MongoDB的副本节点(包括仲裁) + """ + + fields = { + "CouponId": fields.Str(required=False, dump_to="CouponId"), + "IsArbiter": fields.Bool(required=False, dump_to="IsArbiter"), + "Name": fields.Str(required=True, dump_to="Name"), + "Port": fields.Int(required=False, dump_to="Port"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "SrcId": fields.Str(required=True, dump_to="SrcId"), + "UseSSD": fields.Bool(required=False, dump_to="UseSSD"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class CreateUDBReplicationInstanceResponseSchema(schema.ResponseSchema): + """ CreateUDBReplicationInstance - 创建MongoDB的副本节点(包括仲裁) + """ + + fields = {"DBId": fields.Str(required=False, load_from="DBId")} + + +""" +API: CreateUDBRouteInstance + +创建mongos实例 +""" + + +class CreateUDBRouteInstanceRequestSchema(schema.RequestSchema): + """ CreateUDBRouteInstance - 创建mongos实例 + """ + + fields = { + "ChargeType": fields.Str(required=False, dump_to="ChargeType"), + "ConfigsvrId": fields.List(fields.Str()), + "CouponId": fields.Str(required=False, dump_to="CouponId"), + "DBTypeId": fields.Str(required=True, dump_to="DBTypeId"), + "DiskSpace": fields.Int(required=True, dump_to="DiskSpace"), + "MemoryLimit": fields.Int(required=True, dump_to="MemoryLimit"), + "Name": fields.Str(required=True, dump_to="Name"), + "ParamGroupId": fields.Int(required=True, dump_to="ParamGroupId"), + "Port": fields.Int(required=True, dump_to="Port"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Quantity": fields.Int(required=False, dump_to="Quantity"), + "Region": fields.Str(required=True, dump_to="Region"), + "UseSSD": fields.Bool(required=False, dump_to="UseSSD"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class CreateUDBRouteInstanceResponseSchema(schema.ResponseSchema): + """ CreateUDBRouteInstance - 创建mongos实例 + """ + + fields = {"DBId": fields.Str(required=False, load_from="DBId")} + + +""" +API: CreateUDBSlave + +创建UDB实例的slave +""" + + +class CreateUDBSlaveRequestSchema(schema.RequestSchema): + """ CreateUDBSlave - 创建UDB实例的slave + """ + + fields = { + "CouponId": fields.Str(required=False, dump_to="CouponId"), + "DiskSpace": fields.Int(required=False, dump_to="DiskSpace"), + "InstanceMode": fields.Str(required=False, dump_to="InstanceMode"), + "InstanceType": fields.Str(required=False, dump_to="InstanceType"), + "IsLock": fields.Bool(required=False, dump_to="IsLock"), + "MemoryLimit": fields.Int(required=False, dump_to="MemoryLimit"), + "Name": fields.Str(required=True, dump_to="Name"), + "Port": fields.Int(required=False, dump_to="Port"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "SSDType": fields.Str(required=False, dump_to="SSDType"), + "SrcId": fields.Str(required=True, dump_to="SrcId"), + "UseSSD": fields.Bool(required=False, dump_to="UseSSD"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class CreateUDBSlaveResponseSchema(schema.ResponseSchema): + """ CreateUDBSlave - 创建UDB实例的slave + """ + + fields = {"DBId": fields.Str(required=False, load_from="DBId")} + + +""" +API: DeleteUDBBackup + +删除UDB实例备份 +""" + + +class DeleteUDBBackupRequestSchema(schema.RequestSchema): + """ DeleteUDBBackup - 删除UDB实例备份 + """ + + fields = { + "BackupId": fields.Int(required=True, dump_to="BackupId"), + "BackupZone": fields.Str(required=False, dump_to="BackupZone"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class DeleteUDBBackupResponseSchema(schema.ResponseSchema): + """ DeleteUDBBackup - 删除UDB实例备份 + """ + + fields = {} + + +""" +API: DeleteUDBInstance + +删除UDB实例 +""" + + +class DeleteUDBInstanceRequestSchema(schema.RequestSchema): + """ DeleteUDBInstance - 删除UDB实例 + """ + + fields = { + "DBId": fields.Str(required=True, dump_to="DBId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "UDBCId": fields.Str(required=False, dump_to="UDBCId"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class DeleteUDBInstanceResponseSchema(schema.ResponseSchema): + """ DeleteUDBInstance - 删除UDB实例 + """ + + fields = {} + + +""" +API: DeleteUDBLogPackage + +删除UDB日志包 +""" + + +class DeleteUDBLogPackageRequestSchema(schema.RequestSchema): + """ DeleteUDBLogPackage - 删除UDB日志包 + """ + + fields = { + "BackupId": fields.Int(required=True, dump_to="BackupId"), + "BackupZone": fields.Str(required=False, dump_to="BackupZone"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class DeleteUDBLogPackageResponseSchema(schema.ResponseSchema): + """ DeleteUDBLogPackage - 删除UDB日志包 + """ + + fields = {} + + +""" +API: DeleteUDBParamGroup + +删除配置参数组 +""" + + +class DeleteUDBParamGroupRequestSchema(schema.RequestSchema): + """ DeleteUDBParamGroup - 删除配置参数组 + """ + + fields = { + "GroupId": fields.Int(required=True, dump_to="GroupId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "RegionFlag": fields.Bool(required=False, dump_to="RegionFlag"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class DeleteUDBParamGroupResponseSchema(schema.ResponseSchema): + """ DeleteUDBParamGroup - 删除配置参数组 + """ + + fields = {} + + +""" +API: DescribeUDBBackup + +列表UDB实例备份信息.Zone不填表示多可用区,填代表单可用区 +""" + + +class DescribeUDBBackupRequestSchema(schema.RequestSchema): + """ DescribeUDBBackup - 列表UDB实例备份信息.Zone不填表示多可用区,填代表单可用区 + """ + + fields = { + "BackupId": fields.Int(required=False, dump_to="BackupId"), + "BackupType": fields.Int(required=False, dump_to="BackupType"), + "BeginTime": fields.Int(required=False, dump_to="BeginTime"), + "ClassType": fields.Str(required=False, dump_to="ClassType"), + "DBId": fields.Str(required=False, dump_to="DBId"), + "EndTime": fields.Int(required=False, dump_to="EndTime"), + "Limit": fields.Int(required=True, dump_to="Limit"), + "Offset": fields.Int(required=True, dump_to="Offset"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class DescribeUDBBackupResponseSchema(schema.ResponseSchema): + """ DescribeUDBBackup - 列表UDB实例备份信息.Zone不填表示多可用区,填代表单可用区 + """ + + fields = { + "DataSet": fields.List( + models.UDBBackupSetSchema(), required=False, load_from="DataSet" + ), + "TotalCount": fields.Int(required=False, load_from="TotalCount"), + } + + +""" +API: DescribeUDBBackupBlacklist + +获取UDB实例的备份黑名单 +""" + + +class DescribeUDBBackupBlacklistRequestSchema(schema.RequestSchema): + """ DescribeUDBBackupBlacklist - 获取UDB实例的备份黑名单 + """ + + fields = { + "DBId": fields.Str(required=True, dump_to="DBId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class DescribeUDBBackupBlacklistResponseSchema(schema.ResponseSchema): + """ DescribeUDBBackupBlacklist - 获取UDB实例的备份黑名单 + """ + + fields = {"Blacklist": fields.Str(required=False, load_from="Blacklist")} + + +""" +API: DescribeUDBBinlogBackupURL + +获取UDB的Binlog备份地址 +""" + + +class DescribeUDBBinlogBackupURLRequestSchema(schema.RequestSchema): + """ DescribeUDBBinlogBackupURL - 获取UDB的Binlog备份地址 + """ + + fields = { + "BackupId": fields.Int(required=True, dump_to="BackupId"), + "DBId": fields.Str(required=True, dump_to="DBId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class DescribeUDBBinlogBackupURLResponseSchema(schema.ResponseSchema): + """ DescribeUDBBinlogBackupURL - 获取UDB的Binlog备份地址 + """ + + fields = { + "BackupPath": fields.Str(required=False, load_from="BackupPath"), + "InnerBackupPath": fields.Str( + required=False, load_from="InnerBackupPath" + ), + } + + +""" +API: DescribeUDBInstance + +获取UDB实例信息,支持两类操作:(1)指定DBId用于获取该db的信息;(2)指定ClassType、Offset、Limit用于列表操作,查询某一个类型db。 +""" + + +class DescribeUDBInstanceRequestSchema(schema.RequestSchema): + """ DescribeUDBInstance - 获取UDB实例信息,支持两类操作:(1)指定DBId用于获取该db的信息;(2)指定ClassType、Offset、Limit用于列表操作,查询某一个类型db。 + """ + + fields = { + "ClassType": fields.Str(required=False, dump_to="ClassType"), + "DBId": fields.Str(required=False, dump_to="DBId"), + "IncludeSlaves": fields.Bool(required=False, dump_to="IncludeSlaves"), + "IsInUDBC": fields.Bool(required=False, dump_to="IsInUDBC"), + "Limit": fields.Int(required=False, dump_to="Limit"), + "Offset": fields.Int(required=False, dump_to="Offset"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "UDBCId": fields.Str(required=False, dump_to="UDBCId"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class DescribeUDBInstanceResponseSchema(schema.ResponseSchema): + """ DescribeUDBInstance - 获取UDB实例信息,支持两类操作:(1)指定DBId用于获取该db的信息;(2)指定ClassType、Offset、Limit用于列表操作,查询某一个类型db。 + """ + + fields = { + "DataSet": fields.List( + models.UDBInstanceSetSchema(), required=False, load_from="DataSet" + ), + "TotalCount": fields.Int(required=False, load_from="TotalCount"), + } + + +""" +API: DescribeUDBInstanceBackupState + +获取UDB实例备份状态 +""" + + +class DescribeUDBInstanceBackupStateRequestSchema(schema.RequestSchema): + """ DescribeUDBInstanceBackupState - 获取UDB实例备份状态 + """ + + fields = { + "BackupId": fields.Int(required=True, dump_to="BackupId"), + "BackupZone": fields.Str(required=False, dump_to="BackupZone"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class DescribeUDBInstanceBackupStateResponseSchema(schema.ResponseSchema): + """ DescribeUDBInstanceBackupState - 获取UDB实例备份状态 + """ + + fields = { + "BackupEndTime": fields.Int(required=False, load_from="BackupEndTime"), + "BackupSize": fields.Int(required=False, load_from="BackupSize"), + "State": fields.Str(required=False, load_from="State"), + } + + +""" +API: DescribeUDBInstanceBackupURL + +获取UDB备份下载地址 +""" + + +class DescribeUDBInstanceBackupURLRequestSchema(schema.RequestSchema): + """ DescribeUDBInstanceBackupURL - 获取UDB备份下载地址 + """ + + fields = { + "BackupId": fields.Int(required=True, dump_to="BackupId"), + "DBId": fields.Str(required=True, dump_to="DBId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class DescribeUDBInstanceBackupURLResponseSchema(schema.ResponseSchema): + """ DescribeUDBInstanceBackupURL - 获取UDB备份下载地址 + """ + + fields = { + "BackupPath": fields.Str(required=False, load_from="BackupPath"), + "InnerBackupPath": fields.Str( + required=False, load_from="InnerBackupPath" + ), + } + + +""" +API: DescribeUDBInstanceBinlog + +获取UDB指定时间段的binlog列表 +""" + + +class DescribeUDBInstanceBinlogRequestSchema(schema.RequestSchema): + """ DescribeUDBInstanceBinlog - 获取UDB指定时间段的binlog列表 + """ + + fields = { + "BeginTime": fields.Int(required=True, dump_to="BeginTime"), + "DBId": fields.Str(required=True, dump_to="DBId"), + "EndTime": fields.Int(required=True, dump_to="EndTime"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class DescribeUDBInstanceBinlogResponseSchema(schema.ResponseSchema): + """ DescribeUDBInstanceBinlog - 获取UDB指定时间段的binlog列表 + """ + + fields = { + "DataSet": fields.List( + models.UDBInstanceBinlogSetSchema(), + required=False, + load_from="DataSet", + ) + } + + +""" +API: DescribeUDBInstanceBinlogBackupState + +获取udb实例备份状态 +""" + + +class DescribeUDBInstanceBinlogBackupStateRequestSchema(schema.RequestSchema): + """ DescribeUDBInstanceBinlogBackupState - 获取udb实例备份状态 + """ + + fields = { + "BackupId": fields.Int(required=True, dump_to="BackupId"), + "BackupZone": fields.Str(required=False, dump_to="BackupZone"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class DescribeUDBInstanceBinlogBackupStateResponseSchema(schema.ResponseSchema): + """ DescribeUDBInstanceBinlogBackupState - 获取udb实例备份状态 + """ + + fields = { + "BackupSize": fields.Int(required=False, load_from="BackupSize"), + "State": fields.Str(required=False, load_from="State"), + } + + +""" +API: DescribeUDBInstancePrice + +获取UDB实例价格信息 +""" + + +class DescribeUDBInstancePriceRequestSchema(schema.RequestSchema): + """ DescribeUDBInstancePrice - 获取UDB实例价格信息 + """ + + fields = { + "ChargeType": fields.Str(required=False, dump_to="ChargeType"), + "Count": fields.Int(required=False, dump_to="Count"), + "DBTypeId": fields.Str(required=True, dump_to="DBTypeId"), + "DiskSpace": fields.Int(required=True, dump_to="DiskSpace"), + "InstanceMode": fields.Str(required=False, dump_to="InstanceMode"), + "MemoryLimit": fields.Int(required=True, dump_to="MemoryLimit"), + "Quantity": fields.Int(required=False, dump_to="Quantity"), + "Region": fields.Str(required=True, dump_to="Region"), + "SSDType": fields.Str(required=False, dump_to="SSDType"), + "UseSSD": fields.Str(required=False, dump_to="UseSSD"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class DescribeUDBInstancePriceResponseSchema(schema.ResponseSchema): + """ DescribeUDBInstancePrice - 获取UDB实例价格信息 + """ + + fields = { + "DataSet": fields.List( + models.UDBInstancePriceSetSchema(), + required=False, + load_from="DataSet", + ) + } + + +""" +API: DescribeUDBInstanceState + +获取UDB实例状态 +""" + + +class DescribeUDBInstanceStateRequestSchema(schema.RequestSchema): + """ DescribeUDBInstanceState - 获取UDB实例状态 + """ + + fields = { + "DBId": fields.Str(required=True, dump_to="DBId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class DescribeUDBInstanceStateResponseSchema(schema.ResponseSchema): + """ DescribeUDBInstanceState - 获取UDB实例状态 + """ + + fields = {"State": fields.Str(required=False, load_from="State")} + + +""" +API: DescribeUDBInstanceUpgradePrice + +获取UDB实例升降级价格信息 +""" + + +class DescribeUDBInstanceUpgradePriceRequestSchema(schema.RequestSchema): + """ DescribeUDBInstanceUpgradePrice - 获取UDB实例升降级价格信息 + """ + + fields = { + "DBId": fields.Str(required=True, dump_to="DBId"), + "DiskSpace": fields.Int(required=True, dump_to="DiskSpace"), + "MemoryLimit": fields.Int(required=True, dump_to="MemoryLimit"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "SSDType": fields.Str(required=False, dump_to="SSDType"), + "UseSSD": fields.Bool(required=False, dump_to="UseSSD"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class DescribeUDBInstanceUpgradePriceResponseSchema(schema.ResponseSchema): + """ DescribeUDBInstanceUpgradePrice - 获取UDB实例升降级价格信息 + """ + + fields = {"Price": fields.Int(required=False, load_from="Price")} + + +""" +API: DescribeUDBLogBackupURL + +获取UDB的slowlog备份地址 +""" + + +class DescribeUDBLogBackupURLRequestSchema(schema.RequestSchema): + """ DescribeUDBLogBackupURL - 获取UDB的slowlog备份地址 + """ + + fields = { + "BackupId": fields.Int(required=True, dump_to="BackupId"), + "DBId": fields.Str(required=True, dump_to="DBId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class DescribeUDBLogBackupURLResponseSchema(schema.ResponseSchema): + """ DescribeUDBLogBackupURL - 获取UDB的slowlog备份地址 + """ + + fields = { + "BackupPath": fields.Str(required=False, load_from="BackupPath"), + "UsernetPath": fields.Str(required=False, load_from="UsernetPath"), + } + + +""" +API: DescribeUDBLogPackage + +列表UDB实例binlog或slowlog或errorlog备份信息 +""" + + +class DescribeUDBLogPackageRequestSchema(schema.RequestSchema): + """ DescribeUDBLogPackage - 列表UDB实例binlog或slowlog或errorlog备份信息 + """ + + fields = { + "BeginTime": fields.Int(required=False, dump_to="BeginTime"), + "DBId": fields.Str(required=False, dump_to="DBId"), + "EndTime": fields.Int(required=False, dump_to="EndTime"), + "Limit": fields.Int(required=True, dump_to="Limit"), + "Offset": fields.Int(required=True, dump_to="Offset"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Type": fields.Int(required=False, dump_to="Type"), + "Types": fields.List(fields.Int()), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class DescribeUDBLogPackageResponseSchema(schema.ResponseSchema): + """ DescribeUDBLogPackage - 列表UDB实例binlog或slowlog或errorlog备份信息 + """ + + fields = { + "DataSet": fields.List( + models.LogPackageDataSetSchema(), + required=False, + load_from="DataSet", + ), + "TotalCount": fields.Int(required=False, load_from="TotalCount"), + } + + +""" +API: DescribeUDBParamGroup + +获取参数组详细参数信息 +""" + + +class DescribeUDBParamGroupRequestSchema(schema.RequestSchema): + """ DescribeUDBParamGroup - 获取参数组详细参数信息 + """ + + fields = { + "ClassType": fields.Str(required=False, dump_to="ClassType"), + "GroupId": fields.Int(required=False, dump_to="GroupId"), + "IsInUDBC": fields.Bool(required=False, dump_to="IsInUDBC"), + "Limit": fields.Int(required=True, dump_to="Limit"), + "Offset": fields.Int(required=True, dump_to="Offset"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "RegionFlag": fields.Bool(required=False, dump_to="RegionFlag"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class DescribeUDBParamGroupResponseSchema(schema.ResponseSchema): + """ DescribeUDBParamGroup - 获取参数组详细参数信息 + """ + + fields = { + "DataSet": fields.List( + models.UDBParamGroupSetSchema(), required=False, load_from="DataSet" + ), + "TotalCount": fields.Int(required=False, load_from="TotalCount"), + } + + +""" +API: DescribeUDBType + +获取UDB支持的类型信息 +""" + + +class DescribeUDBTypeRequestSchema(schema.RequestSchema): + """ DescribeUDBType - 获取UDB支持的类型信息 + """ + + fields = { + "BackupZone": fields.Str(required=False, dump_to="BackupZone"), + "DBClusterType": fields.Str(required=False, dump_to="DBClusterType"), + "DiskType": fields.Str(required=False, dump_to="DiskType"), + "InstanceMode": fields.Str(required=False, dump_to="InstanceMode"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class DescribeUDBTypeResponseSchema(schema.ResponseSchema): + """ DescribeUDBType - 获取UDB支持的类型信息 + """ + + fields = { + "Action": fields.Str(required=True, load_from="Action"), + "DataSet": fields.List( + models.UDBTypeSetSchema(), required=False, load_from="DataSet" + ), + "RetCode": fields.Int(required=True, load_from="RetCode"), + } + + +""" +API: EditUDBBackupBlacklist + +编辑UDB实例的备份黑名单 +""" + + +class EditUDBBackupBlacklistRequestSchema(schema.RequestSchema): + """ EditUDBBackupBlacklist - 编辑UDB实例的备份黑名单 + """ + + fields = { + "Blacklist": fields.Str(required=True, dump_to="Blacklist"), + "DBId": fields.Str(required=True, dump_to="DBId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class EditUDBBackupBlacklistResponseSchema(schema.ResponseSchema): + """ EditUDBBackupBlacklist - 编辑UDB实例的备份黑名单 + """ + + fields = {} + + +""" +API: FetchUDBInstanceEarliestRecoverTime + +获取UDB最早可回档的时间点 +""" + + +class FetchUDBInstanceEarliestRecoverTimeRequestSchema(schema.RequestSchema): + """ FetchUDBInstanceEarliestRecoverTime - 获取UDB最早可回档的时间点 + """ + + fields = { + "DBId": fields.Str(required=True, dump_to="DBId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class FetchUDBInstanceEarliestRecoverTimeResponseSchema(schema.ResponseSchema): + """ FetchUDBInstanceEarliestRecoverTime - 获取UDB最早可回档的时间点 + """ + + fields = { + "EarliestTime": fields.Int(required=False, load_from="EarliestTime") + } + + +""" +API: ModifyUDBInstanceName + +重命名UDB实例 +""" + + +class ModifyUDBInstanceNameRequestSchema(schema.RequestSchema): + """ ModifyUDBInstanceName - 重命名UDB实例 + """ + + fields = { + "DBId": fields.Str(required=True, dump_to="DBId"), + "Name": fields.Str(required=True, dump_to="Name"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class ModifyUDBInstanceNameResponseSchema(schema.ResponseSchema): + """ ModifyUDBInstanceName - 重命名UDB实例 + """ + + fields = {} + + +""" +API: ModifyUDBInstancePassword + +修改DB实例的管理员密码 +""" + + +class ModifyUDBInstancePasswordRequestSchema(schema.RequestSchema): + """ ModifyUDBInstancePassword - 修改DB实例的管理员密码 + """ + + fields = { + "AccountName": fields.Str(required=False, dump_to="AccountName"), + "DBId": fields.Str(required=True, dump_to="DBId"), + "Password": fields.Str(required=True, dump_to="Password"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class ModifyUDBInstancePasswordResponseSchema(schema.ResponseSchema): + """ ModifyUDBInstancePassword - 修改DB实例的管理员密码 + """ + + fields = {} + + +""" +API: PromoteUDBInstanceToHA + +普通db升级为高可用(只针对mysql5.5及以上版本) +""" + + +class PromoteUDBInstanceToHARequestSchema(schema.RequestSchema): + """ PromoteUDBInstanceToHA - 普通db升级为高可用(只针对mysql5.5及以上版本) + """ + + fields = { + "DBId": fields.Str(required=True, dump_to="DBId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + } + + +class PromoteUDBInstanceToHAResponseSchema(schema.ResponseSchema): + """ PromoteUDBInstanceToHA - 普通db升级为高可用(只针对mysql5.5及以上版本) + """ + + fields = {} + + +""" +API: PromoteUDBSlave + +从库提升为独立库 +""" + + +class PromoteUDBSlaveRequestSchema(schema.RequestSchema): + """ PromoteUDBSlave - 从库提升为独立库 + """ + + fields = { + "DBId": fields.Str(required=True, dump_to="DBId"), + "IsForce": fields.Bool(required=False, dump_to="IsForce"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class PromoteUDBSlaveResponseSchema(schema.ResponseSchema): + """ PromoteUDBSlave - 从库提升为独立库 + """ + + fields = {} + + +""" +API: ResizeUDBInstance + +修改(升级和降级)UDB实例的配置,包括内存和磁盘的配置,对于内存升级无需关闭实例,其他场景需要事先关闭实例。两套参数可以配置升降机:1.配置UseSSD和SSDType 2.配置InstanceType,不需要配置InstanceMode。这两套第二套参数的优先级更高 +""" + + +class ResizeUDBInstanceRequestSchema(schema.RequestSchema): + """ ResizeUDBInstance - 修改(升级和降级)UDB实例的配置,包括内存和磁盘的配置,对于内存升级无需关闭实例,其他场景需要事先关闭实例。两套参数可以配置升降机:1.配置UseSSD和SSDType 2.配置InstanceType,不需要配置InstanceMode。这两套第二套参数的优先级更高 + """ + + fields = { + "CouponId": fields.Str(required=False, dump_to="CouponId"), + "DBId": fields.Str(required=True, dump_to="DBId"), + "DiskSpace": fields.Int(required=True, dump_to="DiskSpace"), + "InstanceMode": fields.Str(required=False, dump_to="InstanceMode"), + "InstanceType": fields.Str(required=False, dump_to="InstanceType"), + "MemoryLimit": fields.Int(required=True, dump_to="MemoryLimit"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "SSDType": fields.Str(required=False, dump_to="SSDType"), + "StartAfterUpgrade": fields.Bool( + required=False, dump_to="StartAfterUpgrade" + ), + "UDBCId": fields.Str(required=False, dump_to="UDBCId"), + "UseSSD": fields.Bool(required=False, dump_to="UseSSD"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class ResizeUDBInstanceResponseSchema(schema.ResponseSchema): + """ ResizeUDBInstance - 修改(升级和降级)UDB实例的配置,包括内存和磁盘的配置,对于内存升级无需关闭实例,其他场景需要事先关闭实例。两套参数可以配置升降机:1.配置UseSSD和SSDType 2.配置InstanceType,不需要配置InstanceMode。这两套第二套参数的优先级更高 + """ + + fields = {} + + +""" +API: RestartUDBInstance + +重启UDB实例 +""" + + +class RestartUDBInstanceRequestSchema(schema.RequestSchema): + """ RestartUDBInstance - 重启UDB实例 + """ + + fields = { + "DBId": fields.Str(required=True, dump_to="DBId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class RestartUDBInstanceResponseSchema(schema.ResponseSchema): + """ RestartUDBInstance - 重启UDB实例 + """ + + fields = {} + + +""" +API: StartUDBInstance + +启动UDB实例 +""" + + +class StartUDBInstanceRequestSchema(schema.RequestSchema): + """ StartUDBInstance - 启动UDB实例 + """ + + fields = { + "DBId": fields.Str(required=True, dump_to="DBId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class StartUDBInstanceResponseSchema(schema.ResponseSchema): + """ StartUDBInstance - 启动UDB实例 + """ + + fields = {} + + +""" +API: StopUDBInstance + +关闭UDB实例 +""" + + +class StopUDBInstanceRequestSchema(schema.RequestSchema): + """ StopUDBInstance - 关闭UDB实例 + """ + + fields = { + "DBId": fields.Str(required=True, dump_to="DBId"), + "ForceToKill": fields.Bool(required=False, dump_to="ForceToKill"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class StopUDBInstanceResponseSchema(schema.ResponseSchema): + """ StopUDBInstance - 关闭UDB实例 + """ + + fields = {} + + +""" +API: SwitchUDBInstanceToHA + +普通UDB切换为高可用,原db状态为WaitForSwitch时,调用该api +""" + + +class SwitchUDBInstanceToHARequestSchema(schema.RequestSchema): + """ SwitchUDBInstanceToHA - 普通UDB切换为高可用,原db状态为WaitForSwitch时,调用该api + """ + + fields = { + "ChargeType": fields.Str(required=False, dump_to="ChargeType"), + "DBId": fields.Str(required=True, dump_to="DBId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Quantity": fields.Str(required=False, dump_to="Quantity"), + "Region": fields.Str(required=True, dump_to="Region"), + "Tag": fields.Str(required=False, dump_to="Tag"), + } + + +class SwitchUDBInstanceToHAResponseSchema(schema.ResponseSchema): + """ SwitchUDBInstanceToHA - 普通UDB切换为高可用,原db状态为WaitForSwitch时,调用该api + """ + + fields = {"DBId": fields.Str(required=False, load_from="DBId")} + + +""" +API: UpdateUDBInstanceBackupStrategy + +修改UDB自动备份策略 +""" + + +class UpdateUDBInstanceBackupStrategyRequestSchema(schema.RequestSchema): + """ UpdateUDBInstanceBackupStrategy - 修改UDB自动备份策略 + """ + + fields = { + "BackupDate": fields.Str(required=False, dump_to="BackupDate"), + "BackupMethod": fields.Str(required=False, dump_to="BackupMethod"), + "BackupTime": fields.Int(required=False, dump_to="BackupTime"), + "DBId": fields.Str(required=True, dump_to="DBId"), + "ForceDump": fields.Bool(required=False, dump_to="ForceDump"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class UpdateUDBInstanceBackupStrategyResponseSchema(schema.ResponseSchema): + """ UpdateUDBInstanceBackupStrategy - 修改UDB自动备份策略 + """ + + fields = {} + + +""" +API: UpdateUDBInstanceSlaveBackupSwitch + +开启或者关闭UDB从库备份 +""" + + +class UpdateUDBInstanceSlaveBackupSwitchRequestSchema(schema.RequestSchema): + """ UpdateUDBInstanceSlaveBackupSwitch - 开启或者关闭UDB从库备份 + """ + + fields = { + "BackupSwitch": fields.Int(required=True, dump_to="BackupSwitch"), + "MasterDBId": fields.Str(required=True, dump_to="MasterDBId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "SlaveDBId": fields.Str(required=False, dump_to="SlaveDBId"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class UpdateUDBInstanceSlaveBackupSwitchResponseSchema(schema.ResponseSchema): + """ UpdateUDBInstanceSlaveBackupSwitch - 开启或者关闭UDB从库备份 + """ + + fields = {} + + +""" +API: UpdateUDBParamGroup + +更新UDB配置参数项 +""" + + +class UpdateUDBParamGroupRequestSchema(schema.RequestSchema): + """ UpdateUDBParamGroup - 更新UDB配置参数项 + """ + + fields = { + "Description": fields.Str(required=False, dump_to="Description"), + "GroupId": fields.Int(required=True, dump_to="GroupId"), + "Key": fields.Str(required=False, dump_to="Key"), + "Name": fields.Str(required=False, dump_to="Name"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "RegionFlag": fields.Bool(required=False, dump_to="RegionFlag"), + "Value": fields.Str(required=False, dump_to="Value"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class UpdateUDBParamGroupResponseSchema(schema.ResponseSchema): + """ UpdateUDBParamGroup - 更新UDB配置参数项 + """ + + fields = {} + + +""" +API: UploadUDBParamGroup + +导入UDB配置 +""" + + +class UploadUDBParamGroupRequestSchema(schema.RequestSchema): + """ UploadUDBParamGroup - 导入UDB配置 + """ + + fields = { + "Content": fields.Str(required=True, dump_to="Content"), + "DBTypeId": fields.Str(required=True, dump_to="DBTypeId"), + "Description": fields.Str(required=True, dump_to="Description"), + "GroupName": fields.Str(required=True, dump_to="GroupName"), + "ParamGroupTypeId": fields.Int( + required=False, dump_to="ParamGroupTypeId" + ), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "RegionFlag": fields.Bool(required=False, dump_to="RegionFlag"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class UploadUDBParamGroupResponseSchema(schema.ResponseSchema): + """ UploadUDBParamGroup - 导入UDB配置 + """ + + fields = {"GroupId": fields.Int(required=False, load_from="GroupId")} diff --git a/ucloud/services/udb/schemas/models.py b/ucloud/services/udb/schemas/models.py index ddaa8d0..9bdea0b 100644 --- a/ucloud/services/udb/schemas/models.py +++ b/ucloud/services/udb/schemas/models.py @@ -1,192 +1,212 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.typesystem import schema, fields - - -class UDBBackupSetSchema(schema.ResponseSchema): - """ UDBBackupSet - DescribeUDBBackup - """ - - fields = { - "BackupEndTime": fields.Int(required=False, load_from="BackupEndTime"), - "BackupId": fields.Int(required=False, load_from="BackupId"), - "BackupName": fields.Str(required=False, load_from="BackupName"), - "BackupSize": fields.Int(required=False, load_from="BackupSize"), - "BackupTime": fields.Int(required=False, load_from="BackupTime"), - "BackupType": fields.Int(required=False, load_from="BackupType"), - "BackupZone": fields.Str(required=False, load_from="BackupZone"), - "DBId": fields.Str(required=False, load_from="DBId"), - "DBName": fields.Str(required=False, load_from="DBName"), - "ErrorInfo": fields.Str(required=False, load_from="ErrorInfo"), - "State": fields.Str(required=False, load_from="State"), - "Zone": fields.Str(required=False, load_from="Zone"), - } - - -class UDBSlaveInstanceSetSchema(schema.ResponseSchema): - """ UDBSlaveInstanceSet - DescribeUDBSlaveInstance - """ - - fields = { - "AdminUser": fields.Str(required=False, load_from="AdminUser"), - "BackupBeginTime": fields.Int(required=False, load_from="BackupBeginTime"), - "BackupBlacklist": fields.Str(required=False, load_from="BackupBlacklist"), - "BackupCount": fields.Int(required=False, load_from="BackupCount"), - "BackupDate": fields.Str(required=False, load_from="BackupDate"), - "BackupDuration": fields.Int(required=False, load_from="BackupDuration"), - "ChargeType": fields.Str(required=False, load_from="ChargeType"), - "ClusterRole": fields.Str(required=False, load_from="ClusterRole"), - "CreateTime": fields.Int(required=False, load_from="CreateTime"), - "DBId": fields.Str(required=False, load_from="DBId"), - "DBTypeId": fields.Str(required=False, load_from="DBTypeId"), - "DataFileSize": fields.Float(required=False, load_from="DataFileSize"), - "DiskSpace": fields.Int(required=False, load_from="DiskSpace"), - "DiskUsedSize": fields.Float(required=False, load_from="DiskUsedSize"), - "ExpiredTime": fields.Int(required=False, load_from="ExpiredTime"), - "InstanceMode": fields.Str(required=False, load_from="InstanceMode"), - "InstanceType": fields.Str(required=False, load_from="InstanceType"), - "InstanceTypeId": fields.Int(required=False, load_from="InstanceTypeId"), - "LogFileSize": fields.Float(required=False, load_from="LogFileSize"), - "MemoryLimit": fields.Int(required=False, load_from="MemoryLimit"), - "ModifyTime": fields.Int(required=False, load_from="ModifyTime"), - "Name": fields.Str(required=False, load_from="Name"), - "ParamGroupId": fields.Int(required=False, load_from="ParamGroupId"), - "Port": fields.Int(required=False, load_from="Port"), - "Role": fields.Str(required=False, load_from="Role"), - "SSDType": fields.Str(required=False, load_from="SSDType"), - "SrcDBId": fields.Str(required=False, load_from="SrcDBId"), - "State": fields.Str(required=False, load_from="State"), - "SubnetId": fields.Str(required=False, load_from="SubnetId"), - "SystemFileSize": fields.Float(required=False, load_from="SystemFileSize"), - "Tag": fields.Str(required=False, load_from="Tag"), - "UseSSD": fields.Bool(required=False, load_from="UseSSD"), - "VPCId": fields.Str(required=False, load_from="VPCId"), - "VirtualIP": fields.Str(required=False, load_from="VirtualIP"), - "VirtualIPMac": fields.Str(required=False, load_from="VirtualIPMac"), - "Zone": fields.Str(required=False, load_from="Zone"), - } - - -class UDBInstanceSetSchema(schema.ResponseSchema): - """ UDBInstanceSet - DescribeUDBInstance - """ - - fields = { - "AdminUser": fields.Str(required=False, load_from="AdminUser"), - "BackupBeginTime": fields.Int(required=False, load_from="BackupBeginTime"), - "BackupBlacklist": fields.Str(required=False, load_from="BackupBlacklist"), - "BackupCount": fields.Int(required=False, load_from="BackupCount"), - "BackupDate": fields.Str(required=False, load_from="BackupDate"), - "BackupDuration": fields.Int(required=False, load_from="BackupDuration"), - "BackupZone": fields.Str(required=False, load_from="BackupZone"), - "ChargeType": fields.Str(required=False, load_from="ChargeType"), - "CluserRole": fields.Str(required=False, load_from="CluserRole"), - "CreateTime": fields.Int(required=False, load_from="CreateTime"), - "DBId": fields.Str(required=False, load_from="DBId"), - "DBTypeId": fields.Str(required=False, load_from="DBTypeId"), - "DataFileSize": fields.Float(required=False, load_from="DataFileSize"), - "DataSet": fields.List(UDBSlaveInstanceSetSchema()), - "DiskSpace": fields.Int(required=False, load_from="DiskSpace"), - "DiskUsedSize": fields.Float(required=False, load_from="DiskUsedSize"), - "ExpiredTime": fields.Int(required=False, load_from="ExpiredTime"), - "InstanceMode": fields.Str(required=False, load_from="InstanceMode"), - "InstanceType": fields.Str(required=False, load_from="InstanceType"), - "InstanceTypeId": fields.Int(required=False, load_from="InstanceTypeId"), - "LogFileSize": fields.Float(required=False, load_from="LogFileSize"), - "MemoryLimit": fields.Int(required=False, load_from="MemoryLimit"), - "ModifyTime": fields.Int(required=False, load_from="ModifyTime"), - "Name": fields.Str(required=False, load_from="Name"), - "ParamGroupId": fields.Int(required=False, load_from="ParamGroupId"), - "Port": fields.Int(required=False, load_from="Port"), - "Role": fields.Str(required=False, load_from="Role"), - "SSDType": fields.Str(required=False, load_from="SSDType"), - "SrcDBId": fields.Str(required=False, load_from="SrcDBId"), - "State": fields.Str(required=False, load_from="State"), - "SubnetId": fields.Str(required=False, load_from="SubnetId"), - "SystemFileSize": fields.Float(required=False, load_from="SystemFileSize"), - "Tag": fields.Str(required=False, load_from="Tag"), - "UseSSD": fields.Bool(required=False, load_from="UseSSD"), - "VPCId": fields.Str(required=False, load_from="VPCId"), - "VirtualIP": fields.Str(required=False, load_from="VirtualIP"), - "VirtualIPMac": fields.Str(required=False, load_from="VirtualIPMac"), - "Zone": fields.Str(required=False, load_from="Zone"), - } - - -class UDBInstanceBinlogSetSchema(schema.ResponseSchema): - """ UDBInstanceBinlogSet - DescribeUDBInstanceBinlog - """ - - fields = { - "BeginTime": fields.Int(required=False, load_from="BeginTime"), - "EndTime": fields.Int(required=False, load_from="EndTime"), - "Name": fields.Str(required=False, load_from="Name"), - "Size": fields.Int(required=False, load_from="Size"), - } - - -class UDBInstancePriceSetSchema(schema.ResponseSchema): - """ UDBInstancePriceSet - DescribeUDBInstancePrice - """ - - fields = { - "ChargeType": fields.Str(required=False, load_from="ChargeType"), - "Price": fields.Float(required=False, load_from="Price"), - } - - -class LogPackageDataSetSchema(schema.ResponseSchema): - """ LogPackageDataSet - DescribeUDBLogPackage - """ - - fields = { - "BackupId": fields.Int(required=False, load_from="BackupId"), - "BackupName": fields.Str(required=False, load_from="BackupName"), - "BackupSize": fields.Int(required=False, load_from="BackupSize"), - "BackupTime": fields.Int(required=False, load_from="BackupTime"), - "BackupType": fields.Int(required=False, load_from="BackupType"), - "BackupZone": fields.Str(required=False, load_from="BackupZone"), - "DBId": fields.Str(required=False, load_from="DBId"), - "DBName": fields.Str(required=False, load_from="DBName"), - "State": fields.Str(required=False, load_from="State"), - "Zone": fields.Str(required=False, load_from="Zone"), - } - - -class UDBParamMemberSetSchema(schema.ResponseSchema): - """ UDBParamMemberSet - DescribeUDBParamGroup - """ - - fields = { - "AllowedVal": fields.Str(required=False, load_from="AllowedVal"), - "ApplyType": fields.Int(required=False, load_from="ApplyType"), - "FormatType": fields.Int(required=False, load_from="FormatType"), - "Key": fields.Str(required=False, load_from="Key"), - "Modifiable": fields.Bool(required=False, load_from="Modifiable"), - "Value": fields.Str(required=False, load_from="Value"), - "ValueType": fields.Int(required=False, load_from="ValueType"), - } - - -class UDBParamGroupSetSchema(schema.ResponseSchema): - """ UDBParamGroupSet - DescribeUDBParamGroup - """ - - fields = { - "DBTypeId": fields.Str(required=False, load_from="DBTypeId"), - "Description": fields.Str(required=False, load_from="Description"), - "GroupId": fields.Int(required=False, load_from="GroupId"), - "GroupName": fields.Str(required=False, load_from="GroupName"), - "Modifiable": fields.Bool(required=False, load_from="Modifiable"), - "ParamMember": fields.List(UDBParamMemberSetSchema()), - "RegionFlag": fields.Bool(required=False, load_from="RegionFlag"), - "Zone": fields.Str(required=False, load_from="Zone"), - } - - -class UDBTypeSetSchema(schema.ResponseSchema): - """ UDBTypeSet - DescribeUDBType - """ - - fields = {"DBTypeId": fields.Str(required=False, load_from="DBTypeId")} +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.typesystem import schema, fields + + +class UDBBackupSetSchema(schema.ResponseSchema): + """ UDBBackupSet - DescribeUDBBackup + """ + + fields = { + "BackupEndTime": fields.Int(required=False, load_from="BackupEndTime"), + "BackupId": fields.Int(required=False, load_from="BackupId"), + "BackupName": fields.Str(required=False, load_from="BackupName"), + "BackupSize": fields.Int(required=False, load_from="BackupSize"), + "BackupTime": fields.Int(required=False, load_from="BackupTime"), + "BackupType": fields.Int(required=False, load_from="BackupType"), + "BackupZone": fields.Str(required=False, load_from="BackupZone"), + "DBId": fields.Str(required=False, load_from="DBId"), + "DBName": fields.Str(required=False, load_from="DBName"), + "ErrorInfo": fields.Str(required=False, load_from="ErrorInfo"), + "State": fields.Str(required=False, load_from="State"), + "Zone": fields.Str(required=False, load_from="Zone"), + } + + +class UDBSlaveInstanceSetSchema(schema.ResponseSchema): + """ UDBSlaveInstanceSet - DescribeUDBSlaveInstance + """ + + fields = { + "AdminUser": fields.Str(required=False, load_from="AdminUser"), + "BackupBeginTime": fields.Int( + required=False, load_from="BackupBeginTime" + ), + "BackupBlacklist": fields.Str( + required=False, load_from="BackupBlacklist" + ), + "BackupCount": fields.Int(required=False, load_from="BackupCount"), + "BackupDate": fields.Str(required=False, load_from="BackupDate"), + "BackupDuration": fields.Int( + required=False, load_from="BackupDuration" + ), + "ChargeType": fields.Str(required=False, load_from="ChargeType"), + "ClusterRole": fields.Str(required=False, load_from="ClusterRole"), + "CreateTime": fields.Int(required=False, load_from="CreateTime"), + "DBId": fields.Str(required=False, load_from="DBId"), + "DBTypeId": fields.Str(required=False, load_from="DBTypeId"), + "DataFileSize": fields.Float(required=False, load_from="DataFileSize"), + "DiskSpace": fields.Int(required=False, load_from="DiskSpace"), + "DiskUsedSize": fields.Float(required=False, load_from="DiskUsedSize"), + "ExpiredTime": fields.Int(required=False, load_from="ExpiredTime"), + "InstanceMode": fields.Str(required=False, load_from="InstanceMode"), + "InstanceType": fields.Str(required=False, load_from="InstanceType"), + "InstanceTypeId": fields.Int( + required=False, load_from="InstanceTypeId" + ), + "LogFileSize": fields.Float(required=False, load_from="LogFileSize"), + "MemoryLimit": fields.Int(required=False, load_from="MemoryLimit"), + "ModifyTime": fields.Int(required=False, load_from="ModifyTime"), + "Name": fields.Str(required=False, load_from="Name"), + "ParamGroupId": fields.Int(required=False, load_from="ParamGroupId"), + "Port": fields.Int(required=False, load_from="Port"), + "Role": fields.Str(required=False, load_from="Role"), + "SSDType": fields.Str(required=False, load_from="SSDType"), + "SrcDBId": fields.Str(required=False, load_from="SrcDBId"), + "State": fields.Str(required=False, load_from="State"), + "SubnetId": fields.Str(required=False, load_from="SubnetId"), + "SystemFileSize": fields.Float( + required=False, load_from="SystemFileSize" + ), + "Tag": fields.Str(required=False, load_from="Tag"), + "UseSSD": fields.Bool(required=False, load_from="UseSSD"), + "VPCId": fields.Str(required=False, load_from="VPCId"), + "VirtualIP": fields.Str(required=False, load_from="VirtualIP"), + "VirtualIPMac": fields.Str(required=False, load_from="VirtualIPMac"), + "Zone": fields.Str(required=False, load_from="Zone"), + } + + +class UDBInstanceSetSchema(schema.ResponseSchema): + """ UDBInstanceSet - DescribeUDBInstance + """ + + fields = { + "AdminUser": fields.Str(required=False, load_from="AdminUser"), + "BackupBeginTime": fields.Int( + required=False, load_from="BackupBeginTime" + ), + "BackupBlacklist": fields.Str( + required=False, load_from="BackupBlacklist" + ), + "BackupCount": fields.Int(required=False, load_from="BackupCount"), + "BackupDate": fields.Str(required=False, load_from="BackupDate"), + "BackupDuration": fields.Int( + required=False, load_from="BackupDuration" + ), + "BackupZone": fields.Str(required=False, load_from="BackupZone"), + "ChargeType": fields.Str(required=False, load_from="ChargeType"), + "CluserRole": fields.Str(required=False, load_from="CluserRole"), + "CreateTime": fields.Int(required=False, load_from="CreateTime"), + "DBId": fields.Str(required=False, load_from="DBId"), + "DBTypeId": fields.Str(required=False, load_from="DBTypeId"), + "DataFileSize": fields.Float(required=False, load_from="DataFileSize"), + "DataSet": fields.List(UDBSlaveInstanceSetSchema()), + "DiskSpace": fields.Int(required=False, load_from="DiskSpace"), + "DiskUsedSize": fields.Float(required=False, load_from="DiskUsedSize"), + "ExpiredTime": fields.Int(required=False, load_from="ExpiredTime"), + "InstanceMode": fields.Str(required=False, load_from="InstanceMode"), + "InstanceType": fields.Str(required=False, load_from="InstanceType"), + "InstanceTypeId": fields.Int( + required=False, load_from="InstanceTypeId" + ), + "LogFileSize": fields.Float(required=False, load_from="LogFileSize"), + "MemoryLimit": fields.Int(required=False, load_from="MemoryLimit"), + "ModifyTime": fields.Int(required=False, load_from="ModifyTime"), + "Name": fields.Str(required=False, load_from="Name"), + "ParamGroupId": fields.Int(required=False, load_from="ParamGroupId"), + "Port": fields.Int(required=False, load_from="Port"), + "Role": fields.Str(required=False, load_from="Role"), + "SSDType": fields.Str(required=False, load_from="SSDType"), + "SrcDBId": fields.Str(required=False, load_from="SrcDBId"), + "State": fields.Str(required=False, load_from="State"), + "SubnetId": fields.Str(required=False, load_from="SubnetId"), + "SystemFileSize": fields.Float( + required=False, load_from="SystemFileSize" + ), + "Tag": fields.Str(required=False, load_from="Tag"), + "UseSSD": fields.Bool(required=False, load_from="UseSSD"), + "VPCId": fields.Str(required=False, load_from="VPCId"), + "VirtualIP": fields.Str(required=False, load_from="VirtualIP"), + "VirtualIPMac": fields.Str(required=False, load_from="VirtualIPMac"), + "Zone": fields.Str(required=False, load_from="Zone"), + } + + +class UDBInstanceBinlogSetSchema(schema.ResponseSchema): + """ UDBInstanceBinlogSet - DescribeUDBInstanceBinlog + """ + + fields = { + "BeginTime": fields.Int(required=False, load_from="BeginTime"), + "EndTime": fields.Int(required=False, load_from="EndTime"), + "Name": fields.Str(required=False, load_from="Name"), + "Size": fields.Int(required=False, load_from="Size"), + } + + +class UDBInstancePriceSetSchema(schema.ResponseSchema): + """ UDBInstancePriceSet - DescribeUDBInstancePrice + """ + + fields = { + "ChargeType": fields.Str(required=False, load_from="ChargeType"), + "Price": fields.Int(required=False, load_from="Price"), + } + + +class LogPackageDataSetSchema(schema.ResponseSchema): + """ LogPackageDataSet - DescribeUDBLogPackage + """ + + fields = { + "BackupId": fields.Int(required=False, load_from="BackupId"), + "BackupName": fields.Str(required=False, load_from="BackupName"), + "BackupSize": fields.Int(required=False, load_from="BackupSize"), + "BackupTime": fields.Int(required=False, load_from="BackupTime"), + "BackupType": fields.Int(required=False, load_from="BackupType"), + "BackupZone": fields.Str(required=False, load_from="BackupZone"), + "DBId": fields.Str(required=False, load_from="DBId"), + "DBName": fields.Str(required=False, load_from="DBName"), + "State": fields.Str(required=False, load_from="State"), + "Zone": fields.Str(required=False, load_from="Zone"), + } + + +class UDBParamMemberSetSchema(schema.ResponseSchema): + """ UDBParamMemberSet - DescribeUDBParamGroup + """ + + fields = { + "AllowedVal": fields.Str(required=False, load_from="AllowedVal"), + "ApplyType": fields.Int(required=False, load_from="ApplyType"), + "FormatType": fields.Int(required=False, load_from="FormatType"), + "Key": fields.Str(required=False, load_from="Key"), + "Modifiable": fields.Bool(required=False, load_from="Modifiable"), + "Value": fields.Str(required=False, load_from="Value"), + "ValueType": fields.Int(required=False, load_from="ValueType"), + } + + +class UDBParamGroupSetSchema(schema.ResponseSchema): + """ UDBParamGroupSet - DescribeUDBParamGroup + """ + + fields = { + "DBTypeId": fields.Str(required=False, load_from="DBTypeId"), + "Description": fields.Str(required=False, load_from="Description"), + "GroupId": fields.Int(required=False, load_from="GroupId"), + "GroupName": fields.Str(required=False, load_from="GroupName"), + "Modifiable": fields.Bool(required=False, load_from="Modifiable"), + "ParamMember": fields.List(UDBParamMemberSetSchema()), + "RegionFlag": fields.Bool(required=False, load_from="RegionFlag"), + "Zone": fields.Str(required=False, load_from="Zone"), + } + + +class UDBTypeSetSchema(schema.ResponseSchema): + """ UDBTypeSet - DescribeUDBType + """ + + fields = {"DBTypeId": fields.Str(required=False, load_from="DBTypeId")} diff --git a/ucloud/services/udisk/__init__.py b/ucloud/services/udisk/__init__.py index 4c48b5a..40a96af 100644 --- a/ucloud/services/udisk/__init__.py +++ b/ucloud/services/udisk/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- diff --git a/ucloud/services/udisk/client.py b/ucloud/services/udisk/client.py index fbfb883..8b836d4 100644 --- a/ucloud/services/udisk/client.py +++ b/ucloud/services/udisk/client.py @@ -1,460 +1,465 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.client import Client -from ucloud.services.udisk.schemas import apis - - -class UDiskClient(Client): - def __init__(self, config, transport=None, middleware=None, logger=None): - super(UDiskClient, self).__init__(config, transport, middleware, logger) - - def attach_udisk(self, req=None, **kwargs): - """ AttachUDisk - 将一个可用的UDisk挂载到某台主机上,当UDisk挂载成功后,还需要在主机内部进行文件系统操作 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **UDiskId** (str) - (Required) 需要挂载的UDisk实例ID. - - **UHostId** (str) - (Required) UHost实例ID - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **MultiAttach** (str) - 是否允许多点挂载(Yes: 允许多点挂载, No: 不允许多点挂载, 不填默认Yes ) - - **Response** - - - **UDiskId** (str) - 挂载的UDisk实例ID - - **UHostId** (str) - 挂载的UHost实例ID - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.AttachUDiskRequestSchema().dumps(d) - resp = self.invoke("AttachUDisk", d, **kwargs) - return apis.AttachUDiskResponseSchema().loads(resp) - - def clone_udisk(self, req=None, **kwargs): - """ CloneUDisk - 从UDisk创建UDisk克隆 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Name** (str) - (Required) 实例名称 - - **SourceId** (str) - (Required) 克隆父Disk的Id - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **ChargeType** (str) - Year , Month, Dynamic,Postpay 默认: Dynamic - - **Comment** (str) - Disk注释 - - **CouponId** (str) - 使用的代金券id - - **Quantity** (int) - 购买时长 默认: 1 - - **UDataArkMode** (str) - 方舟是否开启,"Yes":开启,"No":关闭;默认为"No" - - **Response** - - - **UDiskId** (list) - 创建UDisk Id - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.CloneUDiskRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("CloneUDisk", d, **kwargs) - return apis.CloneUDiskResponseSchema().loads(resp) - - def clone_udisk_snapshot(self, req=None, **kwargs): - """ CloneUDiskSnapshot - 从快照创建UDisk克隆 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Name** (str) - (Required) 实例名称 - - **Size** (int) - (Required) 购买UDisk大小,单位:GB,范围[1~2000], 权限位控制可达8T,若需要请申请开通相关权限。 - - **SourceId** (str) - (Required) 克隆父Snapshot的Id - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **ChargeType** (str) - Year , Month, Dynamic,Postpay 默认: Dynamic - - **Comment** (str) - Disk注释 - - **CouponId** (str) - 使用的代金券id - - **Quantity** (int) - 购买时长 默认: 1 - - **UDataArkMode** (str) - 是否开启数据方舟 默认:No - - **Response** - - - **UDiskId** (list) - 创建UDisk Id - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.CloneUDiskSnapshotRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("CloneUDiskSnapshot", d, **kwargs) - return apis.CloneUDiskSnapshotResponseSchema().loads(resp) - - def create_udisk(self, req=None, **kwargs): - """ CreateUDisk - 创建UDisk磁盘 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Name** (str) - (Required) 实例名称 - - **Size** (int) - (Required) 购买UDisk大小,单位:GB,普通盘: 范围[1~2000], 权限位控制可达8T,若需要请申请开通相关权限;SSD盘: 范围[1~4000]。 - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **ChargeType** (str) - Year , Month, Dynamic, Postpay, Trial 默认: Dynamic - - **CmkId** (str) - 加密需要的cmk id,UKmsMode为Yes时,必填 - - **CouponId** (str) - 使用的代金券id - - **DiskType** (str) - UDisk 类型: DataDisk(普通数据盘),SSDDataDisk(SSD数据盘),RSSDDataDisk(RSSD数据盘),默认值(DataDisk) - - **Quantity** (int) - 购买时长 默认: 1 - - **Tag** (str) - 业务组 默认:Default - - **UDataArkMode** (str) - 是否开启数据方舟 - - **UKmsMode** (str) - 是否加密。Yes:加密,No:不加密,默认值(No) - - **Response** - - - **UDiskId** (list) - UDisk实例Id - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.CreateUDiskRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("CreateUDisk", d, **kwargs) - return apis.CreateUDiskResponseSchema().loads(resp) - - def create_udisk_snapshot(self, req=None, **kwargs): - """ CreateUDiskSnapshot - 创建snapshot快照 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Name** (str) - (Required) 快照名称 - - **UDiskId** (str) - (Required) 快照的UDisk的Id - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **ChargeType** (str) - Year , Month, Dynamic 默认: Dynamic - - **Comment** (str) - 快照描述 - - **Quantity** (int) - 购买时长 默认: 1 - - **Response** - - - **SnapshotId** (list) - 快照Id - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.CreateUDiskSnapshotRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("CreateUDiskSnapshot", d, **kwargs) - return apis.CreateUDiskSnapshotResponseSchema().loads(resp) - - def delete_udisk(self, req=None, **kwargs): - """ DeleteUDisk - 删除UDisk - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **UDiskId** (str) - (Required) 要删除的UDisk的Id - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DeleteUDiskRequestSchema().dumps(d) - resp = self.invoke("DeleteUDisk", d, **kwargs) - return apis.DeleteUDiskResponseSchema().loads(resp) - - def delete_udisk_snapshot(self, req=None, **kwargs): - """ DeleteUDiskSnapshot - 删除Snapshot - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **SnapshotId** (str) - (Required) 快照Id - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **UDiskId** (str) - UDisk Id,删除该盘所创建出来的所有快照 - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DeleteUDiskSnapshotRequestSchema().dumps(d) - resp = self.invoke("DeleteUDiskSnapshot", d, **kwargs) - return apis.DeleteUDiskSnapshotResponseSchema().loads(resp) - - def describe_udisk(self, req=None, **kwargs): - """ DescribeUDisk - 获取UDisk实例 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **DiskType** (str) - 普通数据盘:DataDisk; 普通系统盘:SystemDisk; SSD数据盘:SSDDataDisk; RSSD数据盘:RSSDDataDisk; 为空拉取所有 - - **Limit** (int) - 返回数据长度, 默认为20 - - **Offset** (int) - 数据偏移量, 默认为0 - - **UDiskId** (str) - UDisk Id(留空返回全部) - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **DataSet** (list) - 见 **UDiskDataSet** 模型定义 - - **TotalCount** (int) - 根据过滤条件得到的总数 - - **Response Model** - - **UDiskDataSet** - - - **ArkSwitchEnable** (int) - 是否支持开启方舟,1支持 ,0不支持 - - **ChargeType** (str) - Year,Month,Dynamic,Trial,Postpay - - **CloneEnable** (int) - 是否支持克隆,1支持 ,0不支持 - - **CmkId** (str) - 该盘的cmk id - - **CmkIdAlias** (str) - cmk id 别名 - - **CmkIdStatus** (str) - 该盘cmk的状态, Enabled(正常),Disabled(失效),Deleted(删除),NoCmkId(非加密盘) - - **CreateTime** (int) - 创建时间 - - **DataKey** (str) - 该盘的密文密钥 - - **DeviceName** (str) - 挂载的设备名称 - - **DiskType** (str) - 云硬盘类型: 普通数据盘:DataDisk,普通系统盘:SystemDisk,SSD数据盘:SSDDataDisk,RSSD数据盘:RSSDDataDisk - - **ExpiredTime** (int) - 过期时间 - - **IsExpire** (str) - 资源是否过期,过期:"Yes", 未过期:"No" - - **Name** (str) - 实例名称 - - **Size** (int) - 容量单位GB - - **SnapEnable** (int) - 是否支持快照,1支持 ,0不支持 - - **SnapshotCount** (int) - 该盘快照个数 - - **SnapshotLimit** (int) - 该盘快照上限 - - **Status** (str) - 状态:Available(可用),Attaching(挂载中), InUse(已挂载), Detaching(卸载中), Initializating(分配中), Failed(创建失败),Cloning(克隆中),Restoring(恢复中),RestoreFailed(恢复失败), - - **Tag** (str) - 业务组名称 - - **UDataArkMode** (str) - 是否开启数据方舟,开启:"Yes", 不支持:"No" - - **UDiskId** (str) - UDisk实例Id - - **UHostIP** (str) - 挂载的UHost的IP - - **UHostId** (str) - 挂载的UHost的Id - - **UHostName** (str) - 挂载的UHost的Name - - **UKmsMode** (str) - 是否是加密盘,是:"Yes", 否:"No" - - **Version** (str) - 是否支持数据方舟,支持:"2.0", 不支持:"1.0" - - **Zone** (str) - 可用区 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeUDiskRequestSchema().dumps(d) - resp = self.invoke("DescribeUDisk", d, **kwargs) - return apis.DescribeUDiskResponseSchema().loads(resp) - - def describe_udisk_price(self, req=None, **kwargs): - """ DescribeUDiskPrice - 获取UDisk实例价格信息 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Size** (int) - (Required) 购买UDisk大小,单位:GB,范围[1~1000] - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **ChargeType** (str) - Year, Month, Dynamic,Trial,默认: Dynamic 如果不指定,则一次性获取三种计费 - - **DiskType** (str) - UDisk 类型: DataDisk(普通数据盘),SSDDataDisk(SSD数据盘),默认值(DataDisk) - - **Quantity** (int) - 购买UDisk的时长,默认值为1 - - **UDataArkMode** (str) - 是否打开数据方舟, 打开"Yes",关闭"No", 默认关闭 - - **Response** - - - **DataSet** (list) - 见 **UDiskPriceDataSet** 模型定义 - - **Response Model** - - **UDiskPriceDataSet** - - - **ChargeName** (str) - "UDataArk","UDisk" - - **ChargeType** (str) - Year, Month, Dynamic,Trial - - **Price** (float) - 价格 (单位: 分) - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeUDiskPriceRequestSchema().dumps(d) - resp = self.invoke("DescribeUDiskPrice", d, **kwargs) - return apis.DescribeUDiskPriceResponseSchema().loads(resp) - - def describe_udisk_snapshot(self, req=None, **kwargs): - """ DescribeUDiskSnapshot - 获取UDisk快照 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Limit** (int) - 返回数据长度, 默认为20 - - **Offset** (int) - 数据偏移量, 默认为0 - - **SnapshotId** (str) - 快照id,SnapshotId , UDiskId 同时传SnapshotId优先 - - **UDiskId** (str) - UDiskId,返回该盘所做快照.(必须同时传Zone) - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **DataSet** (list) - 见 **UDiskSnapshotSet** 模型定义 - - **TotalCount** (int) - 根据过滤条件得到的总数 - - **Response Model** - - **UDiskSnapshotSet** - - - **CmkId** (str) - 该快照的cmk id - - **CmkIdAlias** (str) - cmk id 别名 - - **CmkIdStatus** (str) - 该快照cmk的状态, Enabled(正常),Disabled(失效),Deleted(删除),NoCmkId(非加密盘) - - **Comment** (str) - 快照描述 - - **CreateTime** (int) - 创建时间 - - **DataKey** (str) - 该快照的密文密钥 - - **DiskType** (int) - 磁盘类型,0:数据盘,1:系统盘 - - **ExpiredTime** (int) - 过期时间 - - **IsUDiskAvailable** (bool) - 对应磁盘是否处于可用状态 - - **Name** (str) - 快照名称 - - **Size** (int) - 容量单位GB - - **SnapshotId** (str) - 快照Id - - **Status** (str) - 快照状态,Normal:正常,Failed:失败,Creating:制作中 - - **UDiskId** (str) - 快照的源UDisk的Id - - **UDiskName** (str) - 快照的源UDisk的Name - - **UHostId** (str) - 对应磁盘制作快照时所挂载的主机 - - **UKmsMode** (str) - 是否是加密盘快照,是:"Yes", 否:"No" - - **Version** (str) - 快照版本 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeUDiskSnapshotRequestSchema().dumps(d) - resp = self.invoke("DescribeUDiskSnapshot", d, **kwargs) - return apis.DescribeUDiskSnapshotResponseSchema().loads(resp) - - def describe_udisk_upgrade_price(self, req=None, **kwargs): - """ DescribeUDiskUpgradePrice - 获取UDisk升级价格信息 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Size** (int) - (Required) 购买UDisk大小,单位:GB,范围[1~2000], 权限位控制可达8T,若需要请申请开通相关权限。 - - **SourceId** (str) - (Required) 升级目标UDisk ID - - **UDataArkMode** (str) - (Required) 是否打开数据方舟, 打开"Yes",关闭"No", 默认关闭 - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **DiskType** (str) - 磁盘类型,SSDDataDisk:ssd数据盘,DataDisk:普通数据盘,SystemDisk:普通系统盘,SSDSystemDisk:ssd系统盘。默认为DataDisk - - **Response** - - - **Price** (float) - 价格 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeUDiskUpgradePriceRequestSchema().dumps(d) - resp = self.invoke("DescribeUDiskUpgradePrice", d, **kwargs) - return apis.DescribeUDiskUpgradePriceResponseSchema().loads(resp) - - def detach_udisk(self, req=None, **kwargs): - """ DetachUDisk - 卸载某个已经挂载在指定UHost实例上的UDisk - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **UDiskId** (str) - (Required) 需要卸载的UDisk实例ID - - **UHostId** (str) - (Required) UHost实例ID - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **Response** - - - **UDiskId** (str) - 卸载的UDisk实例ID - - **UHostId** (str) - 卸载的UHost实例ID - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DetachUDiskRequestSchema().dumps(d) - resp = self.invoke("DetachUDisk", d, **kwargs) - return apis.DetachUDiskResponseSchema().loads(resp) - - def rename_udisk(self, req=None, **kwargs): - """ RenameUDisk - 重命名UDisk - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **UDiskId** (str) - (Required) 重命名的UDisk的Id - - **UDiskName** (str) - (Required) 重命名UDisk的name - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.RenameUDiskRequestSchema().dumps(d) - resp = self.invoke("RenameUDisk", d, **kwargs) - return apis.RenameUDiskResponseSchema().loads(resp) - - def resize_udisk(self, req=None, **kwargs): - """ ResizeUDisk - 调整UDisk容量 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Size** (int) - (Required) 调整后大小, 单位:GB, 范围[1~2000],权限位控制可达8000,若需要请申请开通相关权限。 - - **UDiskId** (str) - (Required) UDisk Id - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **CouponId** (str) - 使用的代金券id - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.ResizeUDiskRequestSchema().dumps(d) - resp = self.invoke("ResizeUDisk", d, **kwargs) - return apis.ResizeUDiskResponseSchema().loads(resp) - - def restore_udisk(self, req=None, **kwargs): - """ RestoreUDisk - 从备份恢复数据至UDisk - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **UDiskId** (str) - (Required) 需要恢复的盘id - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **SnapshotId** (str) - 从指定的快照恢复 - - **SnapshotTime** (int) - 指定从方舟恢复的备份时间点 - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.RestoreUDiskRequestSchema().dumps(d) - resp = self.invoke("RestoreUDisk", d, **kwargs) - return apis.RestoreUDiskResponseSchema().loads(resp) - - def set_udisk__udataark_mode(self, req=None, **kwargs): - """ SetUDiskUDataArkMode - 设置UDisk数据方舟的状态 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **UDataArkMode** (str) - (Required) 是否开启数据方舟,开启:"Yes", 不支持:"No" - - **UDiskId** (str) - (Required) 需要设置数据方舟的UDisk的Id - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.SetUDiskUDataArkModeRequestSchema().dumps(d) - resp = self.invoke("SetUDiskUDataArkMode", d, **kwargs) - return apis.SetUDiskUDataArkModeResponseSchema().loads(resp) +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.client import Client +from ucloud.services.udisk.schemas import apis + + +class UDiskClient(Client): + def __init__(self, config, transport=None, middleware=None, logger=None): + super(UDiskClient, self).__init__(config, transport, middleware, logger) + + def attach_udisk(self, req=None, **kwargs): + """ AttachUDisk - 将一个可用的UDisk挂载到某台主机上,当UDisk挂载成功后,还需要在主机内部进行文件系统操作 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **UDiskId** (str) - (Required) 需要挂载的UDisk实例ID. + - **UHostId** (str) - (Required) UHost实例ID + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + - **MultiAttach** (str) - 是否允许多点挂载(Yes: 允许多点挂载, No: 不允许多点挂载, 不填默认Yes ) + + **Response** + + - **UDiskId** (str) - 挂载的UDisk实例ID + - **UHostId** (str) - 挂载的UHost实例ID + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.AttachUDiskRequestSchema().dumps(d) + resp = self.invoke("AttachUDisk", d, **kwargs) + return apis.AttachUDiskResponseSchema().loads(resp) + + def clone_udisk(self, req=None, **kwargs): + """ CloneUDisk - 从UDisk创建UDisk克隆 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Name** (str) - (Required) 实例名称 + - **SourceId** (str) - (Required) 克隆父Disk的Id + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + - **ChargeType** (str) - Year , Month, Dynamic,Postpay 默认: Dynamic + - **Comment** (str) - Disk注释 + - **CouponId** (str) - 使用的代金券id + - **Quantity** (int) - 购买时长 默认: 1 + - **UDataArkMode** (str) - 方舟是否开启,"Yes":开启,"No":关闭;默认为"No" + + **Response** + + - **UDiskId** (list) - 创建UDisk Id + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.CloneUDiskRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("CloneUDisk", d, **kwargs) + return apis.CloneUDiskResponseSchema().loads(resp) + + def clone_udisk_snapshot(self, req=None, **kwargs): + """ CloneUDiskSnapshot - 从快照创建UDisk克隆 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Name** (str) - (Required) 实例名称 + - **Size** (int) - (Required) 购买UDisk大小,单位:GB,范围[1~2000], 权限位控制可达8T,若需要请申请开通相关权限。 + - **SourceId** (str) - (Required) 克隆父Snapshot的Id + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + - **ChargeType** (str) - Year , Month, Dynamic,Postpay 默认: Dynamic + - **Comment** (str) - Disk注释 + - **CouponId** (str) - 使用的代金券id + - **Quantity** (int) - 购买时长 默认: 1 + - **UDataArkMode** (str) - 是否开启数据方舟 默认:No + + **Response** + + - **UDiskId** (list) - 创建UDisk Id + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.CloneUDiskSnapshotRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("CloneUDiskSnapshot", d, **kwargs) + return apis.CloneUDiskSnapshotResponseSchema().loads(resp) + + def create_udisk(self, req=None, **kwargs): + """ CreateUDisk - 创建UDisk磁盘 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Name** (str) - (Required) 实例名称 + - **Size** (int) - (Required) 购买UDisk大小,单位:GB,普通盘: 范围[1~2000], 权限位控制可达8T,若需要请申请开通相关权限;SSD盘: 范围[1~4000]。 + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + - **ChargeType** (str) - Year , Month, Dynamic, Postpay, Trial 默认: Dynamic + - **CmkId** (str) - 加密需要的cmk id,UKmsMode为Yes时,必填 + - **CouponId** (str) - 使用的代金券id + - **DiskType** (str) - UDisk 类型: DataDisk(普通数据盘),SSDDataDisk(SSD数据盘),RSSDDataDisk(RSSD数据盘),默认值(DataDisk) + - **Quantity** (int) - 购买时长 默认: 1 + - **Tag** (str) - 业务组 默认:Default + - **UDataArkMode** (str) - 是否开启数据方舟 + - **UKmsMode** (str) - 是否加密。Yes:加密,No:不加密,默认值(No) + + **Response** + + - **UDiskId** (list) - UDisk实例Id + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.CreateUDiskRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("CreateUDisk", d, **kwargs) + return apis.CreateUDiskResponseSchema().loads(resp) + + def create_udisk_snapshot(self, req=None, **kwargs): + """ CreateUDiskSnapshot - 创建snapshot快照 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Name** (str) - (Required) 快照名称 + - **UDiskId** (str) - (Required) 快照的UDisk的Id + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + - **ChargeType** (str) - Year , Month, Dynamic 默认: Dynamic + - **Comment** (str) - 快照描述 + - **Quantity** (int) - 购买时长 默认: 1 + + **Response** + + - **SnapshotId** (list) - 快照Id + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.CreateUDiskSnapshotRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("CreateUDiskSnapshot", d, **kwargs) + return apis.CreateUDiskSnapshotResponseSchema().loads(resp) + + def delete_udisk(self, req=None, **kwargs): + """ DeleteUDisk - 删除UDisk + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **UDiskId** (str) - (Required) 要删除的UDisk的Id + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DeleteUDiskRequestSchema().dumps(d) + resp = self.invoke("DeleteUDisk", d, **kwargs) + return apis.DeleteUDiskResponseSchema().loads(resp) + + def delete_udisk_snapshot(self, req=None, **kwargs): + """ DeleteUDiskSnapshot - 删除Snapshot + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + - **SnapshotId** (str) - 快照Id(填写后不能填写UDisk Id) + - **UDiskId** (str) - UDisk Id,删除该盘所创建出来的所有快照(填写后不能填写SnapshotId) + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DeleteUDiskSnapshotRequestSchema().dumps(d) + resp = self.invoke("DeleteUDiskSnapshot", d, **kwargs) + return apis.DeleteUDiskSnapshotResponseSchema().loads(resp) + + def describe_udisk(self, req=None, **kwargs): + """ DescribeUDisk - 获取UDisk实例 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **DiskType** (str) - ProtocolVersion字段为1时,需结合IsBoot确定具体磁盘类型:普通数据盘:DiskType:"CLOUD_NORMAL",IsBoot:"False"; 普通系统盘:DiskType:"CLOUD_NORMAL",IsBoot:"True";SSD数据盘:DiskType:"CLOUD_SSD",IsBoot:"False";SSD系统盘:DiskType:"CLOUD_SSD",IsBoot:"True";RSSD数据盘:DiskType:"CLOUD_RSSD",IsBoot:"False";为空拉取所有。ProtocolVersion字段为0或没有该字段时,可设为以下几个值:普通数据盘:DataDisk;普通系统盘;SystemDisk;SSD数据盘:SSDDataDisk;SSD系统盘:SSDSystemDisk;RSSD数据盘:RSSDDataDisk;为空拉取所有。 + - **IsBoot** (str) - ProtocolVersion字段为1且DiskType不为空时,必须设置,设置规则请参照DiskType;ProtocolVersion字段为1且DiskType为空时,该字段无效。ProtocolVersion字段为0或没有该字段时,该字段无效。 + - **Limit** (int) - 返回数据长度, 默认为20 + - **Offset** (int) - 数据偏移量, 默认为0 + - **ProtocolVersion** (int) - 请求协议版本,建议升级为1,为1时DiskType与UHost磁盘类型定义一致;默认为0 + - **UDiskId** (str) - UDisk Id(留空返回全部) + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **DataSet** (list) - 见 **UDiskDataSet** 模型定义 + - **TotalCount** (int) - 根据过滤条件得到的总数 + + **Response Model** + + **UDiskDataSet** + + - **ArkSwitchEnable** (int) - 是否支持开启方舟,1支持 ,0不支持 + - **ChargeType** (str) - Year,Month,Dynamic,Trial,Postpay + - **CloneEnable** (int) - 是否支持克隆,1支持 ,0不支持 + - **CmkId** (str) - 该盘的cmk id + - **CmkIdAlias** (str) - cmk id 别名 + - **CmkIdStatus** (str) - 该盘cmk的状态, Enabled(正常),Disabled(失效),Deleted(删除),NoCmkId(非加密盘) + - **CreateTime** (int) - 创建时间 + - **DataKey** (str) - 该盘的密文密钥 + - **DeviceName** (str) - 挂载的设备名称 + - **DiskType** (str) - 请求中的ProtocolVersion字段为1时,需结合IsBoot确定具体磁盘类型:普通数据盘:DiskType:"CLOUD_NORMAL",IsBoot:"False"; 普通系统盘:DiskType:"CLOUD_NORMAL",IsBoot:"True";SSD数据盘:DiskType:"CLOUD_SSD",IsBoot:"False";SSD系统盘:DiskType:"CLOUD_SSD",IsBoot:"True";RSSD数据盘:DiskType:"CLOUD_RSSD",IsBoot:"False"。请求中的ProtocolVersion字段为0或没有该字段时,云硬盘类型参照如下:普通数据盘:DataDisk;普通系统盘:SystemDisk;SSD数据盘:SSDDataDisk;SSD系统盘:SSDSystemDisk;RSSD数据盘:RSSDDataDisk。 + - **ExpiredTime** (int) - 过期时间 + - **IsBoot** (str) - 是否是系统盘,是:"True", 否:"False" + - **IsExpire** (str) - 资源是否过期,过期:"Yes", 未过期:"No" + - **Name** (str) - 实例名称 + - **Size** (int) - 容量单位GB + - **SnapEnable** (int) - 是否支持快照,1支持 ,0不支持 + - **SnapshotCount** (int) - 该盘快照个数 + - **SnapshotLimit** (int) - 该盘快照上限 + - **Status** (str) - 状态:Available(可用),Attaching(挂载中), InUse(已挂载), Detaching(卸载中), Initializating(分配中), Failed(创建失败),Cloning(克隆中),Restoring(恢复中),RestoreFailed(恢复失败), + - **Tag** (str) - 业务组名称 + - **UDataArkMode** (str) - 是否开启数据方舟,开启:"Yes", 不支持:"No" + - **UDiskId** (str) - UDisk实例Id + - **UHostIP** (str) - 挂载的UHost的IP + - **UHostId** (str) - 挂载的UHost的Id + - **UHostName** (str) - 挂载的UHost的Name + - **UKmsMode** (str) - 是否是加密盘,是:"Yes", 否:"No" + - **Version** (str) - 是否支持数据方舟,支持:"2.0", 不支持:"1.0" + - **Zone** (str) - 可用区 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeUDiskRequestSchema().dumps(d) + resp = self.invoke("DescribeUDisk", d, **kwargs) + return apis.DescribeUDiskResponseSchema().loads(resp) + + def describe_udisk_price(self, req=None, **kwargs): + """ DescribeUDiskPrice - 获取UDisk实例价格信息 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Size** (int) - (Required) 购买UDisk大小,单位:GB,范围[1~1000] + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + - **ChargeType** (str) - Year, Month, Dynamic,Trial,默认: Dynamic + - **DiskType** (str) - UDisk 类型: DataDisk(普通数据盘),SSDDataDisk(SSD数据盘),SystemDisk(普通系统盘),SSDSystemDisk(SSD系统盘),RSSDDataDisk(RSSD数据盘),默认值(DataDisk) + - **Quantity** (int) - 购买UDisk的时长,默认值为1 + - **UDataArkMode** (str) - 是否打开数据方舟, 打开"Yes",关闭"No", 默认关闭 + + **Response** + + - **DataSet** (list) - 见 **UDiskPriceDataSet** 模型定义 + + **Response Model** + + **UDiskPriceDataSet** + + - **ChargeName** (str) - "UDataArk","UDisk" + - **ChargeType** (str) - Year, Month, Dynamic,Trial + - **OriginalPrice** (int) - 用户折后价 + - **Price** (int) - 价格 (单位: 分) + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeUDiskPriceRequestSchema().dumps(d) + resp = self.invoke("DescribeUDiskPrice", d, **kwargs) + return apis.DescribeUDiskPriceResponseSchema().loads(resp) + + def describe_udisk_snapshot(self, req=None, **kwargs): + """ DescribeUDiskSnapshot - 获取UDisk快照 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Limit** (int) - 返回数据长度, 默认为20 + - **Offset** (int) - 数据偏移量, 默认为0 + - **SnapshotId** (str) - 快照id,SnapshotId , UDiskId 同时传SnapshotId优先 + - **UDiskId** (str) - UDiskId,返回该盘所做快照.(必须同时传Zone) + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **DataSet** (list) - 见 **UDiskSnapshotSet** 模型定义 + - **TotalCount** (int) - 根据过滤条件得到的总数 + + **Response Model** + + **UDiskSnapshotSet** + + - **CmkId** (str) - 该快照的cmk id + - **CmkIdAlias** (str) - cmk id 别名 + - **CmkIdStatus** (str) - 该快照cmk的状态, Enabled(正常),Disabled(失效),Deleted(删除),NoCmkId(非加密盘) + - **Comment** (str) - 快照描述 + - **CreateTime** (int) - 创建时间 + - **DataKey** (str) - 该快照的密文密钥 + - **DiskType** (int) - 磁盘类型,0:数据盘,1:系统盘 + - **ExpiredTime** (int) - 过期时间 + - **IsUDiskAvailable** (bool) - 对应磁盘是否处于可用状态 + - **Name** (str) - 快照名称 + - **Size** (int) - 容量单位GB + - **SnapshotId** (str) - 快照Id + - **Status** (str) - 快照状态,Normal:正常,Failed:失败,Creating:制作中 + - **UDiskId** (str) - 快照的源UDisk的Id + - **UDiskName** (str) - 快照的源UDisk的Name + - **UHostId** (str) - 对应磁盘制作快照时所挂载的主机 + - **UKmsMode** (str) - 是否是加密盘快照,是:"Yes", 否:"No" + - **Version** (str) - 快照版本 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeUDiskSnapshotRequestSchema().dumps(d) + resp = self.invoke("DescribeUDiskSnapshot", d, **kwargs) + return apis.DescribeUDiskSnapshotResponseSchema().loads(resp) + + def describe_udisk_upgrade_price(self, req=None, **kwargs): + """ DescribeUDiskUpgradePrice - 获取UDisk升级价格信息 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Size** (int) - (Required) 购买UDisk大小,单位:GB,范围[1~2000], 权限位控制可达8T,若需要请申请开通相关权限。 + - **SourceId** (str) - (Required) 升级目标UDisk ID + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + - **DiskType** (str) - 磁盘类型,SSDDataDisk:ssd数据盘,DataDisk:普通数据盘,SystemDisk:普通系统盘,SSDSystemDisk:ssd系统盘。默认为DataDisk + - **UDataArkMode** (str) - 是否打开数据方舟, 打开"Yes",关闭"No", 默认关闭 + + **Response** + + - **OriginalPrice** (int) - 用户折后价 + - **Price** (int) - 价格 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeUDiskUpgradePriceRequestSchema().dumps(d) + resp = self.invoke("DescribeUDiskUpgradePrice", d, **kwargs) + return apis.DescribeUDiskUpgradePriceResponseSchema().loads(resp) + + def detach_udisk(self, req=None, **kwargs): + """ DetachUDisk - 卸载某个已经挂载在指定UHost实例上的UDisk + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **UDiskId** (str) - (Required) 需要卸载的UDisk实例ID + - **UHostId** (str) - (Required) UHost实例ID + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + + **Response** + + - **UDiskId** (str) - 卸载的UDisk实例ID + - **UHostId** (str) - 卸载的UHost实例ID + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DetachUDiskRequestSchema().dumps(d) + resp = self.invoke("DetachUDisk", d, **kwargs) + return apis.DetachUDiskResponseSchema().loads(resp) + + def rename_udisk(self, req=None, **kwargs): + """ RenameUDisk - 重命名UDisk + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **UDiskId** (str) - (Required) 重命名的UDisk的Id + - **UDiskName** (str) - (Required) 重命名UDisk的name + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.RenameUDiskRequestSchema().dumps(d) + resp = self.invoke("RenameUDisk", d, **kwargs) + return apis.RenameUDiskResponseSchema().loads(resp) + + def resize_udisk(self, req=None, **kwargs): + """ ResizeUDisk - 调整UDisk容量 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Size** (int) - (Required) 调整后大小, 单位:GB, 范围[1~2000],权限位控制可达8000,若需要请申请开通相关权限。 + - **UDiskId** (str) - (Required) UDisk Id + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + - **CouponId** (str) - 使用的代金券id + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.ResizeUDiskRequestSchema().dumps(d) + resp = self.invoke("ResizeUDisk", d, **kwargs) + return apis.ResizeUDiskResponseSchema().loads(resp) + + def restore_udisk(self, req=None, **kwargs): + """ RestoreUDisk - 从备份恢复数据至UDisk + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **UDiskId** (str) - (Required) 需要恢复的盘id + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + - **SnapshotId** (str) - 从指定的快照恢复 + - **SnapshotTime** (int) - 指定从方舟恢复的备份时间点 + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.RestoreUDiskRequestSchema().dumps(d) + resp = self.invoke("RestoreUDisk", d, **kwargs) + return apis.RestoreUDiskResponseSchema().loads(resp) + + def set_udisk__udataark_mode(self, req=None, **kwargs): + """ SetUDiskUDataArkMode - 设置UDisk数据方舟的状态 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **UDataArkMode** (str) - (Required) 是否开启数据方舟,开启:"Yes", 不支持:"No" + - **UDiskId** (str) - (Required) 需要设置数据方舟的UDisk的Id + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.SetUDiskUDataArkModeRequestSchema().dumps(d) + resp = self.invoke("SetUDiskUDataArkMode", d, **kwargs) + return apis.SetUDiskUDataArkModeResponseSchema().loads(resp) diff --git a/ucloud/services/udisk/schemas/__init__.py b/ucloud/services/udisk/schemas/__init__.py index 4c48b5a..40a96af 100644 --- a/ucloud/services/udisk/schemas/__init__.py +++ b/ucloud/services/udisk/schemas/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- diff --git a/ucloud/services/udisk/schemas/apis.py b/ucloud/services/udisk/schemas/apis.py index 6f74881..522eb6a 100644 --- a/ucloud/services/udisk/schemas/apis.py +++ b/ucloud/services/udisk/schemas/apis.py @@ -1,493 +1,516 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.typesystem import schema, fields -from ucloud.services.udisk.schemas import models - -""" UDisk API Schema -""" -""" -API: AttachUDisk - -将一个可用的UDisk挂载到某台主机上,当UDisk挂载成功后,还需要在主机内部进行文件系统操作 -""" - - -class AttachUDiskRequestSchema(schema.RequestSchema): - """ AttachUDisk - 将一个可用的UDisk挂载到某台主机上,当UDisk挂载成功后,还需要在主机内部进行文件系统操作 - """ - - fields = { - "MultiAttach": fields.Str(required=False, dump_to="MultiAttach"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "UDiskId": fields.Str(required=True, dump_to="UDiskId"), - "UHostId": fields.Str(required=True, dump_to="UHostId"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class AttachUDiskResponseSchema(schema.ResponseSchema): - """ AttachUDisk - 将一个可用的UDisk挂载到某台主机上,当UDisk挂载成功后,还需要在主机内部进行文件系统操作 - """ - - fields = { - "UDiskId": fields.Str(required=False, load_from="UDiskId"), - "UHostId": fields.Str(required=False, load_from="UHostId"), - } - - -""" -API: CloneUDisk - -从UDisk创建UDisk克隆 -""" - - -class CloneUDiskRequestSchema(schema.RequestSchema): - """ CloneUDisk - 从UDisk创建UDisk克隆 - """ - - fields = { - "ChargeType": fields.Str(required=False, dump_to="ChargeType"), - "Comment": fields.Str(required=False, dump_to="Comment"), - "CouponId": fields.Str(required=False, dump_to="CouponId"), - "Name": fields.Str(required=True, dump_to="Name"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Quantity": fields.Int(required=False, dump_to="Quantity"), - "Region": fields.Str(required=True, dump_to="Region"), - "SourceId": fields.Str(required=True, dump_to="SourceId"), - "UDataArkMode": fields.Str(required=False, dump_to="UDataArkMode"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class CloneUDiskResponseSchema(schema.ResponseSchema): - """ CloneUDisk - 从UDisk创建UDisk克隆 - """ - - fields = {"UDiskId": fields.List(fields.Str(), required=False, load_from="UDiskId")} - - -""" -API: CloneUDiskSnapshot - -从快照创建UDisk克隆 -""" - - -class CloneUDiskSnapshotRequestSchema(schema.RequestSchema): - """ CloneUDiskSnapshot - 从快照创建UDisk克隆 - """ - - fields = { - "ChargeType": fields.Str(required=False, dump_to="ChargeType"), - "Comment": fields.Str(required=False, dump_to="Comment"), - "CouponId": fields.Str(required=False, dump_to="CouponId"), - "Name": fields.Str(required=True, dump_to="Name"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Quantity": fields.Int(required=False, dump_to="Quantity"), - "Region": fields.Str(required=True, dump_to="Region"), - "Size": fields.Int(required=True, dump_to="Size"), - "SourceId": fields.Str(required=True, dump_to="SourceId"), - "UDataArkMode": fields.Str(required=False, dump_to="UDataArkMode"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class CloneUDiskSnapshotResponseSchema(schema.ResponseSchema): - """ CloneUDiskSnapshot - 从快照创建UDisk克隆 - """ - - fields = {"UDiskId": fields.List(fields.Str(), required=False, load_from="UDiskId")} - - -""" -API: CreateUDisk - -创建UDisk磁盘 -""" - - -class CreateUDiskRequestSchema(schema.RequestSchema): - """ CreateUDisk - 创建UDisk磁盘 - """ - - fields = { - "ChargeType": fields.Str(required=False, dump_to="ChargeType"), - "CmkId": fields.Str(required=False, dump_to="CmkId"), - "CouponId": fields.Str(required=False, dump_to="CouponId"), - "DiskType": fields.Str(required=False, dump_to="DiskType"), - "Name": fields.Str(required=True, dump_to="Name"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Quantity": fields.Int(required=False, dump_to="Quantity"), - "Region": fields.Str(required=True, dump_to="Region"), - "Size": fields.Int(required=True, dump_to="Size"), - "Tag": fields.Str(required=False, dump_to="Tag"), - "UDataArkMode": fields.Str(required=False, dump_to="UDataArkMode"), - "UKmsMode": fields.Str(required=False, dump_to="UKmsMode"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class CreateUDiskResponseSchema(schema.ResponseSchema): - """ CreateUDisk - 创建UDisk磁盘 - """ - - fields = {"UDiskId": fields.List(fields.Str(), required=False, load_from="UDiskId")} - - -""" -API: CreateUDiskSnapshot - -创建snapshot快照 -""" - - -class CreateUDiskSnapshotRequestSchema(schema.RequestSchema): - """ CreateUDiskSnapshot - 创建snapshot快照 - """ - - fields = { - "ChargeType": fields.Str(required=False, dump_to="ChargeType"), - "Comment": fields.Str(required=False, dump_to="Comment"), - "Name": fields.Str(required=True, dump_to="Name"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Quantity": fields.Int(required=False, dump_to="Quantity"), - "Region": fields.Str(required=True, dump_to="Region"), - "UDiskId": fields.Str(required=True, dump_to="UDiskId"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class CreateUDiskSnapshotResponseSchema(schema.ResponseSchema): - """ CreateUDiskSnapshot - 创建snapshot快照 - """ - - fields = { - "SnapshotId": fields.List(fields.Str(), required=True, load_from="SnapshotId") - } - - -""" -API: DeleteUDisk - -删除UDisk -""" - - -class DeleteUDiskRequestSchema(schema.RequestSchema): - """ DeleteUDisk - 删除UDisk - """ - - fields = { - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "UDiskId": fields.Str(required=True, dump_to="UDiskId"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class DeleteUDiskResponseSchema(schema.ResponseSchema): - """ DeleteUDisk - 删除UDisk - """ - - fields = {} - - -""" -API: DeleteUDiskSnapshot - -删除Snapshot -""" - - -class DeleteUDiskSnapshotRequestSchema(schema.RequestSchema): - """ DeleteUDiskSnapshot - 删除Snapshot - """ - - fields = { - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "SnapshotId": fields.Str(required=True, dump_to="SnapshotId"), - "UDiskId": fields.Str(required=False, dump_to="UDiskId"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class DeleteUDiskSnapshotResponseSchema(schema.ResponseSchema): - """ DeleteUDiskSnapshot - 删除Snapshot - """ - - fields = {} - - -""" -API: DescribeUDisk - -获取UDisk实例 -""" - - -class DescribeUDiskRequestSchema(schema.RequestSchema): - """ DescribeUDisk - 获取UDisk实例 - """ - - fields = { - "DiskType": fields.Str(required=False, dump_to="DiskType"), - "Limit": fields.Int(required=False, dump_to="Limit"), - "Offset": fields.Int(required=False, dump_to="Offset"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "UDiskId": fields.Str(required=False, dump_to="UDiskId"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class DescribeUDiskResponseSchema(schema.ResponseSchema): - """ DescribeUDisk - 获取UDisk实例 - """ - - fields = { - "DataSet": fields.List( - models.UDiskDataSetSchema(), required=False, load_from="DataSet" - ), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - } - - -""" -API: DescribeUDiskPrice - -获取UDisk实例价格信息 -""" - - -class DescribeUDiskPriceRequestSchema(schema.RequestSchema): - """ DescribeUDiskPrice - 获取UDisk实例价格信息 - """ - - fields = { - "ChargeType": fields.Str(required=False, dump_to="ChargeType"), - "DiskType": fields.Str(required=False, dump_to="DiskType"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Quantity": fields.Int(required=False, dump_to="Quantity"), - "Region": fields.Str(required=True, dump_to="Region"), - "Size": fields.Int(required=True, dump_to="Size"), - "UDataArkMode": fields.Str(required=False, dump_to="UDataArkMode"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class DescribeUDiskPriceResponseSchema(schema.ResponseSchema): - """ DescribeUDiskPrice - 获取UDisk实例价格信息 - """ - - fields = { - "DataSet": fields.List( - models.UDiskPriceDataSetSchema(), required=False, load_from="DataSet" - ) - } - - -""" -API: DescribeUDiskSnapshot - -获取UDisk快照 -""" - - -class DescribeUDiskSnapshotRequestSchema(schema.RequestSchema): - """ DescribeUDiskSnapshot - 获取UDisk快照 - """ - - fields = { - "Limit": fields.Int(required=False, dump_to="Limit"), - "Offset": fields.Int(required=False, dump_to="Offset"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "SnapshotId": fields.Str(required=False, dump_to="SnapshotId"), - "UDiskId": fields.Str(required=False, dump_to="UDiskId"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class DescribeUDiskSnapshotResponseSchema(schema.ResponseSchema): - """ DescribeUDiskSnapshot - 获取UDisk快照 - """ - - fields = { - "DataSet": fields.List( - models.UDiskSnapshotSetSchema(), required=False, load_from="DataSet" - ), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - } - - -""" -API: DescribeUDiskUpgradePrice - -获取UDisk升级价格信息 -""" - - -class DescribeUDiskUpgradePriceRequestSchema(schema.RequestSchema): - """ DescribeUDiskUpgradePrice - 获取UDisk升级价格信息 - """ - - fields = { - "DiskType": fields.Str(required=False, dump_to="DiskType"), - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Size": fields.Int(required=True, dump_to="Size"), - "SourceId": fields.Str(required=True, dump_to="SourceId"), - "UDataArkMode": fields.Str(required=True, dump_to="UDataArkMode"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class DescribeUDiskUpgradePriceResponseSchema(schema.ResponseSchema): - """ DescribeUDiskUpgradePrice - 获取UDisk升级价格信息 - """ - - fields = {"Price": fields.Float(required=False, load_from="Price")} - - -""" -API: DetachUDisk - -卸载某个已经挂载在指定UHost实例上的UDisk -""" - - -class DetachUDiskRequestSchema(schema.RequestSchema): - """ DetachUDisk - 卸载某个已经挂载在指定UHost实例上的UDisk - """ - - fields = { - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "UDiskId": fields.Str(required=True, dump_to="UDiskId"), - "UHostId": fields.Str(required=True, dump_to="UHostId"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class DetachUDiskResponseSchema(schema.ResponseSchema): - """ DetachUDisk - 卸载某个已经挂载在指定UHost实例上的UDisk - """ - - fields = { - "UDiskId": fields.Str(required=False, load_from="UDiskId"), - "UHostId": fields.Str(required=False, load_from="UHostId"), - } - - -""" -API: RenameUDisk - -重命名UDisk -""" - - -class RenameUDiskRequestSchema(schema.RequestSchema): - """ RenameUDisk - 重命名UDisk - """ - - fields = { - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "UDiskId": fields.Str(required=True, dump_to="UDiskId"), - "UDiskName": fields.Str(required=True, dump_to="UDiskName"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class RenameUDiskResponseSchema(schema.ResponseSchema): - """ RenameUDisk - 重命名UDisk - """ - - fields = {} - - -""" -API: ResizeUDisk - -调整UDisk容量 -""" - - -class ResizeUDiskRequestSchema(schema.RequestSchema): - """ ResizeUDisk - 调整UDisk容量 - """ - - fields = { - "CouponId": fields.Str(required=False, dump_to="CouponId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Size": fields.Int(required=True, dump_to="Size"), - "UDiskId": fields.Str(required=True, dump_to="UDiskId"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class ResizeUDiskResponseSchema(schema.ResponseSchema): - """ ResizeUDisk - 调整UDisk容量 - """ - - fields = {} - - -""" -API: RestoreUDisk - -从备份恢复数据至UDisk -""" - - -class RestoreUDiskRequestSchema(schema.RequestSchema): - """ RestoreUDisk - 从备份恢复数据至UDisk - """ - - fields = { - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "SnapshotId": fields.Str(required=False, dump_to="SnapshotId"), - "SnapshotTime": fields.Int(required=False, dump_to="SnapshotTime"), - "UDiskId": fields.Str(required=True, dump_to="UDiskId"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class RestoreUDiskResponseSchema(schema.ResponseSchema): - """ RestoreUDisk - 从备份恢复数据至UDisk - """ - - fields = {} - - -""" -API: SetUDiskUDataArkMode - -设置UDisk数据方舟的状态 -""" - - -class SetUDiskUDataArkModeRequestSchema(schema.RequestSchema): - """ SetUDiskUDataArkMode - 设置UDisk数据方舟的状态 - """ - - fields = { - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "UDataArkMode": fields.Str(required=True, dump_to="UDataArkMode"), - "UDiskId": fields.Str(required=True, dump_to="UDiskId"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class SetUDiskUDataArkModeResponseSchema(schema.ResponseSchema): - """ SetUDiskUDataArkMode - 设置UDisk数据方舟的状态 - """ - - fields = {} +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.typesystem import schema, fields +from ucloud.services.udisk.schemas import models + +""" UDisk API Schema +""" +""" +API: AttachUDisk + +将一个可用的UDisk挂载到某台主机上,当UDisk挂载成功后,还需要在主机内部进行文件系统操作 +""" + + +class AttachUDiskRequestSchema(schema.RequestSchema): + """ AttachUDisk - 将一个可用的UDisk挂载到某台主机上,当UDisk挂载成功后,还需要在主机内部进行文件系统操作 + """ + + fields = { + "MultiAttach": fields.Str(required=False, dump_to="MultiAttach"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "UDiskId": fields.Str(required=True, dump_to="UDiskId"), + "UHostId": fields.Str(required=True, dump_to="UHostId"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class AttachUDiskResponseSchema(schema.ResponseSchema): + """ AttachUDisk - 将一个可用的UDisk挂载到某台主机上,当UDisk挂载成功后,还需要在主机内部进行文件系统操作 + """ + + fields = { + "UDiskId": fields.Str(required=False, load_from="UDiskId"), + "UHostId": fields.Str(required=False, load_from="UHostId"), + } + + +""" +API: CloneUDisk + +从UDisk创建UDisk克隆 +""" + + +class CloneUDiskRequestSchema(schema.RequestSchema): + """ CloneUDisk - 从UDisk创建UDisk克隆 + """ + + fields = { + "ChargeType": fields.Str(required=False, dump_to="ChargeType"), + "Comment": fields.Str(required=False, dump_to="Comment"), + "CouponId": fields.Str(required=False, dump_to="CouponId"), + "Name": fields.Str(required=True, dump_to="Name"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Quantity": fields.Int(required=False, dump_to="Quantity"), + "Region": fields.Str(required=True, dump_to="Region"), + "SourceId": fields.Str(required=True, dump_to="SourceId"), + "UDataArkMode": fields.Str(required=False, dump_to="UDataArkMode"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class CloneUDiskResponseSchema(schema.ResponseSchema): + """ CloneUDisk - 从UDisk创建UDisk克隆 + """ + + fields = { + "UDiskId": fields.List( + fields.Str(), required=False, load_from="UDiskId" + ) + } + + +""" +API: CloneUDiskSnapshot + +从快照创建UDisk克隆 +""" + + +class CloneUDiskSnapshotRequestSchema(schema.RequestSchema): + """ CloneUDiskSnapshot - 从快照创建UDisk克隆 + """ + + fields = { + "ChargeType": fields.Str(required=False, dump_to="ChargeType"), + "Comment": fields.Str(required=False, dump_to="Comment"), + "CouponId": fields.Str(required=False, dump_to="CouponId"), + "Name": fields.Str(required=True, dump_to="Name"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Quantity": fields.Int(required=False, dump_to="Quantity"), + "Region": fields.Str(required=True, dump_to="Region"), + "Size": fields.Int(required=True, dump_to="Size"), + "SourceId": fields.Str(required=True, dump_to="SourceId"), + "UDataArkMode": fields.Str(required=False, dump_to="UDataArkMode"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class CloneUDiskSnapshotResponseSchema(schema.ResponseSchema): + """ CloneUDiskSnapshot - 从快照创建UDisk克隆 + """ + + fields = { + "UDiskId": fields.List( + fields.Str(), required=False, load_from="UDiskId" + ) + } + + +""" +API: CreateUDisk + +创建UDisk磁盘 +""" + + +class CreateUDiskRequestSchema(schema.RequestSchema): + """ CreateUDisk - 创建UDisk磁盘 + """ + + fields = { + "ChargeType": fields.Str(required=False, dump_to="ChargeType"), + "CmkId": fields.Str(required=False, dump_to="CmkId"), + "CouponId": fields.Str(required=False, dump_to="CouponId"), + "DiskType": fields.Str(required=False, dump_to="DiskType"), + "Name": fields.Str(required=True, dump_to="Name"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Quantity": fields.Int(required=False, dump_to="Quantity"), + "Region": fields.Str(required=True, dump_to="Region"), + "Size": fields.Int(required=True, dump_to="Size"), + "Tag": fields.Str(required=False, dump_to="Tag"), + "UDataArkMode": fields.Str(required=False, dump_to="UDataArkMode"), + "UKmsMode": fields.Str(required=False, dump_to="UKmsMode"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class CreateUDiskResponseSchema(schema.ResponseSchema): + """ CreateUDisk - 创建UDisk磁盘 + """ + + fields = { + "UDiskId": fields.List( + fields.Str(), required=False, load_from="UDiskId" + ) + } + + +""" +API: CreateUDiskSnapshot + +创建snapshot快照 +""" + + +class CreateUDiskSnapshotRequestSchema(schema.RequestSchema): + """ CreateUDiskSnapshot - 创建snapshot快照 + """ + + fields = { + "ChargeType": fields.Str(required=False, dump_to="ChargeType"), + "Comment": fields.Str(required=False, dump_to="Comment"), + "Name": fields.Str(required=True, dump_to="Name"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Quantity": fields.Int(required=False, dump_to="Quantity"), + "Region": fields.Str(required=True, dump_to="Region"), + "UDiskId": fields.Str(required=True, dump_to="UDiskId"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class CreateUDiskSnapshotResponseSchema(schema.ResponseSchema): + """ CreateUDiskSnapshot - 创建snapshot快照 + """ + + fields = { + "SnapshotId": fields.List( + fields.Str(), required=True, load_from="SnapshotId" + ) + } + + +""" +API: DeleteUDisk + +删除UDisk +""" + + +class DeleteUDiskRequestSchema(schema.RequestSchema): + """ DeleteUDisk - 删除UDisk + """ + + fields = { + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "UDiskId": fields.Str(required=True, dump_to="UDiskId"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class DeleteUDiskResponseSchema(schema.ResponseSchema): + """ DeleteUDisk - 删除UDisk + """ + + fields = {} + + +""" +API: DeleteUDiskSnapshot + +删除Snapshot +""" + + +class DeleteUDiskSnapshotRequestSchema(schema.RequestSchema): + """ DeleteUDiskSnapshot - 删除Snapshot + """ + + fields = { + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "SnapshotId": fields.Str(required=False, dump_to="SnapshotId"), + "UDiskId": fields.Str(required=False, dump_to="UDiskId"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class DeleteUDiskSnapshotResponseSchema(schema.ResponseSchema): + """ DeleteUDiskSnapshot - 删除Snapshot + """ + + fields = {} + + +""" +API: DescribeUDisk + +获取UDisk实例 +""" + + +class DescribeUDiskRequestSchema(schema.RequestSchema): + """ DescribeUDisk - 获取UDisk实例 + """ + + fields = { + "DiskType": fields.Str(required=False, dump_to="DiskType"), + "IsBoot": fields.Str(required=False, dump_to="IsBoot"), + "Limit": fields.Int(required=False, dump_to="Limit"), + "Offset": fields.Int(required=False, dump_to="Offset"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "ProtocolVersion": fields.Int( + required=False, dump_to="ProtocolVersion" + ), + "Region": fields.Str(required=True, dump_to="Region"), + "UDiskId": fields.Str(required=False, dump_to="UDiskId"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class DescribeUDiskResponseSchema(schema.ResponseSchema): + """ DescribeUDisk - 获取UDisk实例 + """ + + fields = { + "DataSet": fields.List( + models.UDiskDataSetSchema(), required=False, load_from="DataSet" + ), + "TotalCount": fields.Int(required=False, load_from="TotalCount"), + } + + +""" +API: DescribeUDiskPrice + +获取UDisk实例价格信息 +""" + + +class DescribeUDiskPriceRequestSchema(schema.RequestSchema): + """ DescribeUDiskPrice - 获取UDisk实例价格信息 + """ + + fields = { + "ChargeType": fields.Str(required=False, dump_to="ChargeType"), + "DiskType": fields.Str(required=False, dump_to="DiskType"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Quantity": fields.Int(required=False, dump_to="Quantity"), + "Region": fields.Str(required=True, dump_to="Region"), + "Size": fields.Int(required=True, dump_to="Size"), + "UDataArkMode": fields.Str(required=False, dump_to="UDataArkMode"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class DescribeUDiskPriceResponseSchema(schema.ResponseSchema): + """ DescribeUDiskPrice - 获取UDisk实例价格信息 + """ + + fields = { + "DataSet": fields.List( + models.UDiskPriceDataSetSchema(), + required=False, + load_from="DataSet", + ) + } + + +""" +API: DescribeUDiskSnapshot + +获取UDisk快照 +""" + + +class DescribeUDiskSnapshotRequestSchema(schema.RequestSchema): + """ DescribeUDiskSnapshot - 获取UDisk快照 + """ + + fields = { + "Limit": fields.Int(required=False, dump_to="Limit"), + "Offset": fields.Int(required=False, dump_to="Offset"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "SnapshotId": fields.Str(required=False, dump_to="SnapshotId"), + "UDiskId": fields.Str(required=False, dump_to="UDiskId"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class DescribeUDiskSnapshotResponseSchema(schema.ResponseSchema): + """ DescribeUDiskSnapshot - 获取UDisk快照 + """ + + fields = { + "DataSet": fields.List( + models.UDiskSnapshotSetSchema(), required=False, load_from="DataSet" + ), + "TotalCount": fields.Int(required=False, load_from="TotalCount"), + } + + +""" +API: DescribeUDiskUpgradePrice + +获取UDisk升级价格信息 +""" + + +class DescribeUDiskUpgradePriceRequestSchema(schema.RequestSchema): + """ DescribeUDiskUpgradePrice - 获取UDisk升级价格信息 + """ + + fields = { + "DiskType": fields.Str(required=False, dump_to="DiskType"), + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Size": fields.Int(required=True, dump_to="Size"), + "SourceId": fields.Str(required=True, dump_to="SourceId"), + "UDataArkMode": fields.Str(required=False, dump_to="UDataArkMode"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class DescribeUDiskUpgradePriceResponseSchema(schema.ResponseSchema): + """ DescribeUDiskUpgradePrice - 获取UDisk升级价格信息 + """ + + fields = { + "OriginalPrice": fields.Int(required=False, load_from="OriginalPrice"), + "Price": fields.Int(required=False, load_from="Price"), + } + + +""" +API: DetachUDisk + +卸载某个已经挂载在指定UHost实例上的UDisk +""" + + +class DetachUDiskRequestSchema(schema.RequestSchema): + """ DetachUDisk - 卸载某个已经挂载在指定UHost实例上的UDisk + """ + + fields = { + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "UDiskId": fields.Str(required=True, dump_to="UDiskId"), + "UHostId": fields.Str(required=True, dump_to="UHostId"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class DetachUDiskResponseSchema(schema.ResponseSchema): + """ DetachUDisk - 卸载某个已经挂载在指定UHost实例上的UDisk + """ + + fields = { + "UDiskId": fields.Str(required=False, load_from="UDiskId"), + "UHostId": fields.Str(required=False, load_from="UHostId"), + } + + +""" +API: RenameUDisk + +重命名UDisk +""" + + +class RenameUDiskRequestSchema(schema.RequestSchema): + """ RenameUDisk - 重命名UDisk + """ + + fields = { + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "UDiskId": fields.Str(required=True, dump_to="UDiskId"), + "UDiskName": fields.Str(required=True, dump_to="UDiskName"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class RenameUDiskResponseSchema(schema.ResponseSchema): + """ RenameUDisk - 重命名UDisk + """ + + fields = {} + + +""" +API: ResizeUDisk + +调整UDisk容量 +""" + + +class ResizeUDiskRequestSchema(schema.RequestSchema): + """ ResizeUDisk - 调整UDisk容量 + """ + + fields = { + "CouponId": fields.Str(required=False, dump_to="CouponId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Size": fields.Int(required=True, dump_to="Size"), + "UDiskId": fields.Str(required=True, dump_to="UDiskId"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class ResizeUDiskResponseSchema(schema.ResponseSchema): + """ ResizeUDisk - 调整UDisk容量 + """ + + fields = {} + + +""" +API: RestoreUDisk + +从备份恢复数据至UDisk +""" + + +class RestoreUDiskRequestSchema(schema.RequestSchema): + """ RestoreUDisk - 从备份恢复数据至UDisk + """ + + fields = { + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "SnapshotId": fields.Str(required=False, dump_to="SnapshotId"), + "SnapshotTime": fields.Int(required=False, dump_to="SnapshotTime"), + "UDiskId": fields.Str(required=True, dump_to="UDiskId"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class RestoreUDiskResponseSchema(schema.ResponseSchema): + """ RestoreUDisk - 从备份恢复数据至UDisk + """ + + fields = {} + + +""" +API: SetUDiskUDataArkMode + +设置UDisk数据方舟的状态 +""" + + +class SetUDiskUDataArkModeRequestSchema(schema.RequestSchema): + """ SetUDiskUDataArkMode - 设置UDisk数据方舟的状态 + """ + + fields = { + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "UDataArkMode": fields.Str(required=True, dump_to="UDataArkMode"), + "UDiskId": fields.Str(required=True, dump_to="UDiskId"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class SetUDiskUDataArkModeResponseSchema(schema.ResponseSchema): + """ SetUDiskUDataArkMode - 设置UDisk数据方舟的状态 + """ + + fields = {} diff --git a/ucloud/services/udisk/schemas/models.py b/ucloud/services/udisk/schemas/models.py index 99481ff..d0675af 100644 --- a/ucloud/services/udisk/schemas/models.py +++ b/ucloud/services/udisk/schemas/models.py @@ -1,76 +1,82 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.typesystem import schema, fields - - -class UDiskDataSetSchema(schema.ResponseSchema): - """ UDiskDataSet - DescribeUDisk - """ - - fields = { - "ArkSwitchEnable": fields.Int(required=False, load_from="ArkSwitchEnable"), - "ChargeType": fields.Str(required=False, load_from="ChargeType"), - "CloneEnable": fields.Int(required=False, load_from="CloneEnable"), - "CmkId": fields.Str(required=False, load_from="CmkId"), - "CmkIdAlias": fields.Str(required=False, load_from="CmkIdAlias"), - "CmkIdStatus": fields.Str(required=False, load_from="CmkIdStatus"), - "CreateTime": fields.Int(required=False, load_from="CreateTime"), - "DataKey": fields.Str(required=False, load_from="DataKey"), - "DeviceName": fields.Str(required=False, load_from="DeviceName"), - "DiskType": fields.Str(required=False, load_from="DiskType"), - "ExpiredTime": fields.Int(required=False, load_from="ExpiredTime"), - "IsExpire": fields.Str(required=False, load_from="IsExpire"), - "Name": fields.Str(required=False, load_from="Name"), - "Size": fields.Int(required=False, load_from="Size"), - "SnapEnable": fields.Int(required=False, load_from="SnapEnable"), - "SnapshotCount": fields.Int(required=False, load_from="SnapshotCount"), - "SnapshotLimit": fields.Int(required=False, load_from="SnapshotLimit"), - "Status": fields.Str(required=False, load_from="Status"), - "Tag": fields.Str(required=False, load_from="Tag"), - "UDataArkMode": fields.Str(required=False, load_from="UDataArkMode"), - "UDiskId": fields.Str(required=False, load_from="UDiskId"), - "UHostIP": fields.Str(required=False, load_from="UHostIP"), - "UHostId": fields.Str(required=False, load_from="UHostId"), - "UHostName": fields.Str(required=False, load_from="UHostName"), - "UKmsMode": fields.Str(required=False, load_from="UKmsMode"), - "Version": fields.Str(required=False, load_from="Version"), - "Zone": fields.Str(required=False, load_from="Zone"), - } - - -class UDiskPriceDataSetSchema(schema.ResponseSchema): - """ UDiskPriceDataSet - DescribeUDiskPrice - """ - - fields = { - "ChargeName": fields.Str(required=False, load_from="ChargeName"), - "ChargeType": fields.Str(required=False, load_from="ChargeType"), - "Price": fields.Float(required=False, load_from="Price"), - } - - -class UDiskSnapshotSetSchema(schema.ResponseSchema): - """ UDiskSnapshotSet - DescribeUDiskSnapshot - """ - - fields = { - "CmkId": fields.Str(required=False, load_from="CmkId"), - "CmkIdAlias": fields.Str(required=False, load_from="CmkIdAlias"), - "CmkIdStatus": fields.Str(required=False, load_from="CmkIdStatus"), - "Comment": fields.Str(required=False, load_from="Comment"), - "CreateTime": fields.Int(required=True, load_from="CreateTime"), - "DataKey": fields.Str(required=False, load_from="DataKey"), - "DiskType": fields.Int(required=True, load_from="DiskType"), - "ExpiredTime": fields.Int(required=False, load_from="ExpiredTime"), - "IsUDiskAvailable": fields.Bool(required=False, load_from="IsUDiskAvailable"), - "Name": fields.Str(required=True, load_from="Name"), - "Size": fields.Int(required=True, load_from="Size"), - "SnapshotId": fields.Str(required=True, load_from="SnapshotId"), - "Status": fields.Str(required=True, load_from="Status"), - "UDiskId": fields.Str(required=True, load_from="UDiskId"), - "UDiskName": fields.Str(required=True, load_from="UDiskName"), - "UHostId": fields.Str(required=False, load_from="UHostId"), - "UKmsMode": fields.Str(required=False, load_from="UKmsMode"), - "Version": fields.Str(required=False, load_from="Version"), - } +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.typesystem import schema, fields + + +class UDiskDataSetSchema(schema.ResponseSchema): + """ UDiskDataSet - DescribeUDisk + """ + + fields = { + "ArkSwitchEnable": fields.Int( + required=False, load_from="ArkSwitchEnable" + ), + "ChargeType": fields.Str(required=False, load_from="ChargeType"), + "CloneEnable": fields.Int(required=False, load_from="CloneEnable"), + "CmkId": fields.Str(required=False, load_from="CmkId"), + "CmkIdAlias": fields.Str(required=False, load_from="CmkIdAlias"), + "CmkIdStatus": fields.Str(required=False, load_from="CmkIdStatus"), + "CreateTime": fields.Int(required=False, load_from="CreateTime"), + "DataKey": fields.Str(required=False, load_from="DataKey"), + "DeviceName": fields.Str(required=False, load_from="DeviceName"), + "DiskType": fields.Str(required=False, load_from="DiskType"), + "ExpiredTime": fields.Int(required=False, load_from="ExpiredTime"), + "IsBoot": fields.Str(required=False, load_from="IsBoot"), + "IsExpire": fields.Str(required=False, load_from="IsExpire"), + "Name": fields.Str(required=False, load_from="Name"), + "Size": fields.Int(required=False, load_from="Size"), + "SnapEnable": fields.Int(required=False, load_from="SnapEnable"), + "SnapshotCount": fields.Int(required=False, load_from="SnapshotCount"), + "SnapshotLimit": fields.Int(required=False, load_from="SnapshotLimit"), + "Status": fields.Str(required=False, load_from="Status"), + "Tag": fields.Str(required=False, load_from="Tag"), + "UDataArkMode": fields.Str(required=False, load_from="UDataArkMode"), + "UDiskId": fields.Str(required=False, load_from="UDiskId"), + "UHostIP": fields.Str(required=False, load_from="UHostIP"), + "UHostId": fields.Str(required=False, load_from="UHostId"), + "UHostName": fields.Str(required=False, load_from="UHostName"), + "UKmsMode": fields.Str(required=False, load_from="UKmsMode"), + "Version": fields.Str(required=False, load_from="Version"), + "Zone": fields.Str(required=False, load_from="Zone"), + } + + +class UDiskPriceDataSetSchema(schema.ResponseSchema): + """ UDiskPriceDataSet - DescribeUDiskPrice + """ + + fields = { + "ChargeName": fields.Str(required=False, load_from="ChargeName"), + "ChargeType": fields.Str(required=False, load_from="ChargeType"), + "OriginalPrice": fields.Int(required=False, load_from="OriginalPrice"), + "Price": fields.Int(required=False, load_from="Price"), + } + + +class UDiskSnapshotSetSchema(schema.ResponseSchema): + """ UDiskSnapshotSet - DescribeUDiskSnapshot + """ + + fields = { + "CmkId": fields.Str(required=False, load_from="CmkId"), + "CmkIdAlias": fields.Str(required=False, load_from="CmkIdAlias"), + "CmkIdStatus": fields.Str(required=False, load_from="CmkIdStatus"), + "Comment": fields.Str(required=False, load_from="Comment"), + "CreateTime": fields.Int(required=True, load_from="CreateTime"), + "DataKey": fields.Str(required=False, load_from="DataKey"), + "DiskType": fields.Int(required=True, load_from="DiskType"), + "ExpiredTime": fields.Int(required=False, load_from="ExpiredTime"), + "IsUDiskAvailable": fields.Bool( + required=False, load_from="IsUDiskAvailable" + ), + "Name": fields.Str(required=True, load_from="Name"), + "Size": fields.Int(required=True, load_from="Size"), + "SnapshotId": fields.Str(required=True, load_from="SnapshotId"), + "Status": fields.Str(required=True, load_from="Status"), + "UDiskId": fields.Str(required=True, load_from="UDiskId"), + "UDiskName": fields.Str(required=True, load_from="UDiskName"), + "UHostId": fields.Str(required=False, load_from="UHostId"), + "UKmsMode": fields.Str(required=False, load_from="UKmsMode"), + "Version": fields.Str(required=False, load_from="Version"), + } diff --git a/ucloud/services/udpn/__init__.py b/ucloud/services/udpn/__init__.py index 4c48b5a..40a96af 100644 --- a/ucloud/services/udpn/__init__.py +++ b/ucloud/services/udpn/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- diff --git a/ucloud/services/udpn/client.py b/ucloud/services/udpn/client.py index 86bd6ca..769c40b 100644 --- a/ucloud/services/udpn/client.py +++ b/ucloud/services/udpn/client.py @@ -1,184 +1,184 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.client import Client -from ucloud.services.udpn.schemas import apis - - -class UDPNClient(Client): - def __init__(self, config, transport=None, middleware=None, logger=None): - super(UDPNClient, self).__init__(config, transport, middleware, logger) - - def allocate_udpn(self, req=None, **kwargs): - """ AllocateUDPN - 分配一条 UDPN 专线 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Bandwidth** (int) - (Required) 带宽 - - **Peer1** (str) - (Required) 专线可用区1,支持地域:北京二:cn-bj2, 上海二:cn-sh2, 广东:cn-gd, 亚太: hk, 上海一:cn-sh1, 法兰克福:ge-fra, 新加坡:sg, 洛杉矶:us-la, 华盛顿:us-ws, 东京:jpn-tky - - **Peer2** (str) - (Required) 专线可用区2,支持地域:北京二:cn-bj2, 上海二:cn-sh2, 广东:cn-gd, 亚太: hk, 上海一:cn-sh1, 法兰克福:ge-fra, 新加坡:sg, 洛杉矶:us-la, 华盛顿:us-ws, 东京:jpn-tky - - **ChargeType** (str) - 计费类型,枚举值为: Year,按年付费; Month,按月付费; Dynamic,按需付费 - - **CouponId** (str) - 代金劵 - - **Quantity** (int) - 计费时长,默认 1 - - **Response** - - - **UDPNId** (str) - 资源名称 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.AllocateUDPNRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("AllocateUDPN", d, **kwargs) - return apis.AllocateUDPNResponseSchema().loads(resp) - - def describe_udpn(self, req=None, **kwargs): - """ DescribeUDPN - 描述 UDPN - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Limit** (int) - 返回数据长度,默认为 20 - - **Offset** (int) - 列表起始位置偏移量,默认为 0 - - **UDPNId** (str) - 申请到的 UDPN 资源 ID。若为空,则查询该用户在机房所有的专线信息。非默认项目资源,需填写ProjectId - - **Response** - - - **DataSet** (list) - 见 **UDPNData** 模型定义 - - **TotalCount** (int) - 查询到的总数量 - - **Response Model** - - **UDPNData** - - - **Bandwidth** (int) - 带宽 - - **ChargeType** (str) - 计费类型 - - **CreateTime** (int) - unix 时间戳 创建时间 - - **ExpireTime** (int) - unix 时间戳 到期时间 - - **Peer1** (str) - 可用区域 1 - - **Peer2** (str) - 可用区域 2 - - **UDPNId** (str) - UDPN 资源短 ID - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeUDPNRequestSchema().dumps(d) - resp = self.invoke("DescribeUDPN", d, **kwargs) - return apis.DescribeUDPNResponseSchema().loads(resp) - - def get_udpn_line_list(self, req=None, **kwargs): - """ GetUDPNLineList - 获取当前支持的专线线路列表 - - **Request** - - - **ProjectId** (str) - (Config) - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Response** - - - **DataSet** (list) - 见 **UDPNLineSet** 模型定义 - - **TotalCount** (int) - DataSet中的元素个数 - - **Response Model** - - **UDPNLineSet** - - - **BandwidthUpperLimit** (int) - 线路带宽上限,单位 M - - **LocalRegion** (str) - 支持UDPN的地域之一,北京二:cn-bj2, 上海二:cn-sh2, 广东:cn-gd, 亚太: hk, 上海一:cn-sh1, 法兰克福:ge-fra, 新加坡:sg, 华盛顿:us-ws, 洛杉矶:us-la, 东京:jpn-tky - - **RemoteRegion** (str) - 支持UDPN的地域之一,北京二:cn-bj2, 上海二:cn-sh2, 广东:cn-gd, 亚太: hk, 上海一:cn-sh1, 法兰克福:ge-fra, 新加坡:sg, 华盛顿:us-ws, 洛杉矶:us-la, 东京:jpn-tky - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.GetUDPNLineListRequestSchema().dumps(d) - resp = self.invoke("GetUDPNLineList", d, **kwargs) - return apis.GetUDPNLineListResponseSchema().loads(resp) - - def get_udpn_price(self, req=None, **kwargs): - """ GetUDPNPrice - 获取 UDPN 价格 - - **Request** - - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Bandwidth** (int) - (Required) 带宽信息 - - **Peer1** (str) - (Required) 专线可用区1,支持地域:北京二:cn-bj2, 上海二:cn-sh2, 广东:cn-gd, 亚太: hk, 上海一:cn-sh1, 法兰克福:ge-fra, 新加坡:sg, 洛杉矶:us-la, 华盛顿:us-ws, 东京:jpn-tky - - **Peer2** (str) - (Required) 专线可用区2,支持地域:北京二:cn-bj2, 上海二:cn-sh2, 广东:cn-gd, 亚太: hk, 上海一:cn-sh1, 法兰克福:ge-fra, 新加坡:sg, 洛杉矶:us-la, 华盛顿:us-ws, 东京:jpn-tky - - **ChargeType** (str) - 计费类型 - - **Quantity** (int) - 购买时长 - - **Response** - - - **Price** (float) - 专线价格 - - **PurchaseValue** (int) - 资源有效期 unix 时间戳 - - """ - d = {"Region": self.config.region} - req and d.update(req) - d = apis.GetUDPNPriceRequestSchema().dumps(d) - resp = self.invoke("GetUDPNPrice", d, **kwargs) - return apis.GetUDPNPriceResponseSchema().loads(resp) - - def get_udpn_upgrade_price(self, req=None, **kwargs): - """ GetUDPNUpgradePrice - 获取专线升级价格 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Bandwidth** (int) - (Required) 带宽 - - **UDPNId** (str) - (Required) 专线带宽资源 Id - - **Response** - - - **Price** (float) - 升级后的价格 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.GetUDPNUpgradePriceRequestSchema().dumps(d) - resp = self.invoke("GetUDPNUpgradePrice", d, **kwargs) - return apis.GetUDPNUpgradePriceResponseSchema().loads(resp) - - def modify_udpn_bandwidth(self, req=None, **kwargs): - """ ModifyUDPNBandwidth - 修改带宽值 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Bandwidth** (int) - (Required) 调整后专线带宽, 单位为Mbps,取值范围为大于等于2且小于等于1000([2-1000])的整数 - - **UDPNId** (str) - (Required) UDPN Id - - **CouponId** (str) - 代金劵 ID - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.ModifyUDPNBandwidthRequestSchema().dumps(d) - resp = self.invoke("ModifyUDPNBandwidth", d, **kwargs) - return apis.ModifyUDPNBandwidthResponseSchema().loads(resp) - - def release_udpn(self, req=None, **kwargs): - """ ReleaseUDPN - 释放 UDPN - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **UDPNId** (str) - (Required) UDPN 资源 Id - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.ReleaseUDPNRequestSchema().dumps(d) - resp = self.invoke("ReleaseUDPN", d, **kwargs) - return apis.ReleaseUDPNResponseSchema().loads(resp) +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.client import Client +from ucloud.services.udpn.schemas import apis + + +class UDPNClient(Client): + def __init__(self, config, transport=None, middleware=None, logger=None): + super(UDPNClient, self).__init__(config, transport, middleware, logger) + + def allocate_udpn(self, req=None, **kwargs): + """ AllocateUDPN - 分配一条 UDPN 专线 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Bandwidth** (int) - (Required) 带宽 + - **Peer1** (str) - (Required) 专线可用区1,支持地域:北京二:cn-bj2, 上海二:cn-sh2, 广东:cn-gd, 亚太: hk, 上海一:cn-sh1, 法兰克福:ge-fra, 新加坡:sg, 洛杉矶:us-la, 华盛顿:us-ws, 东京:jpn-tky + - **Peer2** (str) - (Required) 专线可用区2,支持地域:北京二:cn-bj2, 上海二:cn-sh2, 广东:cn-gd, 亚太: hk, 上海一:cn-sh1, 法兰克福:ge-fra, 新加坡:sg, 洛杉矶:us-la, 华盛顿:us-ws, 东京:jpn-tky + - **ChargeType** (str) - 计费类型,枚举值为: Year,按年付费; Month,按月付费; Dynamic,按需付费 + - **CouponId** (str) - 代金劵 + - **Quantity** (int) - 计费时长,默认 1 + + **Response** + + - **UDPNId** (str) - 资源名称 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.AllocateUDPNRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("AllocateUDPN", d, **kwargs) + return apis.AllocateUDPNResponseSchema().loads(resp) + + def describe_udpn(self, req=None, **kwargs): + """ DescribeUDPN - 描述 UDPN + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Limit** (int) - 返回数据长度,默认为 20 + - **Offset** (int) - 列表起始位置偏移量,默认为 0 + - **UDPNId** (str) - 申请到的 UDPN 资源 ID。若为空,则查询该用户在机房所有的专线信息。非默认项目资源,需填写ProjectId + + **Response** + + - **DataSet** (list) - 见 **UDPNData** 模型定义 + - **TotalCount** (int) - 查询到的总数量 + + **Response Model** + + **UDPNData** + + - **Bandwidth** (int) - 带宽 + - **ChargeType** (str) - 计费类型 + - **CreateTime** (int) - unix 时间戳 创建时间 + - **ExpireTime** (int) - unix 时间戳 到期时间 + - **Peer1** (str) - 可用区域 1 + - **Peer2** (str) - 可用区域 2 + - **UDPNId** (str) - UDPN 资源短 ID + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeUDPNRequestSchema().dumps(d) + resp = self.invoke("DescribeUDPN", d, **kwargs) + return apis.DescribeUDPNResponseSchema().loads(resp) + + def get_udpn_line_list(self, req=None, **kwargs): + """ GetUDPNLineList - 获取当前支持的专线线路列表 + + **Request** + + - **ProjectId** (str) - (Config) + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + + **Response** + + - **DataSet** (list) - 见 **UDPNLineSet** 模型定义 + - **TotalCount** (int) - DataSet中的元素个数 + + **Response Model** + + **UDPNLineSet** + + - **BandwidthUpperLimit** (int) - 线路带宽上限,单位 M + - **LocalRegion** (str) - 支持UDPN的地域之一,北京二:cn-bj2, 上海二:cn-sh2, 广东:cn-gd, 亚太: hk, 上海一:cn-sh1, 法兰克福:ge-fra, 新加坡:sg, 华盛顿:us-ws, 洛杉矶:us-la, 东京:jpn-tky + - **RemoteRegion** (str) - 支持UDPN的地域之一,北京二:cn-bj2, 上海二:cn-sh2, 广东:cn-gd, 亚太: hk, 上海一:cn-sh1, 法兰克福:ge-fra, 新加坡:sg, 华盛顿:us-ws, 洛杉矶:us-la, 东京:jpn-tky + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.GetUDPNLineListRequestSchema().dumps(d) + resp = self.invoke("GetUDPNLineList", d, **kwargs) + return apis.GetUDPNLineListResponseSchema().loads(resp) + + def get_udpn_price(self, req=None, **kwargs): + """ GetUDPNPrice - 获取 UDPN 价格 + + **Request** + + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Bandwidth** (int) - (Required) 带宽信息 + - **Peer1** (str) - (Required) 专线可用区1,支持地域:北京二:cn-bj2, 上海二:cn-sh2, 广东:cn-gd, 亚太: hk, 上海一:cn-sh1, 法兰克福:ge-fra, 新加坡:sg, 洛杉矶:us-la, 华盛顿:us-ws, 东京:jpn-tky + - **Peer2** (str) - (Required) 专线可用区2,支持地域:北京二:cn-bj2, 上海二:cn-sh2, 广东:cn-gd, 亚太: hk, 上海一:cn-sh1, 法兰克福:ge-fra, 新加坡:sg, 洛杉矶:us-la, 华盛顿:us-ws, 东京:jpn-tky + - **ChargeType** (str) - 计费类型 + - **Quantity** (int) - 购买时长 + + **Response** + + - **Price** (float) - 专线价格 + - **PurchaseValue** (int) - 资源有效期 unix 时间戳 + + """ + d = {"Region": self.config.region} + req and d.update(req) + d = apis.GetUDPNPriceRequestSchema().dumps(d) + resp = self.invoke("GetUDPNPrice", d, **kwargs) + return apis.GetUDPNPriceResponseSchema().loads(resp) + + def get_udpn_upgrade_price(self, req=None, **kwargs): + """ GetUDPNUpgradePrice - 获取专线升级价格 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Bandwidth** (int) - (Required) 带宽 + - **UDPNId** (str) - (Required) 专线带宽资源 Id + + **Response** + + - **Price** (float) - 升级后的价格 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.GetUDPNUpgradePriceRequestSchema().dumps(d) + resp = self.invoke("GetUDPNUpgradePrice", d, **kwargs) + return apis.GetUDPNUpgradePriceResponseSchema().loads(resp) + + def modify_udpn_bandwidth(self, req=None, **kwargs): + """ ModifyUDPNBandwidth - 修改带宽值 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Bandwidth** (int) - (Required) 调整后专线带宽, 单位为Mbps,取值范围为大于等于2且小于等于1000([2-1000])的整数 + - **UDPNId** (str) - (Required) UDPN Id + - **CouponId** (str) - 代金劵 ID + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.ModifyUDPNBandwidthRequestSchema().dumps(d) + resp = self.invoke("ModifyUDPNBandwidth", d, **kwargs) + return apis.ModifyUDPNBandwidthResponseSchema().loads(resp) + + def release_udpn(self, req=None, **kwargs): + """ ReleaseUDPN - 释放 UDPN + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **UDPNId** (str) - (Required) UDPN 资源 Id + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.ReleaseUDPNRequestSchema().dumps(d) + resp = self.invoke("ReleaseUDPN", d, **kwargs) + return apis.ReleaseUDPNResponseSchema().loads(resp) diff --git a/ucloud/services/udpn/schemas/__init__.py b/ucloud/services/udpn/schemas/__init__.py index 4c48b5a..40a96af 100644 --- a/ucloud/services/udpn/schemas/__init__.py +++ b/ucloud/services/udpn/schemas/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- diff --git a/ucloud/services/udpn/schemas/apis.py b/ucloud/services/udpn/schemas/apis.py index 59be99a..5c5332e 100644 --- a/ucloud/services/udpn/schemas/apis.py +++ b/ucloud/services/udpn/schemas/apis.py @@ -1,206 +1,206 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.typesystem import schema, fields -from ucloud.services.udpn.schemas import models - -""" UDPN API Schema -""" -""" -API: AllocateUDPN - -分配一条 UDPN 专线 -""" - - -class AllocateUDPNRequestSchema(schema.RequestSchema): - """ AllocateUDPN - 分配一条 UDPN 专线 - """ - - fields = { - "Bandwidth": fields.Int(required=True, dump_to="Bandwidth"), - "ChargeType": fields.Str(required=False, dump_to="ChargeType"), - "CouponId": fields.Str(required=False, dump_to="CouponId"), - "Peer1": fields.Str(required=True, dump_to="Peer1"), - "Peer2": fields.Str(required=True, dump_to="Peer2"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Quantity": fields.Int(required=False, dump_to="Quantity"), - "Region": fields.Str(required=False, dump_to="Region"), - } - - -class AllocateUDPNResponseSchema(schema.ResponseSchema): - """ AllocateUDPN - 分配一条 UDPN 专线 - """ - - fields = {"UDPNId": fields.Str(required=True, load_from="UDPNId")} - - -""" -API: DescribeUDPN - -描述 UDPN -""" - - -class DescribeUDPNRequestSchema(schema.RequestSchema): - """ DescribeUDPN - 描述 UDPN - """ - - fields = { - "Limit": fields.Int(required=False, dump_to="Limit"), - "Offset": fields.Int(required=False, dump_to="Offset"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=False, dump_to="Region"), - "UDPNId": fields.Str(required=False, dump_to="UDPNId"), - } - - -class DescribeUDPNResponseSchema(schema.ResponseSchema): - """ DescribeUDPN - 描述 UDPN - """ - - fields = { - "DataSet": fields.List( - models.UDPNDataSchema(), required=False, load_from="DataSet" - ), - "TotalCount": fields.Int(required=True, load_from="TotalCount"), - } - - -""" -API: GetUDPNLineList - -获取当前支持的专线线路列表 -""" - - -class GetUDPNLineListRequestSchema(schema.RequestSchema): - """ GetUDPNLineList - 获取当前支持的专线线路列表 - """ - - fields = { - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=False, dump_to="Region"), - } - - -class GetUDPNLineListResponseSchema(schema.ResponseSchema): - """ GetUDPNLineList - 获取当前支持的专线线路列表 - """ - - fields = { - "DataSet": fields.List( - models.UDPNLineSetSchema(), required=True, load_from="DataSet" - ), - "TotalCount": fields.Int(required=True, load_from="TotalCount"), - } - - -""" -API: GetUDPNPrice - -获取 UDPN 价格 -""" - - -class GetUDPNPriceRequestSchema(schema.RequestSchema): - """ GetUDPNPrice - 获取 UDPN 价格 - """ - - fields = { - "Bandwidth": fields.Int(required=True, dump_to="Bandwidth"), - "ChargeType": fields.Str(required=False, dump_to="ChargeType"), - "Peer1": fields.Str(required=True, dump_to="Peer1"), - "Peer2": fields.Str(required=True, dump_to="Peer2"), - "Quantity": fields.Int(required=False, dump_to="Quantity"), - "Region": fields.Str(required=False, dump_to="Region"), - } - - -class GetUDPNPriceResponseSchema(schema.ResponseSchema): - """ GetUDPNPrice - 获取 UDPN 价格 - """ - - fields = { - "Price": fields.Float(required=True, load_from="Price"), - "PurchaseValue": fields.Int(required=True, load_from="PurchaseValue"), - } - - -""" -API: GetUDPNUpgradePrice - -获取专线升级价格 -""" - - -class GetUDPNUpgradePriceRequestSchema(schema.RequestSchema): - """ GetUDPNUpgradePrice - 获取专线升级价格 - """ - - fields = { - "Bandwidth": fields.Int(required=True, dump_to="Bandwidth"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=False, dump_to="Region"), - "UDPNId": fields.Str(required=True, dump_to="UDPNId"), - } - - -class GetUDPNUpgradePriceResponseSchema(schema.ResponseSchema): - """ GetUDPNUpgradePrice - 获取专线升级价格 - """ - - fields = {"Price": fields.Float(required=True, load_from="Price")} - - -""" -API: ModifyUDPNBandwidth - -修改带宽值 -""" - - -class ModifyUDPNBandwidthRequestSchema(schema.RequestSchema): - """ ModifyUDPNBandwidth - 修改带宽值 - """ - - fields = { - "Bandwidth": fields.Int(required=True, dump_to="Bandwidth"), - "CouponId": fields.Str(required=False, dump_to="CouponId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=False, dump_to="Region"), - "UDPNId": fields.Str(required=True, dump_to="UDPNId"), - } - - -class ModifyUDPNBandwidthResponseSchema(schema.ResponseSchema): - """ ModifyUDPNBandwidth - 修改带宽值 - """ - - fields = {} - - -""" -API: ReleaseUDPN - -释放 UDPN -""" - - -class ReleaseUDPNRequestSchema(schema.RequestSchema): - """ ReleaseUDPN - 释放 UDPN - """ - - fields = { - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=False, dump_to="Region"), - "UDPNId": fields.Str(required=True, dump_to="UDPNId"), - } - - -class ReleaseUDPNResponseSchema(schema.ResponseSchema): - """ ReleaseUDPN - 释放 UDPN - """ - - fields = {} +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.typesystem import schema, fields +from ucloud.services.udpn.schemas import models + +""" UDPN API Schema +""" +""" +API: AllocateUDPN + +分配一条 UDPN 专线 +""" + + +class AllocateUDPNRequestSchema(schema.RequestSchema): + """ AllocateUDPN - 分配一条 UDPN 专线 + """ + + fields = { + "Bandwidth": fields.Int(required=True, dump_to="Bandwidth"), + "ChargeType": fields.Str(required=False, dump_to="ChargeType"), + "CouponId": fields.Str(required=False, dump_to="CouponId"), + "Peer1": fields.Str(required=True, dump_to="Peer1"), + "Peer2": fields.Str(required=True, dump_to="Peer2"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Quantity": fields.Int(required=False, dump_to="Quantity"), + "Region": fields.Str(required=False, dump_to="Region"), + } + + +class AllocateUDPNResponseSchema(schema.ResponseSchema): + """ AllocateUDPN - 分配一条 UDPN 专线 + """ + + fields = {"UDPNId": fields.Str(required=True, load_from="UDPNId")} + + +""" +API: DescribeUDPN + +描述 UDPN +""" + + +class DescribeUDPNRequestSchema(schema.RequestSchema): + """ DescribeUDPN - 描述 UDPN + """ + + fields = { + "Limit": fields.Int(required=False, dump_to="Limit"), + "Offset": fields.Int(required=False, dump_to="Offset"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=False, dump_to="Region"), + "UDPNId": fields.Str(required=False, dump_to="UDPNId"), + } + + +class DescribeUDPNResponseSchema(schema.ResponseSchema): + """ DescribeUDPN - 描述 UDPN + """ + + fields = { + "DataSet": fields.List( + models.UDPNDataSchema(), required=False, load_from="DataSet" + ), + "TotalCount": fields.Int(required=True, load_from="TotalCount"), + } + + +""" +API: GetUDPNLineList + +获取当前支持的专线线路列表 +""" + + +class GetUDPNLineListRequestSchema(schema.RequestSchema): + """ GetUDPNLineList - 获取当前支持的专线线路列表 + """ + + fields = { + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=False, dump_to="Region"), + } + + +class GetUDPNLineListResponseSchema(schema.ResponseSchema): + """ GetUDPNLineList - 获取当前支持的专线线路列表 + """ + + fields = { + "DataSet": fields.List( + models.UDPNLineSetSchema(), required=True, load_from="DataSet" + ), + "TotalCount": fields.Int(required=True, load_from="TotalCount"), + } + + +""" +API: GetUDPNPrice + +获取 UDPN 价格 +""" + + +class GetUDPNPriceRequestSchema(schema.RequestSchema): + """ GetUDPNPrice - 获取 UDPN 价格 + """ + + fields = { + "Bandwidth": fields.Int(required=True, dump_to="Bandwidth"), + "ChargeType": fields.Str(required=False, dump_to="ChargeType"), + "Peer1": fields.Str(required=True, dump_to="Peer1"), + "Peer2": fields.Str(required=True, dump_to="Peer2"), + "Quantity": fields.Int(required=False, dump_to="Quantity"), + "Region": fields.Str(required=False, dump_to="Region"), + } + + +class GetUDPNPriceResponseSchema(schema.ResponseSchema): + """ GetUDPNPrice - 获取 UDPN 价格 + """ + + fields = { + "Price": fields.Float(required=True, load_from="Price"), + "PurchaseValue": fields.Int(required=True, load_from="PurchaseValue"), + } + + +""" +API: GetUDPNUpgradePrice + +获取专线升级价格 +""" + + +class GetUDPNUpgradePriceRequestSchema(schema.RequestSchema): + """ GetUDPNUpgradePrice - 获取专线升级价格 + """ + + fields = { + "Bandwidth": fields.Int(required=True, dump_to="Bandwidth"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=False, dump_to="Region"), + "UDPNId": fields.Str(required=True, dump_to="UDPNId"), + } + + +class GetUDPNUpgradePriceResponseSchema(schema.ResponseSchema): + """ GetUDPNUpgradePrice - 获取专线升级价格 + """ + + fields = {"Price": fields.Float(required=True, load_from="Price")} + + +""" +API: ModifyUDPNBandwidth + +修改带宽值 +""" + + +class ModifyUDPNBandwidthRequestSchema(schema.RequestSchema): + """ ModifyUDPNBandwidth - 修改带宽值 + """ + + fields = { + "Bandwidth": fields.Int(required=True, dump_to="Bandwidth"), + "CouponId": fields.Str(required=False, dump_to="CouponId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=False, dump_to="Region"), + "UDPNId": fields.Str(required=True, dump_to="UDPNId"), + } + + +class ModifyUDPNBandwidthResponseSchema(schema.ResponseSchema): + """ ModifyUDPNBandwidth - 修改带宽值 + """ + + fields = {} + + +""" +API: ReleaseUDPN + +释放 UDPN +""" + + +class ReleaseUDPNRequestSchema(schema.RequestSchema): + """ ReleaseUDPN - 释放 UDPN + """ + + fields = { + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=False, dump_to="Region"), + "UDPNId": fields.Str(required=True, dump_to="UDPNId"), + } + + +class ReleaseUDPNResponseSchema(schema.ResponseSchema): + """ ReleaseUDPN - 释放 UDPN + """ + + fields = {} diff --git a/ucloud/services/udpn/schemas/models.py b/ucloud/services/udpn/schemas/models.py index 33f8015..5d3a9d7 100644 --- a/ucloud/services/udpn/schemas/models.py +++ b/ucloud/services/udpn/schemas/models.py @@ -1,32 +1,32 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.typesystem import schema, fields - - -class UDPNDataSchema(schema.ResponseSchema): - """ UDPNData - UDPN 详细信息 - """ - - fields = { - "Bandwidth": fields.Int(required=True, load_from="Bandwidth"), - "ChargeType": fields.Str(required=True, load_from="ChargeType"), - "CreateTime": fields.Int(required=True, load_from="CreateTime"), - "ExpireTime": fields.Int(required=True, load_from="ExpireTime"), - "Peer1": fields.Str(required=True, load_from="Peer1"), - "Peer2": fields.Str(required=True, load_from="Peer2"), - "UDPNId": fields.Str(required=True, load_from="UDPNId"), - } - - -class UDPNLineSetSchema(schema.ResponseSchema): - """ UDPNLineSet - GetUDPNLineList - """ - - fields = { - "BandwidthUpperLimit": fields.Int( - required=True, load_from="BandwidthUpperLimit" - ), - "LocalRegion": fields.Str(required=True, load_from="LocalRegion"), - "RemoteRegion": fields.Str(required=True, load_from="RemoteRegion"), - } +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.typesystem import schema, fields + + +class UDPNDataSchema(schema.ResponseSchema): + """ UDPNData - UDPN 详细信息 + """ + + fields = { + "Bandwidth": fields.Int(required=True, load_from="Bandwidth"), + "ChargeType": fields.Str(required=True, load_from="ChargeType"), + "CreateTime": fields.Int(required=True, load_from="CreateTime"), + "ExpireTime": fields.Int(required=True, load_from="ExpireTime"), + "Peer1": fields.Str(required=True, load_from="Peer1"), + "Peer2": fields.Str(required=True, load_from="Peer2"), + "UDPNId": fields.Str(required=True, load_from="UDPNId"), + } + + +class UDPNLineSetSchema(schema.ResponseSchema): + """ UDPNLineSet - GetUDPNLineList + """ + + fields = { + "BandwidthUpperLimit": fields.Int( + required=True, load_from="BandwidthUpperLimit" + ), + "LocalRegion": fields.Str(required=True, load_from="LocalRegion"), + "RemoteRegion": fields.Str(required=True, load_from="RemoteRegion"), + } diff --git a/ucloud/services/uhost/__init__.py b/ucloud/services/uhost/__init__.py index 4c48b5a..40a96af 100644 --- a/ucloud/services/uhost/__init__.py +++ b/ucloud/services/uhost/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- diff --git a/ucloud/services/uhost/client.py b/ucloud/services/uhost/client.py index ad8c877..fa4a327 100644 --- a/ucloud/services/uhost/client.py +++ b/ucloud/services/uhost/client.py @@ -1,765 +1,765 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.client import Client -from ucloud.services.uhost.schemas import apis - - -class UHostClient(Client): - def __init__(self, config, transport=None, middleware=None, logger=None): - super(UHostClient, self).__init__(config, transport, middleware, logger) - - def copy_custom_image(self, req=None, **kwargs): - """ CopyCustomImage - 复制自制镜像 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **SourceImageId** (str) - (Required) 源镜像Id, 参见 DescribeImage - - **TargetProjectId** (str) - (Required) 目标项目Id, 参见 GetProjectList - - **TargetImageDescription** (str) - 目标镜像描述 - - **TargetImageName** (str) - 目标镜像名称 - - **TargetRegion** (str) - 目标地域,不跨地域不用填 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **TargetImageId** (str) - 目标镜像Id - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.CopyCustomImageRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("CopyCustomImage", d, **kwargs) - return apis.CopyCustomImageResponseSchema().loads(resp) - - def create_custom_image(self, req=None, **kwargs): - """ CreateCustomImage - 从指定UHost实例,生成自定义镜像。 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **ImageName** (str) - (Required) 镜像名称 - - **UHostId** (str) - (Required) UHost实例ID 参见 `DescribeUHostInstance `_ - - **ImageDescription** (str) - 镜像描述 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **ImageId** (str) - 镜像Id - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.CreateCustomImageRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("CreateCustomImage", d, **kwargs) - return apis.CreateCustomImageResponseSchema().loads(resp) - - def create_uhost_instance(self, req=None, **kwargs): - """ CreateUHostInstance - 创建UHost实例。 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **ImageId** (str) - (Required) 镜像ID。 请通过 `DescribeImage `_ 获取 - - **LoginMode** (str) - (Required) 主机登陆模式。密码(默认选项): Password。 - - **Password** (str) - (Required) UHost密码。请遵照 `字段规范 `_ 设定密码。密码需使用base64进行编码,举例如下:# echo -n Password1 | base64UGFzc3dvcmQx。 - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **AlarmTemplateId** (int) - 告警模板id,如果传了告警模板id,且告警模板id正确,则绑定告警模板。绑定告警模板失败只会在后台有日志,不会影响创建主机流程,也不会在前端报错。 - - **BootDiskSpace** (int) - 【待废弃,不建议调用】系统盘大小。 单位:GB, 范围[20,100], 步长:10 - - **CPU** (int) - 虚拟CPU核数。可选参数:1-64(具体机型与CPU的对应关系参照控制台)。默认值: 4。 - - **ChargeType** (str) - 计费模式。枚举值为: \\ > Year,按年付费; \\ > Month,按月付费;\\ > Dynamic,按小时付费 \\ 默认为月付 - - **CouponId** (str) - 主机代金券ID。请通过DescribeCoupon接口查询,或登录用户中心查看 - - **DiskPassword** (str) - 【待废弃,不建议调用】加密盘的密码。若输入此字段,自动选择加密盘。加密盘需要权限位。 - - **DiskSpace** (int) - 【待废弃,不建议调用】数据盘大小。 单位:GB, 范围[0,8000], 步长:10, 默认值:20,云盘支持0-8000;本地普通盘支持0-2000;本地SSD盘(包括所有GPU机型)支持100-1000 - - **Disks** (list) - 见 **CreateUHostInstanceParamDisks** 模型定义 - - **GPU** (int) - GPU卡核心数。仅GPU机型支持此字段(可选范围与UHostType相关) - - **GpuType** (str) - GPU类型,枚举值["K80", "P40", "V100"] - - **HostType** (str) - 【已废弃】宿主机类型,N2,N1 - - **HotplugFeature** (bool) - 是否开启热升级特性。True为开启,False为未开启,默认False。 - - **InstallAgent** (str) - 【暂不支持】是否安装UGA。'yes': 安装;其他或者不填:不安装。 - - **IsolationGroup** (str) - 硬件隔离组id。可通过DescribeIsolationGroup获取。 - - **KeyPair** (str) - 【暂不支持】Keypair公钥,LoginMode为KeyPair时此项必须 - - **MachineType** (str) - 云主机机型(V2.0),枚举值["N", "C", "G", "O"]。参考 `云主机机型说明 `_ 。 - - **MaxCount** (int) - 【批量创建主机时必填】最大创建主机数量,取值范围是[1,100]; - - **Memory** (int) - 内存大小。单位:MB。范围 :[1024, 262144],取值为1024的倍数(可选范围参考控制台)。默认值:8192 - - **MinimalCpuPlatform** (str) - 最低cpu平台,枚举值["Intel/Auto", "Intel/IvyBridge", "Intel/Haswell", "Intel/Broadwell", "Intel/Skylake", "Intel/Cascadelake"。 - - **Name** (str) - UHost实例名称。默认:UHost。请遵照 `字段规范 `_ 设定实例名称。 - - **NetCapability** (str) - 网络增强。枚举值:Normal(默认),不开启; Super,开启网络增强1.0; Ultra,开启网络增强2.0(仅支持部分可用区,请参考控制台) - - **NetworkId** (str) - 【已废弃】网络ID(VPC2.0情况下无需填写)。VPC1.0情况下,若不填写,代表优先选择基础网络; 若填写,代表选择子网。参见DescribeSubnet。 - - **NetworkInterface** (list) - 见 **CreateUHostInstanceParamNetworkInterface** 模型定义 - - **PrivateIp** (list) - 【数组】创建云主机时指定内网IP。若不传值,则随机分配当前子网下的IP。调用方式举例:PrivateIp.0=x.x.x.x。当前只支持一个内网IP。 - - **PrivateMac** (str) - 【批量创建该参数无效】【内部字段】创建云主机时指定Mac。调用方式举例:PrivateMac="xx:xx:xx:xx:xx:xx"。 - - **Quantity** (int) - 购买时长。默认:值 1。按小时购买(Dynamic)时无需此参数。 月付时,此参数传0,代表购买至月末。 - - **ResourceType** (int) - 【内部参数】资源类型 - - **SecurityGroupId** (str) - 防火墙Id,默认:Web推荐防火墙。如何查询SecurityGroupId请参见 `DescribeSecurityGroup `_ 。 - - **SetId** (int) - - - **StorageType** (str) - 【待废弃,不建议调用】磁盘类型,同时设定系统盘和数据盘的磁盘类型。枚举值为:LocalDisk,本地磁盘; UDisk,云硬盘;默认为LocalDisk。仅部分可用区支持云硬盘方式的主机存储方式,具体请查询控制台。 - - **SubnetId** (str) - 子网 ID。默认为当前地域的默认子网。 - - **Tag** (str) - 业务组。默认:Default(Default即为未分组)。请遵照 `字段规范 `_ 设定业务组。 - - **TimemachineFeature** (str) - 【待废弃,不建议调用】是否开启方舟特性。Yes为开启方舟,No为关闭方舟。目前仅选择普通本地盘+普通本地盘 或 SSD云盘+普通云盘的组合支持开启方舟。 - - **UHostType** (str) - 【建议后续不再使用】云主机机型V1.0。参考 `云主机机型说明 `_ 。 - - **UserDataScript** (str) - 【暂不支持】cloudinit方式下,用户初始化脚本 - - **VPCId** (str) - VPC ID。默认为当前地域的默认VPC。 - - **Response** - - - **IPs** (list) - 【批量创建不会返回】IP信息 - - **UHostIds** (list) - UHost实例Id集合 - - **Request Model** - - **CreateUHostInstanceParamNetworkInterfaceEIPGlobalSSH** - - - **Area** (str) - 填写支持SSH访问IP的地区名称,如“洛杉矶”,“新加坡”,“香港”,“东京”,“华盛顿”,“法兰克福”。Area和AreaCode两者必填一个 - - **AreaCode** (str) - GlobalSSH的。AreaCode, 区域航空港国际通用代码。Area和AreaCode两者必填一个 - - **Port** (int) - SSH端口,1-65535且不能使用80,443端口 - - **CreateUHostInstanceParamNetworkInterfaceEIP** - - - **Bandwidth** (int) - 【如果绑定EIP这个参数必填】弹性IP的外网带宽, 单位为Mbps. 共享带宽模式必须指定0M带宽, 非共享带宽模式必须指定非0Mbps带宽. 各地域非共享带宽的带宽范围如下: 流量计费[1-300],带宽计费[1-800] - - **CouponId** (str) - 当前EIP代金券id。请通过DescribeCoupon接口查询,或登录用户中心查看 - - **GlobalSSH** (dict) - 见 **CreateUHostInstanceParamNetworkInterfaceEIPGlobalSSH** 模型定义 - - **OperatorName** (str) - 【如果绑定EIP这个参数必填】弹性IP的线路如下: 国际: International BGP: Bgp 各地域允许的线路参数如下: cn-sh1: Bgp cn-sh2: Bgp cn-gd: Bgp cn-bj1: Bgp cn-bj2: Bgp hk: International us-ca: International th-bkk: International kr-seoul:International us-ws:International ge-fra:International sg:International tw-kh:International.其他海外线路均为 International - - **PayMode** (str) - 弹性IP的计费模式. 枚举值: "Traffic", 流量计费; "Bandwidth", 带宽计费; "ShareBandwidth",共享带宽模式. "Free":免费带宽模式.默认为 "Bandwidth". - - **ShareBandwidthId** (str) - 绑定的共享带宽Id,仅当PayMode为ShareBandwidth时有效 - - **CreateUHostInstanceParamDisks** - - - **BackupType** (str) - 磁盘备份方案。枚举值:\\ > NONE,无备份 \\ > DATAARK,数据方舟 \\ 当前磁盘支持的备份模式参考 `磁盘类型 `_ - - **CouponId** (str) - 云盘代金券id。不适用于系统盘/本地盘。请通过DescribeCoupon接口查询,或登录用户中心查看 - - **Encrypted** (bool) - 【功能仅部分可用区开放,详询技术支持】磁盘是否加密。加密:true, 不加密: false加密必须传入对应的的KmsKeyId - - **IsBoot** (str) - 是否是系统盘。枚举值:\\ > True,是系统盘 \\ > False,是数据盘(默认)。Disks数组中有且只能有一块盘是系统盘。 - - **KmsKeyId** (str) - 【功能仅部分可用区开放,详询技术支持】kms key id。选择加密盘时必填。 - - **Size** (int) - 磁盘大小,单位GB。请参考 `磁盘类型 `_ 。 - - **Type** (str) - 磁盘类型。请参考 `磁盘类型 `_ 。 - - **CreateUHostInstanceParamNetworkInterface** - - - **EIP** (dict) - 见 **CreateUHostInstanceParamNetworkInterfaceEIP** 模型定义 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.CreateUHostInstanceRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("CreateUHostInstance", d, **kwargs) - return apis.CreateUHostInstanceResponseSchema().loads(resp) - - def describe_image(self, req=None, **kwargs): - """ DescribeImage - 获取指定数据中心镜像列表,用户可通过指定操作系统类型,镜像Id进行过滤。 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **ImageId** (str) - 镜像Id - - **ImageType** (str) - 镜像类型。标准镜像:Base,镜像市场:Business, 自定义镜像:Custom,默认返回所有类型 - - **Limit** (int) - 返回数据长度,默认为20 - - **Offset** (int) - 列表起始位置偏移量,默认为0 - - **OsType** (str) - 操作系统类型:Linux, Windows 默认返回所有类型 - - **PriceSet** (int) - 是否返回价格:1返回,0不返回;默认不返回 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **ImageSet** (list) - 见 **UHostImageSet** 模型定义 - - **TotalCount** (int) - 满足条件的镜像总数 - - **Response Model** - - **UHostImageSet** - - - **CreateTime** (int) - 创建时间,格式为Unix时间戳 - - **Features** (list) - 特殊状态标识, 目前包含NetEnhnced(网络增强1.0), NetEnhanced_Ultra](网络增强2.0) - - **FuncType** (str) - 行业镜像类型(仅行业镜像将返回这个值) - - **ImageDescription** (str) - 镜像描述 - - **ImageId** (str) - 镜像ID - - **ImageName** (str) - 镜像名称 - - **ImageSize** (int) - 镜像大小 - - **ImageType** (str) - 镜像类型 标准镜像:Base, 行业镜像:Business,自定义镜像:Custom - - **IntegratedSoftware** (str) - 集成软件名称(仅行业镜像将返回这个值) - - **Links** (str) - 介绍链接(仅行业镜像将返回这个值) - - **MinimalCPU** (str) - 默认值为空'''。当CentOS 7.3/7.4/7.5等镜像会标记为“Broadwell” - - **OsName** (str) - 操作系统名称 - - **OsType** (str) - 操作系统类型:Liunx,Windows - - **State** (str) - 镜像状态, 可用:Available,制作中:Making, 不可用:Unavailable - - **Vendor** (str) - 供应商(仅行业镜像将返回这个值) - - **Zone** (str) - 可用区,参见 `可用区列表 `_ | - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeImageRequestSchema().dumps(d) - resp = self.invoke("DescribeImage", d, **kwargs) - return apis.DescribeImageResponseSchema().loads(resp) - - def describe_uhost_instance(self, req=None, **kwargs): - """ DescribeUHostInstance - 获取主机或主机列表信息,并可根据数据中心,主机ID等参数进行过滤。 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **IsolationGroup** (str) - 硬件隔离组id。通过硬件隔离组筛选主机。 - - **LifeCycle** (int) - 1:普通云主机;2:抢占型云主机;如不传此参数,默认全部获取 - - **Limit** (int) - 返回数据长度,默认为20,最大100 - - **Offset** (int) - 列表起始位置偏移量,默认为0 - - **SubnetId** (str) - 子网id。通过子网筛选主机。北京一地域无效。 - - **Tag** (str) - 要查询的业务组名称 - - **UHostIds** (list) - 【数组】UHost主机的资源ID,例如UHostIds.0代表希望获取信息 的主机1,UHostIds.1代表主机2。 如果不传入,则返回当前Region 所有符合条件的UHost实例。 - - **VPCId** (str) - vpc id。通过VPC筛选主机。北京一地域无效。 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **TotalCount** (int) - UHostInstance总数 - - **UHostSet** (list) - 见 **UHostInstanceSet** 模型定义 - - **Response Model** - - **UHostDiskSet** - - - **BackupType** (str) - 备份方案。若开通了数据方舟,则为DataArk - - **DiskId** (str) - 磁盘ID - - **DiskType** (str) - 磁盘类型。请参考 `磁盘类型 `_ 。 - - **Drive** (str) - 磁盘盘符 - - **Encrypted** (bool) - true: 加密盘 false:非加密盘 - - **IsBoot** (str) - 是否是系统盘。枚举值:\\ > True,是系统盘 \\ > False,是数据盘(默认)。Disks数组中有且只能有一块盘是系统盘。 - - **Name** (str) - UDisk名字(仅当磁盘是UDisk时返回) - - **Size** (int) - 磁盘大小,单位: GB - - **Type** (str) - 【建议不再使用】磁盘类型。系统盘: Boot,数据盘: Data,网络盘:Udisk - - **UHostIPSet** - - - **Bandwidth** (int) - IP对应的带宽, 单位: Mb (内网IP不显示带宽信息) - - **Default** (str) - 是否默认的弹性网卡的信息。true: 是默认弹性网卡;其他值:不是。 - - **IP** (str) - IP地址 - - **IPId** (str) - IP资源ID (内网IP无对应的资源ID) - - **SubnetId** (str) - IP地址对应的子网 ID(北京一当前字段为空) - - **Type** (str) - 国际: Internation,BGP: Bgp,内网: Private - - **VPCId** (str) - IP地址对应的VPC ID(北京一当前字段为空) - - **UHostInstanceSet** - - - **AutoRenew** (str) - 是否自动续费,自动续费:“Yes”,不自动续费:“No” - - **BasicImageId** (str) - 基础镜像ID(指当前自定义镜像的来源镜像) - - **BasicImageName** (str) - 基础镜像名称(指当前自定义镜像的来源镜像) - - **BootDiskState** (str) - 系统盘状态 Normal表示初始化完成;Initializing表示在初始化。仍在初始化的系统盘无法制作镜像。 - - **CPU** (int) - 虚拟CPU核数,单位: 个 - - **ChargeType** (str) - 计费模式,枚举值为: Year,按年付费; Month,按月付费; Dynamic,按需付费(需开启权限); - - **CreateTime** (int) - 创建时间,格式为Unix时间戳 - - **DiskSet** (list) - 见 **UHostDiskSet** 模型定义 - - **ExpireTime** (int) - 到期时间,格式为Unix时间戳 - - **GPU** (int) - GPU个数 - - **HostType** (str) - 【建议不再使用】主机系列:N2,表示系列2;N1,表示系列1 - - **HotplugFeature** (bool) - true: 开启热升级; false,未开启热升级 - - **IPSet** (list) - 见 **UHostIPSet** 模型定义 - - **ImageId** (str) - 【建议不再使用】主机的系统盘ID。 - - **IsolationGroup** (str) - 隔离组id,不在隔离组则返回"" - - **LifeCycle** (str) - 主机的生命周期类型。目前仅支持Normal:普通; - - **MachineType** (str) - 云主机机型(新)。参考 `云主机机型说明 `_ 。 - - **Memory** (int) - 内存大小,单位: MB - - **Name** (str) - UHost实例名称 - - **NetCapability** (str) - 网络增强。Normal: 无;Super: 网络增强1.0; Ultra: 网络增强2.0 - - **NetworkState** (str) - 【建议不再使用】网络状态。 连接:Connected, 断开:NotConnected - - **OsName** (str) - 创建主机的最初来源镜像的操作系统名称(若直接通过基础镜像创建,此处返回和BasicImageName一致) - - **OsType** (str) - 操作系统类别。返回"Linux"或者"Windows" - - **Remark** (str) - 备注 - - **State** (str) - 实例状态,枚举值:\\ >初始化: Initializing; \\ >启动中: Starting; \\> 运行中: Running; \\> 关机中: Stopping; \\ >关机: Stopped \\ >安装失败: Install Fail; \\ >重启中: Rebooting - - **StorageType** (str) - 【建议不再使用】主机磁盘类型。 枚举值为:\\ > LocalDisk,本地磁盘; \\ > UDisk 云盘。\\只要有一块磁盘为本地盘,即返回LocalDisk。 - - **SubnetType** (str) - 【建议不再使用】仅北京A的云主机会返回此字段。基础网络模式:Default;子网模式:Private - - **Tag** (str) - 业务组名称 - - **TimemachineFeature** (str) - 【建议不再使用】数据方舟模式。枚举值:\\ > Yes: 开启方舟; \\ > no,未开启方舟 - - **TotalDiskSpace** (int) - 总的数据盘存储空间。 - - **UHostId** (str) - UHost实例ID - - **UHostType** (str) - 【建议不再使用】云主机机型(旧)。参考 `云主机机型说明 `_ 。 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeUHostInstanceRequestSchema().dumps(d) - resp = self.invoke("DescribeUHostInstance", d, **kwargs) - return apis.DescribeUHostInstanceResponseSchema().loads(resp) - - def describe_uhost_tags(self, req=None, **kwargs): - """ DescribeUHostTags - 获取指定数据中心的业务组列表。 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **TagSet** (list) - 见 **UHostTagSet** 模型定义 - - **TotalCount** (int) - 已有主机的业务组总个数 - - **Response Model** - - **UHostTagSet** - - - **Tag** (str) - 业务组名称 - - **TotalCount** (int) - 该业务组中包含的主机个数 - - **Zone** (str) - 可用区 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeUHostTagsRequestSchema().dumps(d) - resp = self.invoke("DescribeUHostTags", d, **kwargs) - return apis.DescribeUHostTagsResponseSchema().loads(resp) - - def get_uhost_instance_price(self, req=None, **kwargs): - """ GetUHostInstancePrice - 根据UHost实例配置,获取UHost实例的价格。 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **CPU** (int) - (Required) CPU核数。可选参数:1-64。可选范围参照控制台。默认值: 4 - - **Count** (int) - (Required) 购买台数,范围[1,5] - - **ImageId** (str) - (Required) 镜像Id,可通过 `DescribeImage `_ 获取镜像ID - - **Memory** (int) - (Required) 内存大小。单位:MB。范围 :[1024, 262144],取值为1024的倍数(可选范围参照好控制台)。默认值:8192 - - **ChargeType** (str) - 计费模式。枚举值为: \\ > Year,按年付费; \\ > Month,按月付费;\\ > Dynamic,按小时付费 \\ 默认为月付。 - - **DiskSpace** (int) - 【待废弃】数据盘大小,单位: GB,范围[0,1000],步长: 10,默认值: 0 - - **Disks** (list) - 见 **GetUHostInstancePriceParamDisks** 模型定义 - - **GPU** (int) - GPU卡核心数。仅GPU机型支持此字段。 - - **GpuType** (str) - GPU类型,枚举值["K80", "P40", "V100"] - - **LifeCycle** (int) - 【未支持】1:普通云主机;2:抢占性云主机;默认普通 - - **MachineType** (str) - 云主机机型(V2版本概念)。枚举值["N", "C", "G", "O"]。参考 `云主机机型说明 `_ 。 - - **NetCapability** (str) - 网络增强。枚举值:Normal,不开启; Super,开启网络增强1.0。 默认值为Normal。 - - **Quantity** (int) - 购买时长。默认: 1。按小时购买(Dynamic)时无需此参数。 月付时,此参数传0,代表了购买至月末。 - - **StorageType** (str) - 【待废弃】磁盘类型,同时设定系统盘和数据盘, 枚举值为:LocalDisk,本地磁盘; UDisk,云硬盘; 默认为LocalDisk 仅部分可用区支持云硬盘方式的主机存储方式,具体请查询控制台。 - - **TimemachineFeature** (str) - 【待废弃】方舟机型。No,Yes。默认是No。 - - **UHostType** (str) - 【待废弃】云主机机型(V1版本概念)。参考 `云主机机型说明 `_ 。 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **PriceSet** (list) - 见 **UHostPriceSet** 模型定义 - - **Request Model** - - **GetUHostInstancePriceParamDisks** - - - **BackupType** (str) - 磁盘备份方案。枚举值:\\ > NONE,无备份 \\ > DATAARK,数据方舟 \\ 当前磁盘支持的备份模式参考 `磁盘类型 `_ - - **IsBoot** (str) - 是否是系统盘。枚举值:\\ > True,是系统盘 \\ > False,是数据盘(默认)。Disks数组中有且只能有一块盘是系统盘。 - - **Size** (int) - 磁盘大小,单位GB。请参考 `磁盘类型 `_ 。 - - **Type** (str) - 磁盘类型。请参考 `磁盘类型 `_ 。 - - **Response Model** - - **UHostPriceSet** - - - **ChargeType** (str) - 计费类型。Year,Month,Dynamic - - **Price** (float) - 价格,单位: 元,保留小数点后两位有效数字 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.GetUHostInstancePriceRequestSchema().dumps(d) - resp = self.invoke("GetUHostInstancePrice", d, **kwargs) - return apis.GetUHostInstancePriceResponseSchema().loads(resp) - - def get_uhost_instance_vnc_info(self, req=None, **kwargs): - """ GetUHostInstanceVncInfo - 获取指定UHost实例的管理VNC配置详细信息。 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **UHostId** (str) - (Required) UHost实例ID 参见 `DescribeUHostInstance `_ - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **UhostId** (str) - UHost实例ID - - **VncIP** (str) - Vnc登录IP - - **VncPassword** (str) - Vnc 登录密码 - - **VncPort** (int) - Vnc登录端口 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.GetUHostInstanceVncInfoRequestSchema().dumps(d) - resp = self.invoke("GetUHostInstanceVncInfo", d, **kwargs) - return apis.GetUHostInstanceVncInfoResponseSchema().loads(resp) - - def get_uhost_upgrade_price(self, req=None, **kwargs): - """ GetUHostUpgradePrice - 获取UHost实例升级配置的价格。可选配置范围请参考 `云主机机型说明 `_ 。 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **UHostId** (str) - (Required) UHost实例ID。 参见 `DescribeUHostInstance `_ 。 - - **BootDiskSpace** (int) - 【待废弃】系统大小,单位: GB,范围[20,100],步长: 10。 - - **CPU** (int) - 虚拟CPU核数。可选参数:1-64(可选范围参考控制台)。默认值为当前实例的CPU核数。 - - **DiskSpace** (int) - 【待废弃】数据盘大小,单位: GB,范围[0,1000],步长: 10, 默认值是该主机当前数据盘大小。 - - **HostType** (str) - 【待废弃】主机系列,目前支持N1,N2 - - **Memory** (int) - 内存大小。单位:MB。范围 :[1024, 262144],取值为1024的倍数(可选范围参考控制台)。默认值为当前实例的内存大小。 - - **NetCapValue** (int) - 网卡升降级(1,表示升级,2表示降级,0表示不变) - - **TimemachineFeature** (str) - 方舟机型。No,Yes。默认是No。 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **Price** (float) - 规格调整差价。精确到小数点后2位。 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.GetUHostUpgradePriceRequestSchema().dumps(d) - resp = self.invoke("GetUHostUpgradePrice", d, **kwargs) - return apis.GetUHostUpgradePriceResponseSchema().loads(resp) - - def import_custom_image(self, req=None, **kwargs): - """ ImportCustomImage - 把UFile的镜像文件导入到UHost,生成自定义镜像 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Auth** (bool) - (Required) 是否授权。必须填true - - **Format** (str) - (Required) 镜像格式,可选RAW、VHD、VMDK、qcow2 - - **ImageName** (str) - (Required) 镜像名称 - - **OsName** (str) - (Required) 操作系统详细版本,请参考控制台的镜像版本;OsType为Other时,输入参数为Other - - **OsType** (str) - (Required) 操作系统平台,比如CentOS、Ubuntu、Windows、RedHat等,请参考控制台的镜像版本;若导入控制台上没有的操作系统,参数为Other - - **UFileUrl** (str) - (Required) UFile私有空间地址 - - **ImageDescription** (str) - 镜像描述 - - **Response** - - - **ImageId** (str) - 镜像Id - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.ImportCustomImageRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("ImportCustomImage", d, **kwargs) - return apis.ImportCustomImageResponseSchema().loads(resp) - - def modify_uhost_instance_name(self, req=None, **kwargs): - """ ModifyUHostInstanceName - 修改指定UHost实例名称,需要给出数据中心,UHostId,及新的实例名称。 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **UHostId** (str) - (Required) UHost实例ID 参见 `DescribeUHostInstance `_ - - **Name** (str) - UHost实例名称 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **UhostId** (str) - UHost实例ID - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.ModifyUHostInstanceNameRequestSchema().dumps(d) - resp = self.invoke("ModifyUHostInstanceName", d, **kwargs) - return apis.ModifyUHostInstanceNameResponseSchema().loads(resp) - - def modify_uhost_instance_remark(self, req=None, **kwargs): - """ ModifyUHostInstanceRemark - 修改指定UHost实例备注信息。 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **UHostId** (str) - (Required) UHost实例ID 参见 `DescribeUHostInstance `_ - - **Remark** (str) - 备注 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **UhostId** (str) - UHost实例ID - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.ModifyUHostInstanceRemarkRequestSchema().dumps(d) - resp = self.invoke("ModifyUHostInstanceRemark", d, **kwargs) - return apis.ModifyUHostInstanceRemarkResponseSchema().loads(resp) - - def modify_uhost_instance_tag(self, req=None, **kwargs): - """ ModifyUHostInstanceTag - 修改指定UHost实例业务组标识。 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **UHostId** (str) - (Required) UHost实例ID 参见 `DescribeUHostInstance `_ - - **Tag** (str) - 业务组名称 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **UhostId** (str) - UHost实例ID - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.ModifyUHostInstanceTagRequestSchema().dumps(d) - resp = self.invoke("ModifyUHostInstanceTag", d, **kwargs) - return apis.ModifyUHostInstanceTagResponseSchema().loads(resp) - - def poweroff_uhost_instance(self, req=None, **kwargs): - """ PoweroffUHostInstance - 直接关闭UHost实例电源,无需等待实例正常关闭。 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **UHostId** (str) - (Required) UHost实例ID 参见 `DescribeUHostInstance `_ - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **UhostId** (str) - UHost实例ID - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.PoweroffUHostInstanceRequestSchema().dumps(d) - resp = self.invoke("PoweroffUHostInstance", d, **kwargs) - return apis.PoweroffUHostInstanceResponseSchema().loads(resp) - - def reboot_uhost_instance(self, req=None, **kwargs): - """ RebootUHostInstance - 重新启动UHost实例,需要指定数据中心及UHostID两个参数的值。 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **UHostId** (str) - (Required) UHost实例ID 参见 `DescribeUHostInstance `_ - - **DiskPassword** (str) - 加密盘密码 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **UhostId** (str) - UHost实例ID - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.RebootUHostInstanceRequestSchema().dumps(d) - resp = self.invoke("RebootUHostInstance", d, **kwargs) - return apis.RebootUHostInstanceResponseSchema().loads(resp) - - def reinstall_uhost_instance(self, req=None, **kwargs): - """ ReinstallUHostInstance - 重新安装指定UHost实例的操作系统 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **UHostId** (str) - (Required) UHost实例资源ID 参见 `DescribeUHostInstance `_ - - **BootDiskSpace** (int) - 系统盘大小。 单位:GB, 范围[20,100], 步长:10 - - **DNSServers** (list) - 针对非私有子网主机,可自定义DNS。n可为0-2 - - **ImageId** (str) - 镜像Id,默认使用原镜像 参见 `DescribeImage `_ - - **Password** (str) - 如果创建UHost实例时LoginMode为Password,则必须填写,如果LoginMode为KeyPair,不需要填写 (密码格式使用BASE64编码;LoginMode不可变更) - - **ReserveDisk** (str) - 是否保留数据盘,保留:Yes,不报留:No, 默认:Yes;如果是从Windows重装为Linux或反之,则无法保留数据盘 - - **ResourceType** (int) - 云灾备指明191 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **UhostId** (str) - UHost实例资源ID - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.ReinstallUHostInstanceRequestSchema().dumps(d) - resp = self.invoke("ReinstallUHostInstance", d, **kwargs) - return apis.ReinstallUHostInstanceResponseSchema().loads(resp) - - def reset_uhost_instance_password(self, req=None, **kwargs): - """ ResetUHostInstancePassword - 重置UHost实例的管理员密码。 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Password** (str) - (Required) UHost新密码(密码格式使用BASE64编码) - - **UHostId** (str) - (Required) UHost实例ID - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **UhostId** (str) - UHost实例ID - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.ResetUHostInstancePasswordRequestSchema().dumps(d) - resp = self.invoke("ResetUHostInstancePassword", d, **kwargs) - return apis.ResetUHostInstancePasswordResponseSchema().loads(resp) - - def resize_attached_disk(self, req=None, **kwargs): - """ ResizeAttachedDisk - 修改挂载的磁盘大小,包含系统盘和数据盘 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **DiskId** (str) - (Required) 磁盘ID。参见 `DescribeUHostInstance `_ 返回值中的DiskSet。 - - **DiskSpace** (int) - (Required) 磁盘大小,单位GB,步长为10。取值范围需大于当前磁盘大小,最大值请参考 `磁盘类型 `_ 。 - - **UHostId** (str) - (Required) UHost实例ID。 参见 `DescribeUHostInstance `_ 。 - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **Response** - - - **DiskId** (str) - 改配成功的磁盘id - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.ResizeAttachedDiskRequestSchema().dumps(d) - resp = self.invoke("ResizeAttachedDisk", d, **kwargs) - return apis.ResizeAttachedDiskResponseSchema().loads(resp) - - def resize_uhost_instance(self, req=None, **kwargs): - """ ResizeUHostInstance - 修改指定UHost实例的资源配置,如CPU核心数,内存容量大小,网络增强等。可选配置范围请参考 `云主机机型说明 `_ 。 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **UHostId** (str) - (Required) UHost实例ID 参见 `DescribeUHostInstance `_ - - **BootDiskSpace** (int) - 【待废弃】系统盘大小,单位:GB,范围[20,100],步长:10,系统盘不支持缩容,因此不允许输入比当前实例系统盘小的值 - - **CPU** (int) - 虚拟CPU核数。可选参数:1-32(可选范围与UHostType相关)。默认值为当前实例的CPU核数 - - **DiskSpace** (int) - 【待废弃】数据盘大小,单位:GB,范围[10,1000]; SSD机型,单位:GB,范围[100,500];步长:10,默认值为当前实例的数据盘大小,数据盘不支持缩容,因此不允许输入比当前实例数据盘大小的值 - - **Memory** (int) - 内存大小。单位:MB。范围 :[1024, 262144],取值为1024的倍数(可选范围与UHostType相关)。默认值为当前实例的内存大小。 - - **NetCapValue** (int) - 网卡升降级(1,表示升级,2表示降级,0表示不变) - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **UhostId** (str) - UHost实例ID - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.ResizeUHostInstanceRequestSchema().dumps(d) - resp = self.invoke("ResizeUHostInstance", d, **kwargs) - return apis.ResizeUHostInstanceResponseSchema().loads(resp) - - def start_uhost_instance(self, req=None, **kwargs): - """ StartUHostInstance - 启动处于关闭状态的UHost实例,需要指定数据中心及UHostID两个参数的值。 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **UHostId** (str) - (Required) UHost实例ID 参见 `DescribeUHostInstance `_ - - **DiskPassword** (str) - 加密盘密码 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **UhostId** (str) - UHost实例ID - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.StartUHostInstanceRequestSchema().dumps(d) - resp = self.invoke("StartUHostInstance", d, **kwargs) - return apis.StartUHostInstanceResponseSchema().loads(resp) - - def stop_uhost_instance(self, req=None, **kwargs): - """ StopUHostInstance - 指停止处于运行状态的UHost实例,需指定数据中心及UhostID。 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **UHostId** (str) - (Required) UHost实例ID 参见 `DescribeUHostInstance `_ - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **UhostId** (str) - UHost实例ID - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.StopUHostInstanceRequestSchema().dumps(d) - resp = self.invoke("StopUHostInstance", d, **kwargs) - return apis.StopUHostInstanceResponseSchema().loads(resp) - - def terminate_custom_image(self, req=None, **kwargs): - """ TerminateCustomImage - 删除用户自定义镜像 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **ImageId** (str) - (Required) 自制镜像ID 参见 `DescribeImage `_ - - **Response** - - - **ImageId** (str) - 自制镜像Id - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.TerminateCustomImageRequestSchema().dumps(d) - resp = self.invoke("TerminateCustomImage", d, **kwargs) - return apis.TerminateCustomImageResponseSchema().loads(resp) - - def terminate_uhost_instance(self, req=None, **kwargs): - """ TerminateUHostInstance - 删除指定数据中心的UHost实例。 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **UHostId** (str) - (Required) UHost资源Id 参见 `DescribeUHostInstance `_ - - **Destroy** (int) - 是否直接删除,0表示按照原来的逻辑(有回收站权限,则进入回收站),1表示直接删除 - - **ReleaseEIP** (bool) - 是否释放绑定的EIP。true: 解绑EIP后,并释放;其他值或不填:解绑EIP。 - - **ReleaseUDisk** (bool) - 是否删除挂载的数据盘。true删除,其他不删除。 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **InRecycle** (str) - 放入回收站:"Yes", 彻底删除:“No” - - **UHostId** (str) - UHost 实例 Id - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.TerminateUHostInstanceRequestSchema().dumps(d) - resp = self.invoke("TerminateUHostInstance", d, **kwargs) - return apis.TerminateUHostInstanceResponseSchema().loads(resp) - - def upgrade_to_ark_uhost_instance(self, req=None, **kwargs): - """ UpgradeToArkUHostInstance - 普通升级为方舟机型 - - **Request** - - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **UHostIds** (list) - (Required) UHost主机的资源ID,例如UHostIds.0代表希望升级的主机1,UHostIds.1代表主机2。 - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **CouponId** (str) - 代金券ID 请参考DescribeCoupon接口 - - **Response** - - - **UHostSet** (list) - UHost主机的资源ID数组 - - """ - d = {"Region": self.config.region} - req and d.update(req) - d = apis.UpgradeToArkUHostInstanceRequestSchema().dumps(d) - resp = self.invoke("UpgradeToArkUHostInstance", d, **kwargs) - return apis.UpgradeToArkUHostInstanceResponseSchema().loads(resp) +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.client import Client +from ucloud.services.uhost.schemas import apis + + +class UHostClient(Client): + def __init__(self, config, transport=None, middleware=None, logger=None): + super(UHostClient, self).__init__(config, transport, middleware, logger) + + def copy_custom_image(self, req=None, **kwargs): + """ CopyCustomImage - 复制自制镜像 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **SourceImageId** (str) - (Required) 源镜像Id, 参见 DescribeImage + - **TargetProjectId** (str) - (Required) 目标项目Id, 参见 GetProjectList + - **TargetImageDescription** (str) - 目标镜像描述 + - **TargetImageName** (str) - 目标镜像名称 + - **TargetRegion** (str) - 目标地域,不跨地域不用填 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **TargetImageId** (str) - 目标镜像Id + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.CopyCustomImageRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("CopyCustomImage", d, **kwargs) + return apis.CopyCustomImageResponseSchema().loads(resp) + + def create_custom_image(self, req=None, **kwargs): + """ CreateCustomImage - 从指定UHost实例,生成自定义镜像。 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **ImageName** (str) - (Required) 镜像名称 + - **UHostId** (str) - (Required) UHost实例ID 参见 `DescribeUHostInstance `_ + - **ImageDescription** (str) - 镜像描述 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **ImageId** (str) - 镜像Id + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.CreateCustomImageRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("CreateCustomImage", d, **kwargs) + return apis.CreateCustomImageResponseSchema().loads(resp) + + def create_uhost_instance(self, req=None, **kwargs): + """ CreateUHostInstance - 创建UHost实例。 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **ImageId** (str) - (Required) 镜像ID。 请通过 `DescribeImage `_ 获取 + - **LoginMode** (str) - (Required) 主机登陆模式。密码(默认选项): Password。 + - **Password** (str) - (Required) UHost密码。请遵照 `字段规范 `_ 设定密码。密码需使用base64进行编码,举例如下:# echo -n Password1 | base64UGFzc3dvcmQx。 + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + - **AlarmTemplateId** (int) - 告警模板id,如果传了告警模板id,且告警模板id正确,则绑定告警模板。绑定告警模板失败只会在后台有日志,不会影响创建主机流程,也不会在前端报错。 + - **BootDiskSpace** (int) - 【待废弃,不建议调用】系统盘大小。 单位:GB, 范围[20,100], 步长:10 + - **CPU** (int) - 虚拟CPU核数。可选参数:1-64(具体机型与CPU的对应关系参照控制台)。默认值: 4。 + - **ChargeType** (str) - 计费模式。枚举值为: \\ > Year,按年付费; \\ > Month,按月付费;\\ > Dynamic,按小时付费 \\ 默认为月付 + - **CouponId** (str) - 主机代金券ID。请通过DescribeCoupon接口查询,或登录用户中心查看 + - **DiskPassword** (str) - 【待废弃,不建议调用】加密盘的密码。若输入此字段,自动选择加密盘。加密盘需要权限位。 + - **DiskSpace** (int) - 【待废弃,不建议调用】数据盘大小。 单位:GB, 范围[0,8000], 步长:10, 默认值:20,云盘支持0-8000;本地普通盘支持0-2000;本地SSD盘(包括所有GPU机型)支持100-1000 + - **Disks** (list) - 见 **CreateUHostInstanceParamDisks** 模型定义 + - **GPU** (int) - GPU卡核心数。仅GPU机型支持此字段(可选范围与UHostType相关) + - **GpuType** (str) - GPU类型,枚举值["K80", "P40", "V100"] + - **HostType** (str) - 【已废弃】宿主机类型,N2,N1 + - **HotplugFeature** (bool) - 是否开启热升级特性。True为开启,False为未开启,默认False。 + - **InstallAgent** (str) - 【暂不支持】是否安装UGA。'yes': 安装;其他或者不填:不安装。 + - **IsolationGroup** (str) - 硬件隔离组id。可通过DescribeIsolationGroup获取。 + - **KeyPair** (str) - 【暂不支持】Keypair公钥,LoginMode为KeyPair时此项必须 + - **MachineType** (str) - 云主机机型(V2.0),枚举值["N", "C", "G", "O"]。参考 `云主机机型说明 `_ 。 + - **MaxCount** (int) - 【批量创建主机时必填】最大创建主机数量,取值范围是[1,100]; + - **Memory** (int) - 内存大小。单位:MB。范围 :[1024, 262144],取值为1024的倍数(可选范围参考控制台)。默认值:8192 + - **MinimalCpuPlatform** (str) - 最低cpu平台,枚举值["Intel/Auto", "Intel/IvyBridge", "Intel/Haswell", "Intel/Broadwell", "Intel/Skylake", "Intel/Cascadelake"。 + - **Name** (str) - UHost实例名称。默认:UHost。请遵照 `字段规范 `_ 设定实例名称。 + - **NetCapability** (str) - 网络增强。枚举值:Normal(默认),不开启; Super,开启网络增强1.0; Ultra,开启网络增强2.0(仅支持部分可用区,请参考控制台) + - **NetworkId** (str) - 【已废弃】网络ID(VPC2.0情况下无需填写)。VPC1.0情况下,若不填写,代表优先选择基础网络; 若填写,代表选择子网。参见DescribeSubnet。 + - **NetworkInterface** (list) - 见 **CreateUHostInstanceParamNetworkInterface** 模型定义 + - **PrivateIp** (list) - 【数组】创建云主机时指定内网IP。若不传值,则随机分配当前子网下的IP。调用方式举例:PrivateIp.0=x.x.x.x。当前只支持一个内网IP。 + - **PrivateMac** (str) - 【批量创建该参数无效】【内部字段】创建云主机时指定Mac。调用方式举例:PrivateMac="xx:xx:xx:xx:xx:xx"。 + - **Quantity** (int) - 购买时长。默认:值 1。按小时购买(Dynamic)时无需此参数。 月付时,此参数传0,代表购买至月末。 + - **ResourceType** (int) - 【内部参数】资源类型 + - **SecurityGroupId** (str) - 防火墙Id,默认:Web推荐防火墙。如何查询SecurityGroupId请参见 `DescribeSecurityGroup `_ 。 + - **SetId** (int) - + - **StorageType** (str) - 【待废弃,不建议调用】磁盘类型,同时设定系统盘和数据盘的磁盘类型。枚举值为:LocalDisk,本地磁盘; UDisk,云硬盘;默认为LocalDisk。仅部分可用区支持云硬盘方式的主机存储方式,具体请查询控制台。 + - **SubnetId** (str) - 子网 ID。默认为当前地域的默认子网。 + - **Tag** (str) - 业务组。默认:Default(Default即为未分组)。请遵照 `字段规范 `_ 设定业务组。 + - **TimemachineFeature** (str) - 【待废弃,不建议调用】是否开启方舟特性。Yes为开启方舟,No为关闭方舟。目前仅选择普通本地盘+普通本地盘 或 SSD云盘+普通云盘的组合支持开启方舟。 + - **UHostType** (str) - 【建议后续不再使用】云主机机型V1.0。参考 `云主机机型说明 `_ 。 + - **UserDataScript** (str) - 【暂不支持】cloudinit方式下,用户初始化脚本 + - **VPCId** (str) - VPC ID。默认为当前地域的默认VPC。 + + **Response** + + - **IPs** (list) - 【批量创建不会返回】IP信息 + - **UHostIds** (list) - UHost实例Id集合 + + **Request Model** + + **CreateUHostInstanceParamNetworkInterfaceEIPGlobalSSH** + + - **Area** (str) - 填写支持SSH访问IP的地区名称,如“洛杉矶”,“新加坡”,“香港”,“东京”,“华盛顿”,“法兰克福”。Area和AreaCode两者必填一个 + - **AreaCode** (str) - GlobalSSH的。AreaCode, 区域航空港国际通用代码。Area和AreaCode两者必填一个 + - **Port** (int) - SSH端口,1-65535且不能使用80,443端口 + + **CreateUHostInstanceParamNetworkInterfaceEIP** + + - **Bandwidth** (int) - 【如果绑定EIP这个参数必填】弹性IP的外网带宽, 单位为Mbps. 共享带宽模式必须指定0M带宽, 非共享带宽模式必须指定非0Mbps带宽. 各地域非共享带宽的带宽范围如下: 流量计费[1-300],带宽计费[1-800] + - **CouponId** (str) - 当前EIP代金券id。请通过DescribeCoupon接口查询,或登录用户中心查看 + - **GlobalSSH** (dict) - 见 **CreateUHostInstanceParamNetworkInterfaceEIPGlobalSSH** 模型定义 + - **OperatorName** (str) - 【如果绑定EIP这个参数必填】弹性IP的线路如下: 国际: International BGP: Bgp 各地域允许的线路参数如下: cn-sh1: Bgp cn-sh2: Bgp cn-gd: Bgp cn-bj1: Bgp cn-bj2: Bgp hk: International us-ca: International th-bkk: International kr-seoul:International us-ws:International ge-fra:International sg:International tw-kh:International.其他海外线路均为 International + - **PayMode** (str) - 弹性IP的计费模式. 枚举值: "Traffic", 流量计费; "Bandwidth", 带宽计费; "ShareBandwidth",共享带宽模式. "Free":免费带宽模式.默认为 "Bandwidth". + - **ShareBandwidthId** (str) - 绑定的共享带宽Id,仅当PayMode为ShareBandwidth时有效 + + **CreateUHostInstanceParamDisks** + + - **BackupType** (str) - 磁盘备份方案。枚举值:\\ > NONE,无备份 \\ > DATAARK,数据方舟 \\ 当前磁盘支持的备份模式参考 `磁盘类型 `_ + - **CouponId** (str) - 云盘代金券id。不适用于系统盘/本地盘。请通过DescribeCoupon接口查询,或登录用户中心查看 + - **Encrypted** (bool) - 【功能仅部分可用区开放,详询技术支持】磁盘是否加密。加密:true, 不加密: false加密必须传入对应的的KmsKeyId + - **IsBoot** (str) - 是否是系统盘。枚举值:\\ > True,是系统盘 \\ > False,是数据盘(默认)。Disks数组中有且只能有一块盘是系统盘。 + - **KmsKeyId** (str) - 【功能仅部分可用区开放,详询技术支持】kms key id。选择加密盘时必填。 + - **Size** (int) - 磁盘大小,单位GB。请参考 `磁盘类型 `_ 。 + - **Type** (str) - 磁盘类型。请参考 `磁盘类型 `_ 。 + + **CreateUHostInstanceParamNetworkInterface** + + - **EIP** (dict) - 见 **CreateUHostInstanceParamNetworkInterfaceEIP** 模型定义 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.CreateUHostInstanceRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("CreateUHostInstance", d, **kwargs) + return apis.CreateUHostInstanceResponseSchema().loads(resp) + + def describe_image(self, req=None, **kwargs): + """ DescribeImage - 获取指定数据中心镜像列表,用户可通过指定操作系统类型,镜像Id进行过滤。 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **ImageId** (str) - 镜像Id + - **ImageType** (str) - 镜像类型。标准镜像:Base,镜像市场:Business, 自定义镜像:Custom,默认返回所有类型 + - **Limit** (int) - 返回数据长度,默认为20 + - **Offset** (int) - 列表起始位置偏移量,默认为0 + - **OsType** (str) - 操作系统类型:Linux, Windows 默认返回所有类型 + - **PriceSet** (int) - 是否返回价格:1返回,0不返回;默认不返回 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **ImageSet** (list) - 见 **UHostImageSet** 模型定义 + - **TotalCount** (int) - 满足条件的镜像总数 + + **Response Model** + + **UHostImageSet** + + - **CreateTime** (int) - 创建时间,格式为Unix时间戳 + - **Features** (list) - 特殊状态标识, 目前包含NetEnhnced(网络增强1.0), NetEnhanced_Ultra](网络增强2.0) + - **FuncType** (str) - 行业镜像类型(仅行业镜像将返回这个值) + - **ImageDescription** (str) - 镜像描述 + - **ImageId** (str) - 镜像ID + - **ImageName** (str) - 镜像名称 + - **ImageSize** (int) - 镜像大小 + - **ImageType** (str) - 镜像类型 标准镜像:Base, 行业镜像:Business,自定义镜像:Custom + - **IntegratedSoftware** (str) - 集成软件名称(仅行业镜像将返回这个值) + - **Links** (str) - 介绍链接(仅行业镜像将返回这个值) + - **MinimalCPU** (str) - 默认值为空'''。当CentOS 7.3/7.4/7.5等镜像会标记为“Broadwell” + - **OsName** (str) - 操作系统名称 + - **OsType** (str) - 操作系统类型:Liunx,Windows + - **State** (str) - 镜像状态, 可用:Available,制作中:Making, 不可用:Unavailable + - **Vendor** (str) - 供应商(仅行业镜像将返回这个值) + - **Zone** (str) - 可用区,参见 `可用区列表 `_ | + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeImageRequestSchema().dumps(d) + resp = self.invoke("DescribeImage", d, **kwargs) + return apis.DescribeImageResponseSchema().loads(resp) + + def describe_uhost_instance(self, req=None, **kwargs): + """ DescribeUHostInstance - 获取主机或主机列表信息,并可根据数据中心,主机ID等参数进行过滤。 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **IsolationGroup** (str) - 硬件隔离组id。通过硬件隔离组筛选主机。 + - **LifeCycle** (int) - 1:普通云主机;2:抢占型云主机;如不传此参数,默认全部获取 + - **Limit** (int) - 返回数据长度,默认为20,最大100 + - **Offset** (int) - 列表起始位置偏移量,默认为0 + - **SubnetId** (str) - 子网id。通过子网筛选主机。北京一地域无效。 + - **Tag** (str) - 要查询的业务组名称 + - **UHostIds** (list) - 【数组】UHost主机的资源ID,例如UHostIds.0代表希望获取信息 的主机1,UHostIds.1代表主机2。 如果不传入,则返回当前Region 所有符合条件的UHost实例。 + - **VPCId** (str) - vpc id。通过VPC筛选主机。北京一地域无效。 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **TotalCount** (int) - UHostInstance总数 + - **UHostSet** (list) - 见 **UHostInstanceSet** 模型定义 + + **Response Model** + + **UHostDiskSet** + + - **BackupType** (str) - 备份方案。若开通了数据方舟,则为DataArk + - **DiskId** (str) - 磁盘ID + - **DiskType** (str) - 磁盘类型。请参考 `磁盘类型 `_ 。 + - **Drive** (str) - 磁盘盘符 + - **Encrypted** (bool) - true: 加密盘 false:非加密盘 + - **IsBoot** (str) - 是否是系统盘。枚举值:\\ > True,是系统盘 \\ > False,是数据盘(默认)。Disks数组中有且只能有一块盘是系统盘。 + - **Name** (str) - UDisk名字(仅当磁盘是UDisk时返回) + - **Size** (int) - 磁盘大小,单位: GB + - **Type** (str) - 【建议不再使用】磁盘类型。系统盘: Boot,数据盘: Data,网络盘:Udisk + + **UHostIPSet** + + - **Bandwidth** (int) - IP对应的带宽, 单位: Mb (内网IP不显示带宽信息) + - **Default** (str) - 是否默认的弹性网卡的信息。true: 是默认弹性网卡;其他值:不是。 + - **IP** (str) - IP地址 + - **IPId** (str) - IP资源ID (内网IP无对应的资源ID) + - **SubnetId** (str) - IP地址对应的子网 ID(北京一当前字段为空) + - **Type** (str) - 国际: Internation,BGP: Bgp,内网: Private + - **VPCId** (str) - IP地址对应的VPC ID(北京一当前字段为空) + + **UHostInstanceSet** + + - **AutoRenew** (str) - 是否自动续费,自动续费:“Yes”,不自动续费:“No” + - **BasicImageId** (str) - 基础镜像ID(指当前自定义镜像的来源镜像) + - **BasicImageName** (str) - 基础镜像名称(指当前自定义镜像的来源镜像) + - **BootDiskState** (str) - 系统盘状态 Normal表示初始化完成;Initializing表示在初始化。仍在初始化的系统盘无法制作镜像。 + - **CPU** (int) - 虚拟CPU核数,单位: 个 + - **ChargeType** (str) - 计费模式,枚举值为: Year,按年付费; Month,按月付费; Dynamic,按需付费(需开启权限); + - **CreateTime** (int) - 创建时间,格式为Unix时间戳 + - **DiskSet** (list) - 见 **UHostDiskSet** 模型定义 + - **ExpireTime** (int) - 到期时间,格式为Unix时间戳 + - **GPU** (int) - GPU个数 + - **HostType** (str) - 【建议不再使用】主机系列:N2,表示系列2;N1,表示系列1 + - **HotplugFeature** (bool) - true: 开启热升级; false,未开启热升级 + - **IPSet** (list) - 见 **UHostIPSet** 模型定义 + - **ImageId** (str) - 【建议不再使用】主机的系统盘ID。 + - **IsolationGroup** (str) - 隔离组id,不在隔离组则返回"" + - **LifeCycle** (str) - 主机的生命周期类型。目前仅支持Normal:普通; + - **MachineType** (str) - 云主机机型(新)。参考 `云主机机型说明 `_ 。 + - **Memory** (int) - 内存大小,单位: MB + - **Name** (str) - UHost实例名称 + - **NetCapability** (str) - 网络增强。Normal: 无;Super: 网络增强1.0; Ultra: 网络增强2.0 + - **NetworkState** (str) - 【建议不再使用】网络状态。 连接:Connected, 断开:NotConnected + - **OsName** (str) - 创建主机的最初来源镜像的操作系统名称(若直接通过基础镜像创建,此处返回和BasicImageName一致) + - **OsType** (str) - 操作系统类别。返回"Linux"或者"Windows" + - **Remark** (str) - 备注 + - **State** (str) - 实例状态,枚举值:\\ >初始化: Initializing; \\ >启动中: Starting; \\> 运行中: Running; \\> 关机中: Stopping; \\ >关机: Stopped \\ >安装失败: Install Fail; \\ >重启中: Rebooting + - **StorageType** (str) - 【建议不再使用】主机磁盘类型。 枚举值为:\\ > LocalDisk,本地磁盘; \\ > UDisk 云盘。\\只要有一块磁盘为本地盘,即返回LocalDisk。 + - **SubnetType** (str) - 【建议不再使用】仅北京A的云主机会返回此字段。基础网络模式:Default;子网模式:Private + - **Tag** (str) - 业务组名称 + - **TimemachineFeature** (str) - 【建议不再使用】数据方舟模式。枚举值:\\ > Yes: 开启方舟; \\ > no,未开启方舟 + - **TotalDiskSpace** (int) - 总的数据盘存储空间。 + - **UHostId** (str) - UHost实例ID + - **UHostType** (str) - 【建议不再使用】云主机机型(旧)。参考 `云主机机型说明 `_ 。 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeUHostInstanceRequestSchema().dumps(d) + resp = self.invoke("DescribeUHostInstance", d, **kwargs) + return apis.DescribeUHostInstanceResponseSchema().loads(resp) + + def describe_uhost_tags(self, req=None, **kwargs): + """ DescribeUHostTags - 获取指定数据中心的业务组列表。 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **TagSet** (list) - 见 **UHostTagSet** 模型定义 + - **TotalCount** (int) - 已有主机的业务组总个数 + + **Response Model** + + **UHostTagSet** + + - **Tag** (str) - 业务组名称 + - **TotalCount** (int) - 该业务组中包含的主机个数 + - **Zone** (str) - 可用区 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeUHostTagsRequestSchema().dumps(d) + resp = self.invoke("DescribeUHostTags", d, **kwargs) + return apis.DescribeUHostTagsResponseSchema().loads(resp) + + def get_uhost_instance_price(self, req=None, **kwargs): + """ GetUHostInstancePrice - 根据UHost实例配置,获取UHost实例的价格。 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **CPU** (int) - (Required) CPU核数。可选参数:1-64。可选范围参照控制台。默认值: 4 + - **Count** (int) - (Required) 购买台数,范围[1,5] + - **ImageId** (str) - (Required) 镜像Id,可通过 `DescribeImage `_ 获取镜像ID + - **Memory** (int) - (Required) 内存大小。单位:MB。范围 :[1024, 262144],取值为1024的倍数(可选范围参照好控制台)。默认值:8192 + - **ChargeType** (str) - 计费模式。枚举值为: \\ > Year,按年付费; \\ > Month,按月付费;\\ > Dynamic,按小时付费 \\ 默认为月付。 + - **DiskSpace** (int) - 【待废弃】数据盘大小,单位: GB,范围[0,1000],步长: 10,默认值: 0 + - **Disks** (list) - 见 **GetUHostInstancePriceParamDisks** 模型定义 + - **GPU** (int) - GPU卡核心数。仅GPU机型支持此字段。 + - **GpuType** (str) - GPU类型,枚举值["K80", "P40", "V100"] + - **LifeCycle** (int) - 【未支持】1:普通云主机;2:抢占性云主机;默认普通 + - **MachineType** (str) - 云主机机型(V2版本概念)。枚举值["N", "C", "G", "O"]。参考 `云主机机型说明 `_ 。 + - **NetCapability** (str) - 网络增强。枚举值:Normal,不开启; Super,开启网络增强1.0。 默认值为Normal。 + - **Quantity** (int) - 购买时长。默认: 1。按小时购买(Dynamic)时无需此参数。 月付时,此参数传0,代表了购买至月末。 + - **StorageType** (str) - 【待废弃】磁盘类型,同时设定系统盘和数据盘, 枚举值为:LocalDisk,本地磁盘; UDisk,云硬盘; 默认为LocalDisk 仅部分可用区支持云硬盘方式的主机存储方式,具体请查询控制台。 + - **TimemachineFeature** (str) - 【待废弃】方舟机型。No,Yes。默认是No。 + - **UHostType** (str) - 【待废弃】云主机机型(V1版本概念)。参考 `云主机机型说明 `_ 。 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **PriceSet** (list) - 见 **UHostPriceSet** 模型定义 + + **Request Model** + + **GetUHostInstancePriceParamDisks** + + - **BackupType** (str) - 磁盘备份方案。枚举值:\\ > NONE,无备份 \\ > DATAARK,数据方舟 \\ 当前磁盘支持的备份模式参考 `磁盘类型 `_ + - **IsBoot** (str) - 是否是系统盘。枚举值:\\ > True,是系统盘 \\ > False,是数据盘(默认)。Disks数组中有且只能有一块盘是系统盘。 + - **Size** (int) - 磁盘大小,单位GB。请参考 `磁盘类型 `_ 。 + - **Type** (str) - 磁盘类型。请参考 `磁盘类型 `_ 。 + + **Response Model** + + **UHostPriceSet** + + - **ChargeType** (str) - 计费类型。Year,Month,Dynamic + - **Price** (float) - 价格,单位: 元,保留小数点后两位有效数字 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.GetUHostInstancePriceRequestSchema().dumps(d) + resp = self.invoke("GetUHostInstancePrice", d, **kwargs) + return apis.GetUHostInstancePriceResponseSchema().loads(resp) + + def get_uhost_instance_vnc_info(self, req=None, **kwargs): + """ GetUHostInstanceVncInfo - 获取指定UHost实例的管理VNC配置详细信息。 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **UHostId** (str) - (Required) UHost实例ID 参见 `DescribeUHostInstance `_ + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **UhostId** (str) - UHost实例ID + - **VncIP** (str) - Vnc登录IP + - **VncPassword** (str) - Vnc 登录密码 + - **VncPort** (int) - Vnc登录端口 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.GetUHostInstanceVncInfoRequestSchema().dumps(d) + resp = self.invoke("GetUHostInstanceVncInfo", d, **kwargs) + return apis.GetUHostInstanceVncInfoResponseSchema().loads(resp) + + def get_uhost_upgrade_price(self, req=None, **kwargs): + """ GetUHostUpgradePrice - 获取UHost实例升级配置的价格。可选配置范围请参考 `云主机机型说明 `_ 。 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **UHostId** (str) - (Required) UHost实例ID。 参见 `DescribeUHostInstance `_ 。 + - **BootDiskSpace** (int) - 【待废弃】系统大小,单位: GB,范围[20,100],步长: 10。 + - **CPU** (int) - 虚拟CPU核数。可选参数:1-64(可选范围参考控制台)。默认值为当前实例的CPU核数。 + - **DiskSpace** (int) - 【待废弃】数据盘大小,单位: GB,范围[0,1000],步长: 10, 默认值是该主机当前数据盘大小。 + - **HostType** (str) - 【待废弃】主机系列,目前支持N1,N2 + - **Memory** (int) - 内存大小。单位:MB。范围 :[1024, 262144],取值为1024的倍数(可选范围参考控制台)。默认值为当前实例的内存大小。 + - **NetCapValue** (int) - 网卡升降级(1,表示升级,2表示降级,0表示不变) + - **TimemachineFeature** (str) - 方舟机型。No,Yes。默认是No。 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **Price** (float) - 规格调整差价。精确到小数点后2位。 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.GetUHostUpgradePriceRequestSchema().dumps(d) + resp = self.invoke("GetUHostUpgradePrice", d, **kwargs) + return apis.GetUHostUpgradePriceResponseSchema().loads(resp) + + def import_custom_image(self, req=None, **kwargs): + """ ImportCustomImage - 把UFile的镜像文件导入到UHost,生成自定义镜像 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Auth** (bool) - (Required) 是否授权。必须填true + - **Format** (str) - (Required) 镜像格式,可选RAW、VHD、VMDK、qcow2 + - **ImageName** (str) - (Required) 镜像名称 + - **OsName** (str) - (Required) 操作系统详细版本,请参考控制台的镜像版本;OsType为Other时,输入参数为Other + - **OsType** (str) - (Required) 操作系统平台,比如CentOS、Ubuntu、Windows、RedHat等,请参考控制台的镜像版本;若导入控制台上没有的操作系统,参数为Other + - **UFileUrl** (str) - (Required) UFile私有空间地址 + - **ImageDescription** (str) - 镜像描述 + + **Response** + + - **ImageId** (str) - 镜像Id + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.ImportCustomImageRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("ImportCustomImage", d, **kwargs) + return apis.ImportCustomImageResponseSchema().loads(resp) + + def modify_uhost_instance_name(self, req=None, **kwargs): + """ ModifyUHostInstanceName - 修改指定UHost实例名称,需要给出数据中心,UHostId,及新的实例名称。 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **UHostId** (str) - (Required) UHost实例ID 参见 `DescribeUHostInstance `_ + - **Name** (str) - UHost实例名称 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **UhostId** (str) - UHost实例ID + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.ModifyUHostInstanceNameRequestSchema().dumps(d) + resp = self.invoke("ModifyUHostInstanceName", d, **kwargs) + return apis.ModifyUHostInstanceNameResponseSchema().loads(resp) + + def modify_uhost_instance_remark(self, req=None, **kwargs): + """ ModifyUHostInstanceRemark - 修改指定UHost实例备注信息。 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **UHostId** (str) - (Required) UHost实例ID 参见 `DescribeUHostInstance `_ + - **Remark** (str) - 备注 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **UhostId** (str) - UHost实例ID + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.ModifyUHostInstanceRemarkRequestSchema().dumps(d) + resp = self.invoke("ModifyUHostInstanceRemark", d, **kwargs) + return apis.ModifyUHostInstanceRemarkResponseSchema().loads(resp) + + def modify_uhost_instance_tag(self, req=None, **kwargs): + """ ModifyUHostInstanceTag - 修改指定UHost实例业务组标识。 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **UHostId** (str) - (Required) UHost实例ID 参见 `DescribeUHostInstance `_ + - **Tag** (str) - 业务组名称 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **UhostId** (str) - UHost实例ID + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.ModifyUHostInstanceTagRequestSchema().dumps(d) + resp = self.invoke("ModifyUHostInstanceTag", d, **kwargs) + return apis.ModifyUHostInstanceTagResponseSchema().loads(resp) + + def poweroff_uhost_instance(self, req=None, **kwargs): + """ PoweroffUHostInstance - 直接关闭UHost实例电源,无需等待实例正常关闭。 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **UHostId** (str) - (Required) UHost实例ID 参见 `DescribeUHostInstance `_ + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **UhostId** (str) - UHost实例ID + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.PoweroffUHostInstanceRequestSchema().dumps(d) + resp = self.invoke("PoweroffUHostInstance", d, **kwargs) + return apis.PoweroffUHostInstanceResponseSchema().loads(resp) + + def reboot_uhost_instance(self, req=None, **kwargs): + """ RebootUHostInstance - 重新启动UHost实例,需要指定数据中心及UHostID两个参数的值。 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **UHostId** (str) - (Required) UHost实例ID 参见 `DescribeUHostInstance `_ + - **DiskPassword** (str) - 加密盘密码 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **UhostId** (str) - UHost实例ID + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.RebootUHostInstanceRequestSchema().dumps(d) + resp = self.invoke("RebootUHostInstance", d, **kwargs) + return apis.RebootUHostInstanceResponseSchema().loads(resp) + + def reinstall_uhost_instance(self, req=None, **kwargs): + """ ReinstallUHostInstance - 重新安装指定UHost实例的操作系统 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **UHostId** (str) - (Required) UHost实例资源ID 参见 `DescribeUHostInstance `_ + - **BootDiskSpace** (int) - 系统盘大小。 单位:GB, 范围[20,100], 步长:10 + - **DNSServers** (list) - 针对非私有子网主机,可自定义DNS。n可为0-2 + - **ImageId** (str) - 镜像Id,默认使用原镜像 参见 `DescribeImage `_ + - **Password** (str) - 如果创建UHost实例时LoginMode为Password,则必须填写,如果LoginMode为KeyPair,不需要填写 (密码格式使用BASE64编码;LoginMode不可变更) + - **ReserveDisk** (str) - 是否保留数据盘,保留:Yes,不报留:No, 默认:Yes;如果是从Windows重装为Linux或反之,则无法保留数据盘 + - **ResourceType** (int) - 云灾备指明191 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **UhostId** (str) - UHost实例资源ID + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.ReinstallUHostInstanceRequestSchema().dumps(d) + resp = self.invoke("ReinstallUHostInstance", d, **kwargs) + return apis.ReinstallUHostInstanceResponseSchema().loads(resp) + + def reset_uhost_instance_password(self, req=None, **kwargs): + """ ResetUHostInstancePassword - 重置UHost实例的管理员密码。 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Password** (str) - (Required) UHost新密码(密码格式使用BASE64编码) + - **UHostId** (str) - (Required) UHost实例ID + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **UhostId** (str) - UHost实例ID + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.ResetUHostInstancePasswordRequestSchema().dumps(d) + resp = self.invoke("ResetUHostInstancePassword", d, **kwargs) + return apis.ResetUHostInstancePasswordResponseSchema().loads(resp) + + def resize_attached_disk(self, req=None, **kwargs): + """ ResizeAttachedDisk - 修改挂载的磁盘大小,包含系统盘和数据盘 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **DiskId** (str) - (Required) 磁盘ID。参见 `DescribeUHostInstance `_ 返回值中的DiskSet。 + - **DiskSpace** (int) - (Required) 磁盘大小,单位GB,步长为10。取值范围需大于当前磁盘大小,最大值请参考 `磁盘类型 `_ 。 + - **UHostId** (str) - (Required) UHost实例ID。 参见 `DescribeUHostInstance `_ 。 + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + + **Response** + + - **DiskId** (str) - 改配成功的磁盘id + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.ResizeAttachedDiskRequestSchema().dumps(d) + resp = self.invoke("ResizeAttachedDisk", d, **kwargs) + return apis.ResizeAttachedDiskResponseSchema().loads(resp) + + def resize_uhost_instance(self, req=None, **kwargs): + """ ResizeUHostInstance - 修改指定UHost实例的资源配置,如CPU核心数,内存容量大小,网络增强等。可选配置范围请参考 `云主机机型说明 `_ 。 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **UHostId** (str) - (Required) UHost实例ID 参见 `DescribeUHostInstance `_ + - **BootDiskSpace** (int) - 【待废弃】系统盘大小,单位:GB,范围[20,100],步长:10,系统盘不支持缩容,因此不允许输入比当前实例系统盘小的值 + - **CPU** (int) - 虚拟CPU核数。可选参数:1-32(可选范围与UHostType相关)。默认值为当前实例的CPU核数 + - **DiskSpace** (int) - 【待废弃】数据盘大小,单位:GB,范围[10,1000]; SSD机型,单位:GB,范围[100,500];步长:10,默认值为当前实例的数据盘大小,数据盘不支持缩容,因此不允许输入比当前实例数据盘大小的值 + - **Memory** (int) - 内存大小。单位:MB。范围 :[1024, 262144],取值为1024的倍数(可选范围与UHostType相关)。默认值为当前实例的内存大小。 + - **NetCapValue** (int) - 网卡升降级(1,表示升级,2表示降级,0表示不变) + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **UhostId** (str) - UHost实例ID + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.ResizeUHostInstanceRequestSchema().dumps(d) + resp = self.invoke("ResizeUHostInstance", d, **kwargs) + return apis.ResizeUHostInstanceResponseSchema().loads(resp) + + def start_uhost_instance(self, req=None, **kwargs): + """ StartUHostInstance - 启动处于关闭状态的UHost实例,需要指定数据中心及UHostID两个参数的值。 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **UHostId** (str) - (Required) UHost实例ID 参见 `DescribeUHostInstance `_ + - **DiskPassword** (str) - 加密盘密码 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **UhostId** (str) - UHost实例ID + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.StartUHostInstanceRequestSchema().dumps(d) + resp = self.invoke("StartUHostInstance", d, **kwargs) + return apis.StartUHostInstanceResponseSchema().loads(resp) + + def stop_uhost_instance(self, req=None, **kwargs): + """ StopUHostInstance - 指停止处于运行状态的UHost实例,需指定数据中心及UhostID。 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **UHostId** (str) - (Required) UHost实例ID 参见 `DescribeUHostInstance `_ + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **UhostId** (str) - UHost实例ID + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.StopUHostInstanceRequestSchema().dumps(d) + resp = self.invoke("StopUHostInstance", d, **kwargs) + return apis.StopUHostInstanceResponseSchema().loads(resp) + + def terminate_custom_image(self, req=None, **kwargs): + """ TerminateCustomImage - 删除用户自定义镜像 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **ImageId** (str) - (Required) 自制镜像ID 参见 `DescribeImage `_ + + **Response** + + - **ImageId** (str) - 自制镜像Id + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.TerminateCustomImageRequestSchema().dumps(d) + resp = self.invoke("TerminateCustomImage", d, **kwargs) + return apis.TerminateCustomImageResponseSchema().loads(resp) + + def terminate_uhost_instance(self, req=None, **kwargs): + """ TerminateUHostInstance - 删除指定数据中心的UHost实例。 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **UHostId** (str) - (Required) UHost资源Id 参见 `DescribeUHostInstance `_ + - **Destroy** (int) - 是否直接删除,0表示按照原来的逻辑(有回收站权限,则进入回收站),1表示直接删除 + - **ReleaseEIP** (bool) - 是否释放绑定的EIP。true: 解绑EIP后,并释放;其他值或不填:解绑EIP。 + - **ReleaseUDisk** (bool) - 是否删除挂载的数据盘。true删除,其他不删除。 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **InRecycle** (str) - 放入回收站:"Yes", 彻底删除:“No” + - **UHostId** (str) - UHost 实例 Id + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.TerminateUHostInstanceRequestSchema().dumps(d) + resp = self.invoke("TerminateUHostInstance", d, **kwargs) + return apis.TerminateUHostInstanceResponseSchema().loads(resp) + + def upgrade_to_ark_uhost_instance(self, req=None, **kwargs): + """ UpgradeToArkUHostInstance - 普通升级为方舟机型 + + **Request** + + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **UHostIds** (list) - (Required) UHost主机的资源ID,例如UHostIds.0代表希望升级的主机1,UHostIds.1代表主机2。 + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + - **CouponId** (str) - 代金券ID 请参考DescribeCoupon接口 + + **Response** + + - **UHostSet** (list) - UHost主机的资源ID数组 + + """ + d = {"Region": self.config.region} + req and d.update(req) + d = apis.UpgradeToArkUHostInstanceRequestSchema().dumps(d) + resp = self.invoke("UpgradeToArkUHostInstance", d, **kwargs) + return apis.UpgradeToArkUHostInstanceResponseSchema().loads(resp) diff --git a/ucloud/services/uhost/schemas/__init__.py b/ucloud/services/uhost/schemas/__init__.py index 4c48b5a..40a96af 100644 --- a/ucloud/services/uhost/schemas/__init__.py +++ b/ucloud/services/uhost/schemas/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- diff --git a/ucloud/services/uhost/schemas/apis.py b/ucloud/services/uhost/schemas/apis.py index 0e28b25..2b8fbaf 100644 --- a/ucloud/services/uhost/schemas/apis.py +++ b/ucloud/services/uhost/schemas/apis.py @@ -1,834 +1,864 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.typesystem import schema, fields -from ucloud.services.uhost.schemas import models - -""" UHost API Schema -""" -""" -API: CopyCustomImage - -复制自制镜像 -""" - - -class CopyCustomImageRequestSchema(schema.RequestSchema): - """ CopyCustomImage - 复制自制镜像 - """ - - fields = { - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "SourceImageId": fields.Str(required=True, dump_to="SourceImageId"), - "TargetImageDescription": fields.Str( - required=False, dump_to="TargetImageDescription" - ), - "TargetImageName": fields.Str(required=False, dump_to="TargetImageName"), - "TargetProjectId": fields.Str(required=True, dump_to="TargetProjectId"), - "TargetRegion": fields.Str(required=False, dump_to="TargetRegion"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class CopyCustomImageResponseSchema(schema.ResponseSchema): - """ CopyCustomImage - 复制自制镜像 - """ - - fields = {"TargetImageId": fields.Str(required=False, load_from="TargetImageId")} - - -""" -API: CreateCustomImage - -从指定UHost实例,生成自定义镜像。 -""" - - -class CreateCustomImageRequestSchema(schema.RequestSchema): - """ CreateCustomImage - 从指定UHost实例,生成自定义镜像。 - """ - - fields = { - "ImageDescription": fields.Str(required=False, dump_to="ImageDescription"), - "ImageName": fields.Str(required=True, dump_to="ImageName"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "UHostId": fields.Str(required=True, dump_to="UHostId"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class CreateCustomImageResponseSchema(schema.ResponseSchema): - """ CreateCustomImage - 从指定UHost实例,生成自定义镜像。 - """ - - fields = {"ImageId": fields.Str(required=False, load_from="ImageId")} - - -""" -API: CreateUHostInstance - -创建UHost实例。 -""" - - -class CreateUHostInstanceParamNetworkInterfaceEIPGlobalSSHSchema(schema.RequestSchema): - """ CreateUHostInstanceParamNetworkInterfaceEIPGlobalSSH - - """ - - fields = { - "Area": fields.Str(required=False, dump_to="Area"), - "AreaCode": fields.Str(required=False, dump_to="AreaCode"), - "Port": fields.Int(required=False, dump_to="Port"), - } - - -class CreateUHostInstanceParamNetworkInterfaceEIPSchema(schema.RequestSchema): - """ CreateUHostInstanceParamNetworkInterfaceEIP - - """ - - fields = { - "Bandwidth": fields.Int(required=False, dump_to="Bandwidth"), - "CouponId": fields.Str(required=False, dump_to="CouponId"), - "GlobalSSH": CreateUHostInstanceParamNetworkInterfaceEIPGlobalSSHSchema( - required=False, dump_to="GlobalSSH" - ), - "OperatorName": fields.Str(required=False, dump_to="OperatorName"), - "PayMode": fields.Str(required=False, dump_to="PayMode"), - "ShareBandwidthId": fields.Str(required=False, dump_to="ShareBandwidthId"), - } - - -class CreateUHostInstanceParamDisksSchema(schema.RequestSchema): - """ CreateUHostInstanceParamDisks - - """ - - fields = { - "BackupType": fields.Str(required=False, dump_to="BackupType"), - "CouponId": fields.Str(required=False, dump_to="CouponId"), - "Encrypted": fields.Bool(required=False, dump_to="Encrypted"), - "IsBoot": fields.Str(required=True, dump_to="IsBoot"), - "KmsKeyId": fields.Str(required=False, dump_to="KmsKeyId"), - "Size": fields.Int(required=True, dump_to="Size"), - "Type": fields.Str(required=True, dump_to="Type"), - } - - -class CreateUHostInstanceParamNetworkInterfaceSchema(schema.RequestSchema): - """ CreateUHostInstanceParamNetworkInterface - - """ - - fields = { - "EIP": CreateUHostInstanceParamNetworkInterfaceEIPSchema( - required=False, dump_to="EIP" - ) - } - - -class CreateUHostInstanceRequestSchema(schema.RequestSchema): - """ CreateUHostInstance - 创建UHost实例。 - """ - - fields = { - "AlarmTemplateId": fields.Int(required=False, dump_to="AlarmTemplateId"), - "BootDiskSpace": fields.Int(required=False, dump_to="BootDiskSpace"), - "CPU": fields.Int(required=False, dump_to="CPU"), - "ChargeType": fields.Str(required=False, dump_to="ChargeType"), - "CouponId": fields.Str(required=False, dump_to="CouponId"), - "DiskPassword": fields.Str(required=False, dump_to="DiskPassword"), - "DiskSpace": fields.Int(required=False, dump_to="DiskSpace"), - "Disks": fields.List(CreateUHostInstanceParamDisksSchema()), - "GPU": fields.Int(required=False, dump_to="GPU"), - "GpuType": fields.Str(required=False, dump_to="GpuType"), - "HostType": fields.Str(required=False, dump_to="HostType"), - "HotplugFeature": fields.Bool(required=False, dump_to="HotplugFeature"), - "ImageId": fields.Str(required=True, dump_to="ImageId"), - "InstallAgent": fields.Str(required=False, dump_to="InstallAgent"), - "IsolationGroup": fields.Str(required=False, dump_to="IsolationGroup"), - "KeyPair": fields.Str(required=False, dump_to="KeyPair"), - "LoginMode": fields.Str(required=True, dump_to="LoginMode"), - "MachineType": fields.Str(required=False, dump_to="MachineType"), - "MaxCount": fields.Int(required=False, dump_to="MaxCount"), - "Memory": fields.Int(required=False, dump_to="Memory"), - "MinimalCpuPlatform": fields.Str(required=False, dump_to="MinimalCpuPlatform"), - "Name": fields.Str(required=False, dump_to="Name"), - "NetCapability": fields.Str(required=False, dump_to="NetCapability"), - "NetworkId": fields.Str(required=False, dump_to="NetworkId"), - "NetworkInterface": fields.List( - CreateUHostInstanceParamNetworkInterfaceSchema() - ), - "Password": fields.Base64(required=True, dump_to="Password"), - "PrivateIp": fields.List(fields.Str()), - "PrivateMac": fields.Str(required=False, dump_to="PrivateMac"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Quantity": fields.Int(required=False, dump_to="Quantity"), - "Region": fields.Str(required=True, dump_to="Region"), - "ResourceType": fields.Int(required=False, dump_to="ResourceType"), - "SecurityGroupId": fields.Str(required=False, dump_to="SecurityGroupId"), - "SetId": fields.Int(required=False, dump_to="SetId"), - "StorageType": fields.Str(required=False, dump_to="StorageType"), - "SubnetId": fields.Str(required=False, dump_to="SubnetId"), - "Tag": fields.Str(required=False, dump_to="Tag"), - "TimemachineFeature": fields.Str(required=False, dump_to="TimemachineFeature"), - "UHostType": fields.Str(required=False, dump_to="UHostType"), - "UserDataScript": fields.Str(required=False, dump_to="UserDataScript"), - "VPCId": fields.Str(required=False, dump_to="VPCId"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class CreateUHostInstanceResponseSchema(schema.ResponseSchema): - """ CreateUHostInstance - 创建UHost实例。 - """ - - fields = { - "IPs": fields.List(fields.Str(), required=False, load_from="IPs"), - "UHostIds": fields.List(fields.Str(), required=False, load_from="UHostIds"), - } - - -""" -API: DescribeImage - -获取指定数据中心镜像列表,用户可通过指定操作系统类型,镜像Id进行过滤。 -""" - - -class DescribeImageRequestSchema(schema.RequestSchema): - """ DescribeImage - 获取指定数据中心镜像列表,用户可通过指定操作系统类型,镜像Id进行过滤。 - """ - - fields = { - "ImageId": fields.Str(required=False, dump_to="ImageId"), - "ImageType": fields.Str(required=False, dump_to="ImageType"), - "Limit": fields.Int(required=False, dump_to="Limit"), - "Offset": fields.Int(required=False, dump_to="Offset"), - "OsType": fields.Str(required=False, dump_to="OsType"), - "PriceSet": fields.Int(required=False, dump_to="PriceSet"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class DescribeImageResponseSchema(schema.ResponseSchema): - """ DescribeImage - 获取指定数据中心镜像列表,用户可通过指定操作系统类型,镜像Id进行过滤。 - """ - - fields = { - "ImageSet": fields.List( - models.UHostImageSetSchema(), required=False, load_from="ImageSet" - ), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - } - - -""" -API: DescribeUHostInstance - -获取主机或主机列表信息,并可根据数据中心,主机ID等参数进行过滤。 -""" - - -class DescribeUHostInstanceRequestSchema(schema.RequestSchema): - """ DescribeUHostInstance - 获取主机或主机列表信息,并可根据数据中心,主机ID等参数进行过滤。 - """ - - fields = { - "IsolationGroup": fields.Str(required=False, dump_to="IsolationGroup"), - "LifeCycle": fields.Int(required=False, dump_to="LifeCycle"), - "Limit": fields.Int(required=False, dump_to="Limit"), - "Offset": fields.Int(required=False, dump_to="Offset"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "SubnetId": fields.Str(required=False, dump_to="SubnetId"), - "Tag": fields.Str(required=False, dump_to="Tag"), - "UHostIds": fields.List(fields.Str()), - "VPCId": fields.Str(required=False, dump_to="VPCId"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class DescribeUHostInstanceResponseSchema(schema.ResponseSchema): - """ DescribeUHostInstance - 获取主机或主机列表信息,并可根据数据中心,主机ID等参数进行过滤。 - """ - - fields = { - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - "UHostSet": fields.List( - models.UHostInstanceSetSchema(), required=False, load_from="UHostSet" - ), - } - - -""" -API: DescribeUHostTags - -获取指定数据中心的业务组列表。 -""" - - -class DescribeUHostTagsRequestSchema(schema.RequestSchema): - """ DescribeUHostTags - 获取指定数据中心的业务组列表。 - """ - - fields = { - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class DescribeUHostTagsResponseSchema(schema.ResponseSchema): - """ DescribeUHostTags - 获取指定数据中心的业务组列表。 - """ - - fields = { - "TagSet": fields.List( - models.UHostTagSetSchema(), required=False, load_from="TagSet" - ), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - } - - -""" -API: GetUHostInstancePrice - -根据UHost实例配置,获取UHost实例的价格。 -""" - - -class GetUHostInstancePriceParamDisksSchema(schema.RequestSchema): - """ GetUHostInstancePriceParamDisks - - """ - - fields = { - "BackupType": fields.Str(required=False, dump_to="BackupType"), - "IsBoot": fields.Str(required=True, dump_to="IsBoot"), - "Size": fields.Int(required=True, dump_to="Size"), - "Type": fields.Str(required=True, dump_to="Type"), - } - - -class GetUHostInstancePriceRequestSchema(schema.RequestSchema): - """ GetUHostInstancePrice - 根据UHost实例配置,获取UHost实例的价格。 - """ - - fields = { - "CPU": fields.Int(required=True, dump_to="CPU"), - "ChargeType": fields.Str(required=False, dump_to="ChargeType"), - "Count": fields.Int(required=True, dump_to="Count"), - "DiskSpace": fields.Int(required=False, dump_to="DiskSpace"), - "Disks": fields.List(GetUHostInstancePriceParamDisksSchema()), - "GPU": fields.Int(required=False, dump_to="GPU"), - "GpuType": fields.Str(required=False, dump_to="GpuType"), - "ImageId": fields.Str(required=True, dump_to="ImageId"), - "LifeCycle": fields.Int(required=False, dump_to="LifeCycle"), - "MachineType": fields.Str(required=False, dump_to="MachineType"), - "Memory": fields.Int(required=True, dump_to="Memory"), - "NetCapability": fields.Str(required=False, dump_to="NetCapability"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Quantity": fields.Int(required=False, dump_to="Quantity"), - "Region": fields.Str(required=True, dump_to="Region"), - "StorageType": fields.Str(required=False, dump_to="StorageType"), - "TimemachineFeature": fields.Str(required=False, dump_to="TimemachineFeature"), - "UHostType": fields.Str(required=False, dump_to="UHostType"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class GetUHostInstancePriceResponseSchema(schema.ResponseSchema): - """ GetUHostInstancePrice - 根据UHost实例配置,获取UHost实例的价格。 - """ - - fields = { - "PriceSet": fields.List( - models.UHostPriceSetSchema(), required=False, load_from="PriceSet" - ) - } - - -""" -API: GetUHostInstanceVncInfo - -获取指定UHost实例的管理VNC配置详细信息。 -""" - - -class GetUHostInstanceVncInfoRequestSchema(schema.RequestSchema): - """ GetUHostInstanceVncInfo - 获取指定UHost实例的管理VNC配置详细信息。 - """ - - fields = { - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "UHostId": fields.Str(required=True, dump_to="UHostId"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class GetUHostInstanceVncInfoResponseSchema(schema.ResponseSchema): - """ GetUHostInstanceVncInfo - 获取指定UHost实例的管理VNC配置详细信息。 - """ - - fields = { - "UhostId": fields.Str(required=False, load_from="UhostId"), - "VncIP": fields.Str(required=False, load_from="VncIP"), - "VncPassword": fields.Str(required=False, load_from="VncPassword"), - "VncPort": fields.Int(required=False, load_from="VncPort"), - } - - -""" -API: GetUHostUpgradePrice - -获取UHost实例升级配置的价格。可选配置范围请参考[[api:uhost-api:uhost_type|云主机机型说明]]。 -""" - - -class GetUHostUpgradePriceRequestSchema(schema.RequestSchema): - """ GetUHostUpgradePrice - 获取UHost实例升级配置的价格。可选配置范围请参考[[api:uhost-api:uhost_type|云主机机型说明]]。 - """ - - fields = { - "BootDiskSpace": fields.Int(required=False, dump_to="BootDiskSpace"), - "CPU": fields.Int(required=False, dump_to="CPU"), - "DiskSpace": fields.Int(required=False, dump_to="DiskSpace"), - "HostType": fields.Str(required=False, dump_to="HostType"), - "Memory": fields.Int(required=False, dump_to="Memory"), - "NetCapValue": fields.Int(required=False, dump_to="NetCapValue"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "TimemachineFeature": fields.Str(required=False, dump_to="TimemachineFeature"), - "UHostId": fields.Str(required=True, dump_to="UHostId"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class GetUHostUpgradePriceResponseSchema(schema.ResponseSchema): - """ GetUHostUpgradePrice - 获取UHost实例升级配置的价格。可选配置范围请参考[[api:uhost-api:uhost_type|云主机机型说明]]。 - """ - - fields = {"Price": fields.Float(required=False, load_from="Price")} - - -""" -API: ImportCustomImage - -把UFile的镜像文件导入到UHost,生成自定义镜像 -""" - - -class ImportCustomImageRequestSchema(schema.RequestSchema): - """ ImportCustomImage - 把UFile的镜像文件导入到UHost,生成自定义镜像 - """ - - fields = { - "Auth": fields.Bool(required=True, dump_to="Auth"), - "Format": fields.Str(required=True, dump_to="Format"), - "ImageDescription": fields.Str(required=False, dump_to="ImageDescription"), - "ImageName": fields.Str(required=True, dump_to="ImageName"), - "OsName": fields.Str(required=True, dump_to="OsName"), - "OsType": fields.Str(required=True, dump_to="OsType"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "UFileUrl": fields.Str(required=True, dump_to="UFileUrl"), - } - - -class ImportCustomImageResponseSchema(schema.ResponseSchema): - """ ImportCustomImage - 把UFile的镜像文件导入到UHost,生成自定义镜像 - """ - - fields = {"ImageId": fields.Str(required=False, load_from="ImageId")} - - -""" -API: ModifyUHostInstanceName - -修改指定UHost实例名称,需要给出数据中心,UHostId,及新的实例名称。 -""" - - -class ModifyUHostInstanceNameRequestSchema(schema.RequestSchema): - """ ModifyUHostInstanceName - 修改指定UHost实例名称,需要给出数据中心,UHostId,及新的实例名称。 - """ - - fields = { - "Name": fields.Str(required=False, dump_to="Name"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "UHostId": fields.Str(required=True, dump_to="UHostId"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class ModifyUHostInstanceNameResponseSchema(schema.ResponseSchema): - """ ModifyUHostInstanceName - 修改指定UHost实例名称,需要给出数据中心,UHostId,及新的实例名称。 - """ - - fields = {"UhostId": fields.Str(required=False, load_from="UhostId")} - - -""" -API: ModifyUHostInstanceRemark - -修改指定UHost实例备注信息。 -""" - - -class ModifyUHostInstanceRemarkRequestSchema(schema.RequestSchema): - """ ModifyUHostInstanceRemark - 修改指定UHost实例备注信息。 - """ - - fields = { - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Remark": fields.Str(required=False, dump_to="Remark"), - "UHostId": fields.Str(required=True, dump_to="UHostId"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class ModifyUHostInstanceRemarkResponseSchema(schema.ResponseSchema): - """ ModifyUHostInstanceRemark - 修改指定UHost实例备注信息。 - """ - - fields = {"UhostId": fields.Str(required=False, load_from="UhostId")} - - -""" -API: ModifyUHostInstanceTag - -修改指定UHost实例业务组标识。 -""" - - -class ModifyUHostInstanceTagRequestSchema(schema.RequestSchema): - """ ModifyUHostInstanceTag - 修改指定UHost实例业务组标识。 - """ - - fields = { - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Tag": fields.Str(required=False, dump_to="Tag"), - "UHostId": fields.Str(required=True, dump_to="UHostId"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class ModifyUHostInstanceTagResponseSchema(schema.ResponseSchema): - """ ModifyUHostInstanceTag - 修改指定UHost实例业务组标识。 - """ - - fields = {"UhostId": fields.Str(required=False, load_from="UhostId")} - - -""" -API: PoweroffUHostInstance - -直接关闭UHost实例电源,无需等待实例正常关闭。 -""" - - -class PoweroffUHostInstanceRequestSchema(schema.RequestSchema): - """ PoweroffUHostInstance - 直接关闭UHost实例电源,无需等待实例正常关闭。 - """ - - fields = { - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "UHostId": fields.Str(required=True, dump_to="UHostId"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class PoweroffUHostInstanceResponseSchema(schema.ResponseSchema): - """ PoweroffUHostInstance - 直接关闭UHost实例电源,无需等待实例正常关闭。 - """ - - fields = {"UhostId": fields.Str(required=False, load_from="UhostId")} - - -""" -API: RebootUHostInstance - -重新启动UHost实例,需要指定数据中心及UHostID两个参数的值。 -""" - - -class RebootUHostInstanceRequestSchema(schema.RequestSchema): - """ RebootUHostInstance - 重新启动UHost实例,需要指定数据中心及UHostID两个参数的值。 - """ - - fields = { - "DiskPassword": fields.Str(required=False, dump_to="DiskPassword"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "UHostId": fields.Str(required=True, dump_to="UHostId"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class RebootUHostInstanceResponseSchema(schema.ResponseSchema): - """ RebootUHostInstance - 重新启动UHost实例,需要指定数据中心及UHostID两个参数的值。 - """ - - fields = {"UhostId": fields.Str(required=False, load_from="UhostId")} - - -""" -API: ReinstallUHostInstance - -重新安装指定UHost实例的操作系统 -""" - - -class ReinstallUHostInstanceRequestSchema(schema.RequestSchema): - """ ReinstallUHostInstance - 重新安装指定UHost实例的操作系统 - """ - - fields = { - "BootDiskSpace": fields.Int(required=False, dump_to="BootDiskSpace"), - "DNSServers": fields.List(fields.Str()), - "ImageId": fields.Str(required=False, dump_to="ImageId"), - "Password": fields.Base64(required=False, dump_to="Password"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "ReserveDisk": fields.Str(required=False, dump_to="ReserveDisk"), - "ResourceType": fields.Int(required=False, dump_to="ResourceType"), - "UHostId": fields.Str(required=True, dump_to="UHostId"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class ReinstallUHostInstanceResponseSchema(schema.ResponseSchema): - """ ReinstallUHostInstance - 重新安装指定UHost实例的操作系统 - """ - - fields = {"UhostId": fields.Str(required=False, load_from="UhostId")} - - -""" -API: ResetUHostInstancePassword - -重置UHost实例的管理员密码。 -""" - - -class ResetUHostInstancePasswordRequestSchema(schema.RequestSchema): - """ ResetUHostInstancePassword - 重置UHost实例的管理员密码。 - """ - - fields = { - "Password": fields.Base64(required=True, dump_to="Password"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "UHostId": fields.Str(required=True, dump_to="UHostId"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class ResetUHostInstancePasswordResponseSchema(schema.ResponseSchema): - """ ResetUHostInstancePassword - 重置UHost实例的管理员密码。 - """ - - fields = {"UhostId": fields.Str(required=False, load_from="UhostId")} - - -""" -API: ResizeAttachedDisk - -修改挂载的磁盘大小,包含系统盘和数据盘 -""" - - -class ResizeAttachedDiskRequestSchema(schema.RequestSchema): - """ ResizeAttachedDisk - 修改挂载的磁盘大小,包含系统盘和数据盘 - """ - - fields = { - "DiskId": fields.Str(required=True, dump_to="DiskId"), - "DiskSpace": fields.Int(required=True, dump_to="DiskSpace"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "UHostId": fields.Str(required=True, dump_to="UHostId"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class ResizeAttachedDiskResponseSchema(schema.ResponseSchema): - """ ResizeAttachedDisk - 修改挂载的磁盘大小,包含系统盘和数据盘 - """ - - fields = {"DiskId": fields.Str(required=False, load_from="DiskId")} - - -""" -API: ResizeUHostInstance - -修改指定UHost实例的资源配置,如CPU核心数,内存容量大小,网络增强等。可选配置范围请参考[[api:uhost-api:uhost_type|云主机机型说明]]。 -""" - - -class ResizeUHostInstanceRequestSchema(schema.RequestSchema): - """ ResizeUHostInstance - 修改指定UHost实例的资源配置,如CPU核心数,内存容量大小,网络增强等。可选配置范围请参考[[api:uhost-api:uhost_type|云主机机型说明]]。 - """ - - fields = { - "BootDiskSpace": fields.Int(required=False, dump_to="BootDiskSpace"), - "CPU": fields.Int(required=False, dump_to="CPU"), - "DiskSpace": fields.Int(required=False, dump_to="DiskSpace"), - "Memory": fields.Int(required=False, dump_to="Memory"), - "NetCapValue": fields.Int(required=False, dump_to="NetCapValue"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "UHostId": fields.Str(required=True, dump_to="UHostId"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class ResizeUHostInstanceResponseSchema(schema.ResponseSchema): - """ ResizeUHostInstance - 修改指定UHost实例的资源配置,如CPU核心数,内存容量大小,网络增强等。可选配置范围请参考[[api:uhost-api:uhost_type|云主机机型说明]]。 - """ - - fields = {"UhostId": fields.Str(required=False, load_from="UhostId")} - - -""" -API: StartUHostInstance - -启动处于关闭状态的UHost实例,需要指定数据中心及UHostID两个参数的值。 -""" - - -class StartUHostInstanceRequestSchema(schema.RequestSchema): - """ StartUHostInstance - 启动处于关闭状态的UHost实例,需要指定数据中心及UHostID两个参数的值。 - """ - - fields = { - "DiskPassword": fields.Str(required=False, dump_to="DiskPassword"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "UHostId": fields.Str(required=True, dump_to="UHostId"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class StartUHostInstanceResponseSchema(schema.ResponseSchema): - """ StartUHostInstance - 启动处于关闭状态的UHost实例,需要指定数据中心及UHostID两个参数的值。 - """ - - fields = {"UhostId": fields.Str(required=False, load_from="UhostId")} - - -""" -API: StopUHostInstance - -指停止处于运行状态的UHost实例,需指定数据中心及UhostID。 -""" - - -class StopUHostInstanceRequestSchema(schema.RequestSchema): - """ StopUHostInstance - 指停止处于运行状态的UHost实例,需指定数据中心及UhostID。 - """ - - fields = { - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "UHostId": fields.Str(required=True, dump_to="UHostId"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class StopUHostInstanceResponseSchema(schema.ResponseSchema): - """ StopUHostInstance - 指停止处于运行状态的UHost实例,需指定数据中心及UhostID。 - """ - - fields = {"UhostId": fields.Str(required=False, load_from="UhostId")} - - -""" -API: TerminateCustomImage - -删除用户自定义镜像 -""" - - -class TerminateCustomImageRequestSchema(schema.RequestSchema): - """ TerminateCustomImage - 删除用户自定义镜像 - """ - - fields = { - "ImageId": fields.Str(required=True, dump_to="ImageId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - } - - -class TerminateCustomImageResponseSchema(schema.ResponseSchema): - """ TerminateCustomImage - 删除用户自定义镜像 - """ - - fields = {"ImageId": fields.Str(required=False, load_from="ImageId")} - - -""" -API: TerminateUHostInstance - -删除指定数据中心的UHost实例。 -""" - - -class TerminateUHostInstanceRequestSchema(schema.RequestSchema): - """ TerminateUHostInstance - 删除指定数据中心的UHost实例。 - """ - - fields = { - "Destroy": fields.Int(required=False, dump_to="Destroy"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "ReleaseEIP": fields.Bool(required=False, dump_to="ReleaseEIP"), - "ReleaseUDisk": fields.Bool(required=False, dump_to="ReleaseUDisk"), - "UHostId": fields.Str(required=True, dump_to="UHostId"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class TerminateUHostInstanceResponseSchema(schema.ResponseSchema): - """ TerminateUHostInstance - 删除指定数据中心的UHost实例。 - """ - - fields = { - "InRecycle": fields.Str(required=True, load_from="InRecycle"), - "UHostId": fields.Str(required=False, load_from="UHostId"), - } - - -""" -API: UpgradeToArkUHostInstance - -普通升级为方舟机型 -""" - - -class UpgradeToArkUHostInstanceRequestSchema(schema.RequestSchema): - """ UpgradeToArkUHostInstance - 普通升级为方舟机型 - """ - - fields = { - "CouponId": fields.Str(required=False, dump_to="CouponId"), - "Region": fields.Str(required=True, dump_to="Region"), - "UHostIds": fields.List(fields.Str()), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class UpgradeToArkUHostInstanceResponseSchema(schema.ResponseSchema): - """ UpgradeToArkUHostInstance - 普通升级为方舟机型 - """ - - fields = { - "UHostSet": fields.List(fields.Str(), required=False, load_from="UHostSet") - } +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.typesystem import schema, fields +from ucloud.services.uhost.schemas import models + +""" UHost API Schema +""" +""" +API: CopyCustomImage + +复制自制镜像 +""" + + +class CopyCustomImageRequestSchema(schema.RequestSchema): + """ CopyCustomImage - 复制自制镜像 + """ + + fields = { + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "SourceImageId": fields.Str(required=True, dump_to="SourceImageId"), + "TargetImageDescription": fields.Str( + required=False, dump_to="TargetImageDescription" + ), + "TargetImageName": fields.Str( + required=False, dump_to="TargetImageName" + ), + "TargetProjectId": fields.Str(required=True, dump_to="TargetProjectId"), + "TargetRegion": fields.Str(required=False, dump_to="TargetRegion"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class CopyCustomImageResponseSchema(schema.ResponseSchema): + """ CopyCustomImage - 复制自制镜像 + """ + + fields = { + "TargetImageId": fields.Str(required=False, load_from="TargetImageId") + } + + +""" +API: CreateCustomImage + +从指定UHost实例,生成自定义镜像。 +""" + + +class CreateCustomImageRequestSchema(schema.RequestSchema): + """ CreateCustomImage - 从指定UHost实例,生成自定义镜像。 + """ + + fields = { + "ImageDescription": fields.Str( + required=False, dump_to="ImageDescription" + ), + "ImageName": fields.Str(required=True, dump_to="ImageName"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "UHostId": fields.Str(required=True, dump_to="UHostId"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class CreateCustomImageResponseSchema(schema.ResponseSchema): + """ CreateCustomImage - 从指定UHost实例,生成自定义镜像。 + """ + + fields = {"ImageId": fields.Str(required=False, load_from="ImageId")} + + +""" +API: CreateUHostInstance + +创建UHost实例。 +""" + + +class CreateUHostInstanceParamNetworkInterfaceEIPGlobalSSHSchema( + schema.RequestSchema +): + """ CreateUHostInstanceParamNetworkInterfaceEIPGlobalSSH - + """ + + fields = { + "Area": fields.Str(required=False, dump_to="Area"), + "AreaCode": fields.Str(required=False, dump_to="AreaCode"), + "Port": fields.Int(required=False, dump_to="Port"), + } + + +class CreateUHostInstanceParamNetworkInterfaceEIPSchema(schema.RequestSchema): + """ CreateUHostInstanceParamNetworkInterfaceEIP - + """ + + fields = { + "Bandwidth": fields.Int(required=False, dump_to="Bandwidth"), + "CouponId": fields.Str(required=False, dump_to="CouponId"), + "GlobalSSH": CreateUHostInstanceParamNetworkInterfaceEIPGlobalSSHSchema( + required=False, dump_to="GlobalSSH" + ), + "OperatorName": fields.Str(required=False, dump_to="OperatorName"), + "PayMode": fields.Str(required=False, dump_to="PayMode"), + "ShareBandwidthId": fields.Str( + required=False, dump_to="ShareBandwidthId" + ), + } + + +class CreateUHostInstanceParamDisksSchema(schema.RequestSchema): + """ CreateUHostInstanceParamDisks - + """ + + fields = { + "BackupType": fields.Str(required=False, dump_to="BackupType"), + "CouponId": fields.Str(required=False, dump_to="CouponId"), + "Encrypted": fields.Bool(required=False, dump_to="Encrypted"), + "IsBoot": fields.Str(required=True, dump_to="IsBoot"), + "KmsKeyId": fields.Str(required=False, dump_to="KmsKeyId"), + "Size": fields.Int(required=True, dump_to="Size"), + "Type": fields.Str(required=True, dump_to="Type"), + } + + +class CreateUHostInstanceParamNetworkInterfaceSchema(schema.RequestSchema): + """ CreateUHostInstanceParamNetworkInterface - + """ + + fields = { + "EIP": CreateUHostInstanceParamNetworkInterfaceEIPSchema( + required=False, dump_to="EIP" + ) + } + + +class CreateUHostInstanceRequestSchema(schema.RequestSchema): + """ CreateUHostInstance - 创建UHost实例。 + """ + + fields = { + "AlarmTemplateId": fields.Int( + required=False, dump_to="AlarmTemplateId" + ), + "BootDiskSpace": fields.Int(required=False, dump_to="BootDiskSpace"), + "CPU": fields.Int(required=False, dump_to="CPU"), + "ChargeType": fields.Str(required=False, dump_to="ChargeType"), + "CouponId": fields.Str(required=False, dump_to="CouponId"), + "DiskPassword": fields.Str(required=False, dump_to="DiskPassword"), + "DiskSpace": fields.Int(required=False, dump_to="DiskSpace"), + "Disks": fields.List(CreateUHostInstanceParamDisksSchema()), + "GPU": fields.Int(required=False, dump_to="GPU"), + "GpuType": fields.Str(required=False, dump_to="GpuType"), + "HostType": fields.Str(required=False, dump_to="HostType"), + "HotplugFeature": fields.Bool(required=False, dump_to="HotplugFeature"), + "ImageId": fields.Str(required=True, dump_to="ImageId"), + "InstallAgent": fields.Str(required=False, dump_to="InstallAgent"), + "IsolationGroup": fields.Str(required=False, dump_to="IsolationGroup"), + "KeyPair": fields.Str(required=False, dump_to="KeyPair"), + "LoginMode": fields.Str(required=True, dump_to="LoginMode"), + "MachineType": fields.Str(required=False, dump_to="MachineType"), + "MaxCount": fields.Int(required=False, dump_to="MaxCount"), + "Memory": fields.Int(required=False, dump_to="Memory"), + "MinimalCpuPlatform": fields.Str( + required=False, dump_to="MinimalCpuPlatform" + ), + "Name": fields.Str(required=False, dump_to="Name"), + "NetCapability": fields.Str(required=False, dump_to="NetCapability"), + "NetworkId": fields.Str(required=False, dump_to="NetworkId"), + "NetworkInterface": fields.List( + CreateUHostInstanceParamNetworkInterfaceSchema() + ), + "Password": fields.Base64(required=True, dump_to="Password"), + "PrivateIp": fields.List(fields.Str()), + "PrivateMac": fields.Str(required=False, dump_to="PrivateMac"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Quantity": fields.Int(required=False, dump_to="Quantity"), + "Region": fields.Str(required=True, dump_to="Region"), + "ResourceType": fields.Int(required=False, dump_to="ResourceType"), + "SecurityGroupId": fields.Str( + required=False, dump_to="SecurityGroupId" + ), + "SetId": fields.Int(required=False, dump_to="SetId"), + "StorageType": fields.Str(required=False, dump_to="StorageType"), + "SubnetId": fields.Str(required=False, dump_to="SubnetId"), + "Tag": fields.Str(required=False, dump_to="Tag"), + "TimemachineFeature": fields.Str( + required=False, dump_to="TimemachineFeature" + ), + "UHostType": fields.Str(required=False, dump_to="UHostType"), + "UserDataScript": fields.Str(required=False, dump_to="UserDataScript"), + "VPCId": fields.Str(required=False, dump_to="VPCId"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class CreateUHostInstanceResponseSchema(schema.ResponseSchema): + """ CreateUHostInstance - 创建UHost实例。 + """ + + fields = { + "IPs": fields.List(fields.Str(), required=False, load_from="IPs"), + "UHostIds": fields.List( + fields.Str(), required=False, load_from="UHostIds" + ), + } + + +""" +API: DescribeImage + +获取指定数据中心镜像列表,用户可通过指定操作系统类型,镜像Id进行过滤。 +""" + + +class DescribeImageRequestSchema(schema.RequestSchema): + """ DescribeImage - 获取指定数据中心镜像列表,用户可通过指定操作系统类型,镜像Id进行过滤。 + """ + + fields = { + "ImageId": fields.Str(required=False, dump_to="ImageId"), + "ImageType": fields.Str(required=False, dump_to="ImageType"), + "Limit": fields.Int(required=False, dump_to="Limit"), + "Offset": fields.Int(required=False, dump_to="Offset"), + "OsType": fields.Str(required=False, dump_to="OsType"), + "PriceSet": fields.Int(required=False, dump_to="PriceSet"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class DescribeImageResponseSchema(schema.ResponseSchema): + """ DescribeImage - 获取指定数据中心镜像列表,用户可通过指定操作系统类型,镜像Id进行过滤。 + """ + + fields = { + "ImageSet": fields.List( + models.UHostImageSetSchema(), required=False, load_from="ImageSet" + ), + "TotalCount": fields.Int(required=False, load_from="TotalCount"), + } + + +""" +API: DescribeUHostInstance + +获取主机或主机列表信息,并可根据数据中心,主机ID等参数进行过滤。 +""" + + +class DescribeUHostInstanceRequestSchema(schema.RequestSchema): + """ DescribeUHostInstance - 获取主机或主机列表信息,并可根据数据中心,主机ID等参数进行过滤。 + """ + + fields = { + "IsolationGroup": fields.Str(required=False, dump_to="IsolationGroup"), + "LifeCycle": fields.Int(required=False, dump_to="LifeCycle"), + "Limit": fields.Int(required=False, dump_to="Limit"), + "Offset": fields.Int(required=False, dump_to="Offset"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "SubnetId": fields.Str(required=False, dump_to="SubnetId"), + "Tag": fields.Str(required=False, dump_to="Tag"), + "UHostIds": fields.List(fields.Str()), + "VPCId": fields.Str(required=False, dump_to="VPCId"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class DescribeUHostInstanceResponseSchema(schema.ResponseSchema): + """ DescribeUHostInstance - 获取主机或主机列表信息,并可根据数据中心,主机ID等参数进行过滤。 + """ + + fields = { + "TotalCount": fields.Int(required=False, load_from="TotalCount"), + "UHostSet": fields.List( + models.UHostInstanceSetSchema(), + required=False, + load_from="UHostSet", + ), + } + + +""" +API: DescribeUHostTags + +获取指定数据中心的业务组列表。 +""" + + +class DescribeUHostTagsRequestSchema(schema.RequestSchema): + """ DescribeUHostTags - 获取指定数据中心的业务组列表。 + """ + + fields = { + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class DescribeUHostTagsResponseSchema(schema.ResponseSchema): + """ DescribeUHostTags - 获取指定数据中心的业务组列表。 + """ + + fields = { + "TagSet": fields.List( + models.UHostTagSetSchema(), required=False, load_from="TagSet" + ), + "TotalCount": fields.Int(required=False, load_from="TotalCount"), + } + + +""" +API: GetUHostInstancePrice + +根据UHost实例配置,获取UHost实例的价格。 +""" + + +class GetUHostInstancePriceParamDisksSchema(schema.RequestSchema): + """ GetUHostInstancePriceParamDisks - + """ + + fields = { + "BackupType": fields.Str(required=False, dump_to="BackupType"), + "IsBoot": fields.Str(required=True, dump_to="IsBoot"), + "Size": fields.Int(required=True, dump_to="Size"), + "Type": fields.Str(required=True, dump_to="Type"), + } + + +class GetUHostInstancePriceRequestSchema(schema.RequestSchema): + """ GetUHostInstancePrice - 根据UHost实例配置,获取UHost实例的价格。 + """ + + fields = { + "CPU": fields.Int(required=True, dump_to="CPU"), + "ChargeType": fields.Str(required=False, dump_to="ChargeType"), + "Count": fields.Int(required=True, dump_to="Count"), + "DiskSpace": fields.Int(required=False, dump_to="DiskSpace"), + "Disks": fields.List(GetUHostInstancePriceParamDisksSchema()), + "GPU": fields.Int(required=False, dump_to="GPU"), + "GpuType": fields.Str(required=False, dump_to="GpuType"), + "ImageId": fields.Str(required=True, dump_to="ImageId"), + "LifeCycle": fields.Int(required=False, dump_to="LifeCycle"), + "MachineType": fields.Str(required=False, dump_to="MachineType"), + "Memory": fields.Int(required=True, dump_to="Memory"), + "NetCapability": fields.Str(required=False, dump_to="NetCapability"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Quantity": fields.Int(required=False, dump_to="Quantity"), + "Region": fields.Str(required=True, dump_to="Region"), + "StorageType": fields.Str(required=False, dump_to="StorageType"), + "TimemachineFeature": fields.Str( + required=False, dump_to="TimemachineFeature" + ), + "UHostType": fields.Str(required=False, dump_to="UHostType"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class GetUHostInstancePriceResponseSchema(schema.ResponseSchema): + """ GetUHostInstancePrice - 根据UHost实例配置,获取UHost实例的价格。 + """ + + fields = { + "PriceSet": fields.List( + models.UHostPriceSetSchema(), required=False, load_from="PriceSet" + ) + } + + +""" +API: GetUHostInstanceVncInfo + +获取指定UHost实例的管理VNC配置详细信息。 +""" + + +class GetUHostInstanceVncInfoRequestSchema(schema.RequestSchema): + """ GetUHostInstanceVncInfo - 获取指定UHost实例的管理VNC配置详细信息。 + """ + + fields = { + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "UHostId": fields.Str(required=True, dump_to="UHostId"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class GetUHostInstanceVncInfoResponseSchema(schema.ResponseSchema): + """ GetUHostInstanceVncInfo - 获取指定UHost实例的管理VNC配置详细信息。 + """ + + fields = { + "UhostId": fields.Str(required=False, load_from="UhostId"), + "VncIP": fields.Str(required=False, load_from="VncIP"), + "VncPassword": fields.Str(required=False, load_from="VncPassword"), + "VncPort": fields.Int(required=False, load_from="VncPort"), + } + + +""" +API: GetUHostUpgradePrice + +获取UHost实例升级配置的价格。可选配置范围请参考[[api:uhost-api:uhost_type|云主机机型说明]]。 +""" + + +class GetUHostUpgradePriceRequestSchema(schema.RequestSchema): + """ GetUHostUpgradePrice - 获取UHost实例升级配置的价格。可选配置范围请参考[[api:uhost-api:uhost_type|云主机机型说明]]。 + """ + + fields = { + "BootDiskSpace": fields.Int(required=False, dump_to="BootDiskSpace"), + "CPU": fields.Int(required=False, dump_to="CPU"), + "DiskSpace": fields.Int(required=False, dump_to="DiskSpace"), + "HostType": fields.Str(required=False, dump_to="HostType"), + "Memory": fields.Int(required=False, dump_to="Memory"), + "NetCapValue": fields.Int(required=False, dump_to="NetCapValue"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "TimemachineFeature": fields.Str( + required=False, dump_to="TimemachineFeature" + ), + "UHostId": fields.Str(required=True, dump_to="UHostId"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class GetUHostUpgradePriceResponseSchema(schema.ResponseSchema): + """ GetUHostUpgradePrice - 获取UHost实例升级配置的价格。可选配置范围请参考[[api:uhost-api:uhost_type|云主机机型说明]]。 + """ + + fields = {"Price": fields.Float(required=False, load_from="Price")} + + +""" +API: ImportCustomImage + +把UFile的镜像文件导入到UHost,生成自定义镜像 +""" + + +class ImportCustomImageRequestSchema(schema.RequestSchema): + """ ImportCustomImage - 把UFile的镜像文件导入到UHost,生成自定义镜像 + """ + + fields = { + "Auth": fields.Bool(required=True, dump_to="Auth"), + "Format": fields.Str(required=True, dump_to="Format"), + "ImageDescription": fields.Str( + required=False, dump_to="ImageDescription" + ), + "ImageName": fields.Str(required=True, dump_to="ImageName"), + "OsName": fields.Str(required=True, dump_to="OsName"), + "OsType": fields.Str(required=True, dump_to="OsType"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "UFileUrl": fields.Str(required=True, dump_to="UFileUrl"), + } + + +class ImportCustomImageResponseSchema(schema.ResponseSchema): + """ ImportCustomImage - 把UFile的镜像文件导入到UHost,生成自定义镜像 + """ + + fields = {"ImageId": fields.Str(required=False, load_from="ImageId")} + + +""" +API: ModifyUHostInstanceName + +修改指定UHost实例名称,需要给出数据中心,UHostId,及新的实例名称。 +""" + + +class ModifyUHostInstanceNameRequestSchema(schema.RequestSchema): + """ ModifyUHostInstanceName - 修改指定UHost实例名称,需要给出数据中心,UHostId,及新的实例名称。 + """ + + fields = { + "Name": fields.Str(required=False, dump_to="Name"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "UHostId": fields.Str(required=True, dump_to="UHostId"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class ModifyUHostInstanceNameResponseSchema(schema.ResponseSchema): + """ ModifyUHostInstanceName - 修改指定UHost实例名称,需要给出数据中心,UHostId,及新的实例名称。 + """ + + fields = {"UhostId": fields.Str(required=False, load_from="UhostId")} + + +""" +API: ModifyUHostInstanceRemark + +修改指定UHost实例备注信息。 +""" + + +class ModifyUHostInstanceRemarkRequestSchema(schema.RequestSchema): + """ ModifyUHostInstanceRemark - 修改指定UHost实例备注信息。 + """ + + fields = { + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Remark": fields.Str(required=False, dump_to="Remark"), + "UHostId": fields.Str(required=True, dump_to="UHostId"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class ModifyUHostInstanceRemarkResponseSchema(schema.ResponseSchema): + """ ModifyUHostInstanceRemark - 修改指定UHost实例备注信息。 + """ + + fields = {"UhostId": fields.Str(required=False, load_from="UhostId")} + + +""" +API: ModifyUHostInstanceTag + +修改指定UHost实例业务组标识。 +""" + + +class ModifyUHostInstanceTagRequestSchema(schema.RequestSchema): + """ ModifyUHostInstanceTag - 修改指定UHost实例业务组标识。 + """ + + fields = { + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Tag": fields.Str(required=False, dump_to="Tag"), + "UHostId": fields.Str(required=True, dump_to="UHostId"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class ModifyUHostInstanceTagResponseSchema(schema.ResponseSchema): + """ ModifyUHostInstanceTag - 修改指定UHost实例业务组标识。 + """ + + fields = {"UhostId": fields.Str(required=False, load_from="UhostId")} + + +""" +API: PoweroffUHostInstance + +直接关闭UHost实例电源,无需等待实例正常关闭。 +""" + + +class PoweroffUHostInstanceRequestSchema(schema.RequestSchema): + """ PoweroffUHostInstance - 直接关闭UHost实例电源,无需等待实例正常关闭。 + """ + + fields = { + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "UHostId": fields.Str(required=True, dump_to="UHostId"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class PoweroffUHostInstanceResponseSchema(schema.ResponseSchema): + """ PoweroffUHostInstance - 直接关闭UHost实例电源,无需等待实例正常关闭。 + """ + + fields = {"UhostId": fields.Str(required=False, load_from="UhostId")} + + +""" +API: RebootUHostInstance + +重新启动UHost实例,需要指定数据中心及UHostID两个参数的值。 +""" + + +class RebootUHostInstanceRequestSchema(schema.RequestSchema): + """ RebootUHostInstance - 重新启动UHost实例,需要指定数据中心及UHostID两个参数的值。 + """ + + fields = { + "DiskPassword": fields.Str(required=False, dump_to="DiskPassword"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "UHostId": fields.Str(required=True, dump_to="UHostId"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class RebootUHostInstanceResponseSchema(schema.ResponseSchema): + """ RebootUHostInstance - 重新启动UHost实例,需要指定数据中心及UHostID两个参数的值。 + """ + + fields = {"UhostId": fields.Str(required=False, load_from="UhostId")} + + +""" +API: ReinstallUHostInstance + +重新安装指定UHost实例的操作系统 +""" + + +class ReinstallUHostInstanceRequestSchema(schema.RequestSchema): + """ ReinstallUHostInstance - 重新安装指定UHost实例的操作系统 + """ + + fields = { + "BootDiskSpace": fields.Int(required=False, dump_to="BootDiskSpace"), + "DNSServers": fields.List(fields.Str()), + "ImageId": fields.Str(required=False, dump_to="ImageId"), + "Password": fields.Base64(required=False, dump_to="Password"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "ReserveDisk": fields.Str(required=False, dump_to="ReserveDisk"), + "ResourceType": fields.Int(required=False, dump_to="ResourceType"), + "UHostId": fields.Str(required=True, dump_to="UHostId"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class ReinstallUHostInstanceResponseSchema(schema.ResponseSchema): + """ ReinstallUHostInstance - 重新安装指定UHost实例的操作系统 + """ + + fields = {"UhostId": fields.Str(required=False, load_from="UhostId")} + + +""" +API: ResetUHostInstancePassword + +重置UHost实例的管理员密码。 +""" + + +class ResetUHostInstancePasswordRequestSchema(schema.RequestSchema): + """ ResetUHostInstancePassword - 重置UHost实例的管理员密码。 + """ + + fields = { + "Password": fields.Base64(required=True, dump_to="Password"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "UHostId": fields.Str(required=True, dump_to="UHostId"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class ResetUHostInstancePasswordResponseSchema(schema.ResponseSchema): + """ ResetUHostInstancePassword - 重置UHost实例的管理员密码。 + """ + + fields = {"UhostId": fields.Str(required=False, load_from="UhostId")} + + +""" +API: ResizeAttachedDisk + +修改挂载的磁盘大小,包含系统盘和数据盘 +""" + + +class ResizeAttachedDiskRequestSchema(schema.RequestSchema): + """ ResizeAttachedDisk - 修改挂载的磁盘大小,包含系统盘和数据盘 + """ + + fields = { + "DiskId": fields.Str(required=True, dump_to="DiskId"), + "DiskSpace": fields.Int(required=True, dump_to="DiskSpace"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "UHostId": fields.Str(required=True, dump_to="UHostId"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class ResizeAttachedDiskResponseSchema(schema.ResponseSchema): + """ ResizeAttachedDisk - 修改挂载的磁盘大小,包含系统盘和数据盘 + """ + + fields = {"DiskId": fields.Str(required=False, load_from="DiskId")} + + +""" +API: ResizeUHostInstance + +修改指定UHost实例的资源配置,如CPU核心数,内存容量大小,网络增强等。可选配置范围请参考[[api:uhost-api:uhost_type|云主机机型说明]]。 +""" + + +class ResizeUHostInstanceRequestSchema(schema.RequestSchema): + """ ResizeUHostInstance - 修改指定UHost实例的资源配置,如CPU核心数,内存容量大小,网络增强等。可选配置范围请参考[[api:uhost-api:uhost_type|云主机机型说明]]。 + """ + + fields = { + "BootDiskSpace": fields.Int(required=False, dump_to="BootDiskSpace"), + "CPU": fields.Int(required=False, dump_to="CPU"), + "DiskSpace": fields.Int(required=False, dump_to="DiskSpace"), + "Memory": fields.Int(required=False, dump_to="Memory"), + "NetCapValue": fields.Int(required=False, dump_to="NetCapValue"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "UHostId": fields.Str(required=True, dump_to="UHostId"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class ResizeUHostInstanceResponseSchema(schema.ResponseSchema): + """ ResizeUHostInstance - 修改指定UHost实例的资源配置,如CPU核心数,内存容量大小,网络增强等。可选配置范围请参考[[api:uhost-api:uhost_type|云主机机型说明]]。 + """ + + fields = {"UhostId": fields.Str(required=False, load_from="UhostId")} + + +""" +API: StartUHostInstance + +启动处于关闭状态的UHost实例,需要指定数据中心及UHostID两个参数的值。 +""" + + +class StartUHostInstanceRequestSchema(schema.RequestSchema): + """ StartUHostInstance - 启动处于关闭状态的UHost实例,需要指定数据中心及UHostID两个参数的值。 + """ + + fields = { + "DiskPassword": fields.Str(required=False, dump_to="DiskPassword"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "UHostId": fields.Str(required=True, dump_to="UHostId"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class StartUHostInstanceResponseSchema(schema.ResponseSchema): + """ StartUHostInstance - 启动处于关闭状态的UHost实例,需要指定数据中心及UHostID两个参数的值。 + """ + + fields = {"UhostId": fields.Str(required=False, load_from="UhostId")} + + +""" +API: StopUHostInstance + +指停止处于运行状态的UHost实例,需指定数据中心及UhostID。 +""" + + +class StopUHostInstanceRequestSchema(schema.RequestSchema): + """ StopUHostInstance - 指停止处于运行状态的UHost实例,需指定数据中心及UhostID。 + """ + + fields = { + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "UHostId": fields.Str(required=True, dump_to="UHostId"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class StopUHostInstanceResponseSchema(schema.ResponseSchema): + """ StopUHostInstance - 指停止处于运行状态的UHost实例,需指定数据中心及UhostID。 + """ + + fields = {"UhostId": fields.Str(required=False, load_from="UhostId")} + + +""" +API: TerminateCustomImage + +删除用户自定义镜像 +""" + + +class TerminateCustomImageRequestSchema(schema.RequestSchema): + """ TerminateCustomImage - 删除用户自定义镜像 + """ + + fields = { + "ImageId": fields.Str(required=True, dump_to="ImageId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + } + + +class TerminateCustomImageResponseSchema(schema.ResponseSchema): + """ TerminateCustomImage - 删除用户自定义镜像 + """ + + fields = {"ImageId": fields.Str(required=False, load_from="ImageId")} + + +""" +API: TerminateUHostInstance + +删除指定数据中心的UHost实例。 +""" + + +class TerminateUHostInstanceRequestSchema(schema.RequestSchema): + """ TerminateUHostInstance - 删除指定数据中心的UHost实例。 + """ + + fields = { + "Destroy": fields.Int(required=False, dump_to="Destroy"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "ReleaseEIP": fields.Bool(required=False, dump_to="ReleaseEIP"), + "ReleaseUDisk": fields.Bool(required=False, dump_to="ReleaseUDisk"), + "UHostId": fields.Str(required=True, dump_to="UHostId"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class TerminateUHostInstanceResponseSchema(schema.ResponseSchema): + """ TerminateUHostInstance - 删除指定数据中心的UHost实例。 + """ + + fields = { + "InRecycle": fields.Str(required=True, load_from="InRecycle"), + "UHostId": fields.Str(required=False, load_from="UHostId"), + } + + +""" +API: UpgradeToArkUHostInstance + +普通升级为方舟机型 +""" + + +class UpgradeToArkUHostInstanceRequestSchema(schema.RequestSchema): + """ UpgradeToArkUHostInstance - 普通升级为方舟机型 + """ + + fields = { + "CouponId": fields.Str(required=False, dump_to="CouponId"), + "Region": fields.Str(required=True, dump_to="Region"), + "UHostIds": fields.List(fields.Str()), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class UpgradeToArkUHostInstanceResponseSchema(schema.ResponseSchema): + """ UpgradeToArkUHostInstance - 普通升级为方舟机型 + """ + + fields = { + "UHostSet": fields.List( + fields.Str(), required=False, load_from="UHostSet" + ) + } diff --git a/ucloud/services/uhost/schemas/models.py b/ucloud/services/uhost/schemas/models.py index b309802..93fa7d4 100644 --- a/ucloud/services/uhost/schemas/models.py +++ b/ucloud/services/uhost/schemas/models.py @@ -1,126 +1,136 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.typesystem import schema, fields - - -class UHostImageSetSchema(schema.ResponseSchema): - """ UHostImageSet - DescribeImage - """ - - fields = { - "CreateTime": fields.Int(required=False, load_from="CreateTime"), - "Features": fields.List(fields.Str()), - "FuncType": fields.Str(required=False, load_from="FuncType"), - "ImageDescription": fields.Str(required=False, load_from="ImageDescription"), - "ImageId": fields.Str(required=False, load_from="ImageId"), - "ImageName": fields.Str(required=False, load_from="ImageName"), - "ImageSize": fields.Int(required=False, load_from="ImageSize"), - "ImageType": fields.Str(required=False, load_from="ImageType"), - "IntegratedSoftware": fields.Str( - required=False, load_from="IntegratedSoftware" - ), - "Links": fields.Str(required=False, load_from="Links"), - "MinimalCPU": fields.Str(required=False, load_from="MinimalCPU"), - "OsName": fields.Str(required=False, load_from="OsName"), - "OsType": fields.Str(required=False, load_from="OsType"), - "State": fields.Str(required=False, load_from="State"), - "Vendor": fields.Str(required=False, load_from="Vendor"), - "Zone": fields.Str(required=False, load_from="Zone"), - } - - -class UHostDiskSetSchema(schema.ResponseSchema): - """ UHostDiskSet - DescribeUHostInstance - """ - - fields = { - "BackupType": fields.Str(required=False, load_from="BackupType"), - "DiskId": fields.Str(required=False, load_from="DiskId"), - "DiskType": fields.Str(required=True, load_from="DiskType"), - "Drive": fields.Str(required=False, load_from="Drive"), - "Encrypted": fields.Bool(required=False, load_from="Encrypted"), - "IsBoot": fields.Str(required=True, load_from="IsBoot"), - "Name": fields.Str(required=False, load_from="Name"), - "Size": fields.Int(required=False, load_from="Size"), - "Type": fields.Str(required=False, load_from="Type"), - } - - -class UHostIPSetSchema(schema.ResponseSchema): - """ UHostIPSet - DescribeUHostInstance - """ - - fields = { - "Bandwidth": fields.Int(required=False, load_from="Bandwidth"), - "Default": fields.Str(required=False, load_from="Default"), - "IP": fields.Str(required=False, load_from="IP"), - "IPId": fields.Str(required=False, load_from="IPId"), - "SubnetId": fields.Str(required=False, load_from="SubnetId"), - "Type": fields.Str(required=False, load_from="Type"), - "VPCId": fields.Str(required=False, load_from="VPCId"), - } - - -class UHostInstanceSetSchema(schema.ResponseSchema): - """ UHostInstanceSet - DescribeUHostInstance - """ - - fields = { - "AutoRenew": fields.Str(required=False, load_from="AutoRenew"), - "BasicImageId": fields.Str(required=False, load_from="BasicImageId"), - "BasicImageName": fields.Str(required=False, load_from="BasicImageName"), - "BootDiskState": fields.Str(required=False, load_from="BootDiskState"), - "CPU": fields.Int(required=False, load_from="CPU"), - "ChargeType": fields.Str(required=False, load_from="ChargeType"), - "CreateTime": fields.Int(required=False, load_from="CreateTime"), - "DiskSet": fields.List(UHostDiskSetSchema()), - "ExpireTime": fields.Int(required=False, load_from="ExpireTime"), - "GPU": fields.Int(required=False, load_from="GPU"), - "HostType": fields.Str(required=False, load_from="HostType"), - "HotplugFeature": fields.Bool(required=False, load_from="HotplugFeature"), - "IPSet": fields.List(UHostIPSetSchema()), - "ImageId": fields.Str(required=False, load_from="ImageId"), - "IsolationGroup": fields.Str(required=False, load_from="IsolationGroup"), - "LifeCycle": fields.Str(required=False, load_from="LifeCycle"), - "MachineType": fields.Str(required=False, load_from="MachineType"), - "Memory": fields.Int(required=False, load_from="Memory"), - "Name": fields.Str(required=False, load_from="Name"), - "NetCapability": fields.Str(required=False, load_from="NetCapability"), - "NetworkState": fields.Str(required=False, load_from="NetworkState"), - "OsName": fields.Str(required=False, load_from="OsName"), - "OsType": fields.Str(required=False, load_from="OsType"), - "Remark": fields.Str(required=False, load_from="Remark"), - "State": fields.Str(required=False, load_from="State"), - "StorageType": fields.Str(required=False, load_from="StorageType"), - "SubnetType": fields.Str(required=False, load_from="SubnetType"), - "Tag": fields.Str(required=False, load_from="Tag"), - "TimemachineFeature": fields.Str( - required=False, load_from="TimemachineFeature" - ), - "TotalDiskSpace": fields.Int(required=False, load_from="TotalDiskSpace"), - "UHostId": fields.Str(required=False, load_from="UHostId"), - "UHostType": fields.Str(required=False, load_from="UHostType"), - "Zone": fields.Str(required=False, load_from="Zone"), - } - - -class UHostTagSetSchema(schema.ResponseSchema): - """ UHostTagSet - DescribeUHostTags - """ - - fields = { - "Tag": fields.Str(required=False, load_from="Tag"), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - "Zone": fields.Str(required=False, load_from="Zone"), - } - - -class UHostPriceSetSchema(schema.ResponseSchema): - """ UHostPriceSet - 主机价格 - """ - - fields = { - "ChargeType": fields.Str(required=True, load_from="ChargeType"), - "Price": fields.Float(required=True, load_from="Price"), - } +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.typesystem import schema, fields + + +class UHostImageSetSchema(schema.ResponseSchema): + """ UHostImageSet - DescribeImage + """ + + fields = { + "CreateTime": fields.Int(required=False, load_from="CreateTime"), + "Features": fields.List(fields.Str()), + "FuncType": fields.Str(required=False, load_from="FuncType"), + "ImageDescription": fields.Str( + required=False, load_from="ImageDescription" + ), + "ImageId": fields.Str(required=False, load_from="ImageId"), + "ImageName": fields.Str(required=False, load_from="ImageName"), + "ImageSize": fields.Int(required=False, load_from="ImageSize"), + "ImageType": fields.Str(required=False, load_from="ImageType"), + "IntegratedSoftware": fields.Str( + required=False, load_from="IntegratedSoftware" + ), + "Links": fields.Str(required=False, load_from="Links"), + "MinimalCPU": fields.Str(required=False, load_from="MinimalCPU"), + "OsName": fields.Str(required=False, load_from="OsName"), + "OsType": fields.Str(required=False, load_from="OsType"), + "State": fields.Str(required=False, load_from="State"), + "Vendor": fields.Str(required=False, load_from="Vendor"), + "Zone": fields.Str(required=False, load_from="Zone"), + } + + +class UHostDiskSetSchema(schema.ResponseSchema): + """ UHostDiskSet - DescribeUHostInstance + """ + + fields = { + "BackupType": fields.Str(required=False, load_from="BackupType"), + "DiskId": fields.Str(required=False, load_from="DiskId"), + "DiskType": fields.Str(required=True, load_from="DiskType"), + "Drive": fields.Str(required=False, load_from="Drive"), + "Encrypted": fields.Bool(required=False, load_from="Encrypted"), + "IsBoot": fields.Str(required=True, load_from="IsBoot"), + "Name": fields.Str(required=False, load_from="Name"), + "Size": fields.Int(required=False, load_from="Size"), + "Type": fields.Str(required=False, load_from="Type"), + } + + +class UHostIPSetSchema(schema.ResponseSchema): + """ UHostIPSet - DescribeUHostInstance + """ + + fields = { + "Bandwidth": fields.Int(required=False, load_from="Bandwidth"), + "Default": fields.Str(required=False, load_from="Default"), + "IP": fields.Str(required=False, load_from="IP"), + "IPId": fields.Str(required=False, load_from="IPId"), + "SubnetId": fields.Str(required=False, load_from="SubnetId"), + "Type": fields.Str(required=False, load_from="Type"), + "VPCId": fields.Str(required=False, load_from="VPCId"), + } + + +class UHostInstanceSetSchema(schema.ResponseSchema): + """ UHostInstanceSet - DescribeUHostInstance + """ + + fields = { + "AutoRenew": fields.Str(required=False, load_from="AutoRenew"), + "BasicImageId": fields.Str(required=False, load_from="BasicImageId"), + "BasicImageName": fields.Str( + required=False, load_from="BasicImageName" + ), + "BootDiskState": fields.Str(required=False, load_from="BootDiskState"), + "CPU": fields.Int(required=False, load_from="CPU"), + "ChargeType": fields.Str(required=False, load_from="ChargeType"), + "CreateTime": fields.Int(required=False, load_from="CreateTime"), + "DiskSet": fields.List(UHostDiskSetSchema()), + "ExpireTime": fields.Int(required=False, load_from="ExpireTime"), + "GPU": fields.Int(required=False, load_from="GPU"), + "HostType": fields.Str(required=False, load_from="HostType"), + "HotplugFeature": fields.Bool( + required=False, load_from="HotplugFeature" + ), + "IPSet": fields.List(UHostIPSetSchema()), + "ImageId": fields.Str(required=False, load_from="ImageId"), + "IsolationGroup": fields.Str( + required=False, load_from="IsolationGroup" + ), + "LifeCycle": fields.Str(required=False, load_from="LifeCycle"), + "MachineType": fields.Str(required=False, load_from="MachineType"), + "Memory": fields.Int(required=False, load_from="Memory"), + "Name": fields.Str(required=False, load_from="Name"), + "NetCapability": fields.Str(required=False, load_from="NetCapability"), + "NetworkState": fields.Str(required=False, load_from="NetworkState"), + "OsName": fields.Str(required=False, load_from="OsName"), + "OsType": fields.Str(required=False, load_from="OsType"), + "Remark": fields.Str(required=False, load_from="Remark"), + "State": fields.Str(required=False, load_from="State"), + "StorageType": fields.Str(required=False, load_from="StorageType"), + "SubnetType": fields.Str(required=False, load_from="SubnetType"), + "Tag": fields.Str(required=False, load_from="Tag"), + "TimemachineFeature": fields.Str( + required=False, load_from="TimemachineFeature" + ), + "TotalDiskSpace": fields.Int( + required=False, load_from="TotalDiskSpace" + ), + "UHostId": fields.Str(required=False, load_from="UHostId"), + "UHostType": fields.Str(required=False, load_from="UHostType"), + "Zone": fields.Str(required=False, load_from="Zone"), + } + + +class UHostTagSetSchema(schema.ResponseSchema): + """ UHostTagSet - DescribeUHostTags + """ + + fields = { + "Tag": fields.Str(required=False, load_from="Tag"), + "TotalCount": fields.Int(required=False, load_from="TotalCount"), + "Zone": fields.Str(required=False, load_from="Zone"), + } + + +class UHostPriceSetSchema(schema.ResponseSchema): + """ UHostPriceSet - 主机价格 + """ + + fields = { + "ChargeType": fields.Str(required=True, load_from="ChargeType"), + "Price": fields.Float(required=True, load_from="Price"), + } diff --git a/ucloud/services/ulb/__init__.py b/ucloud/services/ulb/__init__.py index 4c48b5a..40a96af 100644 --- a/ucloud/services/ulb/__init__.py +++ b/ucloud/services/ulb/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- diff --git a/ucloud/services/ulb/client.py b/ucloud/services/ulb/client.py index 6fa55d9..9ff8d0f 100644 --- a/ucloud/services/ulb/client.py +++ b/ucloud/services/ulb/client.py @@ -1,655 +1,655 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.client import Client -from ucloud.services.ulb.schemas import apis - - -class ULBClient(Client): - def __init__(self, config, transport=None, middleware=None, logger=None): - super(ULBClient, self).__init__(config, transport, middleware, logger) - - def allocate_backend(self, req=None, **kwargs): - """ AllocateBackend - 添加ULB后端资源实例 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **ResourceId** (str) - (Required) 所添加的后端资源的资源ID - - **ResourceType** (str) - (Required) 所添加的后端资源的类型,枚举值:UHost -> 云主机;UPM -> 物理云主机; UDHost -> 私有专区主机;UDocker -> 容器,默认值为“UHost” - - **ULBId** (str) - (Required) 负载均衡实例的ID - - **VServerId** (str) - (Required) VServer实例的ID - - **Enabled** (int) - 后端实例状态开关,枚举值: 1:启用; 0:禁用 默认为启用 - - **Port** (int) - 所添加的后端资源服务端口,取值范围[1-65535],默认80 - - **Weight** (int) - 所添加的后端RS权重(在加权轮询算法下有效),取值范围[0-100],默认为1 - - **Response** - - - **BackendId** (str) - 所添加的后端资源在ULB中的对象ID,(为ULB系统中使用,与资源自身ID无关),可用于 UpdateBackendAttribute/UpdateBackendAttributeBatch/ReleaseBackend - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.AllocateBackendRequestSchema().dumps(d) - resp = self.invoke("AllocateBackend", d, **kwargs) - return apis.AllocateBackendResponseSchema().loads(resp) - - def allocate_backend_batch(self, req=None, **kwargs): - """ AllocateBackendBatch - 批量添加VServer后端节点 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Backends** (list) - (Required) 用| 分割字段,格式:ResourceId| ResourceType| Port| Enabled|IP| Weight。ResourceId:所添加的后端资源的资源ID;ResourceType:所添加的后端资源的类型,枚举值:UHost -> 云主机;UPM -> 物理云主机; UDHost -> 私有专区主机;UDocker -> 容器,默认值为“UHost”;Port:所添加的后端资源服务端口,取值范围[1-65535];Enabled:后端实例状态开关,枚举值: 1:启用; 0:禁用;IP:后端资源内网ip;Weight:所添加的后端RS权重(在加权轮询算法下有效),取值范围[0-100],默认为1 - - **ULBId** (str) - (Required) 负载均衡实例的ID - - **VServerId** (str) - (Required) VServer实例的ID - - **ApiVersion** (int) - - - **Response** - - - **BackendSet** (list) - 见 **BackendSet** 模型定义 - - **Response Model** - - **BackendSet** - - - **BackendId** (str) - rs的资源ID - - **ResourceId** (str) - rs对应的UHost ID - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.AllocateBackendBatchRequestSchema().dumps(d) - resp = self.invoke("AllocateBackendBatch", d, **kwargs) - return apis.AllocateBackendBatchResponseSchema().loads(resp) - - def bind_ssl(self, req=None, **kwargs): - """ BindSSL - 将SSL证书绑定到VServer - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **SSLId** (str) - (Required) SSL证书的Id - - **ULBId** (str) - (Required) 所绑定ULB实例ID - - **VServerId** (str) - (Required) 所绑定VServer实例ID - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.BindSSLRequestSchema().dumps(d) - resp = self.invoke("BindSSL", d, **kwargs) - return apis.BindSSLResponseSchema().loads(resp) - - def create_policy(self, req=None, **kwargs): - """ CreatePolicy - 创建VServer内容转发策略 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **BackendId** (list) - (Required) 内容转发策略应用的后端资源实例的ID,来源于 AllocateBackend 返回的 BackendId - - **Match** (str) - (Required) 内容转发匹配字段 - - **ULBId** (str) - (Required) 需要添加内容转发策略的负载均衡实例ID - - **VServerId** (str) - (Required) 需要添加内容转发策略的VServer实例ID - - **Type** (str) - 内容转发匹配字段的类型 - - **Response** - - - **PolicyId** (str) - 内容转发策略ID - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.CreatePolicyRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("CreatePolicy", d, **kwargs) - return apis.CreatePolicyResponseSchema().loads(resp) - - def create_ssl(self, req=None, **kwargs): - """ CreateSSL - 创建SSL证书,可以把整个 Pem 证书内容传过来,或者把证书、私钥、CA证书分别传过来 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **SSLName** (str) - (Required) SSL证书的名字,默认值为空 - - **CaCert** (str) - CA证书 - - **PrivateKey** (str) - 加密证书的私钥 - - **SSLContent** (str) - SSL证书的完整内容,包括用户证书、加密证书的私钥、CA证书 - - **SSLType** (str) - 所添加的SSL证书类型,目前只支持Pem格式 - - **UserCert** (str) - 用户的证书 - - **Response** - - - **SSLId** (str) - SSL证书的Id - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.CreateSSLRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("CreateSSL", d, **kwargs) - return apis.CreateSSLResponseSchema().loads(resp) - - def create_ulb(self, req=None, **kwargs): - """ CreateULB - 创建负载均衡实例,可以选择内网或者外网 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **BusinessId** (str) - ULB 所属的业务组ID,如果不传则使用默认的业务组 - - **ChargeType** (str) - 付费方式 - - **IPVersion** (str) - ULB ip类型,枚举值:IPv6 / IPv4 (内部测试,暂未对外开放) - - **InnerMode** (str) - 创建的ULB是否为内网模式 - - **ListenType** (str) - ULB 监听器类型,枚举值:RequestProxy / PacketsTransmit (内部测试,暂未对外开放) - - **OuterMode** (str) - 创建的ULB是否为外网模式,默认即为外网模式 - - **PrivateIp** (str) - 创建内网ULB时指定内网IP。若不传值,则随机分配当前子网下的IP(暂时不对外开放,创建外网ULB该字段会忽略) - - **Remark** (str) - 备注 - - **SubnetId** (str) - 内网ULB 所属的子网ID,如果不传则使用默认的子网 - - **Tag** (str) - 业务组 - - **ULBName** (str) - 负载均衡的名字,默认值为“ULB” - - **VPCId** (str) - ULB所在的VPC的ID, 如果不传则使用默认的VPC - - **Response** - - - **ULBId** (str) - 负载均衡实例的Id - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.CreateULBRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("CreateULB", d, **kwargs) - return apis.CreateULBResponseSchema().loads(resp) - - def create_vserver(self, req=None, **kwargs): - """ CreateVServer - 创建VServer实例,定义监听的协议和端口以及负载均衡算法 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **ULBId** (str) - (Required) 负载均衡实例ID - - **ClientTimeout** (int) - ListenType为RequestProxy时表示空闲连接的回收时间,单位:秒,取值范围:时(0,86400],默认值为60;ListenType为PacketsTransmit时表示连接保持的时间,单位:秒,取值范围:[60,900],0 表示禁用连接保持 - - **Domain** (str) - 根据MonitorType确认; 当MonitorType为Port时,此字段无意义。当MonitorType为Path时,代表HTTP检查域名 - - **FrontendPort** (int) - VServer后端端口,取值范围[1-65535];默认值为80 - - **ListenType** (str) - 监听器类型,枚举值为:RequestProxy -> 请求代理;PacketsTransmit -> 报文转发;默认为"RequestProxy" - - **Method** (str) - VServer负载均衡模式,枚举值:Roundrobin -> 轮询;Source -> 源地址;ConsistentHash -> 一致性哈希;SourcePort -> 源地址(计算端口);ConsistentHashPort -> 一致性哈希(计算端口); WeightRoundrobin -> 加权轮询; Leastconn -> 最小连接数。ConsistentHash,SourcePort,ConsistentHashPort 只在报文转发中使用;Leastconn只在请求代理中使用;Roundrobin、Source和WeightRoundrobin在请求代理和报文转发中使用。默认为:"Roundrobin" - - **MonitorType** (str) - 健康检查类型,枚举值:Port -> 端口检查;Path -> 路径检查; - - **Path** (str) - 根据MonitorType确认; 当MonitorType为Port时,此字段无意义。当MonitorType为Path时,代表HTTP检查路径 - - **PersistenceInfo** (str) - 根据PersistenceType确认; None和ServerInsert: 此字段无意义; UserDefined:此字段传入自定义会话保持String - - **PersistenceType** (str) - VServer会话保持方式,默认关闭会话保持。枚举值:None -> 关闭;ServerInsert -> 自动生成KEY;UserDefined -> 用户自定义KEY。 - - **Protocol** (str) - VServer实例的协议,请求代理模式下有 HTTP、HTTPS、TCP,报文转发下有 TCP,UDP。默认为“HTTP" - - **VServerName** (str) - VServer实例名称,默认为"VServer" - - **Response** - - - **VServerId** (str) - VServer实例的Id - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.CreateVServerRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("CreateVServer", d, **kwargs) - return apis.CreateVServerResponseSchema().loads(resp) - - def delete_policy(self, req=None, **kwargs): - """ DeletePolicy - 删除内容转发策略 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **PolicyId** (str) - (Required) 内容转发策略ID - - **GroupId** (str) - 内容转发策略组ID - - **VServerId** (str) - VServer 资源ID - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DeletePolicyRequestSchema().dumps(d) - resp = self.invoke("DeletePolicy", d, **kwargs) - return apis.DeletePolicyResponseSchema().loads(resp) - - def delete_ssl(self, req=None, **kwargs): - """ DeleteSSL - 删除SSL证书 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **SSLId** (str) - (Required) SSL证书的ID - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DeleteSSLRequestSchema().dumps(d) - resp = self.invoke("DeleteSSL", d, **kwargs) - return apis.DeleteSSLResponseSchema().loads(resp) - - def delete_ulb(self, req=None, **kwargs): - """ DeleteULB - 删除负载均衡实例 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **ULBId** (str) - (Required) 负载均衡实例的ID - - **ReleaseEip** (bool) - 删除ulb时是否释放绑定的EIP,false标识只解绑EIP,true表示会释放绑定的EIP,默认是false - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DeleteULBRequestSchema().dumps(d) - resp = self.invoke("DeleteULB", d, **kwargs) - return apis.DeleteULBResponseSchema().loads(resp) - - def delete_vserver(self, req=None, **kwargs): - """ DeleteVServer - 删除VServer实例 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **ULBId** (str) - (Required) 负载均衡实例的ID - - **VServerId** (str) - (Required) VServer实例的ID - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DeleteVServerRequestSchema().dumps(d) - resp = self.invoke("DeleteVServer", d, **kwargs) - return apis.DeleteVServerResponseSchema().loads(resp) - - def describe_ssl(self, req=None, **kwargs): - """ DescribeSSL - 获取SSL证书信息 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Limit** (int) - 数据分页值,默认为20 - - **Offset** (int) - 数据偏移量,默认值为0 - - **SSLId** (str) - SSL证书的Id - - **Response** - - - **DataSet** (list) - 见 **ULBSSLSet** 模型定义 - - **TotalCount** (int) - 满足条件的SSL证书总数 - - **Response Model** - - **ULBSSLSet** - - - **HashValue** (str) - - - **SSLId** (str) - SSL证书的Id - - **SSLName** (str) - SSL证书的名字 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeSSLRequestSchema().dumps(d) - resp = self.invoke("DescribeSSL", d, **kwargs) - return apis.DescribeSSLResponseSchema().loads(resp) - - def describe_ulb(self, req=None, **kwargs): - """ DescribeULB - 获取ULB详细信息 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **BusinessId** (str) - ULB所属的业务组ID - - **Limit** (int) - 数据分页值,默认为20 - - **Offset** (int) - 数据偏移量,默认为0 - - **SubnetId** (str) - ULB所属的子网ID - - **ULBId** (str) - 负载均衡实例的Id。 若指定则返回指定的负载均衡实例的信息; 若不指定则返回当前数据中心中所有的负载均衡实例的信息 - - **VPCId** (str) - ULB所属的VPC - - **Response** - - - **DataSet** (list) - 见 **ULBSet** 模型定义 - - **TotalCount** (int) - 满足条件的ULB总数 - - **Response Model** - - **PolicyBackendSet** - - - **BackendId** (str) - 所添加的后端资源在ULB中的对象ID,(为ULB系统中使用,与资源自身ID无关 - - **ObjectId** (str) - 后端资源的对象ID - - **Port** (int) - 所添加的后端资源服务端口 - - **PrivateIP** (str) - 后端资源的内网IP - - **ResourceName** (str) - 后端资源的实例名称 - - **ULBPolicySet** - - - **BackendSet** (list) - 见 **PolicyBackendSet** 模型定义 - - **Match** (str) - 内容转发匹配字段;默认内容转发类型下为空。 - - **PolicyId** (str) - 内容转发Id,默认内容转发类型下为空。 - - **PolicyPriority** (int) - 内容转发优先级,范围[1,9999],数字越大优先级越高。默认内容转发规则下为0。 - - **PolicyType** (str) - 内容类型,枚举值:Custom -> 客户自定义;Default -> 默认内容转发 - - **TotalCount** (int) - 默认内容转发类型下返回当前rs总数 - - **Type** (str) - 内容转发匹配字段的类型,枚举值:Domain -> 域名;Path -> 路径; 默认内容转发类型下为空 - - **VServerId** (str) - 所属VServerId - - **ULBBackendSet** - - - **BackendId** (str) - 后端资源实例的Id - - **Enabled** (int) - 后端提供服务的实例启用与否,枚举值:0 禁用 1 启用 - - **Port** (int) - 后端提供服务的端口 - - **PrivateIP** (str) - 后端提供服务的内网IP - - **ResourceId** (str) - 资源实例的资源Id - - **ResourceName** (str) - 资源实例的资源名称 - - **ResourceType** (str) - 资源实例的类型 - - **Status** (int) - 后端提供服务的实例运行状态,枚举值:0健康检查健康状态 1 健康检查异常 - - **SubResourceId** (str) - 资源绑定的虚拟网卡实例的资源Id - - **SubResourceName** (str) - 资源绑定的虚拟网卡实例的资源名称 - - **SubResourceType** (str) - 资源绑定的虚拟网卡实例的类型 - - **SubnetId** (str) - 后端提供服务的资源所在的子网的ID - - **Weight** (int) - - - **ULBSSLSet** - - - **HashValue** (str) - - - **SSLId** (str) - SSL证书的Id - - **SSLName** (str) - SSL证书的名字 - - **ULBVServerSet** - - - **BackendSet** (list) - 见 **ULBBackendSet** 模型定义 - - **ClientTimeout** (int) - 空闲连接的回收时间,单位:秒。 - - **Domain** (str) - 根据MonitorType确认; 当MonitorType为Port时,此字段无意义。当MonitorType为Path时,代表HTTP检查域名 - - **FrontendPort** (int) - VServer服务端口 - - **ListenType** (str) - 监听器类型,枚举值为: RequestProxy -> 请求代理;PacketsTransmit -> 报文转发 - - **Method** (str) - VServer负载均衡的模式,枚举值:Roundrobin -> 轮询;Source -> 源地址;ConsistentHash -> 一致性哈希;SourcePort -> 源地址(计算端口);ConsistentHashPort -> 一致性哈希(计算端口)。 - - **MonitorType** (str) - 健康检查类型,枚举值:Port -> 端口检查;Path -> 路径检查; - - **Path** (str) - 根据MonitorType确认; 当MonitorType为Port时,此字段无意义。当MonitorType为Path时,代表HTTP检查路径 - - **PersistenceInfo** (str) - 根据PersistenceType确定: None或ServerInsert,此字段为空; UserDefined,此字段展示用户自定义会话string。 - - **PersistenceType** (str) - VServer会话保持方式。枚举值为: None -> 关闭会话保持; ServerInsert -> 自动生成; UserDefined -> 用户自定义。 - - **PolicySet** (list) - 见 **ULBPolicySet** 模型定义 - - **Protocol** (str) - VServer实例的协议。 枚举值为:HTTP,TCP,UDP,HTTPS。 - - **SSLSet** (list) - 见 **ULBSSLSet** 模型定义 - - **Status** (int) - VServer的运行状态。枚举值: 0 -> rs全部运行正常;1 -> rs全部运行异常;2 -> rs部分运行异常。 - - **VServerId** (str) - VServer实例的Id - - **VServerName** (str) - VServer实例的名字 - - **ULBIPSet** - - - **Bandwidth** (int) - 弹性IP的带宽值(暂未对外开放) - - **BandwidthType** (int) - 弹性IP的带宽类型,枚举值:1 表示是共享带宽,0 普通带宽类型(暂未对外开放) - - **EIP** (str) - 弹性IP地址 - - **EIPId** (str) - 弹性IP的ID - - **OperatorName** (str) - 弹性IP的运营商信息,枚举值为: Bgp:BGP IP International:国际IP - - **ULBSet** - - - **Bandwidth** (int) - 带宽 - - **BandwidthType** (int) - 带宽类型,枚举值为: 0,非共享带宽; 1,共享带宽 - - **BusinessId** (str) - ULB 所属的业务组ID - - **CreateTime** (int) - ULB的创建时间,格式为Unix Timestamp - - **ExpireTime** (int) - ULB的到期时间,格式为Unix Timestamp - - **IPSet** (list) - 见 **ULBIPSet** 模型定义 - - **Name** (str) - 负载均衡的资源名称(资源系统中),缺省值“ULB” - - **PrivateIP** (str) - ULB的内网IP,当ULBType为OuterMode时,该值为空 - - **Remark** (str) - 负载均衡的备注,缺省值“” - - **Resource** (list) - ULB的详细信息列表(废弃) - - **SubnetId** (str) - ULB 为 InnerMode 时,ULB 所属的子网ID,默认为空 - - **Tag** (str) - 负载均衡的业务组名称,缺省值“Default” - - **ULBId** (str) - 负载均衡的资源ID - - **ULBName** (str) - 负载均衡的资源名称(内部记载,废弃) - - **ULBType** (str) - ULB 的类型 - - **VPCId** (str) - ULB所在的VPC的ID - - **VServerSet** (list) - 见 **ULBVServerSet** 模型定义 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeULBRequestSchema().dumps(d) - resp = self.invoke("DescribeULB", d, **kwargs) - return apis.DescribeULBResponseSchema().loads(resp) - - def describe_vserver(self, req=None, **kwargs): - """ DescribeVServer - 获取ULB下的VServer的详细信息 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **ULBId** (str) - (Required) 负载均衡实例的Id - - **Limit** (int) - 数据分页值 - - **Offset** (int) - 数据偏移量 - - **VServerId** (str) - VServer实例的Id;若指定则返回指定的VServer实例的信息; 若不指定则返回当前负载均衡实例下所有VServer的信息 - - **Response** - - - **DataSet** (list) - 见 **ULBVServerSet** 模型定义 - - **TotalCount** (int) - 满足条件的VServer总数 - - **Response Model** - - **PolicyBackendSet** - - - **BackendId** (str) - 所添加的后端资源在ULB中的对象ID,(为ULB系统中使用,与资源自身ID无关 - - **ObjectId** (str) - 后端资源的对象ID - - **Port** (int) - 所添加的后端资源服务端口 - - **PrivateIP** (str) - 后端资源的内网IP - - **ResourceName** (str) - 后端资源的实例名称 - - **ULBSSLSet** - - - **HashValue** (str) - - - **SSLId** (str) - SSL证书的Id - - **SSLName** (str) - SSL证书的名字 - - **ULBPolicySet** - - - **BackendSet** (list) - 见 **PolicyBackendSet** 模型定义 - - **Match** (str) - 内容转发匹配字段;默认内容转发类型下为空。 - - **PolicyId** (str) - 内容转发Id,默认内容转发类型下为空。 - - **PolicyPriority** (int) - 内容转发优先级,范围[1,9999],数字越大优先级越高。默认内容转发规则下为0。 - - **PolicyType** (str) - 内容类型,枚举值:Custom -> 客户自定义;Default -> 默认内容转发 - - **TotalCount** (int) - 默认内容转发类型下返回当前rs总数 - - **Type** (str) - 内容转发匹配字段的类型,枚举值:Domain -> 域名;Path -> 路径; 默认内容转发类型下为空 - - **VServerId** (str) - 所属VServerId - - **ULBBackendSet** - - - **BackendId** (str) - 后端资源实例的Id - - **Enabled** (int) - 后端提供服务的实例启用与否,枚举值:0 禁用 1 启用 - - **Port** (int) - 后端提供服务的端口 - - **PrivateIP** (str) - 后端提供服务的内网IP - - **ResourceId** (str) - 资源实例的资源Id - - **ResourceName** (str) - 资源实例的资源名称 - - **ResourceType** (str) - 资源实例的类型 - - **Status** (int) - 后端提供服务的实例运行状态,枚举值:0健康检查健康状态 1 健康检查异常 - - **SubResourceId** (str) - 资源绑定的虚拟网卡实例的资源Id - - **SubResourceName** (str) - 资源绑定的虚拟网卡实例的资源名称 - - **SubResourceType** (str) - 资源绑定的虚拟网卡实例的类型 - - **SubnetId** (str) - 后端提供服务的资源所在的子网的ID - - **Weight** (int) - - - **ULBVServerSet** - - - **BackendSet** (list) - 见 **ULBBackendSet** 模型定义 - - **ClientTimeout** (int) - 空闲连接的回收时间,单位:秒。 - - **Domain** (str) - 根据MonitorType确认; 当MonitorType为Port时,此字段无意义。当MonitorType为Path时,代表HTTP检查域名 - - **FrontendPort** (int) - VServer服务端口 - - **ListenType** (str) - 监听器类型,枚举值为: RequestProxy -> 请求代理;PacketsTransmit -> 报文转发 - - **Method** (str) - VServer负载均衡的模式,枚举值:Roundrobin -> 轮询;Source -> 源地址;ConsistentHash -> 一致性哈希;SourcePort -> 源地址(计算端口);ConsistentHashPort -> 一致性哈希(计算端口)。 - - **MonitorType** (str) - 健康检查类型,枚举值:Port -> 端口检查;Path -> 路径检查; - - **Path** (str) - 根据MonitorType确认; 当MonitorType为Port时,此字段无意义。当MonitorType为Path时,代表HTTP检查路径 - - **PersistenceInfo** (str) - 根据PersistenceType确定: None或ServerInsert,此字段为空; UserDefined,此字段展示用户自定义会话string。 - - **PersistenceType** (str) - VServer会话保持方式。枚举值为: None -> 关闭会话保持; ServerInsert -> 自动生成; UserDefined -> 用户自定义。 - - **PolicySet** (list) - 见 **ULBPolicySet** 模型定义 - - **Protocol** (str) - VServer实例的协议。 枚举值为:HTTP,TCP,UDP,HTTPS。 - - **SSLSet** (list) - 见 **ULBSSLSet** 模型定义 - - **Status** (int) - VServer的运行状态。枚举值: 0 -> rs全部运行正常;1 -> rs全部运行异常;2 -> rs部分运行异常。 - - **VServerId** (str) - VServer实例的Id - - **VServerName** (str) - VServer实例的名字 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeVServerRequestSchema().dumps(d) - resp = self.invoke("DescribeVServer", d, **kwargs) - return apis.DescribeVServerResponseSchema().loads(resp) - - def release_backend(self, req=None, **kwargs): - """ ReleaseBackend - 从VServer释放后端资源实例 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **BackendId** (str) - (Required) 后端资源实例的ID(ULB后端ID,非资源自身ID) - - **ULBId** (str) - (Required) 负载均衡实例的ID - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.ReleaseBackendRequestSchema().dumps(d) - resp = self.invoke("ReleaseBackend", d, **kwargs) - return apis.ReleaseBackendResponseSchema().loads(resp) - - def unbind_ssl(self, req=None, **kwargs): - """ UnbindSSL - 从VServer解绑SSL证书 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **SSLId** (str) - (Required) SSL证书的Id - - **ULBId** (str) - (Required) 所绑定ULB实例ID - - **VServerId** (str) - (Required) 所绑定VServer实例ID - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.UnbindSSLRequestSchema().dumps(d) - resp = self.invoke("UnbindSSL", d, **kwargs) - return apis.UnbindSSLResponseSchema().loads(resp) - - def update_backend_attribute(self, req=None, **kwargs): - """ UpdateBackendAttribute - 更新ULB后端资源实例(服务节点)属性 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **BackendId** (str) - (Required) 后端资源实例的ID(ULB后端ID,非资源自身ID) - - **ULBId** (str) - (Required) 负载均衡资源ID - - **Enabled** (int) - 后端实例状态开关 - - **Port** (int) - 后端资源服务端口,取值范围[1-65535] - - **Weight** (int) - 所添加的后端RS权重(在加权轮询算法下有效),取值范围[0-100],默认为1 - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.UpdateBackendAttributeRequestSchema().dumps(d) - resp = self.invoke("UpdateBackendAttribute", d, **kwargs) - return apis.UpdateBackendAttributeResponseSchema().loads(resp) - - def update_policy(self, req=None, **kwargs): - """ UpdatePolicy - 更新内容转发规则,包括转发规则后的服务节点 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **BackendId** (list) - (Required) 内容转发策略应用的后端资源实例的ID,来源于 AllocateBackend 返回的 BackendId - - **Match** (str) - (Required) 内容转发匹配字段 - - **PolicyId** (str) - (Required) 转发规则的ID - - **ULBId** (str) - (Required) 需要添加内容转发策略的负载均衡实例ID - - **VServerId** (str) - (Required) 需要添加内容转发策略的VServer实例ID - - **Type** (str) - 内容转发匹配字段的类型 - - **Response** - - - **PolicyId** (str) - 转发规则的ID - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.UpdatePolicyRequestSchema().dumps(d) - resp = self.invoke("UpdatePolicy", d, **kwargs) - return apis.UpdatePolicyResponseSchema().loads(resp) - - def update_ulb_attribute(self, req=None, **kwargs): - """ UpdateULBAttribute - 更新ULB名字业务组备注等属性字段 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **ULBId** (str) - (Required) ULB资源ID - - **Name** (str) - 名字 - - **Remark** (str) - 备注 - - **Tag** (str) - 业务 - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.UpdateULBAttributeRequestSchema().dumps(d) - resp = self.invoke("UpdateULBAttribute", d, **kwargs) - return apis.UpdateULBAttributeResponseSchema().loads(resp) - - def update_vserver_attribute(self, req=None, **kwargs): - """ UpdateVServerAttribute - 更新VServer实例属性 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **ULBId** (str) - (Required) 负载均衡实例ID - - **VServerId** (str) - (Required) VServer实例ID - - **ClientTimeout** (int) - 请求代理的VServer下表示空闲连接的回收时间,单位:秒,取值范围:时(0,86400],默认值为60;报文转发的VServer下表示回话保持的时间,单位:秒,取值范围:[60,900],0 表示禁用连接保持 - - **Domain** (str) - MonitorType 为 Path 时指定健康检查发送请求时HTTP HEADER 里的域名 - - **Method** (str) - VServer负载均衡模式,枚举值:Roundrobin -> 轮询;Source -> 源地址;ConsistentHash -> 一致性哈希;SourcePort -> 源地址(计算端口);ConsistentHashPort -> 一致性哈希(计算端口); WeightRoundrobin -> 加权轮询; Leastconn -> 最小连接数。ConsistentHash,SourcePort,ConsistentHashPort 只在报文转发中使用;Leastconn只在请求代理中使用;Roundrobin、Source和WeightRoundrobin在请求代理和报文转发中使用。默认为:"Roundrobin" - - **MonitorType** (str) - 健康检查的类型,Port:端口,Path:路径 - - **Path** (str) - MonitorType 为 Path 时指定健康检查发送请求时的路径,默认为 / - - **PersistenceInfo** (str) - 根据PersistenceType确定: None或ServerInsert, 此字段无意义; UserDefined, 则此字段传入用户自定义会话保持String. 若无此字段则不做修改 - - **PersistenceType** (str) - VServer会话保持模式,若无此字段则不做修改。枚举值:None:关闭;ServerInsert:自动生成KEY;UserDefined:用户自定义KEY。 - - **Protocol** (str) - VServer协议类型,请求代理只支持修改为 HTTP/HTTPS,报文转发VServer只支持修改为 TCP/UDP - - **VServerName** (str) - VServer实例名称,若无此字段则不做修改 - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.UpdateVServerAttributeRequestSchema().dumps(d) - resp = self.invoke("UpdateVServerAttribute", d, **kwargs) - return apis.UpdateVServerAttributeResponseSchema().loads(resp) +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.client import Client +from ucloud.services.ulb.schemas import apis + + +class ULBClient(Client): + def __init__(self, config, transport=None, middleware=None, logger=None): + super(ULBClient, self).__init__(config, transport, middleware, logger) + + def allocate_backend(self, req=None, **kwargs): + """ AllocateBackend - 添加ULB后端资源实例 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **ResourceId** (str) - (Required) 所添加的后端资源的资源ID + - **ResourceType** (str) - (Required) 所添加的后端资源的类型,枚举值:UHost -> 云主机;UPM -> 物理云主机; UDHost -> 私有专区主机;UDocker -> 容器,默认值为“UHost” + - **ULBId** (str) - (Required) 负载均衡实例的ID + - **VServerId** (str) - (Required) VServer实例的ID + - **Enabled** (int) - 后端实例状态开关,枚举值: 1:启用; 0:禁用 默认为启用 + - **Port** (int) - 所添加的后端资源服务端口,取值范围[1-65535],默认80 + - **Weight** (int) - 所添加的后端RS权重(在加权轮询算法下有效),取值范围[0-100],默认为1 + + **Response** + + - **BackendId** (str) - 所添加的后端资源在ULB中的对象ID,(为ULB系统中使用,与资源自身ID无关),可用于 UpdateBackendAttribute/UpdateBackendAttributeBatch/ReleaseBackend + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.AllocateBackendRequestSchema().dumps(d) + resp = self.invoke("AllocateBackend", d, **kwargs) + return apis.AllocateBackendResponseSchema().loads(resp) + + def allocate_backend_batch(self, req=None, **kwargs): + """ AllocateBackendBatch - 批量添加VServer后端节点 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Backends** (list) - (Required) 用| 分割字段,格式:ResourceId| ResourceType| Port| Enabled|IP| Weight。ResourceId:所添加的后端资源的资源ID;ResourceType:所添加的后端资源的类型,枚举值:UHost -> 云主机;UPM -> 物理云主机; UDHost -> 私有专区主机;UDocker -> 容器,默认值为“UHost”;Port:所添加的后端资源服务端口,取值范围[1-65535];Enabled:后端实例状态开关,枚举值: 1:启用; 0:禁用;IP:后端资源内网ip;Weight:所添加的后端RS权重(在加权轮询算法下有效),取值范围[0-100],默认为1 + - **ULBId** (str) - (Required) 负载均衡实例的ID + - **VServerId** (str) - (Required) VServer实例的ID + - **ApiVersion** (int) - + + **Response** + + - **BackendSet** (list) - 见 **BackendSet** 模型定义 + + **Response Model** + + **BackendSet** + + - **BackendId** (str) - rs的资源ID + - **ResourceId** (str) - rs对应的UHost ID + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.AllocateBackendBatchRequestSchema().dumps(d) + resp = self.invoke("AllocateBackendBatch", d, **kwargs) + return apis.AllocateBackendBatchResponseSchema().loads(resp) + + def bind_ssl(self, req=None, **kwargs): + """ BindSSL - 将SSL证书绑定到VServer + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **SSLId** (str) - (Required) SSL证书的Id + - **ULBId** (str) - (Required) 所绑定ULB实例ID + - **VServerId** (str) - (Required) 所绑定VServer实例ID + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.BindSSLRequestSchema().dumps(d) + resp = self.invoke("BindSSL", d, **kwargs) + return apis.BindSSLResponseSchema().loads(resp) + + def create_policy(self, req=None, **kwargs): + """ CreatePolicy - 创建VServer内容转发策略 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **BackendId** (list) - (Required) 内容转发策略应用的后端资源实例的ID,来源于 AllocateBackend 返回的 BackendId + - **Match** (str) - (Required) 内容转发匹配字段 + - **ULBId** (str) - (Required) 需要添加内容转发策略的负载均衡实例ID + - **VServerId** (str) - (Required) 需要添加内容转发策略的VServer实例ID + - **Type** (str) - 内容转发匹配字段的类型 + + **Response** + + - **PolicyId** (str) - 内容转发策略ID + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.CreatePolicyRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("CreatePolicy", d, **kwargs) + return apis.CreatePolicyResponseSchema().loads(resp) + + def create_ssl(self, req=None, **kwargs): + """ CreateSSL - 创建SSL证书,可以把整个 Pem 证书内容传过来,或者把证书、私钥、CA证书分别传过来 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **SSLName** (str) - (Required) SSL证书的名字,默认值为空 + - **CaCert** (str) - CA证书 + - **PrivateKey** (str) - 加密证书的私钥 + - **SSLContent** (str) - SSL证书的完整内容,包括用户证书、加密证书的私钥、CA证书 + - **SSLType** (str) - 所添加的SSL证书类型,目前只支持Pem格式 + - **UserCert** (str) - 用户的证书 + + **Response** + + - **SSLId** (str) - SSL证书的Id + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.CreateSSLRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("CreateSSL", d, **kwargs) + return apis.CreateSSLResponseSchema().loads(resp) + + def create_ulb(self, req=None, **kwargs): + """ CreateULB - 创建负载均衡实例,可以选择内网或者外网 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **BusinessId** (str) - ULB 所属的业务组ID,如果不传则使用默认的业务组 + - **ChargeType** (str) - 付费方式 + - **IPVersion** (str) - ULB ip类型,枚举值:IPv6 / IPv4 (内部测试,暂未对外开放) + - **InnerMode** (str) - 创建的ULB是否为内网模式 + - **ListenType** (str) - ULB 监听器类型,枚举值:RequestProxy / PacketsTransmit (内部测试,暂未对外开放) + - **OuterMode** (str) - 创建的ULB是否为外网模式,默认即为外网模式 + - **PrivateIp** (str) - 创建内网ULB时指定内网IP。若不传值,则随机分配当前子网下的IP(暂时不对外开放,创建外网ULB该字段会忽略) + - **Remark** (str) - 备注 + - **SubnetId** (str) - 内网ULB 所属的子网ID,如果不传则使用默认的子网 + - **Tag** (str) - 业务组 + - **ULBName** (str) - 负载均衡的名字,默认值为“ULB” + - **VPCId** (str) - ULB所在的VPC的ID, 如果不传则使用默认的VPC + + **Response** + + - **ULBId** (str) - 负载均衡实例的Id + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.CreateULBRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("CreateULB", d, **kwargs) + return apis.CreateULBResponseSchema().loads(resp) + + def create_vserver(self, req=None, **kwargs): + """ CreateVServer - 创建VServer实例,定义监听的协议和端口以及负载均衡算法 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **ULBId** (str) - (Required) 负载均衡实例ID + - **ClientTimeout** (int) - ListenType为RequestProxy时表示空闲连接的回收时间,单位:秒,取值范围:时(0,86400],默认值为60;ListenType为PacketsTransmit时表示连接保持的时间,单位:秒,取值范围:[60,900],0 表示禁用连接保持 + - **Domain** (str) - 根据MonitorType确认; 当MonitorType为Port时,此字段无意义。当MonitorType为Path时,代表HTTP检查域名 + - **FrontendPort** (int) - VServer后端端口,取值范围[1-65535];默认值为80 + - **ListenType** (str) - 监听器类型,枚举值为:RequestProxy -> 请求代理;PacketsTransmit -> 报文转发;默认为"RequestProxy" + - **Method** (str) - VServer负载均衡模式,枚举值:Roundrobin -> 轮询;Source -> 源地址;ConsistentHash -> 一致性哈希;SourcePort -> 源地址(计算端口);ConsistentHashPort -> 一致性哈希(计算端口); WeightRoundrobin -> 加权轮询; Leastconn -> 最小连接数。ConsistentHash,SourcePort,ConsistentHashPort 只在报文转发中使用;Leastconn只在请求代理中使用;Roundrobin、Source和WeightRoundrobin在请求代理和报文转发中使用。默认为:"Roundrobin" + - **MonitorType** (str) - 健康检查类型,枚举值:Port -> 端口检查;Path -> 路径检查; + - **Path** (str) - 根据MonitorType确认; 当MonitorType为Port时,此字段无意义。当MonitorType为Path时,代表HTTP检查路径 + - **PersistenceInfo** (str) - 根据PersistenceType确认; None和ServerInsert: 此字段无意义; UserDefined:此字段传入自定义会话保持String + - **PersistenceType** (str) - VServer会话保持方式,默认关闭会话保持。枚举值:None -> 关闭;ServerInsert -> 自动生成KEY;UserDefined -> 用户自定义KEY。 + - **Protocol** (str) - VServer实例的协议,请求代理模式下有 HTTP、HTTPS、TCP,报文转发下有 TCP,UDP。默认为“HTTP" + - **VServerName** (str) - VServer实例名称,默认为"VServer" + + **Response** + + - **VServerId** (str) - VServer实例的Id + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.CreateVServerRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("CreateVServer", d, **kwargs) + return apis.CreateVServerResponseSchema().loads(resp) + + def delete_policy(self, req=None, **kwargs): + """ DeletePolicy - 删除内容转发策略 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **PolicyId** (str) - (Required) 内容转发策略ID + - **GroupId** (str) - 内容转发策略组ID + - **VServerId** (str) - VServer 资源ID + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DeletePolicyRequestSchema().dumps(d) + resp = self.invoke("DeletePolicy", d, **kwargs) + return apis.DeletePolicyResponseSchema().loads(resp) + + def delete_ssl(self, req=None, **kwargs): + """ DeleteSSL - 删除SSL证书 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **SSLId** (str) - (Required) SSL证书的ID + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DeleteSSLRequestSchema().dumps(d) + resp = self.invoke("DeleteSSL", d, **kwargs) + return apis.DeleteSSLResponseSchema().loads(resp) + + def delete_ulb(self, req=None, **kwargs): + """ DeleteULB - 删除负载均衡实例 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **ULBId** (str) - (Required) 负载均衡实例的ID + - **ReleaseEip** (bool) - 删除ulb时是否释放绑定的EIP,false标识只解绑EIP,true表示会释放绑定的EIP,默认是false + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DeleteULBRequestSchema().dumps(d) + resp = self.invoke("DeleteULB", d, **kwargs) + return apis.DeleteULBResponseSchema().loads(resp) + + def delete_vserver(self, req=None, **kwargs): + """ DeleteVServer - 删除VServer实例 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **ULBId** (str) - (Required) 负载均衡实例的ID + - **VServerId** (str) - (Required) VServer实例的ID + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DeleteVServerRequestSchema().dumps(d) + resp = self.invoke("DeleteVServer", d, **kwargs) + return apis.DeleteVServerResponseSchema().loads(resp) + + def describe_ssl(self, req=None, **kwargs): + """ DescribeSSL - 获取SSL证书信息 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Limit** (int) - 数据分页值,默认为20 + - **Offset** (int) - 数据偏移量,默认值为0 + - **SSLId** (str) - SSL证书的Id + + **Response** + + - **DataSet** (list) - 见 **ULBSSLSet** 模型定义 + - **TotalCount** (int) - 满足条件的SSL证书总数 + + **Response Model** + + **ULBSSLSet** + + - **HashValue** (str) - + - **SSLId** (str) - SSL证书的Id + - **SSLName** (str) - SSL证书的名字 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeSSLRequestSchema().dumps(d) + resp = self.invoke("DescribeSSL", d, **kwargs) + return apis.DescribeSSLResponseSchema().loads(resp) + + def describe_ulb(self, req=None, **kwargs): + """ DescribeULB - 获取ULB详细信息 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **BusinessId** (str) - ULB所属的业务组ID + - **Limit** (int) - 数据分页值,默认为20 + - **Offset** (int) - 数据偏移量,默认为0 + - **SubnetId** (str) - ULB所属的子网ID + - **ULBId** (str) - 负载均衡实例的Id。 若指定则返回指定的负载均衡实例的信息; 若不指定则返回当前数据中心中所有的负载均衡实例的信息 + - **VPCId** (str) - ULB所属的VPC + + **Response** + + - **DataSet** (list) - 见 **ULBSet** 模型定义 + - **TotalCount** (int) - 满足条件的ULB总数 + + **Response Model** + + **PolicyBackendSet** + + - **BackendId** (str) - 所添加的后端资源在ULB中的对象ID,(为ULB系统中使用,与资源自身ID无关 + - **ObjectId** (str) - 后端资源的对象ID + - **Port** (int) - 所添加的后端资源服务端口 + - **PrivateIP** (str) - 后端资源的内网IP + - **ResourceName** (str) - 后端资源的实例名称 + + **ULBPolicySet** + + - **BackendSet** (list) - 见 **PolicyBackendSet** 模型定义 + - **Match** (str) - 内容转发匹配字段;默认内容转发类型下为空。 + - **PolicyId** (str) - 内容转发Id,默认内容转发类型下为空。 + - **PolicyPriority** (int) - 内容转发优先级,范围[1,9999],数字越大优先级越高。默认内容转发规则下为0。 + - **PolicyType** (str) - 内容类型,枚举值:Custom -> 客户自定义;Default -> 默认内容转发 + - **TotalCount** (int) - 默认内容转发类型下返回当前rs总数 + - **Type** (str) - 内容转发匹配字段的类型,枚举值:Domain -> 域名;Path -> 路径; 默认内容转发类型下为空 + - **VServerId** (str) - 所属VServerId + + **ULBBackendSet** + + - **BackendId** (str) - 后端资源实例的Id + - **Enabled** (int) - 后端提供服务的实例启用与否,枚举值:0 禁用 1 启用 + - **Port** (int) - 后端提供服务的端口 + - **PrivateIP** (str) - 后端提供服务的内网IP + - **ResourceId** (str) - 资源实例的资源Id + - **ResourceName** (str) - 资源实例的资源名称 + - **ResourceType** (str) - 资源实例的类型 + - **Status** (int) - 后端提供服务的实例运行状态,枚举值:0健康检查健康状态 1 健康检查异常 + - **SubResourceId** (str) - 资源绑定的虚拟网卡实例的资源Id + - **SubResourceName** (str) - 资源绑定的虚拟网卡实例的资源名称 + - **SubResourceType** (str) - 资源绑定的虚拟网卡实例的类型 + - **SubnetId** (str) - 后端提供服务的资源所在的子网的ID + - **Weight** (int) - + + **ULBSSLSet** + + - **HashValue** (str) - + - **SSLId** (str) - SSL证书的Id + - **SSLName** (str) - SSL证书的名字 + + **ULBVServerSet** + + - **BackendSet** (list) - 见 **ULBBackendSet** 模型定义 + - **ClientTimeout** (int) - 空闲连接的回收时间,单位:秒。 + - **Domain** (str) - 根据MonitorType确认; 当MonitorType为Port时,此字段无意义。当MonitorType为Path时,代表HTTP检查域名 + - **FrontendPort** (int) - VServer服务端口 + - **ListenType** (str) - 监听器类型,枚举值为: RequestProxy -> 请求代理;PacketsTransmit -> 报文转发 + - **Method** (str) - VServer负载均衡的模式,枚举值:Roundrobin -> 轮询;Source -> 源地址;ConsistentHash -> 一致性哈希;SourcePort -> 源地址(计算端口);ConsistentHashPort -> 一致性哈希(计算端口)。 + - **MonitorType** (str) - 健康检查类型,枚举值:Port -> 端口检查;Path -> 路径检查; + - **Path** (str) - 根据MonitorType确认; 当MonitorType为Port时,此字段无意义。当MonitorType为Path时,代表HTTP检查路径 + - **PersistenceInfo** (str) - 根据PersistenceType确定: None或ServerInsert,此字段为空; UserDefined,此字段展示用户自定义会话string。 + - **PersistenceType** (str) - VServer会话保持方式。枚举值为: None -> 关闭会话保持; ServerInsert -> 自动生成; UserDefined -> 用户自定义。 + - **PolicySet** (list) - 见 **ULBPolicySet** 模型定义 + - **Protocol** (str) - VServer实例的协议。 枚举值为:HTTP,TCP,UDP,HTTPS。 + - **SSLSet** (list) - 见 **ULBSSLSet** 模型定义 + - **Status** (int) - VServer的运行状态。枚举值: 0 -> rs全部运行正常;1 -> rs全部运行异常;2 -> rs部分运行异常。 + - **VServerId** (str) - VServer实例的Id + - **VServerName** (str) - VServer实例的名字 + + **ULBIPSet** + + - **Bandwidth** (int) - 弹性IP的带宽值(暂未对外开放) + - **BandwidthType** (int) - 弹性IP的带宽类型,枚举值:1 表示是共享带宽,0 普通带宽类型(暂未对外开放) + - **EIP** (str) - 弹性IP地址 + - **EIPId** (str) - 弹性IP的ID + - **OperatorName** (str) - 弹性IP的运营商信息,枚举值为: Bgp:BGP IP International:国际IP + + **ULBSet** + + - **Bandwidth** (int) - 带宽 + - **BandwidthType** (int) - 带宽类型,枚举值为: 0,非共享带宽; 1,共享带宽 + - **BusinessId** (str) - ULB 所属的业务组ID + - **CreateTime** (int) - ULB的创建时间,格式为Unix Timestamp + - **ExpireTime** (int) - ULB的到期时间,格式为Unix Timestamp + - **IPSet** (list) - 见 **ULBIPSet** 模型定义 + - **Name** (str) - 负载均衡的资源名称(资源系统中),缺省值“ULB” + - **PrivateIP** (str) - ULB的内网IP,当ULBType为OuterMode时,该值为空 + - **Remark** (str) - 负载均衡的备注,缺省值“” + - **Resource** (list) - ULB的详细信息列表(废弃) + - **SubnetId** (str) - ULB 为 InnerMode 时,ULB 所属的子网ID,默认为空 + - **Tag** (str) - 负载均衡的业务组名称,缺省值“Default” + - **ULBId** (str) - 负载均衡的资源ID + - **ULBName** (str) - 负载均衡的资源名称(内部记载,废弃) + - **ULBType** (str) - ULB 的类型 + - **VPCId** (str) - ULB所在的VPC的ID + - **VServerSet** (list) - 见 **ULBVServerSet** 模型定义 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeULBRequestSchema().dumps(d) + resp = self.invoke("DescribeULB", d, **kwargs) + return apis.DescribeULBResponseSchema().loads(resp) + + def describe_vserver(self, req=None, **kwargs): + """ DescribeVServer - 获取ULB下的VServer的详细信息 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **ULBId** (str) - (Required) 负载均衡实例的Id + - **Limit** (int) - 数据分页值 + - **Offset** (int) - 数据偏移量 + - **VServerId** (str) - VServer实例的Id;若指定则返回指定的VServer实例的信息; 若不指定则返回当前负载均衡实例下所有VServer的信息 + + **Response** + + - **DataSet** (list) - 见 **ULBVServerSet** 模型定义 + - **TotalCount** (int) - 满足条件的VServer总数 + + **Response Model** + + **PolicyBackendSet** + + - **BackendId** (str) - 所添加的后端资源在ULB中的对象ID,(为ULB系统中使用,与资源自身ID无关 + - **ObjectId** (str) - 后端资源的对象ID + - **Port** (int) - 所添加的后端资源服务端口 + - **PrivateIP** (str) - 后端资源的内网IP + - **ResourceName** (str) - 后端资源的实例名称 + + **ULBSSLSet** + + - **HashValue** (str) - + - **SSLId** (str) - SSL证书的Id + - **SSLName** (str) - SSL证书的名字 + + **ULBPolicySet** + + - **BackendSet** (list) - 见 **PolicyBackendSet** 模型定义 + - **Match** (str) - 内容转发匹配字段;默认内容转发类型下为空。 + - **PolicyId** (str) - 内容转发Id,默认内容转发类型下为空。 + - **PolicyPriority** (int) - 内容转发优先级,范围[1,9999],数字越大优先级越高。默认内容转发规则下为0。 + - **PolicyType** (str) - 内容类型,枚举值:Custom -> 客户自定义;Default -> 默认内容转发 + - **TotalCount** (int) - 默认内容转发类型下返回当前rs总数 + - **Type** (str) - 内容转发匹配字段的类型,枚举值:Domain -> 域名;Path -> 路径; 默认内容转发类型下为空 + - **VServerId** (str) - 所属VServerId + + **ULBBackendSet** + + - **BackendId** (str) - 后端资源实例的Id + - **Enabled** (int) - 后端提供服务的实例启用与否,枚举值:0 禁用 1 启用 + - **Port** (int) - 后端提供服务的端口 + - **PrivateIP** (str) - 后端提供服务的内网IP + - **ResourceId** (str) - 资源实例的资源Id + - **ResourceName** (str) - 资源实例的资源名称 + - **ResourceType** (str) - 资源实例的类型 + - **Status** (int) - 后端提供服务的实例运行状态,枚举值:0健康检查健康状态 1 健康检查异常 + - **SubResourceId** (str) - 资源绑定的虚拟网卡实例的资源Id + - **SubResourceName** (str) - 资源绑定的虚拟网卡实例的资源名称 + - **SubResourceType** (str) - 资源绑定的虚拟网卡实例的类型 + - **SubnetId** (str) - 后端提供服务的资源所在的子网的ID + - **Weight** (int) - + + **ULBVServerSet** + + - **BackendSet** (list) - 见 **ULBBackendSet** 模型定义 + - **ClientTimeout** (int) - 空闲连接的回收时间,单位:秒。 + - **Domain** (str) - 根据MonitorType确认; 当MonitorType为Port时,此字段无意义。当MonitorType为Path时,代表HTTP检查域名 + - **FrontendPort** (int) - VServer服务端口 + - **ListenType** (str) - 监听器类型,枚举值为: RequestProxy -> 请求代理;PacketsTransmit -> 报文转发 + - **Method** (str) - VServer负载均衡的模式,枚举值:Roundrobin -> 轮询;Source -> 源地址;ConsistentHash -> 一致性哈希;SourcePort -> 源地址(计算端口);ConsistentHashPort -> 一致性哈希(计算端口)。 + - **MonitorType** (str) - 健康检查类型,枚举值:Port -> 端口检查;Path -> 路径检查; + - **Path** (str) - 根据MonitorType确认; 当MonitorType为Port时,此字段无意义。当MonitorType为Path时,代表HTTP检查路径 + - **PersistenceInfo** (str) - 根据PersistenceType确定: None或ServerInsert,此字段为空; UserDefined,此字段展示用户自定义会话string。 + - **PersistenceType** (str) - VServer会话保持方式。枚举值为: None -> 关闭会话保持; ServerInsert -> 自动生成; UserDefined -> 用户自定义。 + - **PolicySet** (list) - 见 **ULBPolicySet** 模型定义 + - **Protocol** (str) - VServer实例的协议。 枚举值为:HTTP,TCP,UDP,HTTPS。 + - **SSLSet** (list) - 见 **ULBSSLSet** 模型定义 + - **Status** (int) - VServer的运行状态。枚举值: 0 -> rs全部运行正常;1 -> rs全部运行异常;2 -> rs部分运行异常。 + - **VServerId** (str) - VServer实例的Id + - **VServerName** (str) - VServer实例的名字 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeVServerRequestSchema().dumps(d) + resp = self.invoke("DescribeVServer", d, **kwargs) + return apis.DescribeVServerResponseSchema().loads(resp) + + def release_backend(self, req=None, **kwargs): + """ ReleaseBackend - 从VServer释放后端资源实例 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **BackendId** (str) - (Required) 后端资源实例的ID(ULB后端ID,非资源自身ID) + - **ULBId** (str) - (Required) 负载均衡实例的ID + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.ReleaseBackendRequestSchema().dumps(d) + resp = self.invoke("ReleaseBackend", d, **kwargs) + return apis.ReleaseBackendResponseSchema().loads(resp) + + def unbind_ssl(self, req=None, **kwargs): + """ UnbindSSL - 从VServer解绑SSL证书 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **SSLId** (str) - (Required) SSL证书的Id + - **ULBId** (str) - (Required) 所绑定ULB实例ID + - **VServerId** (str) - (Required) 所绑定VServer实例ID + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.UnbindSSLRequestSchema().dumps(d) + resp = self.invoke("UnbindSSL", d, **kwargs) + return apis.UnbindSSLResponseSchema().loads(resp) + + def update_backend_attribute(self, req=None, **kwargs): + """ UpdateBackendAttribute - 更新ULB后端资源实例(服务节点)属性 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **BackendId** (str) - (Required) 后端资源实例的ID(ULB后端ID,非资源自身ID) + - **ULBId** (str) - (Required) 负载均衡资源ID + - **Enabled** (int) - 后端实例状态开关 + - **Port** (int) - 后端资源服务端口,取值范围[1-65535] + - **Weight** (int) - 所添加的后端RS权重(在加权轮询算法下有效),取值范围[0-100],默认为1 + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.UpdateBackendAttributeRequestSchema().dumps(d) + resp = self.invoke("UpdateBackendAttribute", d, **kwargs) + return apis.UpdateBackendAttributeResponseSchema().loads(resp) + + def update_policy(self, req=None, **kwargs): + """ UpdatePolicy - 更新内容转发规则,包括转发规则后的服务节点 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **BackendId** (list) - (Required) 内容转发策略应用的后端资源实例的ID,来源于 AllocateBackend 返回的 BackendId + - **Match** (str) - (Required) 内容转发匹配字段 + - **PolicyId** (str) - (Required) 转发规则的ID + - **ULBId** (str) - (Required) 需要添加内容转发策略的负载均衡实例ID + - **VServerId** (str) - (Required) 需要添加内容转发策略的VServer实例ID + - **Type** (str) - 内容转发匹配字段的类型 + + **Response** + + - **PolicyId** (str) - 转发规则的ID + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.UpdatePolicyRequestSchema().dumps(d) + resp = self.invoke("UpdatePolicy", d, **kwargs) + return apis.UpdatePolicyResponseSchema().loads(resp) + + def update_ulb_attribute(self, req=None, **kwargs): + """ UpdateULBAttribute - 更新ULB名字业务组备注等属性字段 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **ULBId** (str) - (Required) ULB资源ID + - **Name** (str) - 名字 + - **Remark** (str) - 备注 + - **Tag** (str) - 业务 + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.UpdateULBAttributeRequestSchema().dumps(d) + resp = self.invoke("UpdateULBAttribute", d, **kwargs) + return apis.UpdateULBAttributeResponseSchema().loads(resp) + + def update_vserver_attribute(self, req=None, **kwargs): + """ UpdateVServerAttribute - 更新VServer实例属性 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **ULBId** (str) - (Required) 负载均衡实例ID + - **VServerId** (str) - (Required) VServer实例ID + - **ClientTimeout** (int) - 请求代理的VServer下表示空闲连接的回收时间,单位:秒,取值范围:时(0,86400],默认值为60;报文转发的VServer下表示回话保持的时间,单位:秒,取值范围:[60,900],0 表示禁用连接保持 + - **Domain** (str) - MonitorType 为 Path 时指定健康检查发送请求时HTTP HEADER 里的域名 + - **Method** (str) - VServer负载均衡模式,枚举值:Roundrobin -> 轮询;Source -> 源地址;ConsistentHash -> 一致性哈希;SourcePort -> 源地址(计算端口);ConsistentHashPort -> 一致性哈希(计算端口); WeightRoundrobin -> 加权轮询; Leastconn -> 最小连接数。ConsistentHash,SourcePort,ConsistentHashPort 只在报文转发中使用;Leastconn只在请求代理中使用;Roundrobin、Source和WeightRoundrobin在请求代理和报文转发中使用。默认为:"Roundrobin" + - **MonitorType** (str) - 健康检查的类型,Port:端口,Path:路径 + - **Path** (str) - MonitorType 为 Path 时指定健康检查发送请求时的路径,默认为 / + - **PersistenceInfo** (str) - 根据PersistenceType确定: None或ServerInsert, 此字段无意义; UserDefined, 则此字段传入用户自定义会话保持String. 若无此字段则不做修改 + - **PersistenceType** (str) - VServer会话保持模式,若无此字段则不做修改。枚举值:None:关闭;ServerInsert:自动生成KEY;UserDefined:用户自定义KEY。 + - **Protocol** (str) - VServer协议类型,请求代理只支持修改为 HTTP/HTTPS,报文转发VServer只支持修改为 TCP/UDP + - **VServerName** (str) - VServer实例名称,若无此字段则不做修改 + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.UpdateVServerAttributeRequestSchema().dumps(d) + resp = self.invoke("UpdateVServerAttribute", d, **kwargs) + return apis.UpdateVServerAttributeResponseSchema().loads(resp) diff --git a/ucloud/services/ulb/schemas/__init__.py b/ucloud/services/ulb/schemas/__init__.py index 4c48b5a..40a96af 100644 --- a/ucloud/services/ulb/schemas/__init__.py +++ b/ucloud/services/ulb/schemas/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- diff --git a/ucloud/services/ulb/schemas/apis.py b/ucloud/services/ulb/schemas/apis.py index 5af2a38..6c2e57d 100644 --- a/ucloud/services/ulb/schemas/apis.py +++ b/ucloud/services/ulb/schemas/apis.py @@ -1,606 +1,614 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.typesystem import schema, fields -from ucloud.services.ulb.schemas import models - -""" ULB API Schema -""" -""" -API: AllocateBackend - -添加ULB后端资源实例 -""" - - -class AllocateBackendRequestSchema(schema.RequestSchema): - """ AllocateBackend - 添加ULB后端资源实例 - """ - - fields = { - "Enabled": fields.Int(required=False, dump_to="Enabled"), - "Port": fields.Int(required=False, dump_to="Port"), - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "ResourceId": fields.Str(required=True, dump_to="ResourceId"), - "ResourceType": fields.Str(required=True, dump_to="ResourceType"), - "ULBId": fields.Str(required=True, dump_to="ULBId"), - "VServerId": fields.Str(required=True, dump_to="VServerId"), - "Weight": fields.Int(required=False, dump_to="Weight"), - } - - -class AllocateBackendResponseSchema(schema.ResponseSchema): - """ AllocateBackend - 添加ULB后端资源实例 - """ - - fields = {"BackendId": fields.Str(required=False, load_from="BackendId")} - - -""" -API: AllocateBackendBatch - -批量添加VServer后端节点 -""" - - -class AllocateBackendBatchRequestSchema(schema.RequestSchema): - """ AllocateBackendBatch - 批量添加VServer后端节点 - """ - - fields = { - "ApiVersion": fields.Int(required=False, dump_to="ApiVersion"), - "Backends": fields.List(fields.Str()), - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "ULBId": fields.Str(required=True, dump_to="ULBId"), - "VServerId": fields.Str(required=True, dump_to="VServerId"), - } - - -class AllocateBackendBatchResponseSchema(schema.ResponseSchema): - """ AllocateBackendBatch - 批量添加VServer后端节点 - """ - - fields = { - "BackendSet": fields.List( - models.BackendSetSchema(), required=False, load_from="BackendSet" - ) - } - - -""" -API: BindSSL - -将SSL证书绑定到VServer -""" - - -class BindSSLRequestSchema(schema.RequestSchema): - """ BindSSL - 将SSL证书绑定到VServer - """ - - fields = { - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "SSLId": fields.Str(required=True, dump_to="SSLId"), - "ULBId": fields.Str(required=True, dump_to="ULBId"), - "VServerId": fields.Str(required=True, dump_to="VServerId"), - } - - -class BindSSLResponseSchema(schema.ResponseSchema): - """ BindSSL - 将SSL证书绑定到VServer - """ - - fields = {} - - -""" -API: CreatePolicy - -创建VServer内容转发策略 -""" - - -class CreatePolicyRequestSchema(schema.RequestSchema): - """ CreatePolicy - 创建VServer内容转发策略 - """ - - fields = { - "BackendId": fields.List(fields.Str()), - "Match": fields.Str(required=True, dump_to="Match"), - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Type": fields.Str(required=False, dump_to="Type"), - "ULBId": fields.Str(required=True, dump_to="ULBId"), - "VServerId": fields.Str(required=True, dump_to="VServerId"), - } - - -class CreatePolicyResponseSchema(schema.ResponseSchema): - """ CreatePolicy - 创建VServer内容转发策略 - """ - - fields = {"PolicyId": fields.Str(required=False, load_from="PolicyId")} - - -""" -API: CreateSSL - -创建SSL证书,可以把整个 Pem 证书内容传过来,或者把证书、私钥、CA证书分别传过来 -""" - - -class CreateSSLRequestSchema(schema.RequestSchema): - """ CreateSSL - 创建SSL证书,可以把整个 Pem 证书内容传过来,或者把证书、私钥、CA证书分别传过来 - """ - - fields = { - "CaCert": fields.Str(required=False, dump_to="CaCert"), - "PrivateKey": fields.Str(required=False, dump_to="PrivateKey"), - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "SSLContent": fields.Str(required=False, dump_to="SSLContent"), - "SSLName": fields.Str(required=True, dump_to="SSLName"), - "SSLType": fields.Str(required=False, dump_to="SSLType"), - "UserCert": fields.Str(required=False, dump_to="UserCert"), - } - - -class CreateSSLResponseSchema(schema.ResponseSchema): - """ CreateSSL - 创建SSL证书,可以把整个 Pem 证书内容传过来,或者把证书、私钥、CA证书分别传过来 - """ - - fields = {"SSLId": fields.Str(required=False, load_from="SSLId")} - - -""" -API: CreateULB - -创建负载均衡实例,可以选择内网或者外网 -""" - - -class CreateULBRequestSchema(schema.RequestSchema): - """ CreateULB - 创建负载均衡实例,可以选择内网或者外网 - """ - - fields = { - "BusinessId": fields.Str(required=False, dump_to="BusinessId"), - "ChargeType": fields.Str(required=False, dump_to="ChargeType"), - "IPVersion": fields.Str(required=False, dump_to="IPVersion"), - "InnerMode": fields.Str(required=False, dump_to="InnerMode"), - "ListenType": fields.Str(required=False, dump_to="ListenType"), - "OuterMode": fields.Str(required=False, dump_to="OuterMode"), - "PrivateIp": fields.Str(required=False, dump_to="PrivateIp"), - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Remark": fields.Str(required=False, dump_to="Remark"), - "SubnetId": fields.Str(required=False, dump_to="SubnetId"), - "Tag": fields.Str(required=False, dump_to="Tag"), - "ULBName": fields.Str(required=False, dump_to="ULBName"), - "VPCId": fields.Str(required=False, dump_to="VPCId"), - } - - -class CreateULBResponseSchema(schema.ResponseSchema): - """ CreateULB - 创建负载均衡实例,可以选择内网或者外网 - """ - - fields = {"ULBId": fields.Str(required=False, load_from="ULBId")} - - -""" -API: CreateVServer - -创建VServer实例,定义监听的协议和端口以及负载均衡算法 -""" - - -class CreateVServerRequestSchema(schema.RequestSchema): - """ CreateVServer - 创建VServer实例,定义监听的协议和端口以及负载均衡算法 - """ - - fields = { - "ClientTimeout": fields.Int(required=False, dump_to="ClientTimeout"), - "Domain": fields.Str(required=False, dump_to="Domain"), - "FrontendPort": fields.Int(required=False, dump_to="FrontendPort"), - "ListenType": fields.Str(required=False, dump_to="ListenType"), - "Method": fields.Str(required=False, dump_to="Method"), - "MonitorType": fields.Str(required=False, dump_to="MonitorType"), - "Path": fields.Str(required=False, dump_to="Path"), - "PersistenceInfo": fields.Str(required=False, dump_to="PersistenceInfo"), - "PersistenceType": fields.Str(required=False, dump_to="PersistenceType"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Protocol": fields.Str(required=False, dump_to="Protocol"), - "Region": fields.Str(required=True, dump_to="Region"), - "ULBId": fields.Str(required=True, dump_to="ULBId"), - "VServerName": fields.Str(required=False, dump_to="VServerName"), - } - - -class CreateVServerResponseSchema(schema.ResponseSchema): - """ CreateVServer - 创建VServer实例,定义监听的协议和端口以及负载均衡算法 - """ - - fields = {"VServerId": fields.Str(required=False, load_from="VServerId")} - - -""" -API: DeletePolicy - -删除内容转发策略 -""" - - -class DeletePolicyRequestSchema(schema.RequestSchema): - """ DeletePolicy - 删除内容转发策略 - """ - - fields = { - "GroupId": fields.Str(required=False, dump_to="GroupId"), - "PolicyId": fields.Str(required=True, dump_to="PolicyId"), - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "VServerId": fields.Str(required=False, dump_to="VServerId"), - } - - -class DeletePolicyResponseSchema(schema.ResponseSchema): - """ DeletePolicy - 删除内容转发策略 - """ - - fields = {} - - -""" -API: DeleteSSL - -删除SSL证书 -""" - - -class DeleteSSLRequestSchema(schema.RequestSchema): - """ DeleteSSL - 删除SSL证书 - """ - - fields = { - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "SSLId": fields.Str(required=True, dump_to="SSLId"), - } - - -class DeleteSSLResponseSchema(schema.ResponseSchema): - """ DeleteSSL - 删除SSL证书 - """ - - fields = {} - - -""" -API: DeleteULB - -删除负载均衡实例 -""" - - -class DeleteULBRequestSchema(schema.RequestSchema): - """ DeleteULB - 删除负载均衡实例 - """ - - fields = { - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "ReleaseEip": fields.Bool(required=False, dump_to="ReleaseEip"), - "ULBId": fields.Str(required=True, dump_to="ULBId"), - } - - -class DeleteULBResponseSchema(schema.ResponseSchema): - """ DeleteULB - 删除负载均衡实例 - """ - - fields = {} - - -""" -API: DeleteVServer - -删除VServer实例 -""" - - -class DeleteVServerRequestSchema(schema.RequestSchema): - """ DeleteVServer - 删除VServer实例 - """ - - fields = { - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "ULBId": fields.Str(required=True, dump_to="ULBId"), - "VServerId": fields.Str(required=True, dump_to="VServerId"), - } - - -class DeleteVServerResponseSchema(schema.ResponseSchema): - """ DeleteVServer - 删除VServer实例 - """ - - fields = {} - - -""" -API: DescribeSSL - -获取SSL证书信息 -""" - - -class DescribeSSLRequestSchema(schema.RequestSchema): - """ DescribeSSL - 获取SSL证书信息 - """ - - fields = { - "Limit": fields.Int(required=False, dump_to="Limit"), - "Offset": fields.Int(required=False, dump_to="Offset"), - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "SSLId": fields.Str(required=False, dump_to="SSLId"), - } - - -class DescribeSSLResponseSchema(schema.ResponseSchema): - """ DescribeSSL - 获取SSL证书信息 - """ - - fields = { - "DataSet": fields.List( - models.ULBSSLSetSchema(), required=False, load_from="DataSet" - ), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - } - - -""" -API: DescribeULB - -获取ULB详细信息 -""" - - -class DescribeULBRequestSchema(schema.RequestSchema): - """ DescribeULB - 获取ULB详细信息 - """ - - fields = { - "BusinessId": fields.Str(required=False, dump_to="BusinessId"), - "Limit": fields.Int(required=False, dump_to="Limit"), - "Offset": fields.Int(required=False, dump_to="Offset"), - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "SubnetId": fields.Str(required=False, dump_to="SubnetId"), - "ULBId": fields.Str(required=False, dump_to="ULBId"), - "VPCId": fields.Str(required=False, dump_to="VPCId"), - } - - -class DescribeULBResponseSchema(schema.ResponseSchema): - """ DescribeULB - 获取ULB详细信息 - """ - - fields = { - "DataSet": fields.List( - models.ULBSetSchema(), required=False, load_from="DataSet" - ), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - } - - -""" -API: DescribeVServer - -获取ULB下的VServer的详细信息 -""" - - -class DescribeVServerRequestSchema(schema.RequestSchema): - """ DescribeVServer - 获取ULB下的VServer的详细信息 - """ - - fields = { - "Limit": fields.Int(required=False, dump_to="Limit"), - "Offset": fields.Int(required=False, dump_to="Offset"), - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "ULBId": fields.Str(required=True, dump_to="ULBId"), - "VServerId": fields.Str(required=False, dump_to="VServerId"), - } - - -class DescribeVServerResponseSchema(schema.ResponseSchema): - """ DescribeVServer - 获取ULB下的VServer的详细信息 - """ - - fields = { - "DataSet": fields.List( - models.ULBVServerSetSchema(), required=False, load_from="DataSet" - ), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - } - - -""" -API: ReleaseBackend - -从VServer释放后端资源实例 -""" - - -class ReleaseBackendRequestSchema(schema.RequestSchema): - """ ReleaseBackend - 从VServer释放后端资源实例 - """ - - fields = { - "BackendId": fields.Str(required=True, dump_to="BackendId"), - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "ULBId": fields.Str(required=True, dump_to="ULBId"), - } - - -class ReleaseBackendResponseSchema(schema.ResponseSchema): - """ ReleaseBackend - 从VServer释放后端资源实例 - """ - - fields = {} - - -""" -API: UnbindSSL - -从VServer解绑SSL证书 -""" - - -class UnbindSSLRequestSchema(schema.RequestSchema): - """ UnbindSSL - 从VServer解绑SSL证书 - """ - - fields = { - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "SSLId": fields.Str(required=True, dump_to="SSLId"), - "ULBId": fields.Str(required=True, dump_to="ULBId"), - "VServerId": fields.Str(required=True, dump_to="VServerId"), - } - - -class UnbindSSLResponseSchema(schema.ResponseSchema): - """ UnbindSSL - 从VServer解绑SSL证书 - """ - - fields = {} - - -""" -API: UpdateBackendAttribute - -更新ULB后端资源实例(服务节点)属性 -""" - - -class UpdateBackendAttributeRequestSchema(schema.RequestSchema): - """ UpdateBackendAttribute - 更新ULB后端资源实例(服务节点)属性 - """ - - fields = { - "BackendId": fields.Str(required=True, dump_to="BackendId"), - "Enabled": fields.Int(required=False, dump_to="Enabled"), - "Port": fields.Int(required=False, dump_to="Port"), - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "ULBId": fields.Str(required=True, dump_to="ULBId"), - "Weight": fields.Int(required=False, dump_to="Weight"), - } - - -class UpdateBackendAttributeResponseSchema(schema.ResponseSchema): - """ UpdateBackendAttribute - 更新ULB后端资源实例(服务节点)属性 - """ - - fields = {} - - -""" -API: UpdatePolicy - -更新内容转发规则,包括转发规则后的服务节点 -""" - - -class UpdatePolicyRequestSchema(schema.RequestSchema): - """ UpdatePolicy - 更新内容转发规则,包括转发规则后的服务节点 - """ - - fields = { - "BackendId": fields.List(fields.Str()), - "Match": fields.Str(required=True, dump_to="Match"), - "PolicyId": fields.Str(required=True, dump_to="PolicyId"), - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Type": fields.Str(required=False, dump_to="Type"), - "ULBId": fields.Str(required=True, dump_to="ULBId"), - "VServerId": fields.Str(required=True, dump_to="VServerId"), - } - - -class UpdatePolicyResponseSchema(schema.ResponseSchema): - """ UpdatePolicy - 更新内容转发规则,包括转发规则后的服务节点 - """ - - fields = {"PolicyId": fields.Str(required=False, load_from="PolicyId")} - - -""" -API: UpdateULBAttribute - -更新ULB名字业务组备注等属性字段 -""" - - -class UpdateULBAttributeRequestSchema(schema.RequestSchema): - """ UpdateULBAttribute - 更新ULB名字业务组备注等属性字段 - """ - - fields = { - "Name": fields.Str(required=False, dump_to="Name"), - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Remark": fields.Str(required=False, dump_to="Remark"), - "Tag": fields.Str(required=False, dump_to="Tag"), - "ULBId": fields.Str(required=True, dump_to="ULBId"), - } - - -class UpdateULBAttributeResponseSchema(schema.ResponseSchema): - """ UpdateULBAttribute - 更新ULB名字业务组备注等属性字段 - """ - - fields = {} - - -""" -API: UpdateVServerAttribute - -更新VServer实例属性 -""" - - -class UpdateVServerAttributeRequestSchema(schema.RequestSchema): - """ UpdateVServerAttribute - 更新VServer实例属性 - """ - - fields = { - "ClientTimeout": fields.Int(required=False, dump_to="ClientTimeout"), - "Domain": fields.Str(required=False, dump_to="Domain"), - "Method": fields.Str(required=False, dump_to="Method"), - "MonitorType": fields.Str(required=False, dump_to="MonitorType"), - "Path": fields.Str(required=False, dump_to="Path"), - "PersistenceInfo": fields.Str(required=False, dump_to="PersistenceInfo"), - "PersistenceType": fields.Str(required=False, dump_to="PersistenceType"), - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Protocol": fields.Str(required=False, dump_to="Protocol"), - "Region": fields.Str(required=True, dump_to="Region"), - "ULBId": fields.Str(required=True, dump_to="ULBId"), - "VServerId": fields.Str(required=True, dump_to="VServerId"), - "VServerName": fields.Str(required=False, dump_to="VServerName"), - } - - -class UpdateVServerAttributeResponseSchema(schema.ResponseSchema): - """ UpdateVServerAttribute - 更新VServer实例属性 - """ - - fields = {} +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.typesystem import schema, fields +from ucloud.services.ulb.schemas import models + +""" ULB API Schema +""" +""" +API: AllocateBackend + +添加ULB后端资源实例 +""" + + +class AllocateBackendRequestSchema(schema.RequestSchema): + """ AllocateBackend - 添加ULB后端资源实例 + """ + + fields = { + "Enabled": fields.Int(required=False, dump_to="Enabled"), + "Port": fields.Int(required=False, dump_to="Port"), + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "ResourceId": fields.Str(required=True, dump_to="ResourceId"), + "ResourceType": fields.Str(required=True, dump_to="ResourceType"), + "ULBId": fields.Str(required=True, dump_to="ULBId"), + "VServerId": fields.Str(required=True, dump_to="VServerId"), + "Weight": fields.Int(required=False, dump_to="Weight"), + } + + +class AllocateBackendResponseSchema(schema.ResponseSchema): + """ AllocateBackend - 添加ULB后端资源实例 + """ + + fields = {"BackendId": fields.Str(required=False, load_from="BackendId")} + + +""" +API: AllocateBackendBatch + +批量添加VServer后端节点 +""" + + +class AllocateBackendBatchRequestSchema(schema.RequestSchema): + """ AllocateBackendBatch - 批量添加VServer后端节点 + """ + + fields = { + "ApiVersion": fields.Int(required=False, dump_to="ApiVersion"), + "Backends": fields.List(fields.Str()), + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "ULBId": fields.Str(required=True, dump_to="ULBId"), + "VServerId": fields.Str(required=True, dump_to="VServerId"), + } + + +class AllocateBackendBatchResponseSchema(schema.ResponseSchema): + """ AllocateBackendBatch - 批量添加VServer后端节点 + """ + + fields = { + "BackendSet": fields.List( + models.BackendSetSchema(), required=False, load_from="BackendSet" + ) + } + + +""" +API: BindSSL + +将SSL证书绑定到VServer +""" + + +class BindSSLRequestSchema(schema.RequestSchema): + """ BindSSL - 将SSL证书绑定到VServer + """ + + fields = { + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "SSLId": fields.Str(required=True, dump_to="SSLId"), + "ULBId": fields.Str(required=True, dump_to="ULBId"), + "VServerId": fields.Str(required=True, dump_to="VServerId"), + } + + +class BindSSLResponseSchema(schema.ResponseSchema): + """ BindSSL - 将SSL证书绑定到VServer + """ + + fields = {} + + +""" +API: CreatePolicy + +创建VServer内容转发策略 +""" + + +class CreatePolicyRequestSchema(schema.RequestSchema): + """ CreatePolicy - 创建VServer内容转发策略 + """ + + fields = { + "BackendId": fields.List(fields.Str()), + "Match": fields.Str(required=True, dump_to="Match"), + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Type": fields.Str(required=False, dump_to="Type"), + "ULBId": fields.Str(required=True, dump_to="ULBId"), + "VServerId": fields.Str(required=True, dump_to="VServerId"), + } + + +class CreatePolicyResponseSchema(schema.ResponseSchema): + """ CreatePolicy - 创建VServer内容转发策略 + """ + + fields = {"PolicyId": fields.Str(required=False, load_from="PolicyId")} + + +""" +API: CreateSSL + +创建SSL证书,可以把整个 Pem 证书内容传过来,或者把证书、私钥、CA证书分别传过来 +""" + + +class CreateSSLRequestSchema(schema.RequestSchema): + """ CreateSSL - 创建SSL证书,可以把整个 Pem 证书内容传过来,或者把证书、私钥、CA证书分别传过来 + """ + + fields = { + "CaCert": fields.Str(required=False, dump_to="CaCert"), + "PrivateKey": fields.Str(required=False, dump_to="PrivateKey"), + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "SSLContent": fields.Str(required=False, dump_to="SSLContent"), + "SSLName": fields.Str(required=True, dump_to="SSLName"), + "SSLType": fields.Str(required=False, dump_to="SSLType"), + "UserCert": fields.Str(required=False, dump_to="UserCert"), + } + + +class CreateSSLResponseSchema(schema.ResponseSchema): + """ CreateSSL - 创建SSL证书,可以把整个 Pem 证书内容传过来,或者把证书、私钥、CA证书分别传过来 + """ + + fields = {"SSLId": fields.Str(required=False, load_from="SSLId")} + + +""" +API: CreateULB + +创建负载均衡实例,可以选择内网或者外网 +""" + + +class CreateULBRequestSchema(schema.RequestSchema): + """ CreateULB - 创建负载均衡实例,可以选择内网或者外网 + """ + + fields = { + "BusinessId": fields.Str(required=False, dump_to="BusinessId"), + "ChargeType": fields.Str(required=False, dump_to="ChargeType"), + "IPVersion": fields.Str(required=False, dump_to="IPVersion"), + "InnerMode": fields.Str(required=False, dump_to="InnerMode"), + "ListenType": fields.Str(required=False, dump_to="ListenType"), + "OuterMode": fields.Str(required=False, dump_to="OuterMode"), + "PrivateIp": fields.Str(required=False, dump_to="PrivateIp"), + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Remark": fields.Str(required=False, dump_to="Remark"), + "SubnetId": fields.Str(required=False, dump_to="SubnetId"), + "Tag": fields.Str(required=False, dump_to="Tag"), + "ULBName": fields.Str(required=False, dump_to="ULBName"), + "VPCId": fields.Str(required=False, dump_to="VPCId"), + } + + +class CreateULBResponseSchema(schema.ResponseSchema): + """ CreateULB - 创建负载均衡实例,可以选择内网或者外网 + """ + + fields = {"ULBId": fields.Str(required=False, load_from="ULBId")} + + +""" +API: CreateVServer + +创建VServer实例,定义监听的协议和端口以及负载均衡算法 +""" + + +class CreateVServerRequestSchema(schema.RequestSchema): + """ CreateVServer - 创建VServer实例,定义监听的协议和端口以及负载均衡算法 + """ + + fields = { + "ClientTimeout": fields.Int(required=False, dump_to="ClientTimeout"), + "Domain": fields.Str(required=False, dump_to="Domain"), + "FrontendPort": fields.Int(required=False, dump_to="FrontendPort"), + "ListenType": fields.Str(required=False, dump_to="ListenType"), + "Method": fields.Str(required=False, dump_to="Method"), + "MonitorType": fields.Str(required=False, dump_to="MonitorType"), + "Path": fields.Str(required=False, dump_to="Path"), + "PersistenceInfo": fields.Str( + required=False, dump_to="PersistenceInfo" + ), + "PersistenceType": fields.Str( + required=False, dump_to="PersistenceType" + ), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Protocol": fields.Str(required=False, dump_to="Protocol"), + "Region": fields.Str(required=True, dump_to="Region"), + "ULBId": fields.Str(required=True, dump_to="ULBId"), + "VServerName": fields.Str(required=False, dump_to="VServerName"), + } + + +class CreateVServerResponseSchema(schema.ResponseSchema): + """ CreateVServer - 创建VServer实例,定义监听的协议和端口以及负载均衡算法 + """ + + fields = {"VServerId": fields.Str(required=False, load_from="VServerId")} + + +""" +API: DeletePolicy + +删除内容转发策略 +""" + + +class DeletePolicyRequestSchema(schema.RequestSchema): + """ DeletePolicy - 删除内容转发策略 + """ + + fields = { + "GroupId": fields.Str(required=False, dump_to="GroupId"), + "PolicyId": fields.Str(required=True, dump_to="PolicyId"), + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "VServerId": fields.Str(required=False, dump_to="VServerId"), + } + + +class DeletePolicyResponseSchema(schema.ResponseSchema): + """ DeletePolicy - 删除内容转发策略 + """ + + fields = {} + + +""" +API: DeleteSSL + +删除SSL证书 +""" + + +class DeleteSSLRequestSchema(schema.RequestSchema): + """ DeleteSSL - 删除SSL证书 + """ + + fields = { + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "SSLId": fields.Str(required=True, dump_to="SSLId"), + } + + +class DeleteSSLResponseSchema(schema.ResponseSchema): + """ DeleteSSL - 删除SSL证书 + """ + + fields = {} + + +""" +API: DeleteULB + +删除负载均衡实例 +""" + + +class DeleteULBRequestSchema(schema.RequestSchema): + """ DeleteULB - 删除负载均衡实例 + """ + + fields = { + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "ReleaseEip": fields.Bool(required=False, dump_to="ReleaseEip"), + "ULBId": fields.Str(required=True, dump_to="ULBId"), + } + + +class DeleteULBResponseSchema(schema.ResponseSchema): + """ DeleteULB - 删除负载均衡实例 + """ + + fields = {} + + +""" +API: DeleteVServer + +删除VServer实例 +""" + + +class DeleteVServerRequestSchema(schema.RequestSchema): + """ DeleteVServer - 删除VServer实例 + """ + + fields = { + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "ULBId": fields.Str(required=True, dump_to="ULBId"), + "VServerId": fields.Str(required=True, dump_to="VServerId"), + } + + +class DeleteVServerResponseSchema(schema.ResponseSchema): + """ DeleteVServer - 删除VServer实例 + """ + + fields = {} + + +""" +API: DescribeSSL + +获取SSL证书信息 +""" + + +class DescribeSSLRequestSchema(schema.RequestSchema): + """ DescribeSSL - 获取SSL证书信息 + """ + + fields = { + "Limit": fields.Int(required=False, dump_to="Limit"), + "Offset": fields.Int(required=False, dump_to="Offset"), + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "SSLId": fields.Str(required=False, dump_to="SSLId"), + } + + +class DescribeSSLResponseSchema(schema.ResponseSchema): + """ DescribeSSL - 获取SSL证书信息 + """ + + fields = { + "DataSet": fields.List( + models.ULBSSLSetSchema(), required=False, load_from="DataSet" + ), + "TotalCount": fields.Int(required=False, load_from="TotalCount"), + } + + +""" +API: DescribeULB + +获取ULB详细信息 +""" + + +class DescribeULBRequestSchema(schema.RequestSchema): + """ DescribeULB - 获取ULB详细信息 + """ + + fields = { + "BusinessId": fields.Str(required=False, dump_to="BusinessId"), + "Limit": fields.Int(required=False, dump_to="Limit"), + "Offset": fields.Int(required=False, dump_to="Offset"), + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "SubnetId": fields.Str(required=False, dump_to="SubnetId"), + "ULBId": fields.Str(required=False, dump_to="ULBId"), + "VPCId": fields.Str(required=False, dump_to="VPCId"), + } + + +class DescribeULBResponseSchema(schema.ResponseSchema): + """ DescribeULB - 获取ULB详细信息 + """ + + fields = { + "DataSet": fields.List( + models.ULBSetSchema(), required=False, load_from="DataSet" + ), + "TotalCount": fields.Int(required=False, load_from="TotalCount"), + } + + +""" +API: DescribeVServer + +获取ULB下的VServer的详细信息 +""" + + +class DescribeVServerRequestSchema(schema.RequestSchema): + """ DescribeVServer - 获取ULB下的VServer的详细信息 + """ + + fields = { + "Limit": fields.Int(required=False, dump_to="Limit"), + "Offset": fields.Int(required=False, dump_to="Offset"), + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "ULBId": fields.Str(required=True, dump_to="ULBId"), + "VServerId": fields.Str(required=False, dump_to="VServerId"), + } + + +class DescribeVServerResponseSchema(schema.ResponseSchema): + """ DescribeVServer - 获取ULB下的VServer的详细信息 + """ + + fields = { + "DataSet": fields.List( + models.ULBVServerSetSchema(), required=False, load_from="DataSet" + ), + "TotalCount": fields.Int(required=False, load_from="TotalCount"), + } + + +""" +API: ReleaseBackend + +从VServer释放后端资源实例 +""" + + +class ReleaseBackendRequestSchema(schema.RequestSchema): + """ ReleaseBackend - 从VServer释放后端资源实例 + """ + + fields = { + "BackendId": fields.Str(required=True, dump_to="BackendId"), + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "ULBId": fields.Str(required=True, dump_to="ULBId"), + } + + +class ReleaseBackendResponseSchema(schema.ResponseSchema): + """ ReleaseBackend - 从VServer释放后端资源实例 + """ + + fields = {} + + +""" +API: UnbindSSL + +从VServer解绑SSL证书 +""" + + +class UnbindSSLRequestSchema(schema.RequestSchema): + """ UnbindSSL - 从VServer解绑SSL证书 + """ + + fields = { + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "SSLId": fields.Str(required=True, dump_to="SSLId"), + "ULBId": fields.Str(required=True, dump_to="ULBId"), + "VServerId": fields.Str(required=True, dump_to="VServerId"), + } + + +class UnbindSSLResponseSchema(schema.ResponseSchema): + """ UnbindSSL - 从VServer解绑SSL证书 + """ + + fields = {} + + +""" +API: UpdateBackendAttribute + +更新ULB后端资源实例(服务节点)属性 +""" + + +class UpdateBackendAttributeRequestSchema(schema.RequestSchema): + """ UpdateBackendAttribute - 更新ULB后端资源实例(服务节点)属性 + """ + + fields = { + "BackendId": fields.Str(required=True, dump_to="BackendId"), + "Enabled": fields.Int(required=False, dump_to="Enabled"), + "Port": fields.Int(required=False, dump_to="Port"), + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "ULBId": fields.Str(required=True, dump_to="ULBId"), + "Weight": fields.Int(required=False, dump_to="Weight"), + } + + +class UpdateBackendAttributeResponseSchema(schema.ResponseSchema): + """ UpdateBackendAttribute - 更新ULB后端资源实例(服务节点)属性 + """ + + fields = {} + + +""" +API: UpdatePolicy + +更新内容转发规则,包括转发规则后的服务节点 +""" + + +class UpdatePolicyRequestSchema(schema.RequestSchema): + """ UpdatePolicy - 更新内容转发规则,包括转发规则后的服务节点 + """ + + fields = { + "BackendId": fields.List(fields.Str()), + "Match": fields.Str(required=True, dump_to="Match"), + "PolicyId": fields.Str(required=True, dump_to="PolicyId"), + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Type": fields.Str(required=False, dump_to="Type"), + "ULBId": fields.Str(required=True, dump_to="ULBId"), + "VServerId": fields.Str(required=True, dump_to="VServerId"), + } + + +class UpdatePolicyResponseSchema(schema.ResponseSchema): + """ UpdatePolicy - 更新内容转发规则,包括转发规则后的服务节点 + """ + + fields = {"PolicyId": fields.Str(required=False, load_from="PolicyId")} + + +""" +API: UpdateULBAttribute + +更新ULB名字业务组备注等属性字段 +""" + + +class UpdateULBAttributeRequestSchema(schema.RequestSchema): + """ UpdateULBAttribute - 更新ULB名字业务组备注等属性字段 + """ + + fields = { + "Name": fields.Str(required=False, dump_to="Name"), + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Remark": fields.Str(required=False, dump_to="Remark"), + "Tag": fields.Str(required=False, dump_to="Tag"), + "ULBId": fields.Str(required=True, dump_to="ULBId"), + } + + +class UpdateULBAttributeResponseSchema(schema.ResponseSchema): + """ UpdateULBAttribute - 更新ULB名字业务组备注等属性字段 + """ + + fields = {} + + +""" +API: UpdateVServerAttribute + +更新VServer实例属性 +""" + + +class UpdateVServerAttributeRequestSchema(schema.RequestSchema): + """ UpdateVServerAttribute - 更新VServer实例属性 + """ + + fields = { + "ClientTimeout": fields.Int(required=False, dump_to="ClientTimeout"), + "Domain": fields.Str(required=False, dump_to="Domain"), + "Method": fields.Str(required=False, dump_to="Method"), + "MonitorType": fields.Str(required=False, dump_to="MonitorType"), + "Path": fields.Str(required=False, dump_to="Path"), + "PersistenceInfo": fields.Str( + required=False, dump_to="PersistenceInfo" + ), + "PersistenceType": fields.Str( + required=False, dump_to="PersistenceType" + ), + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Protocol": fields.Str(required=False, dump_to="Protocol"), + "Region": fields.Str(required=True, dump_to="Region"), + "ULBId": fields.Str(required=True, dump_to="ULBId"), + "VServerId": fields.Str(required=True, dump_to="VServerId"), + "VServerName": fields.Str(required=False, dump_to="VServerName"), + } + + +class UpdateVServerAttributeResponseSchema(schema.ResponseSchema): + """ UpdateVServerAttribute - 更新VServer实例属性 + """ + + fields = {} diff --git a/ucloud/services/ulb/schemas/models.py b/ucloud/services/ulb/schemas/models.py index 79f5c9d..7a07165 100644 --- a/ucloud/services/ulb/schemas/models.py +++ b/ucloud/services/ulb/schemas/models.py @@ -1,137 +1,147 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.typesystem import schema, fields - - -class BackendSetSchema(schema.ResponseSchema): - """ BackendSet - ulb添加rs时返回的信息 - """ - - fields = { - "BackendId": fields.Str(required=True, load_from="BackendId"), - "ResourceId": fields.Str(required=True, load_from="ResourceId"), - } - - -class ULBSSLSetSchema(schema.ResponseSchema): - """ ULBSSLSet - DescribeULB - """ - - fields = { - "HashValue": fields.Str(required=False, load_from="HashValue"), - "SSLId": fields.Str(required=False, load_from="SSLId"), - "SSLName": fields.Str(required=False, load_from="SSLName"), - } - - -class PolicyBackendSetSchema(schema.ResponseSchema): - """ PolicyBackendSet - 内容转发下rs详细信息 - """ - - fields = { - "BackendId": fields.Str(required=False, load_from="BackendId"), - "ObjectId": fields.Str(required=False, load_from="ObjectId"), - "Port": fields.Int(required=False, load_from="Port"), - "PrivateIP": fields.Str(required=False, load_from="PrivateIP"), - "ResourceName": fields.Str(required=False, load_from="ResourceName"), - } - - -class ULBBackendSetSchema(schema.ResponseSchema): - """ ULBBackendSet - DescribeULB - """ - - fields = { - "BackendId": fields.Str(required=False, load_from="BackendId"), - "Enabled": fields.Int(required=False, load_from="Enabled"), - "Port": fields.Int(required=False, load_from="Port"), - "PrivateIP": fields.Str(required=False, load_from="PrivateIP"), - "ResourceId": fields.Str(required=False, load_from="ResourceId"), - "ResourceName": fields.Str(required=False, load_from="ResourceName"), - "ResourceType": fields.Str(required=False, load_from="ResourceType"), - "Status": fields.Int(required=False, load_from="Status"), - "SubResourceId": fields.Str(required=False, load_from="SubResourceId"), - "SubResourceName": fields.Str(required=False, load_from="SubResourceName"), - "SubResourceType": fields.Str(required=False, load_from="SubResourceType"), - "SubnetId": fields.Str(required=False, load_from="SubnetId"), - "Weight": fields.Int(required=False, load_from="Weight"), - } - - -class ULBPolicySetSchema(schema.ResponseSchema): - """ ULBPolicySet - 内容转发详细列表 - """ - - fields = { - "BackendSet": fields.List(PolicyBackendSetSchema()), - "Match": fields.Str(required=False, load_from="Match"), - "PolicyId": fields.Str(required=False, load_from="PolicyId"), - "PolicyPriority": fields.Int(required=False, load_from="PolicyPriority"), - "PolicyType": fields.Str(required=False, load_from="PolicyType"), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - "Type": fields.Str(required=False, load_from="Type"), - "VServerId": fields.Str(required=False, load_from="VServerId"), - } - - -class ULBVServerSetSchema(schema.ResponseSchema): - """ ULBVServerSet - DescribeULB - """ - - fields = { - "BackendSet": fields.List(ULBBackendSetSchema()), - "ClientTimeout": fields.Int(required=False, load_from="ClientTimeout"), - "Domain": fields.Str(required=True, load_from="Domain"), - "FrontendPort": fields.Int(required=False, load_from="FrontendPort"), - "ListenType": fields.Str(required=False, load_from="ListenType"), - "Method": fields.Str(required=False, load_from="Method"), - "MonitorType": fields.Str(required=True, load_from="MonitorType"), - "Path": fields.Str(required=True, load_from="Path"), - "PersistenceInfo": fields.Str(required=False, load_from="PersistenceInfo"), - "PersistenceType": fields.Str(required=False, load_from="PersistenceType"), - "PolicySet": fields.List(ULBPolicySetSchema()), - "Protocol": fields.Str(required=False, load_from="Protocol"), - "SSLSet": fields.List(ULBSSLSetSchema()), - "Status": fields.Int(required=False, load_from="Status"), - "VServerId": fields.Str(required=False, load_from="VServerId"), - "VServerName": fields.Str(required=False, load_from="VServerName"), - } - - -class ULBIPSetSchema(schema.ResponseSchema): - """ ULBIPSet - DescribeULB - """ - - fields = { - "Bandwidth": fields.Int(required=False, load_from="Bandwidth"), - "BandwidthType": fields.Int(required=False, load_from="BandwidthType"), - "EIP": fields.Str(required=False, load_from="EIP"), - "EIPId": fields.Str(required=False, load_from="EIPId"), - "OperatorName": fields.Str(required=False, load_from="OperatorName"), - } - - -class ULBSetSchema(schema.ResponseSchema): - """ ULBSet - DescribeULB - """ - - fields = { - "Bandwidth": fields.Int(required=False, load_from="Bandwidth"), - "BandwidthType": fields.Int(required=False, load_from="BandwidthType"), - "BusinessId": fields.Str(required=False, load_from="BusinessId"), - "CreateTime": fields.Int(required=False, load_from="CreateTime"), - "ExpireTime": fields.Int(required=False, load_from="ExpireTime"), - "IPSet": fields.List(ULBIPSetSchema()), - "Name": fields.Str(required=False, load_from="Name"), - "PrivateIP": fields.Str(required=False, load_from="PrivateIP"), - "Remark": fields.Str(required=False, load_from="Remark"), - "Resource": fields.List(fields.Str()), - "SubnetId": fields.Str(required=False, load_from="SubnetId"), - "Tag": fields.Str(required=False, load_from="Tag"), - "ULBId": fields.Str(required=False, load_from="ULBId"), - "ULBName": fields.Str(required=False, load_from="ULBName"), - "ULBType": fields.Str(required=False, load_from="ULBType"), - "VPCId": fields.Str(required=False, load_from="VPCId"), - "VServerSet": fields.List(ULBVServerSetSchema()), - } +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.typesystem import schema, fields + + +class BackendSetSchema(schema.ResponseSchema): + """ BackendSet - ulb添加rs时返回的信息 + """ + + fields = { + "BackendId": fields.Str(required=True, load_from="BackendId"), + "ResourceId": fields.Str(required=True, load_from="ResourceId"), + } + + +class ULBSSLSetSchema(schema.ResponseSchema): + """ ULBSSLSet - DescribeULB + """ + + fields = { + "HashValue": fields.Str(required=False, load_from="HashValue"), + "SSLId": fields.Str(required=False, load_from="SSLId"), + "SSLName": fields.Str(required=False, load_from="SSLName"), + } + + +class PolicyBackendSetSchema(schema.ResponseSchema): + """ PolicyBackendSet - 内容转发下rs详细信息 + """ + + fields = { + "BackendId": fields.Str(required=False, load_from="BackendId"), + "ObjectId": fields.Str(required=False, load_from="ObjectId"), + "Port": fields.Int(required=False, load_from="Port"), + "PrivateIP": fields.Str(required=False, load_from="PrivateIP"), + "ResourceName": fields.Str(required=False, load_from="ResourceName"), + } + + +class ULBBackendSetSchema(schema.ResponseSchema): + """ ULBBackendSet - DescribeULB + """ + + fields = { + "BackendId": fields.Str(required=False, load_from="BackendId"), + "Enabled": fields.Int(required=False, load_from="Enabled"), + "Port": fields.Int(required=False, load_from="Port"), + "PrivateIP": fields.Str(required=False, load_from="PrivateIP"), + "ResourceId": fields.Str(required=False, load_from="ResourceId"), + "ResourceName": fields.Str(required=False, load_from="ResourceName"), + "ResourceType": fields.Str(required=False, load_from="ResourceType"), + "Status": fields.Int(required=False, load_from="Status"), + "SubResourceId": fields.Str(required=False, load_from="SubResourceId"), + "SubResourceName": fields.Str( + required=False, load_from="SubResourceName" + ), + "SubResourceType": fields.Str( + required=False, load_from="SubResourceType" + ), + "SubnetId": fields.Str(required=False, load_from="SubnetId"), + "Weight": fields.Int(required=False, load_from="Weight"), + } + + +class ULBPolicySetSchema(schema.ResponseSchema): + """ ULBPolicySet - 内容转发详细列表 + """ + + fields = { + "BackendSet": fields.List(PolicyBackendSetSchema()), + "Match": fields.Str(required=False, load_from="Match"), + "PolicyId": fields.Str(required=False, load_from="PolicyId"), + "PolicyPriority": fields.Int( + required=False, load_from="PolicyPriority" + ), + "PolicyType": fields.Str(required=False, load_from="PolicyType"), + "TotalCount": fields.Int(required=False, load_from="TotalCount"), + "Type": fields.Str(required=False, load_from="Type"), + "VServerId": fields.Str(required=False, load_from="VServerId"), + } + + +class ULBVServerSetSchema(schema.ResponseSchema): + """ ULBVServerSet - DescribeULB + """ + + fields = { + "BackendSet": fields.List(ULBBackendSetSchema()), + "ClientTimeout": fields.Int(required=False, load_from="ClientTimeout"), + "Domain": fields.Str(required=True, load_from="Domain"), + "FrontendPort": fields.Int(required=False, load_from="FrontendPort"), + "ListenType": fields.Str(required=False, load_from="ListenType"), + "Method": fields.Str(required=False, load_from="Method"), + "MonitorType": fields.Str(required=True, load_from="MonitorType"), + "Path": fields.Str(required=True, load_from="Path"), + "PersistenceInfo": fields.Str( + required=False, load_from="PersistenceInfo" + ), + "PersistenceType": fields.Str( + required=False, load_from="PersistenceType" + ), + "PolicySet": fields.List(ULBPolicySetSchema()), + "Protocol": fields.Str(required=False, load_from="Protocol"), + "SSLSet": fields.List(ULBSSLSetSchema()), + "Status": fields.Int(required=False, load_from="Status"), + "VServerId": fields.Str(required=False, load_from="VServerId"), + "VServerName": fields.Str(required=False, load_from="VServerName"), + } + + +class ULBIPSetSchema(schema.ResponseSchema): + """ ULBIPSet - DescribeULB + """ + + fields = { + "Bandwidth": fields.Int(required=False, load_from="Bandwidth"), + "BandwidthType": fields.Int(required=False, load_from="BandwidthType"), + "EIP": fields.Str(required=False, load_from="EIP"), + "EIPId": fields.Str(required=False, load_from="EIPId"), + "OperatorName": fields.Str(required=False, load_from="OperatorName"), + } + + +class ULBSetSchema(schema.ResponseSchema): + """ ULBSet - DescribeULB + """ + + fields = { + "Bandwidth": fields.Int(required=False, load_from="Bandwidth"), + "BandwidthType": fields.Int(required=False, load_from="BandwidthType"), + "BusinessId": fields.Str(required=False, load_from="BusinessId"), + "CreateTime": fields.Int(required=False, load_from="CreateTime"), + "ExpireTime": fields.Int(required=False, load_from="ExpireTime"), + "IPSet": fields.List(ULBIPSetSchema()), + "Name": fields.Str(required=False, load_from="Name"), + "PrivateIP": fields.Str(required=False, load_from="PrivateIP"), + "Remark": fields.Str(required=False, load_from="Remark"), + "Resource": fields.List(fields.Str()), + "SubnetId": fields.Str(required=False, load_from="SubnetId"), + "Tag": fields.Str(required=False, load_from="Tag"), + "ULBId": fields.Str(required=False, load_from="ULBId"), + "ULBName": fields.Str(required=False, load_from="ULBName"), + "ULBType": fields.Str(required=False, load_from="ULBType"), + "VPCId": fields.Str(required=False, load_from="VPCId"), + "VServerSet": fields.List(ULBVServerSetSchema()), + } diff --git a/ucloud/services/umem/__init__.py b/ucloud/services/umem/__init__.py index 4c48b5a..40a96af 100644 --- a/ucloud/services/umem/__init__.py +++ b/ucloud/services/umem/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- diff --git a/ucloud/services/umem/client.py b/ucloud/services/umem/client.py index 2754b17..5f824ba 100644 --- a/ucloud/services/umem/client.py +++ b/ucloud/services/umem/client.py @@ -1,700 +1,730 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.client import Client -from ucloud.services.umem.schemas import apis - - -class UMemClient(Client): - def __init__(self, config, transport=None, middleware=None, logger=None): - super(UMemClient, self).__init__(config, transport, middleware, logger) - - def create_umem_space(self, req=None, **kwargs): - """ CreateUMemSpace - 创建UMem内存空间 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Name** (str) - (Required) 空间名称,长度(6<=size<=63) - - **Size** (int) - (Required) 内存大小, 单位:GB, 范围[1~1024] - - **ChargeType** (str) - Year , Month, Dynamic, Trial 默认: Month - - **CouponId** (str) - 使用的代金券id - - **Password** (str) - URedis密码。请遵照 `字段规范 `_ 设定密码。密码需使用base64进行编码,举例如下:# echo -n Password1 | base64UGFzc3dvcmQx。 - - **Protocol** (str) - 协议:memcache, redis (默认redis).注意:redis无single类型 - - **Quantity** (int) - 购买时长 默认: 1 - - **SubnetId** (str) - - - **Tag** (str) - - - **Type** (str) - 空间类型:single(无热备),double(热备)(默认: double) - - **VPCId** (str) - - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **SpaceId** (str) - 创建内存空间ID列表 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.CreateUMemSpaceRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("CreateUMemSpace", d, **kwargs) - return apis.CreateUMemSpaceResponseSchema().loads(resp) - - def create_umem_cache_group(self, req=None, **kwargs): - """ CreateUMemcacheGroup - 创建单机Memcache - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Name** (str) - (Required) 请求创建组的名称 范围[6-60] - - **ChargeType** (str) - 计费模式,Year , Month, Dynamic 默认: Month - - **ConfigId** (str) - 配置ID,目前仅支持默认配置id 默认配置id:"9a891891-c245-4b66-bce8-67e59430d67c" - - **CouponId** (str) - 代金券ID - - **Protocol** (str) - - - **Quantity** (int) - 购买时长,默认为1 - - **Size** (int) - 每个节点的内存大小,单位GB,默认1GB 目前仅支持1/2/4/8/16/32这几档 - - **SubnetId** (str) - - - **Tag** (str) - 业务组 默认:Default - - **VPCId** (str) - - - **Version** (str) - Memcache版本信息,默认为1.4.31 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **GroupId** (str) - 创建的组ID - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.CreateUMemcacheGroupRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("CreateUMemcacheGroup", d, **kwargs) - return apis.CreateUMemcacheGroupResponseSchema().loads(resp) - - def create_uredis_group(self, req=None, **kwargs): - """ CreateURedisGroup - 创建主备redis - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **HighAvailability** (str) - (Required) 是否开启高可用,enable或disable - - **Name** (str) - (Required) 请求创建组的名称 (范围[6-63],只能包含英文、数字以及符号-和_) - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **AutoBackup** (str) - 是否自动备份,enable或disable,默认disable - - **BackupId** (str) - 有此项代表从备份中创建,无代表正常创建 - - **BackupTime** (int) - 自动备份开始时间,范围[0-23],默认3点 - - **ChargeType** (str) - 计费模式,Year , Month, Dynamic 默认: Month - - **ConfigId** (str) - 配置ID,目前支持 3.0版本配置ID:"03f58ca9-b64d-4bdd-abc7-c6b9a46fd801",3.2版本配置ID:"3e45ac48-f8a2-a9q2-261d-l342dab130gf", 4.0版本配置ID:"6c9298a3-9d7f-428c-b1d0-e87ab3b8a1ea",默认版本3.0,从备份创建为必传项 - - **CouponId** (str) - 代金券ID - - **MasterGroupId** (str) - Master Redis Group的ID,创建只读Slave时,必须填写 - - **Password** (str) - 初始化密码,需要 base64 编码 - - **Quantity** (int) - 购买时长,默认为1 - - **Size** (int) - 每个节点的内存大小,单位GB,默认1GB,目前仅支持1/2/4/8/16/32,六种 - - **SlaveZone** (str) - 跨机房URedis,slave所在可用区(必须和Zone在同一Region,且不可相同) - - **SubnetId** (str) - - - **Tag** (str) - 业务组名称 - - **VPCId** (str) - - - **Version** (str) - Redis版本信息(详见DescribeURedisVersion返回结果),默认版本3.0 - - **Response** - - - **GroupId** (str) - 创建的组ID - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.CreateURedisGroupRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("CreateURedisGroup", d, **kwargs) - return apis.CreateURedisGroupResponseSchema().loads(resp) - - def delete_umem_space(self, req=None, **kwargs): - """ DeleteUMemSpace - 删除UMem内存空间 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **SpaceId** (str) - (Required) UMem内存空间ID - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DeleteUMemSpaceRequestSchema().dumps(d) - resp = self.invoke("DeleteUMemSpace", d, **kwargs) - return apis.DeleteUMemSpaceResponseSchema().loads(resp) - - def delete_umem_cache_group(self, req=None, **kwargs): - """ DeleteUMemcacheGroup - 删除单机Memcache - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **GroupId** (str) - (Required) 组ID - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DeleteUMemcacheGroupRequestSchema().dumps(d) - resp = self.invoke("DeleteUMemcacheGroup", d, **kwargs) - return apis.DeleteUMemcacheGroupResponseSchema().loads(resp) - - def delete_uredis_group(self, req=None, **kwargs): - """ DeleteURedisGroup - 删除主备redis - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **GroupId** (str) - (Required) 组ID - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DeleteURedisGroupRequestSchema().dumps(d) - resp = self.invoke("DeleteURedisGroup", d, **kwargs) - return apis.DeleteURedisGroupResponseSchema().loads(resp) - - def describe_umem_price(self, req=None, **kwargs): - """ DescribeUMemPrice - 获取UMem实例价格信息 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Size** (int) - (Required) 购买umem大小,单位:GB,范围[1~1024] - - **Type** (str) - (Required) 空间类型:single(无热备),double(热备)(默认: double) - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **ChargeType** (str) - Year, Month, Dynamic,Trial 如果不指定,则一次性获取三种计费 - - **Quantity** (int) - 购买UMem的时长,默认值为1 - - **RegionFlag** (bool) - - - **Response** - - - **DataSet** (list) - 见 **UMemPriceSet** 模型定义 - - **Response Model** - - **UMemPriceSet** - - - **ChargeType** (str) - Year, Month, Dynamic,Trial - - **Price** (float) - 价格,单位: 元,保留小数点后两位有效数字 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeUMemPriceRequestSchema().dumps(d) - resp = self.invoke("DescribeUMemPrice", d, **kwargs) - return apis.DescribeUMemPriceResponseSchema().loads(resp) - - def describe_umem_space(self, req=None, **kwargs): - """ DescribeUMemSpace - 获取UMem内存空间列表 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Limit** (int) - 返回数据长度, 默认为20 - - **Offset** (int) - 数据偏移量, 默认为0 - - **SpaceId** (str) - 内存空间ID (无ID,则获取所有) - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **DataSet** (list) - 见 **UMemSpaceSet** 模型定义 - - **TotalCount** (int) - 根据过滤条件得到的总数 - - **Response Model** - - **UMemSpaceAddressSet** - - - **IP** (str) - UMem实例访问IP - - **Port** (int) - UMem实例访问Port - - **UMemSpaceSet** - - - **Address** (list) - 见 **UMemSpaceAddressSet** 模型定义 - - **ChargeType** (str) - Year, Month, Dynamic, Trial - - **CreateTime** (int) - 创建时间 - - **ExpireTime** (int) - 到期时间 - - **Name** (str) - 内存空间名称 - - **Protocol** (str) - 协议类型: memcache, redis - - **RewriteTime** (int) - 运维时间0 //0点1 //1点依次类推 - - **Size** (int) - 容量单位GB - - **SpaceId** (str) - 内存空间ID - - **State** (str) - Starting:创建中 Running:运行中 Fail:失败 - - **SubnetId** (str) - - - **Tag** (str) - - - **Type** (str) - 空间类型:single(无热备),double(热备) - - **UsedSize** (int) - 使用量单位MB - - **VPCId** (str) - - - **Zone** (str) - 可用区,参见 `可用区列表 `_ - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeUMemSpaceRequestSchema().dumps(d) - resp = self.invoke("DescribeUMemSpace", d, **kwargs) - return apis.DescribeUMemSpaceResponseSchema().loads(resp) - - def describe_umem_upgrade_price(self, req=None, **kwargs): - """ DescribeUMemUpgradePrice - 获取UMem升级价格信息 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Size** (int) - (Required) 购买UMem大小,单位:GB - - **SpaceId** (str) - (Required) 需要升级的空间的SpaceId - - **Type** (str) - (Required) 空间类型:single(无热备),double(热备)(默认: double) - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **Price** (float) - 价格 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeUMemUpgradePriceRequestSchema().dumps(d) - resp = self.invoke("DescribeUMemUpgradePrice", d, **kwargs) - return apis.DescribeUMemUpgradePriceResponseSchema().loads(resp) - - def describe_umem_cache_group(self, req=None, **kwargs): - """ DescribeUMemcacheGroup - 显示Memcache - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **GroupId** (str) - 组的ID,如果指定则获取描述,否则为列表操 作,需指定Offset/Limit - - **Limit** (int) - 分页显示的条目数, 默认值为20 - - **Offset** (int) - 分页显示的起始偏移, 默认值为0 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **DataSet** (list) - 见 **UMemcacheGroupSet** 模型定义 - - **TotalCount** (int) - 组的总的节点个数 - - **Response Model** - - **UMemcacheGroupSet** - - - **ChargeType** (str) - 计费类型:Year,Month,Dynamic 默认Dynamic - - **ConfigId** (str) - 节点的配置ID - - **CreateTime** (int) - 创建时间 (UNIX时间戳) - - **ExpireTime** (int) - 过期时间 (UNIX时间戳) - - **GroupId** (str) - 组ID - - **ModifyTime** (int) - 修改时间 (UNIX时间戳) - - **Name** (str) - 组名称 - - **Port** (int) - 节点分配的服务端口 - - **Size** (int) - 容量单位GB - - **State** (str) - 状态标记 Creating // 初始化中 CreateFail // 创建失败 Deleting // 删除中 DeleteFail // 删除失败 Running // 运行 Resizing // 容量调整中 ResizeFail // 容量调整失败 Configing // 配置中 ConfigFail // 配置失败Restarting // 重启中 - - **SubnetId** (str) - - - **Tag** (str) - 业务组名称 - - **UsedSize** (int) - 使用量单位MB - - **VPCId** (str) - - - **Version** (str) - Memcache版本信息,默认为1.4.31 - - **VirtualIP** (str) - 节点的虚拟IP地址 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeUMemcacheGroupRequestSchema().dumps(d) - resp = self.invoke("DescribeUMemcacheGroup", d, **kwargs) - return apis.DescribeUMemcacheGroupResponseSchema().loads(resp) - - def describe_umem_cache_price(self, req=None, **kwargs): - """ DescribeUMemcachePrice - 获取umemcache组价格信息 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Size** (int) - (Required) 容量大小,单位:GB 取值范围[1-32] - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **ChargeType** (str) - 计费模式,Year, Month, Dynamic,默认: Dynamic 默认: 获取所有计费模式的价格 - - **Quantity** (int) - 购买umemcache的时长,默认值为1 - - **Type** (str) - 空间类型:single(无热备),double(热备)(默认: double) - - **Response** - - - **DataSet** (list) - 见 **UMemcachePriceSet** 模型定义 - - **Response Model** - - **UMemcachePriceSet** - - - **ChargeType** (str) - 计费模式,Year, Month, Dynamic - - **Price** (float) - 价格,单位: 元,保留小数点后两位有效数字 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeUMemcachePriceRequestSchema().dumps(d) - resp = self.invoke("DescribeUMemcachePrice", d, **kwargs) - return apis.DescribeUMemcachePriceResponseSchema().loads(resp) - - def describe_umem_cache_upgrade_price(self, req=None, **kwargs): - """ DescribeUMemcacheUpgradePrice - 获取umemcache升级价格信息 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **GroupId** (str) - (Required) 需要升级的空间的GroupId,请参考DescribeUMemcacheGroup接口 - - **Size** (int) - (Required) 购买umemcache大小,单位:GB - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **Price** (float) - 价格,单位:元 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeUMemcacheUpgradePriceRequestSchema().dumps(d) - resp = self.invoke("DescribeUMemcacheUpgradePrice", d, **kwargs) - return apis.DescribeUMemcacheUpgradePriceResponseSchema().loads(resp) - - def describe_uredis_backup(self, req=None, **kwargs): - """ DescribeURedisBackup - 查询主备redis备份 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **GroupId** (str) - 组的ID - - **Limit** (int) - 分页显示的条目数, 默认值为10 - - **Offset** (int) - 分页显示的起始偏移, 默认值为0 - - **Response** - - - **DataSet** (list) - 见 **URedisBackupSet** 模型定义 - - **TotalCount** (int) - 用户名下总的备份个数 - - **Response Model** - - **URedisBackupSet** - - - **BackupId** (str) - 备份ID - - **BackupName** (str) - 备份的名称 - - **BackupSize** (int) - 备份文件大小, 以字节为单位 - - **BackupTime** (int) - 备份时间 (UNIX时间戳) - - **BackupType** (str) - 备份类型: Manual 手动 Auto 自动 - - **GroupId** (str) - 对应的实例ID - - **GroupName** (str) - 组名称 - - **State** (str) - 备份的状态: Backuping 备份中 Success 备份成功 Error 备份失败 Expired 备份过期 - - **Zone** (str) - 可用区,参见 `可用区列表 `_ - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeURedisBackupRequestSchema().dumps(d) - resp = self.invoke("DescribeURedisBackup", d, **kwargs) - return apis.DescribeURedisBackupResponseSchema().loads(resp) - - def describe_uredis_backup_url(self, req=None, **kwargs): - """ DescribeURedisBackupURL - 获取主备Redis备份下载链接 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **BackupId** (str) - (Required) 备份ID - - **GroupId** (str) - (Required) - - **RegionFlag** (bool) - 是否是跨机房URedis(默认false) - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **BackupPath** (str) - 备份文件公网的地址 - - **BackupURL** (str) - 备份文件公网的地址 - - **InnerBackupPath** (str) - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeURedisBackupURLRequestSchema().dumps(d) - resp = self.invoke("DescribeURedisBackupURL", d, **kwargs) - return apis.DescribeURedisBackupURLResponseSchema().loads(resp) - - def describe_uredis_group(self, req=None, **kwargs): - """ DescribeURedisGroup - 查询主备Redis - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **GroupId** (str) - 组的ID,如果指定则获取描述,否则为列表操 作,需指定Offset/Limit - - **Limit** (int) - 分页显示的条目数, 默认值为20 - - **Offset** (int) - 分页显示的起始偏移, 默认值为0 - - **Zone** (str) - - - **Response** - - - **DataSet** (list) - 见 **URedisGroupSet** 模型定义 - - **TotalCount** (int) - 组的总的节点个数 - - **Response Model** - - **URedisGroupSet** - - - **AutoBackup** (str) - 是否需要自动备份,enable,disable - - **BackupTime** (int) - 组自动备份开始时间,单位小时计,范围[0-23] - - **ChargeType** (str) - 计费类型:Year,Month,Dynamic 默认Dynamic - - **ConfigId** (str) - 节点的配置ID - - **CreateTime** (int) - 创建时间 (UNIX时间戳) - - **ExpireTime** (int) - 过期时间 (UNIX时间戳) - - **GroupId** (str) - 组ID - - **GroupName** (str) - 组名称 - - **HighAvailability** (str) - 是否开启高可用,enable,disable - - **MemorySize** (int) - 容量单位GB - - **ModifyTime** (int) - 修改时间 (UNIX时间戳) - - **Name** (str) - 组名称 - - **Port** (int) - 节点分配的服务端口 - - **Protocol** (str) - 协议 - - **RewriteTime** (int) - 返回运维时间 0 //0点 1 //1点 以此类推 - - **Size** (int) - 容量单位GB - - **SlaveZone** (str) - 跨机房URedis,slave redis所在可用区,参见 `可用区列表 `_ - - **State** (str) - 状态标记 Creating // 初始化中 CreateFail // 创建失败 Deleting // 删除中 DeleteFail // 删除失败 Running // 运行 Resizing // 容量调整中 ResizeFail // 容量调整失败 Configing // 配置中 ConfigFail // 配置失败 - - **SubnetId** (str) - - - **Tag** (str) - 业务组名称 - - **Type** (str) - - - **UsedSize** (int) - 使用量单位MB - - **VPCId** (str) - - - **Version** (str) - Redis版本信息 - - **VirtualIP** (str) - 节点的虚拟IP地址 - - **Zone** (str) - 实例所在可用区,或者master redis所在可用区,参见 `可用区列表 `_ - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeURedisGroupRequestSchema().dumps(d) - resp = self.invoke("DescribeURedisGroup", d, **kwargs) - return apis.DescribeURedisGroupResponseSchema().loads(resp) - - def describe_uredis_price(self, req=None, **kwargs): - """ DescribeURedisPrice - 取uredis价格信息 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Size** (int) - (Required) 量大小,单位:GB 取值范围[1-32] - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **ChargeType** (str) - 计费模式,Year, Month, Dynamic;如果不指定,则一次性获取三种计费 - - **ProductType** (str) - 产品类型:MS_Redis(标准主备版),S_Redis(从库),默认为MS_Redis - - **Quantity** (int) - 计费模式为Dynamic时,购买的时长, 默认为1 - - **RegionFlag** (bool) - 是否是跨机房URedis(默认false) - - **Type** (str) - - - **Response** - - - **DataSet** (list) - 见 **URedisPriceSet** 模型定义 - - **Response Model** - - **URedisPriceSet** - - - **ChargeType** (str) - Year, Month, Dynamic,Trial - - **Price** (float) - 价格,单位: 元,保留小数点后两位有效数字 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeURedisPriceRequestSchema().dumps(d) - resp = self.invoke("DescribeURedisPrice", d, **kwargs) - return apis.DescribeURedisPriceResponseSchema().loads(resp) - - def describe_uredis_upgrade_price(self, req=None, **kwargs): - """ DescribeURedisUpgradePrice - 获取uredis升级价格信息 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **GroupId** (str) - (Required) 要升级的空间的GroupId,请参考DescribeURedisGroup接口 - - **Size** (int) - (Required) 购买uredis大小,单位:GB,范围是[1-32] - - **Type** (str) - - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **Price** (float) - 扩容差价,单位: 元,保留小数点后两位有效数字 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeURedisUpgradePriceRequestSchema().dumps(d) - resp = self.invoke("DescribeURedisUpgradePrice", d, **kwargs) - return apis.DescribeURedisUpgradePriceResponseSchema().loads(resp) - - def get_umem_space_state(self, req=None, **kwargs): - """ GetUMemSpaceState - 获取UMem内存空间列表 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **SpaceId** (str) - (Required) 内存空间ID - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **State** (str) - Starting:创建中 Running:运行中 Fail:失败 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.GetUMemSpaceStateRequestSchema().dumps(d) - resp = self.invoke("GetUMemSpaceState", d, **kwargs) - return apis.GetUMemSpaceStateResponseSchema().loads(resp) - - def modify_umem_space_name(self, req=None, **kwargs): - """ ModifyUMemSpaceName - 修改UMem内存空间名称 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Name** (str) - (Required) 新的名称,长度(6<=size<=63) - - **SpaceId** (str) - (Required) UMem内存空间ID - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.ModifyUMemSpaceNameRequestSchema().dumps(d) - resp = self.invoke("ModifyUMemSpaceName", d, **kwargs) - return apis.ModifyUMemSpaceNameResponseSchema().loads(resp) - - def modify_uredis_group_name(self, req=None, **kwargs): - """ ModifyURedisGroupName - 修改主备redis名称 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **GroupId** (str) - (Required) 组的ID - - **Name** (str) - (Required) Redis组名称 (范围[6-63],只能包含英文、数字以及符号-和_) - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.ModifyURedisGroupNameRequestSchema().dumps(d) - resp = self.invoke("ModifyURedisGroupName", d, **kwargs) - return apis.ModifyURedisGroupNameResponseSchema().loads(resp) - - def resize_udredis_space(self, req=None, **kwargs): - """ ResizeUDredisSpace - 调整内存空间容量 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Size** (int) - (Required) 内存大小, 单位:GB (需要大于原size,<= 1024) - - **SpaceId** (str) - (Required) 高性能UMem 内存空间Id - - **CouponId** (str) - 使用的代金券Id - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.ResizeUDredisSpaceRequestSchema().dumps(d) - resp = self.invoke("ResizeUDredisSpace", d, **kwargs) - return apis.ResizeUDredisSpaceResponseSchema().loads(resp) - - def resize_umem_space(self, req=None, **kwargs): - """ ResizeUMemSpace - 调整内存空间容量 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Size** (int) - (Required) 内存大小, 单位:GB (需要大于原size,<= 1024) - - **SpaceId** (str) - (Required) UMem 内存空间Id - - **ChargeType** (str) - - - **CouponId** (str) - 使用的代金券Id - - **Type** (str) - 空间类型:single(无热备),double(热备)(默认: double) - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.ResizeUMemSpaceRequestSchema().dumps(d) - resp = self.invoke("ResizeUMemSpace", d, **kwargs) - return apis.ResizeUMemSpaceResponseSchema().loads(resp) - - def resize_uredis_group(self, req=None, **kwargs): - """ ResizeURedisGroup - 调整主备redis容量 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **GroupId** (str) - (Required) 组ID - - **Size** (int) - (Required) 内存大小, 单位:GB (需要大于原size,且小于等于32) 目前仅支持1/2/4/8/16/32 G 六种容量规格 - - **ChargeType** (str) - - - **CouponId** (int) - 代金券ID 请参考DescribeCoupon接口 - - **Type** (str) - 空间类型:single(无热备),double(热备)(默认: double) - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.ResizeURedisGroupRequestSchema().dumps(d) - resp = self.invoke("ResizeURedisGroup", d, **kwargs) - return apis.ResizeURedisGroupResponseSchema().loads(resp) - - def restart_umem_cache_group(self, req=None, **kwargs): - """ RestartUMemcacheGroup - 重启单机Memcache - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **GroupId** (str) - (Required) 组的ID - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.RestartUMemcacheGroupRequestSchema().dumps(d) - resp = self.invoke("RestartUMemcacheGroup", d, **kwargs) - return apis.RestartUMemcacheGroupResponseSchema().loads(resp) +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.client import Client +from ucloud.services.umem.schemas import apis + + +class UMemClient(Client): + def __init__(self, config, transport=None, middleware=None, logger=None): + super(UMemClient, self).__init__(config, transport, middleware, logger) + + def create_umem_space(self, req=None, **kwargs): + """ CreateUMemSpace - 创建UMem内存空间 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Name** (str) - (Required) 空间名称,长度(6<=size<=63) + - **Size** (int) - (Required) 内存大小, 单位:GB, 范围[1~1024] + - **ChargeType** (str) - Year , Month, Dynamic, Trial 默认: Month + - **CouponId** (str) - 使用的代金券id + - **Password** (str) - URedis密码。请遵照 `字段规范 `_ 设定密码。密码需使用base64进行编码,举例如下:# echo -n Password1 | base64UGFzc3dvcmQx。 + - **Protocol** (str) - 协议:memcache, redis (默认redis).注意:redis无single类型 + - **Quantity** (int) - 购买时长 默认: 1 + - **SubnetId** (str) - + - **Tag** (str) - + - **Type** (str) - 空间类型:single(无热备),double(热备)(默认: double) + - **VPCId** (str) - + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **SpaceId** (str) - 创建内存空间ID列表 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.CreateUMemSpaceRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("CreateUMemSpace", d, **kwargs) + return apis.CreateUMemSpaceResponseSchema().loads(resp) + + def create_umem_cache_group(self, req=None, **kwargs): + """ CreateUMemcacheGroup - 创建单机Memcache + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Name** (str) - (Required) 请求创建组的名称 范围[6-60] + - **ChargeType** (str) - 计费模式,Year , Month, Dynamic 默认: Month + - **ConfigId** (str) - 配置ID,目前仅支持默认配置id 默认配置id:"9a891891-c245-4b66-bce8-67e59430d67c" + - **CouponId** (str) - 代金券ID + - **Protocol** (str) - + - **Quantity** (int) - 购买时长,默认为1 + - **Size** (int) - 每个节点的内存大小,单位GB,默认1GB 目前仅支持1/2/4/8/16/32这几档 + - **SubnetId** (str) - + - **Tag** (str) - 业务组 默认:Default + - **VPCId** (str) - + - **Version** (str) - Memcache版本信息,默认为1.4.31 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **GroupId** (str) - 创建的组ID + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.CreateUMemcacheGroupRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("CreateUMemcacheGroup", d, **kwargs) + return apis.CreateUMemcacheGroupResponseSchema().loads(resp) + + def create_uredis_group(self, req=None, **kwargs): + """ CreateURedisGroup - 创建主备redis + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **HighAvailability** (str) - (Required) 是否开启高可用,enable或disable + - **Name** (str) - (Required) 请求创建组的名称 (范围[6-63],只能包含英文、数字以及符号-和_) + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + - **AutoBackup** (str) - 是否自动备份,enable或disable,默认disable + - **BackupId** (str) - 有此项代表从备份中创建,无代表正常创建 + - **BackupTime** (int) - 自动备份开始时间,范围[0-23],默认3点 + - **ChargeType** (str) - 计费模式,Year , Month, Dynamic 默认: Month + - **ConfigId** (str) - 配置ID,目前支持 3.0版本配置ID:"03f58ca9-b64d-4bdd-abc7-c6b9a46fd801",3.2版本配置ID:"3e45ac48-f8a2-a9q2-261d-l342dab130gf", 4.0版本配置ID:"6c9298a3-9d7f-428c-b1d0-e87ab3b8a1ea",默认版本3.0,从备份创建为必传项 + - **CouponId** (str) - 代金券ID + - **MasterGroupId** (str) - Master Redis Group的ID,创建只读Slave时,必须填写 + - **Password** (str) - 初始化密码,需要 base64 编码 + - **Quantity** (int) - 购买时长,默认为1 + - **Size** (int) - 每个节点的内存大小,单位GB,默认1GB,目前仅支持1/2/4/8/16/32,六种 + - **SlaveZone** (str) - 跨机房URedis,slave所在可用区(必须和Zone在同一Region,且不可相同) + - **SubnetId** (str) - + - **Tag** (str) - 业务组名称 + - **VPCId** (str) - + - **Version** (str) - Redis版本信息(详见DescribeURedisVersion返回结果),默认版本3.0 + + **Response** + + - **GroupId** (str) - 创建的组ID + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.CreateURedisGroupRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("CreateURedisGroup", d, **kwargs) + return apis.CreateURedisGroupResponseSchema().loads(resp) + + def delete_umem_space(self, req=None, **kwargs): + """ DeleteUMemSpace - 删除UMem内存空间 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **SpaceId** (str) - (Required) UMem内存空间ID + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DeleteUMemSpaceRequestSchema().dumps(d) + resp = self.invoke("DeleteUMemSpace", d, **kwargs) + return apis.DeleteUMemSpaceResponseSchema().loads(resp) + + def delete_umem_cache_group(self, req=None, **kwargs): + """ DeleteUMemcacheGroup - 删除单机Memcache + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **GroupId** (str) - (Required) 组ID + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DeleteUMemcacheGroupRequestSchema().dumps(d) + resp = self.invoke("DeleteUMemcacheGroup", d, **kwargs) + return apis.DeleteUMemcacheGroupResponseSchema().loads(resp) + + def delete_uredis_group(self, req=None, **kwargs): + """ DeleteURedisGroup - 删除主备redis + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **GroupId** (str) - (Required) 组ID + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DeleteURedisGroupRequestSchema().dumps(d) + resp = self.invoke("DeleteURedisGroup", d, **kwargs) + return apis.DeleteURedisGroupResponseSchema().loads(resp) + + def describe_umem_price(self, req=None, **kwargs): + """ DescribeUMemPrice - 获取UMem实例价格信息 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Size** (int) - (Required) 购买umem大小,单位:GB,范围[1~1024] + - **Type** (str) - (Required) 空间类型:single(无热备),double(热备)(默认: double) + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + - **ChargeType** (str) - Year, Month, Dynamic,Trial 如果不指定,则一次性获取三种计费 + - **Quantity** (int) - 购买UMem的时长,默认值为1 + - **RegionFlag** (bool) - + + **Response** + + - **DataSet** (list) - 见 **UMemPriceSet** 模型定义 + + **Response Model** + + **UMemPriceSet** + + - **ChargeType** (str) - Year, Month, Dynamic,Trial + - **OriginalPrice** (int) - 原价 + - **Price** (int) - 现价,单位: 元,保留小数点后两位有效数字 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeUMemPriceRequestSchema().dumps(d) + resp = self.invoke("DescribeUMemPrice", d, **kwargs) + return apis.DescribeUMemPriceResponseSchema().loads(resp) + + def describe_umem_space(self, req=None, **kwargs): + """ DescribeUMemSpace - 获取UMem内存空间列表 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Limit** (int) - 返回数据长度, 默认为20 + - **Offset** (int) - 数据偏移量, 默认为0 + - **SpaceId** (str) - 内存空间ID (无ID,则获取所有) + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **DataSet** (list) - 见 **UMemSpaceSet** 模型定义 + - **TotalCount** (int) - 根据过滤条件得到的总数 + + **Response Model** + + **UMemSpaceAddressSet** + + - **IP** (str) - UMem实例访问IP + - **Port** (int) - UMem实例访问Port + + **UMemSpaceSet** + + - **Address** (list) - 见 **UMemSpaceAddressSet** 模型定义 + - **ChargeType** (str) - Year, Month, Dynamic, Trial + - **CreateTime** (int) - 创建时间 + - **ExpireTime** (int) - 到期时间 + - **Name** (str) - 内存空间名称 + - **Protocol** (str) - 协议类型: memcache, redis + - **RewriteTime** (int) - 运维时间0 //0点1 //1点依次类推 + - **Size** (int) - 容量单位GB + - **SpaceId** (str) - 内存空间ID + - **State** (str) - Starting:创建中 Running:运行中 Fail:失败 + - **SubnetId** (str) - + - **Tag** (str) - + - **Type** (str) - 空间类型:single(无热备),double(热备) + - **UsedSize** (int) - 使用量单位MB + - **VPCId** (str) - + - **Zone** (str) - 可用区,参见 `可用区列表 `_ + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeUMemSpaceRequestSchema().dumps(d) + resp = self.invoke("DescribeUMemSpace", d, **kwargs) + return apis.DescribeUMemSpaceResponseSchema().loads(resp) + + def describe_umem_upgrade_price(self, req=None, **kwargs): + """ DescribeUMemUpgradePrice - 获取UMem升级价格信息 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Size** (int) - (Required) 购买UMem大小,单位:GB + - **SpaceId** (str) - (Required) 需要升级的空间的SpaceId + - **Type** (str) - (Required) 空间类型:single(无热备),double(热备)(默认: double) + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **DataSet** (dict) - 见 **PriceDataSet** 模型定义 + - **Price** (int) - 价格(兼容老版本) + + **Response Model** + + **PriceDataSet** + + - **CustomPrice** (int) - 用户折后价 + - **PurchaseValue** (int) - 资源有效期 + - **TotalPrice** (int) - 升降级资源的价格 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeUMemUpgradePriceRequestSchema().dumps(d) + resp = self.invoke("DescribeUMemUpgradePrice", d, **kwargs) + return apis.DescribeUMemUpgradePriceResponseSchema().loads(resp) + + def describe_umem_cache_group(self, req=None, **kwargs): + """ DescribeUMemcacheGroup - 显示Memcache + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **GroupId** (str) - 组的ID,如果指定则获取描述,否则为列表操 作,需指定Offset/Limit + - **Limit** (int) - 分页显示的条目数, 默认值为20 + - **Offset** (int) - 分页显示的起始偏移, 默认值为0 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **DataSet** (list) - 见 **UMemcacheGroupSet** 模型定义 + - **TotalCount** (int) - 组的总的节点个数 + + **Response Model** + + **UMemcacheGroupSet** + + - **ChargeType** (str) - 计费类型:Year,Month,Dynamic 默认Dynamic + - **ConfigId** (str) - 节点的配置ID + - **CreateTime** (int) - 创建时间 (UNIX时间戳) + - **ExpireTime** (int) - 过期时间 (UNIX时间戳) + - **GroupId** (str) - 组ID + - **ModifyTime** (int) - 修改时间 (UNIX时间戳) + - **Name** (str) - 组名称 + - **Port** (int) - 节点分配的服务端口 + - **Size** (int) - 容量单位GB + - **State** (str) - 状态标记 Creating // 初始化中 CreateFail // 创建失败 Deleting // 删除中 DeleteFail // 删除失败 Running // 运行 Resizing // 容量调整中 ResizeFail // 容量调整失败 Configing // 配置中 ConfigFail // 配置失败Restarting // 重启中 + - **SubnetId** (str) - + - **Tag** (str) - 业务组名称 + - **UsedSize** (int) - 使用量单位MB + - **VPCId** (str) - + - **Version** (str) - Memcache版本信息,默认为1.4.31 + - **VirtualIP** (str) - 节点的虚拟IP地址 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeUMemcacheGroupRequestSchema().dumps(d) + resp = self.invoke("DescribeUMemcacheGroup", d, **kwargs) + return apis.DescribeUMemcacheGroupResponseSchema().loads(resp) + + def describe_umem_cache_price(self, req=None, **kwargs): + """ DescribeUMemcachePrice - 获取umemcache组价格信息 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Size** (int) - (Required) 容量大小,单位:GB 取值范围[1-32] + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + - **ChargeType** (str) - 计费模式,Year, Month, Dynamic,默认: Dynamic 默认: 获取所有计费模式的价格 + - **Quantity** (int) - 购买umemcache的时长,默认值为1 + - **Type** (str) - 空间类型:single(无热备),double(热备)(默认: double) + + **Response** + + - **DataSet** (list) - 见 **UMemcachePriceSet** 模型定义 + + **Response Model** + + **UMemcachePriceSet** + + - **ChargeType** (str) - 计费模式,Year, Month, Dynamic + - **OriginalPrice** (int) - 原价 + - **Price** (int) - 总价格,单位: 元,保留小数点后两位有效数字 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeUMemcachePriceRequestSchema().dumps(d) + resp = self.invoke("DescribeUMemcachePrice", d, **kwargs) + return apis.DescribeUMemcachePriceResponseSchema().loads(resp) + + def describe_umem_cache_upgrade_price(self, req=None, **kwargs): + """ DescribeUMemcacheUpgradePrice - 获取umemcache升级价格信息 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **GroupId** (str) - (Required) 需要升级的空间的GroupId,请参考DescribeUMemcacheGroup接口 + - **Size** (int) - (Required) 购买umemcache大小,单位:GB + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **DataSet** (dict) - 见 **PriceDataSet** 模型定义 + - **Price** (int) - 价格,单位:元 + + **Response Model** + + **PriceDataSet** + + - **CustomPrice** (int) - 用户折后价 + - **PurchaseValue** (int) - 资源有效期 + - **TotalPrice** (int) - 升降级资源的价格 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeUMemcacheUpgradePriceRequestSchema().dumps(d) + resp = self.invoke("DescribeUMemcacheUpgradePrice", d, **kwargs) + return apis.DescribeUMemcacheUpgradePriceResponseSchema().loads(resp) + + def describe_uredis_backup(self, req=None, **kwargs): + """ DescribeURedisBackup - 查询主备redis备份 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **GroupId** (str) - 组的ID + - **Limit** (int) - 分页显示的条目数, 默认值为10 + - **Offset** (int) - 分页显示的起始偏移, 默认值为0 + + **Response** + + - **DataSet** (list) - 见 **URedisBackupSet** 模型定义 + - **TotalCount** (int) - 用户名下总的备份个数 + + **Response Model** + + **URedisBackupSet** + + - **BackupId** (str) - 备份ID + - **BackupName** (str) - 备份的名称 + - **BackupSize** (int) - 备份文件大小, 以字节为单位 + - **BackupTime** (int) - 备份时间 (UNIX时间戳) + - **BackupType** (str) - 备份类型: Manual 手动 Auto 自动 + - **GroupId** (str) - 对应的实例ID + - **GroupName** (str) - 组名称 + - **State** (str) - 备份的状态: Backuping 备份中 Success 备份成功 Error 备份失败 Expired 备份过期 + - **Zone** (str) - 可用区,参见 `可用区列表 `_ + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeURedisBackupRequestSchema().dumps(d) + resp = self.invoke("DescribeURedisBackup", d, **kwargs) + return apis.DescribeURedisBackupResponseSchema().loads(resp) + + def describe_uredis_backup_url(self, req=None, **kwargs): + """ DescribeURedisBackupURL - 获取主备Redis备份下载链接 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **BackupId** (str) - (Required) 备份ID + - **GroupId** (str) - 实例名称 + - **RegionFlag** (bool) - 是否是跨机房URedis(默认false) + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **BackupPath** (str) - 备份文件公网的地址 + - **BackupURL** (str) - 备份文件公网的地址 + - **InnerBackupPath** (str) - + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeURedisBackupURLRequestSchema().dumps(d) + resp = self.invoke("DescribeURedisBackupURL", d, **kwargs) + return apis.DescribeURedisBackupURLResponseSchema().loads(resp) + + def describe_uredis_group(self, req=None, **kwargs): + """ DescribeURedisGroup - 查询主备Redis + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **GroupId** (str) - 组的ID,如果指定则获取描述,否则为列表操 作,需指定Offset/Limit + - **Limit** (int) - 分页显示的条目数, 默认值为20 + - **Offset** (int) - 分页显示的起始偏移, 默认值为0 + - **Zone** (str) - + + **Response** + + - **DataSet** (list) - 见 **URedisGroupSet** 模型定义 + - **TotalCount** (int) - 组的总的节点个数 + + **Response Model** + + **URedisGroupSet** + + - **AutoBackup** (str) - 是否需要自动备份,enable,disable + - **BackupTime** (int) - 组自动备份开始时间,单位小时计,范围[0-23] + - **ChargeType** (str) - 计费类型:Year,Month,Dynamic 默认Dynamic + - **ConfigId** (str) - 节点的配置ID + - **CreateTime** (int) - 创建时间 (UNIX时间戳) + - **ExpireTime** (int) - 过期时间 (UNIX时间戳) + - **GroupId** (str) - 组ID + - **GroupName** (str) - 组名称 + - **HighAvailability** (str) - 是否开启高可用,enable,disable + - **MemorySize** (int) - 容量单位GB + - **ModifyTime** (int) - 修改时间 (UNIX时间戳) + - **Name** (str) - 组名称 + - **Port** (int) - 节点分配的服务端口 + - **Protocol** (str) - 协议 + - **RewriteTime** (int) - 返回运维时间 0 //0点 1 //1点 以此类推 + - **Size** (int) - 容量单位GB + - **SlaveZone** (str) - 跨机房URedis,slave redis所在可用区,参见 `可用区列表 `_ + - **State** (str) - 状态标记 Creating // 初始化中 CreateFail // 创建失败 Deleting // 删除中 DeleteFail // 删除失败 Running // 运行 Resizing // 容量调整中 ResizeFail // 容量调整失败 Configing // 配置中 ConfigFail // 配置失败 + - **SubnetId** (str) - + - **Tag** (str) - 业务组名称 + - **Type** (str) - + - **UsedSize** (int) - 使用量单位MB + - **VPCId** (str) - + - **Version** (str) - Redis版本信息 + - **VirtualIP** (str) - 节点的虚拟IP地址 + - **Zone** (str) - 实例所在可用区,或者master redis所在可用区,参见 `可用区列表 `_ + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeURedisGroupRequestSchema().dumps(d) + resp = self.invoke("DescribeURedisGroup", d, **kwargs) + return apis.DescribeURedisGroupResponseSchema().loads(resp) + + def describe_uredis_price(self, req=None, **kwargs): + """ DescribeURedisPrice - 取uredis价格信息 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Size** (int) - (Required) 量大小,单位:GB 取值范围[1-32] + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + - **ChargeType** (str) - 计费模式,Year, Month, Dynamic;如果不指定,则一次性获取三种计费 + - **ProductType** (str) - 产品类型:MS_Redis(标准主备版),S_Redis(从库),默认为MS_Redis + - **Quantity** (int) - 计费模式为Dynamic时,购买的时长, 默认为1 + - **RegionFlag** (bool) - 是否是跨机房URedis(默认false) + - **Type** (str) - + + **Response** + + - **DataSet** (list) - 见 **URedisPriceSet** 模型定义 + + **Response Model** + + **URedisPriceSet** + + - **ChargeType** (str) - Year, Month, Dynamic,Trial + - **OriginalPrice** (int) - 原价 + - **Price** (int) - 总价格,单位: 元,保留小数点后两位有效数字 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeURedisPriceRequestSchema().dumps(d) + resp = self.invoke("DescribeURedisPrice", d, **kwargs) + return apis.DescribeURedisPriceResponseSchema().loads(resp) + + def describe_uredis_upgrade_price(self, req=None, **kwargs): + """ DescribeURedisUpgradePrice - 获取uredis升级价格信息 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **GroupId** (str) - (Required) 要升级的空间的GroupId,请参考DescribeURedisGroup接口 + - **Size** (int) - (Required) 购买uredis大小,单位:GB,范围是[1-32] + - **Type** (str) - + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **DataSet** (dict) - 见 **PriceDataSet** 模型定义 + - **Price** (int) - 扩容差价,单位: 元,保留小数点后两位有效数字(兼容老版本) + + **Response Model** + + **PriceDataSet** + + - **CustomPrice** (int) - 用户折后价 + - **PurchaseValue** (int) - 资源有效期 + - **TotalPrice** (int) - 升降级资源的价格 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeURedisUpgradePriceRequestSchema().dumps(d) + resp = self.invoke("DescribeURedisUpgradePrice", d, **kwargs) + return apis.DescribeURedisUpgradePriceResponseSchema().loads(resp) + + def get_umem_space_state(self, req=None, **kwargs): + """ GetUMemSpaceState - 获取UMem内存空间列表 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **SpaceId** (str) - (Required) 内存空间ID + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **State** (str) - Starting:创建中 Running:运行中 Fail:失败 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.GetUMemSpaceStateRequestSchema().dumps(d) + resp = self.invoke("GetUMemSpaceState", d, **kwargs) + return apis.GetUMemSpaceStateResponseSchema().loads(resp) + + def modify_umem_space_name(self, req=None, **kwargs): + """ ModifyUMemSpaceName - 修改UMem内存空间名称 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Name** (str) - (Required) 新的名称,长度(6<=size<=63) + - **SpaceId** (str) - (Required) UMem内存空间ID + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.ModifyUMemSpaceNameRequestSchema().dumps(d) + resp = self.invoke("ModifyUMemSpaceName", d, **kwargs) + return apis.ModifyUMemSpaceNameResponseSchema().loads(resp) + + def modify_uredis_group_name(self, req=None, **kwargs): + """ ModifyURedisGroupName - 修改主备redis名称 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **GroupId** (str) - (Required) 组的ID + - **Name** (str) - (Required) Redis组名称 (范围[6-63],只能包含英文、数字以及符号-和_) + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.ModifyURedisGroupNameRequestSchema().dumps(d) + resp = self.invoke("ModifyURedisGroupName", d, **kwargs) + return apis.ModifyURedisGroupNameResponseSchema().loads(resp) + + def resize_udredis_space(self, req=None, **kwargs): + """ ResizeUDredisSpace - 调整内存空间容量 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Size** (int) - (Required) 内存大小, 单位:GB (需要大于原size,<= 1024) + - **SpaceId** (str) - (Required) 高性能UMem 内存空间Id + - **CouponId** (str) - 使用的代金券Id + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.ResizeUDredisSpaceRequestSchema().dumps(d) + resp = self.invoke("ResizeUDredisSpace", d, **kwargs) + return apis.ResizeUDredisSpaceResponseSchema().loads(resp) + + def resize_umem_space(self, req=None, **kwargs): + """ ResizeUMemSpace - 调整内存空间容量 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Size** (int) - (Required) 内存大小, 单位:GB (需要大于原size,<= 1024) + - **SpaceId** (str) - (Required) UMem 内存空间Id + - **ChargeType** (str) - + - **CouponId** (str) - 使用的代金券Id + - **Type** (str) - 空间类型:single(无热备),double(热备)(默认: double) + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.ResizeUMemSpaceRequestSchema().dumps(d) + resp = self.invoke("ResizeUMemSpace", d, **kwargs) + return apis.ResizeUMemSpaceResponseSchema().loads(resp) + + def resize_uredis_group(self, req=None, **kwargs): + """ ResizeURedisGroup - 调整主备redis容量 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **GroupId** (str) - (Required) 组ID + - **Size** (int) - (Required) 内存大小, 单位:GB (需要大于原size,且小于等于32) 目前仅支持1/2/4/8/16/32 G 六种容量规格 + - **ChargeType** (str) - + - **CouponId** (int) - 代金券ID 请参考DescribeCoupon接口 + - **Type** (str) - 空间类型:single(无热备),double(热备)(默认: double) + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.ResizeURedisGroupRequestSchema().dumps(d) + resp = self.invoke("ResizeURedisGroup", d, **kwargs) + return apis.ResizeURedisGroupResponseSchema().loads(resp) + + def restart_umem_cache_group(self, req=None, **kwargs): + """ RestartUMemcacheGroup - 重启单机Memcache + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **GroupId** (str) - (Required) 组的ID + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.RestartUMemcacheGroupRequestSchema().dumps(d) + resp = self.invoke("RestartUMemcacheGroup", d, **kwargs) + return apis.RestartUMemcacheGroupResponseSchema().loads(resp) diff --git a/ucloud/services/umem/schemas/__init__.py b/ucloud/services/umem/schemas/__init__.py index 4c48b5a..40a96af 100644 --- a/ucloud/services/umem/schemas/__init__.py +++ b/ucloud/services/umem/schemas/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- diff --git a/ucloud/services/umem/schemas/apis.py b/ucloud/services/umem/schemas/apis.py index 0b49495..bbf178f 100644 --- a/ucloud/services/umem/schemas/apis.py +++ b/ucloud/services/umem/schemas/apis.py @@ -1,739 +1,756 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.typesystem import schema, fields -from ucloud.services.umem.schemas import models - -""" UMem API Schema -""" -""" -API: CreateUMemSpace - -创建UMem内存空间 -""" - - -class CreateUMemSpaceRequestSchema(schema.RequestSchema): - """ CreateUMemSpace - 创建UMem内存空间 - """ - - fields = { - "ChargeType": fields.Str(required=False, dump_to="ChargeType"), - "CouponId": fields.Str(required=False, dump_to="CouponId"), - "Name": fields.Str(required=True, dump_to="Name"), - "Password": fields.Base64(required=False, dump_to="Password"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Protocol": fields.Str(required=False, dump_to="Protocol"), - "Quantity": fields.Int(required=False, dump_to="Quantity"), - "Region": fields.Str(required=True, dump_to="Region"), - "Size": fields.Int(required=True, dump_to="Size"), - "SubnetId": fields.Str(required=False, dump_to="SubnetId"), - "Tag": fields.Str(required=False, dump_to="Tag"), - "Type": fields.Str(required=False, dump_to="Type"), - "VPCId": fields.Str(required=False, dump_to="VPCId"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class CreateUMemSpaceResponseSchema(schema.ResponseSchema): - """ CreateUMemSpace - 创建UMem内存空间 - """ - - fields = {"SpaceId": fields.Str(required=False, load_from="SpaceId")} - - -""" -API: CreateUMemcacheGroup - -创建单机Memcache -""" - - -class CreateUMemcacheGroupRequestSchema(schema.RequestSchema): - """ CreateUMemcacheGroup - 创建单机Memcache - """ - - fields = { - "ChargeType": fields.Str(required=False, dump_to="ChargeType"), - "ConfigId": fields.Str(required=False, dump_to="ConfigId"), - "CouponId": fields.Str(required=False, dump_to="CouponId"), - "Name": fields.Str(required=True, dump_to="Name"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Protocol": fields.Str(required=False, dump_to="Protocol"), - "Quantity": fields.Int(required=False, dump_to="Quantity"), - "Region": fields.Str(required=True, dump_to="Region"), - "Size": fields.Int(required=False, dump_to="Size"), - "SubnetId": fields.Str(required=False, dump_to="SubnetId"), - "Tag": fields.Str(required=False, dump_to="Tag"), - "VPCId": fields.Str(required=False, dump_to="VPCId"), - "Version": fields.Str(required=False, dump_to="Version"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class CreateUMemcacheGroupResponseSchema(schema.ResponseSchema): - """ CreateUMemcacheGroup - 创建单机Memcache - """ - - fields = {"GroupId": fields.Str(required=False, load_from="GroupId")} - - -""" -API: CreateURedisGroup - -创建主备redis -""" - - -class CreateURedisGroupRequestSchema(schema.RequestSchema): - """ CreateURedisGroup - 创建主备redis - """ - - fields = { - "AutoBackup": fields.Str(required=False, dump_to="AutoBackup"), - "BackupId": fields.Str(required=False, dump_to="BackupId"), - "BackupTime": fields.Int(required=False, dump_to="BackupTime"), - "ChargeType": fields.Str(required=False, dump_to="ChargeType"), - "ConfigId": fields.Str(required=False, dump_to="ConfigId"), - "CouponId": fields.Str(required=False, dump_to="CouponId"), - "HighAvailability": fields.Str(required=True, dump_to="HighAvailability"), - "MasterGroupId": fields.Str(required=False, dump_to="MasterGroupId"), - "Name": fields.Str(required=True, dump_to="Name"), - "Password": fields.Base64(required=False, dump_to="Password"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Quantity": fields.Int(required=False, dump_to="Quantity"), - "Region": fields.Str(required=True, dump_to="Region"), - "Size": fields.Int(required=False, dump_to="Size"), - "SlaveZone": fields.Str(required=False, dump_to="SlaveZone"), - "SubnetId": fields.Str(required=False, dump_to="SubnetId"), - "Tag": fields.Str(required=False, dump_to="Tag"), - "VPCId": fields.Str(required=False, dump_to="VPCId"), - "Version": fields.Str(required=False, dump_to="Version"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class CreateURedisGroupResponseSchema(schema.ResponseSchema): - """ CreateURedisGroup - 创建主备redis - """ - - fields = {"GroupId": fields.Str(required=False, load_from="GroupId")} - - -""" -API: DeleteUMemSpace - -删除UMem内存空间 -""" - - -class DeleteUMemSpaceRequestSchema(schema.RequestSchema): - """ DeleteUMemSpace - 删除UMem内存空间 - """ - - fields = { - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "SpaceId": fields.Str(required=True, dump_to="SpaceId"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class DeleteUMemSpaceResponseSchema(schema.ResponseSchema): - """ DeleteUMemSpace - 删除UMem内存空间 - """ - - fields = {} - - -""" -API: DeleteUMemcacheGroup - -删除单机Memcache -""" - - -class DeleteUMemcacheGroupRequestSchema(schema.RequestSchema): - """ DeleteUMemcacheGroup - 删除单机Memcache - """ - - fields = { - "GroupId": fields.Str(required=True, dump_to="GroupId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class DeleteUMemcacheGroupResponseSchema(schema.ResponseSchema): - """ DeleteUMemcacheGroup - 删除单机Memcache - """ - - fields = {} - - -""" -API: DeleteURedisGroup - -删除主备redis -""" - - -class DeleteURedisGroupRequestSchema(schema.RequestSchema): - """ DeleteURedisGroup - 删除主备redis - """ - - fields = { - "GroupId": fields.Str(required=True, dump_to="GroupId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - } - - -class DeleteURedisGroupResponseSchema(schema.ResponseSchema): - """ DeleteURedisGroup - 删除主备redis - """ - - fields = {} - - -""" -API: DescribeUMemPrice - -获取UMem实例价格信息 -""" - - -class DescribeUMemPriceRequestSchema(schema.RequestSchema): - """ DescribeUMemPrice - 获取UMem实例价格信息 - """ - - fields = { - "ChargeType": fields.Str(required=False, dump_to="ChargeType"), - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Quantity": fields.Int(required=False, dump_to="Quantity"), - "Region": fields.Str(required=True, dump_to="Region"), - "RegionFlag": fields.Bool(required=False, dump_to="RegionFlag"), - "Size": fields.Int(required=True, dump_to="Size"), - "Type": fields.Str(required=True, dump_to="Type"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class DescribeUMemPriceResponseSchema(schema.ResponseSchema): - """ DescribeUMemPrice - 获取UMem实例价格信息 - """ - - fields = { - "DataSet": fields.List( - models.UMemPriceSetSchema(), required=False, load_from="DataSet" - ) - } - - -""" -API: DescribeUMemSpace - -获取UMem内存空间列表 -""" - - -class DescribeUMemSpaceRequestSchema(schema.RequestSchema): - """ DescribeUMemSpace - 获取UMem内存空间列表 - """ - - fields = { - "Limit": fields.Int(required=False, dump_to="Limit"), - "Offset": fields.Int(required=False, dump_to="Offset"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "SpaceId": fields.Str(required=False, dump_to="SpaceId"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class DescribeUMemSpaceResponseSchema(schema.ResponseSchema): - """ DescribeUMemSpace - 获取UMem内存空间列表 - """ - - fields = { - "DataSet": fields.List( - models.UMemSpaceSetSchema(), required=False, load_from="DataSet" - ), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - } - - -""" -API: DescribeUMemUpgradePrice - -获取UMem升级价格信息 -""" - - -class DescribeUMemUpgradePriceRequestSchema(schema.RequestSchema): - """ DescribeUMemUpgradePrice - 获取UMem升级价格信息 - """ - - fields = { - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Size": fields.Int(required=True, dump_to="Size"), - "SpaceId": fields.Str(required=True, dump_to="SpaceId"), - "Type": fields.Str(required=True, dump_to="Type"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class DescribeUMemUpgradePriceResponseSchema(schema.ResponseSchema): - """ DescribeUMemUpgradePrice - 获取UMem升级价格信息 - """ - - fields = {"Price": fields.Float(required=False, load_from="Price")} - - -""" -API: DescribeUMemcacheGroup - -显示Memcache -""" - - -class DescribeUMemcacheGroupRequestSchema(schema.RequestSchema): - """ DescribeUMemcacheGroup - 显示Memcache - """ - - fields = { - "GroupId": fields.Str(required=False, dump_to="GroupId"), - "Limit": fields.Int(required=False, dump_to="Limit"), - "Offset": fields.Int(required=False, dump_to="Offset"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class DescribeUMemcacheGroupResponseSchema(schema.ResponseSchema): - """ DescribeUMemcacheGroup - 显示Memcache - """ - - fields = { - "DataSet": fields.List( - models.UMemcacheGroupSetSchema(), required=False, load_from="DataSet" - ), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - } - - -""" -API: DescribeUMemcachePrice - -获取umemcache组价格信息 -""" - - -class DescribeUMemcachePriceRequestSchema(schema.RequestSchema): - """ DescribeUMemcachePrice - 获取umemcache组价格信息 - """ - - fields = { - "ChargeType": fields.Str(required=False, dump_to="ChargeType"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Quantity": fields.Int(required=False, dump_to="Quantity"), - "Region": fields.Str(required=True, dump_to="Region"), - "Size": fields.Int(required=True, dump_to="Size"), - "Type": fields.Str(required=False, dump_to="Type"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class DescribeUMemcachePriceResponseSchema(schema.ResponseSchema): - """ DescribeUMemcachePrice - 获取umemcache组价格信息 - """ - - fields = { - "DataSet": fields.List( - models.UMemcachePriceSetSchema(), required=False, load_from="DataSet" - ) - } - - -""" -API: DescribeUMemcacheUpgradePrice - -获取umemcache升级价格信息 -""" - - -class DescribeUMemcacheUpgradePriceRequestSchema(schema.RequestSchema): - """ DescribeUMemcacheUpgradePrice - 获取umemcache升级价格信息 - """ - - fields = { - "GroupId": fields.Str(required=True, dump_to="GroupId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Size": fields.Int(required=True, dump_to="Size"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class DescribeUMemcacheUpgradePriceResponseSchema(schema.ResponseSchema): - """ DescribeUMemcacheUpgradePrice - 获取umemcache升级价格信息 - """ - - fields = {"Price": fields.Float(required=False, load_from="Price")} - - -""" -API: DescribeURedisBackup - -查询主备redis备份 -""" - - -class DescribeURedisBackupRequestSchema(schema.RequestSchema): - """ DescribeURedisBackup - 查询主备redis备份 - """ - - fields = { - "GroupId": fields.Str(required=False, dump_to="GroupId"), - "Limit": fields.Int(required=False, dump_to="Limit"), - "Offset": fields.Int(required=False, dump_to="Offset"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - } - - -class DescribeURedisBackupResponseSchema(schema.ResponseSchema): - """ DescribeURedisBackup - 查询主备redis备份 - """ - - fields = { - "DataSet": fields.List( - models.URedisBackupSetSchema(), required=False, load_from="DataSet" - ), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - } - - -""" -API: DescribeURedisBackupURL - -获取主备Redis备份下载链接 -""" - - -class DescribeURedisBackupURLRequestSchema(schema.RequestSchema): - """ DescribeURedisBackupURL - 获取主备Redis备份下载链接 - """ - - fields = { - "BackupId": fields.Str(required=True, dump_to="BackupId"), - "GroupId": fields.Str(required=True, dump_to="GroupId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "RegionFlag": fields.Bool(required=False, dump_to="RegionFlag"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class DescribeURedisBackupURLResponseSchema(schema.ResponseSchema): - """ DescribeURedisBackupURL - 获取主备Redis备份下载链接 - """ - - fields = { - "BackupPath": fields.Str(required=False, load_from="BackupPath"), - "BackupURL": fields.Str(required=False, load_from="BackupURL"), - "InnerBackupPath": fields.Str(required=False, load_from="InnerBackupPath"), - } - - -""" -API: DescribeURedisGroup - -查询主备Redis -""" - - -class DescribeURedisGroupRequestSchema(schema.RequestSchema): - """ DescribeURedisGroup - 查询主备Redis - """ - - fields = { - "GroupId": fields.Str(required=False, dump_to="GroupId"), - "Limit": fields.Int(required=False, dump_to="Limit"), - "Offset": fields.Int(required=False, dump_to="Offset"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class DescribeURedisGroupResponseSchema(schema.ResponseSchema): - """ DescribeURedisGroup - 查询主备Redis - """ - - fields = { - "DataSet": fields.List( - models.URedisGroupSetSchema(), required=False, load_from="DataSet" - ), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - } - - -""" -API: DescribeURedisPrice - -取uredis价格信息 -""" - - -class DescribeURedisPriceRequestSchema(schema.RequestSchema): - """ DescribeURedisPrice - 取uredis价格信息 - """ - - fields = { - "ChargeType": fields.Str(required=False, dump_to="ChargeType"), - "ProductType": fields.Str(required=False, dump_to="ProductType"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Quantity": fields.Int(required=False, dump_to="Quantity"), - "Region": fields.Str(required=True, dump_to="Region"), - "RegionFlag": fields.Bool(required=False, dump_to="RegionFlag"), - "Size": fields.Int(required=True, dump_to="Size"), - "Type": fields.Str(required=False, dump_to="Type"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class DescribeURedisPriceResponseSchema(schema.ResponseSchema): - """ DescribeURedisPrice - 取uredis价格信息 - """ - - fields = { - "DataSet": fields.List( - models.URedisPriceSetSchema(), required=False, load_from="DataSet" - ) - } - - -""" -API: DescribeURedisUpgradePrice - -获取uredis升级价格信息 -""" - - -class DescribeURedisUpgradePriceRequestSchema(schema.RequestSchema): - """ DescribeURedisUpgradePrice - 获取uredis升级价格信息 - """ - - fields = { - "GroupId": fields.Str(required=True, dump_to="GroupId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Size": fields.Int(required=True, dump_to="Size"), - "Type": fields.Str(required=False, dump_to="Type"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class DescribeURedisUpgradePriceResponseSchema(schema.ResponseSchema): - """ DescribeURedisUpgradePrice - 获取uredis升级价格信息 - """ - - fields = {"Price": fields.Float(required=False, load_from="Price")} - - -""" -API: GetUMemSpaceState - -获取UMem内存空间列表 -""" - - -class GetUMemSpaceStateRequestSchema(schema.RequestSchema): - """ GetUMemSpaceState - 获取UMem内存空间列表 - """ - - fields = { - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "SpaceId": fields.Str(required=True, dump_to="SpaceId"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class GetUMemSpaceStateResponseSchema(schema.ResponseSchema): - """ GetUMemSpaceState - 获取UMem内存空间列表 - """ - - fields = {"State": fields.Str(required=False, load_from="State")} - - -""" -API: ModifyUMemSpaceName - -修改UMem内存空间名称 -""" - - -class ModifyUMemSpaceNameRequestSchema(schema.RequestSchema): - """ ModifyUMemSpaceName - 修改UMem内存空间名称 - """ - - fields = { - "Name": fields.Str(required=True, dump_to="Name"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "SpaceId": fields.Str(required=True, dump_to="SpaceId"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class ModifyUMemSpaceNameResponseSchema(schema.ResponseSchema): - """ ModifyUMemSpaceName - 修改UMem内存空间名称 - """ - - fields = {} - - -""" -API: ModifyURedisGroupName - -修改主备redis名称 -""" - - -class ModifyURedisGroupNameRequestSchema(schema.RequestSchema): - """ ModifyURedisGroupName - 修改主备redis名称 - """ - - fields = { - "GroupId": fields.Str(required=True, dump_to="GroupId"), - "Name": fields.Str(required=True, dump_to="Name"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class ModifyURedisGroupNameResponseSchema(schema.ResponseSchema): - """ ModifyURedisGroupName - 修改主备redis名称 - """ - - fields = {} - - -""" -API: ResizeUDredisSpace - -调整内存空间容量 -""" - - -class ResizeUDredisSpaceRequestSchema(schema.RequestSchema): - """ ResizeUDredisSpace - 调整内存空间容量 - """ - - fields = { - "CouponId": fields.Str(required=False, dump_to="CouponId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Size": fields.Int(required=True, dump_to="Size"), - "SpaceId": fields.Str(required=True, dump_to="SpaceId"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class ResizeUDredisSpaceResponseSchema(schema.ResponseSchema): - """ ResizeUDredisSpace - 调整内存空间容量 - """ - - fields = {} - - -""" -API: ResizeUMemSpace - -调整内存空间容量 -""" - - -class ResizeUMemSpaceRequestSchema(schema.RequestSchema): - """ ResizeUMemSpace - 调整内存空间容量 - """ - - fields = { - "ChargeType": fields.Str(required=False, dump_to="ChargeType"), - "CouponId": fields.Str(required=False, dump_to="CouponId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Size": fields.Int(required=True, dump_to="Size"), - "SpaceId": fields.Str(required=True, dump_to="SpaceId"), - "Type": fields.Str(required=False, dump_to="Type"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class ResizeUMemSpaceResponseSchema(schema.ResponseSchema): - """ ResizeUMemSpace - 调整内存空间容量 - """ - - fields = {} - - -""" -API: ResizeURedisGroup - -调整主备redis容量 -""" - - -class ResizeURedisGroupRequestSchema(schema.RequestSchema): - """ ResizeURedisGroup - 调整主备redis容量 - """ - - fields = { - "ChargeType": fields.Str(required=False, dump_to="ChargeType"), - "CouponId": fields.Int(required=False, dump_to="CouponId"), - "GroupId": fields.Str(required=True, dump_to="GroupId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Size": fields.Int(required=True, dump_to="Size"), - "Type": fields.Str(required=False, dump_to="Type"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class ResizeURedisGroupResponseSchema(schema.ResponseSchema): - """ ResizeURedisGroup - 调整主备redis容量 - """ - - fields = {} - - -""" -API: RestartUMemcacheGroup - -重启单机Memcache -""" - - -class RestartUMemcacheGroupRequestSchema(schema.RequestSchema): - """ RestartUMemcacheGroup - 重启单机Memcache - """ - - fields = { - "GroupId": fields.Str(required=True, dump_to="GroupId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class RestartUMemcacheGroupResponseSchema(schema.ResponseSchema): - """ RestartUMemcacheGroup - 重启单机Memcache - """ - - fields = {} +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.typesystem import schema, fields +from ucloud.services.umem.schemas import models + +""" UMem API Schema +""" +""" +API: CreateUMemSpace + +创建UMem内存空间 +""" + + +class CreateUMemSpaceRequestSchema(schema.RequestSchema): + """ CreateUMemSpace - 创建UMem内存空间 + """ + + fields = { + "ChargeType": fields.Str(required=False, dump_to="ChargeType"), + "CouponId": fields.Str(required=False, dump_to="CouponId"), + "Name": fields.Str(required=True, dump_to="Name"), + "Password": fields.Base64(required=False, dump_to="Password"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Protocol": fields.Str(required=False, dump_to="Protocol"), + "Quantity": fields.Int(required=False, dump_to="Quantity"), + "Region": fields.Str(required=True, dump_to="Region"), + "Size": fields.Int(required=True, dump_to="Size"), + "SubnetId": fields.Str(required=False, dump_to="SubnetId"), + "Tag": fields.Str(required=False, dump_to="Tag"), + "Type": fields.Str(required=False, dump_to="Type"), + "VPCId": fields.Str(required=False, dump_to="VPCId"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class CreateUMemSpaceResponseSchema(schema.ResponseSchema): + """ CreateUMemSpace - 创建UMem内存空间 + """ + + fields = {"SpaceId": fields.Str(required=False, load_from="SpaceId")} + + +""" +API: CreateUMemcacheGroup + +创建单机Memcache +""" + + +class CreateUMemcacheGroupRequestSchema(schema.RequestSchema): + """ CreateUMemcacheGroup - 创建单机Memcache + """ + + fields = { + "ChargeType": fields.Str(required=False, dump_to="ChargeType"), + "ConfigId": fields.Str(required=False, dump_to="ConfigId"), + "CouponId": fields.Str(required=False, dump_to="CouponId"), + "Name": fields.Str(required=True, dump_to="Name"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Protocol": fields.Str(required=False, dump_to="Protocol"), + "Quantity": fields.Int(required=False, dump_to="Quantity"), + "Region": fields.Str(required=True, dump_to="Region"), + "Size": fields.Int(required=False, dump_to="Size"), + "SubnetId": fields.Str(required=False, dump_to="SubnetId"), + "Tag": fields.Str(required=False, dump_to="Tag"), + "VPCId": fields.Str(required=False, dump_to="VPCId"), + "Version": fields.Str(required=False, dump_to="Version"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class CreateUMemcacheGroupResponseSchema(schema.ResponseSchema): + """ CreateUMemcacheGroup - 创建单机Memcache + """ + + fields = {"GroupId": fields.Str(required=False, load_from="GroupId")} + + +""" +API: CreateURedisGroup + +创建主备redis +""" + + +class CreateURedisGroupRequestSchema(schema.RequestSchema): + """ CreateURedisGroup - 创建主备redis + """ + + fields = { + "AutoBackup": fields.Str(required=False, dump_to="AutoBackup"), + "BackupId": fields.Str(required=False, dump_to="BackupId"), + "BackupTime": fields.Int(required=False, dump_to="BackupTime"), + "ChargeType": fields.Str(required=False, dump_to="ChargeType"), + "ConfigId": fields.Str(required=False, dump_to="ConfigId"), + "CouponId": fields.Str(required=False, dump_to="CouponId"), + "HighAvailability": fields.Str( + required=True, dump_to="HighAvailability" + ), + "MasterGroupId": fields.Str(required=False, dump_to="MasterGroupId"), + "Name": fields.Str(required=True, dump_to="Name"), + "Password": fields.Base64(required=False, dump_to="Password"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Quantity": fields.Int(required=False, dump_to="Quantity"), + "Region": fields.Str(required=True, dump_to="Region"), + "Size": fields.Int(required=False, dump_to="Size"), + "SlaveZone": fields.Str(required=False, dump_to="SlaveZone"), + "SubnetId": fields.Str(required=False, dump_to="SubnetId"), + "Tag": fields.Str(required=False, dump_to="Tag"), + "VPCId": fields.Str(required=False, dump_to="VPCId"), + "Version": fields.Str(required=False, dump_to="Version"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class CreateURedisGroupResponseSchema(schema.ResponseSchema): + """ CreateURedisGroup - 创建主备redis + """ + + fields = {"GroupId": fields.Str(required=False, load_from="GroupId")} + + +""" +API: DeleteUMemSpace + +删除UMem内存空间 +""" + + +class DeleteUMemSpaceRequestSchema(schema.RequestSchema): + """ DeleteUMemSpace - 删除UMem内存空间 + """ + + fields = { + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "SpaceId": fields.Str(required=True, dump_to="SpaceId"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class DeleteUMemSpaceResponseSchema(schema.ResponseSchema): + """ DeleteUMemSpace - 删除UMem内存空间 + """ + + fields = {} + + +""" +API: DeleteUMemcacheGroup + +删除单机Memcache +""" + + +class DeleteUMemcacheGroupRequestSchema(schema.RequestSchema): + """ DeleteUMemcacheGroup - 删除单机Memcache + """ + + fields = { + "GroupId": fields.Str(required=True, dump_to="GroupId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class DeleteUMemcacheGroupResponseSchema(schema.ResponseSchema): + """ DeleteUMemcacheGroup - 删除单机Memcache + """ + + fields = {} + + +""" +API: DeleteURedisGroup + +删除主备redis +""" + + +class DeleteURedisGroupRequestSchema(schema.RequestSchema): + """ DeleteURedisGroup - 删除主备redis + """ + + fields = { + "GroupId": fields.Str(required=True, dump_to="GroupId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + } + + +class DeleteURedisGroupResponseSchema(schema.ResponseSchema): + """ DeleteURedisGroup - 删除主备redis + """ + + fields = {} + + +""" +API: DescribeUMemPrice + +获取UMem实例价格信息 +""" + + +class DescribeUMemPriceRequestSchema(schema.RequestSchema): + """ DescribeUMemPrice - 获取UMem实例价格信息 + """ + + fields = { + "ChargeType": fields.Str(required=False, dump_to="ChargeType"), + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Quantity": fields.Int(required=False, dump_to="Quantity"), + "Region": fields.Str(required=True, dump_to="Region"), + "RegionFlag": fields.Bool(required=False, dump_to="RegionFlag"), + "Size": fields.Int(required=True, dump_to="Size"), + "Type": fields.Str(required=True, dump_to="Type"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class DescribeUMemPriceResponseSchema(schema.ResponseSchema): + """ DescribeUMemPrice - 获取UMem实例价格信息 + """ + + fields = { + "DataSet": fields.List( + models.UMemPriceSetSchema(), required=False, load_from="DataSet" + ) + } + + +""" +API: DescribeUMemSpace + +获取UMem内存空间列表 +""" + + +class DescribeUMemSpaceRequestSchema(schema.RequestSchema): + """ DescribeUMemSpace - 获取UMem内存空间列表 + """ + + fields = { + "Limit": fields.Int(required=False, dump_to="Limit"), + "Offset": fields.Int(required=False, dump_to="Offset"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "SpaceId": fields.Str(required=False, dump_to="SpaceId"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class DescribeUMemSpaceResponseSchema(schema.ResponseSchema): + """ DescribeUMemSpace - 获取UMem内存空间列表 + """ + + fields = { + "DataSet": fields.List( + models.UMemSpaceSetSchema(), required=False, load_from="DataSet" + ), + "TotalCount": fields.Int(required=False, load_from="TotalCount"), + } + + +""" +API: DescribeUMemUpgradePrice + +获取UMem升级价格信息 +""" + + +class DescribeUMemUpgradePriceRequestSchema(schema.RequestSchema): + """ DescribeUMemUpgradePrice - 获取UMem升级价格信息 + """ + + fields = { + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Size": fields.Int(required=True, dump_to="Size"), + "SpaceId": fields.Str(required=True, dump_to="SpaceId"), + "Type": fields.Str(required=True, dump_to="Type"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class DescribeUMemUpgradePriceResponseSchema(schema.ResponseSchema): + """ DescribeUMemUpgradePrice - 获取UMem升级价格信息 + """ + + fields = { + "DataSet": models.PriceDataSetSchema(), + "Price": fields.Int(required=False, load_from="Price"), + } + + +""" +API: DescribeUMemcacheGroup + +显示Memcache +""" + + +class DescribeUMemcacheGroupRequestSchema(schema.RequestSchema): + """ DescribeUMemcacheGroup - 显示Memcache + """ + + fields = { + "GroupId": fields.Str(required=False, dump_to="GroupId"), + "Limit": fields.Int(required=False, dump_to="Limit"), + "Offset": fields.Int(required=False, dump_to="Offset"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class DescribeUMemcacheGroupResponseSchema(schema.ResponseSchema): + """ DescribeUMemcacheGroup - 显示Memcache + """ + + fields = { + "DataSet": fields.List( + models.UMemcacheGroupSetSchema(), + required=False, + load_from="DataSet", + ), + "TotalCount": fields.Int(required=False, load_from="TotalCount"), + } + + +""" +API: DescribeUMemcachePrice + +获取umemcache组价格信息 +""" + + +class DescribeUMemcachePriceRequestSchema(schema.RequestSchema): + """ DescribeUMemcachePrice - 获取umemcache组价格信息 + """ + + fields = { + "ChargeType": fields.Str(required=False, dump_to="ChargeType"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Quantity": fields.Int(required=False, dump_to="Quantity"), + "Region": fields.Str(required=True, dump_to="Region"), + "Size": fields.Int(required=True, dump_to="Size"), + "Type": fields.Str(required=False, dump_to="Type"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class DescribeUMemcachePriceResponseSchema(schema.ResponseSchema): + """ DescribeUMemcachePrice - 获取umemcache组价格信息 + """ + + fields = { + "DataSet": fields.List( + models.UMemcachePriceSetSchema(), + required=False, + load_from="DataSet", + ) + } + + +""" +API: DescribeUMemcacheUpgradePrice + +获取umemcache升级价格信息 +""" + + +class DescribeUMemcacheUpgradePriceRequestSchema(schema.RequestSchema): + """ DescribeUMemcacheUpgradePrice - 获取umemcache升级价格信息 + """ + + fields = { + "GroupId": fields.Str(required=True, dump_to="GroupId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Size": fields.Int(required=True, dump_to="Size"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class DescribeUMemcacheUpgradePriceResponseSchema(schema.ResponseSchema): + """ DescribeUMemcacheUpgradePrice - 获取umemcache升级价格信息 + """ + + fields = { + "DataSet": models.PriceDataSetSchema(), + "Price": fields.Int(required=False, load_from="Price"), + } + + +""" +API: DescribeURedisBackup + +查询主备redis备份 +""" + + +class DescribeURedisBackupRequestSchema(schema.RequestSchema): + """ DescribeURedisBackup - 查询主备redis备份 + """ + + fields = { + "GroupId": fields.Str(required=False, dump_to="GroupId"), + "Limit": fields.Int(required=False, dump_to="Limit"), + "Offset": fields.Int(required=False, dump_to="Offset"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + } + + +class DescribeURedisBackupResponseSchema(schema.ResponseSchema): + """ DescribeURedisBackup - 查询主备redis备份 + """ + + fields = { + "DataSet": fields.List( + models.URedisBackupSetSchema(), required=False, load_from="DataSet" + ), + "TotalCount": fields.Int(required=False, load_from="TotalCount"), + } + + +""" +API: DescribeURedisBackupURL + +获取主备Redis备份下载链接 +""" + + +class DescribeURedisBackupURLRequestSchema(schema.RequestSchema): + """ DescribeURedisBackupURL - 获取主备Redis备份下载链接 + """ + + fields = { + "BackupId": fields.Str(required=True, dump_to="BackupId"), + "GroupId": fields.Str(required=False, dump_to="GroupId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "RegionFlag": fields.Bool(required=False, dump_to="RegionFlag"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class DescribeURedisBackupURLResponseSchema(schema.ResponseSchema): + """ DescribeURedisBackupURL - 获取主备Redis备份下载链接 + """ + + fields = { + "BackupPath": fields.Str(required=False, load_from="BackupPath"), + "BackupURL": fields.Str(required=False, load_from="BackupURL"), + "InnerBackupPath": fields.Str( + required=False, load_from="InnerBackupPath" + ), + } + + +""" +API: DescribeURedisGroup + +查询主备Redis +""" + + +class DescribeURedisGroupRequestSchema(schema.RequestSchema): + """ DescribeURedisGroup - 查询主备Redis + """ + + fields = { + "GroupId": fields.Str(required=False, dump_to="GroupId"), + "Limit": fields.Int(required=False, dump_to="Limit"), + "Offset": fields.Int(required=False, dump_to="Offset"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class DescribeURedisGroupResponseSchema(schema.ResponseSchema): + """ DescribeURedisGroup - 查询主备Redis + """ + + fields = { + "DataSet": fields.List( + models.URedisGroupSetSchema(), required=False, load_from="DataSet" + ), + "TotalCount": fields.Int(required=False, load_from="TotalCount"), + } + + +""" +API: DescribeURedisPrice + +取uredis价格信息 +""" + + +class DescribeURedisPriceRequestSchema(schema.RequestSchema): + """ DescribeURedisPrice - 取uredis价格信息 + """ + + fields = { + "ChargeType": fields.Str(required=False, dump_to="ChargeType"), + "ProductType": fields.Str(required=False, dump_to="ProductType"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Quantity": fields.Int(required=False, dump_to="Quantity"), + "Region": fields.Str(required=True, dump_to="Region"), + "RegionFlag": fields.Bool(required=False, dump_to="RegionFlag"), + "Size": fields.Int(required=True, dump_to="Size"), + "Type": fields.Str(required=False, dump_to="Type"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class DescribeURedisPriceResponseSchema(schema.ResponseSchema): + """ DescribeURedisPrice - 取uredis价格信息 + """ + + fields = { + "DataSet": fields.List( + models.URedisPriceSetSchema(), required=False, load_from="DataSet" + ) + } + + +""" +API: DescribeURedisUpgradePrice + +获取uredis升级价格信息 +""" + + +class DescribeURedisUpgradePriceRequestSchema(schema.RequestSchema): + """ DescribeURedisUpgradePrice - 获取uredis升级价格信息 + """ + + fields = { + "GroupId": fields.Str(required=True, dump_to="GroupId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Size": fields.Int(required=True, dump_to="Size"), + "Type": fields.Str(required=False, dump_to="Type"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class DescribeURedisUpgradePriceResponseSchema(schema.ResponseSchema): + """ DescribeURedisUpgradePrice - 获取uredis升级价格信息 + """ + + fields = { + "DataSet": models.PriceDataSetSchema(), + "Price": fields.Int(required=False, load_from="Price"), + } + + +""" +API: GetUMemSpaceState + +获取UMem内存空间列表 +""" + + +class GetUMemSpaceStateRequestSchema(schema.RequestSchema): + """ GetUMemSpaceState - 获取UMem内存空间列表 + """ + + fields = { + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "SpaceId": fields.Str(required=True, dump_to="SpaceId"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class GetUMemSpaceStateResponseSchema(schema.ResponseSchema): + """ GetUMemSpaceState - 获取UMem内存空间列表 + """ + + fields = {"State": fields.Str(required=False, load_from="State")} + + +""" +API: ModifyUMemSpaceName + +修改UMem内存空间名称 +""" + + +class ModifyUMemSpaceNameRequestSchema(schema.RequestSchema): + """ ModifyUMemSpaceName - 修改UMem内存空间名称 + """ + + fields = { + "Name": fields.Str(required=True, dump_to="Name"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "SpaceId": fields.Str(required=True, dump_to="SpaceId"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class ModifyUMemSpaceNameResponseSchema(schema.ResponseSchema): + """ ModifyUMemSpaceName - 修改UMem内存空间名称 + """ + + fields = {} + + +""" +API: ModifyURedisGroupName + +修改主备redis名称 +""" + + +class ModifyURedisGroupNameRequestSchema(schema.RequestSchema): + """ ModifyURedisGroupName - 修改主备redis名称 + """ + + fields = { + "GroupId": fields.Str(required=True, dump_to="GroupId"), + "Name": fields.Str(required=True, dump_to="Name"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class ModifyURedisGroupNameResponseSchema(schema.ResponseSchema): + """ ModifyURedisGroupName - 修改主备redis名称 + """ + + fields = {} + + +""" +API: ResizeUDredisSpace + +调整内存空间容量 +""" + + +class ResizeUDredisSpaceRequestSchema(schema.RequestSchema): + """ ResizeUDredisSpace - 调整内存空间容量 + """ + + fields = { + "CouponId": fields.Str(required=False, dump_to="CouponId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Size": fields.Int(required=True, dump_to="Size"), + "SpaceId": fields.Str(required=True, dump_to="SpaceId"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class ResizeUDredisSpaceResponseSchema(schema.ResponseSchema): + """ ResizeUDredisSpace - 调整内存空间容量 + """ + + fields = {} + + +""" +API: ResizeUMemSpace + +调整内存空间容量 +""" + + +class ResizeUMemSpaceRequestSchema(schema.RequestSchema): + """ ResizeUMemSpace - 调整内存空间容量 + """ + + fields = { + "ChargeType": fields.Str(required=False, dump_to="ChargeType"), + "CouponId": fields.Str(required=False, dump_to="CouponId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Size": fields.Int(required=True, dump_to="Size"), + "SpaceId": fields.Str(required=True, dump_to="SpaceId"), + "Type": fields.Str(required=False, dump_to="Type"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class ResizeUMemSpaceResponseSchema(schema.ResponseSchema): + """ ResizeUMemSpace - 调整内存空间容量 + """ + + fields = {} + + +""" +API: ResizeURedisGroup + +调整主备redis容量 +""" + + +class ResizeURedisGroupRequestSchema(schema.RequestSchema): + """ ResizeURedisGroup - 调整主备redis容量 + """ + + fields = { + "ChargeType": fields.Str(required=False, dump_to="ChargeType"), + "CouponId": fields.Int(required=False, dump_to="CouponId"), + "GroupId": fields.Str(required=True, dump_to="GroupId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Size": fields.Int(required=True, dump_to="Size"), + "Type": fields.Str(required=False, dump_to="Type"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class ResizeURedisGroupResponseSchema(schema.ResponseSchema): + """ ResizeURedisGroup - 调整主备redis容量 + """ + + fields = {} + + +""" +API: RestartUMemcacheGroup + +重启单机Memcache +""" + + +class RestartUMemcacheGroupRequestSchema(schema.RequestSchema): + """ RestartUMemcacheGroup - 重启单机Memcache + """ + + fields = { + "GroupId": fields.Str(required=True, dump_to="GroupId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class RestartUMemcacheGroupResponseSchema(schema.ResponseSchema): + """ RestartUMemcacheGroup - 重启单机Memcache + """ + + fields = {} diff --git a/ucloud/services/umem/schemas/models.py b/ucloud/services/umem/schemas/models.py index 3c4a9ac..57d7f23 100644 --- a/ucloud/services/umem/schemas/models.py +++ b/ucloud/services/umem/schemas/models.py @@ -1,143 +1,159 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.typesystem import schema, fields - - -class UMemPriceSetSchema(schema.ResponseSchema): - """ UMemPriceSet - DescribeUMemPrice - """ - - fields = { - "ChargeType": fields.Str(required=False, load_from="ChargeType"), - "Price": fields.Float(required=False, load_from="Price"), - } - - -class UMemSpaceAddressSetSchema(schema.ResponseSchema): - """ UMemSpaceAddressSet - DescribeUMemSpace - """ - - fields = { - "IP": fields.Str(required=False, load_from="IP"), - "Port": fields.Int(required=False, load_from="Port"), - } - - -class UMemSpaceSetSchema(schema.ResponseSchema): - """ UMemSpaceSet - DescribeUMemSpace - """ - - fields = { - "Address": fields.List(UMemSpaceAddressSetSchema()), - "ChargeType": fields.Str(required=False, load_from="ChargeType"), - "CreateTime": fields.Int(required=False, load_from="CreateTime"), - "ExpireTime": fields.Int(required=False, load_from="ExpireTime"), - "Name": fields.Str(required=False, load_from="Name"), - "Protocol": fields.Str(required=False, load_from="Protocol"), - "RewriteTime": fields.Int(required=True, load_from="RewriteTime"), - "Size": fields.Int(required=False, load_from="Size"), - "SpaceId": fields.Str(required=False, load_from="SpaceId"), - "State": fields.Str(required=False, load_from="State"), - "SubnetId": fields.Str(required=False, load_from="SubnetId"), - "Tag": fields.Str(required=True, load_from="Tag"), - "Type": fields.Str(required=False, load_from="Type"), - "UsedSize": fields.Int(required=False, load_from="UsedSize"), - "VPCId": fields.Str(required=False, load_from="VPCId"), - "Zone": fields.Str(required=False, load_from="Zone"), - } - - -class UMemcacheGroupSetSchema(schema.ResponseSchema): - """ UMemcacheGroupSet - DescribeUMemcacheGroup - """ - - fields = { - "ChargeType": fields.Str(required=False, load_from="ChargeType"), - "ConfigId": fields.Str(required=False, load_from="ConfigId"), - "CreateTime": fields.Int(required=False, load_from="CreateTime"), - "ExpireTime": fields.Int(required=False, load_from="ExpireTime"), - "GroupId": fields.Str(required=False, load_from="GroupId"), - "ModifyTime": fields.Int(required=False, load_from="ModifyTime"), - "Name": fields.Str(required=False, load_from="Name"), - "Port": fields.Int(required=False, load_from="Port"), - "Size": fields.Int(required=False, load_from="Size"), - "State": fields.Str(required=False, load_from="State"), - "SubnetId": fields.Str(required=False, load_from="SubnetId"), - "Tag": fields.Str(required=False, load_from="Tag"), - "UsedSize": fields.Int(required=False, load_from="UsedSize"), - "VPCId": fields.Str(required=False, load_from="VPCId"), - "Version": fields.Str(required=False, load_from="Version"), - "VirtualIP": fields.Str(required=False, load_from="VirtualIP"), - } - - -class UMemcachePriceSetSchema(schema.ResponseSchema): - """ UMemcachePriceSet - DescribeUMemcachePrice - """ - - fields = { - "ChargeType": fields.Str(required=False, load_from="ChargeType"), - "Price": fields.Float(required=False, load_from="Price"), - } - - -class URedisBackupSetSchema(schema.ResponseSchema): - """ URedisBackupSet - DescribeURedisBackup - """ - - fields = { - "BackupId": fields.Str(required=False, load_from="BackupId"), - "BackupName": fields.Str(required=False, load_from="BackupName"), - "BackupSize": fields.Int(required=False, load_from="BackupSize"), - "BackupTime": fields.Int(required=False, load_from="BackupTime"), - "BackupType": fields.Str(required=False, load_from="BackupType"), - "GroupId": fields.Str(required=False, load_from="GroupId"), - "GroupName": fields.Str(required=False, load_from="GroupName"), - "State": fields.Str(required=False, load_from="State"), - "Zone": fields.Str(required=False, load_from="Zone"), - } - - -class URedisGroupSetSchema(schema.ResponseSchema): - """ URedisGroupSet - DescribeURedisGroup - """ - - fields = { - "AutoBackup": fields.Str(required=False, load_from="AutoBackup"), - "BackupTime": fields.Int(required=False, load_from="BackupTime"), - "ChargeType": fields.Str(required=False, load_from="ChargeType"), - "ConfigId": fields.Str(required=False, load_from="ConfigId"), - "CreateTime": fields.Int(required=False, load_from="CreateTime"), - "ExpireTime": fields.Int(required=False, load_from="ExpireTime"), - "GroupId": fields.Str(required=False, load_from="GroupId"), - "GroupName": fields.Str(required=False, load_from="GroupName"), - "HighAvailability": fields.Str(required=False, load_from="HighAvailability"), - "MemorySize": fields.Int(required=False, load_from="MemorySize"), - "ModifyTime": fields.Int(required=False, load_from="ModifyTime"), - "Name": fields.Str(required=False, load_from="Name"), - "Port": fields.Int(required=False, load_from="Port"), - "Protocol": fields.Str(required=False, load_from="Protocol"), - "RewriteTime": fields.Int(required=True, load_from="RewriteTime"), - "Size": fields.Int(required=False, load_from="Size"), - "SlaveZone": fields.Str(required=False, load_from="SlaveZone"), - "State": fields.Str(required=False, load_from="State"), - "SubnetId": fields.Str(required=False, load_from="SubnetId"), - "Tag": fields.Str(required=False, load_from="Tag"), - "Type": fields.Str(required=False, load_from="Type"), - "UsedSize": fields.Int(required=False, load_from="UsedSize"), - "VPCId": fields.Str(required=True, load_from="VPCId"), - "Version": fields.Str(required=False, load_from="Version"), - "VirtualIP": fields.Str(required=False, load_from="VirtualIP"), - "Zone": fields.Str(required=False, load_from="Zone"), - } - - -class URedisPriceSetSchema(schema.ResponseSchema): - """ URedisPriceSet - 主备Redis价格 - """ - - fields = { - "ChargeType": fields.Str(required=False, load_from="ChargeType"), - "Price": fields.Float(required=False, load_from="Price"), - } +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.typesystem import schema, fields + + +class UMemPriceSetSchema(schema.ResponseSchema): + """ UMemPriceSet - DescribeUMemPrice + """ + + fields = { + "ChargeType": fields.Str(required=False, load_from="ChargeType"), + "OriginalPrice": fields.Int(required=False, load_from="OriginalPrice"), + "Price": fields.Int(required=False, load_from="Price"), + } + + +class UMemSpaceAddressSetSchema(schema.ResponseSchema): + """ UMemSpaceAddressSet - DescribeUMemSpace + """ + + fields = { + "IP": fields.Str(required=False, load_from="IP"), + "Port": fields.Int(required=False, load_from="Port"), + } + + +class UMemSpaceSetSchema(schema.ResponseSchema): + """ UMemSpaceSet - DescribeUMemSpace + """ + + fields = { + "Address": fields.List(UMemSpaceAddressSetSchema()), + "ChargeType": fields.Str(required=False, load_from="ChargeType"), + "CreateTime": fields.Int(required=False, load_from="CreateTime"), + "ExpireTime": fields.Int(required=False, load_from="ExpireTime"), + "Name": fields.Str(required=False, load_from="Name"), + "Protocol": fields.Str(required=False, load_from="Protocol"), + "RewriteTime": fields.Int(required=True, load_from="RewriteTime"), + "Size": fields.Int(required=False, load_from="Size"), + "SpaceId": fields.Str(required=False, load_from="SpaceId"), + "State": fields.Str(required=False, load_from="State"), + "SubnetId": fields.Str(required=False, load_from="SubnetId"), + "Tag": fields.Str(required=True, load_from="Tag"), + "Type": fields.Str(required=False, load_from="Type"), + "UsedSize": fields.Int(required=False, load_from="UsedSize"), + "VPCId": fields.Str(required=False, load_from="VPCId"), + "Zone": fields.Str(required=False, load_from="Zone"), + } + + +class PriceDataSetSchema(schema.ResponseSchema): + """ PriceDataSet - 升降级价格 + """ + + fields = { + "CustomPrice": fields.Int(required=False, load_from="CustomPrice"), + "PurchaseValue": fields.Int(required=False, load_from="PurchaseValue"), + "TotalPrice": fields.Int(required=False, load_from="TotalPrice"), + } + + +class UMemcacheGroupSetSchema(schema.ResponseSchema): + """ UMemcacheGroupSet - DescribeUMemcacheGroup + """ + + fields = { + "ChargeType": fields.Str(required=False, load_from="ChargeType"), + "ConfigId": fields.Str(required=False, load_from="ConfigId"), + "CreateTime": fields.Int(required=False, load_from="CreateTime"), + "ExpireTime": fields.Int(required=False, load_from="ExpireTime"), + "GroupId": fields.Str(required=False, load_from="GroupId"), + "ModifyTime": fields.Int(required=False, load_from="ModifyTime"), + "Name": fields.Str(required=False, load_from="Name"), + "Port": fields.Int(required=False, load_from="Port"), + "Size": fields.Int(required=False, load_from="Size"), + "State": fields.Str(required=False, load_from="State"), + "SubnetId": fields.Str(required=False, load_from="SubnetId"), + "Tag": fields.Str(required=False, load_from="Tag"), + "UsedSize": fields.Int(required=False, load_from="UsedSize"), + "VPCId": fields.Str(required=False, load_from="VPCId"), + "Version": fields.Str(required=False, load_from="Version"), + "VirtualIP": fields.Str(required=False, load_from="VirtualIP"), + } + + +class UMemcachePriceSetSchema(schema.ResponseSchema): + """ UMemcachePriceSet - DescribeUMemcachePrice + """ + + fields = { + "ChargeType": fields.Str(required=False, load_from="ChargeType"), + "OriginalPrice": fields.Int(required=False, load_from="OriginalPrice"), + "Price": fields.Int(required=False, load_from="Price"), + } + + +class URedisBackupSetSchema(schema.ResponseSchema): + """ URedisBackupSet - DescribeURedisBackup + """ + + fields = { + "BackupId": fields.Str(required=False, load_from="BackupId"), + "BackupName": fields.Str(required=False, load_from="BackupName"), + "BackupSize": fields.Int(required=False, load_from="BackupSize"), + "BackupTime": fields.Int(required=False, load_from="BackupTime"), + "BackupType": fields.Str(required=False, load_from="BackupType"), + "GroupId": fields.Str(required=False, load_from="GroupId"), + "GroupName": fields.Str(required=False, load_from="GroupName"), + "State": fields.Str(required=False, load_from="State"), + "Zone": fields.Str(required=False, load_from="Zone"), + } + + +class URedisGroupSetSchema(schema.ResponseSchema): + """ URedisGroupSet - DescribeURedisGroup + """ + + fields = { + "AutoBackup": fields.Str(required=False, load_from="AutoBackup"), + "BackupTime": fields.Int(required=False, load_from="BackupTime"), + "ChargeType": fields.Str(required=False, load_from="ChargeType"), + "ConfigId": fields.Str(required=False, load_from="ConfigId"), + "CreateTime": fields.Int(required=False, load_from="CreateTime"), + "ExpireTime": fields.Int(required=False, load_from="ExpireTime"), + "GroupId": fields.Str(required=False, load_from="GroupId"), + "GroupName": fields.Str(required=False, load_from="GroupName"), + "HighAvailability": fields.Str( + required=False, load_from="HighAvailability" + ), + "MemorySize": fields.Int(required=False, load_from="MemorySize"), + "ModifyTime": fields.Int(required=False, load_from="ModifyTime"), + "Name": fields.Str(required=False, load_from="Name"), + "Port": fields.Int(required=False, load_from="Port"), + "Protocol": fields.Str(required=False, load_from="Protocol"), + "RewriteTime": fields.Int(required=True, load_from="RewriteTime"), + "Size": fields.Int(required=False, load_from="Size"), + "SlaveZone": fields.Str(required=False, load_from="SlaveZone"), + "State": fields.Str(required=False, load_from="State"), + "SubnetId": fields.Str(required=False, load_from="SubnetId"), + "Tag": fields.Str(required=False, load_from="Tag"), + "Type": fields.Str(required=False, load_from="Type"), + "UsedSize": fields.Int(required=False, load_from="UsedSize"), + "VPCId": fields.Str(required=True, load_from="VPCId"), + "Version": fields.Str(required=False, load_from="Version"), + "VirtualIP": fields.Str(required=False, load_from="VirtualIP"), + "Zone": fields.Str(required=False, load_from="Zone"), + } + + +class URedisPriceSetSchema(schema.ResponseSchema): + """ URedisPriceSet - 主备Redis价格 + """ + + fields = { + "ChargeType": fields.Str(required=False, load_from="ChargeType"), + "OriginalPrice": fields.Int(required=True, load_from="OriginalPrice"), + "Price": fields.Int(required=False, load_from="Price"), + } diff --git a/ucloud/services/unet/__init__.py b/ucloud/services/unet/__init__.py index 4c48b5a..40a96af 100644 --- a/ucloud/services/unet/__init__.py +++ b/ucloud/services/unet/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- diff --git a/ucloud/services/unet/client.py b/ucloud/services/unet/client.py index b56727b..e925f68 100644 --- a/ucloud/services/unet/client.py +++ b/ucloud/services/unet/client.py @@ -1,928 +1,932 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.client import Client -from ucloud.services.unet.schemas import apis - - -class UNetClient(Client): - def __init__(self, config, transport=None, middleware=None, logger=None): - super(UNetClient, self).__init__(config, transport, middleware, logger) - - def allocate_eip(self, req=None, **kwargs): - """ AllocateEIP - 根据提供信息, 申请弹性IP - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 - - **Region** (str) - (Config) 地域。 - - **Bandwidth** (int) - (Required) 弹性IP的外网带宽, 单位为Mbps. 共享带宽模式必须指定0M带宽, 非共享带宽模式必须指定非0Mbps带宽. 各地域非共享带宽的带宽范围如下: 流量计费[1-200],带宽计费[1-800] - - **OperatorName** (str) - (Required) 弹性IP的线路如下: 国际: International BGP: Bgp 各地域允许的线路参数如下: cn-sh1: Bgp cn-sh2: Bgp cn-gd: Bgp cn-bj1: Bgp cn-bj2: Bgp hk: International us-ca: International th-bkk: International kr-seoul:International us-ws:International ge-fra:International sg:International tw-kh:International.其他海外线路均为 International - - **ChargeType** (str) - 付费方式, 枚举值为: Year, 按年付费; Month, 按月付费; Dynamic, 按需付费(需开启权限); Trial, 试用(需开启权限) 默认为按月付费 - - **CouponId** (str) - 代金券ID, 默认不使用 - - **Name** (str) - 弹性IP的名称, 默认为 "EIP" - - **PayMode** (str) - 弹性IP的计费模式. 枚举值: "Traffic", 流量计费; "Bandwidth", 带宽计费; "ShareBandwidth",共享带宽模式. 默认为 "Bandwidth". - - **Quantity** (int) - 购买时长, 默认: 1 - - **Remark** (str) - 弹性IP的备注, 默认为空 - - **ShareBandwidthId** (str) - 绑定的共享带宽Id,仅当PayMode为ShareBandwidth时有效 - - **Tag** (str) - 业务组名称, 默认为 "Default" - - **Response** - - - **EIPSet** (list) - 见 **UnetAllocateEIPSet** 模型定义 - - **Response Model** - - **UnetEIPAddrSet** - - - **IP** (str) - IP地址 - - **OperatorName** (str) - 运营商信息如: 电信: Telecom, 联通: Unicom, 国际: International, Duplet: 双线IP(电信+联通), BGP: Bgp - - **UnetAllocateEIPSet** - - - **EIPAddr** (list) - 见 **UnetEIPAddrSet** 模型定义 - - **EIPId** (str) - 申请到的EIP资源ID - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.AllocateEIPRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("AllocateEIP", d, **kwargs) - return apis.AllocateEIPResponseSchema().loads(resp) - - def allocate_share_bandwidth(self, req=None, **kwargs): - """ AllocateShareBandwidth - 开通共享带宽 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **ChargeType** (str) - (Required) 付费方式:Year 按年,Month 按月,Dynamic 按时; - - **Name** (str) - (Required) 共享带宽名字 - - **ShareBandwidth** (int) - (Required) 共享带宽值 - - **BwType** (str) - 共享带宽类型,ipv4或者ipv6,不传默认ipv4 - - **Quantity** (int) - 购买时长 - - **ShareBandwidthGuarantee** (int) - 共享带宽保底值(后付费) - - **Response** - - - **ShareBandwidthId** (str) - 共享带宽资源Id - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.AllocateShareBandwidthRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("AllocateShareBandwidth", d, **kwargs) - return apis.AllocateShareBandwidthResponseSchema().loads(resp) - - def allocate_vip(self, req=None, **kwargs): - """ AllocateVIP - 根据提供信息,申请内网VIP(Virtual IP),多用于高可用程序作为漂移IP。 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域 - - **SubnetId** (str) - (Required) 子网id - - **VPCId** (str) - (Required) 指定vip所属的VPC - - **BusinessId** (str) - 业务组 - - **Count** (int) - 申请数量,默认: 1 - - **Ip** (str) - 指定ip - - **Name** (str) - vip名,默认为VIP - - **Remark** (str) - 备注 - - **Tag** (str) - 业务组名称,默认为Default - - **Zone** (str) - 可用区 - - **Response** - - - **DataSet** (list) - 申请到的VIP地址 - - **VIPSet** (list) - 见 **VIPSet** 模型定义 - - **Response Model** - - **VIPSet** - - - **VIP** (str) - 虚拟ip - - **VIPId** (str) - 虚拟ip id - - **VPCId** (str) - VPC id - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.AllocateVIPRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("AllocateVIP", d, **kwargs) - return apis.AllocateVIPResponseSchema().loads(resp) - - def associate_eip_with_share_bandwidth(self, req=None, **kwargs): - """ AssociateEIPWithShareBandwidth - 将EIP加入共享带宽 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 - - **Region** (str) - (Config) 地域。 - - **EIPIds** (list) - (Required) 要加入共享带宽的EIP的资源Id - - **ShareBandwidthId** (str) - (Required) 共享带宽ID - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.AssociateEIPWithShareBandwidthRequestSchema().dumps(d) - resp = self.invoke("AssociateEIPWithShareBandwidth", d, **kwargs) - return apis.AssociateEIPWithShareBandwidthResponseSchema().loads(resp) - - def bind_eip(self, req=None, **kwargs): - """ BindEIP - 将尚未使用的弹性IP绑定到指定的资源 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写 - - **Region** (str) - (Config) 地域 - - **EIPId** (str) - (Required) 弹性IP的资源Id - - **ResourceId** (str) - (Required) 弹性IP请求绑定的资源ID - - **ResourceType** (str) - (Required) 弹性IP请求绑定的资源类型, 枚举值为: uhost: 云主机; ulb, 负载均衡器 upm: 物理机; hadoophost: 大数据集群;fortresshost:堡垒机;udockhost:容器;udhost:私有专区主机;natgw:natgw;udb:udb;vpngw:ipsec vpn;ucdr:云灾备;dbaudit:数据库审计;uni:虚拟网卡。 - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.BindEIPRequestSchema().dumps(d) - resp = self.invoke("BindEIP", d, **kwargs) - return apis.BindEIPResponseSchema().loads(resp) - - def create_bandwidth_package(self, req=None, **kwargs): - """ CreateBandwidthPackage - 为非共享带宽模式下, 已绑定资源实例的带宽计费弹性IP附加临时带宽包 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 - - **Region** (str) - (Config) 地域 - - **Bandwidth** (int) - (Required) 带宽大小(单位Mbps), 取值范围[2,800] (最大值受地域限制) - - **EIPId** (str) - (Required) 所绑定弹性IP的资源ID - - **TimeRange** (int) - (Required) 带宽包有效时长, 取值范围为大于0的整数, 即该带宽包在EnableTime到 EnableTime+TimeRange时间段内生效 - - **CouponId** (str) - 代金券ID - - **EnableTime** (int) - 生效时间, 格式为 Unix timestamp, 默认为立即开通 - - **Response** - - - **BandwidthPackageId** (str) - 所创建带宽包的资源ID - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.CreateBandwidthPackageRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("CreateBandwidthPackage", d, **kwargs) - return apis.CreateBandwidthPackageResponseSchema().loads(resp) - - def create_firewall(self, req=None, **kwargs): - """ CreateFirewall - 创建防火墙 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写 - - **Region** (str) - (Config) 地域 - - **Name** (str) - (Required) 防火墙名称 - - **Rule** (list) - (Required) 防火墙规则,例如:TCP|22|192.168.1.1/22|DROP|LOW|禁用22端口,第一个参数代表协议:第二个参数代表端口号,第三个参数为ip,第四个参数为ACCEPT(接受)和DROP(拒绝),第五个参数优先级:HIGH(高),MEDIUM(中),LOW(低),第六个参数为该条规则的自定义备注 - - **Remark** (str) - 防火墙描述,默认为空 - - **Tag** (str) - 防火墙业务组,默认为Default - - **Response** - - - **FWId** (str) - 防火墙ID - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.CreateFirewallRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("CreateFirewall", d, **kwargs) - return apis.CreateFirewallResponseSchema().loads(resp) - - def delete_bandwidth_package(self, req=None, **kwargs): - """ DeleteBandwidthPackage - 删除弹性IP上已附加带宽包 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写 - - **Region** (str) - (Config) 地域 - - **BandwidthPackageId** (str) - (Required) 带宽包资源ID - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DeleteBandwidthPackageRequestSchema().dumps(d) - resp = self.invoke("DeleteBandwidthPackage", d, **kwargs) - return apis.DeleteBandwidthPackageResponseSchema().loads(resp) - - def delete_firewall(self, req=None, **kwargs): - """ DeleteFirewall - 删除防火墙 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写 - - **Region** (str) - (Config) 地域 - - **FWId** (str) - (Required) 防火墙资源ID - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DeleteFirewallRequestSchema().dumps(d) - resp = self.invoke("DeleteFirewall", d, **kwargs) - return apis.DeleteFirewallResponseSchema().loads(resp) - - def describe_bandwidth_package(self, req=None, **kwargs): - """ DescribeBandwidthPackage - 获取某地域下的带宽包信息 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Limit** (int) - 返回数据分页值, 取值范围为 [0,10000000] 之间的整数, 默认为20 - - **Offset** (int) - 返回数据偏移量, 默认为0 - - **Response** - - - **DataSets** (list) - 见 **UnetBandwidthPackageSet** 模型定义 - - **TotalCount** (int) - 满足条件的带宽包总数 - - **Response Model** - - **EIPAddrSet** - - - **IP** (str) - 弹性IP地址 - - **OperatorName** (str) - 运营商信息, 枚举值为: Telecom 电信; Unicom: 联通; Duplet: 双线; Bgp: BGP; International: 国际. - - **UnetBandwidthPackageSet** - - - **Bandwidth** (int) - 带宽包的临时带宽值, 单位Mbps - - **BandwidthPackageId** (str) - 带宽包的资源ID - - **CreateTime** (int) - 创建时间, 格式为 Unix Timestamp - - **DisableTime** (int) - 失效时间, 格式为 Unix Timestamp - - **EIPAddr** (list) - 见 **EIPAddrSet** 模型定义 - - **EIPId** (str) - 带宽包所绑定弹性IP的资源ID - - **EnableTime** (int) - 生效时间, 格式为 Unix Timestamp - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeBandwidthPackageRequestSchema().dumps(d) - resp = self.invoke("DescribeBandwidthPackage", d, **kwargs) - return apis.DescribeBandwidthPackageResponseSchema().loads(resp) - - def describe_bandwidth_usage(self, req=None, **kwargs): - """ DescribeBandwidthUsage - 获取带宽用量信息 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **EIPIds** (list) - 弹性IP的资源Id. 如果为空, 则返回当前 Region中符合条件的所有EIP的带宽用量, n为自然数 - - **Limit** (int) - 返回数据分页值, 取值范围为 [0,10000000] 之间的整数, 默认为20 - - **OffSet** (int) - 返回数据偏移量, 默认为0 - - **Response** - - - **EIPSet** (list) - 见 **UnetBandwidthUsageEIPSet** 模型定义 - - **TotalCount** (int) - EIPSet中的元素个数 - - **Response Model** - - **UnetBandwidthUsageEIPSet** - - - **CurBandwidth** (float) - 最近5分钟带宽用量, 单位Mbps - - **EIPId** (str) - 弹性IP资源ID - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeBandwidthUsageRequestSchema().dumps(d) - resp = self.invoke("DescribeBandwidthUsage", d, **kwargs) - return apis.DescribeBandwidthUsageResponseSchema().loads(resp) - - def describe_eip(self, req=None, **kwargs): - """ DescribeEIP - 获取弹性IP信息 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写 - - **Region** (str) - (Config) 地域 - - **EIPIds** (list) - 弹性IP的资源ID如果为空, 则返回当前 Region中符合条件的的所有EIP - - **Limit** (int) - 数据分页值, 默认为20 - - **Offset** (int) - 数据偏移量, 默认为0 - - **Response** - - - **EIPSet** (list) - 见 **UnetEIPSet** 模型定义 - - **TotalBandwidth** (int) - 满足条件的弹性IP带宽总和, 单位Mbps - - **TotalCount** (int) - 满足条件的弹性IP总数 - - **Response Model** - - **ShareBandwidthSet** - - - **ShareBandwidth** (int) - 共享带宽带宽值 - - **ShareBandwidthId** (str) - 共享带宽ID - - **ShareBandwidthName** (str) - 共享带宽的资源名称 - - **UnetEIPAddrSet** - - - **IP** (str) - IP地址 - - **OperatorName** (str) - 运营商信息如: 电信: Telecom, 联通: Unicom, 国际: International, Duplet: 双线IP(电信+联通), BGP: Bgp - - **UnetEIPResourceSet** - - - **EIPId** (str) - 弹性IP的资源ID - - **ResourceId** (str) - 已绑定资源的资源ID - - **ResourceName** (str) - 已绑定的资源名称 - - **ResourceType** (str) - 已绑定的资源类型, 枚举值为: uhost, 云主机;natgw:NAT网关;ulb:负载均衡器;upm: 物理机; hadoophost: 大数据集群;fortresshost:堡垒机;udockhost:容器;udhost:私有专区主机;vpngw:IPSec VPN;ucdr:云灾备;dbaudit:数据库审计,uni:虚拟网卡。 - - **SubResourceId** (str) - 资源绑定的虚拟网卡的ID - - **SubResourceName** (str) - 资源绑定的虚拟网卡的名称 - - **SubResourceType** (str) - 资源绑定的虚拟网卡的类型。uni,虚拟网卡。 - - **UnetEIPSet** - - - **Bandwidth** (int) - 弹性IP的带宽, 单位为Mbps, 当BandwidthType=1时, 该处显示为共享带宽值. 当BandwidthType=0时, 该处显示这个弹性IP的带宽. - - **BandwidthType** (int) - 带宽模式, 枚举值为: 0: 非共享带宽模式, 1: 共享带宽模式 - - **ChargeType** (str) - 付费方式, 枚举值为: Year, 按年付费; Month, 按月付费; Dynamic, 按小时付费; Trial, 试用. 按小时付费和试用这两种付费模式需要开通权限. - - **CreateTime** (int) - 弹性IP的创建时间, 格式为Unix Timestamp - - **EIPAddr** (list) - 见 **UnetEIPAddrSet** 模型定义 - - **EIPId** (str) - 弹性IP的资源ID - - **Expire** (bool) - 弹性IP是否到期 - - **ExpireTime** (int) - 弹性IP的到期时间, 格式为Unix Timestamp - - **Name** (str) - 弹性IP的名称,缺省值为 "EIP" - - **PayMode** (str) - 弹性IP的计费模式, 枚举值为: "Bandwidth", 带宽计费; "Traffic", 流量计费; "ShareBandwidth",共享带宽模式. 默认为 "Bandwidth". - - **Remark** (str) - 弹性IP的备注, 缺省值为 "" - - **Resource** (dict) - 见 **UnetEIPResourceSet** 模型定义 - - **ShareBandwidthSet** (dict) - 见 **ShareBandwidthSet** 模型定义 - - **Status** (str) - 弹性IP的资源绑定状态, 枚举值为: used: 已绑定, free: 未绑定, freeze: 已冻结 - - **Tag** (str) - 弹性IP的业务组标识, 缺省值为 "Default" - - **Weight** (int) - 外网出口权重, 默认为50, 范围[0-100] - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeEIPRequestSchema().dumps(d) - resp = self.invoke("DescribeEIP", d, **kwargs) - return apis.DescribeEIPResponseSchema().loads(resp) - - def describe_firewall(self, req=None, **kwargs): - """ DescribeFirewall - 获取防火墙组信息 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写 - - **Region** (str) - (Config) 地域 - - **FWId** (str) - 防火墙ID,默认为返回所有防火墙 - - **Limit** (int) - 返回数据长度,默认为20,最大10000000 - - **Offset** (int) - 列表起始位置偏移量,默认为0 - - **ResourceId** (str) - 绑定防火墙组的资源ID - - **ResourceType** (str) - 绑定防火墙组的资源类型,默认为全部资源类型。枚举值为:"unatgw",NAT网关; "uhost",云主机; "upm",物理云主机; "hadoophost",hadoop节点; "fortresshost",堡垒机; "udhost",私有专区主机;"udockhost",容器;"dbaudit",数据库审计. - - **Response** - - - **DataSet** (list) - 见 **FirewallDataSet** 模型定义 - - **TotalCount** (int) - - - **Response Model** - - **FirewallRuleSet** - - - **DstPort** (str) - 目标端口 - - **Priority** (str) - 优先级 - - **ProtocolType** (str) - 协议类型 - - **Remark** (str) - 防火墙规则备注 - - **RuleAction** (str) - 防火墙动作 - - **SrcIP** (str) - 源地址 - - **FirewallDataSet** - - - **CreateTime** (int) - 防火墙组创建时间,格式为Unix Timestamp - - **FWId** (str) - 防火墙ID - - **GroupId** (str) - 安全组ID(即将废弃) - - **Name** (str) - 防火墙名称 - - **Remark** (str) - 防火墙备注 - - **ResourceCount** (int) - 防火墙绑定资源数量 - - **Rule** (list) - 见 **FirewallRuleSet** 模型定义 - - **Tag** (str) - 防火墙业务组 - - **Type** (str) - 防火墙组类型,枚举值为: "user defined", 用户自定义防火墙; "recommend web", 默认Web防火墙; "recommend non web", 默认非Web防火墙 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeFirewallRequestSchema().dumps(d) - resp = self.invoke("DescribeFirewall", d, **kwargs) - return apis.DescribeFirewallResponseSchema().loads(resp) - - def describe_firewall_resource(self, req=None, **kwargs): - """ DescribeFirewallResource - 获取防火墙组所绑定资源的外网IP - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **FWId** (str) - (Required) 防火墙ID - - **Limit** (int) - 返回数据长度,默认为20,最大10000000 - - **Offset** (int) - 列表起始位置偏移量,默认为0 - - **Response** - - - **ResourceSet** (list) - 见 **ResourceSet** 模型定义 - - **TotalCount** (int) - 绑定资源总数 - - **Response Model** - - **ResourceSet** - - - **Name** (str) - 名称 - - **PrivateIP** (str) - 内网IP - - **Remark** (str) - 备注 - - **ResourceID** (str) - 绑定该防火墙的资源id - - **ResourceType** (str) - 绑定资源的资源类型,如"uhost","upm","umem","uhive","uvip","uredis","uhadoop","ufortress","dbaudit","udw","udocker", "umemcache" - - **Status** (int) - 状态 - - **Tag** (str) - 业务组 - - **Zone** (int) - 可用区 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeFirewallResourceRequestSchema().dumps(d) - resp = self.invoke("DescribeFirewallResource", d, **kwargs) - return apis.DescribeFirewallResourceResponseSchema().loads(resp) - - def describe_share_bandwidth(self, req=None, **kwargs): - """ DescribeShareBandwidth - 获取共享带宽信息 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **ShareBandwidthIds** (list) - 需要返回的共享带宽Id - - **Response** - - - **DataSet** (list) - 见 **UnetShareBandwidthSet** 模型定义 - - **TotalCount** (int) - 符合条件的共享带宽总数,大于等于返回DataSet长度 - - **Response Model** - - **EIPAddrSet** - - - **IP** (str) - 弹性IP地址 - - **OperatorName** (str) - 运营商信息, 枚举值为: Telecom 电信; Unicom: 联通; Duplet: 双线; Bgp: BGP; International: 国际. - - **EIPSetData** - - - **Bandwidth** (int) - EIP带宽值 - - **EIPAddr** (list) - 见 **EIPAddrSet** 模型定义 - - **EIPId** (str) - EIP资源Id - - **UnetShareBandwidthSet** - - - **BandwidthGuarantee** (int) - 共享带宽保底值(后付费) - - **ChargeType** (str) - 付费方式, 预付费:Year 按年,Month 按月,Dynamic 按需;后付费:PostPay(按月) - - **CreateTime** (int) - 创建时间, 格式为Unix Timestamp - - **EIPSet** (list) - 见 **EIPSetData** 模型定义 - - **ExpireTime** (int) - 过期时间, 格式为Unix Timestamp - - **Name** (str) - 共享带宽名称 - - **PostPayStartTime** (int) - 共享带宽后付费开始计费时间(后付费) - - **ShareBandwidth** (int) - 共享带宽值(预付费)/共享带宽峰值(后付费), 单位Mbps - - **ShareBandwidthId** (str) - 共享带宽的资源ID - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeShareBandwidthRequestSchema().dumps(d) - resp = self.invoke("DescribeShareBandwidth", d, **kwargs) - return apis.DescribeShareBandwidthResponseSchema().loads(resp) - - def describe_vip(self, req=None, **kwargs): - """ DescribeVIP - 获取内网VIP详细信息 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **BusinessId** (str) - 业务组 - - **SubnetId** (str) - 子网id,不指定则获取VPCId下的所有vip - - **Tag** (str) - 业务组名称, 默认为 Default - - **VPCId** (str) - vpc的id,指定SubnetId时必填 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **DataSet** (list) - 内网VIP地址列表 - - **TotalCount** (int) - vip数量 - - **VIPSet** (list) - 见 **VIPDetailSet** 模型定义 - - **Response Model** - - **VIPDetailSet** - - - **CreateTime** (int) - 创建时间 - - **Name** (str) - - - **RealIp** (str) - 真实主机ip - - **SubnetId** (str) - 子网id - - **VIP** (str) - 虚拟ip - - **VIPId** (str) - 虚拟ip id - - **VPCId** (str) - VPC id - - **Zone** (str) - 地域 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeVIPRequestSchema().dumps(d) - resp = self.invoke("DescribeVIP", d, **kwargs) - return apis.DescribeVIPResponseSchema().loads(resp) - - def disassociate_eip_with_share_bandwidth(self, req=None, **kwargs): - """ DisassociateEIPWithShareBandwidth - 将EIP移出共享带宽 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Bandwidth** (int) - (Required) 移出共享带宽后,EIP的外网带宽, 单位为Mbps. 各地域带宽范围如下: 流量计费[1-200],带宽计费[1-800] - - **ShareBandwidthId** (str) - (Required) 共享带宽ID - - **EIPIds** (list) - EIP的资源Id;默认移出该共享带宽下所有的EIP - - **PayMode** (str) - 移出共享带宽后,EIP的计费模式. 枚举值: "Traffic", 流量计费; "Bandwidth", 带宽计费; 默认为 "Bandwidth". - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DisassociateEIPWithShareBandwidthRequestSchema().dumps(d) - resp = self.invoke("DisassociateEIPWithShareBandwidth", d, **kwargs) - return apis.DisassociateEIPWithShareBandwidthResponseSchema().loads(resp) - - def get_eip_pay_mode(self, req=None, **kwargs): - """ GetEIPPayMode - 获取弹性IP计费模式 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写 - - **Region** (str) - (Config) 地域 - - **EIPId** (list) - (Required) 弹性IP的资源Id - - **Response** - - - **EIPPayMode** (list) - 见 **EIPPayModeSet** 模型定义 - - **Response Model** - - **EIPPayModeSet** - - - **EIPId** (str) - EIP的资源ID - - **EIPPayMode** (str) - EIP的计费模式. 枚举值为:Bandwidth, 带宽计费;Traffic, 流量计费; "ShareBandwidth",共享带宽模式 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.GetEIPPayModeRequestSchema().dumps(d) - resp = self.invoke("GetEIPPayMode", d, **kwargs) - return apis.GetEIPPayModeResponseSchema().loads(resp) - - def get_eip_price(self, req=None, **kwargs): - """ GetEIPPrice - 获取弹性IP价格 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Bandwidth** (int) - (Required) 弹性IP的外网带宽, 单位为Mbps, 范围 [0-800] - - **OperatorName** (str) - (Required) 弹性IP的线路如下: 国际: International BGP: Bgp 各地域允许的线路参数如下: cn-sh1: Bgp cn-sh2: Bgp cn-gd: Bgp cn-bj1: Bgp cn-bj2: Bgp hk: International us-ca: International th-bkk: International kr-seoul:International us-ws:International ge-fra:International sg:International tw-kh:International.其他海外线路均为 International,泉州为移动单线cn-qz:ChinaMobile - - **ChargeType** (str) - 付费方式, 枚举值为: Year, 按年付费; Month, 按月付费; Dynamic, 按时付费; 默认为获取三种价格 - - **PayMode** (str) - 弹性IP计费方式r. 枚举值为: Traffic, 流量计费; Bandwidth, 带宽计费; "ShareBandwidth",共享带宽模式. 默认为Bandwidth - - **Quantity** (int) - 购买时长。默认: 1。按小时购买(Dynamic)时无需此参数。 月付时,此参数传0,代表了购买至月末 - - **Response** - - - **PriceSet** (list) - 见 **EIPPriceDetailSet** 模型定义 - - **Response Model** - - **EIPPriceDetailSet** - - - **ChargeType** (str) - 弹性IP付费方式 - - **Price** (float) - 弹性IP价格, 单位"元" - - **PurchaseValue** (int) - 资源有效期, 以Unix Timestamp表示 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.GetEIPPriceRequestSchema().dumps(d) - resp = self.invoke("GetEIPPrice", d, **kwargs) - return apis.GetEIPPriceResponseSchema().loads(resp) - - def get_eip_upgrade_price(self, req=None, **kwargs): - """ GetEIPUpgradePrice - 获取弹性IP带宽改动价格 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Bandwidth** (int) - (Required) 弹性IP的外网带宽, 单位为Mbps, 范围 [1-800] - - **EIPId** (str) - (Required) 弹性IP的资源ID - - **Response** - - - **Price** (float) - 调整带宽后的EIP价格, 单位为"元", 如需退费此处为负值 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.GetEIPUpgradePriceRequestSchema().dumps(d) - resp = self.invoke("GetEIPUpgradePrice", d, **kwargs) - return apis.GetEIPUpgradePriceResponseSchema().loads(resp) - - def grant_firewall(self, req=None, **kwargs): - """ GrantFirewall - 将防火墙应用到资源上 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **FWId** (str) - (Required) 防火墙资源ID - - **ResourceId** (str) - (Required) 所应用资源ID - - **ResourceType** (str) - (Required) 绑定防火墙组的资源类型,默认为全部资源类型。枚举值为:"unatgw",NAT网关; "uhost",云主机; "upm",物理云主机; "hadoophost",hadoop节点; "fortresshost",堡垒机; "udhost",私有专区主机;"udockhost",容器;"dbaudit",数据库审计,”uni“,虚拟网卡。 - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.GrantFirewallRequestSchema().dumps(d) - resp = self.invoke("GrantFirewall", d, **kwargs) - return apis.GrantFirewallResponseSchema().loads(resp) - - def modify_eip_bandwidth(self, req=None, **kwargs): - """ ModifyEIPBandwidth - 调整弹性IP的外网带宽 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Bandwidth** (int) - (Required) 弹性IP的外网带宽, 单位为Mbps. 各地域的带宽值范围如下:流量计费[1-200],带宽计费[1-800] - - **EIPId** (str) - (Required) 弹性IP的资源ID - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.ModifyEIPBandwidthRequestSchema().dumps(d) - resp = self.invoke("ModifyEIPBandwidth", d, **kwargs) - return apis.ModifyEIPBandwidthResponseSchema().loads(resp) - - def modify_eip_weight(self, req=None, **kwargs): - """ ModifyEIPWeight - 修改弹性IP的外网出口权重 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **EIPId** (str) - (Required) 弹性IP的资源ID - - **Weight** (int) - (Required) 外网出口权重, 范围[0-100] 取值为0时, 该弹性IP不会被使用. 取值为100时, 同主机下只会使用这个弹性IP,其他弹性IP不会被使用 请勿将多个绑定在同一资源的弹性IP设置为相同权重 - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.ModifyEIPWeightRequestSchema().dumps(d) - resp = self.invoke("ModifyEIPWeight", d, **kwargs) - return apis.ModifyEIPWeightResponseSchema().loads(resp) - - def release_eip(self, req=None, **kwargs): - """ ReleaseEIP - 释放弹性IP资源, 所释放弹性IP必须为非绑定状态. - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **EIPId** (str) - (Required) 弹性IP的资源ID - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.ReleaseEIPRequestSchema().dumps(d) - resp = self.invoke("ReleaseEIP", d, **kwargs) - return apis.ReleaseEIPResponseSchema().loads(resp) - - def release_share_bandwidth(self, req=None, **kwargs): - """ ReleaseShareBandwidth - 关闭共享带宽 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **EIPBandwidth** (int) - (Required) 关闭共享带宽后,各EIP恢复为的带宽值 - - **ShareBandwidthId** (str) - (Required) 共享带宽ID - - **PayMode** (str) - Bandwidth 带宽计费, Traffic 转流量计费 - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.ReleaseShareBandwidthRequestSchema().dumps(d) - resp = self.invoke("ReleaseShareBandwidth", d, **kwargs) - return apis.ReleaseShareBandwidthResponseSchema().loads(resp) - - def release_vip(self, req=None, **kwargs): - """ ReleaseVIP - 释放VIP资源 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写 - - **Region** (str) - (Config) 地域 - - **VIPId** (str) - (Required) 内网VIP的id - - **Zone** (str) - 可用区 - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.ReleaseVIPRequestSchema().dumps(d) - resp = self.invoke("ReleaseVIP", d, **kwargs) - return apis.ReleaseVIPResponseSchema().loads(resp) - - def resize_share_bandwidth(self, req=None, **kwargs): - """ ResizeShareBandwidth - 调整共享带宽的带宽值 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **ShareBandwidth** (int) - (Required) 带宽值,单位为Mb,范围 [20-5000] (最大值受地域限制) - - **ShareBandwidthId** (str) - (Required) 共享带宽的Id - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.ResizeShareBandwidthRequestSchema().dumps(d) - resp = self.invoke("ResizeShareBandwidth", d, **kwargs) - return apis.ResizeShareBandwidthResponseSchema().loads(resp) - - def set_eip_pay_mode(self, req=None, **kwargs): - """ SetEIPPayMode - 设置弹性IP计费模式, 切换时会涉及付费/退费. - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Bandwidth** (int) - (Required) 调整的目标带宽值, 单位Mbps. 各地域的带宽值范围如下: 流量计费[1-200],其余情况[1-800] - - **EIPId** (str) - (Required) 弹性IP的资源Id - - **PayMode** (str) - (Required) 计费模式. 枚举值:"Traffic", 流量计费模式; "Bandwidth", 带宽计费模式 - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.SetEIPPayModeRequestSchema().dumps(d) - resp = self.invoke("SetEIPPayMode", d, **kwargs) - return apis.SetEIPPayModeResponseSchema().loads(resp) - - def un_bind_eip(self, req=None, **kwargs): - """ UnBindEIP - 将弹性IP从资源上解绑 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **EIPId** (str) - (Required) 弹性IP的资源Id - - **ResourceId** (str) - (Required) 弹性IP请求解绑的资源ID - - **ResourceType** (str) - (Required) 弹性IP请求解绑的资源类型, 枚举值为: uhost: 云主机; ulb, 负载均衡器 upm: 物理机; hadoophost: 大数据集群;fortresshost:堡垒机;udockhost:容器;udhost:私有专区主机;natgw:NAT网关;udb:udb;vpngw:ipsec vpn;ucdr:云灾备;dbaudit:数据库审计;uni,虚拟网卡。 - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.UnBindEIPRequestSchema().dumps(d) - resp = self.invoke("UnBindEIP", d, **kwargs) - return apis.UnBindEIPResponseSchema().loads(resp) - - def update_eip_attribute(self, req=None, **kwargs): - """ UpdateEIPAttribute - 更新弹性IP名称,业务组,备注等属性字段 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **EIPId** (str) - (Required) EIP资源ID - - **Name** (str) - 名字(Name Tag Remark都为空则报错) - - **Remark** (str) - 备注 - - **Tag** (str) - 业务 - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.UpdateEIPAttributeRequestSchema().dumps(d) - resp = self.invoke("UpdateEIPAttribute", d, **kwargs) - return apis.UpdateEIPAttributeResponseSchema().loads(resp) - - def update_firewall(self, req=None, **kwargs): - """ UpdateFirewall - 更新防火墙规则 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **FWId** (str) - (Required) 防火墙资源ID - - **Rule** (list) - (Required) 防火墙规则,例如:TCP|22|192.168.1.1/22|DROP|LOW|禁用22端口,第一个参数代表协议:第二个参数代表端口号,第三个参数为ip,第四个参数为ACCEPT(接受)和DROP(拒绝),第五个参数优先级:HIGH(高),MEDIUM(中),LOW(低),第六个参数为该条规则的自定义备注 - - **Response** - - - **FWId** (str) - 防火墙id - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.UpdateFirewallRequestSchema().dumps(d) - resp = self.invoke("UpdateFirewall", d, **kwargs) - return apis.UpdateFirewallResponseSchema().loads(resp) - - def update_firewall_attribute(self, req=None, **kwargs): - """ UpdateFirewallAttribute - 更新防火墙规则 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **FWId** (str) - (Required) 防火墙资源ID - - **Name** (str) - 防火墙名称,默认为空,为空则不做修改。Name,Tag,Remark必须填写1个及以上 - - **Remark** (str) - 防火墙备注,默认为空,为空则不做修改。Name,Tag,Remark必须填写1个及以上 - - **Tag** (str) - 防火墙业务组,默认为空,为空则不做修改。Name,Tag,Remark必须填写1个及以上 - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.UpdateFirewallAttributeRequestSchema().dumps(d) - resp = self.invoke("UpdateFirewallAttribute", d, **kwargs) - return apis.UpdateFirewallAttributeResponseSchema().loads(resp) - - _deprecated = { - "allocate_e_ip": "allocate_eip", - "associate_e_ip_with_share_bandwidth": "associate_eip_with_share_bandwidth", - "bind_e_ip": "bind_eip", - "describe_e_ip": "describe_eip", - "disassociate_e_ip_with_share_bandwidth": "disassociate_eip_with_share_bandwidth", - "get_e_ip_pay_mode": "get_eip_pay_mode", - "get_e_ip_price": "get_eip_price", - "get_e_ip_upgrade_price": "get_eip_upgrade_price", - "modify_e_ip_bandwidth": "modify_eip_bandwidth", - "modify_e_ip_weight": "modify_eip_weight", - "release_e_ip": "release_eip", - "set_e_ip_pay_mode": "set_eip_pay_mode", - "un_bind_e_ip": "un_bind_eip", - "update_e_ip_attribute": "update_eip_attribute", - "release_v_ip": "release_vip", - "allocate_v_ip": "allocate_vip", - "describe_v_ip": "describe_vip", - } - - def __getattr__(self, item): - if item in self._deprecated: - instead_of = self._deprecated[item] - msg = "the method {} is deprecated, please use {} instead, this method will remove after 0.5.0 version" - self.logger.warning(msg.format(item, instead_of)) - return getattr(self, self._deprecated[item]) - raise AttributeError( - "'{}' object has no attribute '{}'".format(self.__class__.__name__, item) - ) +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.client import Client +from ucloud.services.unet.schemas import apis + + +class UNetClient(Client): + def __init__(self, config, transport=None, middleware=None, logger=None): + super(UNetClient, self).__init__(config, transport, middleware, logger) + + def allocate_eip(self, req=None, **kwargs): + """ AllocateEIP - 根据提供信息, 申请弹性IP + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 + - **Region** (str) - (Config) 地域。 + - **Bandwidth** (int) - (Required) 弹性IP的外网带宽, 单位为Mbps. 共享带宽模式必须指定0M带宽, 非共享带宽模式必须指定非0Mbps带宽. 各地域非共享带宽的带宽范围如下: 流量计费[1-200],带宽计费[1-800] + - **OperatorName** (str) - (Required) 弹性IP的线路如下: 国际: International BGP: Bgp 各地域允许的线路参数如下: cn-sh1: Bgp cn-sh2: Bgp cn-gd: Bgp cn-bj1: Bgp cn-bj2: Bgp hk: International us-ca: International th-bkk: International kr-seoul:International us-ws:International ge-fra:International sg:International tw-kh:International.其他海外线路均为 International + - **ChargeType** (str) - 付费方式, 枚举值为: Year, 按年付费; Month, 按月付费; Dynamic, 按需付费(需开启权限); Trial, 试用(需开启权限) 默认为按月付费 + - **CouponId** (str) - 代金券ID, 默认不使用 + - **Name** (str) - 弹性IP的名称, 默认为 "EIP" + - **PayMode** (str) - 弹性IP的计费模式. 枚举值: "Traffic", 流量计费; "Bandwidth", 带宽计费; "ShareBandwidth",共享带宽模式. 默认为 "Bandwidth". + - **Quantity** (int) - 购买时长, 默认: 1 + - **Remark** (str) - 弹性IP的备注, 默认为空 + - **ShareBandwidthId** (str) - 绑定的共享带宽Id,仅当PayMode为ShareBandwidth时有效 + - **Tag** (str) - 业务组名称, 默认为 "Default" + + **Response** + + - **EIPSet** (list) - 见 **UnetAllocateEIPSet** 模型定义 + + **Response Model** + + **UnetEIPAddrSet** + + - **IP** (str) - IP地址 + - **OperatorName** (str) - 运营商信息如: 电信: Telecom, 联通: Unicom, 国际: International, Duplet: 双线IP(电信+联通), BGP: Bgp + + **UnetAllocateEIPSet** + + - **EIPAddr** (list) - 见 **UnetEIPAddrSet** 模型定义 + - **EIPId** (str) - 申请到的EIP资源ID + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.AllocateEIPRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("AllocateEIP", d, **kwargs) + return apis.AllocateEIPResponseSchema().loads(resp) + + def allocate_share_bandwidth(self, req=None, **kwargs): + """ AllocateShareBandwidth - 开通共享带宽 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **ChargeType** (str) - (Required) 付费方式:Year 按年,Month 按月,Dynamic 按时; + - **Name** (str) - (Required) 共享带宽名字 + - **ShareBandwidth** (int) - (Required) 共享带宽值 + - **BwType** (str) - 共享带宽类型,ipv4或者ipv6,不传默认ipv4 + - **Quantity** (int) - 购买时长 + - **ShareBandwidthGuarantee** (int) - 共享带宽保底值(后付费) + + **Response** + + - **ShareBandwidthId** (str) - 共享带宽资源Id + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.AllocateShareBandwidthRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("AllocateShareBandwidth", d, **kwargs) + return apis.AllocateShareBandwidthResponseSchema().loads(resp) + + def allocate_vip(self, req=None, **kwargs): + """ AllocateVIP - 根据提供信息,申请内网VIP(Virtual IP),多用于高可用程序作为漂移IP。 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域 + - **SubnetId** (str) - (Required) 子网id + - **VPCId** (str) - (Required) 指定vip所属的VPC + - **BusinessId** (str) - 业务组 + - **Count** (int) - 申请数量,默认: 1 + - **Ip** (str) - 指定ip + - **Name** (str) - vip名,默认为VIP + - **Remark** (str) - 备注 + - **Tag** (str) - 业务组名称,默认为Default + - **Zone** (str) - 可用区 + + **Response** + + - **DataSet** (list) - 申请到的VIP地址 + - **VIPSet** (list) - 见 **VIPSet** 模型定义 + + **Response Model** + + **VIPSet** + + - **VIP** (str) - 虚拟ip + - **VIPId** (str) - 虚拟ip id + - **VPCId** (str) - VPC id + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.AllocateVIPRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("AllocateVIP", d, **kwargs) + return apis.AllocateVIPResponseSchema().loads(resp) + + def associate_eip_with_share_bandwidth(self, req=None, **kwargs): + """ AssociateEIPWithShareBandwidth - 将EIP加入共享带宽 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 + - **Region** (str) - (Config) 地域。 + - **EIPIds** (list) - (Required) 要加入共享带宽的EIP的资源Id + - **ShareBandwidthId** (str) - (Required) 共享带宽ID + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.AssociateEIPWithShareBandwidthRequestSchema().dumps(d) + resp = self.invoke("AssociateEIPWithShareBandwidth", d, **kwargs) + return apis.AssociateEIPWithShareBandwidthResponseSchema().loads(resp) + + def bind_eip(self, req=None, **kwargs): + """ BindEIP - 将尚未使用的弹性IP绑定到指定的资源 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写 + - **Region** (str) - (Config) 地域 + - **EIPId** (str) - (Required) 弹性IP的资源Id + - **ResourceId** (str) - (Required) 弹性IP请求绑定的资源ID + - **ResourceType** (str) - (Required) 弹性IP请求绑定的资源类型, 枚举值为: uhost: 云主机; ulb, 负载均衡器 upm: 物理机; hadoophost: 大数据集群;fortresshost:堡垒机;udockhost:容器;udhost:私有专区主机;natgw:natgw;udb:udb;vpngw:ipsec vpn;ucdr:云灾备;dbaudit:数据库审计;uni:虚拟网卡。 + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.BindEIPRequestSchema().dumps(d) + resp = self.invoke("BindEIP", d, **kwargs) + return apis.BindEIPResponseSchema().loads(resp) + + def create_bandwidth_package(self, req=None, **kwargs): + """ CreateBandwidthPackage - 为非共享带宽模式下, 已绑定资源实例的带宽计费弹性IP附加临时带宽包 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 + - **Region** (str) - (Config) 地域 + - **Bandwidth** (int) - (Required) 带宽大小(单位Mbps), 取值范围[2,800] (最大值受地域限制) + - **EIPId** (str) - (Required) 所绑定弹性IP的资源ID + - **TimeRange** (int) - (Required) 带宽包有效时长, 取值范围为大于0的整数, 即该带宽包在EnableTime到 EnableTime+TimeRange时间段内生效 + - **CouponId** (str) - 代金券ID + - **EnableTime** (int) - 生效时间, 格式为 Unix timestamp, 默认为立即开通 + + **Response** + + - **BandwidthPackageId** (str) - 所创建带宽包的资源ID + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.CreateBandwidthPackageRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("CreateBandwidthPackage", d, **kwargs) + return apis.CreateBandwidthPackageResponseSchema().loads(resp) + + def create_firewall(self, req=None, **kwargs): + """ CreateFirewall - 创建防火墙 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写 + - **Region** (str) - (Config) 地域 + - **Name** (str) - (Required) 防火墙名称 + - **Rule** (list) - (Required) 防火墙规则,例如:TCP|22|192.168.1.1/22|DROP|LOW|禁用22端口,第一个参数代表协议:第二个参数代表端口号,第三个参数为ip,第四个参数为ACCEPT(接受)和DROP(拒绝),第五个参数优先级:HIGH(高),MEDIUM(中),LOW(低),第六个参数为该条规则的自定义备注 + - **Remark** (str) - 防火墙描述,默认为空 + - **Tag** (str) - 防火墙业务组,默认为Default + + **Response** + + - **FWId** (str) - 防火墙ID + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.CreateFirewallRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("CreateFirewall", d, **kwargs) + return apis.CreateFirewallResponseSchema().loads(resp) + + def delete_bandwidth_package(self, req=None, **kwargs): + """ DeleteBandwidthPackage - 删除弹性IP上已附加带宽包 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写 + - **Region** (str) - (Config) 地域 + - **BandwidthPackageId** (str) - (Required) 带宽包资源ID + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DeleteBandwidthPackageRequestSchema().dumps(d) + resp = self.invoke("DeleteBandwidthPackage", d, **kwargs) + return apis.DeleteBandwidthPackageResponseSchema().loads(resp) + + def delete_firewall(self, req=None, **kwargs): + """ DeleteFirewall - 删除防火墙 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写 + - **Region** (str) - (Config) 地域 + - **FWId** (str) - (Required) 防火墙资源ID + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DeleteFirewallRequestSchema().dumps(d) + resp = self.invoke("DeleteFirewall", d, **kwargs) + return apis.DeleteFirewallResponseSchema().loads(resp) + + def describe_bandwidth_package(self, req=None, **kwargs): + """ DescribeBandwidthPackage - 获取某地域下的带宽包信息 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Limit** (int) - 返回数据分页值, 取值范围为 [0,10000000] 之间的整数, 默认为20 + - **Offset** (int) - 返回数据偏移量, 默认为0 + + **Response** + + - **DataSets** (list) - 见 **UnetBandwidthPackageSet** 模型定义 + - **TotalCount** (int) - 满足条件的带宽包总数 + + **Response Model** + + **EIPAddrSet** + + - **IP** (str) - 弹性IP地址 + - **OperatorName** (str) - 运营商信息, 枚举值为: Telecom 电信; Unicom: 联通; Duplet: 双线; Bgp: BGP; International: 国际. + + **UnetBandwidthPackageSet** + + - **Bandwidth** (int) - 带宽包的临时带宽值, 单位Mbps + - **BandwidthPackageId** (str) - 带宽包的资源ID + - **CreateTime** (int) - 创建时间, 格式为 Unix Timestamp + - **DisableTime** (int) - 失效时间, 格式为 Unix Timestamp + - **EIPAddr** (list) - 见 **EIPAddrSet** 模型定义 + - **EIPId** (str) - 带宽包所绑定弹性IP的资源ID + - **EnableTime** (int) - 生效时间, 格式为 Unix Timestamp + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeBandwidthPackageRequestSchema().dumps(d) + resp = self.invoke("DescribeBandwidthPackage", d, **kwargs) + return apis.DescribeBandwidthPackageResponseSchema().loads(resp) + + def describe_bandwidth_usage(self, req=None, **kwargs): + """ DescribeBandwidthUsage - 获取带宽用量信息 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **EIPIds** (list) - 弹性IP的资源Id. 如果为空, 则返回当前 Region中符合条件的所有EIP的带宽用量, n为自然数 + - **Limit** (int) - 返回数据分页值, 取值范围为 [0,10000000] 之间的整数, 默认为20 + - **OffSet** (int) - 返回数据偏移量, 默认为0 + + **Response** + + - **EIPSet** (list) - 见 **UnetBandwidthUsageEIPSet** 模型定义 + - **TotalCount** (int) - EIPSet中的元素个数 + + **Response Model** + + **UnetBandwidthUsageEIPSet** + + - **CurBandwidth** (float) - 最近5分钟带宽用量, 单位Mbps + - **EIPId** (str) - 弹性IP资源ID + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeBandwidthUsageRequestSchema().dumps(d) + resp = self.invoke("DescribeBandwidthUsage", d, **kwargs) + return apis.DescribeBandwidthUsageResponseSchema().loads(resp) + + def describe_eip(self, req=None, **kwargs): + """ DescribeEIP - 获取弹性IP信息 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写 + - **Region** (str) - (Config) 地域 + - **EIPIds** (list) - 弹性IP的资源ID如果为空, 则返回当前 Region中符合条件的的所有EIP + - **Limit** (int) - 数据分页值, 默认为20 + - **Offset** (int) - 数据偏移量, 默认为0 + + **Response** + + - **EIPSet** (list) - 见 **UnetEIPSet** 模型定义 + - **TotalBandwidth** (int) - 满足条件的弹性IP带宽总和, 单位Mbps + - **TotalCount** (int) - 满足条件的弹性IP总数 + + **Response Model** + + **ShareBandwidthSet** + + - **ShareBandwidth** (int) - 共享带宽带宽值 + - **ShareBandwidthId** (str) - 共享带宽ID + - **ShareBandwidthName** (str) - 共享带宽的资源名称 + + **UnetEIPAddrSet** + + - **IP** (str) - IP地址 + - **OperatorName** (str) - 运营商信息如: 电信: Telecom, 联通: Unicom, 国际: International, Duplet: 双线IP(电信+联通), BGP: Bgp + + **UnetEIPResourceSet** + + - **EIPId** (str) - 弹性IP的资源ID + - **ResourceId** (str) - 已绑定资源的资源ID + - **ResourceName** (str) - 已绑定的资源名称 + - **ResourceType** (str) - 已绑定的资源类型, 枚举值为: uhost, 云主机;natgw:NAT网关;ulb:负载均衡器;upm: 物理机; hadoophost: 大数据集群;fortresshost:堡垒机;udockhost:容器;udhost:私有专区主机;vpngw:IPSec VPN;ucdr:云灾备;dbaudit:数据库审计,uni:虚拟网卡。 + - **SubResourceId** (str) - 资源绑定的虚拟网卡的ID + - **SubResourceName** (str) - 资源绑定的虚拟网卡的名称 + - **SubResourceType** (str) - 资源绑定的虚拟网卡的类型。uni,虚拟网卡。 + + **UnetEIPSet** + + - **Bandwidth** (int) - 弹性IP的带宽, 单位为Mbps, 当BandwidthType=1时, 该处显示为共享带宽值. 当BandwidthType=0时, 该处显示这个弹性IP的带宽. + - **BandwidthType** (int) - 带宽模式, 枚举值为: 0: 非共享带宽模式, 1: 共享带宽模式 + - **ChargeType** (str) - 付费方式, 枚举值为: Year, 按年付费; Month, 按月付费; Dynamic, 按小时付费; Trial, 试用. 按小时付费和试用这两种付费模式需要开通权限. + - **CreateTime** (int) - 弹性IP的创建时间, 格式为Unix Timestamp + - **EIPAddr** (list) - 见 **UnetEIPAddrSet** 模型定义 + - **EIPId** (str) - 弹性IP的资源ID + - **Expire** (bool) - 弹性IP是否到期 + - **ExpireTime** (int) - 弹性IP的到期时间, 格式为Unix Timestamp + - **Name** (str) - 弹性IP的名称,缺省值为 "EIP" + - **PayMode** (str) - 弹性IP的计费模式, 枚举值为: "Bandwidth", 带宽计费; "Traffic", 流量计费; "ShareBandwidth",共享带宽模式. 默认为 "Bandwidth". + - **Remark** (str) - 弹性IP的备注, 缺省值为 "" + - **Resource** (dict) - 见 **UnetEIPResourceSet** 模型定义 + - **ShareBandwidthSet** (dict) - 见 **ShareBandwidthSet** 模型定义 + - **Status** (str) - 弹性IP的资源绑定状态, 枚举值为: used: 已绑定, free: 未绑定, freeze: 已冻结 + - **Tag** (str) - 弹性IP的业务组标识, 缺省值为 "Default" + - **Weight** (int) - 外网出口权重, 默认为50, 范围[0-100] + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeEIPRequestSchema().dumps(d) + resp = self.invoke("DescribeEIP", d, **kwargs) + return apis.DescribeEIPResponseSchema().loads(resp) + + def describe_firewall(self, req=None, **kwargs): + """ DescribeFirewall - 获取防火墙组信息 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写 + - **Region** (str) - (Config) 地域 + - **FWId** (str) - 防火墙ID,默认为返回所有防火墙 + - **Limit** (int) - 返回数据长度,默认为20,最大10000000 + - **Offset** (int) - 列表起始位置偏移量,默认为0 + - **ResourceId** (str) - 绑定防火墙组的资源ID + - **ResourceType** (str) - 绑定防火墙组的资源类型,默认为全部资源类型。枚举值为:"unatgw",NAT网关; "uhost",云主机; "upm",物理云主机; "hadoophost",hadoop节点; "fortresshost",堡垒机; "udhost",私有专区主机;"udockhost",容器;"dbaudit",数据库审计. + + **Response** + + - **DataSet** (list) - 见 **FirewallDataSet** 模型定义 + - **TotalCount** (int) - + + **Response Model** + + **FirewallRuleSet** + + - **DstPort** (str) - 目标端口 + - **Priority** (str) - 优先级 + - **ProtocolType** (str) - 协议类型 + - **Remark** (str) - 防火墙规则备注 + - **RuleAction** (str) - 防火墙动作 + - **SrcIP** (str) - 源地址 + + **FirewallDataSet** + + - **CreateTime** (int) - 防火墙组创建时间,格式为Unix Timestamp + - **FWId** (str) - 防火墙ID + - **GroupId** (str) - 安全组ID(即将废弃) + - **Name** (str) - 防火墙名称 + - **Remark** (str) - 防火墙备注 + - **ResourceCount** (int) - 防火墙绑定资源数量 + - **Rule** (list) - 见 **FirewallRuleSet** 模型定义 + - **Tag** (str) - 防火墙业务组 + - **Type** (str) - 防火墙组类型,枚举值为: "user defined", 用户自定义防火墙; "recommend web", 默认Web防火墙; "recommend non web", 默认非Web防火墙 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeFirewallRequestSchema().dumps(d) + resp = self.invoke("DescribeFirewall", d, **kwargs) + return apis.DescribeFirewallResponseSchema().loads(resp) + + def describe_firewall_resource(self, req=None, **kwargs): + """ DescribeFirewallResource - 获取防火墙组所绑定资源的外网IP + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **FWId** (str) - (Required) 防火墙ID + - **Limit** (int) - 返回数据长度,默认为20,最大10000000 + - **Offset** (int) - 列表起始位置偏移量,默认为0 + + **Response** + + - **ResourceSet** (list) - 见 **ResourceSet** 模型定义 + - **TotalCount** (int) - 绑定资源总数 + + **Response Model** + + **ResourceSet** + + - **Name** (str) - 名称 + - **PrivateIP** (str) - 内网IP + - **Remark** (str) - 备注 + - **ResourceID** (str) - 绑定该防火墙的资源id + - **ResourceType** (str) - 绑定资源的资源类型,如"uhost","upm","umem","uhive","uvip","uredis","uhadoop","ufortress","dbaudit","udw","udocker", "umemcache" + - **Status** (int) - 状态 + - **Tag** (str) - 业务组 + - **Zone** (int) - 可用区 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeFirewallResourceRequestSchema().dumps(d) + resp = self.invoke("DescribeFirewallResource", d, **kwargs) + return apis.DescribeFirewallResourceResponseSchema().loads(resp) + + def describe_share_bandwidth(self, req=None, **kwargs): + """ DescribeShareBandwidth - 获取共享带宽信息 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **ShareBandwidthIds** (list) - 需要返回的共享带宽Id + + **Response** + + - **DataSet** (list) - 见 **UnetShareBandwidthSet** 模型定义 + - **TotalCount** (int) - 符合条件的共享带宽总数,大于等于返回DataSet长度 + + **Response Model** + + **EIPAddrSet** + + - **IP** (str) - 弹性IP地址 + - **OperatorName** (str) - 运营商信息, 枚举值为: Telecom 电信; Unicom: 联通; Duplet: 双线; Bgp: BGP; International: 国际. + + **EIPSetData** + + - **Bandwidth** (int) - EIP带宽值 + - **EIPAddr** (list) - 见 **EIPAddrSet** 模型定义 + - **EIPId** (str) - EIP资源Id + + **UnetShareBandwidthSet** + + - **BandwidthGuarantee** (int) - 共享带宽保底值(后付费) + - **ChargeType** (str) - 付费方式, 预付费:Year 按年,Month 按月,Dynamic 按需;后付费:PostPay(按月) + - **CreateTime** (int) - 创建时间, 格式为Unix Timestamp + - **EIPSet** (list) - 见 **EIPSetData** 模型定义 + - **ExpireTime** (int) - 过期时间, 格式为Unix Timestamp + - **Name** (str) - 共享带宽名称 + - **PostPayStartTime** (int) - 共享带宽后付费开始计费时间(后付费) + - **ShareBandwidth** (int) - 共享带宽值(预付费)/共享带宽峰值(后付费), 单位Mbps + - **ShareBandwidthId** (str) - 共享带宽的资源ID + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeShareBandwidthRequestSchema().dumps(d) + resp = self.invoke("DescribeShareBandwidth", d, **kwargs) + return apis.DescribeShareBandwidthResponseSchema().loads(resp) + + def describe_vip(self, req=None, **kwargs): + """ DescribeVIP - 获取内网VIP详细信息 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **BusinessId** (str) - 业务组 + - **SubnetId** (str) - 子网id,不指定则获取VPCId下的所有vip + - **Tag** (str) - 业务组名称, 默认为 Default + - **VPCId** (str) - vpc的id,指定SubnetId时必填 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **DataSet** (list) - 内网VIP地址列表 + - **TotalCount** (int) - vip数量 + - **VIPSet** (list) - 见 **VIPDetailSet** 模型定义 + + **Response Model** + + **VIPDetailSet** + + - **CreateTime** (int) - 创建时间 + - **Name** (str) - + - **RealIp** (str) - 真实主机ip + - **SubnetId** (str) - 子网id + - **VIP** (str) - 虚拟ip + - **VIPId** (str) - 虚拟ip id + - **VPCId** (str) - VPC id + - **Zone** (str) - 地域 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeVIPRequestSchema().dumps(d) + resp = self.invoke("DescribeVIP", d, **kwargs) + return apis.DescribeVIPResponseSchema().loads(resp) + + def disassociate_eip_with_share_bandwidth(self, req=None, **kwargs): + """ DisassociateEIPWithShareBandwidth - 将EIP移出共享带宽 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Bandwidth** (int) - (Required) 移出共享带宽后,EIP的外网带宽, 单位为Mbps. 各地域带宽范围如下: 流量计费[1-200],带宽计费[1-800] + - **ShareBandwidthId** (str) - (Required) 共享带宽ID + - **EIPIds** (list) - EIP的资源Id;默认移出该共享带宽下所有的EIP + - **PayMode** (str) - 移出共享带宽后,EIP的计费模式. 枚举值: "Traffic", 流量计费; "Bandwidth", 带宽计费; 默认为 "Bandwidth". + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DisassociateEIPWithShareBandwidthRequestSchema().dumps(d) + resp = self.invoke("DisassociateEIPWithShareBandwidth", d, **kwargs) + return apis.DisassociateEIPWithShareBandwidthResponseSchema().loads( + resp + ) + + def get_eip_pay_mode(self, req=None, **kwargs): + """ GetEIPPayMode - 获取弹性IP计费模式 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写 + - **Region** (str) - (Config) 地域 + - **EIPId** (list) - (Required) 弹性IP的资源Id + + **Response** + + - **EIPPayMode** (list) - 见 **EIPPayModeSet** 模型定义 + + **Response Model** + + **EIPPayModeSet** + + - **EIPId** (str) - EIP的资源ID + - **EIPPayMode** (str) - EIP的计费模式. 枚举值为:Bandwidth, 带宽计费;Traffic, 流量计费; "ShareBandwidth",共享带宽模式 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.GetEIPPayModeRequestSchema().dumps(d) + resp = self.invoke("GetEIPPayMode", d, **kwargs) + return apis.GetEIPPayModeResponseSchema().loads(resp) + + def get_eip_price(self, req=None, **kwargs): + """ GetEIPPrice - 获取弹性IP价格 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Bandwidth** (int) - (Required) 弹性IP的外网带宽, 单位为Mbps, 范围 [0-800] + - **OperatorName** (str) - (Required) 弹性IP的线路如下: 国际: International BGP: Bgp 各地域允许的线路参数如下: cn-sh1: Bgp cn-sh2: Bgp cn-gd: Bgp cn-bj1: Bgp cn-bj2: Bgp hk: International us-ca: International th-bkk: International kr-seoul:International us-ws:International ge-fra:International sg:International tw-kh:International.其他海外线路均为 International,泉州为移动单线cn-qz:ChinaMobile + - **ChargeType** (str) - 付费方式, 枚举值为: Year, 按年付费; Month, 按月付费; Dynamic, 按时付费; 默认为获取三种价格 + - **PayMode** (str) - 弹性IP计费方式r. 枚举值为: Traffic, 流量计费; Bandwidth, 带宽计费; "ShareBandwidth",共享带宽模式. 默认为Bandwidth + - **Quantity** (int) - 购买时长。默认: 1。按小时购买(Dynamic)时无需此参数。 月付时,此参数传0,代表了购买至月末 + + **Response** + + - **PriceSet** (list) - 见 **EIPPriceDetailSet** 模型定义 + + **Response Model** + + **EIPPriceDetailSet** + + - **ChargeType** (str) - 弹性IP付费方式 + - **Price** (float) - 弹性IP价格, 单位"元" + - **PurchaseValue** (int) - 资源有效期, 以Unix Timestamp表示 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.GetEIPPriceRequestSchema().dumps(d) + resp = self.invoke("GetEIPPrice", d, **kwargs) + return apis.GetEIPPriceResponseSchema().loads(resp) + + def get_eip_upgrade_price(self, req=None, **kwargs): + """ GetEIPUpgradePrice - 获取弹性IP带宽改动价格 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Bandwidth** (int) - (Required) 弹性IP的外网带宽, 单位为Mbps, 范围 [1-800] + - **EIPId** (str) - (Required) 弹性IP的资源ID + + **Response** + + - **Price** (float) - 调整带宽后的EIP价格, 单位为"元", 如需退费此处为负值 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.GetEIPUpgradePriceRequestSchema().dumps(d) + resp = self.invoke("GetEIPUpgradePrice", d, **kwargs) + return apis.GetEIPUpgradePriceResponseSchema().loads(resp) + + def grant_firewall(self, req=None, **kwargs): + """ GrantFirewall - 将防火墙应用到资源上 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **FWId** (str) - (Required) 防火墙资源ID + - **ResourceId** (str) - (Required) 所应用资源ID + - **ResourceType** (str) - (Required) 绑定防火墙组的资源类型,默认为全部资源类型。枚举值为:"unatgw",NAT网关; "uhost",云主机; "upm",物理云主机; "hadoophost",hadoop节点; "fortresshost",堡垒机; "udhost",私有专区主机;"udockhost",容器;"dbaudit",数据库审计,”uni“,虚拟网卡。 + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.GrantFirewallRequestSchema().dumps(d) + resp = self.invoke("GrantFirewall", d, **kwargs) + return apis.GrantFirewallResponseSchema().loads(resp) + + def modify_eip_bandwidth(self, req=None, **kwargs): + """ ModifyEIPBandwidth - 调整弹性IP的外网带宽 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Bandwidth** (int) - (Required) 弹性IP的外网带宽, 单位为Mbps. 各地域的带宽值范围如下:流量计费[1-200],带宽计费[1-800] + - **EIPId** (str) - (Required) 弹性IP的资源ID + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.ModifyEIPBandwidthRequestSchema().dumps(d) + resp = self.invoke("ModifyEIPBandwidth", d, **kwargs) + return apis.ModifyEIPBandwidthResponseSchema().loads(resp) + + def modify_eip_weight(self, req=None, **kwargs): + """ ModifyEIPWeight - 修改弹性IP的外网出口权重 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **EIPId** (str) - (Required) 弹性IP的资源ID + - **Weight** (int) - (Required) 外网出口权重, 范围[0-100] 取值为0时, 该弹性IP不会被使用. 取值为100时, 同主机下只会使用这个弹性IP,其他弹性IP不会被使用 请勿将多个绑定在同一资源的弹性IP设置为相同权重 + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.ModifyEIPWeightRequestSchema().dumps(d) + resp = self.invoke("ModifyEIPWeight", d, **kwargs) + return apis.ModifyEIPWeightResponseSchema().loads(resp) + + def release_eip(self, req=None, **kwargs): + """ ReleaseEIP - 释放弹性IP资源, 所释放弹性IP必须为非绑定状态. + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **EIPId** (str) - (Required) 弹性IP的资源ID + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.ReleaseEIPRequestSchema().dumps(d) + resp = self.invoke("ReleaseEIP", d, **kwargs) + return apis.ReleaseEIPResponseSchema().loads(resp) + + def release_share_bandwidth(self, req=None, **kwargs): + """ ReleaseShareBandwidth - 关闭共享带宽 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **EIPBandwidth** (int) - (Required) 关闭共享带宽后,各EIP恢复为的带宽值 + - **ShareBandwidthId** (str) - (Required) 共享带宽ID + - **PayMode** (str) - Bandwidth 带宽计费, Traffic 转流量计费 + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.ReleaseShareBandwidthRequestSchema().dumps(d) + resp = self.invoke("ReleaseShareBandwidth", d, **kwargs) + return apis.ReleaseShareBandwidthResponseSchema().loads(resp) + + def release_vip(self, req=None, **kwargs): + """ ReleaseVIP - 释放VIP资源 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写 + - **Region** (str) - (Config) 地域 + - **VIPId** (str) - (Required) 内网VIP的id + - **Zone** (str) - 可用区 + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.ReleaseVIPRequestSchema().dumps(d) + resp = self.invoke("ReleaseVIP", d, **kwargs) + return apis.ReleaseVIPResponseSchema().loads(resp) + + def resize_share_bandwidth(self, req=None, **kwargs): + """ ResizeShareBandwidth - 调整共享带宽的带宽值 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **ShareBandwidth** (int) - (Required) 带宽值,单位为Mb,范围 [20-5000] (最大值受地域限制) + - **ShareBandwidthId** (str) - (Required) 共享带宽的Id + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.ResizeShareBandwidthRequestSchema().dumps(d) + resp = self.invoke("ResizeShareBandwidth", d, **kwargs) + return apis.ResizeShareBandwidthResponseSchema().loads(resp) + + def set_eip_pay_mode(self, req=None, **kwargs): + """ SetEIPPayMode - 设置弹性IP计费模式, 切换时会涉及付费/退费. + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Bandwidth** (int) - (Required) 调整的目标带宽值, 单位Mbps. 各地域的带宽值范围如下: 流量计费[1-200],其余情况[1-800] + - **EIPId** (str) - (Required) 弹性IP的资源Id + - **PayMode** (str) - (Required) 计费模式. 枚举值:"Traffic", 流量计费模式; "Bandwidth", 带宽计费模式 + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.SetEIPPayModeRequestSchema().dumps(d) + resp = self.invoke("SetEIPPayMode", d, **kwargs) + return apis.SetEIPPayModeResponseSchema().loads(resp) + + def un_bind_eip(self, req=None, **kwargs): + """ UnBindEIP - 将弹性IP从资源上解绑 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **EIPId** (str) - (Required) 弹性IP的资源Id + - **ResourceId** (str) - (Required) 弹性IP请求解绑的资源ID + - **ResourceType** (str) - (Required) 弹性IP请求解绑的资源类型, 枚举值为: uhost: 云主机; ulb, 负载均衡器 upm: 物理机; hadoophost: 大数据集群;fortresshost:堡垒机;udockhost:容器;udhost:私有专区主机;natgw:NAT网关;udb:udb;vpngw:ipsec vpn;ucdr:云灾备;dbaudit:数据库审计;uni,虚拟网卡。 + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.UnBindEIPRequestSchema().dumps(d) + resp = self.invoke("UnBindEIP", d, **kwargs) + return apis.UnBindEIPResponseSchema().loads(resp) + + def update_eip_attribute(self, req=None, **kwargs): + """ UpdateEIPAttribute - 更新弹性IP名称,业务组,备注等属性字段 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **EIPId** (str) - (Required) EIP资源ID + - **Name** (str) - 名字(Name Tag Remark都为空则报错) + - **Remark** (str) - 备注 + - **Tag** (str) - 业务 + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.UpdateEIPAttributeRequestSchema().dumps(d) + resp = self.invoke("UpdateEIPAttribute", d, **kwargs) + return apis.UpdateEIPAttributeResponseSchema().loads(resp) + + def update_firewall(self, req=None, **kwargs): + """ UpdateFirewall - 更新防火墙规则 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **FWId** (str) - (Required) 防火墙资源ID + - **Rule** (list) - (Required) 防火墙规则,例如:TCP|22|192.168.1.1/22|DROP|LOW|禁用22端口,第一个参数代表协议:第二个参数代表端口号,第三个参数为ip,第四个参数为ACCEPT(接受)和DROP(拒绝),第五个参数优先级:HIGH(高),MEDIUM(中),LOW(低),第六个参数为该条规则的自定义备注 + + **Response** + + - **FWId** (str) - 防火墙id + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.UpdateFirewallRequestSchema().dumps(d) + resp = self.invoke("UpdateFirewall", d, **kwargs) + return apis.UpdateFirewallResponseSchema().loads(resp) + + def update_firewall_attribute(self, req=None, **kwargs): + """ UpdateFirewallAttribute - 更新防火墙规则 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **FWId** (str) - (Required) 防火墙资源ID + - **Name** (str) - 防火墙名称,默认为空,为空则不做修改。Name,Tag,Remark必须填写1个及以上 + - **Remark** (str) - 防火墙备注,默认为空,为空则不做修改。Name,Tag,Remark必须填写1个及以上 + - **Tag** (str) - 防火墙业务组,默认为空,为空则不做修改。Name,Tag,Remark必须填写1个及以上 + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.UpdateFirewallAttributeRequestSchema().dumps(d) + resp = self.invoke("UpdateFirewallAttribute", d, **kwargs) + return apis.UpdateFirewallAttributeResponseSchema().loads(resp) + + _deprecated = { + "allocate_e_ip": "allocate_eip", + "associate_e_ip_with_share_bandwidth": "associate_eip_with_share_bandwidth", + "bind_e_ip": "bind_eip", + "describe_e_ip": "describe_eip", + "disassociate_e_ip_with_share_bandwidth": "disassociate_eip_with_share_bandwidth", + "get_e_ip_pay_mode": "get_eip_pay_mode", + "get_e_ip_price": "get_eip_price", + "get_e_ip_upgrade_price": "get_eip_upgrade_price", + "modify_e_ip_bandwidth": "modify_eip_bandwidth", + "modify_e_ip_weight": "modify_eip_weight", + "release_e_ip": "release_eip", + "set_e_ip_pay_mode": "set_eip_pay_mode", + "un_bind_e_ip": "un_bind_eip", + "update_e_ip_attribute": "update_eip_attribute", + "release_v_ip": "release_vip", + "allocate_v_ip": "allocate_vip", + "describe_v_ip": "describe_vip", + } + + def __getattr__(self, item): + if item in self._deprecated: + instead_of = self._deprecated[item] + msg = "the method {} is deprecated, please use {} instead, this method will remove after 0.5.0 version" + self.logger.warning(msg.format(item, instead_of)) + return getattr(self, self._deprecated[item]) + raise AttributeError( + "'{}' object has no attribute '{}'".format( + self.__class__.__name__, item + ) + ) diff --git a/ucloud/services/unet/schemas/__init__.py b/ucloud/services/unet/schemas/__init__.py index 4c48b5a..40a96af 100644 --- a/ucloud/services/unet/schemas/__init__.py +++ b/ucloud/services/unet/schemas/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- diff --git a/ucloud/services/unet/schemas/apis.py b/ucloud/services/unet/schemas/apis.py index 97f92a7..bce0f77 100644 --- a/ucloud/services/unet/schemas/apis.py +++ b/ucloud/services/unet/schemas/apis.py @@ -1,940 +1,972 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.typesystem import schema, fields -from ucloud.services.unet.schemas import models - -""" UNet API Schema -""" -""" -API: AllocateEIP - -根据提供信息, 申请弹性IP -""" - - -class AllocateEIPRequestSchema(schema.RequestSchema): - """ AllocateEIP - 根据提供信息, 申请弹性IP - """ - - fields = { - "Bandwidth": fields.Int(required=True, dump_to="Bandwidth"), - "ChargeType": fields.Str(required=False, dump_to="ChargeType"), - "CouponId": fields.Str(required=False, dump_to="CouponId"), - "Name": fields.Str(required=False, dump_to="Name"), - "OperatorName": fields.Str(required=True, dump_to="OperatorName"), - "PayMode": fields.Str(required=False, dump_to="PayMode"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Quantity": fields.Int(required=False, dump_to="Quantity"), - "Region": fields.Str(required=True, dump_to="Region"), - "Remark": fields.Str(required=False, dump_to="Remark"), - "ShareBandwidthId": fields.Str(required=False, dump_to="ShareBandwidthId"), - "Tag": fields.Str(required=False, dump_to="Tag"), - } - - -class AllocateEIPResponseSchema(schema.ResponseSchema): - """ AllocateEIP - 根据提供信息, 申请弹性IP - """ - - fields = { - "EIPSet": fields.List( - models.UnetAllocateEIPSetSchema(), required=False, load_from="EIPSet" - ) - } - - -""" -API: AllocateShareBandwidth - -开通共享带宽 -""" - - -class AllocateShareBandwidthRequestSchema(schema.RequestSchema): - """ AllocateShareBandwidth - 开通共享带宽 - """ - - fields = { - "BwType": fields.Str(required=False, dump_to="BwType"), - "ChargeType": fields.Str(required=True, dump_to="ChargeType"), - "Name": fields.Str(required=True, dump_to="Name"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Quantity": fields.Int(required=False, dump_to="Quantity"), - "Region": fields.Str(required=True, dump_to="Region"), - "ShareBandwidth": fields.Int(required=True, dump_to="ShareBandwidth"), - "ShareBandwidthGuarantee": fields.Int( - required=False, dump_to="ShareBandwidthGuarantee" - ), - } - - -class AllocateShareBandwidthResponseSchema(schema.ResponseSchema): - """ AllocateShareBandwidth - 开通共享带宽 - """ - - fields = { - "ShareBandwidthId": fields.Str(required=False, load_from="ShareBandwidthId") - } - - -""" -API: AllocateVIP - -根据提供信息,申请内网VIP(Virtual IP),多用于高可用程序作为漂移IP。 -""" - - -class AllocateVIPRequestSchema(schema.RequestSchema): - """ AllocateVIP - 根据提供信息,申请内网VIP(Virtual IP),多用于高可用程序作为漂移IP。 - """ - - fields = { - "BusinessId": fields.Str(required=False, dump_to="BusinessId"), - "Count": fields.Int(required=False, dump_to="Count"), - "Ip": fields.Str(required=False, dump_to="Ip"), - "Name": fields.Str(required=False, dump_to="Name"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Remark": fields.Str(required=False, dump_to="Remark"), - "SubnetId": fields.Str(required=True, dump_to="SubnetId"), - "Tag": fields.Str(required=False, dump_to="Tag"), - "VPCId": fields.Str(required=True, dump_to="VPCId"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class AllocateVIPResponseSchema(schema.ResponseSchema): - """ AllocateVIP - 根据提供信息,申请内网VIP(Virtual IP),多用于高可用程序作为漂移IP。 - """ - - fields = { - "DataSet": fields.List(fields.Str(), required=False, load_from="DataSet"), - "VIPSet": fields.List( - models.VIPSetSchema(), required=False, load_from="VIPSet" - ), - } - - -""" -API: AssociateEIPWithShareBandwidth - -将EIP加入共享带宽 -""" - - -class AssociateEIPWithShareBandwidthRequestSchema(schema.RequestSchema): - """ AssociateEIPWithShareBandwidth - 将EIP加入共享带宽 - """ - - fields = { - "EIPIds": fields.List(fields.Str()), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "ShareBandwidthId": fields.Str(required=True, dump_to="ShareBandwidthId"), - } - - -class AssociateEIPWithShareBandwidthResponseSchema(schema.ResponseSchema): - """ AssociateEIPWithShareBandwidth - 将EIP加入共享带宽 - """ - - fields = {} - - -""" -API: BindEIP - -将尚未使用的弹性IP绑定到指定的资源 -""" - - -class BindEIPRequestSchema(schema.RequestSchema): - """ BindEIP - 将尚未使用的弹性IP绑定到指定的资源 - """ - - fields = { - "EIPId": fields.Str(required=True, dump_to="EIPId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "ResourceId": fields.Str(required=True, dump_to="ResourceId"), - "ResourceType": fields.Str(required=True, dump_to="ResourceType"), - } - - -class BindEIPResponseSchema(schema.ResponseSchema): - """ BindEIP - 将尚未使用的弹性IP绑定到指定的资源 - """ - - fields = {} - - -""" -API: CreateBandwidthPackage - -为非共享带宽模式下, 已绑定资源实例的带宽计费弹性IP附加临时带宽包 -""" - - -class CreateBandwidthPackageRequestSchema(schema.RequestSchema): - """ CreateBandwidthPackage - 为非共享带宽模式下, 已绑定资源实例的带宽计费弹性IP附加临时带宽包 - """ - - fields = { - "Bandwidth": fields.Int(required=True, dump_to="Bandwidth"), - "CouponId": fields.Str(required=False, dump_to="CouponId"), - "EIPId": fields.Str(required=True, dump_to="EIPId"), - "EnableTime": fields.Int(required=False, dump_to="EnableTime"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "TimeRange": fields.Int(required=True, dump_to="TimeRange"), - } - - -class CreateBandwidthPackageResponseSchema(schema.ResponseSchema): - """ CreateBandwidthPackage - 为非共享带宽模式下, 已绑定资源实例的带宽计费弹性IP附加临时带宽包 - """ - - fields = { - "BandwidthPackageId": fields.Str(required=False, load_from="BandwidthPackageId") - } - - -""" -API: CreateFirewall - -创建防火墙 -""" - - -class CreateFirewallRequestSchema(schema.RequestSchema): - """ CreateFirewall - 创建防火墙 - """ - - fields = { - "Name": fields.Str(required=True, dump_to="Name"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Remark": fields.Str(required=False, dump_to="Remark"), - "Rule": fields.List(fields.Str()), - "Tag": fields.Str(required=False, dump_to="Tag"), - } - - -class CreateFirewallResponseSchema(schema.ResponseSchema): - """ CreateFirewall - 创建防火墙 - """ - - fields = {"FWId": fields.Str(required=False, load_from="FWId")} - - -""" -API: DeleteBandwidthPackage - -删除弹性IP上已附加带宽包 -""" - - -class DeleteBandwidthPackageRequestSchema(schema.RequestSchema): - """ DeleteBandwidthPackage - 删除弹性IP上已附加带宽包 - """ - - fields = { - "BandwidthPackageId": fields.Str(required=True, dump_to="BandwidthPackageId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - } - - -class DeleteBandwidthPackageResponseSchema(schema.ResponseSchema): - """ DeleteBandwidthPackage - 删除弹性IP上已附加带宽包 - """ - - fields = {} - - -""" -API: DeleteFirewall - -删除防火墙 -""" - - -class DeleteFirewallRequestSchema(schema.RequestSchema): - """ DeleteFirewall - 删除防火墙 - """ - - fields = { - "FWId": fields.Str(required=True, dump_to="FWId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - } - - -class DeleteFirewallResponseSchema(schema.ResponseSchema): - """ DeleteFirewall - 删除防火墙 - """ - - fields = {} - - -""" -API: DescribeBandwidthPackage - -获取某地域下的带宽包信息 -""" - - -class DescribeBandwidthPackageRequestSchema(schema.RequestSchema): - """ DescribeBandwidthPackage - 获取某地域下的带宽包信息 - """ - - fields = { - "Limit": fields.Int(required=False, dump_to="Limit"), - "Offset": fields.Int(required=False, dump_to="Offset"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - } - - -class DescribeBandwidthPackageResponseSchema(schema.ResponseSchema): - """ DescribeBandwidthPackage - 获取某地域下的带宽包信息 - """ - - fields = { - "DataSets": fields.List( - models.UnetBandwidthPackageSetSchema(), required=False, load_from="DataSets" - ), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - } - - -""" -API: DescribeBandwidthUsage - -获取带宽用量信息 -""" - - -class DescribeBandwidthUsageRequestSchema(schema.RequestSchema): - """ DescribeBandwidthUsage - 获取带宽用量信息 - """ - - fields = { - "EIPIds": fields.List(fields.Str()), - "Limit": fields.Int(required=False, dump_to="Limit"), - "OffSet": fields.Int(required=False, dump_to="OffSet"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - } - - -class DescribeBandwidthUsageResponseSchema(schema.ResponseSchema): - """ DescribeBandwidthUsage - 获取带宽用量信息 - """ - - fields = { - "EIPSet": fields.List( - models.UnetBandwidthUsageEIPSetSchema(), required=False, load_from="EIPSet" - ), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - } - - -""" -API: DescribeEIP - -获取弹性IP信息 -""" - - -class DescribeEIPRequestSchema(schema.RequestSchema): - """ DescribeEIP - 获取弹性IP信息 - """ - - fields = { - "EIPIds": fields.List(fields.Str()), - "Limit": fields.Int(required=False, dump_to="Limit"), - "Offset": fields.Int(required=False, dump_to="Offset"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - } - - -class DescribeEIPResponseSchema(schema.ResponseSchema): - """ DescribeEIP - 获取弹性IP信息 - """ - - fields = { - "EIPSet": fields.List( - models.UnetEIPSetSchema(), required=False, load_from="EIPSet" - ), - "TotalBandwidth": fields.Int(required=False, load_from="TotalBandwidth"), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - } - - -""" -API: DescribeFirewall - -获取防火墙组信息 -""" - - -class DescribeFirewallRequestSchema(schema.RequestSchema): - """ DescribeFirewall - 获取防火墙组信息 - """ - - fields = { - "FWId": fields.Str(required=False, dump_to="FWId"), - "Limit": fields.Int(required=False, dump_to="Limit"), - "Offset": fields.Int(required=False, dump_to="Offset"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "ResourceId": fields.Str(required=False, dump_to="ResourceId"), - "ResourceType": fields.Str(required=False, dump_to="ResourceType"), - } - - -class DescribeFirewallResponseSchema(schema.ResponseSchema): - """ DescribeFirewall - 获取防火墙组信息 - """ - - fields = { - "DataSet": fields.List( - models.FirewallDataSetSchema(), required=False, load_from="DataSet" - ), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - } - - -""" -API: DescribeFirewallResource - -获取防火墙组所绑定资源的外网IP -""" - - -class DescribeFirewallResourceRequestSchema(schema.RequestSchema): - """ DescribeFirewallResource - 获取防火墙组所绑定资源的外网IP - """ - - fields = { - "FWId": fields.Str(required=True, dump_to="FWId"), - "Limit": fields.Int(required=False, dump_to="Limit"), - "Offset": fields.Int(required=False, dump_to="Offset"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - } - - -class DescribeFirewallResourceResponseSchema(schema.ResponseSchema): - """ DescribeFirewallResource - 获取防火墙组所绑定资源的外网IP - """ - - fields = { - "ResourceSet": fields.List( - models.ResourceSetSchema(), required=False, load_from="ResourceSet" - ), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - } - - -""" -API: DescribeShareBandwidth - -获取共享带宽信息 -""" - - -class DescribeShareBandwidthRequestSchema(schema.RequestSchema): - """ DescribeShareBandwidth - 获取共享带宽信息 - """ - - fields = { - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "ShareBandwidthIds": fields.List(fields.Str()), - } - - -class DescribeShareBandwidthResponseSchema(schema.ResponseSchema): - """ DescribeShareBandwidth - 获取共享带宽信息 - """ - - fields = { - "DataSet": fields.List( - models.UnetShareBandwidthSetSchema(), required=False, load_from="DataSet" - ), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - } - - -""" -API: DescribeVIP - -获取内网VIP详细信息 -""" - - -class DescribeVIPRequestSchema(schema.RequestSchema): - """ DescribeVIP - 获取内网VIP详细信息 - """ - - fields = { - "BusinessId": fields.Str(required=False, dump_to="BusinessId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "SubnetId": fields.Str(required=False, dump_to="SubnetId"), - "Tag": fields.Str(required=False, dump_to="Tag"), - "VPCId": fields.Str(required=False, dump_to="VPCId"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class DescribeVIPResponseSchema(schema.ResponseSchema): - """ DescribeVIP - 获取内网VIP详细信息 - """ - - fields = { - "DataSet": fields.List(fields.Str(), required=False, load_from="DataSet"), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - "VIPSet": fields.List( - models.VIPDetailSetSchema(), required=False, load_from="VIPSet" - ), - } - - -""" -API: DisassociateEIPWithShareBandwidth - -将EIP移出共享带宽 -""" - - -class DisassociateEIPWithShareBandwidthRequestSchema(schema.RequestSchema): - """ DisassociateEIPWithShareBandwidth - 将EIP移出共享带宽 - """ - - fields = { - "Bandwidth": fields.Int(required=True, dump_to="Bandwidth"), - "EIPIds": fields.List(fields.Str()), - "PayMode": fields.Str(required=False, dump_to="PayMode"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "ShareBandwidthId": fields.Str(required=True, dump_to="ShareBandwidthId"), - } - - -class DisassociateEIPWithShareBandwidthResponseSchema(schema.ResponseSchema): - """ DisassociateEIPWithShareBandwidth - 将EIP移出共享带宽 - """ - - fields = {} - - -""" -API: GetEIPPayMode - -获取弹性IP计费模式 -""" - - -class GetEIPPayModeRequestSchema(schema.RequestSchema): - """ GetEIPPayMode - 获取弹性IP计费模式 - """ - - fields = { - "EIPId": fields.List(fields.Str()), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - } - - -class GetEIPPayModeResponseSchema(schema.ResponseSchema): - """ GetEIPPayMode - 获取弹性IP计费模式 - """ - - fields = { - "EIPPayMode": fields.List( - models.EIPPayModeSetSchema(), required=False, load_from="EIPPayMode" - ) - } - - -""" -API: GetEIPPrice - -获取弹性IP价格 -""" - - -class GetEIPPriceRequestSchema(schema.RequestSchema): - """ GetEIPPrice - 获取弹性IP价格 - """ - - fields = { - "Bandwidth": fields.Int(required=True, dump_to="Bandwidth"), - "ChargeType": fields.Str(required=False, dump_to="ChargeType"), - "OperatorName": fields.Str(required=True, dump_to="OperatorName"), - "PayMode": fields.Str(required=False, dump_to="PayMode"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Quantity": fields.Int(required=False, dump_to="Quantity"), - "Region": fields.Str(required=True, dump_to="Region"), - } - - -class GetEIPPriceResponseSchema(schema.ResponseSchema): - """ GetEIPPrice - 获取弹性IP价格 - """ - - fields = { - "PriceSet": fields.List( - models.EIPPriceDetailSetSchema(), required=False, load_from="PriceSet" - ) - } - - -""" -API: GetEIPUpgradePrice - -获取弹性IP带宽改动价格 -""" - - -class GetEIPUpgradePriceRequestSchema(schema.RequestSchema): - """ GetEIPUpgradePrice - 获取弹性IP带宽改动价格 - """ - - fields = { - "Bandwidth": fields.Int(required=True, dump_to="Bandwidth"), - "EIPId": fields.Str(required=True, dump_to="EIPId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - } - - -class GetEIPUpgradePriceResponseSchema(schema.ResponseSchema): - """ GetEIPUpgradePrice - 获取弹性IP带宽改动价格 - """ - - fields = {"Price": fields.Float(required=False, load_from="Price")} - - -""" -API: GrantFirewall - -将防火墙应用到资源上 -""" - - -class GrantFirewallRequestSchema(schema.RequestSchema): - """ GrantFirewall - 将防火墙应用到资源上 - """ - - fields = { - "FWId": fields.Str(required=True, dump_to="FWId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "ResourceId": fields.Str(required=True, dump_to="ResourceId"), - "ResourceType": fields.Str(required=True, dump_to="ResourceType"), - } - - -class GrantFirewallResponseSchema(schema.ResponseSchema): - """ GrantFirewall - 将防火墙应用到资源上 - """ - - fields = {} - - -""" -API: ModifyEIPBandwidth - -调整弹性IP的外网带宽 -""" - - -class ModifyEIPBandwidthRequestSchema(schema.RequestSchema): - """ ModifyEIPBandwidth - 调整弹性IP的外网带宽 - """ - - fields = { - "Bandwidth": fields.Int(required=True, dump_to="Bandwidth"), - "EIPId": fields.Str(required=True, dump_to="EIPId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - } - - -class ModifyEIPBandwidthResponseSchema(schema.ResponseSchema): - """ ModifyEIPBandwidth - 调整弹性IP的外网带宽 - """ - - fields = {} - - -""" -API: ModifyEIPWeight - -修改弹性IP的外网出口权重 -""" - - -class ModifyEIPWeightRequestSchema(schema.RequestSchema): - """ ModifyEIPWeight - 修改弹性IP的外网出口权重 - """ - - fields = { - "EIPId": fields.Str(required=True, dump_to="EIPId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Weight": fields.Int(required=True, dump_to="Weight"), - } - - -class ModifyEIPWeightResponseSchema(schema.ResponseSchema): - """ ModifyEIPWeight - 修改弹性IP的外网出口权重 - """ - - fields = {} - - -""" -API: ReleaseEIP - -释放弹性IP资源, 所释放弹性IP必须为非绑定状态. -""" - - -class ReleaseEIPRequestSchema(schema.RequestSchema): - """ ReleaseEIP - 释放弹性IP资源, 所释放弹性IP必须为非绑定状态. - """ - - fields = { - "EIPId": fields.Str(required=True, dump_to="EIPId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - } - - -class ReleaseEIPResponseSchema(schema.ResponseSchema): - """ ReleaseEIP - 释放弹性IP资源, 所释放弹性IP必须为非绑定状态. - """ - - fields = {} - - -""" -API: ReleaseShareBandwidth - -关闭共享带宽 -""" - - -class ReleaseShareBandwidthRequestSchema(schema.RequestSchema): - """ ReleaseShareBandwidth - 关闭共享带宽 - """ - - fields = { - "EIPBandwidth": fields.Int(required=True, dump_to="EIPBandwidth"), - "PayMode": fields.Str(required=False, dump_to="PayMode"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "ShareBandwidthId": fields.Str(required=True, dump_to="ShareBandwidthId"), - } - - -class ReleaseShareBandwidthResponseSchema(schema.ResponseSchema): - """ ReleaseShareBandwidth - 关闭共享带宽 - """ - - fields = {} - - -""" -API: ReleaseVIP - -释放VIP资源 -""" - - -class ReleaseVIPRequestSchema(schema.RequestSchema): - """ ReleaseVIP - 释放VIP资源 - """ - - fields = { - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "VIPId": fields.Str(required=True, dump_to="VIPId"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class ReleaseVIPResponseSchema(schema.ResponseSchema): - """ ReleaseVIP - 释放VIP资源 - """ - - fields = {} - - -""" -API: ResizeShareBandwidth - -调整共享带宽的带宽值 -""" - - -class ResizeShareBandwidthRequestSchema(schema.RequestSchema): - """ ResizeShareBandwidth - 调整共享带宽的带宽值 - """ - - fields = { - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "ShareBandwidth": fields.Int(required=True, dump_to="ShareBandwidth"), - "ShareBandwidthId": fields.Str(required=True, dump_to="ShareBandwidthId"), - } - - -class ResizeShareBandwidthResponseSchema(schema.ResponseSchema): - """ ResizeShareBandwidth - 调整共享带宽的带宽值 - """ - - fields = {} - - -""" -API: SetEIPPayMode - -设置弹性IP计费模式, 切换时会涉及付费/退费. -""" - - -class SetEIPPayModeRequestSchema(schema.RequestSchema): - """ SetEIPPayMode - 设置弹性IP计费模式, 切换时会涉及付费/退费. - """ - - fields = { - "Bandwidth": fields.Int(required=True, dump_to="Bandwidth"), - "EIPId": fields.Str(required=True, dump_to="EIPId"), - "PayMode": fields.Str(required=True, dump_to="PayMode"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - } - - -class SetEIPPayModeResponseSchema(schema.ResponseSchema): - """ SetEIPPayMode - 设置弹性IP计费模式, 切换时会涉及付费/退费. - """ - - fields = {} - - -""" -API: UnBindEIP - -将弹性IP从资源上解绑 -""" - - -class UnBindEIPRequestSchema(schema.RequestSchema): - """ UnBindEIP - 将弹性IP从资源上解绑 - """ - - fields = { - "EIPId": fields.Str(required=True, dump_to="EIPId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "ResourceId": fields.Str(required=True, dump_to="ResourceId"), - "ResourceType": fields.Str(required=True, dump_to="ResourceType"), - } - - -class UnBindEIPResponseSchema(schema.ResponseSchema): - """ UnBindEIP - 将弹性IP从资源上解绑 - """ - - fields = {} - - -""" -API: UpdateEIPAttribute - -更新弹性IP名称,业务组,备注等属性字段 -""" - - -class UpdateEIPAttributeRequestSchema(schema.RequestSchema): - """ UpdateEIPAttribute - 更新弹性IP名称,业务组,备注等属性字段 - """ - - fields = { - "EIPId": fields.Str(required=True, dump_to="EIPId"), - "Name": fields.Str(required=False, dump_to="Name"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Remark": fields.Str(required=False, dump_to="Remark"), - "Tag": fields.Str(required=False, dump_to="Tag"), - } - - -class UpdateEIPAttributeResponseSchema(schema.ResponseSchema): - """ UpdateEIPAttribute - 更新弹性IP名称,业务组,备注等属性字段 - """ - - fields = {} - - -""" -API: UpdateFirewall - -更新防火墙规则 -""" - - -class UpdateFirewallRequestSchema(schema.RequestSchema): - """ UpdateFirewall - 更新防火墙规则 - """ - - fields = { - "FWId": fields.Str(required=True, dump_to="FWId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Rule": fields.List(fields.Str()), - } - - -class UpdateFirewallResponseSchema(schema.ResponseSchema): - """ UpdateFirewall - 更新防火墙规则 - """ - - fields = {"FWId": fields.Str(required=False, load_from="FWId")} - - -""" -API: UpdateFirewallAttribute - -更新防火墙规则 -""" - - -class UpdateFirewallAttributeRequestSchema(schema.RequestSchema): - """ UpdateFirewallAttribute - 更新防火墙规则 - """ - - fields = { - "FWId": fields.Str(required=True, dump_to="FWId"), - "Name": fields.Str(required=False, dump_to="Name"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Remark": fields.Str(required=False, dump_to="Remark"), - "Tag": fields.Str(required=False, dump_to="Tag"), - } - - -class UpdateFirewallAttributeResponseSchema(schema.ResponseSchema): - """ UpdateFirewallAttribute - 更新防火墙规则 - """ - - fields = {} +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.typesystem import schema, fields +from ucloud.services.unet.schemas import models + +""" UNet API Schema +""" +""" +API: AllocateEIP + +根据提供信息, 申请弹性IP +""" + + +class AllocateEIPRequestSchema(schema.RequestSchema): + """ AllocateEIP - 根据提供信息, 申请弹性IP + """ + + fields = { + "Bandwidth": fields.Int(required=True, dump_to="Bandwidth"), + "ChargeType": fields.Str(required=False, dump_to="ChargeType"), + "CouponId": fields.Str(required=False, dump_to="CouponId"), + "Name": fields.Str(required=False, dump_to="Name"), + "OperatorName": fields.Str(required=True, dump_to="OperatorName"), + "PayMode": fields.Str(required=False, dump_to="PayMode"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Quantity": fields.Int(required=False, dump_to="Quantity"), + "Region": fields.Str(required=True, dump_to="Region"), + "Remark": fields.Str(required=False, dump_to="Remark"), + "ShareBandwidthId": fields.Str( + required=False, dump_to="ShareBandwidthId" + ), + "Tag": fields.Str(required=False, dump_to="Tag"), + } + + +class AllocateEIPResponseSchema(schema.ResponseSchema): + """ AllocateEIP - 根据提供信息, 申请弹性IP + """ + + fields = { + "EIPSet": fields.List( + models.UnetAllocateEIPSetSchema(), + required=False, + load_from="EIPSet", + ) + } + + +""" +API: AllocateShareBandwidth + +开通共享带宽 +""" + + +class AllocateShareBandwidthRequestSchema(schema.RequestSchema): + """ AllocateShareBandwidth - 开通共享带宽 + """ + + fields = { + "BwType": fields.Str(required=False, dump_to="BwType"), + "ChargeType": fields.Str(required=True, dump_to="ChargeType"), + "Name": fields.Str(required=True, dump_to="Name"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Quantity": fields.Int(required=False, dump_to="Quantity"), + "Region": fields.Str(required=True, dump_to="Region"), + "ShareBandwidth": fields.Int(required=True, dump_to="ShareBandwidth"), + "ShareBandwidthGuarantee": fields.Int( + required=False, dump_to="ShareBandwidthGuarantee" + ), + } + + +class AllocateShareBandwidthResponseSchema(schema.ResponseSchema): + """ AllocateShareBandwidth - 开通共享带宽 + """ + + fields = { + "ShareBandwidthId": fields.Str( + required=False, load_from="ShareBandwidthId" + ) + } + + +""" +API: AllocateVIP + +根据提供信息,申请内网VIP(Virtual IP),多用于高可用程序作为漂移IP。 +""" + + +class AllocateVIPRequestSchema(schema.RequestSchema): + """ AllocateVIP - 根据提供信息,申请内网VIP(Virtual IP),多用于高可用程序作为漂移IP。 + """ + + fields = { + "BusinessId": fields.Str(required=False, dump_to="BusinessId"), + "Count": fields.Int(required=False, dump_to="Count"), + "Ip": fields.Str(required=False, dump_to="Ip"), + "Name": fields.Str(required=False, dump_to="Name"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Remark": fields.Str(required=False, dump_to="Remark"), + "SubnetId": fields.Str(required=True, dump_to="SubnetId"), + "Tag": fields.Str(required=False, dump_to="Tag"), + "VPCId": fields.Str(required=True, dump_to="VPCId"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class AllocateVIPResponseSchema(schema.ResponseSchema): + """ AllocateVIP - 根据提供信息,申请内网VIP(Virtual IP),多用于高可用程序作为漂移IP。 + """ + + fields = { + "DataSet": fields.List( + fields.Str(), required=False, load_from="DataSet" + ), + "VIPSet": fields.List( + models.VIPSetSchema(), required=False, load_from="VIPSet" + ), + } + + +""" +API: AssociateEIPWithShareBandwidth + +将EIP加入共享带宽 +""" + + +class AssociateEIPWithShareBandwidthRequestSchema(schema.RequestSchema): + """ AssociateEIPWithShareBandwidth - 将EIP加入共享带宽 + """ + + fields = { + "EIPIds": fields.List(fields.Str()), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "ShareBandwidthId": fields.Str( + required=True, dump_to="ShareBandwidthId" + ), + } + + +class AssociateEIPWithShareBandwidthResponseSchema(schema.ResponseSchema): + """ AssociateEIPWithShareBandwidth - 将EIP加入共享带宽 + """ + + fields = {} + + +""" +API: BindEIP + +将尚未使用的弹性IP绑定到指定的资源 +""" + + +class BindEIPRequestSchema(schema.RequestSchema): + """ BindEIP - 将尚未使用的弹性IP绑定到指定的资源 + """ + + fields = { + "EIPId": fields.Str(required=True, dump_to="EIPId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "ResourceId": fields.Str(required=True, dump_to="ResourceId"), + "ResourceType": fields.Str(required=True, dump_to="ResourceType"), + } + + +class BindEIPResponseSchema(schema.ResponseSchema): + """ BindEIP - 将尚未使用的弹性IP绑定到指定的资源 + """ + + fields = {} + + +""" +API: CreateBandwidthPackage + +为非共享带宽模式下, 已绑定资源实例的带宽计费弹性IP附加临时带宽包 +""" + + +class CreateBandwidthPackageRequestSchema(schema.RequestSchema): + """ CreateBandwidthPackage - 为非共享带宽模式下, 已绑定资源实例的带宽计费弹性IP附加临时带宽包 + """ + + fields = { + "Bandwidth": fields.Int(required=True, dump_to="Bandwidth"), + "CouponId": fields.Str(required=False, dump_to="CouponId"), + "EIPId": fields.Str(required=True, dump_to="EIPId"), + "EnableTime": fields.Int(required=False, dump_to="EnableTime"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "TimeRange": fields.Int(required=True, dump_to="TimeRange"), + } + + +class CreateBandwidthPackageResponseSchema(schema.ResponseSchema): + """ CreateBandwidthPackage - 为非共享带宽模式下, 已绑定资源实例的带宽计费弹性IP附加临时带宽包 + """ + + fields = { + "BandwidthPackageId": fields.Str( + required=False, load_from="BandwidthPackageId" + ) + } + + +""" +API: CreateFirewall + +创建防火墙 +""" + + +class CreateFirewallRequestSchema(schema.RequestSchema): + """ CreateFirewall - 创建防火墙 + """ + + fields = { + "Name": fields.Str(required=True, dump_to="Name"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Remark": fields.Str(required=False, dump_to="Remark"), + "Rule": fields.List(fields.Str()), + "Tag": fields.Str(required=False, dump_to="Tag"), + } + + +class CreateFirewallResponseSchema(schema.ResponseSchema): + """ CreateFirewall - 创建防火墙 + """ + + fields = {"FWId": fields.Str(required=False, load_from="FWId")} + + +""" +API: DeleteBandwidthPackage + +删除弹性IP上已附加带宽包 +""" + + +class DeleteBandwidthPackageRequestSchema(schema.RequestSchema): + """ DeleteBandwidthPackage - 删除弹性IP上已附加带宽包 + """ + + fields = { + "BandwidthPackageId": fields.Str( + required=True, dump_to="BandwidthPackageId" + ), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + } + + +class DeleteBandwidthPackageResponseSchema(schema.ResponseSchema): + """ DeleteBandwidthPackage - 删除弹性IP上已附加带宽包 + """ + + fields = {} + + +""" +API: DeleteFirewall + +删除防火墙 +""" + + +class DeleteFirewallRequestSchema(schema.RequestSchema): + """ DeleteFirewall - 删除防火墙 + """ + + fields = { + "FWId": fields.Str(required=True, dump_to="FWId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + } + + +class DeleteFirewallResponseSchema(schema.ResponseSchema): + """ DeleteFirewall - 删除防火墙 + """ + + fields = {} + + +""" +API: DescribeBandwidthPackage + +获取某地域下的带宽包信息 +""" + + +class DescribeBandwidthPackageRequestSchema(schema.RequestSchema): + """ DescribeBandwidthPackage - 获取某地域下的带宽包信息 + """ + + fields = { + "Limit": fields.Int(required=False, dump_to="Limit"), + "Offset": fields.Int(required=False, dump_to="Offset"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + } + + +class DescribeBandwidthPackageResponseSchema(schema.ResponseSchema): + """ DescribeBandwidthPackage - 获取某地域下的带宽包信息 + """ + + fields = { + "DataSets": fields.List( + models.UnetBandwidthPackageSetSchema(), + required=False, + load_from="DataSets", + ), + "TotalCount": fields.Int(required=False, load_from="TotalCount"), + } + + +""" +API: DescribeBandwidthUsage + +获取带宽用量信息 +""" + + +class DescribeBandwidthUsageRequestSchema(schema.RequestSchema): + """ DescribeBandwidthUsage - 获取带宽用量信息 + """ + + fields = { + "EIPIds": fields.List(fields.Str()), + "Limit": fields.Int(required=False, dump_to="Limit"), + "OffSet": fields.Int(required=False, dump_to="OffSet"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + } + + +class DescribeBandwidthUsageResponseSchema(schema.ResponseSchema): + """ DescribeBandwidthUsage - 获取带宽用量信息 + """ + + fields = { + "EIPSet": fields.List( + models.UnetBandwidthUsageEIPSetSchema(), + required=False, + load_from="EIPSet", + ), + "TotalCount": fields.Int(required=False, load_from="TotalCount"), + } + + +""" +API: DescribeEIP + +获取弹性IP信息 +""" + + +class DescribeEIPRequestSchema(schema.RequestSchema): + """ DescribeEIP - 获取弹性IP信息 + """ + + fields = { + "EIPIds": fields.List(fields.Str()), + "Limit": fields.Int(required=False, dump_to="Limit"), + "Offset": fields.Int(required=False, dump_to="Offset"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + } + + +class DescribeEIPResponseSchema(schema.ResponseSchema): + """ DescribeEIP - 获取弹性IP信息 + """ + + fields = { + "EIPSet": fields.List( + models.UnetEIPSetSchema(), required=False, load_from="EIPSet" + ), + "TotalBandwidth": fields.Int( + required=False, load_from="TotalBandwidth" + ), + "TotalCount": fields.Int(required=False, load_from="TotalCount"), + } + + +""" +API: DescribeFirewall + +获取防火墙组信息 +""" + + +class DescribeFirewallRequestSchema(schema.RequestSchema): + """ DescribeFirewall - 获取防火墙组信息 + """ + + fields = { + "FWId": fields.Str(required=False, dump_to="FWId"), + "Limit": fields.Int(required=False, dump_to="Limit"), + "Offset": fields.Int(required=False, dump_to="Offset"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "ResourceId": fields.Str(required=False, dump_to="ResourceId"), + "ResourceType": fields.Str(required=False, dump_to="ResourceType"), + } + + +class DescribeFirewallResponseSchema(schema.ResponseSchema): + """ DescribeFirewall - 获取防火墙组信息 + """ + + fields = { + "DataSet": fields.List( + models.FirewallDataSetSchema(), required=False, load_from="DataSet" + ), + "TotalCount": fields.Int(required=False, load_from="TotalCount"), + } + + +""" +API: DescribeFirewallResource + +获取防火墙组所绑定资源的外网IP +""" + + +class DescribeFirewallResourceRequestSchema(schema.RequestSchema): + """ DescribeFirewallResource - 获取防火墙组所绑定资源的外网IP + """ + + fields = { + "FWId": fields.Str(required=True, dump_to="FWId"), + "Limit": fields.Int(required=False, dump_to="Limit"), + "Offset": fields.Int(required=False, dump_to="Offset"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + } + + +class DescribeFirewallResourceResponseSchema(schema.ResponseSchema): + """ DescribeFirewallResource - 获取防火墙组所绑定资源的外网IP + """ + + fields = { + "ResourceSet": fields.List( + models.ResourceSetSchema(), required=False, load_from="ResourceSet" + ), + "TotalCount": fields.Int(required=False, load_from="TotalCount"), + } + + +""" +API: DescribeShareBandwidth + +获取共享带宽信息 +""" + + +class DescribeShareBandwidthRequestSchema(schema.RequestSchema): + """ DescribeShareBandwidth - 获取共享带宽信息 + """ + + fields = { + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "ShareBandwidthIds": fields.List(fields.Str()), + } + + +class DescribeShareBandwidthResponseSchema(schema.ResponseSchema): + """ DescribeShareBandwidth - 获取共享带宽信息 + """ + + fields = { + "DataSet": fields.List( + models.UnetShareBandwidthSetSchema(), + required=False, + load_from="DataSet", + ), + "TotalCount": fields.Int(required=False, load_from="TotalCount"), + } + + +""" +API: DescribeVIP + +获取内网VIP详细信息 +""" + + +class DescribeVIPRequestSchema(schema.RequestSchema): + """ DescribeVIP - 获取内网VIP详细信息 + """ + + fields = { + "BusinessId": fields.Str(required=False, dump_to="BusinessId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "SubnetId": fields.Str(required=False, dump_to="SubnetId"), + "Tag": fields.Str(required=False, dump_to="Tag"), + "VPCId": fields.Str(required=False, dump_to="VPCId"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class DescribeVIPResponseSchema(schema.ResponseSchema): + """ DescribeVIP - 获取内网VIP详细信息 + """ + + fields = { + "DataSet": fields.List( + fields.Str(), required=False, load_from="DataSet" + ), + "TotalCount": fields.Int(required=False, load_from="TotalCount"), + "VIPSet": fields.List( + models.VIPDetailSetSchema(), required=False, load_from="VIPSet" + ), + } + + +""" +API: DisassociateEIPWithShareBandwidth + +将EIP移出共享带宽 +""" + + +class DisassociateEIPWithShareBandwidthRequestSchema(schema.RequestSchema): + """ DisassociateEIPWithShareBandwidth - 将EIP移出共享带宽 + """ + + fields = { + "Bandwidth": fields.Int(required=True, dump_to="Bandwidth"), + "EIPIds": fields.List(fields.Str()), + "PayMode": fields.Str(required=False, dump_to="PayMode"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "ShareBandwidthId": fields.Str( + required=True, dump_to="ShareBandwidthId" + ), + } + + +class DisassociateEIPWithShareBandwidthResponseSchema(schema.ResponseSchema): + """ DisassociateEIPWithShareBandwidth - 将EIP移出共享带宽 + """ + + fields = {} + + +""" +API: GetEIPPayMode + +获取弹性IP计费模式 +""" + + +class GetEIPPayModeRequestSchema(schema.RequestSchema): + """ GetEIPPayMode - 获取弹性IP计费模式 + """ + + fields = { + "EIPId": fields.List(fields.Str()), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + } + + +class GetEIPPayModeResponseSchema(schema.ResponseSchema): + """ GetEIPPayMode - 获取弹性IP计费模式 + """ + + fields = { + "EIPPayMode": fields.List( + models.EIPPayModeSetSchema(), required=False, load_from="EIPPayMode" + ) + } + + +""" +API: GetEIPPrice + +获取弹性IP价格 +""" + + +class GetEIPPriceRequestSchema(schema.RequestSchema): + """ GetEIPPrice - 获取弹性IP价格 + """ + + fields = { + "Bandwidth": fields.Int(required=True, dump_to="Bandwidth"), + "ChargeType": fields.Str(required=False, dump_to="ChargeType"), + "OperatorName": fields.Str(required=True, dump_to="OperatorName"), + "PayMode": fields.Str(required=False, dump_to="PayMode"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Quantity": fields.Int(required=False, dump_to="Quantity"), + "Region": fields.Str(required=True, dump_to="Region"), + } + + +class GetEIPPriceResponseSchema(schema.ResponseSchema): + """ GetEIPPrice - 获取弹性IP价格 + """ + + fields = { + "PriceSet": fields.List( + models.EIPPriceDetailSetSchema(), + required=False, + load_from="PriceSet", + ) + } + + +""" +API: GetEIPUpgradePrice + +获取弹性IP带宽改动价格 +""" + + +class GetEIPUpgradePriceRequestSchema(schema.RequestSchema): + """ GetEIPUpgradePrice - 获取弹性IP带宽改动价格 + """ + + fields = { + "Bandwidth": fields.Int(required=True, dump_to="Bandwidth"), + "EIPId": fields.Str(required=True, dump_to="EIPId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + } + + +class GetEIPUpgradePriceResponseSchema(schema.ResponseSchema): + """ GetEIPUpgradePrice - 获取弹性IP带宽改动价格 + """ + + fields = {"Price": fields.Float(required=False, load_from="Price")} + + +""" +API: GrantFirewall + +将防火墙应用到资源上 +""" + + +class GrantFirewallRequestSchema(schema.RequestSchema): + """ GrantFirewall - 将防火墙应用到资源上 + """ + + fields = { + "FWId": fields.Str(required=True, dump_to="FWId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "ResourceId": fields.Str(required=True, dump_to="ResourceId"), + "ResourceType": fields.Str(required=True, dump_to="ResourceType"), + } + + +class GrantFirewallResponseSchema(schema.ResponseSchema): + """ GrantFirewall - 将防火墙应用到资源上 + """ + + fields = {} + + +""" +API: ModifyEIPBandwidth + +调整弹性IP的外网带宽 +""" + + +class ModifyEIPBandwidthRequestSchema(schema.RequestSchema): + """ ModifyEIPBandwidth - 调整弹性IP的外网带宽 + """ + + fields = { + "Bandwidth": fields.Int(required=True, dump_to="Bandwidth"), + "EIPId": fields.Str(required=True, dump_to="EIPId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + } + + +class ModifyEIPBandwidthResponseSchema(schema.ResponseSchema): + """ ModifyEIPBandwidth - 调整弹性IP的外网带宽 + """ + + fields = {} + + +""" +API: ModifyEIPWeight + +修改弹性IP的外网出口权重 +""" + + +class ModifyEIPWeightRequestSchema(schema.RequestSchema): + """ ModifyEIPWeight - 修改弹性IP的外网出口权重 + """ + + fields = { + "EIPId": fields.Str(required=True, dump_to="EIPId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Weight": fields.Int(required=True, dump_to="Weight"), + } + + +class ModifyEIPWeightResponseSchema(schema.ResponseSchema): + """ ModifyEIPWeight - 修改弹性IP的外网出口权重 + """ + + fields = {} + + +""" +API: ReleaseEIP + +释放弹性IP资源, 所释放弹性IP必须为非绑定状态. +""" + + +class ReleaseEIPRequestSchema(schema.RequestSchema): + """ ReleaseEIP - 释放弹性IP资源, 所释放弹性IP必须为非绑定状态. + """ + + fields = { + "EIPId": fields.Str(required=True, dump_to="EIPId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + } + + +class ReleaseEIPResponseSchema(schema.ResponseSchema): + """ ReleaseEIP - 释放弹性IP资源, 所释放弹性IP必须为非绑定状态. + """ + + fields = {} + + +""" +API: ReleaseShareBandwidth + +关闭共享带宽 +""" + + +class ReleaseShareBandwidthRequestSchema(schema.RequestSchema): + """ ReleaseShareBandwidth - 关闭共享带宽 + """ + + fields = { + "EIPBandwidth": fields.Int(required=True, dump_to="EIPBandwidth"), + "PayMode": fields.Str(required=False, dump_to="PayMode"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "ShareBandwidthId": fields.Str( + required=True, dump_to="ShareBandwidthId" + ), + } + + +class ReleaseShareBandwidthResponseSchema(schema.ResponseSchema): + """ ReleaseShareBandwidth - 关闭共享带宽 + """ + + fields = {} + + +""" +API: ReleaseVIP + +释放VIP资源 +""" + + +class ReleaseVIPRequestSchema(schema.RequestSchema): + """ ReleaseVIP - 释放VIP资源 + """ + + fields = { + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "VIPId": fields.Str(required=True, dump_to="VIPId"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class ReleaseVIPResponseSchema(schema.ResponseSchema): + """ ReleaseVIP - 释放VIP资源 + """ + + fields = {} + + +""" +API: ResizeShareBandwidth + +调整共享带宽的带宽值 +""" + + +class ResizeShareBandwidthRequestSchema(schema.RequestSchema): + """ ResizeShareBandwidth - 调整共享带宽的带宽值 + """ + + fields = { + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "ShareBandwidth": fields.Int(required=True, dump_to="ShareBandwidth"), + "ShareBandwidthId": fields.Str( + required=True, dump_to="ShareBandwidthId" + ), + } + + +class ResizeShareBandwidthResponseSchema(schema.ResponseSchema): + """ ResizeShareBandwidth - 调整共享带宽的带宽值 + """ + + fields = {} + + +""" +API: SetEIPPayMode + +设置弹性IP计费模式, 切换时会涉及付费/退费. +""" + + +class SetEIPPayModeRequestSchema(schema.RequestSchema): + """ SetEIPPayMode - 设置弹性IP计费模式, 切换时会涉及付费/退费. + """ + + fields = { + "Bandwidth": fields.Int(required=True, dump_to="Bandwidth"), + "EIPId": fields.Str(required=True, dump_to="EIPId"), + "PayMode": fields.Str(required=True, dump_to="PayMode"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + } + + +class SetEIPPayModeResponseSchema(schema.ResponseSchema): + """ SetEIPPayMode - 设置弹性IP计费模式, 切换时会涉及付费/退费. + """ + + fields = {} + + +""" +API: UnBindEIP + +将弹性IP从资源上解绑 +""" + + +class UnBindEIPRequestSchema(schema.RequestSchema): + """ UnBindEIP - 将弹性IP从资源上解绑 + """ + + fields = { + "EIPId": fields.Str(required=True, dump_to="EIPId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "ResourceId": fields.Str(required=True, dump_to="ResourceId"), + "ResourceType": fields.Str(required=True, dump_to="ResourceType"), + } + + +class UnBindEIPResponseSchema(schema.ResponseSchema): + """ UnBindEIP - 将弹性IP从资源上解绑 + """ + + fields = {} + + +""" +API: UpdateEIPAttribute + +更新弹性IP名称,业务组,备注等属性字段 +""" + + +class UpdateEIPAttributeRequestSchema(schema.RequestSchema): + """ UpdateEIPAttribute - 更新弹性IP名称,业务组,备注等属性字段 + """ + + fields = { + "EIPId": fields.Str(required=True, dump_to="EIPId"), + "Name": fields.Str(required=False, dump_to="Name"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Remark": fields.Str(required=False, dump_to="Remark"), + "Tag": fields.Str(required=False, dump_to="Tag"), + } + + +class UpdateEIPAttributeResponseSchema(schema.ResponseSchema): + """ UpdateEIPAttribute - 更新弹性IP名称,业务组,备注等属性字段 + """ + + fields = {} + + +""" +API: UpdateFirewall + +更新防火墙规则 +""" + + +class UpdateFirewallRequestSchema(schema.RequestSchema): + """ UpdateFirewall - 更新防火墙规则 + """ + + fields = { + "FWId": fields.Str(required=True, dump_to="FWId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Rule": fields.List(fields.Str()), + } + + +class UpdateFirewallResponseSchema(schema.ResponseSchema): + """ UpdateFirewall - 更新防火墙规则 + """ + + fields = {"FWId": fields.Str(required=False, load_from="FWId")} + + +""" +API: UpdateFirewallAttribute + +更新防火墙规则 +""" + + +class UpdateFirewallAttributeRequestSchema(schema.RequestSchema): + """ UpdateFirewallAttribute - 更新防火墙规则 + """ + + fields = { + "FWId": fields.Str(required=True, dump_to="FWId"), + "Name": fields.Str(required=False, dump_to="Name"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Remark": fields.Str(required=False, dump_to="Remark"), + "Tag": fields.Str(required=False, dump_to="Tag"), + } + + +class UpdateFirewallAttributeResponseSchema(schema.ResponseSchema): + """ UpdateFirewallAttribute - 更新防火墙规则 + """ + + fields = {} diff --git a/ucloud/services/unet/schemas/models.py b/ucloud/services/unet/schemas/models.py index 6fe0231..ff74a6f 100644 --- a/ucloud/services/unet/schemas/models.py +++ b/ucloud/services/unet/schemas/models.py @@ -1,238 +1,252 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.typesystem import schema, fields - - -class UnetEIPAddrSetSchema(schema.ResponseSchema): - """ UnetEIPAddrSet - DescribeEIP - """ - - fields = { - "IP": fields.Str(required=False, load_from="IP"), - "OperatorName": fields.Str(required=False, load_from="OperatorName"), - } - - -class UnetAllocateEIPSetSchema(schema.ResponseSchema): - """ UnetAllocateEIPSet - AllocateEIP - """ - - fields = { - "EIPAddr": fields.List(UnetEIPAddrSetSchema()), - "EIPId": fields.Str(required=False, load_from="EIPId"), - } - - -class VIPSetSchema(schema.ResponseSchema): - """ VIPSet - VIPSet - """ - - fields = { - "VIP": fields.Str(required=False, load_from="VIP"), - "VIPId": fields.Str(required=False, load_from="VIPId"), - "VPCId": fields.Str(required=False, load_from="VPCId"), - } - - -class EIPAddrSetSchema(schema.ResponseSchema): - """ EIPAddrSet - DescribeShareBandwidth - """ - - fields = { - "IP": fields.Str(required=False, load_from="IP"), - "OperatorName": fields.Str(required=False, load_from="OperatorName"), - } - - -class UnetBandwidthPackageSetSchema(schema.ResponseSchema): - """ UnetBandwidthPackageSet - DescribeBandwidthPackage - """ - - fields = { - "Bandwidth": fields.Int(required=False, load_from="Bandwidth"), - "BandwidthPackageId": fields.Str( - required=False, load_from="BandwidthPackageId" - ), - "CreateTime": fields.Int(required=False, load_from="CreateTime"), - "DisableTime": fields.Int(required=False, load_from="DisableTime"), - "EIPAddr": fields.List(EIPAddrSetSchema()), - "EIPId": fields.Str(required=False, load_from="EIPId"), - "EnableTime": fields.Int(required=False, load_from="EnableTime"), - } - - -class UnetBandwidthUsageEIPSetSchema(schema.ResponseSchema): - """ UnetBandwidthUsageEIPSet - DescribeBandwidthUsage - """ - - fields = { - "CurBandwidth": fields.Float(required=False, load_from="CurBandwidth"), - "EIPId": fields.Str(required=False, load_from="EIPId"), - } - - -class ShareBandwidthSetSchema(schema.ResponseSchema): - """ ShareBandwidthSet - DescribeEIP - """ - - fields = { - "ShareBandwidth": fields.Int(required=False, load_from="ShareBandwidth"), - "ShareBandwidthId": fields.Str(required=False, load_from="ShareBandwidthId"), - "ShareBandwidthName": fields.Str( - required=False, load_from="ShareBandwidthName" - ), - } - - -class UnetEIPResourceSetSchema(schema.ResponseSchema): - """ UnetEIPResourceSet - DescribeEIP - """ - - fields = { - "EIPId": fields.Str(required=False, load_from="EIPId"), - "ResourceId": fields.Str(required=False, load_from="ResourceId"), - "ResourceName": fields.Str(required=False, load_from="ResourceName"), - "ResourceType": fields.Str(required=False, load_from="ResourceType"), - "SubResourceId": fields.Str(required=False, load_from="SubResourceId"), - "SubResourceName": fields.Str(required=False, load_from="SubResourceName"), - "SubResourceType": fields.Str(required=False, load_from="SubResourceType"), - } - - -class UnetEIPSetSchema(schema.ResponseSchema): - """ UnetEIPSet - DescribeEIP - """ - - fields = { - "Bandwidth": fields.Int(required=False, load_from="Bandwidth"), - "BandwidthType": fields.Int(required=False, load_from="BandwidthType"), - "ChargeType": fields.Str(required=False, load_from="ChargeType"), - "CreateTime": fields.Int(required=False, load_from="CreateTime"), - "EIPAddr": fields.List(UnetEIPAddrSetSchema()), - "EIPId": fields.Str(required=False, load_from="EIPId"), - "Expire": fields.Bool(required=False, load_from="Expire"), - "ExpireTime": fields.Int(required=False, load_from="ExpireTime"), - "Name": fields.Str(required=False, load_from="Name"), - "PayMode": fields.Str(required=False, load_from="PayMode"), - "Remark": fields.Str(required=False, load_from="Remark"), - "Resource": UnetEIPResourceSetSchema(), - "ShareBandwidthSet": ShareBandwidthSetSchema(), - "Status": fields.Str(required=False, load_from="Status"), - "Tag": fields.Str(required=False, load_from="Tag"), - "Weight": fields.Int(required=False, load_from="Weight"), - } - - -class FirewallRuleSetSchema(schema.ResponseSchema): - """ FirewallRuleSet - DescribeFirewall - """ - - fields = { - "DstPort": fields.Str(required=False, load_from="DstPort"), - "Priority": fields.Str(required=False, load_from="Priority"), - "ProtocolType": fields.Str(required=False, load_from="ProtocolType"), - "Remark": fields.Str(required=False, load_from="Remark"), - "RuleAction": fields.Str(required=False, load_from="RuleAction"), - "SrcIP": fields.Str(required=False, load_from="SrcIP"), - } - - -class FirewallDataSetSchema(schema.ResponseSchema): - """ FirewallDataSet - DescribeFirewall - """ - - fields = { - "CreateTime": fields.Int(required=False, load_from="CreateTime"), - "FWId": fields.Str(required=True, load_from="FWId"), - "GroupId": fields.Str(required=True, load_from="GroupId"), - "Name": fields.Str(required=False, load_from="Name"), - "Remark": fields.Str(required=False, load_from="Remark"), - "ResourceCount": fields.Int(required=False, load_from="ResourceCount"), - "Rule": fields.List(FirewallRuleSetSchema()), - "Tag": fields.Str(required=False, load_from="Tag"), - "Type": fields.Str(required=False, load_from="Type"), - } - - -class ResourceSetSchema(schema.ResponseSchema): - """ ResourceSet - 资源信息 - """ - - fields = { - "Name": fields.Str(required=False, load_from="Name"), - "PrivateIP": fields.Str(required=False, load_from="PrivateIP"), - "Remark": fields.Str(required=False, load_from="Remark"), - "ResourceID": fields.Str(required=False, load_from="ResourceID"), - "ResourceType": fields.Str(required=False, load_from="ResourceType"), - "Status": fields.Int(required=False, load_from="Status"), - "Tag": fields.Str(required=False, load_from="Tag"), - "Zone": fields.Int(required=False, load_from="Zone"), - } - - -class EIPSetDataSchema(schema.ResponseSchema): - """ EIPSetData - describeShareBandwidth - """ - - fields = { - "Bandwidth": fields.Int(required=False, load_from="Bandwidth"), - "EIPAddr": fields.List(EIPAddrSetSchema()), - "EIPId": fields.Str(required=False, load_from="EIPId"), - } - - -class UnetShareBandwidthSetSchema(schema.ResponseSchema): - """ UnetShareBandwidthSet - DescribeShareBandwidth - """ - - fields = { - "BandwidthGuarantee": fields.Int( - required=False, load_from="BandwidthGuarantee" - ), - "ChargeType": fields.Str(required=False, load_from="ChargeType"), - "CreateTime": fields.Int(required=False, load_from="CreateTime"), - "EIPSet": fields.List(EIPSetDataSchema()), - "ExpireTime": fields.Int(required=False, load_from="ExpireTime"), - "Name": fields.Str(required=False, load_from="Name"), - "PostPayStartTime": fields.Int(required=False, load_from="PostPayStartTime"), - "ShareBandwidth": fields.Int(required=False, load_from="ShareBandwidth"), - "ShareBandwidthId": fields.Str(required=False, load_from="ShareBandwidthId"), - } - - -class VIPDetailSetSchema(schema.ResponseSchema): - """ VIPDetailSet - VIPDetailSet - """ - - fields = { - "CreateTime": fields.Int(required=False, load_from="CreateTime"), - "Name": fields.Str(required=False, load_from="Name"), - "RealIp": fields.Str(required=False, load_from="RealIp"), - "SubnetId": fields.Str(required=False, load_from="SubnetId"), - "VIP": fields.Str(required=False, load_from="VIP"), - "VIPId": fields.Str(required=False, load_from="VIPId"), - "VPCId": fields.Str(required=False, load_from="VPCId"), - "Zone": fields.Str(required=False, load_from="Zone"), - } - - -class EIPPayModeSetSchema(schema.ResponseSchema): - """ EIPPayModeSet - GetEIPPayModeEIP - """ - - fields = { - "EIPId": fields.Str(required=False, load_from="EIPId"), - "EIPPayMode": fields.Str(required=False, load_from="EIPPayMode"), - } - - -class EIPPriceDetailSetSchema(schema.ResponseSchema): - """ EIPPriceDetailSet - GetEIPPrice - """ - - fields = { - "ChargeType": fields.Str(required=False, load_from="ChargeType"), - "Price": fields.Float(required=False, load_from="Price"), - "PurchaseValue": fields.Int(required=False, load_from="PurchaseValue"), - } +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.typesystem import schema, fields + + +class UnetEIPAddrSetSchema(schema.ResponseSchema): + """ UnetEIPAddrSet - DescribeEIP + """ + + fields = { + "IP": fields.Str(required=False, load_from="IP"), + "OperatorName": fields.Str(required=False, load_from="OperatorName"), + } + + +class UnetAllocateEIPSetSchema(schema.ResponseSchema): + """ UnetAllocateEIPSet - AllocateEIP + """ + + fields = { + "EIPAddr": fields.List(UnetEIPAddrSetSchema()), + "EIPId": fields.Str(required=False, load_from="EIPId"), + } + + +class VIPSetSchema(schema.ResponseSchema): + """ VIPSet - VIPSet + """ + + fields = { + "VIP": fields.Str(required=False, load_from="VIP"), + "VIPId": fields.Str(required=False, load_from="VIPId"), + "VPCId": fields.Str(required=False, load_from="VPCId"), + } + + +class EIPAddrSetSchema(schema.ResponseSchema): + """ EIPAddrSet - DescribeShareBandwidth + """ + + fields = { + "IP": fields.Str(required=False, load_from="IP"), + "OperatorName": fields.Str(required=False, load_from="OperatorName"), + } + + +class UnetBandwidthPackageSetSchema(schema.ResponseSchema): + """ UnetBandwidthPackageSet - DescribeBandwidthPackage + """ + + fields = { + "Bandwidth": fields.Int(required=False, load_from="Bandwidth"), + "BandwidthPackageId": fields.Str( + required=False, load_from="BandwidthPackageId" + ), + "CreateTime": fields.Int(required=False, load_from="CreateTime"), + "DisableTime": fields.Int(required=False, load_from="DisableTime"), + "EIPAddr": fields.List(EIPAddrSetSchema()), + "EIPId": fields.Str(required=False, load_from="EIPId"), + "EnableTime": fields.Int(required=False, load_from="EnableTime"), + } + + +class UnetBandwidthUsageEIPSetSchema(schema.ResponseSchema): + """ UnetBandwidthUsageEIPSet - DescribeBandwidthUsage + """ + + fields = { + "CurBandwidth": fields.Float(required=False, load_from="CurBandwidth"), + "EIPId": fields.Str(required=False, load_from="EIPId"), + } + + +class ShareBandwidthSetSchema(schema.ResponseSchema): + """ ShareBandwidthSet - DescribeEIP + """ + + fields = { + "ShareBandwidth": fields.Int( + required=False, load_from="ShareBandwidth" + ), + "ShareBandwidthId": fields.Str( + required=False, load_from="ShareBandwidthId" + ), + "ShareBandwidthName": fields.Str( + required=False, load_from="ShareBandwidthName" + ), + } + + +class UnetEIPResourceSetSchema(schema.ResponseSchema): + """ UnetEIPResourceSet - DescribeEIP + """ + + fields = { + "EIPId": fields.Str(required=False, load_from="EIPId"), + "ResourceId": fields.Str(required=False, load_from="ResourceId"), + "ResourceName": fields.Str(required=False, load_from="ResourceName"), + "ResourceType": fields.Str(required=False, load_from="ResourceType"), + "SubResourceId": fields.Str(required=False, load_from="SubResourceId"), + "SubResourceName": fields.Str( + required=False, load_from="SubResourceName" + ), + "SubResourceType": fields.Str( + required=False, load_from="SubResourceType" + ), + } + + +class UnetEIPSetSchema(schema.ResponseSchema): + """ UnetEIPSet - DescribeEIP + """ + + fields = { + "Bandwidth": fields.Int(required=False, load_from="Bandwidth"), + "BandwidthType": fields.Int(required=False, load_from="BandwidthType"), + "ChargeType": fields.Str(required=False, load_from="ChargeType"), + "CreateTime": fields.Int(required=False, load_from="CreateTime"), + "EIPAddr": fields.List(UnetEIPAddrSetSchema()), + "EIPId": fields.Str(required=False, load_from="EIPId"), + "Expire": fields.Bool(required=False, load_from="Expire"), + "ExpireTime": fields.Int(required=False, load_from="ExpireTime"), + "Name": fields.Str(required=False, load_from="Name"), + "PayMode": fields.Str(required=False, load_from="PayMode"), + "Remark": fields.Str(required=False, load_from="Remark"), + "Resource": UnetEIPResourceSetSchema(), + "ShareBandwidthSet": ShareBandwidthSetSchema(), + "Status": fields.Str(required=False, load_from="Status"), + "Tag": fields.Str(required=False, load_from="Tag"), + "Weight": fields.Int(required=False, load_from="Weight"), + } + + +class FirewallRuleSetSchema(schema.ResponseSchema): + """ FirewallRuleSet - DescribeFirewall + """ + + fields = { + "DstPort": fields.Str(required=False, load_from="DstPort"), + "Priority": fields.Str(required=False, load_from="Priority"), + "ProtocolType": fields.Str(required=False, load_from="ProtocolType"), + "Remark": fields.Str(required=False, load_from="Remark"), + "RuleAction": fields.Str(required=False, load_from="RuleAction"), + "SrcIP": fields.Str(required=False, load_from="SrcIP"), + } + + +class FirewallDataSetSchema(schema.ResponseSchema): + """ FirewallDataSet - DescribeFirewall + """ + + fields = { + "CreateTime": fields.Int(required=False, load_from="CreateTime"), + "FWId": fields.Str(required=True, load_from="FWId"), + "GroupId": fields.Str(required=True, load_from="GroupId"), + "Name": fields.Str(required=False, load_from="Name"), + "Remark": fields.Str(required=False, load_from="Remark"), + "ResourceCount": fields.Int(required=False, load_from="ResourceCount"), + "Rule": fields.List(FirewallRuleSetSchema()), + "Tag": fields.Str(required=False, load_from="Tag"), + "Type": fields.Str(required=False, load_from="Type"), + } + + +class ResourceSetSchema(schema.ResponseSchema): + """ ResourceSet - 资源信息 + """ + + fields = { + "Name": fields.Str(required=False, load_from="Name"), + "PrivateIP": fields.Str(required=False, load_from="PrivateIP"), + "Remark": fields.Str(required=False, load_from="Remark"), + "ResourceID": fields.Str(required=False, load_from="ResourceID"), + "ResourceType": fields.Str(required=False, load_from="ResourceType"), + "Status": fields.Int(required=False, load_from="Status"), + "Tag": fields.Str(required=False, load_from="Tag"), + "Zone": fields.Int(required=False, load_from="Zone"), + } + + +class EIPSetDataSchema(schema.ResponseSchema): + """ EIPSetData - describeShareBandwidth + """ + + fields = { + "Bandwidth": fields.Int(required=False, load_from="Bandwidth"), + "EIPAddr": fields.List(EIPAddrSetSchema()), + "EIPId": fields.Str(required=False, load_from="EIPId"), + } + + +class UnetShareBandwidthSetSchema(schema.ResponseSchema): + """ UnetShareBandwidthSet - DescribeShareBandwidth + """ + + fields = { + "BandwidthGuarantee": fields.Int( + required=False, load_from="BandwidthGuarantee" + ), + "ChargeType": fields.Str(required=False, load_from="ChargeType"), + "CreateTime": fields.Int(required=False, load_from="CreateTime"), + "EIPSet": fields.List(EIPSetDataSchema()), + "ExpireTime": fields.Int(required=False, load_from="ExpireTime"), + "Name": fields.Str(required=False, load_from="Name"), + "PostPayStartTime": fields.Int( + required=False, load_from="PostPayStartTime" + ), + "ShareBandwidth": fields.Int( + required=False, load_from="ShareBandwidth" + ), + "ShareBandwidthId": fields.Str( + required=False, load_from="ShareBandwidthId" + ), + } + + +class VIPDetailSetSchema(schema.ResponseSchema): + """ VIPDetailSet - VIPDetailSet + """ + + fields = { + "CreateTime": fields.Int(required=False, load_from="CreateTime"), + "Name": fields.Str(required=False, load_from="Name"), + "RealIp": fields.Str(required=False, load_from="RealIp"), + "SubnetId": fields.Str(required=False, load_from="SubnetId"), + "VIP": fields.Str(required=False, load_from="VIP"), + "VIPId": fields.Str(required=False, load_from="VIPId"), + "VPCId": fields.Str(required=False, load_from="VPCId"), + "Zone": fields.Str(required=False, load_from="Zone"), + } + + +class EIPPayModeSetSchema(schema.ResponseSchema): + """ EIPPayModeSet - GetEIPPayModeEIP + """ + + fields = { + "EIPId": fields.Str(required=False, load_from="EIPId"), + "EIPPayMode": fields.Str(required=False, load_from="EIPPayMode"), + } + + +class EIPPriceDetailSetSchema(schema.ResponseSchema): + """ EIPPriceDetailSet - GetEIPPrice + """ + + fields = { + "ChargeType": fields.Str(required=False, load_from="ChargeType"), + "Price": fields.Float(required=False, load_from="Price"), + "PurchaseValue": fields.Int(required=False, load_from="PurchaseValue"), + } diff --git a/ucloud/services/uphost/__init__.py b/ucloud/services/uphost/__init__.py index 4c48b5a..40a96af 100644 --- a/ucloud/services/uphost/__init__.py +++ b/ucloud/services/uphost/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- diff --git a/ucloud/services/uphost/client.py b/ucloud/services/uphost/client.py index 74a7574..9a93e98 100644 --- a/ucloud/services/uphost/client.py +++ b/ucloud/services/uphost/client.py @@ -1,354 +1,356 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.client import Client -from ucloud.services.uphost.schemas import apis - - -class UPHostClient(Client): - def __init__(self, config, transport=None, middleware=None, logger=None): - super(UPHostClient, self).__init__(config, transport, middleware, logger) - - def create_phost(self, req=None, **kwargs): - """ CreatePHost - 指定数据中心,根据资源使用量创建指定数量的UPHost物理云主机实例。 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **ImageId** (str) - (Required) 镜像ID。 请通过 [DescribePHostImage]获取 - - **Password** (str) - (Required) 密码(密码需使用base64进行编码) - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **ChargeType** (str) - 计费模式,枚举值为:year, 按年付费; month,按月付费;dynamic,按需付费,(需开启权限) trial, 试用(需开启权限)。默认为按月付费 - - **Cluster** (str) - 网络环境,可选千兆:1G ,万兆:10G, 默认1G - - **Count** (int) - 购买数量,默认为1,(暂不支持) - - **CouponId** (str) - 代金券 - - **Name** (str) - 物理机名称,默认为phost - - **Quantity** (str) - 购买时长,默认为1,范围[1-10] - - **Raid** (str) - Raid配置,默认Raid10 支持:Raid0、Raid1、Raid5、Raid10,NoRaid - - **Remark** (str) - 物理机备注,默认为空 - - **SecurityGroupId** (str) - 防火墙Id,默认:Web推荐防火墙。如何查询SecurityGroupId请参见 `DescribeSecurityGroup `_ - - **SubnetId** (str) - 子网ID,不填为默认,VPC2.0下需要填写此字段。 - - **Tag** (str) - 业务组,默认为default - - **Type** (str) - 物理机类型,默认为:db-2(基础型-SAS-V3) - - **VPCId** (str) - VPC ID,不填为默认,VPC2.0下需要填写此字段。 - - **Response** - - - **PHostId** (list) - PHost的资源ID数组 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.CreatePHostRequestSchema().dumps(d) - resp = self.invoke("CreatePHost", d, **kwargs) - return apis.CreatePHostResponseSchema().loads(resp) - - def describe_phost(self, req=None, **kwargs): - """ DescribePHost - 获取物理机详细信息 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Limit** (int) - 返回数据长度,默认为20 - - **Offset** (int) - 数据偏移量,默认为0 - - **PHostId** (list) - PHost资源ID,若为空,则返回当前Region所有PHost。 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **PHostSet** (list) - 见 **PHostSet** 模型定义 - - **TotalCount** (int) - 满足条件的PHost总数 - - **Response Model** - - **PHostDiskSet** - - - **Count** (int) - 磁盘数量 - - **IOCap** (int) - 磁盘IO性能,单位MB/s(待废弃) - - **Name** (str) - 磁盘名称,sys/data - - **Space** (int) - 单盘大小,单位GB - - **Type** (str) - 磁盘属性 - - **PHostCPUSet** - - - **CoreCount** (int) - CPU核数 - - **Count** (int) - CPU个数 - - **Frequence** (float) - CPU主频 - - **Model** (str) - CPU型号 - - **PHostIPSet** - - - **Bandwidth** (int) - IP对应带宽,单位Mb,内网IP不显示带宽信息 - - **IPAddr** (str) - IP地址, - - **IPId** (str) - IP资源ID(内网IP无资源ID)(待废弃) - - **MACAddr** (str) - MAC地址 - - **OperatorName** (str) - 国际: Internation, BGP: BGP, 内网: Private - - **SubnetId** (str) - 子网ID - - **VPCId** (str) - VPC ID - - **PHostSet** - - - **AutoRenew** (str) - 自动续费 - - **CPUSet** (list) - 见 **PHostCPUSet** 模型定义 - - **ChargeType** (str) - 计费模式,枚举值为: Year,按年付费; Month,按月付费; Dynamic,按需付费(需开启权限); Trial,试用(需开启权限)默认为月付 - - **Cluster** (str) - 网络环境。枚举值:千兆:1G ,万兆:10G - - **Components** (str) - 组件信息(暂不支持) - - **CreateTime** (int) - 创建时间 - - **DiskSet** (list) - 见 **PHostDiskSet** 模型定义 - - **ExpireTime** (int) - 到期时间 - - **IPSet** (list) - 见 **PHostIPSet** 模型定义 - - **ImageName** (str) - 镜像名称 - - **IsSupportKVM** (str) - 是否支持紧急登录 - - **Memory** (int) - 内存大小,单位:MB - - **Name** (str) - 物理机名称 - - **OSType** (str) - 操作系统类型 - - **OSname** (str) - 操作系统名称 - - **PHostId** (str) - PHost资源ID - - **PHostType** (str) - 物理机类型,参见DescribePHostMachineType返回值 - - **PMStatus** (str) - 物理云主机状态。枚举值:\\ > 初始化:Initializing; \\ > 启动中:Starting; \\ > 运行中:Running;\\ > 关机中:Stopping; \\ > 安装失败:InstallFailed; \\ > 重启中:Rebooting;\\ > 关机:Stopped; - - **PowerState** (str) - 电源状态,on 或 off - - **RaidSupported** (str) - 是否支持Raid。枚举值:Yes:支持;No:不支持。 - - **Remark** (str) - 物理机备注 - - **SN** (str) - 物理机序列号 - - **Tag** (str) - 业务组 - - **Zone** (str) - 可用区,参见 `可用区列表 `_ - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribePHostRequestSchema().dumps(d) - resp = self.invoke("DescribePHost", d, **kwargs) - return apis.DescribePHostResponseSchema().loads(resp) - - def describe_phost_image(self, req=None, **kwargs): - """ DescribePHostImage - 获取物理云主机镜像列表 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **ImageId** (list) - 镜像ID - - **ImageType** (str) - 镜像类别,枚举为:Base,标准镜像;默认为标准镜像。 - - **Limit** (int) - 返回数据长度,默认为20 - - **Offset** (int) - 数据偏移量,默认为0 - - **Response** - - - **ImageSet** (list) - 见 **PHostImageSet** 模型定义 - - **TotalCount** (int) - 满足条件的镜像总数 - - **Response Model** - - **PHostImageSet** - - - **ImageId** (str) - 镜像ID - - **ImageName** (str) - 镜像名称 - - **OsName** (str) - 操作系统名称 - - **OsType** (str) - 操作系统类型 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribePHostImageRequestSchema().dumps(d) - resp = self.invoke("DescribePHostImage", d, **kwargs) - return apis.DescribePHostImageResponseSchema().loads(resp) - - def describe_phost_tags(self, req=None, **kwargs): - """ DescribePHostTags - 获取物理机tag列表(业务组) - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **TagSet** (list) - 见 **PHostTagSet** 模型定义 - - **TotalCount** (int) - Tag的个数 - - **Response Model** - - **PHostTagSet** - - - **Tag** (str) - 业务组名称 - - **TotalCount** (int) - 该业务组中包含的主机个数 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribePHostTagsRequestSchema().dumps(d) - resp = self.invoke("DescribePHostTags", d, **kwargs) - return apis.DescribePHostTagsResponseSchema().loads(resp) - - def get_phost_price(self, req=None, **kwargs): - """ GetPHostPrice - 获取物理机价格列表 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **ChargeType** (str) - (Required) 计费模式,枚举值为: Year/Month/Trial/Dynamic - - **Count** (int) - (Required) 购买数量,范围[1-5] - - **Quantity** (int) - (Required) 购买时长,1-10个月或1-10年 - - **Cluster** (str) - 网络环境,可选千兆:1G ,万兆:10G - - **Type** (str) - 默认为:DB(数据库型) - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **PriceSet** (list) - 见 **PHostPriceSet** 模型定义 - - **Response Model** - - **PHostPriceSet** - - - **ChargeType** (str) - Year/Month/Trial/Dynamic - - **Price** (float) - 价格, 单位:元, 保留小数点后两位有效数字 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.GetPHostPriceRequestSchema().dumps(d) - resp = self.invoke("GetPHostPrice", d, **kwargs) - return apis.GetPHostPriceResponseSchema().loads(resp) - - def modify_phost_info(self, req=None, **kwargs): - """ ModifyPHostInfo - 更改物理机信息 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **PHostId** (str) - (Required) 物理机资源ID - - **Name** (str) - 物理机名称,默认不更改 - - **Remark** (str) - 物理机备注,默认不更改 - - **Tag** (str) - 业务组,默认不更改 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **PHostId** (str) - PHost 的资源ID - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.ModifyPHostInfoRequestSchema().dumps(d) - resp = self.invoke("ModifyPHostInfo", d, **kwargs) - return apis.ModifyPHostInfoResponseSchema().loads(resp) - - def poweroff_phost(self, req=None, **kwargs): - """ PoweroffPHost - 断电物理云主机 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **PHostId** (str) - (Required) PHost资源ID - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **PHostId** (str) - PHost 的资源ID - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.PoweroffPHostRequestSchema().dumps(d) - resp = self.invoke("PoweroffPHost", d, **kwargs) - return apis.PoweroffPHostResponseSchema().loads(resp) - - def reboot_phost(self, req=None, **kwargs): - """ RebootPHost - 重启物理机 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **PHostId** (str) - (Required) PHost资源ID - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **PHostId** (str) - PHost 的资源ID - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.RebootPHostRequestSchema().dumps(d) - resp = self.invoke("RebootPHost", d, **kwargs) - return apis.RebootPHostResponseSchema().loads(resp) - - def reinstall_phost(self, req=None, **kwargs): - """ ReinstallPHost - 重装物理机操作系统 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **PHostId** (str) - (Required) PHost资源ID - - **Password** (str) - (Required) 密码 - - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ - - **ImageId** (str) - 镜像Id,参考镜像列表,默认使用原镜像 - - **Name** (str) - 物理机名称,默认不更改 - - **Raid** (str) - 不保留数据盘重装,可选Raid - - **Remark** (str) - 物理机备注,默认为不更改。 - - **ReserveDisk** (str) - 是否保留数据盘,保留:Yes,不报留:No, 默认:Yes - - **Tag** (str) - 业务组,默认不更改。 - - **Response** - - - **PHostId** (str) - PHost 的资源ID - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.ReinstallPHostRequestSchema().dumps(d) - resp = self.invoke("ReinstallPHost", d, **kwargs) - return apis.ReinstallPHostResponseSchema().loads(resp) - - def start_phost(self, req=None, **kwargs): - """ StartPHost - 启动物理机 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **PHostId** (str) - (Required) PHost资源ID - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **PHostId** (str) - PHost 的资源ID - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.StartPHostRequestSchema().dumps(d) - resp = self.invoke("StartPHost", d, **kwargs) - return apis.StartPHostResponseSchema().loads(resp) - - def terminate_phost(self, req=None, **kwargs): - """ TerminatePHost - 删除物理云主机 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **PHostId** (str) - (Required) PHost资源ID - - **ReleaseEIP** (bool) - 是否释放绑定的EIP。true: 解绑EIP后,并释放;其他值或不填:解绑EIP。 - - **Zone** (str) - 可用区。参见 `可用区列表 `_ - - **Response** - - - **PHostId** (str) - PHost 的资源ID - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.TerminatePHostRequestSchema().dumps(d) - resp = self.invoke("TerminatePHost", d, **kwargs) - return apis.TerminatePHostResponseSchema().loads(resp) +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.client import Client +from ucloud.services.uphost.schemas import apis + + +class UPHostClient(Client): + def __init__(self, config, transport=None, middleware=None, logger=None): + super(UPHostClient, self).__init__( + config, transport, middleware, logger + ) + + def create_phost(self, req=None, **kwargs): + """ CreatePHost - 指定数据中心,根据资源使用量创建指定数量的UPHost物理云主机实例。 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **ImageId** (str) - (Required) 镜像ID。 请通过 [DescribePHostImage]获取 + - **Password** (str) - (Required) 密码(密码需使用base64进行编码) + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + - **ChargeType** (str) - 计费模式,枚举值为:year, 按年付费; month,按月付费;dynamic,按需付费,(需开启权限) trial, 试用(需开启权限)。默认为按月付费 + - **Cluster** (str) - 网络环境,可选千兆:1G ,万兆:10G, 默认1G + - **Count** (int) - 购买数量,默认为1,(暂不支持) + - **CouponId** (str) - 代金券 + - **Name** (str) - 物理机名称,默认为phost + - **Quantity** (str) - 购买时长,默认为1,范围[1-10] + - **Raid** (str) - Raid配置,默认Raid10 支持:Raid0、Raid1、Raid5、Raid10,NoRaid + - **Remark** (str) - 物理机备注,默认为空 + - **SecurityGroupId** (str) - 防火墙Id,默认:Web推荐防火墙。如何查询SecurityGroupId请参见 `DescribeSecurityGroup `_ + - **SubnetId** (str) - 子网ID,不填为默认,VPC2.0下需要填写此字段。 + - **Tag** (str) - 业务组,默认为default + - **Type** (str) - 物理机类型,默认为:db-2(基础型-SAS-V3) + - **VPCId** (str) - VPC ID,不填为默认,VPC2.0下需要填写此字段。 + + **Response** + + - **PHostId** (list) - PHost的资源ID数组 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.CreatePHostRequestSchema().dumps(d) + resp = self.invoke("CreatePHost", d, **kwargs) + return apis.CreatePHostResponseSchema().loads(resp) + + def describe_phost(self, req=None, **kwargs): + """ DescribePHost - 获取物理机详细信息 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Limit** (int) - 返回数据长度,默认为20 + - **Offset** (int) - 数据偏移量,默认为0 + - **PHostId** (list) - PHost资源ID,若为空,则返回当前Region所有PHost。 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **PHostSet** (list) - 见 **PHostSet** 模型定义 + - **TotalCount** (int) - 满足条件的PHost总数 + + **Response Model** + + **PHostDiskSet** + + - **Count** (int) - 磁盘数量 + - **IOCap** (int) - 磁盘IO性能,单位MB/s(待废弃) + - **Name** (str) - 磁盘名称,sys/data + - **Space** (int) - 单盘大小,单位GB + - **Type** (str) - 磁盘属性 + + **PHostCPUSet** + + - **CoreCount** (int) - CPU核数 + - **Count** (int) - CPU个数 + - **Frequence** (float) - CPU主频 + - **Model** (str) - CPU型号 + + **PHostIPSet** + + - **Bandwidth** (int) - IP对应带宽,单位Mb,内网IP不显示带宽信息 + - **IPAddr** (str) - IP地址, + - **IPId** (str) - IP资源ID(内网IP无资源ID)(待废弃) + - **MACAddr** (str) - MAC地址 + - **OperatorName** (str) - 国际: Internation, BGP: BGP, 内网: Private + - **SubnetId** (str) - 子网ID + - **VPCId** (str) - VPC ID + + **PHostSet** + + - **AutoRenew** (str) - 自动续费 + - **CPUSet** (list) - 见 **PHostCPUSet** 模型定义 + - **ChargeType** (str) - 计费模式,枚举值为: Year,按年付费; Month,按月付费; Dynamic,按需付费(需开启权限); Trial,试用(需开启权限)默认为月付 + - **Cluster** (str) - 网络环境。枚举值:千兆:1G ,万兆:10G + - **Components** (str) - 组件信息(暂不支持) + - **CreateTime** (int) - 创建时间 + - **DiskSet** (list) - 见 **PHostDiskSet** 模型定义 + - **ExpireTime** (int) - 到期时间 + - **IPSet** (list) - 见 **PHostIPSet** 模型定义 + - **ImageName** (str) - 镜像名称 + - **IsSupportKVM** (str) - 是否支持紧急登录 + - **Memory** (int) - 内存大小,单位:MB + - **Name** (str) - 物理机名称 + - **OSType** (str) - 操作系统类型 + - **OSname** (str) - 操作系统名称 + - **PHostId** (str) - PHost资源ID + - **PHostType** (str) - 物理机类型,参见DescribePHostMachineType返回值 + - **PMStatus** (str) - 物理云主机状态。枚举值:\\ > 初始化:Initializing; \\ > 启动中:Starting; \\ > 运行中:Running;\\ > 关机中:Stopping; \\ > 安装失败:InstallFailed; \\ > 重启中:Rebooting;\\ > 关机:Stopped; + - **PowerState** (str) - 电源状态,on 或 off + - **RaidSupported** (str) - 是否支持Raid。枚举值:Yes:支持;No:不支持。 + - **Remark** (str) - 物理机备注 + - **SN** (str) - 物理机序列号 + - **Tag** (str) - 业务组 + - **Zone** (str) - 可用区,参见 `可用区列表 `_ + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribePHostRequestSchema().dumps(d) + resp = self.invoke("DescribePHost", d, **kwargs) + return apis.DescribePHostResponseSchema().loads(resp) + + def describe_phost_image(self, req=None, **kwargs): + """ DescribePHostImage - 获取物理云主机镜像列表 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + - **ImageId** (list) - 镜像ID + - **ImageType** (str) - 镜像类别,枚举为:Base,标准镜像;默认为标准镜像。 + - **Limit** (int) - 返回数据长度,默认为20 + - **Offset** (int) - 数据偏移量,默认为0 + + **Response** + + - **ImageSet** (list) - 见 **PHostImageSet** 模型定义 + - **TotalCount** (int) - 满足条件的镜像总数 + + **Response Model** + + **PHostImageSet** + + - **ImageId** (str) - 镜像ID + - **ImageName** (str) - 镜像名称 + - **OsName** (str) - 操作系统名称 + - **OsType** (str) - 操作系统类型 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribePHostImageRequestSchema().dumps(d) + resp = self.invoke("DescribePHostImage", d, **kwargs) + return apis.DescribePHostImageResponseSchema().loads(resp) + + def describe_phost_tags(self, req=None, **kwargs): + """ DescribePHostTags - 获取物理机tag列表(业务组) + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **TagSet** (list) - 见 **PHostTagSet** 模型定义 + - **TotalCount** (int) - Tag的个数 + + **Response Model** + + **PHostTagSet** + + - **Tag** (str) - 业务组名称 + - **TotalCount** (int) - 该业务组中包含的主机个数 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribePHostTagsRequestSchema().dumps(d) + resp = self.invoke("DescribePHostTags", d, **kwargs) + return apis.DescribePHostTagsResponseSchema().loads(resp) + + def get_phost_price(self, req=None, **kwargs): + """ GetPHostPrice - 获取物理机价格列表 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **ChargeType** (str) - (Required) 计费模式,枚举值为: Year/Month/Trial/Dynamic + - **Count** (int) - (Required) 购买数量,范围[1-5] + - **Quantity** (int) - (Required) 购买时长,1-10个月或1-10年 + - **Cluster** (str) - 网络环境,可选千兆:1G ,万兆:10G + - **Type** (str) - 默认为:DB(数据库型) + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **PriceSet** (list) - 见 **PHostPriceSet** 模型定义 + + **Response Model** + + **PHostPriceSet** + + - **ChargeType** (str) - Year/Month/Trial/Dynamic + - **Price** (float) - 价格, 单位:元, 保留小数点后两位有效数字 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.GetPHostPriceRequestSchema().dumps(d) + resp = self.invoke("GetPHostPrice", d, **kwargs) + return apis.GetPHostPriceResponseSchema().loads(resp) + + def modify_phost_info(self, req=None, **kwargs): + """ ModifyPHostInfo - 更改物理机信息 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **PHostId** (str) - (Required) 物理机资源ID + - **Name** (str) - 物理机名称,默认不更改 + - **Remark** (str) - 物理机备注,默认不更改 + - **Tag** (str) - 业务组,默认不更改 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **PHostId** (str) - PHost 的资源ID + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.ModifyPHostInfoRequestSchema().dumps(d) + resp = self.invoke("ModifyPHostInfo", d, **kwargs) + return apis.ModifyPHostInfoResponseSchema().loads(resp) + + def poweroff_phost(self, req=None, **kwargs): + """ PoweroffPHost - 断电物理云主机 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **PHostId** (str) - (Required) PHost资源ID + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **PHostId** (str) - PHost 的资源ID + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.PoweroffPHostRequestSchema().dumps(d) + resp = self.invoke("PoweroffPHost", d, **kwargs) + return apis.PoweroffPHostResponseSchema().loads(resp) + + def reboot_phost(self, req=None, **kwargs): + """ RebootPHost - 重启物理机 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **PHostId** (str) - (Required) PHost资源ID + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **PHostId** (str) - PHost 的资源ID + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.RebootPHostRequestSchema().dumps(d) + resp = self.invoke("RebootPHost", d, **kwargs) + return apis.RebootPHostResponseSchema().loads(resp) + + def reinstall_phost(self, req=None, **kwargs): + """ ReinstallPHost - 重装物理机操作系统 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **PHostId** (str) - (Required) PHost资源ID + - **Password** (str) - (Required) 密码 + - **Zone** (str) - (Required) 可用区。参见 `可用区列表 `_ + - **ImageId** (str) - 镜像Id,参考镜像列表,默认使用原镜像 + - **Name** (str) - 物理机名称,默认不更改 + - **Raid** (str) - 不保留数据盘重装,可选Raid + - **Remark** (str) - 物理机备注,默认为不更改。 + - **ReserveDisk** (str) - 是否保留数据盘,保留:Yes,不报留:No, 默认:Yes + - **Tag** (str) - 业务组,默认不更改。 + + **Response** + + - **PHostId** (str) - PHost 的资源ID + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.ReinstallPHostRequestSchema().dumps(d) + resp = self.invoke("ReinstallPHost", d, **kwargs) + return apis.ReinstallPHostResponseSchema().loads(resp) + + def start_phost(self, req=None, **kwargs): + """ StartPHost - 启动物理机 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **PHostId** (str) - (Required) PHost资源ID + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **PHostId** (str) - PHost 的资源ID + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.StartPHostRequestSchema().dumps(d) + resp = self.invoke("StartPHost", d, **kwargs) + return apis.StartPHostResponseSchema().loads(resp) + + def terminate_phost(self, req=None, **kwargs): + """ TerminatePHost - 删除物理云主机 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **PHostId** (str) - (Required) PHost资源ID + - **ReleaseEIP** (bool) - 是否释放绑定的EIP。true: 解绑EIP后,并释放;其他值或不填:解绑EIP。 + - **Zone** (str) - 可用区。参见 `可用区列表 `_ + + **Response** + + - **PHostId** (str) - PHost 的资源ID + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.TerminatePHostRequestSchema().dumps(d) + resp = self.invoke("TerminatePHost", d, **kwargs) + return apis.TerminatePHostResponseSchema().loads(resp) diff --git a/ucloud/services/uphost/schemas/__init__.py b/ucloud/services/uphost/schemas/__init__.py index 4c48b5a..40a96af 100644 --- a/ucloud/services/uphost/schemas/__init__.py +++ b/ucloud/services/uphost/schemas/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- diff --git a/ucloud/services/uphost/schemas/apis.py b/ucloud/services/uphost/schemas/apis.py index 31faec1..7bea31b 100644 --- a/ucloud/services/uphost/schemas/apis.py +++ b/ucloud/services/uphost/schemas/apis.py @@ -1,344 +1,350 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.typesystem import schema, fields -from ucloud.services.uphost.schemas import models - -""" UPHost API Schema -""" -""" -API: CreatePHost - -指定数据中心,根据资源使用量创建指定数量的UPHost物理云主机实例。 -""" - - -class CreatePHostRequestSchema(schema.RequestSchema): - """ CreatePHost - 指定数据中心,根据资源使用量创建指定数量的UPHost物理云主机实例。 - """ - - fields = { - "ChargeType": fields.Str(required=False, dump_to="ChargeType"), - "Cluster": fields.Str(required=False, dump_to="Cluster"), - "Count": fields.Int(required=False, dump_to="Count"), - "CouponId": fields.Str(required=False, dump_to="CouponId"), - "ImageId": fields.Str(required=True, dump_to="ImageId"), - "Name": fields.Str(required=False, dump_to="Name"), - "Password": fields.Str(required=True, dump_to="Password"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Quantity": fields.Str(required=False, dump_to="Quantity"), - "Raid": fields.Str(required=False, dump_to="Raid"), - "Region": fields.Str(required=True, dump_to="Region"), - "Remark": fields.Str(required=False, dump_to="Remark"), - "SecurityGroupId": fields.Str(required=False, dump_to="SecurityGroupId"), - "SubnetId": fields.Str(required=False, dump_to="SubnetId"), - "Tag": fields.Str(required=False, dump_to="Tag"), - "Type": fields.Str(required=False, dump_to="Type"), - "VPCId": fields.Str(required=False, dump_to="VPCId"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class CreatePHostResponseSchema(schema.ResponseSchema): - """ CreatePHost - 指定数据中心,根据资源使用量创建指定数量的UPHost物理云主机实例。 - """ - - fields = {"PHostId": fields.List(fields.Str(), required=False, load_from="PHostId")} - - -""" -API: DescribePHost - -获取物理机详细信息 -""" - - -class DescribePHostRequestSchema(schema.RequestSchema): - """ DescribePHost - 获取物理机详细信息 - """ - - fields = { - "Limit": fields.Int(required=False, dump_to="Limit"), - "Offset": fields.Int(required=False, dump_to="Offset"), - "PHostId": fields.List(fields.Str()), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class DescribePHostResponseSchema(schema.ResponseSchema): - """ DescribePHost - 获取物理机详细信息 - """ - - fields = { - "PHostSet": fields.List( - models.PHostSetSchema(), required=False, load_from="PHostSet" - ), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - } - - -""" -API: DescribePHostImage - -获取物理云主机镜像列表 -""" - - -class DescribePHostImageRequestSchema(schema.RequestSchema): - """ DescribePHostImage - 获取物理云主机镜像列表 - """ - - fields = { - "ImageId": fields.List(fields.Str()), - "ImageType": fields.Str(required=False, dump_to="ImageType"), - "Limit": fields.Int(required=False, dump_to="Limit"), - "Offset": fields.Int(required=False, dump_to="Offset"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class DescribePHostImageResponseSchema(schema.ResponseSchema): - """ DescribePHostImage - 获取物理云主机镜像列表 - """ - - fields = { - "ImageSet": fields.List( - models.PHostImageSetSchema(), required=False, load_from="ImageSet" - ), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - } - - -""" -API: DescribePHostTags - -获取物理机tag列表(业务组) -""" - - -class DescribePHostTagsRequestSchema(schema.RequestSchema): - """ DescribePHostTags - 获取物理机tag列表(业务组) - """ - - fields = { - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class DescribePHostTagsResponseSchema(schema.ResponseSchema): - """ DescribePHostTags - 获取物理机tag列表(业务组) - """ - - fields = { - "TagSet": fields.List( - models.PHostTagSetSchema(), required=False, load_from="TagSet" - ), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - } - - -""" -API: GetPHostPrice - -获取物理机价格列表 -""" - - -class GetPHostPriceRequestSchema(schema.RequestSchema): - """ GetPHostPrice - 获取物理机价格列表 - """ - - fields = { - "ChargeType": fields.Str(required=True, dump_to="ChargeType"), - "Cluster": fields.Str(required=False, dump_to="Cluster"), - "Count": fields.Int(required=True, dump_to="Count"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Quantity": fields.Int(required=True, dump_to="Quantity"), - "Region": fields.Str(required=True, dump_to="Region"), - "Type": fields.Str(required=False, dump_to="Type"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class GetPHostPriceResponseSchema(schema.ResponseSchema): - """ GetPHostPrice - 获取物理机价格列表 - """ - - fields = { - "PriceSet": fields.List( - models.PHostPriceSetSchema(), required=False, load_from="PriceSet" - ) - } - - -""" -API: ModifyPHostInfo - -更改物理机信息 -""" - - -class ModifyPHostInfoRequestSchema(schema.RequestSchema): - """ ModifyPHostInfo - 更改物理机信息 - """ - - fields = { - "Name": fields.Str(required=False, dump_to="Name"), - "PHostId": fields.Str(required=True, dump_to="PHostId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Remark": fields.Str(required=False, dump_to="Remark"), - "Tag": fields.Str(required=False, dump_to="Tag"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class ModifyPHostInfoResponseSchema(schema.ResponseSchema): - """ ModifyPHostInfo - 更改物理机信息 - """ - - fields = {"PHostId": fields.Str(required=False, load_from="PHostId")} - - -""" -API: PoweroffPHost - -断电物理云主机 -""" - - -class PoweroffPHostRequestSchema(schema.RequestSchema): - """ PoweroffPHost - 断电物理云主机 - """ - - fields = { - "PHostId": fields.Str(required=True, dump_to="PHostId"), - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class PoweroffPHostResponseSchema(schema.ResponseSchema): - """ PoweroffPHost - 断电物理云主机 - """ - - fields = {"PHostId": fields.Str(required=False, load_from="PHostId")} - - -""" -API: RebootPHost - -重启物理机 -""" - - -class RebootPHostRequestSchema(schema.RequestSchema): - """ RebootPHost - 重启物理机 - """ - - fields = { - "PHostId": fields.Str(required=True, dump_to="PHostId"), - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class RebootPHostResponseSchema(schema.ResponseSchema): - """ RebootPHost - 重启物理机 - """ - - fields = {"PHostId": fields.Str(required=False, load_from="PHostId")} - - -""" -API: ReinstallPHost - -重装物理机操作系统 -""" - - -class ReinstallPHostRequestSchema(schema.RequestSchema): - """ ReinstallPHost - 重装物理机操作系统 - """ - - fields = { - "ImageId": fields.Str(required=False, dump_to="ImageId"), - "Name": fields.Str(required=False, dump_to="Name"), - "PHostId": fields.Str(required=True, dump_to="PHostId"), - "Password": fields.Str(required=True, dump_to="Password"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Raid": fields.Str(required=False, dump_to="Raid"), - "Region": fields.Str(required=True, dump_to="Region"), - "Remark": fields.Str(required=False, dump_to="Remark"), - "ReserveDisk": fields.Str(required=False, dump_to="ReserveDisk"), - "Tag": fields.Str(required=False, dump_to="Tag"), - "Zone": fields.Str(required=True, dump_to="Zone"), - } - - -class ReinstallPHostResponseSchema(schema.ResponseSchema): - """ ReinstallPHost - 重装物理机操作系统 - """ - - fields = {"PHostId": fields.Str(required=False, load_from="PHostId")} - - -""" -API: StartPHost - -启动物理机 -""" - - -class StartPHostRequestSchema(schema.RequestSchema): - """ StartPHost - 启动物理机 - """ - - fields = { - "PHostId": fields.Str(required=True, dump_to="PHostId"), - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class StartPHostResponseSchema(schema.ResponseSchema): - """ StartPHost - 启动物理机 - """ - - fields = {"PHostId": fields.Str(required=False, load_from="PHostId")} - - -""" -API: TerminatePHost - -删除物理云主机 -""" - - -class TerminatePHostRequestSchema(schema.RequestSchema): - """ TerminatePHost - 删除物理云主机 - """ - - fields = { - "PHostId": fields.Str(required=True, dump_to="PHostId"), - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "ReleaseEIP": fields.Bool(required=False, dump_to="ReleaseEIP"), - "Zone": fields.Str(required=False, dump_to="Zone"), - } - - -class TerminatePHostResponseSchema(schema.ResponseSchema): - """ TerminatePHost - 删除物理云主机 - """ - - fields = {"PHostId": fields.Str(required=False, load_from="PHostId")} +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.typesystem import schema, fields +from ucloud.services.uphost.schemas import models + +""" UPHost API Schema +""" +""" +API: CreatePHost + +指定数据中心,根据资源使用量创建指定数量的UPHost物理云主机实例。 +""" + + +class CreatePHostRequestSchema(schema.RequestSchema): + """ CreatePHost - 指定数据中心,根据资源使用量创建指定数量的UPHost物理云主机实例。 + """ + + fields = { + "ChargeType": fields.Str(required=False, dump_to="ChargeType"), + "Cluster": fields.Str(required=False, dump_to="Cluster"), + "Count": fields.Int(required=False, dump_to="Count"), + "CouponId": fields.Str(required=False, dump_to="CouponId"), + "ImageId": fields.Str(required=True, dump_to="ImageId"), + "Name": fields.Str(required=False, dump_to="Name"), + "Password": fields.Str(required=True, dump_to="Password"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Quantity": fields.Str(required=False, dump_to="Quantity"), + "Raid": fields.Str(required=False, dump_to="Raid"), + "Region": fields.Str(required=True, dump_to="Region"), + "Remark": fields.Str(required=False, dump_to="Remark"), + "SecurityGroupId": fields.Str( + required=False, dump_to="SecurityGroupId" + ), + "SubnetId": fields.Str(required=False, dump_to="SubnetId"), + "Tag": fields.Str(required=False, dump_to="Tag"), + "Type": fields.Str(required=False, dump_to="Type"), + "VPCId": fields.Str(required=False, dump_to="VPCId"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class CreatePHostResponseSchema(schema.ResponseSchema): + """ CreatePHost - 指定数据中心,根据资源使用量创建指定数量的UPHost物理云主机实例。 + """ + + fields = { + "PHostId": fields.List( + fields.Str(), required=False, load_from="PHostId" + ) + } + + +""" +API: DescribePHost + +获取物理机详细信息 +""" + + +class DescribePHostRequestSchema(schema.RequestSchema): + """ DescribePHost - 获取物理机详细信息 + """ + + fields = { + "Limit": fields.Int(required=False, dump_to="Limit"), + "Offset": fields.Int(required=False, dump_to="Offset"), + "PHostId": fields.List(fields.Str()), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class DescribePHostResponseSchema(schema.ResponseSchema): + """ DescribePHost - 获取物理机详细信息 + """ + + fields = { + "PHostSet": fields.List( + models.PHostSetSchema(), required=False, load_from="PHostSet" + ), + "TotalCount": fields.Int(required=False, load_from="TotalCount"), + } + + +""" +API: DescribePHostImage + +获取物理云主机镜像列表 +""" + + +class DescribePHostImageRequestSchema(schema.RequestSchema): + """ DescribePHostImage - 获取物理云主机镜像列表 + """ + + fields = { + "ImageId": fields.List(fields.Str()), + "ImageType": fields.Str(required=False, dump_to="ImageType"), + "Limit": fields.Int(required=False, dump_to="Limit"), + "Offset": fields.Int(required=False, dump_to="Offset"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class DescribePHostImageResponseSchema(schema.ResponseSchema): + """ DescribePHostImage - 获取物理云主机镜像列表 + """ + + fields = { + "ImageSet": fields.List( + models.PHostImageSetSchema(), required=False, load_from="ImageSet" + ), + "TotalCount": fields.Int(required=False, load_from="TotalCount"), + } + + +""" +API: DescribePHostTags + +获取物理机tag列表(业务组) +""" + + +class DescribePHostTagsRequestSchema(schema.RequestSchema): + """ DescribePHostTags - 获取物理机tag列表(业务组) + """ + + fields = { + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class DescribePHostTagsResponseSchema(schema.ResponseSchema): + """ DescribePHostTags - 获取物理机tag列表(业务组) + """ + + fields = { + "TagSet": fields.List( + models.PHostTagSetSchema(), required=False, load_from="TagSet" + ), + "TotalCount": fields.Int(required=False, load_from="TotalCount"), + } + + +""" +API: GetPHostPrice + +获取物理机价格列表 +""" + + +class GetPHostPriceRequestSchema(schema.RequestSchema): + """ GetPHostPrice - 获取物理机价格列表 + """ + + fields = { + "ChargeType": fields.Str(required=True, dump_to="ChargeType"), + "Cluster": fields.Str(required=False, dump_to="Cluster"), + "Count": fields.Int(required=True, dump_to="Count"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Quantity": fields.Int(required=True, dump_to="Quantity"), + "Region": fields.Str(required=True, dump_to="Region"), + "Type": fields.Str(required=False, dump_to="Type"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class GetPHostPriceResponseSchema(schema.ResponseSchema): + """ GetPHostPrice - 获取物理机价格列表 + """ + + fields = { + "PriceSet": fields.List( + models.PHostPriceSetSchema(), required=False, load_from="PriceSet" + ) + } + + +""" +API: ModifyPHostInfo + +更改物理机信息 +""" + + +class ModifyPHostInfoRequestSchema(schema.RequestSchema): + """ ModifyPHostInfo - 更改物理机信息 + """ + + fields = { + "Name": fields.Str(required=False, dump_to="Name"), + "PHostId": fields.Str(required=True, dump_to="PHostId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Remark": fields.Str(required=False, dump_to="Remark"), + "Tag": fields.Str(required=False, dump_to="Tag"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class ModifyPHostInfoResponseSchema(schema.ResponseSchema): + """ ModifyPHostInfo - 更改物理机信息 + """ + + fields = {"PHostId": fields.Str(required=False, load_from="PHostId")} + + +""" +API: PoweroffPHost + +断电物理云主机 +""" + + +class PoweroffPHostRequestSchema(schema.RequestSchema): + """ PoweroffPHost - 断电物理云主机 + """ + + fields = { + "PHostId": fields.Str(required=True, dump_to="PHostId"), + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class PoweroffPHostResponseSchema(schema.ResponseSchema): + """ PoweroffPHost - 断电物理云主机 + """ + + fields = {"PHostId": fields.Str(required=False, load_from="PHostId")} + + +""" +API: RebootPHost + +重启物理机 +""" + + +class RebootPHostRequestSchema(schema.RequestSchema): + """ RebootPHost - 重启物理机 + """ + + fields = { + "PHostId": fields.Str(required=True, dump_to="PHostId"), + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class RebootPHostResponseSchema(schema.ResponseSchema): + """ RebootPHost - 重启物理机 + """ + + fields = {"PHostId": fields.Str(required=False, load_from="PHostId")} + + +""" +API: ReinstallPHost + +重装物理机操作系统 +""" + + +class ReinstallPHostRequestSchema(schema.RequestSchema): + """ ReinstallPHost - 重装物理机操作系统 + """ + + fields = { + "ImageId": fields.Str(required=False, dump_to="ImageId"), + "Name": fields.Str(required=False, dump_to="Name"), + "PHostId": fields.Str(required=True, dump_to="PHostId"), + "Password": fields.Str(required=True, dump_to="Password"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Raid": fields.Str(required=False, dump_to="Raid"), + "Region": fields.Str(required=True, dump_to="Region"), + "Remark": fields.Str(required=False, dump_to="Remark"), + "ReserveDisk": fields.Str(required=False, dump_to="ReserveDisk"), + "Tag": fields.Str(required=False, dump_to="Tag"), + "Zone": fields.Str(required=True, dump_to="Zone"), + } + + +class ReinstallPHostResponseSchema(schema.ResponseSchema): + """ ReinstallPHost - 重装物理机操作系统 + """ + + fields = {"PHostId": fields.Str(required=False, load_from="PHostId")} + + +""" +API: StartPHost + +启动物理机 +""" + + +class StartPHostRequestSchema(schema.RequestSchema): + """ StartPHost - 启动物理机 + """ + + fields = { + "PHostId": fields.Str(required=True, dump_to="PHostId"), + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class StartPHostResponseSchema(schema.ResponseSchema): + """ StartPHost - 启动物理机 + """ + + fields = {"PHostId": fields.Str(required=False, load_from="PHostId")} + + +""" +API: TerminatePHost + +删除物理云主机 +""" + + +class TerminatePHostRequestSchema(schema.RequestSchema): + """ TerminatePHost - 删除物理云主机 + """ + + fields = { + "PHostId": fields.Str(required=True, dump_to="PHostId"), + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "ReleaseEIP": fields.Bool(required=False, dump_to="ReleaseEIP"), + "Zone": fields.Str(required=False, dump_to="Zone"), + } + + +class TerminatePHostResponseSchema(schema.ResponseSchema): + """ TerminatePHost - 删除物理云主机 + """ + + fields = {"PHostId": fields.Str(required=False, load_from="PHostId")} diff --git a/ucloud/services/uphost/schemas/models.py b/ucloud/services/uphost/schemas/models.py index 150c60b..5a5c191 100644 --- a/ucloud/services/uphost/schemas/models.py +++ b/ucloud/services/uphost/schemas/models.py @@ -1,108 +1,108 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.typesystem import schema, fields - - -class PHostCPUSetSchema(schema.ResponseSchema): - """ PHostCPUSet - DescribePHost - """ - - fields = { - "CoreCount": fields.Int(required=False, load_from="CoreCount"), - "Count": fields.Int(required=False, load_from="Count"), - "Frequence": fields.Float(required=False, load_from="Frequence"), - "Model": fields.Str(required=False, load_from="Model"), - } - - -class PHostDiskSetSchema(schema.ResponseSchema): - """ PHostDiskSet - GetPHostTypeInfo - """ - - fields = { - "Count": fields.Int(required=False, load_from="Count"), - "IOCap": fields.Int(required=False, load_from="IOCap"), - "Name": fields.Str(required=False, load_from="Name"), - "Space": fields.Int(required=False, load_from="Space"), - "Type": fields.Str(required=False, load_from="Type"), - } - - -class PHostIPSetSchema(schema.ResponseSchema): - """ PHostIPSet - DescribePHost - """ - - fields = { - "Bandwidth": fields.Int(required=False, load_from="Bandwidth"), - "IPAddr": fields.Str(required=False, load_from="IPAddr"), - "IPId": fields.Str(required=False, load_from="IPId"), - "MACAddr": fields.Str(required=False, load_from="MACAddr"), - "OperatorName": fields.Str(required=False, load_from="OperatorName"), - "SubnetId": fields.Str(required=False, load_from="SubnetId"), - "VPCId": fields.Str(required=False, load_from="VPCId"), - } - - -class PHostSetSchema(schema.ResponseSchema): - """ PHostSet - DescribePHost - """ - - fields = { - "AutoRenew": fields.Str(required=False, load_from="AutoRenew"), - "CPUSet": fields.List(PHostCPUSetSchema()), - "ChargeType": fields.Str(required=False, load_from="ChargeType"), - "Cluster": fields.Str(required=False, load_from="Cluster"), - "Components": fields.Str(required=False, load_from="Components"), - "CreateTime": fields.Int(required=False, load_from="CreateTime"), - "DiskSet": fields.List(PHostDiskSetSchema()), - "ExpireTime": fields.Int(required=False, load_from="ExpireTime"), - "IPSet": fields.List(PHostIPSetSchema()), - "ImageName": fields.Str(required=False, load_from="ImageName"), - "IsSupportKVM": fields.Str(required=False, load_from="IsSupportKVM"), - "Memory": fields.Int(required=False, load_from="Memory"), - "Name": fields.Str(required=False, load_from="Name"), - "OSType": fields.Str(required=False, load_from="OSType"), - "OSname": fields.Str(required=False, load_from="OSname"), - "PHostId": fields.Str(required=False, load_from="PHostId"), - "PHostType": fields.Str(required=False, load_from="PHostType"), - "PMStatus": fields.Str(required=False, load_from="PMStatus"), - "PowerState": fields.Str(required=False, load_from="PowerState"), - "RaidSupported": fields.Str(required=False, load_from="RaidSupported"), - "Remark": fields.Str(required=False, load_from="Remark"), - "SN": fields.Str(required=False, load_from="SN"), - "Tag": fields.Str(required=False, load_from="Tag"), - "Zone": fields.Str(required=False, load_from="Zone"), - } - - -class PHostImageSetSchema(schema.ResponseSchema): - """ PHostImageSet - DescribePHostImage - """ - - fields = { - "ImageId": fields.Str(required=False, load_from="ImageId"), - "ImageName": fields.Str(required=False, load_from="ImageName"), - "OsName": fields.Str(required=False, load_from="OsName"), - "OsType": fields.Str(required=False, load_from="OsType"), - } - - -class PHostTagSetSchema(schema.ResponseSchema): - """ PHostTagSet - DescribePHostTags - """ - - fields = { - "Tag": fields.Str(required=False, load_from="Tag"), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - } - - -class PHostPriceSetSchema(schema.ResponseSchema): - """ PHostPriceSet - GetPHostPrice - """ - - fields = { - "ChargeType": fields.Str(required=False, load_from="ChargeType"), - "Price": fields.Float(required=False, load_from="Price"), - } +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.typesystem import schema, fields + + +class PHostCPUSetSchema(schema.ResponseSchema): + """ PHostCPUSet - DescribePHost + """ + + fields = { + "CoreCount": fields.Int(required=False, load_from="CoreCount"), + "Count": fields.Int(required=False, load_from="Count"), + "Frequence": fields.Float(required=False, load_from="Frequence"), + "Model": fields.Str(required=False, load_from="Model"), + } + + +class PHostDiskSetSchema(schema.ResponseSchema): + """ PHostDiskSet - GetPHostTypeInfo + """ + + fields = { + "Count": fields.Int(required=False, load_from="Count"), + "IOCap": fields.Int(required=False, load_from="IOCap"), + "Name": fields.Str(required=False, load_from="Name"), + "Space": fields.Int(required=False, load_from="Space"), + "Type": fields.Str(required=False, load_from="Type"), + } + + +class PHostIPSetSchema(schema.ResponseSchema): + """ PHostIPSet - DescribePHost + """ + + fields = { + "Bandwidth": fields.Int(required=False, load_from="Bandwidth"), + "IPAddr": fields.Str(required=False, load_from="IPAddr"), + "IPId": fields.Str(required=False, load_from="IPId"), + "MACAddr": fields.Str(required=False, load_from="MACAddr"), + "OperatorName": fields.Str(required=False, load_from="OperatorName"), + "SubnetId": fields.Str(required=False, load_from="SubnetId"), + "VPCId": fields.Str(required=False, load_from="VPCId"), + } + + +class PHostSetSchema(schema.ResponseSchema): + """ PHostSet - DescribePHost + """ + + fields = { + "AutoRenew": fields.Str(required=False, load_from="AutoRenew"), + "CPUSet": fields.List(PHostCPUSetSchema()), + "ChargeType": fields.Str(required=False, load_from="ChargeType"), + "Cluster": fields.Str(required=False, load_from="Cluster"), + "Components": fields.Str(required=False, load_from="Components"), + "CreateTime": fields.Int(required=False, load_from="CreateTime"), + "DiskSet": fields.List(PHostDiskSetSchema()), + "ExpireTime": fields.Int(required=False, load_from="ExpireTime"), + "IPSet": fields.List(PHostIPSetSchema()), + "ImageName": fields.Str(required=False, load_from="ImageName"), + "IsSupportKVM": fields.Str(required=False, load_from="IsSupportKVM"), + "Memory": fields.Int(required=False, load_from="Memory"), + "Name": fields.Str(required=False, load_from="Name"), + "OSType": fields.Str(required=False, load_from="OSType"), + "OSname": fields.Str(required=False, load_from="OSname"), + "PHostId": fields.Str(required=False, load_from="PHostId"), + "PHostType": fields.Str(required=False, load_from="PHostType"), + "PMStatus": fields.Str(required=False, load_from="PMStatus"), + "PowerState": fields.Str(required=False, load_from="PowerState"), + "RaidSupported": fields.Str(required=False, load_from="RaidSupported"), + "Remark": fields.Str(required=False, load_from="Remark"), + "SN": fields.Str(required=False, load_from="SN"), + "Tag": fields.Str(required=False, load_from="Tag"), + "Zone": fields.Str(required=False, load_from="Zone"), + } + + +class PHostImageSetSchema(schema.ResponseSchema): + """ PHostImageSet - DescribePHostImage + """ + + fields = { + "ImageId": fields.Str(required=False, load_from="ImageId"), + "ImageName": fields.Str(required=False, load_from="ImageName"), + "OsName": fields.Str(required=False, load_from="OsName"), + "OsType": fields.Str(required=False, load_from="OsType"), + } + + +class PHostTagSetSchema(schema.ResponseSchema): + """ PHostTagSet - DescribePHostTags + """ + + fields = { + "Tag": fields.Str(required=False, load_from="Tag"), + "TotalCount": fields.Int(required=False, load_from="TotalCount"), + } + + +class PHostPriceSetSchema(schema.ResponseSchema): + """ PHostPriceSet - GetPHostPrice + """ + + fields = { + "ChargeType": fields.Str(required=False, load_from="ChargeType"), + "Price": fields.Float(required=False, load_from="Price"), + } diff --git a/ucloud/services/vpc/__init__.py b/ucloud/services/vpc/__init__.py index 4c48b5a..40a96af 100644 --- a/ucloud/services/vpc/__init__.py +++ b/ucloud/services/vpc/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- diff --git a/ucloud/services/vpc/client.py b/ucloud/services/vpc/client.py index f07b868..bd91bdb 100644 --- a/ucloud/services/vpc/client.py +++ b/ucloud/services/vpc/client.py @@ -1,542 +1,542 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.client import Client -from ucloud.services.vpc.schemas import apis - - -class VPCClient(Client): - def __init__(self, config, transport=None, middleware=None, logger=None): - super(VPCClient, self).__init__(config, transport, middleware, logger) - - def add_vpc_network(self, req=None, **kwargs): - """ AddVPCNetwork - 添加VPC网段 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Network** (list) - (Required) 增加网段 - - **VPCId** (str) - (Required) 源VPC短ID - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.AddVPCNetworkRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("AddVPCNetwork", d, **kwargs) - return apis.AddVPCNetworkResponseSchema().loads(resp) - - def associate_route_table(self, req=None, **kwargs): - """ AssociateRouteTable - 绑定子网的路由表 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **RouteTableId** (str) - (Required) 路由表ID,仅限自定义路由表 - - **SubnetId** (str) - (Required) 子网ID - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.AssociateRouteTableRequestSchema().dumps(d) - resp = self.invoke("AssociateRouteTable", d, **kwargs) - return apis.AssociateRouteTableResponseSchema().loads(resp) - - def clone_route_table(self, req=None, **kwargs): - """ CloneRouteTable - 根据一张现有路由表复制一张新的路由表 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **RouteTableId** (str) - (Required) 被克隆的路由表ID - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.CloneRouteTableRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("CloneRouteTable", d, **kwargs) - return apis.CloneRouteTableResponseSchema().loads(resp) - - def create_route_table(self, req=None, **kwargs): - """ CreateRouteTable - 创建路由表 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **VPCId** (str) - (Required) VPC ID - - **Name** (str) - 路由表名称 Default RouteTable - - **Remark** (str) - 备注 - - **Tag** (str) - 业务组 - - **Response** - - - **RouteTableId** (str) - 路由表ID - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.CreateRouteTableRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("CreateRouteTable", d, **kwargs) - return apis.CreateRouteTableResponseSchema().loads(resp) - - def create_subnet(self, req=None, **kwargs): - """ CreateSubnet - 创建子网 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Subnet** (str) - (Required) 子网网络地址,例如192.168.0.0 - - **VPCId** (str) - (Required) VPC资源ID - - **Netmask** (int) - 子网网络号位数,默认为24 - - **Remark** (str) - 备注 - - **SubnetName** (str) - 子网名称,默认为Subnet - - **Tag** (str) - 业务组名称,默认为Default - - **Response** - - - **SubnetId** (str) - 子网ID - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.CreateSubnetRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("CreateSubnet", d, **kwargs) - return apis.CreateSubnetResponseSchema().loads(resp) - - def create_vpc(self, req=None, **kwargs): - """ CreateVPC - 创建VPC - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Name** (str) - (Required) VPC名称 - - **Network** (list) - (Required) VPC网段 - - **Remark** (str) - 备注 - - **Tag** (str) - 业务组名称 - - **Type** (int) - VPC类型 - - **Response** - - - **VPCId** (str) - VPC资源Id - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.CreateVPCRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("CreateVPC", d, **kwargs) - return apis.CreateVPCResponseSchema().loads(resp) - - def create_vpc_intercom(self, req=None, **kwargs): - """ CreateVPCIntercom - 新建VPC互通关系 - - **Request** - - - **ProjectId** (str) - (Config) 源VPC所在项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 源VPC所在地域。 参见 `地域和可用区列表 `_ - - **DstVPCId** (str) - (Required) 目的VPC短ID - - **VPCId** (str) - (Required) 源VPC短ID - - **DstProjectId** (str) - 目的VPC项目ID。默认与源VPC同项目。 - - **DstRegion** (str) - 目的VPC所在地域,默认与源VPC同地域。 - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.CreateVPCIntercomRequestSchema().dumps(d) - kwargs["max_retries"] = 0 - resp = self.invoke("CreateVPCIntercom", d, **kwargs) - return apis.CreateVPCIntercomResponseSchema().loads(resp) - - def delete_route_table(self, req=None, **kwargs): - """ DeleteRouteTable - 删除自定义路由表 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **RouteTableId** (str) - (Required) 路由ID - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DeleteRouteTableRequestSchema().dumps(d) - resp = self.invoke("DeleteRouteTable", d, **kwargs) - return apis.DeleteRouteTableResponseSchema().loads(resp) - - def delete_subnet(self, req=None, **kwargs): - """ DeleteSubnet - 删除子网 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **SubnetId** (str) - (Required) 子网ID - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DeleteSubnetRequestSchema().dumps(d) - resp = self.invoke("DeleteSubnet", d, **kwargs) - return apis.DeleteSubnetResponseSchema().loads(resp) - - def delete_vpc(self, req=None, **kwargs): - """ DeleteVPC - 删除VPC - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **VPCId** (str) - (Required) VPC资源Id - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DeleteVPCRequestSchema().dumps(d) - resp = self.invoke("DeleteVPC", d, **kwargs) - return apis.DeleteVPCResponseSchema().loads(resp) - - def delete_vpc_intercom(self, req=None, **kwargs): - """ DeleteVPCIntercom - 删除VPC互通关系 - - **Request** - - - **ProjectId** (str) - (Config) 源VPC所在项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 源VPC所在地域。 参见 `地域和可用区列表 `_ - - **DstVPCId** (str) - (Required) 目的VPC短ID - - **VPCId** (str) - (Required) 源VPC短ID - - **DstProjectId** (str) - 目的VPC所在项目ID,默认为源VPC所在项目ID - - **DstRegion** (str) - 目的VPC所在地域,默认为源VPC所在地域 - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DeleteVPCIntercomRequestSchema().dumps(d) - resp = self.invoke("DeleteVPCIntercom", d, **kwargs) - return apis.DeleteVPCIntercomResponseSchema().loads(resp) - - def describe_route_table(self, req=None, **kwargs): - """ DescribeRouteTable - 获取路由表详细信息(包括路由策略) - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **BusinessId** (str) - 业务组ID - - **Limit** (int) - Limit - - **OffSet** (int) - OffSet - - **RouteTableId** (str) - 路由表ID - - **VPCId** (str) - VPC ID - - **Response** - - - **RouteTables** (list) - 见 **RouteTableInfo** 模型定义 - - **TotalCount** (int) - RouteTables字段的数量 - - **Response Model** - - **RouteRuleInfo** - - - **DstAddr** (str) - 目的地址,比如10.10.8/24 - - **NexthopId** (str) - 路由下一跳ID,比如uvnet-3eljvj - - **NexthopType** (str) - 下一跳类型,比如local、vnet - - **Remark** (str) - 路由规则备注 - - **RouteRuleId** (str) - 规则ID - - **RuleType** (int) - 路由规则类型(0表示系统路由,1表示自定义路由) - - **RouteTableInfo** - - - **CreateTime** (int) - 创建时间戳 - - **Remark** (str) - 路由表备注 - - **RouteRules** (list) - 见 **RouteRuleInfo** 模型定义 - - **RouteTableId** (str) - 路由表ID - - **RouteTableType** (int) - 路由表类型,1为默认,0为自定义 - - **SubnetCount** (str) - 绑定了该路由表的子网数量 - - **Tag** (str) - 业务组 - - **VPCId** (str) - 路由表所属vpc - - **VPCName** (str) - vpc名称 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeRouteTableRequestSchema().dumps(d) - resp = self.invoke("DescribeRouteTable", d, **kwargs) - return apis.DescribeRouteTableResponseSchema().loads(resp) - - def describe_subnet(self, req=None, **kwargs): - """ DescribeSubnet - 获取子网信息 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **BusinessId** (str) - 业务组 - - **Limit** (int) - 列表长度,默认为20 - - **Offset** (int) - 偏移量,默认为0 - - **RouteTableId** (str) - 路由表Id - - **SubnetId** (str) - 子网id,适用于一次查询一个子网信息 - - **SubnetIds** (list) - 子网id数组,适用于一次查询多个子网信息 - - **Tag** (str) - 业务组名称,默认为Default - - **VPCId** (str) - VPC资源id - - **Response** - - - **DataSet** (list) - 见 **SubnetInfo** 模型定义 - - **TotalCount** (int) - 子网总数量 - - **Response Model** - - **SubnetInfo** - - - **CreateTime** (int) - 创建时间 - - **Gateway** (str) - 子网网关 - - **HasNATGW** (bool) - 是否有natgw - - **IPv6Network** (str) - 子网关联的IPv6网段 - - **Netmask** (int) - 子网掩码 - - **OperatorName** (str) - 子网关联的IPv6网段所属运营商 - - **Remark** (str) - 备注 - - **RouteTableId** (str) - 路由表Id - - **Subnet** (str) - 子网网段 - - **SubnetId** (str) - 子网Id - - **SubnetName** (str) - 子网名称 - - **SubnetType** (int) - 子网类型 - - **Tag** (str) - 业务组 - - **VPCId** (str) - VPCId - - **VPCName** (str) - VPC名称 - - **Zone** (str) - 可用区名称 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeSubnetRequestSchema().dumps(d) - resp = self.invoke("DescribeSubnet", d, **kwargs) - return apis.DescribeSubnetResponseSchema().loads(resp) - - def describe_subnet_resource(self, req=None, **kwargs): - """ DescribeSubnetResource - 展示子网资源 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **SubnetId** (str) - (Required) 子网id - - **Limit** (int) - 单页返回数据长度,默认为20 - - **Offset** (int) - 列表起始位置偏移量,默认为0 - - **ResourceType** (str) - 资源类型,默认为全部资源类型。枚举值为:UHOST,云主机;PHOST,物理云主机;ULB,负载均衡;UHADOOP_HOST,hadoop节点;UFORTRESS_HOST,堡垒机;UNATGW,NAT网关;UKAFKA,Kafka消息队列;UMEM,内存存储;DOCKER,容器集群;UDB,数据库;UDW,数据仓库;VIP,内网VIP. - - **Response** - - - **DataSet** (list) - 见 **SubnetResource** 模型定义 - - **TotalCount** (int) - 总数 - - **Response Model** - - **SubnetResource** - - - **IP** (str) - 资源ip - - **IPv6Address** (str) - 资源的IPv6地址 - - **Name** (str) - 资源名称 - - **ResourceId** (str) - 资源Id - - **ResourceType** (str) - 资源类型。对应的资源类型:UHOST,云主机;PHOST,物理云主机;ULB,负载均衡;UHADOOP_HOST,hadoop节点;UFORTRESS_HOST,堡垒机;UNATGW,NAT网关;UKAFKA,Kafka消息队列;UMEM,内存存储;DOCKER,容器集群;UDB,数据库;UDW,数据仓库;VIP,内网VIP. - - **SubResourceId** (str) - 资源绑定的虚拟网卡的实例ID - - **SubResourceName** (str) - 资源绑定的虚拟网卡的实例名称 - - **SubResourceType** (str) - 资源绑定的虚拟网卡的类型 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeSubnetResourceRequestSchema().dumps(d) - resp = self.invoke("DescribeSubnetResource", d, **kwargs) - return apis.DescribeSubnetResourceResponseSchema().loads(resp) - - def describe_vpc(self, req=None, **kwargs): - """ DescribeVPC - 获取VPC信息 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Limit** (int) - - - **Offset** (int) - - - **Tag** (str) - 业务组名称 - - **VPCIds** (list) - VPCId - - **Response** - - - **DataSet** (list) - 见 **VPCInfo** 模型定义 - - **Response Model** - - **VPCNetworkInfo** - - - **Network** (str) - vpc地址空间 - - **SubnetCount** (int) - 地址空间中子网数量 - - **VPCInfo** - - - **CreateTime** (int) - - - **IPv6Network** (str) - VPC关联的IPv6网段 - - **Name** (str) - - - **Network** (list) - - - **NetworkInfo** (list) - 见 **VPCNetworkInfo** 模型定义 - - **OperatorName** (str) - VPC关联的IPv6网段所属运营商 - - **SubnetCount** (int) - - - **Tag** (str) - - - **UpdateTime** (int) - - - **VPCId** (str) - VPCId - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeVPCRequestSchema().dumps(d) - resp = self.invoke("DescribeVPC", d, **kwargs) - return apis.DescribeVPCResponseSchema().loads(resp) - - def describe_vpc_intercom(self, req=None, **kwargs): - """ DescribeVPCIntercom - 获取VPC互通信息 - - **Request** - - - **ProjectId** (str) - (Config) 源VPC所在项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 源VPC所在地域。 参见 `地域和可用区列表 `_ - - **VPCId** (str) - (Required) VPC短ID - - **DstProjectId** (str) - 目的项目ID,默认为全部项目 - - **DstRegion** (str) - 目的VPC所在地域,默认为全部地域 - - **Response** - - - **DataSet** (list) - 见 **VPCIntercomInfo** 模型定义 - - **Response Model** - - **VPCIntercomInfo** - - - **DstRegion** (str) - 所属地域 - - **Name** (str) - VPC名字 - - **Network** (list) - VPC的地址空间 - - **ProjectId** (str) - 项目Id - - **Tag** (str) - 业务组(未分组显示为 Default) - - **VPCId** (str) - VPCId - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.DescribeVPCIntercomRequestSchema().dumps(d) - resp = self.invoke("DescribeVPCIntercom", d, **kwargs) - return apis.DescribeVPCIntercomResponseSchema().loads(resp) - - def modify_route_rule(self, req=None, **kwargs): - """ ModifyRouteRule - 路由策略增、删、改 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **RouteRule** (list) - (Required) 格式: RouteRuleId | 目的网段 | 下一跳类型 | 下一跳 |优先级| 备注 | 增、删、改标志 (下一跳类型为instance或者vip,下一跳为云主机id或者vip的id,优先级使用0,动作标志为add/delete/update) 。"添加"示例: test_id | 10.8.0.0/16 | instance | uhost-xd8ja | 0 | Default Route Rule| add (添加的RouteRuleId填任意非空字符串) 。"删除"示例: routerule-xk3jxa | 10.8.0.0/16 | instance | uhost-xd8ja | 0 | Default Route Rule| delete (RouteRuleId来自DescribeRouteTable中) 。“修改”示例: routerule-xk3jxa | 10.8.0.0/16 | instance | uhost-cjksa2 | 0 | Default Route Rule| update (RouteRuleId来自DescribeRouteTable中) - - **RouteTableId** (str) - (Required) 通过DescribeRouteTable拿到 - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.ModifyRouteRuleRequestSchema().dumps(d) - resp = self.invoke("ModifyRouteRule", d, **kwargs) - return apis.ModifyRouteRuleResponseSchema().loads(resp) - - def update_route_table_attribute(self, req=None, **kwargs): - """ UpdateRouteTableAttribute - 更新路由表基本信息 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **RouteTableId** (str) - (Required) 路由表ID - - **Name** (str) - 名称 - - **Remark** (str) - 备注 - - **Tag** (str) - 业务组名称 - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.UpdateRouteTableAttributeRequestSchema().dumps(d) - resp = self.invoke("UpdateRouteTableAttribute", d, **kwargs) - return apis.UpdateRouteTableAttributeResponseSchema().loads(resp) - - def update_subnet_attribute(self, req=None, **kwargs): - """ UpdateSubnetAttribute - 更新子网信息 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **SubnetId** (str) - (Required) 子网ID - - **Name** (str) - 子网名称(如果Name不填写,Tag必须填写) - - **Tag** (str) - 业务组名称(如果Tag不填写,Name必须填写) - - **Response** - - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.UpdateSubnetAttributeRequestSchema().dumps(d) - resp = self.invoke("UpdateSubnetAttribute", d, **kwargs) - return apis.UpdateSubnetAttributeResponseSchema().loads(resp) - - def update_vpc_network(self, req=None, **kwargs): - """ UpdateVPCNetwork - 更新VPC网段 - - **Request** - - - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ - - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ - - **Network** (list) - (Required) 需要保留的VPC网段。当前仅支持删除VPC网段,添加网段请参考 `AddVPCNetwork `_ - - **VPCId** (str) - (Required) VPC的ID - - **Response** - - - **Message** (str) - 错误信息 - - """ - d = {"ProjectId": self.config.project_id, "Region": self.config.region} - req and d.update(req) - d = apis.UpdateVPCNetworkRequestSchema().dumps(d) - resp = self.invoke("UpdateVPCNetwork", d, **kwargs) - return apis.UpdateVPCNetworkResponseSchema().loads(resp) +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.client import Client +from ucloud.services.vpc.schemas import apis + + +class VPCClient(Client): + def __init__(self, config, transport=None, middleware=None, logger=None): + super(VPCClient, self).__init__(config, transport, middleware, logger) + + def add_vpc_network(self, req=None, **kwargs): + """ AddVPCNetwork - 添加VPC网段 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Network** (list) - (Required) 增加网段 + - **VPCId** (str) - (Required) 源VPC短ID + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.AddVPCNetworkRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("AddVPCNetwork", d, **kwargs) + return apis.AddVPCNetworkResponseSchema().loads(resp) + + def associate_route_table(self, req=None, **kwargs): + """ AssociateRouteTable - 绑定子网的路由表 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **RouteTableId** (str) - (Required) 路由表ID,仅限自定义路由表 + - **SubnetId** (str) - (Required) 子网ID + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.AssociateRouteTableRequestSchema().dumps(d) + resp = self.invoke("AssociateRouteTable", d, **kwargs) + return apis.AssociateRouteTableResponseSchema().loads(resp) + + def clone_route_table(self, req=None, **kwargs): + """ CloneRouteTable - 根据一张现有路由表复制一张新的路由表 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **RouteTableId** (str) - (Required) 被克隆的路由表ID + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.CloneRouteTableRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("CloneRouteTable", d, **kwargs) + return apis.CloneRouteTableResponseSchema().loads(resp) + + def create_route_table(self, req=None, **kwargs): + """ CreateRouteTable - 创建路由表 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **VPCId** (str) - (Required) VPC ID + - **Name** (str) - 路由表名称 Default RouteTable + - **Remark** (str) - 备注 + - **Tag** (str) - 业务组 + + **Response** + + - **RouteTableId** (str) - 路由表ID + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.CreateRouteTableRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("CreateRouteTable", d, **kwargs) + return apis.CreateRouteTableResponseSchema().loads(resp) + + def create_subnet(self, req=None, **kwargs): + """ CreateSubnet - 创建子网 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Subnet** (str) - (Required) 子网网络地址,例如192.168.0.0 + - **VPCId** (str) - (Required) VPC资源ID + - **Netmask** (int) - 子网网络号位数,默认为24 + - **Remark** (str) - 备注 + - **SubnetName** (str) - 子网名称,默认为Subnet + - **Tag** (str) - 业务组名称,默认为Default + + **Response** + + - **SubnetId** (str) - 子网ID + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.CreateSubnetRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("CreateSubnet", d, **kwargs) + return apis.CreateSubnetResponseSchema().loads(resp) + + def create_vpc(self, req=None, **kwargs): + """ CreateVPC - 创建VPC + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Name** (str) - (Required) VPC名称 + - **Network** (list) - (Required) VPC网段 + - **Remark** (str) - 备注 + - **Tag** (str) - 业务组名称 + - **Type** (int) - VPC类型 + + **Response** + + - **VPCId** (str) - VPC资源Id + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.CreateVPCRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("CreateVPC", d, **kwargs) + return apis.CreateVPCResponseSchema().loads(resp) + + def create_vpc_intercom(self, req=None, **kwargs): + """ CreateVPCIntercom - 新建VPC互通关系 + + **Request** + + - **ProjectId** (str) - (Config) 源VPC所在项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 源VPC所在地域。 参见 `地域和可用区列表 `_ + - **DstVPCId** (str) - (Required) 目的VPC短ID + - **VPCId** (str) - (Required) 源VPC短ID + - **DstProjectId** (str) - 目的VPC项目ID。默认与源VPC同项目。 + - **DstRegion** (str) - 目的VPC所在地域,默认与源VPC同地域。 + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.CreateVPCIntercomRequestSchema().dumps(d) + kwargs["max_retries"] = 0 + resp = self.invoke("CreateVPCIntercom", d, **kwargs) + return apis.CreateVPCIntercomResponseSchema().loads(resp) + + def delete_route_table(self, req=None, **kwargs): + """ DeleteRouteTable - 删除自定义路由表 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **RouteTableId** (str) - (Required) 路由ID + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DeleteRouteTableRequestSchema().dumps(d) + resp = self.invoke("DeleteRouteTable", d, **kwargs) + return apis.DeleteRouteTableResponseSchema().loads(resp) + + def delete_subnet(self, req=None, **kwargs): + """ DeleteSubnet - 删除子网 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **SubnetId** (str) - (Required) 子网ID + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DeleteSubnetRequestSchema().dumps(d) + resp = self.invoke("DeleteSubnet", d, **kwargs) + return apis.DeleteSubnetResponseSchema().loads(resp) + + def delete_vpc(self, req=None, **kwargs): + """ DeleteVPC - 删除VPC + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **VPCId** (str) - (Required) VPC资源Id + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DeleteVPCRequestSchema().dumps(d) + resp = self.invoke("DeleteVPC", d, **kwargs) + return apis.DeleteVPCResponseSchema().loads(resp) + + def delete_vpc_intercom(self, req=None, **kwargs): + """ DeleteVPCIntercom - 删除VPC互通关系 + + **Request** + + - **ProjectId** (str) - (Config) 源VPC所在项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 源VPC所在地域。 参见 `地域和可用区列表 `_ + - **DstVPCId** (str) - (Required) 目的VPC短ID + - **VPCId** (str) - (Required) 源VPC短ID + - **DstProjectId** (str) - 目的VPC所在项目ID,默认为源VPC所在项目ID + - **DstRegion** (str) - 目的VPC所在地域,默认为源VPC所在地域 + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DeleteVPCIntercomRequestSchema().dumps(d) + resp = self.invoke("DeleteVPCIntercom", d, **kwargs) + return apis.DeleteVPCIntercomResponseSchema().loads(resp) + + def describe_route_table(self, req=None, **kwargs): + """ DescribeRouteTable - 获取路由表详细信息(包括路由策略) + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **BusinessId** (str) - 业务组ID + - **Limit** (int) - Limit + - **OffSet** (int) - OffSet + - **RouteTableId** (str) - 路由表ID + - **VPCId** (str) - VPC ID + + **Response** + + - **RouteTables** (list) - 见 **RouteTableInfo** 模型定义 + - **TotalCount** (int) - RouteTables字段的数量 + + **Response Model** + + **RouteRuleInfo** + + - **DstAddr** (str) - 目的地址,比如10.10.8/24 + - **NexthopId** (str) - 路由下一跳ID,比如uvnet-3eljvj + - **NexthopType** (str) - 下一跳类型,比如local、vnet + - **Remark** (str) - 路由规则备注 + - **RouteRuleId** (str) - 规则ID + - **RuleType** (int) - 路由规则类型(0表示系统路由,1表示自定义路由) + + **RouteTableInfo** + + - **CreateTime** (int) - 创建时间戳 + - **Remark** (str) - 路由表备注 + - **RouteRules** (list) - 见 **RouteRuleInfo** 模型定义 + - **RouteTableId** (str) - 路由表ID + - **RouteTableType** (int) - 路由表类型,1为默认,0为自定义 + - **SubnetCount** (str) - 绑定了该路由表的子网数量 + - **Tag** (str) - 业务组 + - **VPCId** (str) - 路由表所属vpc + - **VPCName** (str) - vpc名称 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeRouteTableRequestSchema().dumps(d) + resp = self.invoke("DescribeRouteTable", d, **kwargs) + return apis.DescribeRouteTableResponseSchema().loads(resp) + + def describe_subnet(self, req=None, **kwargs): + """ DescribeSubnet - 获取子网信息 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **BusinessId** (str) - 业务组 + - **Limit** (int) - 列表长度,默认为20 + - **Offset** (int) - 偏移量,默认为0 + - **RouteTableId** (str) - 路由表Id + - **SubnetId** (str) - 子网id,适用于一次查询一个子网信息 + - **SubnetIds** (list) - 子网id数组,适用于一次查询多个子网信息 + - **Tag** (str) - 业务组名称,默认为Default + - **VPCId** (str) - VPC资源id + + **Response** + + - **DataSet** (list) - 见 **SubnetInfo** 模型定义 + - **TotalCount** (int) - 子网总数量 + + **Response Model** + + **SubnetInfo** + + - **CreateTime** (int) - 创建时间 + - **Gateway** (str) - 子网网关 + - **HasNATGW** (bool) - 是否有natgw + - **IPv6Network** (str) - 子网关联的IPv6网段 + - **Netmask** (int) - 子网掩码 + - **OperatorName** (str) - 子网关联的IPv6网段所属运营商 + - **Remark** (str) - 备注 + - **RouteTableId** (str) - 路由表Id + - **Subnet** (str) - 子网网段 + - **SubnetId** (str) - 子网Id + - **SubnetName** (str) - 子网名称 + - **SubnetType** (int) - 子网类型 + - **Tag** (str) - 业务组 + - **VPCId** (str) - VPCId + - **VPCName** (str) - VPC名称 + - **Zone** (str) - 可用区名称 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeSubnetRequestSchema().dumps(d) + resp = self.invoke("DescribeSubnet", d, **kwargs) + return apis.DescribeSubnetResponseSchema().loads(resp) + + def describe_subnet_resource(self, req=None, **kwargs): + """ DescribeSubnetResource - 展示子网资源 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **SubnetId** (str) - (Required) 子网id + - **Limit** (int) - 单页返回数据长度,默认为20 + - **Offset** (int) - 列表起始位置偏移量,默认为0 + - **ResourceType** (str) - 资源类型,默认为全部资源类型。枚举值为:UHOST,云主机;PHOST,物理云主机;ULB,负载均衡;UHADOOP_HOST,hadoop节点;UFORTRESS_HOST,堡垒机;UNATGW,NAT网关;UKAFKA,Kafka消息队列;UMEM,内存存储;DOCKER,容器集群;UDB,数据库;UDW,数据仓库;VIP,内网VIP. + + **Response** + + - **DataSet** (list) - 见 **SubnetResource** 模型定义 + - **TotalCount** (int) - 总数 + + **Response Model** + + **SubnetResource** + + - **IP** (str) - 资源ip + - **IPv6Address** (str) - 资源的IPv6地址 + - **Name** (str) - 资源名称 + - **ResourceId** (str) - 资源Id + - **ResourceType** (str) - 资源类型。对应的资源类型:UHOST,云主机;PHOST,物理云主机;ULB,负载均衡;UHADOOP_HOST,hadoop节点;UFORTRESS_HOST,堡垒机;UNATGW,NAT网关;UKAFKA,Kafka消息队列;UMEM,内存存储;DOCKER,容器集群;UDB,数据库;UDW,数据仓库;VIP,内网VIP. + - **SubResourceId** (str) - 资源绑定的虚拟网卡的实例ID + - **SubResourceName** (str) - 资源绑定的虚拟网卡的实例名称 + - **SubResourceType** (str) - 资源绑定的虚拟网卡的类型 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeSubnetResourceRequestSchema().dumps(d) + resp = self.invoke("DescribeSubnetResource", d, **kwargs) + return apis.DescribeSubnetResourceResponseSchema().loads(resp) + + def describe_vpc(self, req=None, **kwargs): + """ DescribeVPC - 获取VPC信息 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Limit** (int) - + - **Offset** (int) - + - **Tag** (str) - 业务组名称 + - **VPCIds** (list) - VPCId + + **Response** + + - **DataSet** (list) - 见 **VPCInfo** 模型定义 + + **Response Model** + + **VPCNetworkInfo** + + - **Network** (str) - vpc地址空间 + - **SubnetCount** (int) - 地址空间中子网数量 + + **VPCInfo** + + - **CreateTime** (int) - + - **IPv6Network** (str) - VPC关联的IPv6网段 + - **Name** (str) - + - **Network** (list) - + - **NetworkInfo** (list) - 见 **VPCNetworkInfo** 模型定义 + - **OperatorName** (str) - VPC关联的IPv6网段所属运营商 + - **SubnetCount** (int) - + - **Tag** (str) - + - **UpdateTime** (int) - + - **VPCId** (str) - VPCId + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeVPCRequestSchema().dumps(d) + resp = self.invoke("DescribeVPC", d, **kwargs) + return apis.DescribeVPCResponseSchema().loads(resp) + + def describe_vpc_intercom(self, req=None, **kwargs): + """ DescribeVPCIntercom - 获取VPC互通信息 + + **Request** + + - **ProjectId** (str) - (Config) 源VPC所在项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 源VPC所在地域。 参见 `地域和可用区列表 `_ + - **VPCId** (str) - (Required) VPC短ID + - **DstProjectId** (str) - 目的项目ID,默认为全部项目 + - **DstRegion** (str) - 目的VPC所在地域,默认为全部地域 + + **Response** + + - **DataSet** (list) - 见 **VPCIntercomInfo** 模型定义 + + **Response Model** + + **VPCIntercomInfo** + + - **DstRegion** (str) - 所属地域 + - **Name** (str) - VPC名字 + - **Network** (list) - VPC的地址空间 + - **ProjectId** (str) - 项目Id + - **Tag** (str) - 业务组(未分组显示为 Default) + - **VPCId** (str) - VPCId + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.DescribeVPCIntercomRequestSchema().dumps(d) + resp = self.invoke("DescribeVPCIntercom", d, **kwargs) + return apis.DescribeVPCIntercomResponseSchema().loads(resp) + + def modify_route_rule(self, req=None, **kwargs): + """ ModifyRouteRule - 路由策略增、删、改 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **RouteRule** (list) - (Required) 格式: RouteRuleId | 目的网段 | 下一跳类型 | 下一跳 |优先级| 备注 | 增、删、改标志 (下一跳类型为instance或者vip,下一跳为云主机id或者vip的id,优先级使用0,动作标志为add/delete/update) 。"添加"示例: test_id | 10.8.0.0/16 | instance | uhost-xd8ja | 0 | Default Route Rule| add (添加的RouteRuleId填任意非空字符串) 。"删除"示例: routerule-xk3jxa | 10.8.0.0/16 | instance | uhost-xd8ja | 0 | Default Route Rule| delete (RouteRuleId来自DescribeRouteTable中) 。“修改”示例: routerule-xk3jxa | 10.8.0.0/16 | instance | uhost-cjksa2 | 0 | Default Route Rule| update (RouteRuleId来自DescribeRouteTable中) + - **RouteTableId** (str) - (Required) 通过DescribeRouteTable拿到 + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.ModifyRouteRuleRequestSchema().dumps(d) + resp = self.invoke("ModifyRouteRule", d, **kwargs) + return apis.ModifyRouteRuleResponseSchema().loads(resp) + + def update_route_table_attribute(self, req=None, **kwargs): + """ UpdateRouteTableAttribute - 更新路由表基本信息 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **RouteTableId** (str) - (Required) 路由表ID + - **Name** (str) - 名称 + - **Remark** (str) - 备注 + - **Tag** (str) - 业务组名称 + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.UpdateRouteTableAttributeRequestSchema().dumps(d) + resp = self.invoke("UpdateRouteTableAttribute", d, **kwargs) + return apis.UpdateRouteTableAttributeResponseSchema().loads(resp) + + def update_subnet_attribute(self, req=None, **kwargs): + """ UpdateSubnetAttribute - 更新子网信息 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **SubnetId** (str) - (Required) 子网ID + - **Name** (str) - 子网名称(如果Name不填写,Tag必须填写) + - **Tag** (str) - 业务组名称(如果Tag不填写,Name必须填写) + + **Response** + + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.UpdateSubnetAttributeRequestSchema().dumps(d) + resp = self.invoke("UpdateSubnetAttribute", d, **kwargs) + return apis.UpdateSubnetAttributeResponseSchema().loads(resp) + + def update_vpc_network(self, req=None, **kwargs): + """ UpdateVPCNetwork - 更新VPC网段 + + **Request** + + - **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 `_ + - **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 `_ + - **Network** (list) - (Required) 需要保留的VPC网段。当前仅支持删除VPC网段,添加网段请参考 `AddVPCNetwork `_ + - **VPCId** (str) - (Required) VPC的ID + + **Response** + + - **Message** (str) - 错误信息 + + """ + d = {"ProjectId": self.config.project_id, "Region": self.config.region} + req and d.update(req) + d = apis.UpdateVPCNetworkRequestSchema().dumps(d) + resp = self.invoke("UpdateVPCNetwork", d, **kwargs) + return apis.UpdateVPCNetworkResponseSchema().loads(resp) diff --git a/ucloud/services/vpc/schemas/__init__.py b/ucloud/services/vpc/schemas/__init__.py index 4c48b5a..40a96af 100644 --- a/ucloud/services/vpc/schemas/__init__.py +++ b/ucloud/services/vpc/schemas/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- diff --git a/ucloud/services/vpc/schemas/apis.py b/ucloud/services/vpc/schemas/apis.py index 1c3ce80..cef0fc2 100644 --- a/ucloud/services/vpc/schemas/apis.py +++ b/ucloud/services/vpc/schemas/apis.py @@ -1,575 +1,579 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.typesystem import schema, fields -from ucloud.services.vpc.schemas import models - -""" VPC API Schema -""" -""" -API: AddVPCNetwork - -添加VPC网段 -""" - - -class AddVPCNetworkRequestSchema(schema.RequestSchema): - """ AddVPCNetwork - 添加VPC网段 - """ - - fields = { - "Network": fields.List(fields.Str()), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "VPCId": fields.Str(required=True, dump_to="VPCId"), - } - - -class AddVPCNetworkResponseSchema(schema.ResponseSchema): - """ AddVPCNetwork - 添加VPC网段 - """ - - fields = {} - - -""" -API: AssociateRouteTable - -绑定子网的路由表 -""" - - -class AssociateRouteTableRequestSchema(schema.RequestSchema): - """ AssociateRouteTable - 绑定子网的路由表 - """ - - fields = { - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "RouteTableId": fields.Str(required=True, dump_to="RouteTableId"), - "SubnetId": fields.Str(required=True, dump_to="SubnetId"), - } - - -class AssociateRouteTableResponseSchema(schema.ResponseSchema): - """ AssociateRouteTable - 绑定子网的路由表 - """ - - fields = {} - - -""" -API: CloneRouteTable - -根据一张现有路由表复制一张新的路由表 -""" - - -class CloneRouteTableRequestSchema(schema.RequestSchema): - """ CloneRouteTable - 根据一张现有路由表复制一张新的路由表 - """ - - fields = { - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=False, dump_to="Region"), - "RouteTableId": fields.Str(required=True, dump_to="RouteTableId"), - } - - -class CloneRouteTableResponseSchema(schema.ResponseSchema): - """ CloneRouteTable - 根据一张现有路由表复制一张新的路由表 - """ - - fields = {} - - -""" -API: CreateRouteTable - -创建路由表 -""" - - -class CreateRouteTableRequestSchema(schema.RequestSchema): - """ CreateRouteTable - 创建路由表 - """ - - fields = { - "Name": fields.Str(required=False, dump_to="Name"), - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Remark": fields.Str(required=False, dump_to="Remark"), - "Tag": fields.Str(required=False, dump_to="Tag"), - "VPCId": fields.Str(required=True, dump_to="VPCId"), - } - - -class CreateRouteTableResponseSchema(schema.ResponseSchema): - """ CreateRouteTable - 创建路由表 - """ - - fields = {"RouteTableId": fields.Str(required=False, load_from="RouteTableId")} - - -""" -API: CreateSubnet - -创建子网 -""" - - -class CreateSubnetRequestSchema(schema.RequestSchema): - """ CreateSubnet - 创建子网 - """ - - fields = { - "Netmask": fields.Int(required=False, dump_to="Netmask"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Remark": fields.Str(required=False, dump_to="Remark"), - "Subnet": fields.Str(required=True, dump_to="Subnet"), - "SubnetName": fields.Str(required=False, dump_to="SubnetName"), - "Tag": fields.Str(required=False, dump_to="Tag"), - "VPCId": fields.Str(required=True, dump_to="VPCId"), - } - - -class CreateSubnetResponseSchema(schema.ResponseSchema): - """ CreateSubnet - 创建子网 - """ - - fields = {"SubnetId": fields.Str(required=False, load_from="SubnetId")} - - -""" -API: CreateVPC - -创建VPC -""" - - -class CreateVPCRequestSchema(schema.RequestSchema): - """ CreateVPC - 创建VPC - """ - - fields = { - "Name": fields.Str(required=True, dump_to="Name"), - "Network": fields.List(fields.Str()), - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Remark": fields.Str(required=False, dump_to="Remark"), - "Tag": fields.Str(required=False, dump_to="Tag"), - "Type": fields.Int(required=False, dump_to="Type"), - } - - -class CreateVPCResponseSchema(schema.ResponseSchema): - """ CreateVPC - 创建VPC - """ - - fields = {"VPCId": fields.Str(required=False, load_from="VPCId")} - - -""" -API: CreateVPCIntercom - -新建VPC互通关系 -""" - - -class CreateVPCIntercomRequestSchema(schema.RequestSchema): - """ CreateVPCIntercom - 新建VPC互通关系 - """ - - fields = { - "DstProjectId": fields.Str(required=False, dump_to="DstProjectId"), - "DstRegion": fields.Str(required=False, dump_to="DstRegion"), - "DstVPCId": fields.Str(required=True, dump_to="DstVPCId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "VPCId": fields.Str(required=True, dump_to="VPCId"), - } - - -class CreateVPCIntercomResponseSchema(schema.ResponseSchema): - """ CreateVPCIntercom - 新建VPC互通关系 - """ - - fields = {} - - -""" -API: DeleteRouteTable - -删除自定义路由表 -""" - - -class DeleteRouteTableRequestSchema(schema.RequestSchema): - """ DeleteRouteTable - 删除自定义路由表 - """ - - fields = { - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "RouteTableId": fields.Str(required=True, dump_to="RouteTableId"), - } - - -class DeleteRouteTableResponseSchema(schema.ResponseSchema): - """ DeleteRouteTable - 删除自定义路由表 - """ - - fields = {} - - -""" -API: DeleteSubnet - -删除子网 -""" - - -class DeleteSubnetRequestSchema(schema.RequestSchema): - """ DeleteSubnet - 删除子网 - """ - - fields = { - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "SubnetId": fields.Str(required=True, dump_to="SubnetId"), - } - - -class DeleteSubnetResponseSchema(schema.ResponseSchema): - """ DeleteSubnet - 删除子网 - """ - - fields = {} - - -""" -API: DeleteVPC - -删除VPC -""" - - -class DeleteVPCRequestSchema(schema.RequestSchema): - """ DeleteVPC - 删除VPC - """ - - fields = { - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "VPCId": fields.Str(required=True, dump_to="VPCId"), - } - - -class DeleteVPCResponseSchema(schema.ResponseSchema): - """ DeleteVPC - 删除VPC - """ - - fields = {} - - -""" -API: DeleteVPCIntercom - -删除VPC互通关系 -""" - - -class DeleteVPCIntercomRequestSchema(schema.RequestSchema): - """ DeleteVPCIntercom - 删除VPC互通关系 - """ - - fields = { - "DstProjectId": fields.Str(required=False, dump_to="DstProjectId"), - "DstRegion": fields.Str(required=False, dump_to="DstRegion"), - "DstVPCId": fields.Str(required=True, dump_to="DstVPCId"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "VPCId": fields.Str(required=True, dump_to="VPCId"), - } - - -class DeleteVPCIntercomResponseSchema(schema.ResponseSchema): - """ DeleteVPCIntercom - 删除VPC互通关系 - """ - - fields = {} - - -""" -API: DescribeRouteTable - -获取路由表详细信息(包括路由策略) -""" - - -class DescribeRouteTableRequestSchema(schema.RequestSchema): - """ DescribeRouteTable - 获取路由表详细信息(包括路由策略) - """ - - fields = { - "BusinessId": fields.Str(required=False, dump_to="BusinessId"), - "Limit": fields.Int(required=False, dump_to="Limit"), - "OffSet": fields.Int(required=False, dump_to="OffSet"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "RouteTableId": fields.Str(required=False, dump_to="RouteTableId"), - "VPCId": fields.Str(required=False, dump_to="VPCId"), - } - - -class DescribeRouteTableResponseSchema(schema.ResponseSchema): - """ DescribeRouteTable - 获取路由表详细信息(包括路由策略) - """ - - fields = { - "RouteTables": fields.List( - models.RouteTableInfoSchema(), required=False, load_from="RouteTables" - ), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - } - - -""" -API: DescribeSubnet - -获取子网信息 -""" - - -class DescribeSubnetRequestSchema(schema.RequestSchema): - """ DescribeSubnet - 获取子网信息 - """ - - fields = { - "BusinessId": fields.Str(required=False, dump_to="BusinessId"), - "Limit": fields.Int(required=False, dump_to="Limit"), - "Offset": fields.Int(required=False, dump_to="Offset"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "RouteTableId": fields.Str(required=False, dump_to="RouteTableId"), - "SubnetId": fields.Str(required=False, dump_to="SubnetId"), - "SubnetIds": fields.List(fields.Str()), - "Tag": fields.Str(required=False, dump_to="Tag"), - "VPCId": fields.Str(required=False, dump_to="VPCId"), - } - - -class DescribeSubnetResponseSchema(schema.ResponseSchema): - """ DescribeSubnet - 获取子网信息 - """ - - fields = { - "DataSet": fields.List( - models.SubnetInfoSchema(), required=True, load_from="DataSet" - ), - "TotalCount": fields.Int(required=True, load_from="TotalCount"), - } - - -""" -API: DescribeSubnetResource - -展示子网资源 -""" - - -class DescribeSubnetResourceRequestSchema(schema.RequestSchema): - """ DescribeSubnetResource - 展示子网资源 - """ - - fields = { - "Limit": fields.Int(required=False, dump_to="Limit"), - "Offset": fields.Int(required=False, dump_to="Offset"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "ResourceType": fields.Str(required=False, dump_to="ResourceType"), - "SubnetId": fields.Str(required=True, dump_to="SubnetId"), - } - - -class DescribeSubnetResourceResponseSchema(schema.ResponseSchema): - """ DescribeSubnetResource - 展示子网资源 - """ - - fields = { - "DataSet": fields.List( - models.SubnetResourceSchema(), required=False, load_from="DataSet" - ), - "TotalCount": fields.Int(required=False, load_from="TotalCount"), - } - - -""" -API: DescribeVPC - -获取VPC信息 -""" - - -class DescribeVPCRequestSchema(schema.RequestSchema): - """ DescribeVPC - 获取VPC信息 - """ - - fields = { - "Limit": fields.Int(required=False, dump_to="Limit"), - "Offset": fields.Int(required=False, dump_to="Offset"), - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Tag": fields.Str(required=False, dump_to="Tag"), - "VPCIds": fields.List(fields.Str()), - } - - -class DescribeVPCResponseSchema(schema.ResponseSchema): - """ DescribeVPC - 获取VPC信息 - """ - - fields = { - "DataSet": fields.List( - models.VPCInfoSchema(), required=False, load_from="DataSet" - ) - } - - -""" -API: DescribeVPCIntercom - -获取VPC互通信息 -""" - - -class DescribeVPCIntercomRequestSchema(schema.RequestSchema): - """ DescribeVPCIntercom - 获取VPC互通信息 - """ - - fields = { - "DstProjectId": fields.Str(required=False, dump_to="DstProjectId"), - "DstRegion": fields.Str(required=False, dump_to="DstRegion"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "VPCId": fields.Str(required=True, dump_to="VPCId"), - } - - -class DescribeVPCIntercomResponseSchema(schema.ResponseSchema): - """ DescribeVPCIntercom - 获取VPC互通信息 - """ - - fields = { - "DataSet": fields.List( - models.VPCIntercomInfoSchema(), required=False, load_from="DataSet" - ) - } - - -""" -API: ModifyRouteRule - -路由策略增、删、改 -""" - - -class ModifyRouteRuleRequestSchema(schema.RequestSchema): - """ ModifyRouteRule - 路由策略增、删、改 - """ - - fields = { - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "RouteRule": fields.List(fields.Str()), - "RouteTableId": fields.Str(required=True, dump_to="RouteTableId"), - } - - -class ModifyRouteRuleResponseSchema(schema.ResponseSchema): - """ ModifyRouteRule - 路由策略增、删、改 - """ - - fields = {} - - -""" -API: UpdateRouteTableAttribute - -更新路由表基本信息 -""" - - -class UpdateRouteTableAttributeRequestSchema(schema.RequestSchema): - """ UpdateRouteTableAttribute - 更新路由表基本信息 - """ - - fields = { - "Name": fields.Str(required=False, dump_to="Name"), - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "Remark": fields.Str(required=False, dump_to="Remark"), - "RouteTableId": fields.Str(required=True, dump_to="RouteTableId"), - "Tag": fields.Str(required=False, dump_to="Tag"), - } - - -class UpdateRouteTableAttributeResponseSchema(schema.ResponseSchema): - """ UpdateRouteTableAttribute - 更新路由表基本信息 - """ - - fields = {} - - -""" -API: UpdateSubnetAttribute - -更新子网信息 -""" - - -class UpdateSubnetAttributeRequestSchema(schema.RequestSchema): - """ UpdateSubnetAttribute - 更新子网信息 - """ - - fields = { - "Name": fields.Str(required=False, dump_to="Name"), - "ProjectId": fields.Str(required=False, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "SubnetId": fields.Str(required=True, dump_to="SubnetId"), - "Tag": fields.Str(required=False, dump_to="Tag"), - } - - -class UpdateSubnetAttributeResponseSchema(schema.ResponseSchema): - """ UpdateSubnetAttribute - 更新子网信息 - """ - - fields = {} - - -""" -API: UpdateVPCNetwork - -更新VPC网段 -""" - - -class UpdateVPCNetworkRequestSchema(schema.RequestSchema): - """ UpdateVPCNetwork - 更新VPC网段 - """ - - fields = { - "Network": fields.List(fields.Str()), - "ProjectId": fields.Str(required=True, dump_to="ProjectId"), - "Region": fields.Str(required=True, dump_to="Region"), - "VPCId": fields.Str(required=True, dump_to="VPCId"), - } - - -class UpdateVPCNetworkResponseSchema(schema.ResponseSchema): - """ UpdateVPCNetwork - 更新VPC网段 - """ - - fields = {"Message": fields.Str(required=True, load_from="Message")} +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.typesystem import schema, fields +from ucloud.services.vpc.schemas import models + +""" VPC API Schema +""" +""" +API: AddVPCNetwork + +添加VPC网段 +""" + + +class AddVPCNetworkRequestSchema(schema.RequestSchema): + """ AddVPCNetwork - 添加VPC网段 + """ + + fields = { + "Network": fields.List(fields.Str()), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "VPCId": fields.Str(required=True, dump_to="VPCId"), + } + + +class AddVPCNetworkResponseSchema(schema.ResponseSchema): + """ AddVPCNetwork - 添加VPC网段 + """ + + fields = {} + + +""" +API: AssociateRouteTable + +绑定子网的路由表 +""" + + +class AssociateRouteTableRequestSchema(schema.RequestSchema): + """ AssociateRouteTable - 绑定子网的路由表 + """ + + fields = { + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "RouteTableId": fields.Str(required=True, dump_to="RouteTableId"), + "SubnetId": fields.Str(required=True, dump_to="SubnetId"), + } + + +class AssociateRouteTableResponseSchema(schema.ResponseSchema): + """ AssociateRouteTable - 绑定子网的路由表 + """ + + fields = {} + + +""" +API: CloneRouteTable + +根据一张现有路由表复制一张新的路由表 +""" + + +class CloneRouteTableRequestSchema(schema.RequestSchema): + """ CloneRouteTable - 根据一张现有路由表复制一张新的路由表 + """ + + fields = { + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=False, dump_to="Region"), + "RouteTableId": fields.Str(required=True, dump_to="RouteTableId"), + } + + +class CloneRouteTableResponseSchema(schema.ResponseSchema): + """ CloneRouteTable - 根据一张现有路由表复制一张新的路由表 + """ + + fields = {} + + +""" +API: CreateRouteTable + +创建路由表 +""" + + +class CreateRouteTableRequestSchema(schema.RequestSchema): + """ CreateRouteTable - 创建路由表 + """ + + fields = { + "Name": fields.Str(required=False, dump_to="Name"), + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Remark": fields.Str(required=False, dump_to="Remark"), + "Tag": fields.Str(required=False, dump_to="Tag"), + "VPCId": fields.Str(required=True, dump_to="VPCId"), + } + + +class CreateRouteTableResponseSchema(schema.ResponseSchema): + """ CreateRouteTable - 创建路由表 + """ + + fields = { + "RouteTableId": fields.Str(required=False, load_from="RouteTableId") + } + + +""" +API: CreateSubnet + +创建子网 +""" + + +class CreateSubnetRequestSchema(schema.RequestSchema): + """ CreateSubnet - 创建子网 + """ + + fields = { + "Netmask": fields.Int(required=False, dump_to="Netmask"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Remark": fields.Str(required=False, dump_to="Remark"), + "Subnet": fields.Str(required=True, dump_to="Subnet"), + "SubnetName": fields.Str(required=False, dump_to="SubnetName"), + "Tag": fields.Str(required=False, dump_to="Tag"), + "VPCId": fields.Str(required=True, dump_to="VPCId"), + } + + +class CreateSubnetResponseSchema(schema.ResponseSchema): + """ CreateSubnet - 创建子网 + """ + + fields = {"SubnetId": fields.Str(required=False, load_from="SubnetId")} + + +""" +API: CreateVPC + +创建VPC +""" + + +class CreateVPCRequestSchema(schema.RequestSchema): + """ CreateVPC - 创建VPC + """ + + fields = { + "Name": fields.Str(required=True, dump_to="Name"), + "Network": fields.List(fields.Str()), + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Remark": fields.Str(required=False, dump_to="Remark"), + "Tag": fields.Str(required=False, dump_to="Tag"), + "Type": fields.Int(required=False, dump_to="Type"), + } + + +class CreateVPCResponseSchema(schema.ResponseSchema): + """ CreateVPC - 创建VPC + """ + + fields = {"VPCId": fields.Str(required=False, load_from="VPCId")} + + +""" +API: CreateVPCIntercom + +新建VPC互通关系 +""" + + +class CreateVPCIntercomRequestSchema(schema.RequestSchema): + """ CreateVPCIntercom - 新建VPC互通关系 + """ + + fields = { + "DstProjectId": fields.Str(required=False, dump_to="DstProjectId"), + "DstRegion": fields.Str(required=False, dump_to="DstRegion"), + "DstVPCId": fields.Str(required=True, dump_to="DstVPCId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "VPCId": fields.Str(required=True, dump_to="VPCId"), + } + + +class CreateVPCIntercomResponseSchema(schema.ResponseSchema): + """ CreateVPCIntercom - 新建VPC互通关系 + """ + + fields = {} + + +""" +API: DeleteRouteTable + +删除自定义路由表 +""" + + +class DeleteRouteTableRequestSchema(schema.RequestSchema): + """ DeleteRouteTable - 删除自定义路由表 + """ + + fields = { + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "RouteTableId": fields.Str(required=True, dump_to="RouteTableId"), + } + + +class DeleteRouteTableResponseSchema(schema.ResponseSchema): + """ DeleteRouteTable - 删除自定义路由表 + """ + + fields = {} + + +""" +API: DeleteSubnet + +删除子网 +""" + + +class DeleteSubnetRequestSchema(schema.RequestSchema): + """ DeleteSubnet - 删除子网 + """ + + fields = { + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "SubnetId": fields.Str(required=True, dump_to="SubnetId"), + } + + +class DeleteSubnetResponseSchema(schema.ResponseSchema): + """ DeleteSubnet - 删除子网 + """ + + fields = {} + + +""" +API: DeleteVPC + +删除VPC +""" + + +class DeleteVPCRequestSchema(schema.RequestSchema): + """ DeleteVPC - 删除VPC + """ + + fields = { + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "VPCId": fields.Str(required=True, dump_to="VPCId"), + } + + +class DeleteVPCResponseSchema(schema.ResponseSchema): + """ DeleteVPC - 删除VPC + """ + + fields = {} + + +""" +API: DeleteVPCIntercom + +删除VPC互通关系 +""" + + +class DeleteVPCIntercomRequestSchema(schema.RequestSchema): + """ DeleteVPCIntercom - 删除VPC互通关系 + """ + + fields = { + "DstProjectId": fields.Str(required=False, dump_to="DstProjectId"), + "DstRegion": fields.Str(required=False, dump_to="DstRegion"), + "DstVPCId": fields.Str(required=True, dump_to="DstVPCId"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "VPCId": fields.Str(required=True, dump_to="VPCId"), + } + + +class DeleteVPCIntercomResponseSchema(schema.ResponseSchema): + """ DeleteVPCIntercom - 删除VPC互通关系 + """ + + fields = {} + + +""" +API: DescribeRouteTable + +获取路由表详细信息(包括路由策略) +""" + + +class DescribeRouteTableRequestSchema(schema.RequestSchema): + """ DescribeRouteTable - 获取路由表详细信息(包括路由策略) + """ + + fields = { + "BusinessId": fields.Str(required=False, dump_to="BusinessId"), + "Limit": fields.Int(required=False, dump_to="Limit"), + "OffSet": fields.Int(required=False, dump_to="OffSet"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "RouteTableId": fields.Str(required=False, dump_to="RouteTableId"), + "VPCId": fields.Str(required=False, dump_to="VPCId"), + } + + +class DescribeRouteTableResponseSchema(schema.ResponseSchema): + """ DescribeRouteTable - 获取路由表详细信息(包括路由策略) + """ + + fields = { + "RouteTables": fields.List( + models.RouteTableInfoSchema(), + required=False, + load_from="RouteTables", + ), + "TotalCount": fields.Int(required=False, load_from="TotalCount"), + } + + +""" +API: DescribeSubnet + +获取子网信息 +""" + + +class DescribeSubnetRequestSchema(schema.RequestSchema): + """ DescribeSubnet - 获取子网信息 + """ + + fields = { + "BusinessId": fields.Str(required=False, dump_to="BusinessId"), + "Limit": fields.Int(required=False, dump_to="Limit"), + "Offset": fields.Int(required=False, dump_to="Offset"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "RouteTableId": fields.Str(required=False, dump_to="RouteTableId"), + "SubnetId": fields.Str(required=False, dump_to="SubnetId"), + "SubnetIds": fields.List(fields.Str()), + "Tag": fields.Str(required=False, dump_to="Tag"), + "VPCId": fields.Str(required=False, dump_to="VPCId"), + } + + +class DescribeSubnetResponseSchema(schema.ResponseSchema): + """ DescribeSubnet - 获取子网信息 + """ + + fields = { + "DataSet": fields.List( + models.SubnetInfoSchema(), required=True, load_from="DataSet" + ), + "TotalCount": fields.Int(required=True, load_from="TotalCount"), + } + + +""" +API: DescribeSubnetResource + +展示子网资源 +""" + + +class DescribeSubnetResourceRequestSchema(schema.RequestSchema): + """ DescribeSubnetResource - 展示子网资源 + """ + + fields = { + "Limit": fields.Int(required=False, dump_to="Limit"), + "Offset": fields.Int(required=False, dump_to="Offset"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "ResourceType": fields.Str(required=False, dump_to="ResourceType"), + "SubnetId": fields.Str(required=True, dump_to="SubnetId"), + } + + +class DescribeSubnetResourceResponseSchema(schema.ResponseSchema): + """ DescribeSubnetResource - 展示子网资源 + """ + + fields = { + "DataSet": fields.List( + models.SubnetResourceSchema(), required=False, load_from="DataSet" + ), + "TotalCount": fields.Int(required=False, load_from="TotalCount"), + } + + +""" +API: DescribeVPC + +获取VPC信息 +""" + + +class DescribeVPCRequestSchema(schema.RequestSchema): + """ DescribeVPC - 获取VPC信息 + """ + + fields = { + "Limit": fields.Int(required=False, dump_to="Limit"), + "Offset": fields.Int(required=False, dump_to="Offset"), + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Tag": fields.Str(required=False, dump_to="Tag"), + "VPCIds": fields.List(fields.Str()), + } + + +class DescribeVPCResponseSchema(schema.ResponseSchema): + """ DescribeVPC - 获取VPC信息 + """ + + fields = { + "DataSet": fields.List( + models.VPCInfoSchema(), required=False, load_from="DataSet" + ) + } + + +""" +API: DescribeVPCIntercom + +获取VPC互通信息 +""" + + +class DescribeVPCIntercomRequestSchema(schema.RequestSchema): + """ DescribeVPCIntercom - 获取VPC互通信息 + """ + + fields = { + "DstProjectId": fields.Str(required=False, dump_to="DstProjectId"), + "DstRegion": fields.Str(required=False, dump_to="DstRegion"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "VPCId": fields.Str(required=True, dump_to="VPCId"), + } + + +class DescribeVPCIntercomResponseSchema(schema.ResponseSchema): + """ DescribeVPCIntercom - 获取VPC互通信息 + """ + + fields = { + "DataSet": fields.List( + models.VPCIntercomInfoSchema(), required=False, load_from="DataSet" + ) + } + + +""" +API: ModifyRouteRule + +路由策略增、删、改 +""" + + +class ModifyRouteRuleRequestSchema(schema.RequestSchema): + """ ModifyRouteRule - 路由策略增、删、改 + """ + + fields = { + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "RouteRule": fields.List(fields.Str()), + "RouteTableId": fields.Str(required=True, dump_to="RouteTableId"), + } + + +class ModifyRouteRuleResponseSchema(schema.ResponseSchema): + """ ModifyRouteRule - 路由策略增、删、改 + """ + + fields = {} + + +""" +API: UpdateRouteTableAttribute + +更新路由表基本信息 +""" + + +class UpdateRouteTableAttributeRequestSchema(schema.RequestSchema): + """ UpdateRouteTableAttribute - 更新路由表基本信息 + """ + + fields = { + "Name": fields.Str(required=False, dump_to="Name"), + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "Remark": fields.Str(required=False, dump_to="Remark"), + "RouteTableId": fields.Str(required=True, dump_to="RouteTableId"), + "Tag": fields.Str(required=False, dump_to="Tag"), + } + + +class UpdateRouteTableAttributeResponseSchema(schema.ResponseSchema): + """ UpdateRouteTableAttribute - 更新路由表基本信息 + """ + + fields = {} + + +""" +API: UpdateSubnetAttribute + +更新子网信息 +""" + + +class UpdateSubnetAttributeRequestSchema(schema.RequestSchema): + """ UpdateSubnetAttribute - 更新子网信息 + """ + + fields = { + "Name": fields.Str(required=False, dump_to="Name"), + "ProjectId": fields.Str(required=False, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "SubnetId": fields.Str(required=True, dump_to="SubnetId"), + "Tag": fields.Str(required=False, dump_to="Tag"), + } + + +class UpdateSubnetAttributeResponseSchema(schema.ResponseSchema): + """ UpdateSubnetAttribute - 更新子网信息 + """ + + fields = {} + + +""" +API: UpdateVPCNetwork + +更新VPC网段 +""" + + +class UpdateVPCNetworkRequestSchema(schema.RequestSchema): + """ UpdateVPCNetwork - 更新VPC网段 + """ + + fields = { + "Network": fields.List(fields.Str()), + "ProjectId": fields.Str(required=True, dump_to="ProjectId"), + "Region": fields.Str(required=True, dump_to="Region"), + "VPCId": fields.Str(required=True, dump_to="VPCId"), + } + + +class UpdateVPCNetworkResponseSchema(schema.ResponseSchema): + """ UpdateVPCNetwork - 更新VPC网段 + """ + + fields = {"Message": fields.Str(required=True, load_from="Message")} diff --git a/ucloud/services/vpc/schemas/models.py b/ucloud/services/vpc/schemas/models.py index 25a0218..97a8b97 100644 --- a/ucloud/services/vpc/schemas/models.py +++ b/ucloud/services/vpc/schemas/models.py @@ -1,117 +1,123 @@ -# -*- coding: utf-8 -*- - -""" Code is generated by ucloud-model, DO NOT EDIT IT. """ -from ucloud.core.typesystem import schema, fields - - -class RouteRuleInfoSchema(schema.ResponseSchema): - """ RouteRuleInfo - 路由规则信息 - """ - - fields = { - "DstAddr": fields.Str(required=False, load_from="DstAddr"), - "NexthopId": fields.Str(required=False, load_from="NexthopId"), - "NexthopType": fields.Str(required=False, load_from="NexthopType"), - "Remark": fields.Str(required=False, load_from="Remark"), - "RouteRuleId": fields.Str(required=False, load_from="RouteRuleId"), - "RuleType": fields.Int(required=False, load_from="RuleType"), - } - - -class RouteTableInfoSchema(schema.ResponseSchema): - """ RouteTableInfo - 路由表信息 - """ - - fields = { - "CreateTime": fields.Int(required=False, load_from="CreateTime"), - "Remark": fields.Str(required=False, load_from="Remark"), - "RouteRules": fields.List(RouteRuleInfoSchema()), - "RouteTableId": fields.Str(required=False, load_from="RouteTableId"), - "RouteTableType": fields.Int(required=False, load_from="RouteTableType"), - "SubnetCount": fields.Str(required=False, load_from="SubnetCount"), - "Tag": fields.Str(required=False, load_from="Tag"), - "VPCId": fields.Str(required=False, load_from="VPCId"), - "VPCName": fields.Str(required=False, load_from="VPCName"), - } - - -class SubnetInfoSchema(schema.ResponseSchema): - """ SubnetInfo - 子网信息 - """ - - fields = { - "CreateTime": fields.Int(required=False, load_from="CreateTime"), - "Gateway": fields.Str(required=False, load_from="Gateway"), - "HasNATGW": fields.Bool(required=False, load_from="HasNATGW"), - "IPv6Network": fields.Str(required=False, load_from="IPv6Network"), - "Netmask": fields.Int(required=False, load_from="Netmask"), - "OperatorName": fields.Str(required=False, load_from="OperatorName"), - "Remark": fields.Str(required=False, load_from="Remark"), - "RouteTableId": fields.Str(required=False, load_from="RouteTableId"), - "Subnet": fields.Str(required=False, load_from="Subnet"), - "SubnetId": fields.Str(required=False, load_from="SubnetId"), - "SubnetName": fields.Str(required=False, load_from="SubnetName"), - "SubnetType": fields.Int(required=False, load_from="SubnetType"), - "Tag": fields.Str(required=False, load_from="Tag"), - "VPCId": fields.Str(required=False, load_from="VPCId"), - "VPCName": fields.Str(required=False, load_from="VPCName"), - "Zone": fields.Str(required=False, load_from="Zone"), - } - - -class SubnetResourceSchema(schema.ResponseSchema): - """ SubnetResource - 子网下资源 - """ - - fields = { - "IP": fields.Str(required=False, load_from="IP"), - "IPv6Address": fields.Str(required=False, load_from="IPv6Address"), - "Name": fields.Str(required=False, load_from="Name"), - "ResourceId": fields.Str(required=False, load_from="ResourceId"), - "ResourceType": fields.Str(required=False, load_from="ResourceType"), - "SubResourceId": fields.Str(required=False, load_from="SubResourceId"), - "SubResourceName": fields.Str(required=False, load_from="SubResourceName"), - "SubResourceType": fields.Str(required=False, load_from="SubResourceType"), - } - - -class VPCNetworkInfoSchema(schema.ResponseSchema): - """ VPCNetworkInfo - vpc地址空间信息 - """ - - fields = { - "Network": fields.Str(required=False, load_from="Network"), - "SubnetCount": fields.Int(required=False, load_from="SubnetCount"), - } - - -class VPCInfoSchema(schema.ResponseSchema): - """ VPCInfo - VPC信息 - """ - - fields = { - "CreateTime": fields.Int(required=True, load_from="CreateTime"), - "IPv6Network": fields.Str(required=False, load_from="IPv6Network"), - "Name": fields.Str(required=True, load_from="Name"), - "Network": fields.List(fields.Str()), - "NetworkInfo": fields.List(VPCNetworkInfoSchema()), - "OperatorName": fields.Str(required=False, load_from="OperatorName"), - "SubnetCount": fields.Int(required=True, load_from="SubnetCount"), - "Tag": fields.Str(required=True, load_from="Tag"), - "UpdateTime": fields.Int(required=True, load_from="UpdateTime"), - "VPCId": fields.Str(required=False, load_from="VPCId"), - } - - -class VPCIntercomInfoSchema(schema.ResponseSchema): - """ VPCIntercomInfo - - """ - - fields = { - "DstRegion": fields.Str(required=False, load_from="DstRegion"), - "Name": fields.Str(required=False, load_from="Name"), - "Network": fields.List(fields.Str()), - "ProjectId": fields.Str(required=False, load_from="ProjectId"), - "Tag": fields.Str(required=False, load_from="Tag"), - "VPCId": fields.Str(required=False, load_from="VPCId"), - } +# -*- coding: utf-8 -*- + +""" Code is generated by ucloud-model, DO NOT EDIT IT. """ +from ucloud.core.typesystem import schema, fields + + +class RouteRuleInfoSchema(schema.ResponseSchema): + """ RouteRuleInfo - 路由规则信息 + """ + + fields = { + "DstAddr": fields.Str(required=False, load_from="DstAddr"), + "NexthopId": fields.Str(required=False, load_from="NexthopId"), + "NexthopType": fields.Str(required=False, load_from="NexthopType"), + "Remark": fields.Str(required=False, load_from="Remark"), + "RouteRuleId": fields.Str(required=False, load_from="RouteRuleId"), + "RuleType": fields.Int(required=False, load_from="RuleType"), + } + + +class RouteTableInfoSchema(schema.ResponseSchema): + """ RouteTableInfo - 路由表信息 + """ + + fields = { + "CreateTime": fields.Int(required=False, load_from="CreateTime"), + "Remark": fields.Str(required=False, load_from="Remark"), + "RouteRules": fields.List(RouteRuleInfoSchema()), + "RouteTableId": fields.Str(required=False, load_from="RouteTableId"), + "RouteTableType": fields.Int( + required=False, load_from="RouteTableType" + ), + "SubnetCount": fields.Str(required=False, load_from="SubnetCount"), + "Tag": fields.Str(required=False, load_from="Tag"), + "VPCId": fields.Str(required=False, load_from="VPCId"), + "VPCName": fields.Str(required=False, load_from="VPCName"), + } + + +class SubnetInfoSchema(schema.ResponseSchema): + """ SubnetInfo - 子网信息 + """ + + fields = { + "CreateTime": fields.Int(required=False, load_from="CreateTime"), + "Gateway": fields.Str(required=False, load_from="Gateway"), + "HasNATGW": fields.Bool(required=False, load_from="HasNATGW"), + "IPv6Network": fields.Str(required=False, load_from="IPv6Network"), + "Netmask": fields.Int(required=False, load_from="Netmask"), + "OperatorName": fields.Str(required=False, load_from="OperatorName"), + "Remark": fields.Str(required=False, load_from="Remark"), + "RouteTableId": fields.Str(required=False, load_from="RouteTableId"), + "Subnet": fields.Str(required=False, load_from="Subnet"), + "SubnetId": fields.Str(required=False, load_from="SubnetId"), + "SubnetName": fields.Str(required=False, load_from="SubnetName"), + "SubnetType": fields.Int(required=False, load_from="SubnetType"), + "Tag": fields.Str(required=False, load_from="Tag"), + "VPCId": fields.Str(required=False, load_from="VPCId"), + "VPCName": fields.Str(required=False, load_from="VPCName"), + "Zone": fields.Str(required=False, load_from="Zone"), + } + + +class SubnetResourceSchema(schema.ResponseSchema): + """ SubnetResource - 子网下资源 + """ + + fields = { + "IP": fields.Str(required=False, load_from="IP"), + "IPv6Address": fields.Str(required=False, load_from="IPv6Address"), + "Name": fields.Str(required=False, load_from="Name"), + "ResourceId": fields.Str(required=False, load_from="ResourceId"), + "ResourceType": fields.Str(required=False, load_from="ResourceType"), + "SubResourceId": fields.Str(required=False, load_from="SubResourceId"), + "SubResourceName": fields.Str( + required=False, load_from="SubResourceName" + ), + "SubResourceType": fields.Str( + required=False, load_from="SubResourceType" + ), + } + + +class VPCNetworkInfoSchema(schema.ResponseSchema): + """ VPCNetworkInfo - vpc地址空间信息 + """ + + fields = { + "Network": fields.Str(required=False, load_from="Network"), + "SubnetCount": fields.Int(required=False, load_from="SubnetCount"), + } + + +class VPCInfoSchema(schema.ResponseSchema): + """ VPCInfo - VPC信息 + """ + + fields = { + "CreateTime": fields.Int(required=True, load_from="CreateTime"), + "IPv6Network": fields.Str(required=False, load_from="IPv6Network"), + "Name": fields.Str(required=True, load_from="Name"), + "Network": fields.List(fields.Str()), + "NetworkInfo": fields.List(VPCNetworkInfoSchema()), + "OperatorName": fields.Str(required=False, load_from="OperatorName"), + "SubnetCount": fields.Int(required=True, load_from="SubnetCount"), + "Tag": fields.Str(required=True, load_from="Tag"), + "UpdateTime": fields.Int(required=True, load_from="UpdateTime"), + "VPCId": fields.Str(required=False, load_from="VPCId"), + } + + +class VPCIntercomInfoSchema(schema.ResponseSchema): + """ VPCIntercomInfo - + """ + + fields = { + "DstRegion": fields.Str(required=False, load_from="DstRegion"), + "Name": fields.Str(required=False, load_from="Name"), + "Network": fields.List(fields.Str()), + "ProjectId": fields.Str(required=False, load_from="ProjectId"), + "Tag": fields.Str(required=False, load_from="Tag"), + "VPCId": fields.Str(required=False, load_from="VPCId"), + } diff --git a/ucloud/testing/__init__.py b/ucloud/testing/__init__.py index 4c48b5a..40a96af 100644 --- a/ucloud/testing/__init__.py +++ b/ucloud/testing/__init__.py @@ -1 +1 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- diff --git a/ucloud/testing/env.py b/ucloud/testing/env.py index 8fa4c43..a41ee14 100644 --- a/ucloud/testing/env.py +++ b/ucloud/testing/env.py @@ -1,30 +1,30 @@ -# -*- coding: utf-8 -*- - -import os - -ACC_ENV_KEY = "USDKACC" -ACC_SKIP_REASON = "skip test for non-acc environment" - - -def get_skip_reason(): - return ACC_SKIP_REASON - - -def is_acc(): - """ check test env is acceptance testing or not """ - return os.getenv(ACC_ENV_KEY) - - -def is_ut(): - """ check test env is unit testing or not """ - return not is_acc() - - -def pre_check_env(): - """ pre check environment for testing - - NOTE: system environment variables credential is required for test environment - """ - assert os.getenv("UCLOUD_PUBLIC_KEY"), "invalid public key" - assert os.getenv("UCLOUD_PRIVATE_KEY"), "invalid private key" - assert os.getenv("UCLOUD_REGION"), "invalid region" +# -*- coding: utf-8 -*- + +import os + +ACC_ENV_KEY = "USDKACC" +ACC_SKIP_REASON = "skip test for non-acc environment" + + +def get_skip_reason(): + return ACC_SKIP_REASON + + +def is_acc(): + """ check test env is acceptance testing or not """ + return os.getenv(ACC_ENV_KEY) + + +def is_ut(): + """ check test env is unit testing or not """ + return not is_acc() + + +def pre_check_env(): + """ pre check environment for testing + + NOTE: system environment variables credential is required for test environment + """ + assert os.getenv("UCLOUD_PUBLIC_KEY"), "invalid public key" + assert os.getenv("UCLOUD_PRIVATE_KEY"), "invalid private key" + assert os.getenv("UCLOUD_PROJECT_ID"), "invalid region" diff --git a/ucloud/testing/exc.py b/ucloud/testing/exc.py new file mode 100644 index 0000000..c850fd6 --- /dev/null +++ b/ucloud/testing/exc.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- + + +class UTestError(Exception): + pass + + +class ValidateError(UTestError): + def __init__(self, errors): + self.errors = errors + + def __str__(self): + return str(self.errors) + + +class ValueNotFoundError(UTestError): + pass + + +class CompareError(UTestError): + pass diff --git a/ucloud/testing/funcs.py b/ucloud/testing/funcs.py index 3261236..613a3b1 100644 --- a/ucloud/testing/funcs.py +++ b/ucloud/testing/funcs.py @@ -1,69 +1,69 @@ -# -*- coding: utf-8 -*- - -import datetime -import time - - -def concat(*args): - """ cancat strings - - >>> concat(42, 'foo', 'bar') - '42foobar' - """ - return "".join([str(s) for s in args]) - - -def concat_without_dot(args): - """ replace blank - - >>> concat_without_dot('42foo bar') - '42foobar' - """ - return "".join([str(s) for s in args.split()]) - - -def search_value(array, origin_key, origin_value, dest_key): - """ given origin key and value,search dest_value form array by dest_key - - >>> d = [{"UHostId": "foo", "Name": "testing"}] - >>> search_value(d, "Name", "testing", "UHostId") - 'foo' - """ - arr = [i.get(dest_key, "") for i in array if i[origin_key] == origin_value] - if arr: - return arr[0] - return "" - - -def timedelta(timestamp, value, typ="days"): - """ given timestamp(10bit) and calculate relative delta time - - >>> timedelta(0, 1, "days") - 86400.0 - - :param timestamp: timestamp (round to second) - :param value: float, can as positive or negative - :param typ: days/hours - :return: timestamp - """ - value = int(value) - dt = datetime.datetime.fromtimestamp(float(timestamp)) - if typ == "days": - dt += datetime.timedelta(days=value) - elif typ == "hours": - dt += datetime.timedelta(hours=value) - return time.mktime(dt.timetuple()) - - -def get_timestamp(length=13): - """ get current timestamp string - - >>> len(str(int(get_timestamp(10)))) - 10 - - :param length: length of timestamp, can only between 0 and 16 - :return: - """ - if isinstance(length, int) and 0 < length < 17: - return float("{:.6f}".format(time.time()).replace(".", "")[:length]) - raise ValueError("timestamp length can only between 0 and 16.") +# -*- coding: utf-8 -*- + +import datetime +import time + + +def concat(*args): + """ cancat strings + + >>> concat(42, 'foo', 'bar') + '42foobar' + """ + return "".join([str(s) for s in args]) + + +def concat_without_dot(args): + """ replace blank + + >>> concat_without_dot('42foo bar') + '42foobar' + """ + return "".join([str(s) for s in args.split()]) + + +def search_value(array, origin_key, origin_value, dest_key): + """ given origin key and value,search dest_value form array by dest_key + + >>> d = [{"UHostId": "foo", "Name": "testing"}] + >>> search_value(d, "Name", "testing", "UHostId") + 'foo' + """ + arr = [i.get(dest_key, "") for i in array if i[origin_key] == origin_value] + if arr: + return arr[0] + return "" + + +def timedelta(timestamp, value, typ="days"): + """ given timestamp(10bit) and calculate relative delta time + + >>> timedelta(0, 1, "days") + 86400.0 + + :param timestamp: timestamp (round to second) + :param value: float, can as positive or negative + :param typ: days/hours + :return: timestamp + """ + value = int(value) + dt = datetime.datetime.fromtimestamp(float(timestamp)) + if typ == "days": + dt += datetime.timedelta(days=value) + elif typ == "hours": + dt += datetime.timedelta(hours=value) + return time.mktime(dt.timetuple()) + + +def get_timestamp(length=13): + """ get current timestamp string + + >>> len(str(int(get_timestamp(10)))) + 10 + + :param length: length of timestamp, can only between 0 and 16 + :return: + """ + if isinstance(length, int) and 0 < length < 17: + return float("{:.6f}".format(time.time()).replace(".", "")[:length]) + raise ValueError("timestamp length can only between 0 and 16.") diff --git a/ucloud/testing/mock.py b/ucloud/testing/mock.py new file mode 100644 index 0000000..e99df25 --- /dev/null +++ b/ucloud/testing/mock.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +import json +from ucloud.core.transport import Transport, Request, Response + + +class MockedTransport(Transport): + def __init__(self): + super(MockedTransport, self).__init__() + self.transport_handlers = [] + self.client_handler = [] + + def send(self, req, **options): + resp = Response(req.url, req.method) + for handler in self.transport_handlers: + resp = handler(req) + for handler in self.client_handler: + payload = handler(req.payload()) + resp.content = json.dumps(payload).encode("utf-8") + return resp + + def mock(self, handler): + self.transport_handlers.append(handler) + + def mock_data(self, handler): + self.client_handler.append(handler) diff --git a/ucloud/testing/op.py b/ucloud/testing/op.py index 681a9d0..000beb5 100644 --- a/ucloud/testing/op.py +++ b/ucloud/testing/op.py @@ -1,198 +1,193 @@ -# -*- coding: utf-8 -*- - -import re - - -def eq(value, expected): - """ value is equal to expected - """ - assert value == expected - - -def ne(value, expected): - """ value is equal to expected - """ - assert value != expected - - -def gt(value, expected): - """ value is greater than expected - """ - assert value > expected - - -def ge(value, expected): - """ value is greater than or equal to expected - """ - assert value >= expected - - -def abs_eq(value, expected): - """ value is approx equal to expected - """ - assert round(float(value), 2) == round(float(expected), 2) - - -def lt(value, expected): - """ value is less than excepted - """ - assert value < expected - - -def le(value, expected): - """ value is less than or equal to excepted - """ - assert value <= expected - - -def str_eq(value, expected): - """ value is equal to excepted as string - """ - assert str(value) == str(expected) - - -def float_eq(value, expected): - """ value is equal to excepted as float - """ - assert round(float(value), 2) == round(float(expected), 2) - - -def len_eq(value, expected): - """ length of value is equal to excepted - """ - assert isinstance(expected, int) - assert len(value) == expected - - -def len_gt(value, expected): - """ length of value is greater than excepted - """ - assert isinstance(expected, int) - assert len(value) > expected - - -def len_ge(value, expected): - """ length of value is greater than or equal to excepted - """ - assert isinstance(expected, int) - assert len(value) >= expected - - -def len_lt(value, expected): - """ length of value is less than excepted - """ - assert isinstance(expected, int) - assert len(value) < expected - - -def len_le(value, expected): - """ length of value is less than or equal to excepted - """ - assert isinstance(expected, int) - assert len(value) <= expected - - -def contains(value, expected): - """ value is contains expected - """ - assert isinstance(value, list) - assert expected in value - - -def contained_by(value, expected): - """ value is contained by expected - """ - assert isinstance(expected, list) - assert value in expected - - -def type_eq(value, expected): - assert isinstance(value, expected) - - -def regex(value, expected): - assert isinstance(expected, str) - assert isinstance(value, str) - assert re.match(expected, value) - - -def startswith(value, expected): - assert str(value).startswith(expected) - - -def endswith(value, expected): - assert str(value).endswith(expected) - - -def object_contains(value, expected): - assert str(expected) in str(value) - - -def object_not_contains(value, expected): - assert str(expected) not in str(value) - - -mapper = { - "eq": eq, - "equals": eq, - "==": eq, - "abs_eq": abs_eq, - "abs_equals": abs_eq, - "lt": lt, - "less_than": lt, - "le": le, - "less_than_or_equals": le, - "gt": gt, - "greater_than": gt, - "ge": ge, - "greater_than_or_equals": ge, - "ne": ne, - "not_equals": ne, - "str_eq": str_eq, - "string_equals": str_eq, - "float_eq": float_eq, - "float_equals": float_eq, - "len_eq": len_eq, - "length_equals": len_eq, - "count_eq": len_eq, - "len_gt": len_gt, - "count_gt": len_gt, - "length_greater_than": len_gt, - "count_greater_than": len_gt, - "len_ge": len_ge, - "count_ge": len_ge, - "length_greater_than_or_equals": len_ge, - "count_greater_than_or_equals": len_ge, - "len_lt": len_lt, - "count_lt": len_lt, - "length_less_than": len_lt, - "count_less_than": len_lt, - "len_le": len_le, - "count_le": len_le, - "length_less_than_or_equals": len_le, - "count_less_than_or_equals": len_le, - "contains": contains, - "contained_by": contained_by, - "type": type_eq, - "regex": regex, - "startswith": startswith, - "endswith": endswith, - "object_contains": object_contains, - "object_not_contains": object_not_contains, -} - - -class CompareError(Exception): - pass - - -def check(name, value, expected): - if name not in mapper: - raise CompareError("comparator {} is not found".format(name)) - try: - return mapper.get(name)(value, expected) - except AssertionError as e: - msg = "assert error, expect {} {} {}, got error {}".format( - value, name, expected, e - ) - raise CompareError(msg) +# -*- coding: utf-8 -*- + +import re +from ucloud.testing.exc import CompareError + + +def eq(value, expected): + """ value is equal to expected + """ + assert value == expected + + +def ne(value, expected): + """ value is equal to expected + """ + assert value != expected + + +def gt(value, expected): + """ value is greater than expected + """ + assert float(value) > float(expected) + + +def ge(value, expected): + """ value is greater than or equal to expected + """ + assert float(value) >= float(expected) + + +def abs_eq(value, expected): + """ value is approx equal to expected + """ + assert round(float(value), 2) == round(float(expected), 2) + + +def lt(value, expected): + """ value is less than excepted + """ + assert float(value) < float(expected) + + +def le(value, expected): + """ value is less than or equal to excepted + """ + assert float(value) <= float(expected) + + +def str_eq(value, expected): + """ value is equal to excepted as string + """ + assert str(value) == str(expected) + + +def float_eq(value, expected): + """ value is equal to excepted as float + """ + assert round(float(value), 2) == round(float(expected), 2) + + +def len_eq(value, expected): + """ length of value is equal to excepted + """ + assert isinstance(expected, int) + assert len(value) == expected + + +def len_gt(value, expected): + """ length of value is greater than excepted + """ + assert isinstance(expected, int) + assert len(value) > expected + + +def len_ge(value, expected): + """ length of value is greater than or equal to excepted + """ + assert isinstance(expected, int) + assert len(value) >= expected + + +def len_lt(value, expected): + """ length of value is less than excepted + """ + assert isinstance(expected, int) + assert len(value) < expected + + +def len_le(value, expected): + """ length of value is less than or equal to excepted + """ + assert isinstance(expected, int) + assert len(value) <= expected + + +def contains(value, expected): + """ value is contains expected + """ + assert expected in value + + +def contained_by(value, expected): + """ value is contained by expected + """ + assert value in expected + + +def type_eq(value, expected): + assert isinstance(value, expected) + + +def regex(value, expected): + assert isinstance(expected, str) + assert isinstance(value, str) + assert re.match(expected, value) + + +def startswith(value, expected): + assert str(value).startswith(expected) + + +def endswith(value, expected): + assert str(value).endswith(expected) + + +def object_contains(value, expected): + assert str(expected) in str(value) + + +def object_not_contains(value, expected): + assert str(expected) not in str(value) + + +mapper = { + "eq": eq, + "equals": eq, + "==": eq, + "abs_eq": abs_eq, + "abs_equals": abs_eq, + "lt": lt, + "less_than": lt, + "le": le, + "less_than_or_equals": le, + "gt": gt, + "greater_than": gt, + "ge": ge, + "greater_than_or_equals": ge, + "ne": ne, + "not_equals": ne, + "str_eq": str_eq, + "string_equals": str_eq, + "float_eq": float_eq, + "float_equals": float_eq, + "len_eq": len_eq, + "length_equals": len_eq, + "count_eq": len_eq, + "len_gt": len_gt, + "count_gt": len_gt, + "length_greater_than": len_gt, + "count_greater_than": len_gt, + "len_ge": len_ge, + "count_ge": len_ge, + "length_greater_than_or_equals": len_ge, + "count_greater_than_or_equals": len_ge, + "len_lt": len_lt, + "count_lt": len_lt, + "length_less_than": len_lt, + "count_less_than": len_lt, + "len_le": len_le, + "count_le": len_le, + "length_less_than_or_equals": len_le, + "count_less_than_or_equals": len_le, + "contains": contains, + "contained_by": contained_by, + "type": type_eq, + "regex": regex, + "startswith": startswith, + "endswith": endswith, + "object_contains": object_contains, + "object_not_contains": object_not_contains, +} + + +def check(name, value, expected): + if name not in mapper: + raise CompareError("comparator {} is not found".format(name)) + try: + return mapper.get(name)(value, expected) + except AssertionError as e: + msg = "assert error, expect {} {} {}, got error {}".format( + value, name, expected, e + ) + raise CompareError(msg) diff --git a/ucloud/testing/utest.py b/ucloud/testing/utest.py index c5323f8..d9ca1b0 100644 --- a/ucloud/testing/utest.py +++ b/ucloud/testing/utest.py @@ -1,104 +1,177 @@ -# -*- coding: utf-8 -*- - -import functools -import logging -import time -from ucloud.testing import op - -logger = logging.getLogger(__name__) - - -class ValueNotFoundError(Exception): - pass - - -def case( - max_retries=0, - retry_interval=0, - retry_for=(op.CompareError, ValueNotFoundError), - startup_delay=0, - fast_fail=False, -): - """ wrap a function as a test case - - :param max_retries: the maximum retry number by the `retry_for` exception, - it will resolve the flaky testing case - :param retry_interval: the interval between twice retrying - :param retry_for: the exceptions to retrying - :param startup_delay: the delay seconds before any action execution - :param fast_fail: if fast fail is true, the test will fail when got - unexpected exception - :return: - """ - - def deco(fn): - @functools.wraps(fn) - def wrapper(*args, **kwargs): - if startup_delay: - time.sleep(startup_delay) - for i in range(max_retries + 1): - try: - result = fn(*args, **kwargs) - except Exception as e: - if isinstance(e, retry_for) and i != max_retries: - if retry_interval: - time.sleep(retry_interval) - continue - if fast_fail: - raise e - else: - logger.exception(e) - return - else: - return result - - return wrapper - - return deco - - -def validate(resp, validators): - """ validate dict by 3-tuple (comparator, value, expected) - """ - for validator in validators: - op.check(validator[0], value_at_path(resp, validator[1]), validator[2]) - - -def value_at_path(d, path): - """ access value by object path - - >>> d = {"Data": [{"UHostId": "foo"}, {"UHostId": "bar"}]} - >>> value_at_path(d, "Data.1.UHostId") - 'bar' - - :param d: dict or list of dict - :param path: object path like `Data.1.UHostId` - :return: any value access by path - """ - if d is None: - return - indices = path.split(".") - result = d - for i, key in enumerate(indices): - if isinstance(result, list): - if not key.isdigit(): - return - if len(result) <= int(key): - msg = "{} not found".format(".".join(indices[:i])) - raise ValueNotFoundError(msg) - result = result[int(key)] - continue - if isinstance(result, dict): - result = result.get(key) - if result is None: - msg = "{} not found".format(".".join(indices[:i])) - raise ValueNotFoundError(msg) - continue - return result - - -def set_default_response(d, action): - d = d.copy() - d.setdefault("RetCode", 0) - d.setdefault("Action", "{}Response".format(action)) - return d +# -*- coding: utf-8 -*- + +import logging +import time +from ucloud.client import Client +from ucloud.testing import op +from ucloud.testing.exc import ValueNotFoundError, CompareError, ValidateError + +logger = logging.getLogger(__name__) + + +class Step(object): + def __init__( + self, + invoker, + max_retries=0, + retry_interval=0, + startup_delay=0, + retry_for=(CompareError, ValueNotFoundError), + fast_fail=False, + validators=None, + **kwargs + ): + """ Step is the test step in a test scenario + :param invoker: invoker is a callable function + :param max_retries: the maximum retry number by the `retry_for` exception, + it will resolve the flaky testing case + :param retry_interval: the interval between twice retrying + :param retry_for: the exceptions to retrying + :param startup_delay: the delay seconds before any action execution + :param fast_fail: if fast fail is true, the test will fail when got + unexpected exception + :return: + """ + self.invoker = invoker + self.max_retries = max_retries + self.retry_interval = retry_interval + self.startup_delay = startup_delay + self.retry_for = retry_for + self.fast_fail = fast_fail + self.validators = validators or (lambda _: []) + self.extras = kwargs + + def run(self, client, variables): + if self.startup_delay: + time.sleep(self.startup_delay) + for i in range(self.max_retries + 1): + try: + result = self.invoker(client, variables) + except self.retry_for as e: + if i == self.max_retries: + raise e + if self.retry_interval: + time.sleep(self.retry_interval) + continue + else: + result = self.set_default_response(result) + errors = [] + for validator in self.validators(variables): + try: + op.check( + validator[0], + value_at_path(result, validator[1]), + validator[2], + ) + except self.retry_for as e: + errors.append(e) + if errors: + if i == self.max_retries: + raise ValidateError(errors) + if self.retry_interval: + time.sleep(self.retry_interval) + continue + return result + + def set_default_response(self, resp): + resp = resp.copy() + resp.setdefault("RetCode", 0) + if "action" in self.extras: + resp["Action"] = "{}Response".format(self.extras["action"]) + return resp + + +class Scenario(object): + def __init__(self, id_): + self.id = id_ + self.variables = {} + self.errors = [] + self.steps = [] + + def summary(self): + logger.info("=" * 42) + logger.info("TEST SET {}".format(self.id)) + logger.info("=" * 42) + if self.errors: + logger.info("-" * 42) + logger.info("ERRORS") + logger.info("-" * 42) + for err in self.errors: + logger.error(err) + logger.info("Errors!") + else: + logger.info("Success!") + + def step( + self, + max_retries=0, + retry_interval=0, + startup_delay=0, + retry_for=(CompareError, ValueNotFoundError), + fast_fail=False, + validators=None, + **kwargs + ): + def deco(fn): + step = Step( + invoker=fn, + max_retries=max_retries, + retry_interval=retry_interval, + startup_delay=startup_delay, + retry_for=retry_for, + fast_fail=fast_fail, + validators=validators, + **kwargs + ) + self.steps.append(step) + return fn + + return deco + + def run(self, client): + for i, step in enumerate(self.steps): + try: + action = step.extras.get("action", "unknown") + client.logger.info( + "running {} step {} {}".format(self.id, i + 1, action) + ) + step.run(client, self.variables) + except CompareError as e: + self.errors.append(e) + if step.fast_fail: + self.summary() + raise e + client.logger.error(e) + self.summary() + + def initial(self, variables=None): + self.variables = variables + + +def value_at_path(d, path): + """ access value by object path + + :param d: dict or list of dict + :param path: object path like `Data.1.UHostId` + :return: any value access by path + """ + if d is None: + return + indices = path.split(".") + result = d + for i, key in enumerate(indices): + if isinstance(result, list): + if not key.isdigit(): + return + if len(result) <= int(key): + msg = "{} not found".format(".".join(indices[: i + 1])) + raise ValueNotFoundError(msg) + result = result[int(key)] + continue + if isinstance(result, dict): + result = {k.lower(): v for k, v in result.items()}.get(key.lower()) + if result is None: + msg = "{} not found".format(".".join(indices[: i + 1])) + raise ValueNotFoundError(msg) + continue + return result diff --git a/ucloud/version.py b/ucloud/version.py index e9a17d9..fab8312 100644 --- a/ucloud/version.py +++ b/ucloud/version.py @@ -1,3 +1,3 @@ -# -*- coding: utf-8 -*- - -version = "0.3.0" +# -*- coding: utf-8 -*- + +version = "0.4.0"