2020-06-15 07:04:23 +00:00
|
|
|
|
# coding: utf-8
|
|
|
|
|
|
|
|
|
|
from __future__ import absolute_import
|
|
|
|
|
|
|
|
|
|
import datetime
|
|
|
|
|
import re
|
|
|
|
|
import importlib
|
|
|
|
|
|
|
|
|
|
import six
|
|
|
|
|
|
2020-07-30 11:19:13 +00:00
|
|
|
|
from huaweicloudsdkcore.client import Client, ClientBuilder
|
2020-06-15 07:04:23 +00:00
|
|
|
|
from huaweicloudsdkcore.exceptions import exceptions
|
|
|
|
|
from huaweicloudsdkcore.utils import http_utils
|
2020-07-15 09:30:15 +00:00
|
|
|
|
from huaweicloudsdkcore.sdk_stream_request import SdkStreamRequest
|
2020-06-15 07:04:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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'}
|
|
|
|
|
|
2020-07-30 11:19:13 +00:00
|
|
|
|
@staticmethod
|
|
|
|
|
def new_builder(clazz):
|
|
|
|
|
return ClientBuilder(clazz)
|
2020-06-15 07:04:23 +00:00
|
|
|
|
|
2020-09-04 09:44:58 +00:00
|
|
|
|
def download_application_code_async(self, request):
|
|
|
|
|
"""下载模板产物
|
2020-06-15 07:04:23 +00:00
|
|
|
|
|
2020-09-04 09:44:58 +00:00
|
|
|
|
下载模板产物
|
2020-06-15 07:04:23 +00:00
|
|
|
|
|
2020-09-04 09:44:58 +00:00
|
|
|
|
:param DownloadApplicationCodeRequest request
|
|
|
|
|
:return: DownloadApplicationCodeResponse
|
2020-06-15 07:04:23 +00:00
|
|
|
|
"""
|
2020-09-04 09:44:58 +00:00
|
|
|
|
return self.download_application_code_with_http_info(request)
|
2020-06-15 07:04:23 +00:00
|
|
|
|
|
2020-09-04 09:44:58 +00:00
|
|
|
|
def download_application_code_with_http_info(self, request):
|
|
|
|
|
"""下载模板产物
|
2020-06-15 07:04:23 +00:00
|
|
|
|
|
2020-09-04 09:44:58 +00:00
|
|
|
|
下载模板产物
|
2020-06-15 07:04:23 +00:00
|
|
|
|
|
2020-09-04 09:44:58 +00:00
|
|
|
|
:param DownloadApplicationCodeRequest request
|
|
|
|
|
:return: DownloadApplicationCodeResponse
|
2020-06-15 07:04:23 +00:00
|
|
|
|
"""
|
|
|
|
|
|
2020-09-04 09:44:58 +00:00
|
|
|
|
all_params = ['job_id', 'x_language']
|
|
|
|
|
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 'job_id' in local_var_params:
|
|
|
|
|
query_params.append(('job_id', local_var_params['job_id']))
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auth_settings = []
|
|
|
|
|
|
|
|
|
|
return self.call_api(
|
|
|
|
|
resource_path='/v1/application-codes',
|
|
|
|
|
method='GET',
|
|
|
|
|
path_params=path_params,
|
|
|
|
|
query_params=query_params,
|
|
|
|
|
header_params=header_params,
|
|
|
|
|
body=body_params,
|
|
|
|
|
post_params=form_params,
|
|
|
|
|
response_type='DownloadApplicationCodeResponse',
|
|
|
|
|
auth_settings=auth_settings,
|
|
|
|
|
collection_formats=collection_formats,
|
|
|
|
|
request_type=request.__class__.__name__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def run_devstar_template_job_async(self, request):
|
|
|
|
|
"""Devstar 模板生成代码
|
|
|
|
|
|
|
|
|
|
通过DevStar的模板进行应用代码创建 通过 DevStar 模板创建生成应用代码的任务,并将应用代码存储于指定的 CodeHub 仓库中,可以通过返回的任务 ID 查询相关任务状态 - 接口鉴权方式 通过华为云服务获取的用户token - 代码生成位置 应用代码生成后的地址,目前支持codehub地址和压缩包下载地址。
|
|
|
|
|
|
|
|
|
|
:param RunDevstarTemplateJobRequest request
|
|
|
|
|
:return: RunDevstarTemplateJobResponse
|
|
|
|
|
"""
|
|
|
|
|
return self.run_devstar_template_job_with_http_info(request)
|
|
|
|
|
|
|
|
|
|
def run_devstar_template_job_with_http_info(self, request):
|
|
|
|
|
"""Devstar 模板生成代码
|
|
|
|
|
|
|
|
|
|
通过DevStar的模板进行应用代码创建 通过 DevStar 模板创建生成应用代码的任务,并将应用代码存储于指定的 CodeHub 仓库中,可以通过返回的任务 ID 查询相关任务状态 - 接口鉴权方式 通过华为云服务获取的用户token - 代码生成位置 应用代码生成后的地址,目前支持codehub地址和压缩包下载地址。
|
|
|
|
|
|
|
|
|
|
:param RunDevstarTemplateJobRequest request
|
|
|
|
|
:return: RunDevstarTemplateJobResponse
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
all_params = ['run_devstar_template_job_request_body', 'x_language']
|
2020-06-15 07:04:23 +00:00
|
|
|
|
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']
|
|
|
|
|
|
2020-07-15 09:30:15 +00:00
|
|
|
|
form_params = {}
|
2020-06-15 07:04:23 +00:00
|
|
|
|
|
|
|
|
|
body_params = None
|
|
|
|
|
if 'body' in local_var_params:
|
|
|
|
|
body_params = local_var_params['body']
|
2020-07-15 09:30:15 +00:00
|
|
|
|
if isinstance(request, SdkStreamRequest):
|
|
|
|
|
body_params = request.get_file_stream()
|
2020-06-15 07:04:23 +00:00
|
|
|
|
|
|
|
|
|
header_params['Content-Type'] = http_utils.select_header_content_type(
|
2020-08-28 10:16:33 +00:00
|
|
|
|
['application/json;charset=UTF-8'])
|
2020-07-15 09:30:15 +00:00
|
|
|
|
|
2020-06-15 07:04:23 +00:00
|
|
|
|
auth_settings = []
|
|
|
|
|
|
|
|
|
|
return self.call_api(
|
2020-07-15 09:30:15 +00:00
|
|
|
|
resource_path='/v1/jobs/template',
|
|
|
|
|
method='POST',
|
|
|
|
|
path_params=path_params,
|
|
|
|
|
query_params=query_params,
|
|
|
|
|
header_params=header_params,
|
2020-06-15 07:04:23 +00:00
|
|
|
|
body=body_params,
|
|
|
|
|
post_params=form_params,
|
2020-09-04 09:44:58 +00:00
|
|
|
|
response_type='RunDevstarTemplateJobResponse',
|
2020-06-15 07:04:23 +00:00
|
|
|
|
auth_settings=auth_settings,
|
|
|
|
|
collection_formats=collection_formats,
|
|
|
|
|
request_type=request.__class__.__name__)
|
|
|
|
|
|
2020-07-30 11:19:13 +00:00
|
|
|
|
|
2020-06-15 07:04:23 +00:00
|
|
|
|
def show_job_detail_async(self, request):
|
2020-09-04 09:44:58 +00:00
|
|
|
|
"""查询任务详情
|
2020-06-15 07:04:23 +00:00
|
|
|
|
|
|
|
|
|
查询任务的详情 通过任务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):
|
2020-09-04 09:44:58 +00:00
|
|
|
|
"""查询任务详情
|
2020-06-15 07:04:23 +00:00
|
|
|
|
|
|
|
|
|
查询任务的详情 通过任务ID可以查看任务的状态 当任务结束时返回应用代码存放的位置 - 接口鉴权方式 通过华为云服务获取的用户token - 代码生成位置 应用代码生成后的地址,目前支持codehub地址和压缩包下载地址
|
|
|
|
|
|
|
|
|
|
:param ShowJobDetailRequest request
|
2020-07-15 09:30:15 +00:00
|
|
|
|
:return: ShowJobDetailResponse
|
2020-06-15 07:04:23 +00:00
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
all_params = ['job_id', 'x_language']
|
|
|
|
|
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']
|
|
|
|
|
|
2020-07-15 09:30:15 +00:00
|
|
|
|
form_params = {}
|
2020-06-15 07:04:23 +00:00
|
|
|
|
|
|
|
|
|
body_params = None
|
2020-07-15 09:30:15 +00:00
|
|
|
|
if isinstance(request, SdkStreamRequest):
|
|
|
|
|
body_params = request.get_file_stream()
|
2020-06-15 07:04:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auth_settings = []
|
|
|
|
|
|
|
|
|
|
return self.call_api(
|
2020-07-15 09:30:15 +00:00
|
|
|
|
resource_path='/v1/jobs/{job_id}',
|
|
|
|
|
method='GET',
|
|
|
|
|
path_params=path_params,
|
|
|
|
|
query_params=query_params,
|
|
|
|
|
header_params=header_params,
|
2020-06-15 07:04:23 +00:00
|
|
|
|
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
|
2020-07-15 09:30:15 +00:00
|
|
|
|
:return: ListPublishedTemplatesResponse
|
2020-06-15 07:04:23 +00:00
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
all_params = ['x_language', 'keyword', '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 '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']
|
|
|
|
|
|
2020-07-15 09:30:15 +00:00
|
|
|
|
form_params = {}
|
2020-06-15 07:04:23 +00:00
|
|
|
|
|
|
|
|
|
body_params = None
|
2020-07-15 09:30:15 +00:00
|
|
|
|
if isinstance(request, SdkStreamRequest):
|
|
|
|
|
body_params = request.get_file_stream()
|
2020-06-15 07:04:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auth_settings = []
|
|
|
|
|
|
|
|
|
|
return self.call_api(
|
2020-07-15 09:30:15 +00:00
|
|
|
|
resource_path='/v1/templates',
|
|
|
|
|
method='GET',
|
|
|
|
|
path_params=path_params,
|
|
|
|
|
query_params=query_params,
|
|
|
|
|
header_params=header_params,
|
2020-06-15 07:04:23 +00:00
|
|
|
|
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
|
2020-07-15 09:30:15 +00:00
|
|
|
|
:return: ShowTemplateDetailResponse
|
2020-06-15 07:04:23 +00:00
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
all_params = ['template_id', 'x_language']
|
|
|
|
|
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']
|
|
|
|
|
|
2020-07-15 09:30:15 +00:00
|
|
|
|
form_params = {}
|
2020-06-15 07:04:23 +00:00
|
|
|
|
|
|
|
|
|
body_params = None
|
2020-07-15 09:30:15 +00:00
|
|
|
|
if isinstance(request, SdkStreamRequest):
|
|
|
|
|
body_params = request.get_file_stream()
|
2020-06-15 07:04:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auth_settings = []
|
|
|
|
|
|
|
|
|
|
return self.call_api(
|
2020-07-15 09:30:15 +00:00
|
|
|
|
resource_path='/v1/templates/{template_id}',
|
|
|
|
|
method='GET',
|
|
|
|
|
path_params=path_params,
|
|
|
|
|
query_params=query_params,
|
|
|
|
|
header_params=header_params,
|
2020-06-15 07:04:23 +00:00
|
|
|
|
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.
|
|
|
|
|
"""
|
2020-07-15 09:30:15 +00:00
|
|
|
|
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,
|
|
|
|
|
collection_formats=collection_formats,
|
|
|
|
|
request_type=request_type,
|
|
|
|
|
async_request=True)
|