huaweicloud-sdk-python-v3/huaweicloud-sdk-cloudtable/huaweicloudsdkcloudtable/v2/cloudtable_async_client.py

347 lines
12 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

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

# coding: utf-8
from __future__ import absolute_import
import datetime
import re
import importlib
import six
from huaweicloudsdkcore.client import Client, ClientBuilder
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkcore.utils import http_utils
from huaweicloudsdkcore.sdk_stream_request import SdkStreamRequest
class CloudTableAsyncClient(Client):
"""
:param configuration: .Configuration object for this client
:param pool_threads: The number of threads to use for async requests
to the API. More threads means more concurrent API requests.
"""
PRIMITIVE_TYPES = (float, bool, bytes, six.text_type) + six.integer_types
NATIVE_TYPES_MAPPING = {
'int': int,
'long': int if six.PY3 else long,
'float': float,
'str': str,
'bool': bool,
'date': datetime.date,
'datetime': datetime.datetime,
'object': object,
}
def __init__(self):
super(CloudTableAsyncClient, self).__init__()
self.model_package = importlib.import_module("huaweicloudsdkcloudtable.v2.model")
self.preset_headers = {'User-Agent': 'HuaweiCloud-SDK-Python'}
@classmethod
def new_builder(cls, clazz=None):
if clazz is None:
return ClientBuilder(cls)
if clazz.__name__ != "CloudTableClient":
raise TypeError("client type error, support client type is CloudTableClient")
return ClientBuilder(clazz)
def create_cluster_async(self, request):
"""创建CloudTable集群
创建一个CloudTable集群。 使用接口前,您需要先获取如下资源信息。 - 通过VPC创建或查询VPC、子网 - 通过安全组创建或查询可用的security_group_id 本接口是一个同步接口当创建CloudTable集群成功后会返回集群id。
:param CreateClusterRequest request
:return: CreateClusterResponse
"""
return self.create_cluster_with_http_info(request)
def create_cluster_with_http_info(self, request):
"""创建CloudTable集群
创建一个CloudTable集群。 使用接口前,您需要先获取如下资源信息。 - 通过VPC创建或查询VPC、子网 - 通过安全组创建或查询可用的security_group_id 本接口是一个同步接口当创建CloudTable集群成功后会返回集群id。
:param CreateClusterRequest request
:return: CreateClusterResponse
"""
all_params = ['x_language', 'create_cluster_request_body']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
if 'x_language' in local_var_params:
header_params['X-Language'] = local_var_params['x_language']
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json'])
auth_settings = []
return self.call_api(
resource_path='/v2/{project_id}/clusters',
method='POST',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='CreateClusterResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def delete_cluster_async(self, request):
"""删除CloudTable指定集群
集群ID为集群唯一标识根据集群ID删除指定集群。 如下状态的集群不允许删除: - 创建中 - 扩容中
:param DeleteClusterRequest request
:return: DeleteClusterResponse
"""
return self.delete_cluster_with_http_info(request)
def delete_cluster_with_http_info(self, request):
"""删除CloudTable指定集群
集群ID为集群唯一标识根据集群ID删除指定集群。 如下状态的集群不允许删除: - 创建中 - 扩容中
:param DeleteClusterRequest request
:return: DeleteClusterResponse
"""
all_params = ['x_language', 'cluster_id']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
if 'cluster_id' in local_var_params:
path_params['cluster_id'] = local_var_params['cluster_id']
query_params = []
header_params = {}
if 'x_language' in local_var_params:
header_params['X-Language'] = local_var_params['x_language']
form_params = {}
body_params = None
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json'])
auth_settings = []
return self.call_api(
resource_path='/v2/{project_id}/clusters/{cluster_id}',
method='DELETE',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='DeleteClusterResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def list_clusters_async(self, request):
"""查询CloudTable集群列表
查看用户创建的集群列表信息。
:param ListClustersRequest request
:return: ListClustersResponse
"""
return self.list_clusters_with_http_info(request)
def list_clusters_with_http_info(self, request):
"""查询CloudTable集群列表
查看用户创建的集群列表信息。
:param ListClustersRequest request
:return: ListClustersResponse
"""
all_params = ['offset', 'limit']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
query_params = []
if 'offset' in local_var_params:
query_params.append(('offset', local_var_params['offset']))
if 'limit' in local_var_params:
query_params.append(('limit', local_var_params['limit']))
header_params = {}
form_params = {}
body_params = None
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json'])
auth_settings = []
return self.call_api(
resource_path='/v2/{project_id}/clusters',
method='GET',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='ListClustersResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def show_cluster_detail_async(self, request):
"""查询CloudTable集群详情
通过集群ID唯一标识一个集群根据集群ID查询特定CloudTable集群的详情信息。
:param ShowClusterDetailRequest request
:return: ShowClusterDetailResponse
"""
return self.show_cluster_detail_with_http_info(request)
def show_cluster_detail_with_http_info(self, request):
"""查询CloudTable集群详情
通过集群ID唯一标识一个集群根据集群ID查询特定CloudTable集群的详情信息。
:param ShowClusterDetailRequest request
:return: ShowClusterDetailResponse
"""
all_params = ['x_language', 'cluster_id']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
if 'cluster_id' in local_var_params:
path_params['cluster_id'] = local_var_params['cluster_id']
query_params = []
header_params = {}
if 'x_language' in local_var_params:
header_params['X-Language'] = local_var_params['x_language']
form_params = {}
body_params = None
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json'])
auth_settings = []
return self.call_api(
resource_path='/v2/{project_id}/clusters/{cluster_id}',
method='GET',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='ShowClusterDetailResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def call_api(self, resource_path, method, path_params=None, query_params=None, header_params=None, body=None,
post_params=None, response_type=None, response_headers=None, auth_settings=None,
collection_formats=None, request_type=None):
"""Makes the HTTP request and returns deserialized data.
:param resource_path: Path to method endpoint.
:param method: Method to call.
:param path_params: Path parameters in the url.
:param query_params: Query parameters in the url.
:param header_params: Header parameters to be
placed in the request header.
:param body: Request body.
:param post_params dict: Request post form parameters,
for `application/x-www-form-urlencoded`, `multipart/form-data`.
:param auth_settings list: Auth Settings names for the request.
:param response_type: Response data type.
:param response_headers: Header should be added to response data.
:param collection_formats: dict of collection formats for path, query,
header, and post parameters.
:param request_type: Request data type.
:return:
Return the response directly.
"""
return self.do_http_request(
method=method,
resource_path=resource_path,
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body,
post_params=post_params,
response_type=response_type,
response_headers=response_headers,
collection_formats=collection_formats,
request_type=request_type,
async_request=True)