680 lines
22 KiB
Python
680 lines
22 KiB
Python
# 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 CloudBuildClient(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(CloudBuildClient, self).__init__()
|
|
self.model_package = importlib.import_module("huaweicloudsdkcloudbuild.v3.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__ != "CloudBuildClient":
|
|
raise TypeError("client type error, support client type is CloudBuildClient")
|
|
|
|
return ClientBuilder(clazz)
|
|
|
|
def download_keystore(self, request):
|
|
"""KeyStore文件下载
|
|
|
|
下载指定租户下的KeyStore文件
|
|
|
|
:param DownloadKeystoreRequest request
|
|
:return: DownloadKeystoreResponse
|
|
"""
|
|
return self.download_keystore_with_http_info(request)
|
|
|
|
def download_keystore_with_http_info(self, request):
|
|
"""KeyStore文件下载
|
|
|
|
下载指定租户下的KeyStore文件
|
|
|
|
:param DownloadKeystoreRequest request
|
|
:return: DownloadKeystoreResponse
|
|
"""
|
|
|
|
all_params = ['file_name', 'domain_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 = {}
|
|
|
|
query_params = []
|
|
if 'file_name' in local_var_params:
|
|
query_params.append(('file_name', local_var_params['file_name']))
|
|
if 'domain_id' in local_var_params:
|
|
query_params.append(('domain_id', local_var_params['domain_id']))
|
|
|
|
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 = ['apig-auth-iam']
|
|
|
|
return self.call_api(
|
|
resource_path='/v3/keystore',
|
|
method='GET',
|
|
path_params=path_params,
|
|
query_params=query_params,
|
|
header_params=header_params,
|
|
body=body_params,
|
|
post_params=form_params,
|
|
response_type='DownloadKeystoreResponse',
|
|
response_headers=response_headers,
|
|
auth_settings=auth_settings,
|
|
collection_formats=collection_formats,
|
|
request_type=request.__class__.__name__)
|
|
|
|
|
|
def run_job(self, request):
|
|
"""执行构建任务
|
|
|
|
执行构建任务,可传自定义参数。
|
|
|
|
:param RunJobRequest request
|
|
:return: RunJobResponse
|
|
"""
|
|
return self.run_job_with_http_info(request)
|
|
|
|
def run_job_with_http_info(self, request):
|
|
"""执行构建任务
|
|
|
|
执行构建任务,可传自定义参数。
|
|
|
|
:param RunJobRequest request
|
|
:return: RunJobResponse
|
|
"""
|
|
|
|
all_params = ['run_job_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 = {}
|
|
|
|
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 = ['apig-auth-iam']
|
|
|
|
return self.call_api(
|
|
resource_path='/v3/jobs/build',
|
|
method='POST',
|
|
path_params=path_params,
|
|
query_params=query_params,
|
|
header_params=header_params,
|
|
body=body_params,
|
|
post_params=form_params,
|
|
response_type='RunJobResponse',
|
|
response_headers=response_headers,
|
|
auth_settings=auth_settings,
|
|
collection_formats=collection_formats,
|
|
request_type=request.__class__.__name__)
|
|
|
|
|
|
def show_history_details(self, request):
|
|
"""获取构建历史详情信息接口
|
|
|
|
获取构建历史详情信息接口
|
|
|
|
:param ShowHistoryDetailsRequest request
|
|
:return: ShowHistoryDetailsResponse
|
|
"""
|
|
return self.show_history_details_with_http_info(request)
|
|
|
|
def show_history_details_with_http_info(self, request):
|
|
"""获取构建历史详情信息接口
|
|
|
|
获取构建历史详情信息接口
|
|
|
|
:param ShowHistoryDetailsRequest request
|
|
:return: ShowHistoryDetailsResponse
|
|
"""
|
|
|
|
all_params = ['job_id', 'build_number']
|
|
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']
|
|
if 'build_number' in local_var_params:
|
|
path_params['build_number'] = local_var_params['build_number']
|
|
|
|
query_params = []
|
|
|
|
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 = ['apig-auth-iam']
|
|
|
|
return self.call_api(
|
|
resource_path='/v3/jobs/{job_id}/{build_number}/history-details',
|
|
method='GET',
|
|
path_params=path_params,
|
|
query_params=query_params,
|
|
header_params=header_params,
|
|
body=body_params,
|
|
post_params=form_params,
|
|
response_type='ShowHistoryDetailsResponse',
|
|
response_headers=response_headers,
|
|
auth_settings=auth_settings,
|
|
collection_formats=collection_formats,
|
|
request_type=request.__class__.__name__)
|
|
|
|
|
|
def show_job_list_by_project_id(self, request):
|
|
"""查看项目下用户的构建任务列表
|
|
|
|
查看项目下用户的构建任务列表
|
|
|
|
:param ShowJobListByProjectIdRequest request
|
|
:return: ShowJobListByProjectIdResponse
|
|
"""
|
|
return self.show_job_list_by_project_id_with_http_info(request)
|
|
|
|
def show_job_list_by_project_id_with_http_info(self, request):
|
|
"""查看项目下用户的构建任务列表
|
|
|
|
查看项目下用户的构建任务列表
|
|
|
|
:param ShowJobListByProjectIdRequest request
|
|
:return: ShowJobListByProjectIdResponse
|
|
"""
|
|
|
|
all_params = ['project_id', 'page_index', 'page_size']
|
|
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 'project_id' in local_var_params:
|
|
path_params['project_id'] = local_var_params['project_id']
|
|
|
|
query_params = []
|
|
if 'page_index' in local_var_params:
|
|
query_params.append(('page_index', local_var_params['page_index']))
|
|
if 'page_size' in local_var_params:
|
|
query_params.append(('page_size', local_var_params['page_size']))
|
|
|
|
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 = ['apig-auth-iam']
|
|
|
|
return self.call_api(
|
|
resource_path='/v3/{project_id}/jobs',
|
|
method='GET',
|
|
path_params=path_params,
|
|
query_params=query_params,
|
|
header_params=header_params,
|
|
body=body_params,
|
|
post_params=form_params,
|
|
response_type='ShowJobListByProjectIdResponse',
|
|
response_headers=response_headers,
|
|
auth_settings=auth_settings,
|
|
collection_formats=collection_formats,
|
|
request_type=request.__class__.__name__)
|
|
|
|
|
|
def show_job_status(self, request):
|
|
"""查看任务运行状态
|
|
|
|
查看任务运行状态
|
|
|
|
:param ShowJobStatusRequest request
|
|
:return: ShowJobStatusResponse
|
|
"""
|
|
return self.show_job_status_with_http_info(request)
|
|
|
|
def show_job_status_with_http_info(self, request):
|
|
"""查看任务运行状态
|
|
|
|
查看任务运行状态
|
|
|
|
:param ShowJobStatusRequest request
|
|
:return: ShowJobStatusResponse
|
|
"""
|
|
|
|
all_params = ['job_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 'job_id' in local_var_params:
|
|
path_params['job_id'] = local_var_params['job_id']
|
|
|
|
query_params = []
|
|
|
|
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 = ['apig-auth-iam']
|
|
|
|
return self.call_api(
|
|
resource_path='/v3/jobs/{job_id}/status',
|
|
method='GET',
|
|
path_params=path_params,
|
|
query_params=query_params,
|
|
header_params=header_params,
|
|
body=body_params,
|
|
post_params=form_params,
|
|
response_type='ShowJobStatusResponse',
|
|
response_headers=response_headers,
|
|
auth_settings=auth_settings,
|
|
collection_formats=collection_formats,
|
|
request_type=request.__class__.__name__)
|
|
|
|
|
|
def show_job_success_ratio(self, request):
|
|
"""根据开始时间和结束时间查看构建任务的构建成功率
|
|
|
|
根据开始时间和结束时间查看构建任务的构建成功率
|
|
|
|
:param ShowJobSuccessRatioRequest request
|
|
:return: ShowJobSuccessRatioResponse
|
|
"""
|
|
return self.show_job_success_ratio_with_http_info(request)
|
|
|
|
def show_job_success_ratio_with_http_info(self, request):
|
|
"""根据开始时间和结束时间查看构建任务的构建成功率
|
|
|
|
根据开始时间和结束时间查看构建任务的构建成功率
|
|
|
|
:param ShowJobSuccessRatioRequest request
|
|
:return: ShowJobSuccessRatioResponse
|
|
"""
|
|
|
|
all_params = ['job_id', 'start_time', 'end_time']
|
|
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 = []
|
|
if 'start_time' in local_var_params:
|
|
query_params.append(('start_time', local_var_params['start_time']))
|
|
if 'end_time' in local_var_params:
|
|
query_params.append(('end_time', local_var_params['end_time']))
|
|
|
|
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 = ['apig-auth-iam']
|
|
|
|
return self.call_api(
|
|
resource_path='/v3/jobs/{job_id}/success-ratio',
|
|
method='GET',
|
|
path_params=path_params,
|
|
query_params=query_params,
|
|
header_params=header_params,
|
|
body=body_params,
|
|
post_params=form_params,
|
|
response_type='ShowJobSuccessRatioResponse',
|
|
response_headers=response_headers,
|
|
auth_settings=auth_settings,
|
|
collection_formats=collection_formats,
|
|
request_type=request.__class__.__name__)
|
|
|
|
|
|
def show_last_history(self, request):
|
|
"""查询指定代码仓库最近一次成功的构建历史
|
|
|
|
查询指定代码仓库最近一次成功的构建历史
|
|
|
|
:param ShowLastHistoryRequest request
|
|
:return: ShowLastHistoryResponse
|
|
"""
|
|
return self.show_last_history_with_http_info(request)
|
|
|
|
def show_last_history_with_http_info(self, request):
|
|
"""查询指定代码仓库最近一次成功的构建历史
|
|
|
|
查询指定代码仓库最近一次成功的构建历史
|
|
|
|
:param ShowLastHistoryRequest request
|
|
:return: ShowLastHistoryResponse
|
|
"""
|
|
|
|
all_params = ['project_id', 'repository_name']
|
|
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 'project_id' in local_var_params:
|
|
path_params['project_id'] = local_var_params['project_id']
|
|
|
|
query_params = []
|
|
if 'repository_name' in local_var_params:
|
|
query_params.append(('repository_name', local_var_params['repository_name']))
|
|
|
|
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 = ['apig-auth-iam']
|
|
|
|
return self.call_api(
|
|
resource_path='/v3/jobs/{project_id}/last-history',
|
|
method='GET',
|
|
path_params=path_params,
|
|
query_params=query_params,
|
|
header_params=header_params,
|
|
body=body_params,
|
|
post_params=form_params,
|
|
response_type='ShowLastHistoryResponse',
|
|
response_headers=response_headers,
|
|
auth_settings=auth_settings,
|
|
collection_formats=collection_formats,
|
|
request_type=request.__class__.__name__)
|
|
|
|
|
|
def show_list_history(self, request):
|
|
"""查看构建任务的构建历史列表
|
|
|
|
查看构建任务的构建历史列表
|
|
|
|
:param ShowListHistoryRequest request
|
|
:return: ShowListHistoryResponse
|
|
"""
|
|
return self.show_list_history_with_http_info(request)
|
|
|
|
def show_list_history_with_http_info(self, request):
|
|
"""查看构建任务的构建历史列表
|
|
|
|
查看构建任务的构建历史列表
|
|
|
|
:param ShowListHistoryRequest request
|
|
:return: ShowListHistoryResponse
|
|
"""
|
|
|
|
all_params = ['job_id', 'offset', 'limit', 'interval']
|
|
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 = []
|
|
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']))
|
|
if 'interval' in local_var_params:
|
|
query_params.append(('interval', local_var_params['interval']))
|
|
|
|
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 = ['apig-auth-iam']
|
|
|
|
return self.call_api(
|
|
resource_path='/v3/jobs/{job_id}/history',
|
|
method='GET',
|
|
path_params=path_params,
|
|
query_params=query_params,
|
|
header_params=header_params,
|
|
body=body_params,
|
|
post_params=form_params,
|
|
response_type='ShowListHistoryResponse',
|
|
response_headers=response_headers,
|
|
auth_settings=auth_settings,
|
|
collection_formats=collection_formats,
|
|
request_type=request.__class__.__name__)
|
|
|
|
|
|
def show_list_period_history(self, request):
|
|
"""根据开始时间和结束时间查看构建任务的构建历史列表
|
|
|
|
根据开始时间和结束时间查看构建任务的构建历史列表
|
|
|
|
:param ShowListPeriodHistoryRequest request
|
|
:return: ShowListPeriodHistoryResponse
|
|
"""
|
|
return self.show_list_period_history_with_http_info(request)
|
|
|
|
def show_list_period_history_with_http_info(self, request):
|
|
"""根据开始时间和结束时间查看构建任务的构建历史列表
|
|
|
|
根据开始时间和结束时间查看构建任务的构建历史列表
|
|
|
|
:param ShowListPeriodHistoryRequest request
|
|
:return: ShowListPeriodHistoryResponse
|
|
"""
|
|
|
|
all_params = ['job_id', 'offset', 'limit', 'start_time', 'end_time']
|
|
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 = []
|
|
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']))
|
|
if 'start_time' in local_var_params:
|
|
query_params.append(('start_time', local_var_params['start_time']))
|
|
if 'end_time' in local_var_params:
|
|
query_params.append(('end_time', local_var_params['end_time']))
|
|
|
|
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 = ['apig-auth-iam']
|
|
|
|
return self.call_api(
|
|
resource_path='/v3/jobs/{job_id}/period-history',
|
|
method='GET',
|
|
path_params=path_params,
|
|
query_params=query_params,
|
|
header_params=header_params,
|
|
body=body_params,
|
|
post_params=form_params,
|
|
response_type='ShowListPeriodHistoryResponse',
|
|
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)
|