huaweicloud-sdk-python-v3/huaweicloud-sdk-css/huaweicloudsdkcss/v2/css_client.py

354 lines
12 KiB
Python
Raw Normal View History

2022-02-10 11:09:33 +00:00
# coding: utf-8
from __future__ import absolute_import
import importlib
from huaweicloudsdkcore.client import Client, ClientBuilder
from huaweicloudsdkcore.utils import http_utils
from huaweicloudsdkcore.sdk_stream_request import SdkStreamRequest
class CssClient(Client):
def __init__(self):
super(CssClient, self).__init__()
self.model_package = importlib.import_module("huaweicloudsdkcss.v2.model")
@classmethod
def new_builder(cls, clazz=None):
2023-10-19 08:19:16 +00:00
if not clazz:
client_builder = ClientBuilder(cls)
else:
if clazz.__name__ != "CssClient":
raise TypeError("client type error, support client type is CssClient")
client_builder = ClientBuilder(clazz)
2022-02-10 11:09:33 +00:00
2023-10-19 08:19:16 +00:00
2022-02-10 11:09:33 +00:00
2023-10-19 08:19:16 +00:00
return client_builder
2022-02-10 11:09:33 +00:00
def create_cluster(self, request):
"""创建集群V2
2022-06-23 11:11:56 +00:00
该接口用于创建拥有多种不同节点类型essess-coldess-clientess-master组合的集群
2022-04-21 12:03:46 +00:00
2022-11-30 08:59:35 +00:00
Please refer to HUAWEI cloud API Explorer for details.
2022-02-10 11:09:33 +00:00
2022-04-21 12:03:46 +00:00
:param request: Request instance for CreateCluster
:type request: :class:`huaweicloudsdkcss.v2.CreateClusterRequest`
:rtype: :class:`huaweicloudsdkcss.v2.CreateClusterResponse`
2022-02-10 11:09:33 +00:00
"""
2023-05-11 09:07:48 +00:00
return self._create_cluster_with_http_info(request)
2022-02-10 11:09:33 +00:00
2023-05-11 09:07:48 +00:00
def _create_cluster_with_http_info(self, request):
local_var_params = {attr: getattr(request, attr) for attr in request.attribute_map if hasattr(request, attr)}
2022-02-10 11:09:33 +00:00
2022-11-17 12:13:53 +00:00
cname = None
2022-02-10 11:09:33 +00:00
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json'])
auth_settings = []
return self.call_api(
resource_path='/v2.0/{project_id}/clusters',
method='POST',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
2022-11-17 12:13:53 +00:00
cname=cname,
2022-02-10 11:09:33 +00:00
response_type='CreateClusterResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def restart_cluster(self, request):
"""重启集群V2
2022-06-23 11:11:56 +00:00
该接口可以用于重启当前集群拥有的全部节点类型或部分节点类型组合的节点
2022-04-21 12:03:46 +00:00
2022-11-30 08:59:35 +00:00
Please refer to HUAWEI cloud API Explorer for details.
2022-02-10 11:09:33 +00:00
2022-04-21 12:03:46 +00:00
:param request: Request instance for RestartCluster
:type request: :class:`huaweicloudsdkcss.v2.RestartClusterRequest`
:rtype: :class:`huaweicloudsdkcss.v2.RestartClusterResponse`
2022-02-10 11:09:33 +00:00
"""
2023-05-11 09:07:48 +00:00
return self._restart_cluster_with_http_info(request)
2022-02-10 11:09:33 +00:00
2023-05-11 09:07:48 +00:00
def _restart_cluster_with_http_info(self, request):
local_var_params = {attr: getattr(request, attr) for attr in request.attribute_map if hasattr(request, attr)}
2022-02-10 11:09:33 +00:00
2022-11-17 12:13:53 +00:00
cname = None
2022-02-10 11:09:33 +00:00
collection_formats = {}
path_params = {}
if 'cluster_id' in local_var_params:
path_params['cluster_id'] = local_var_params['cluster_id']
query_params = []
header_params = {}
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json'])
auth_settings = []
return self.call_api(
resource_path='/v2.0/{project_id}/clusters/{cluster_id}/restart',
method='POST',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
2022-11-17 12:13:53 +00:00
cname=cname,
2022-02-10 11:09:33 +00:00
response_type='RestartClusterResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def rolling_restart(self, request):
"""滚动重启
2022-06-23 11:11:56 +00:00
该接口会一个一个重启节点在索引数量比较多的情况下耗时较长
2022-04-21 12:03:46 +00:00
2023-04-20 08:57:41 +00:00
>仅当集群的节点数量含Master节点Client节点和冷数据节点大于3时才支持滚动重启
2022-11-30 08:59:35 +00:00
Please refer to HUAWEI cloud API Explorer for details.
2022-02-10 11:09:33 +00:00
2022-04-21 12:03:46 +00:00
:param request: Request instance for RollingRestart
:type request: :class:`huaweicloudsdkcss.v2.RollingRestartRequest`
:rtype: :class:`huaweicloudsdkcss.v2.RollingRestartResponse`
2022-02-10 11:09:33 +00:00
"""
2023-05-11 09:07:48 +00:00
return self._rolling_restart_with_http_info(request)
2022-02-10 11:09:33 +00:00
2023-05-11 09:07:48 +00:00
def _rolling_restart_with_http_info(self, request):
local_var_params = {attr: getattr(request, attr) for attr in request.attribute_map if hasattr(request, attr)}
2022-02-10 11:09:33 +00:00
2022-11-17 12:13:53 +00:00
cname = None
2022-02-10 11:09:33 +00:00
collection_formats = {}
path_params = {}
if 'cluster_id' in local_var_params:
path_params['cluster_id'] = local_var_params['cluster_id']
query_params = []
header_params = {}
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json'])
auth_settings = []
return self.call_api(
resource_path='/v2.0/{project_id}/clusters/{cluster_id}/rolling_restart',
method='POST',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
2022-11-17 12:13:53 +00:00
cname=cname,
2022-02-10 11:09:33 +00:00
response_type='RollingRestartResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def start_auto_create_snapshots(self, request):
"""开启自动创建快照功能
2022-06-23 11:11:56 +00:00
该接口用于打开自动备份功能
2022-04-21 12:03:46 +00:00
2022-11-30 08:59:35 +00:00
Please refer to HUAWEI cloud API Explorer for details.
2022-02-10 11:09:33 +00:00
2022-04-21 12:03:46 +00:00
:param request: Request instance for StartAutoCreateSnapshots
:type request: :class:`huaweicloudsdkcss.v2.StartAutoCreateSnapshotsRequest`
:rtype: :class:`huaweicloudsdkcss.v2.StartAutoCreateSnapshotsResponse`
2022-02-10 11:09:33 +00:00
"""
2023-05-11 09:07:48 +00:00
return self._start_auto_create_snapshots_with_http_info(request)
2022-02-10 11:09:33 +00:00
2023-05-11 09:07:48 +00:00
def _start_auto_create_snapshots_with_http_info(self, request):
local_var_params = {attr: getattr(request, attr) for attr in request.attribute_map if hasattr(request, attr)}
2022-02-10 11:09:33 +00:00
2022-11-17 12:13:53 +00:00
cname = None
2022-02-10 11:09:33 +00:00
collection_formats = {}
path_params = {}
if 'cluster_id' in local_var_params:
path_params['cluster_id'] = local_var_params['cluster_id']
query_params = []
header_params = {}
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json'])
auth_settings = []
return self.call_api(
resource_path='/v2.0/{project_id}/clusters/{cluster_id}/snapshots/policy/open',
method='POST',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
2022-11-17 12:13:53 +00:00
cname=cname,
2022-02-10 11:09:33 +00:00
response_type='StartAutoCreateSnapshotsResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def stop_auto_create_snapshots(self, request):
"""关闭自动创建快照功能
2022-06-23 11:11:56 +00:00
该接口用于关闭自动备份功能
2022-04-21 12:03:46 +00:00
2022-11-30 08:59:35 +00:00
Please refer to HUAWEI cloud API Explorer for details.
2022-02-10 11:09:33 +00:00
2022-04-21 12:03:46 +00:00
:param request: Request instance for StopAutoCreateSnapshots
:type request: :class:`huaweicloudsdkcss.v2.StopAutoCreateSnapshotsRequest`
:rtype: :class:`huaweicloudsdkcss.v2.StopAutoCreateSnapshotsResponse`
2022-02-10 11:09:33 +00:00
"""
2023-05-11 09:07:48 +00:00
return self._stop_auto_create_snapshots_with_http_info(request)
def _stop_auto_create_snapshots_with_http_info(self, request):
local_var_params = {attr: getattr(request, attr) for attr in request.attribute_map if hasattr(request, attr)}
2022-02-10 11:09:33 +00:00
2022-11-17 12:13:53 +00:00
cname = None
2022-02-10 11:09:33 +00:00
collection_formats = {}
path_params = {}
if 'cluster_id' in local_var_params:
path_params['cluster_id'] = local_var_params['cluster_id']
query_params = []
header_params = {}
form_params = {}
body_params = None
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json'])
auth_settings = []
return self.call_api(
resource_path='/v2.0/{project_id}/clusters/{cluster_id}/snapshots/policy/close',
method='PUT',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
2022-11-17 12:13:53 +00:00
cname=cname,
2022-02-10 11:09:33 +00:00
response_type='StopAutoCreateSnapshotsResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def call_api(self, resource_path, method, path_params=None, query_params=None, header_params=None, body=None,
2022-11-17 12:13:53 +00:00
post_params=None, cname=None, response_type=None, response_headers=None, auth_settings=None,
2022-02-10 11:09:33 +00:00
collection_formats=None, request_type=None):
"""Makes the HTTP request and returns deserialized data.
:param resource_path: Path to method endpoint.
:param method: Method to call.
:param path_params: Path parameters in the url.
:param query_params: Query parameters in the url.
:param header_params: Header parameters to be placed in the request header.
:param body: Request body.
2022-11-17 12:13:53 +00:00
:param post_params: Request post form parameters,
2022-02-10 11:09:33 +00:00
for `application/x-www-form-urlencoded`, `multipart/form-data`.
2022-11-17 12:13:53 +00:00
:param cname: Used for obs endpoint.
:param auth_settings: Auth Settings names for the request.
2022-02-10 11:09:33 +00:00
:param response_type: Response data type.
:param response_headers: Header should be added to response data.
:param collection_formats: dict of collection formats for path, query,
header, and post parameters.
:param request_type: Request data type.
:return:
Return the response directly.
"""
return self.do_http_request(
method=method,
resource_path=resource_path,
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body,
post_params=post_params,
2022-11-17 12:13:53 +00:00
cname=cname,
2022-02-10 11:09:33 +00:00
response_type=response_type,
response_headers=response_headers,
collection_formats=collection_formats,
request_type=request_type)