413 lines
14 KiB
Python
413 lines
14 KiB
Python
# coding: utf-8
|
||
|
||
from __future__ import absolute_import
|
||
|
||
import importlib
|
||
|
||
from huaweicloudsdkcore.client import Client, ClientBuilder
|
||
from huaweicloudsdkcore.utils import http_utils
|
||
from huaweicloudsdkcore.sdk_stream_request import SdkStreamRequest
|
||
|
||
|
||
class ScmClient(Client):
|
||
def __init__(self):
|
||
super(ScmClient, self).__init__()
|
||
self.model_package = importlib.import_module("huaweicloudsdkscm.v3.model")
|
||
|
||
@classmethod
|
||
def new_builder(cls, clazz=None):
|
||
if clazz is None:
|
||
return ClientBuilder(cls, "GlobalCredentials")
|
||
|
||
if clazz.__name__ != "ScmClient":
|
||
raise TypeError("client type error, support client type is ScmClient")
|
||
|
||
return ClientBuilder(clazz, "GlobalCredentials")
|
||
|
||
def delete_certificate(self, request):
|
||
"""删除证书
|
||
|
||
删除证书实例,即将证书资源从华为云系统中删除。
|
||
|
||
Please refer to HUAWEI cloud API Explorer for details.
|
||
|
||
:param request: Request instance for DeleteCertificate
|
||
:type request: :class:`huaweicloudsdkscm.v3.DeleteCertificateRequest`
|
||
:rtype: :class:`huaweicloudsdkscm.v3.DeleteCertificateResponse`
|
||
"""
|
||
return self._delete_certificate_with_http_info(request)
|
||
|
||
def _delete_certificate_with_http_info(self, request):
|
||
local_var_params = {attr: getattr(request, attr) for attr in request.attribute_map if hasattr(request, attr)}
|
||
|
||
cname = None
|
||
|
||
collection_formats = {}
|
||
|
||
path_params = {}
|
||
if 'certificate_id' in local_var_params:
|
||
path_params['certificate_id'] = local_var_params['certificate_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 = []
|
||
|
||
return self.call_api(
|
||
resource_path='/v3/scm/certificates/{certificate_id}',
|
||
method='DELETE',
|
||
path_params=path_params,
|
||
query_params=query_params,
|
||
header_params=header_params,
|
||
body=body_params,
|
||
post_params=form_params,
|
||
cname=cname,
|
||
response_type='DeleteCertificateResponse',
|
||
response_headers=response_headers,
|
||
auth_settings=auth_settings,
|
||
collection_formats=collection_formats,
|
||
request_type=request.__class__.__name__)
|
||
|
||
def export_certificate(self, request):
|
||
"""导出证书
|
||
|
||
导出证书。
|
||
|
||
Please refer to HUAWEI cloud API Explorer for details.
|
||
|
||
:param request: Request instance for ExportCertificate
|
||
:type request: :class:`huaweicloudsdkscm.v3.ExportCertificateRequest`
|
||
:rtype: :class:`huaweicloudsdkscm.v3.ExportCertificateResponse`
|
||
"""
|
||
return self._export_certificate_with_http_info(request)
|
||
|
||
def _export_certificate_with_http_info(self, request):
|
||
local_var_params = {attr: getattr(request, attr) for attr in request.attribute_map if hasattr(request, attr)}
|
||
|
||
cname = None
|
||
|
||
collection_formats = {}
|
||
|
||
path_params = {}
|
||
if 'certificate_id' in local_var_params:
|
||
path_params['certificate_id'] = local_var_params['certificate_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 = []
|
||
|
||
return self.call_api(
|
||
resource_path='/v3/scm/certificates/{certificate_id}/export',
|
||
method='POST',
|
||
path_params=path_params,
|
||
query_params=query_params,
|
||
header_params=header_params,
|
||
body=body_params,
|
||
post_params=form_params,
|
||
cname=cname,
|
||
response_type='ExportCertificateResponse',
|
||
response_headers=response_headers,
|
||
auth_settings=auth_settings,
|
||
collection_formats=collection_formats,
|
||
request_type=request.__class__.__name__)
|
||
|
||
def import_certificate(self, request):
|
||
"""导入证书
|
||
|
||
导入证书到SCM服务管理。
|
||
|
||
Please refer to HUAWEI cloud API Explorer for details.
|
||
|
||
:param request: Request instance for ImportCertificate
|
||
:type request: :class:`huaweicloudsdkscm.v3.ImportCertificateRequest`
|
||
:rtype: :class:`huaweicloudsdkscm.v3.ImportCertificateResponse`
|
||
"""
|
||
return self._import_certificate_with_http_info(request)
|
||
|
||
def _import_certificate_with_http_info(self, request):
|
||
local_var_params = {attr: getattr(request, attr) for attr in request.attribute_map if hasattr(request, attr)}
|
||
|
||
cname = None
|
||
|
||
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 = []
|
||
|
||
return self.call_api(
|
||
resource_path='/v3/scm/certificates/import',
|
||
method='POST',
|
||
path_params=path_params,
|
||
query_params=query_params,
|
||
header_params=header_params,
|
||
body=body_params,
|
||
post_params=form_params,
|
||
cname=cname,
|
||
response_type='ImportCertificateResponse',
|
||
response_headers=response_headers,
|
||
auth_settings=auth_settings,
|
||
collection_formats=collection_formats,
|
||
request_type=request.__class__.__name__)
|
||
|
||
def list_certificates(self, request):
|
||
"""查询证书列表
|
||
|
||
根据证书名称或绑定域名查询证书列表。
|
||
|
||
Please refer to HUAWEI cloud API Explorer for details.
|
||
|
||
:param request: Request instance for ListCertificates
|
||
:type request: :class:`huaweicloudsdkscm.v3.ListCertificatesRequest`
|
||
:rtype: :class:`huaweicloudsdkscm.v3.ListCertificatesResponse`
|
||
"""
|
||
return self._list_certificates_with_http_info(request)
|
||
|
||
def _list_certificates_with_http_info(self, request):
|
||
local_var_params = {attr: getattr(request, attr) for attr in request.attribute_map if hasattr(request, attr)}
|
||
|
||
cname = None
|
||
|
||
collection_formats = {}
|
||
|
||
path_params = {}
|
||
|
||
query_params = []
|
||
if 'limit' in local_var_params:
|
||
query_params.append(('limit', local_var_params['limit']))
|
||
if 'offset' in local_var_params:
|
||
query_params.append(('offset', local_var_params['offset']))
|
||
if 'sort_dir' in local_var_params:
|
||
query_params.append(('sort_dir', local_var_params['sort_dir']))
|
||
if 'sort_key' in local_var_params:
|
||
query_params.append(('sort_key', local_var_params['sort_key']))
|
||
if 'status' in local_var_params:
|
||
query_params.append(('status', local_var_params['status']))
|
||
if 'enterprise_project_id' in local_var_params:
|
||
query_params.append(('enterprise_project_id', local_var_params['enterprise_project_id']))
|
||
if 'deploy_support' in local_var_params:
|
||
query_params.append(('deploy_support', local_var_params['deploy_support']))
|
||
|
||
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 = []
|
||
|
||
return self.call_api(
|
||
resource_path='/v3/scm/certificates',
|
||
method='GET',
|
||
path_params=path_params,
|
||
query_params=query_params,
|
||
header_params=header_params,
|
||
body=body_params,
|
||
post_params=form_params,
|
||
cname=cname,
|
||
response_type='ListCertificatesResponse',
|
||
response_headers=response_headers,
|
||
auth_settings=auth_settings,
|
||
collection_formats=collection_formats,
|
||
request_type=request.__class__.__name__)
|
||
|
||
def push_certificate(self, request):
|
||
"""推送证书
|
||
|
||
推送SSL证书到弹性负载均衡(Elastic Load Balance,简称ELB)、Web应用防火墙(Web Application Firewall,WAF)、CDN(Content Delivery Network,内容分发网络)等其它华为云产品中。
|
||
|
||
Please refer to HUAWEI cloud API Explorer for details.
|
||
|
||
:param request: Request instance for PushCertificate
|
||
:type request: :class:`huaweicloudsdkscm.v3.PushCertificateRequest`
|
||
:rtype: :class:`huaweicloudsdkscm.v3.PushCertificateResponse`
|
||
"""
|
||
return self._push_certificate_with_http_info(request)
|
||
|
||
def _push_certificate_with_http_info(self, request):
|
||
local_var_params = {attr: getattr(request, attr) for attr in request.attribute_map if hasattr(request, attr)}
|
||
|
||
cname = None
|
||
|
||
collection_formats = {}
|
||
|
||
path_params = {}
|
||
if 'certificate_id' in local_var_params:
|
||
path_params['certificate_id'] = local_var_params['certificate_id']
|
||
|
||
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 = []
|
||
|
||
return self.call_api(
|
||
resource_path='/v3/scm/certificates/{certificate_id}/push',
|
||
method='POST',
|
||
path_params=path_params,
|
||
query_params=query_params,
|
||
header_params=header_params,
|
||
body=body_params,
|
||
post_params=form_params,
|
||
cname=cname,
|
||
response_type='PushCertificateResponse',
|
||
response_headers=response_headers,
|
||
auth_settings=auth_settings,
|
||
collection_formats=collection_formats,
|
||
request_type=request.__class__.__name__)
|
||
|
||
def show_certificate(self, request):
|
||
"""获取证书详情
|
||
|
||
查询某张证书的详细信息。
|
||
|
||
Please refer to HUAWEI cloud API Explorer for details.
|
||
|
||
:param request: Request instance for ShowCertificate
|
||
:type request: :class:`huaweicloudsdkscm.v3.ShowCertificateRequest`
|
||
:rtype: :class:`huaweicloudsdkscm.v3.ShowCertificateResponse`
|
||
"""
|
||
return self._show_certificate_with_http_info(request)
|
||
|
||
def _show_certificate_with_http_info(self, request):
|
||
local_var_params = {attr: getattr(request, attr) for attr in request.attribute_map if hasattr(request, attr)}
|
||
|
||
cname = None
|
||
|
||
collection_formats = {}
|
||
|
||
path_params = {}
|
||
if 'certificate_id' in local_var_params:
|
||
path_params['certificate_id'] = local_var_params['certificate_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 = []
|
||
|
||
return self.call_api(
|
||
resource_path='/v3/scm/certificates/{certificate_id}',
|
||
method='GET',
|
||
path_params=path_params,
|
||
query_params=query_params,
|
||
header_params=header_params,
|
||
body=body_params,
|
||
post_params=form_params,
|
||
cname=cname,
|
||
response_type='ShowCertificateResponse',
|
||
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, cname=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: Request post form parameters,
|
||
for `application/x-www-form-urlencoded`, `multipart/form-data`.
|
||
:param cname: Used for obs endpoint.
|
||
:param auth_settings: 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,
|
||
cname=cname,
|
||
response_type=response_type,
|
||
response_headers=response_headers,
|
||
collection_formats=collection_formats,
|
||
request_type=request_type)
|