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 DevstarClient(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(DevstarClient, 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
|
|
|
|
|
|
|
|
|
def run_template_job_v2(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
|
2020-07-15 09:30:15 +00:00
|
|
|
|
:return: RunTemplateJobV2Response
|
2020-06-15 07:04:23 +00:00
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
all_params = ['run_template_job_request_body', '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 = []
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
response_type='RunTemplateJobV2Response',
|
|
|
|
|
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(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
|
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(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(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)
|