huaweicloud-sdk-python-v3/huaweicloud-sdk-devstar/huaweicloudsdkdevstar/v1/devstar_async_client.py

327 lines
12 KiB
Python
Raw Normal View History

# coding: utf-8
from __future__ import absolute_import
import datetime
import re
import importlib
import six
from huaweicloudsdkcore.client import Client
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkcore.utils import http_utils
class DevstarAsyncClient(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(DevstarAsyncClient, self).__init__()
self.model_package = importlib.import_module("huaweicloudsdkdevstar.v1.model")
self.preset_headers = {'User-Agent': 'HuaweiCloud-SDK-Python'}
def run_template_job_v2_async(self, request):
"""通过DevStar模板创建生成应用代码任务
通过DevStar的模板进行应用代码创建 新建任务时会返回任务ID通过任务ID可以查看任务的状态以及最终代码生成的地址 - 接口鉴权方式 通过华为云服务获取的用户token - 代码生成位置 应用代码生成后的地址目前支持codehub地址和压缩包下载地址
:param RunTemplateJobV2Request request
:return: RunTemplateJobV2Response
"""
return self.run_template_job_v2_with_http_info(request)
def run_template_job_v2_with_http_info(self, request):
"""通过DevStar模板创建生成应用代码任务
通过DevStar的模板进行应用代码创建 新建任务时会返回任务ID通过任务ID可以查看任务的状态以及最终代码生成的地址 - 接口鉴权方式 通过华为云服务获取的用户token - 代码生成位置 应用代码生成后的地址目前支持codehub地址和压缩包下载地址
:param RunTemplateJobV2Request request
:return: tuple(RunTemplateJobV2Response, status_code(int), headers(HTTPHeaderDict))
"""
all_params = ['run_template_job_request_body', 'x_language']
all_params.append('async_req')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')
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']
header_params['Accept'] = http_utils.select_header_accept(
['application/json;charset=UTF-8', 'application/json'])
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json;charset=UTF-8'])
auth_settings = []
return self.call_api(
'/v1/jobs/template', 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
response_type='RunTemplateJobV2Response',
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def show_job_detail_async(self, request):
"""查询任务状态
查询任务的详情 通过任务ID可以查看任务的状态 当任务结束时返回应用代码存放的位置 - 接口鉴权方式 通过华为云服务获取的用户token - 代码生成位置 应用代码生成后的地址目前支持codehub地址和压缩包下载地址
:param ShowJobDetailRequest request
:return: ShowJobDetailResponse
"""
return self.show_job_detail_with_http_info(request)
def show_job_detail_with_http_info(self, request):
"""查询任务状态
查询任务的详情 通过任务ID可以查看任务的状态 当任务结束时返回应用代码存放的位置 - 接口鉴权方式 通过华为云服务获取的用户token - 代码生成位置 应用代码生成后的地址目前支持codehub地址和压缩包下载地址
:param ShowJobDetailRequest request
:return: tuple(ShowJobDetailResponse, status_code(int), headers(HTTPHeaderDict))
"""
all_params = ['job_id', 'x_language']
all_params.append('async_req')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')
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 'job_id' in local_var_params:
path_params['job_id'] = local_var_params['job_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
header_params['Accept'] = http_utils.select_header_accept(
['application/json;charset=UTF-8', 'application/json'])
auth_settings = []
return self.call_api(
'/v1/jobs/{job_id}', 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
response_type='ShowJobDetailResponse',
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def list_published_templates_async(self, request):
"""查询模板列表
查询模板列表
:param ListPublishedTemplatesRequest request
:return: ListPublishedTemplatesResponse
"""
return self.list_published_templates_with_http_info(request)
def list_published_templates_with_http_info(self, request):
"""查询模板列表
查询模板列表
:param ListPublishedTemplatesRequest request
:return: tuple(ListPublishedTemplatesResponse, status_code(int), headers(HTTPHeaderDict))
"""
all_params = ['x_language', 'keyword', 'offset', 'limit']
all_params.append('async_req')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')
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 'keyword' in local_var_params:
query_params.append(('keyword', local_var_params['keyword']))
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 = {}
if 'x_language' in local_var_params:
header_params['X-Language'] = local_var_params['x_language']
form_params = []
body_params = None
header_params['Accept'] = http_utils.select_header_accept(
['application/json;charset=UTF-8', 'application/json'])
auth_settings = []
return self.call_api(
'/v1/templates', 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
response_type='ListPublishedTemplatesResponse',
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def show_template_detail_async(self, request):
"""查询模板详情
查询模板详情
:param ShowTemplateDetailRequest request
:return: ShowTemplateDetailResponse
"""
return self.show_template_detail_with_http_info(request)
def show_template_detail_with_http_info(self, request):
"""查询模板详情
查询模板详情
:param ShowTemplateDetailRequest request
:return: tuple(ShowTemplateDetailResponse, status_code(int), headers(HTTPHeaderDict))
"""
all_params = ['template_id', 'x_language']
all_params.append('async_req')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')
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 'template_id' in local_var_params:
path_params['template_id'] = local_var_params['template_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
header_params['Accept'] = http_utils.select_header_accept(
['application/json;charset=UTF-8'])
auth_settings = []
return self.call_api(
'/v1/templates/{template_id}', 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
response_type='ShowTemplateDetailResponse',
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, 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 collection_formats: dict of collection formats for path, query,
header, and post parameters.
:return:
Return the response directly.
"""
return self.do_http_request(method, resource_path, path_params,
query_params, header_params, body, post_params,
response_type, collection_formats, request_type, True)