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

323 lines
11 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 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'}
@staticmethod
def new_builder(clazz):
return ClientBuilder(clazz)
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
:return: RunTemplateJobV2Response
"""
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']
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()
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json;charset=UTF-8'])
auth_settings = []
return self.call_api(
resource_path='/v1/jobs/template',
method='POST',
path_params=path_params,
query_params=query_params,
header_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(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: ShowJobDetailResponse
"""
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']
form_params = {}
body_params = None
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
auth_settings = []
return self.call_api(
resource_path='/v1/jobs/{job_id}',
method='GET',
path_params=path_params,
query_params=query_params,
header_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(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: ListPublishedTemplatesResponse
"""
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']
form_params = {}
body_params = None
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
auth_settings = []
return self.call_api(
resource_path='/v1/templates',
method='GET',
path_params=path_params,
query_params=query_params,
header_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(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: ShowTemplateDetailResponse
"""
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']
form_params = {}
body_params = None
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
auth_settings = []
return self.call_api(
resource_path='/v1/templates/{template_id}',
method='GET',
path_params=path_params,
query_params=query_params,
header_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=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)