# 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 CdmClient(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(CdmClient, self).__init__()
        self.model_package = importlib.import_module("huaweicloudsdkcdm.v1.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__ != "CdmClient":
            raise TypeError("client type error, support client type is CdmClient")

        return ClientBuilder(clazz)

    def create_and_start_random_cluster_job(self, request):
        """随机集群创建作业并执行

        随机集群创建作业并执行接口。

        :param CreateAndStartRandomClusterJobRequest request
        :return: CreateAndStartRandomClusterJobResponse
        """
        return self.create_and_start_random_cluster_job_with_http_info(request)

    def create_and_start_random_cluster_job_with_http_info(self, request):
        """随机集群创建作业并执行

        随机集群创建作业并执行接口。

        :param CreateAndStartRandomClusterJobRequest request
        :return: CreateAndStartRandomClusterJobResponse
        """

        all_params = ['x_language', 'cdm_random_create_and_start_job_json_req']
        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()

        response_headers = []

        header_params['Content-Type'] = http_utils.select_header_content_type(
            ['application/json;charset=UTF-8'])

        auth_settings = []

        return self.call_api(
            resource_path='/v1.1/{project_id}/clusters/job',
            method='POST',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='CreateAndStartRandomClusterJobResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def create_cluster(self, request):
        """创建集群

        创建集群接口。

        :param CreateClusterRequest request
        :return: CreateClusterResponse
        """
        return self.create_cluster_with_http_info(request)

    def create_cluster_with_http_info(self, request):
        """创建集群

        创建集群接口。

        :param CreateClusterRequest request
        :return: CreateClusterResponse
        """

        all_params = ['x_language', 'cdm_create_cluster_req']
        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()

        response_headers = []

        header_params['Content-Type'] = http_utils.select_header_content_type(
            ['application/json;charset=UTF-8'])

        auth_settings = []

        return self.call_api(
            resource_path='/v1.1/{project_id}/clusters',
            method='POST',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='CreateClusterResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def create_job(self, request):
        """指定集群创建作业

        指定集群创建作业接口。

        :param CreateJobRequest request
        :return: CreateJobResponse
        """
        return self.create_job_with_http_info(request)

    def create_job_with_http_info(self, request):
        """指定集群创建作业

        指定集群创建作业接口。

        :param CreateJobRequest request
        :return: CreateJobResponse
        """

        all_params = ['cluster_id', 'cdm_start_job_json_req']
        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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_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;charset=UTF-8'])

        auth_settings = []

        return self.call_api(
            resource_path='/v1.1/{project_id}/clusters/{cluster_id}/cdm/job',
            method='POST',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='CreateJobResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def create_link(self, request):
        """创建连接

        创建连接接口。

        :param CreateLinkRequest request
        :return: CreateLinkResponse
        """
        return self.create_link_with_http_info(request)

    def create_link_with_http_info(self, request):
        """创建连接

        创建连接接口。

        :param CreateLinkRequest request
        :return: CreateLinkResponse
        """

        all_params = ['cluster_id', 'cdm_create_link_req', 'validate']
        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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_id']

        query_params = []
        if 'validate' in local_var_params:
            query_params.append(('validate', local_var_params['validate']))

        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;charset=UTF-8'])

        auth_settings = []

        return self.call_api(
            resource_path='/v1.1/{project_id}/clusters/{cluster_id}/cdm/link',
            method='POST',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='CreateLinkResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def delete_cluster(self, request):
        """删除集群

        删除集群接口。

        :param DeleteClusterRequest request
        :return: DeleteClusterResponse
        """
        return self.delete_cluster_with_http_info(request)

    def delete_cluster_with_http_info(self, request):
        """删除集群

        删除集群接口。

        :param DeleteClusterRequest request
        :return: DeleteClusterResponse
        """

        all_params = ['cluster_id', 'cdm_delete_cluster_req']
        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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_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;charset=UTF-8'])

        auth_settings = []

        return self.call_api(
            resource_path='/v1.1/{project_id}/clusters/{cluster_id}',
            method='DELETE',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='DeleteClusterResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def delete_job(self, request):
        """删除作业

        删除作业接口。

        :param DeleteJobRequest request
        :return: DeleteJobResponse
        """
        return self.delete_job_with_http_info(request)

    def delete_job_with_http_info(self, request):
        """删除作业

        删除作业接口。

        :param DeleteJobRequest request
        :return: DeleteJobResponse
        """

        all_params = ['cluster_id', 'job_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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_id']
        if 'job_name' in local_var_params:
            path_params['job_name'] = local_var_params['job_name']

        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='/v1.1/{project_id}/clusters/{cluster_id}/cdm/job/{job_name}',
            method='DELETE',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='DeleteJobResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def delete_link(self, request):
        """删除连接

        删除连接接口。

        :param DeleteLinkRequest request
        :return: DeleteLinkResponse
        """
        return self.delete_link_with_http_info(request)

    def delete_link_with_http_info(self, request):
        """删除连接

        删除连接接口。

        :param DeleteLinkRequest request
        :return: DeleteLinkResponse
        """

        all_params = ['cluster_id', 'link_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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_id']
        if 'link_name' in local_var_params:
            path_params['link_name'] = local_var_params['link_name']

        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='/v1.1/{project_id}/clusters/{cluster_id}/cdm/link/{link_name}',
            method='DELETE',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='DeleteLinkResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def list_clusters(self, request):
        """查询集群列表

        查询集群列表接口。

        :param ListClustersRequest request
        :return: ListClustersResponse
        """
        return self.list_clusters_with_http_info(request)

    def list_clusters_with_http_info(self, request):
        """查询集群列表

        查询集群列表接口。

        :param ListClustersRequest request
        :return: ListClustersResponse
        """

        all_params = []
        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 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='/v1.1/{project_id}/clusters',
            method='GET',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='ListClustersResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def restart_cluster(self, request):
        """重启集群

        重启集群接口。

        :param RestartClusterRequest request
        :return: RestartClusterResponse
        """
        return self.restart_cluster_with_http_info(request)

    def restart_cluster_with_http_info(self, request):
        """重启集群

        重启集群接口。

        :param RestartClusterRequest request
        :return: RestartClusterResponse
        """

        all_params = ['cluster_id', 'cdm_restart_cluster_req']
        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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_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;charset=UTF-8'])

        auth_settings = []

        return self.call_api(
            resource_path='/v1.1/{project_id}/clusters/{cluster_id}/action',
            method='POST',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='RestartClusterResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def show_cluster_detail(self, request):
        """查询集群详情

        查询集群详情接口。

        :param ShowClusterDetailRequest request
        :return: ShowClusterDetailResponse
        """
        return self.show_cluster_detail_with_http_info(request)

    def show_cluster_detail_with_http_info(self, request):
        """查询集群详情

        查询集群详情接口。

        :param ShowClusterDetailRequest request
        :return: ShowClusterDetailResponse
        """

        all_params = ['cluster_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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_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='/v1.1/{project_id}/clusters/{cluster_id}',
            method='GET',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='ShowClusterDetailResponse',
            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 = ['cluster_id', 'job_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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_id']
        if 'job_name' in local_var_params:
            path_params['job_name'] = local_var_params['job_name']

        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='/v1.1/{project_id}/clusters/{cluster_id}/cdm/job/{job_name}/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_jobs(self, request):
        """查询作业

        查询作业接口。

        :param ShowJobsRequest request
        :return: ShowJobsResponse
        """
        return self.show_jobs_with_http_info(request)

    def show_jobs_with_http_info(self, request):
        """查询作业

        查询作业接口。

        :param ShowJobsRequest request
        :return: ShowJobsResponse
        """

        all_params = ['cluster_id', 'job_name', 'filter', 'page_no', 'page_size', 'job_type']
        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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_id']
        if 'job_name' in local_var_params:
            path_params['job_name'] = local_var_params['job_name']

        query_params = []
        if 'filter' in local_var_params:
            query_params.append(('filter', local_var_params['filter']))
        if 'page_no' in local_var_params:
            query_params.append(('page_no', local_var_params['page_no']))
        if 'page_size' in local_var_params:
            query_params.append(('page_size', local_var_params['page_size']))
        if 'job_type' in local_var_params:
            query_params.append(('jobType', local_var_params['job_type']))

        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='/v1.1/{project_id}/clusters/{cluster_id}/cdm/job/{job_name}',
            method='GET',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='ShowJobsResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def show_link(self, request):
        """查询连接

        查询连接接口。

        :param ShowLinkRequest request
        :return: ShowLinkResponse
        """
        return self.show_link_with_http_info(request)

    def show_link_with_http_info(self, request):
        """查询连接

        查询连接接口。

        :param ShowLinkRequest request
        :return: ShowLinkResponse
        """

        all_params = ['cluster_id', 'link_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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_id']
        if 'link_name' in local_var_params:
            path_params['link_name'] = local_var_params['link_name']

        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='/v1.1/{project_id}/clusters/{cluster_id}/cdm/link/{link_name}',
            method='GET',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='ShowLinkResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def show_submissions(self, request):
        """查询作业执行历史

        查询作业执行历史接口。

        :param ShowSubmissionsRequest request
        :return: ShowSubmissionsResponse
        """
        return self.show_submissions_with_http_info(request)

    def show_submissions_with_http_info(self, request):
        """查询作业执行历史

        查询作业执行历史接口。

        :param ShowSubmissionsRequest request
        :return: ShowSubmissionsResponse
        """

        all_params = ['cluster_id', 'jname']
        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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_id']

        query_params = []
        if 'jname' in local_var_params:
            query_params.append(('jname', local_var_params['jname']))

        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='/v1.1/{project_id}/clusters/{cluster_id}/cdm/submissions',
            method='GET',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='ShowSubmissionsResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def start_cluster(self, request):
        """启动集群

        启动集群接口。

        :param StartClusterRequest request
        :return: StartClusterResponse
        """
        return self.start_cluster_with_http_info(request)

    def start_cluster_with_http_info(self, request):
        """启动集群

        启动集群接口。

        :param StartClusterRequest request
        :return: StartClusterResponse
        """

        all_params = ['cluster_id', 'cdm_start_cluster_req']
        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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_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;charset=UTF-8'])

        auth_settings = []

        return self.call_api(
            resource_path='/v1.1/{project_id}/clusters/{cluster_id}/action',
            method='POST',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='StartClusterResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def start_job(self, request):
        """启动作业

        启动作业接口。

        :param StartJobRequest request
        :return: StartJobResponse
        """
        return self.start_job_with_http_info(request)

    def start_job_with_http_info(self, request):
        """启动作业

        启动作业接口。

        :param StartJobRequest request
        :return: StartJobResponse
        """

        all_params = ['cluster_id', 'job_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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_id']
        if 'job_name' in local_var_params:
            path_params['job_name'] = local_var_params['job_name']

        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='/v1.1/{project_id}/clusters/{cluster_id}/cdm/job/{job_name}/start',
            method='PUT',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='StartJobResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def stop_cluster(self, request):
        """停止集群

        停止集群接口。

        :param StopClusterRequest request
        :return: StopClusterResponse
        """
        return self.stop_cluster_with_http_info(request)

    def stop_cluster_with_http_info(self, request):
        """停止集群

        停止集群接口。

        :param StopClusterRequest request
        :return: StopClusterResponse
        """

        all_params = ['cluster_id', 'cdm_stop_cluster_req']
        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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_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;charset=UTF-8'])

        auth_settings = []

        return self.call_api(
            resource_path='/v1.1/{project_id}/clusters/{cluster_id}/action',
            method='POST',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='StopClusterResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def stop_job(self, request):
        """停止作业

        停止作业接口。

        :param StopJobRequest request
        :return: StopJobResponse
        """
        return self.stop_job_with_http_info(request)

    def stop_job_with_http_info(self, request):
        """停止作业

        停止作业接口。

        :param StopJobRequest request
        :return: StopJobResponse
        """

        all_params = ['cluster_id', 'job_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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_id']
        if 'job_name' in local_var_params:
            path_params['job_name'] = local_var_params['job_name']

        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='/v1.1/{project_id}/clusters/{cluster_id}/cdm/job/{job_name}/stop',
            method='PUT',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='StopJobResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def update_job(self, request):
        """修改作业

        修改作业接口。

        :param UpdateJobRequest request
        :return: UpdateJobResponse
        """
        return self.update_job_with_http_info(request)

    def update_job_with_http_info(self, request):
        """修改作业

        修改作业接口。

        :param UpdateJobRequest request
        :return: UpdateJobResponse
        """

        all_params = ['cluster_id', 'job_name', 'cdm_update_job_json_req']
        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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_id']
        if 'job_name' in local_var_params:
            path_params['job_name'] = local_var_params['job_name']

        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;charset=UTF-8'])

        auth_settings = []

        return self.call_api(
            resource_path='/v1.1/{project_id}/clusters/{cluster_id}/cdm/job/{job_name}',
            method='PUT',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='UpdateJobResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def update_link(self, request):
        """修改连接

        修改连接接口。

        :param UpdateLinkRequest request
        :return: UpdateLinkResponse
        """
        return self.update_link_with_http_info(request)

    def update_link_with_http_info(self, request):
        """修改连接

        修改连接接口。

        :param UpdateLinkRequest request
        :return: UpdateLinkResponse
        """

        all_params = ['cluster_id', 'link_name', 'cdm_update_link_req']
        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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_id']
        if 'link_name' in local_var_params:
            path_params['link_name'] = local_var_params['link_name']

        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;charset=UTF-8'])

        auth_settings = []

        return self.call_api(
            resource_path='/v1.1/{project_id}/clusters/{cluster_id}/cdm/link/{link_name}',
            method='PUT',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='UpdateLinkResponse',
            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)

# 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 CdmClient(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(CdmClient, self).__init__()
        self.model_package = importlib.import_module("huaweicloudsdkcdm.v1.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__ != "CdmClient":
            raise TypeError("client type error, support client type is CdmClient")

        return ClientBuilder(clazz)

    def create_and_start_random_cluster_job(self, request):
        """随机集群创建作业并执行

        随机集群创建作业并执行接口。

        :param CreateAndStartRandomClusterJobRequest request
        :return: CreateAndStartRandomClusterJobResponse
        """
        return self.create_and_start_random_cluster_job_with_http_info(request)

    def create_and_start_random_cluster_job_with_http_info(self, request):
        """随机集群创建作业并执行

        随机集群创建作业并执行接口。

        :param CreateAndStartRandomClusterJobRequest request
        :return: CreateAndStartRandomClusterJobResponse
        """

        all_params = ['x_language', 'cdm_random_create_and_start_job_json_req']
        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()

        response_headers = []

        header_params['Content-Type'] = http_utils.select_header_content_type(
            ['application/json;charset=UTF-8'])

        auth_settings = []

        return self.call_api(
            resource_path='/v1.1/{project_id}/clusters/job',
            method='POST',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='CreateAndStartRandomClusterJobResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def create_cluster(self, request):
        """创建集群

        创建集群接口。

        :param CreateClusterRequest request
        :return: CreateClusterResponse
        """
        return self.create_cluster_with_http_info(request)

    def create_cluster_with_http_info(self, request):
        """创建集群

        创建集群接口。

        :param CreateClusterRequest request
        :return: CreateClusterResponse
        """

        all_params = ['x_language', 'cdm_create_cluster_req']
        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()

        response_headers = []

        header_params['Content-Type'] = http_utils.select_header_content_type(
            ['application/json;charset=UTF-8'])

        auth_settings = []

        return self.call_api(
            resource_path='/v1.1/{project_id}/clusters',
            method='POST',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='CreateClusterResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def create_job(self, request):
        """指定集群创建作业

        指定集群创建作业接口。

        :param CreateJobRequest request
        :return: CreateJobResponse
        """
        return self.create_job_with_http_info(request)

    def create_job_with_http_info(self, request):
        """指定集群创建作业

        指定集群创建作业接口。

        :param CreateJobRequest request
        :return: CreateJobResponse
        """

        all_params = ['cluster_id', 'cdm_start_job_json_req']
        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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_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;charset=UTF-8'])

        auth_settings = []

        return self.call_api(
            resource_path='/v1.1/{project_id}/clusters/{cluster_id}/cdm/job',
            method='POST',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='CreateJobResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def create_link(self, request):
        """创建连接

        创建连接接口。

        :param CreateLinkRequest request
        :return: CreateLinkResponse
        """
        return self.create_link_with_http_info(request)

    def create_link_with_http_info(self, request):
        """创建连接

        创建连接接口。

        :param CreateLinkRequest request
        :return: CreateLinkResponse
        """

        all_params = ['cluster_id', 'cdm_create_link_req', 'validate']
        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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_id']

        query_params = []
        if 'validate' in local_var_params:
            query_params.append(('validate', local_var_params['validate']))

        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;charset=UTF-8'])

        auth_settings = []

        return self.call_api(
            resource_path='/v1.1/{project_id}/clusters/{cluster_id}/cdm/link',
            method='POST',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='CreateLinkResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def delete_cluster(self, request):
        """删除集群

        删除集群接口。

        :param DeleteClusterRequest request
        :return: DeleteClusterResponse
        """
        return self.delete_cluster_with_http_info(request)

    def delete_cluster_with_http_info(self, request):
        """删除集群

        删除集群接口。

        :param DeleteClusterRequest request
        :return: DeleteClusterResponse
        """

        all_params = ['cluster_id', 'cdm_delete_cluster_req']
        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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_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;charset=UTF-8'])

        auth_settings = []

        return self.call_api(
            resource_path='/v1.1/{project_id}/clusters/{cluster_id}',
            method='DELETE',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='DeleteClusterResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def delete_job(self, request):
        """删除作业

        删除作业接口。

        :param DeleteJobRequest request
        :return: DeleteJobResponse
        """
        return self.delete_job_with_http_info(request)

    def delete_job_with_http_info(self, request):
        """删除作业

        删除作业接口。

        :param DeleteJobRequest request
        :return: DeleteJobResponse
        """

        all_params = ['cluster_id', 'job_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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_id']
        if 'job_name' in local_var_params:
            path_params['job_name'] = local_var_params['job_name']

        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='/v1.1/{project_id}/clusters/{cluster_id}/cdm/job/{job_name}',
            method='DELETE',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='DeleteJobResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def delete_link(self, request):
        """删除连接

        删除连接接口。

        :param DeleteLinkRequest request
        :return: DeleteLinkResponse
        """
        return self.delete_link_with_http_info(request)

    def delete_link_with_http_info(self, request):
        """删除连接

        删除连接接口。

        :param DeleteLinkRequest request
        :return: DeleteLinkResponse
        """

        all_params = ['cluster_id', 'link_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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_id']
        if 'link_name' in local_var_params:
            path_params['link_name'] = local_var_params['link_name']

        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='/v1.1/{project_id}/clusters/{cluster_id}/cdm/link/{link_name}',
            method='DELETE',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='DeleteLinkResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def list_clusters(self, request):
        """查询集群列表

        查询集群列表接口。

        :param ListClustersRequest request
        :return: ListClustersResponse
        """
        return self.list_clusters_with_http_info(request)

    def list_clusters_with_http_info(self, request):
        """查询集群列表

        查询集群列表接口。

        :param ListClustersRequest request
        :return: ListClustersResponse
        """

        all_params = []
        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 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='/v1.1/{project_id}/clusters',
            method='GET',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='ListClustersResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def restart_cluster(self, request):
        """重启集群

        重启集群接口。

        :param RestartClusterRequest request
        :return: RestartClusterResponse
        """
        return self.restart_cluster_with_http_info(request)

    def restart_cluster_with_http_info(self, request):
        """重启集群

        重启集群接口。

        :param RestartClusterRequest request
        :return: RestartClusterResponse
        """

        all_params = ['cluster_id', 'cdm_restart_cluster_req']
        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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_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;charset=UTF-8'])

        auth_settings = []

        return self.call_api(
            resource_path='/v1.1/{project_id}/clusters/{cluster_id}/action',
            method='POST',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='RestartClusterResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def show_cluster_detail(self, request):
        """查询集群详情

        查询集群详情接口。

        :param ShowClusterDetailRequest request
        :return: ShowClusterDetailResponse
        """
        return self.show_cluster_detail_with_http_info(request)

    def show_cluster_detail_with_http_info(self, request):
        """查询集群详情

        查询集群详情接口。

        :param ShowClusterDetailRequest request
        :return: ShowClusterDetailResponse
        """

        all_params = ['cluster_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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_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='/v1.1/{project_id}/clusters/{cluster_id}',
            method='GET',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='ShowClusterDetailResponse',
            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 = ['cluster_id', 'job_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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_id']
        if 'job_name' in local_var_params:
            path_params['job_name'] = local_var_params['job_name']

        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='/v1.1/{project_id}/clusters/{cluster_id}/cdm/job/{job_name}/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_jobs(self, request):
        """查询作业

        查询作业接口。

        :param ShowJobsRequest request
        :return: ShowJobsResponse
        """
        return self.show_jobs_with_http_info(request)

    def show_jobs_with_http_info(self, request):
        """查询作业

        查询作业接口。

        :param ShowJobsRequest request
        :return: ShowJobsResponse
        """

        all_params = ['cluster_id', 'job_name', 'filter', 'page_no', 'page_size', 'job_type']
        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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_id']
        if 'job_name' in local_var_params:
            path_params['job_name'] = local_var_params['job_name']

        query_params = []
        if 'filter' in local_var_params:
            query_params.append(('filter', local_var_params['filter']))
        if 'page_no' in local_var_params:
            query_params.append(('page_no', local_var_params['page_no']))
        if 'page_size' in local_var_params:
            query_params.append(('page_size', local_var_params['page_size']))
        if 'job_type' in local_var_params:
            query_params.append(('jobType', local_var_params['job_type']))

        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='/v1.1/{project_id}/clusters/{cluster_id}/cdm/job/{job_name}',
            method='GET',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='ShowJobsResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def show_link(self, request):
        """查询连接

        查询连接接口。

        :param ShowLinkRequest request
        :return: ShowLinkResponse
        """
        return self.show_link_with_http_info(request)

    def show_link_with_http_info(self, request):
        """查询连接

        查询连接接口。

        :param ShowLinkRequest request
        :return: ShowLinkResponse
        """

        all_params = ['cluster_id', 'link_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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_id']
        if 'link_name' in local_var_params:
            path_params['link_name'] = local_var_params['link_name']

        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='/v1.1/{project_id}/clusters/{cluster_id}/cdm/link/{link_name}',
            method='GET',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='ShowLinkResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def show_submissions(self, request):
        """查询作业执行历史

        查询作业执行历史接口。

        :param ShowSubmissionsRequest request
        :return: ShowSubmissionsResponse
        """
        return self.show_submissions_with_http_info(request)

    def show_submissions_with_http_info(self, request):
        """查询作业执行历史

        查询作业执行历史接口。

        :param ShowSubmissionsRequest request
        :return: ShowSubmissionsResponse
        """

        all_params = ['cluster_id', 'jname']
        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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_id']

        query_params = []
        if 'jname' in local_var_params:
            query_params.append(('jname', local_var_params['jname']))

        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='/v1.1/{project_id}/clusters/{cluster_id}/cdm/submissions',
            method='GET',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='ShowSubmissionsResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def start_cluster(self, request):
        """启动集群

        启动集群接口。

        :param StartClusterRequest request
        :return: StartClusterResponse
        """
        return self.start_cluster_with_http_info(request)

    def start_cluster_with_http_info(self, request):
        """启动集群

        启动集群接口。

        :param StartClusterRequest request
        :return: StartClusterResponse
        """

        all_params = ['cluster_id', 'cdm_start_cluster_req']
        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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_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;charset=UTF-8'])

        auth_settings = []

        return self.call_api(
            resource_path='/v1.1/{project_id}/clusters/{cluster_id}/action',
            method='POST',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='StartClusterResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def start_job(self, request):
        """启动作业

        启动作业接口。

        :param StartJobRequest request
        :return: StartJobResponse
        """
        return self.start_job_with_http_info(request)

    def start_job_with_http_info(self, request):
        """启动作业

        启动作业接口。

        :param StartJobRequest request
        :return: StartJobResponse
        """

        all_params = ['cluster_id', 'job_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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_id']
        if 'job_name' in local_var_params:
            path_params['job_name'] = local_var_params['job_name']

        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='/v1.1/{project_id}/clusters/{cluster_id}/cdm/job/{job_name}/start',
            method='PUT',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='StartJobResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def stop_cluster(self, request):
        """停止集群

        停止集群接口。

        :param StopClusterRequest request
        :return: StopClusterResponse
        """
        return self.stop_cluster_with_http_info(request)

    def stop_cluster_with_http_info(self, request):
        """停止集群

        停止集群接口。

        :param StopClusterRequest request
        :return: StopClusterResponse
        """

        all_params = ['cluster_id', 'cdm_stop_cluster_req']
        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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_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;charset=UTF-8'])

        auth_settings = []

        return self.call_api(
            resource_path='/v1.1/{project_id}/clusters/{cluster_id}/action',
            method='POST',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='StopClusterResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def stop_job(self, request):
        """停止作业

        停止作业接口。

        :param StopJobRequest request
        :return: StopJobResponse
        """
        return self.stop_job_with_http_info(request)

    def stop_job_with_http_info(self, request):
        """停止作业

        停止作业接口。

        :param StopJobRequest request
        :return: StopJobResponse
        """

        all_params = ['cluster_id', 'job_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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_id']
        if 'job_name' in local_var_params:
            path_params['job_name'] = local_var_params['job_name']

        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='/v1.1/{project_id}/clusters/{cluster_id}/cdm/job/{job_name}/stop',
            method='PUT',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='StopJobResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def update_job(self, request):
        """修改作业

        修改作业接口。

        :param UpdateJobRequest request
        :return: UpdateJobResponse
        """
        return self.update_job_with_http_info(request)

    def update_job_with_http_info(self, request):
        """修改作业

        修改作业接口。

        :param UpdateJobRequest request
        :return: UpdateJobResponse
        """

        all_params = ['cluster_id', 'job_name', 'cdm_update_job_json_req']
        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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_id']
        if 'job_name' in local_var_params:
            path_params['job_name'] = local_var_params['job_name']

        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;charset=UTF-8'])

        auth_settings = []

        return self.call_api(
            resource_path='/v1.1/{project_id}/clusters/{cluster_id}/cdm/job/{job_name}',
            method='PUT',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='UpdateJobResponse',
            response_headers=response_headers,
            auth_settings=auth_settings,
            collection_formats=collection_formats,
            request_type=request.__class__.__name__)


    def update_link(self, request):
        """修改连接

        修改连接接口。

        :param UpdateLinkRequest request
        :return: UpdateLinkResponse
        """
        return self.update_link_with_http_info(request)

    def update_link_with_http_info(self, request):
        """修改连接

        修改连接接口。

        :param UpdateLinkRequest request
        :return: UpdateLinkResponse
        """

        all_params = ['cluster_id', 'link_name', 'cdm_update_link_req']
        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 'cluster_id' in local_var_params:
            path_params['cluster_id'] = local_var_params['cluster_id']
        if 'link_name' in local_var_params:
            path_params['link_name'] = local_var_params['link_name']

        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;charset=UTF-8'])

        auth_settings = []

        return self.call_api(
            resource_path='/v1.1/{project_id}/clusters/{cluster_id}/cdm/link/{link_name}',
            method='PUT',
            path_params=path_params,
            query_params=query_params,
            header_params=header_params,
            body=body_params,
            post_params=form_params,
            response_type='UpdateLinkResponse',
            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)

# coding: utf-8 :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. 随机集群创建作业并执行          随机集群创建作业并执行接口。          :param CreateAndStartRandomClusterJobRequest request         :return: CreateAndStartRandomClusterJobResponse 随机集群创建作业并执行          随机集群创建作业并执行接口。          :param CreateAndStartRandomClusterJobRequest request         :return: CreateAndStartRandomClusterJobResponse 创建集群          创建集群接口。          :param CreateClusterRequest request         :return: CreateClusterResponse 创建集群          创建集群接口。          :param CreateClusterRequest request         :return: CreateClusterResponse 指定集群创建作业          指定集群创建作业接口。          :param CreateJobRequest request         :return: CreateJobResponse 指定集群创建作业          指定集群创建作业接口。          :param CreateJobRequest request         :return: CreateJobResponse 创建连接          创建连接接口。          :param CreateLinkRequest request         :return: CreateLinkResponse 创建连接          创建连接接口。          :param CreateLinkRequest request         :return: CreateLinkResponse 删除集群          删除集群接口。          :param DeleteClusterRequest request         :return: DeleteClusterResponse 删除集群          删除集群接口。          :param DeleteClusterRequest request         :return: DeleteClusterResponse 删除作业          删除作业接口。          :param DeleteJobRequest request         :return: DeleteJobResponse 删除作业          删除作业接口。          :param DeleteJobRequest request         :return: DeleteJobResponse 删除连接          删除连接接口。          :param DeleteLinkRequest request         :return: DeleteLinkResponse 删除连接          删除连接接口。          :param DeleteLinkRequest request         :return: DeleteLinkResponse 查询集群列表          查询集群列表接口。          :param ListClustersRequest request         :return: ListClustersResponse 查询集群列表          查询集群列表接口。          :param ListClustersRequest request         :return: ListClustersResponse 重启集群          重启集群接口。          :param RestartClusterRequest request         :return: RestartClusterResponse 重启集群          重启集群接口。          :param RestartClusterRequest request         :return: RestartClusterResponse 查询集群详情          查询集群详情接口。          :param ShowClusterDetailRequest request         :return: ShowClusterDetailResponse 查询集群详情          查询集群详情接口。          :param ShowClusterDetailRequest request         :return: ShowClusterDetailResponse 查询作业状态          查询作业状态接口。          :param ShowJobStatusRequest request         :return: ShowJobStatusResponse 查询作业状态          查询作业状态接口。          :param ShowJobStatusRequest request         :return: ShowJobStatusResponse 查询作业          查询作业接口。          :param ShowJobsRequest request         :return: ShowJobsResponse 查询作业          查询作业接口。          :param ShowJobsRequest request         :return: ShowJobsResponse 查询连接          查询连接接口。          :param ShowLinkRequest request         :return: ShowLinkResponse 查询连接          查询连接接口。          :param ShowLinkRequest request         :return: ShowLinkResponse 查询作业执行历史          查询作业执行历史接口。          :param ShowSubmissionsRequest request         :return: ShowSubmissionsResponse 查询作业执行历史          查询作业执行历史接口。          :param ShowSubmissionsRequest request         :return: ShowSubmissionsResponse 启动集群          启动集群接口。          :param StartClusterRequest request         :return: StartClusterResponse 启动集群          启动集群接口。          :param StartClusterRequest request         :return: StartClusterResponse 启动作业          启动作业接口。          :param StartJobRequest request         :return: StartJobResponse 启动作业          启动作业接口。          :param StartJobRequest request         :return: StartJobResponse 停止集群          停止集群接口。          :param StopClusterRequest request         :return: StopClusterResponse 停止集群          停止集群接口。          :param StopClusterRequest request         :return: StopClusterResponse 停止作业          停止作业接口。          :param StopJobRequest request         :return: StopJobResponse 停止作业          停止作业接口。          :param StopJobRequest request         :return: StopJobResponse 修改作业          修改作业接口。          :param UpdateJobRequest request         :return: UpdateJobResponse 修改作业          修改作业接口。          :param UpdateJobRequest request         :return: UpdateJobResponse 修改连接          修改连接接口。          :param UpdateLinkRequest request         :return: UpdateLinkResponse 修改连接          修改连接接口。          :param UpdateLinkRequest request         :return: UpdateLinkResponse 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.