# coding: utf-8

"""
    herd

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)  # noqa: E501

    OpenAPI spec version: 0.178.0-SNAPSHOT
    Generated by: https://openapi-generator.tech
"""


from __future__ import absolute_import

import re  # noqa: F401

# python 2 and python 3 compatibility library
import six

from herdsdk.api_client import ApiClient


class JobApi(object):
    """NOTE: This class is auto generated by OpenAPI Generator
    Ref: https://openapi-generator.tech

    Do not edit the class manually.
    """

    def __init__(self, api_client=None):
        if api_client is None:
            api_client = ApiClient()
        self.api_client = api_client

    def job_create_job(self, job_create_request, **kwargs):  # noqa: E501
        """createJob  # noqa: E501

        Creates and starts a new job asynchronously. <p>Requires EXECUTE permission on namespace</p>  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.job_create_job(job_create_request, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param JobCreateRequest job_create_request: the information needed to create the job. (required)
        :return: Job
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.job_create_job_with_http_info(job_create_request, **kwargs)  # noqa: E501
        else:
            (data) = self.job_create_job_with_http_info(job_create_request, **kwargs)  # noqa: E501
            return data

    def job_create_job_with_http_info(self, job_create_request, **kwargs):  # noqa: E501
        """createJob  # noqa: E501

        Creates and starts a new job asynchronously. <p>Requires EXECUTE permission on namespace</p>  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.job_create_job_with_http_info(job_create_request, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param JobCreateRequest job_create_request: the information needed to create the job. (required)
        :return: Job
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['job_create_request']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        for key, val in six.iteritems(local_var_params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method job_create_job" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'job_create_request' is set
        if ('job_create_request' not in local_var_params or
                local_var_params['job_create_request'] is None):
            raise ValueError("Missing the required parameter `job_create_request` when calling `job_create_job`")  # noqa: E501

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'job_create_request' in local_var_params:
            body_params = local_var_params['job_create_request']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json', 'application/xml'])  # noqa: E501

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['application/json', 'application/xml'])  # noqa: E501

        # Authentication setting
        auth_settings = ['basicAuth', 'oauthAuth']  # noqa: E501

        return self.api_client.call_api(
            '/jobs', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Job',  # noqa: E501
            auth_settings=auth_settings,
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats=collection_formats)

    def job_delete_job(self, id, job_delete_request, **kwargs):  # noqa: E501
        """deleteJob  # noqa: E501

        Deletes a currently running job and preserves the job state in history. <p>Requires EXECUTE permission on namespace</p>  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.job_delete_job(id, job_delete_request, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str id: The job id (required)
        :param JobDeleteRequest job_delete_request: The delete request (required)
        :return: Job
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.job_delete_job_with_http_info(id, job_delete_request, **kwargs)  # noqa: E501
        else:
            (data) = self.job_delete_job_with_http_info(id, job_delete_request, **kwargs)  # noqa: E501
            return data

    def job_delete_job_with_http_info(self, id, job_delete_request, **kwargs):  # noqa: E501
        """deleteJob  # noqa: E501

        Deletes a currently running job and preserves the job state in history. <p>Requires EXECUTE permission on namespace</p>  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.job_delete_job_with_http_info(id, job_delete_request, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str id: The job id (required)
        :param JobDeleteRequest job_delete_request: The delete request (required)
        :return: Job
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['id', 'job_delete_request']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        for key, val in six.iteritems(local_var_params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method job_delete_job" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'id' is set
        if ('id' not in local_var_params or
                local_var_params['id'] is None):
            raise ValueError("Missing the required parameter `id` when calling `job_delete_job`")  # noqa: E501
        # verify the required parameter 'job_delete_request' is set
        if ('job_delete_request' not in local_var_params or
                local_var_params['job_delete_request'] is None):
            raise ValueError("Missing the required parameter `job_delete_request` when calling `job_delete_job`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'id' in local_var_params:
            path_params['id'] = local_var_params['id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'job_delete_request' in local_var_params:
            body_params = local_var_params['job_delete_request']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json', 'application/xml'])  # noqa: E501

        # Authentication setting
        auth_settings = ['basicAuth', 'oauthAuth']  # noqa: E501

        return self.api_client.call_api(
            '/jobs/ids/{id}', 'DELETE',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Job',  # noqa: E501
            auth_settings=auth_settings,
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats=collection_formats)

    def job_get_job(self, id, **kwargs):  # noqa: E501
        """getJob  # noqa: E501

        Gets the details of a previously submitted job. <p>Requires READ permission on namespace</p>  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.job_get_job(id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str id: the job id. (required)
        :param bool verbose:
        :return: Job
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.job_get_job_with_http_info(id, **kwargs)  # noqa: E501
        else:
            (data) = self.job_get_job_with_http_info(id, **kwargs)  # noqa: E501
            return data

    def job_get_job_with_http_info(self, id, **kwargs):  # noqa: E501
        """getJob  # noqa: E501

        Gets the details of a previously submitted job. <p>Requires READ permission on namespace</p>  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.job_get_job_with_http_info(id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str id: the job id. (required)
        :param bool verbose:
        :return: Job
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['id', 'verbose']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        for key, val in six.iteritems(local_var_params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method job_get_job" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'id' is set
        if ('id' not in local_var_params or
                local_var_params['id'] is None):
            raise ValueError("Missing the required parameter `id` when calling `job_get_job`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'id' in local_var_params:
            path_params['id'] = local_var_params['id']  # noqa: E501

        query_params = []
        if 'verbose' in local_var_params:
            query_params.append(('verbose', local_var_params['verbose']))  # noqa: E501

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json', 'application/xml'])  # noqa: E501

        # Authentication setting
        auth_settings = ['basicAuth', 'oauthAuth']  # noqa: E501

        return self.api_client.call_api(
            '/jobs/ids/{id}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Job',  # noqa: E501
            auth_settings=auth_settings,
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats=collection_formats)

    def job_get_jobs(self, **kwargs):  # noqa: E501
        """getJobs  # noqa: E501

        <p>Gets a list of job executions based on the specified filter parameters.</p> <p>Jobs' namespace to which you do not have READ permissions to will be omitted from the result.</p>  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.job_get_jobs(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str namespace: an optional namespace filter
        :param str job_name: an optional job name filter
        :param str status: an optional job status filter
        :param str start_time: an optional start time filter (ex. 2015, 2015-12, 2015-12-28, 2015-12-12T3:4:5)
        :param str end_time: an optional end time filter (ex. 2015, 2015-12, 2015-12-28, 2015-12-12T3:4:5)
        :return: JobSummaries
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.job_get_jobs_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.job_get_jobs_with_http_info(**kwargs)  # noqa: E501
            return data

    def job_get_jobs_with_http_info(self, **kwargs):  # noqa: E501
        """getJobs  # noqa: E501

        <p>Gets a list of job executions based on the specified filter parameters.</p> <p>Jobs' namespace to which you do not have READ permissions to will be omitted from the result.</p>  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.job_get_jobs_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str namespace: an optional namespace filter
        :param str job_name: an optional job name filter
        :param str status: an optional job status filter
        :param str start_time: an optional start time filter (ex. 2015, 2015-12, 2015-12-28, 2015-12-12T3:4:5)
        :param str end_time: an optional end time filter (ex. 2015, 2015-12, 2015-12-28, 2015-12-12T3:4:5)
        :return: JobSummaries
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['namespace', 'job_name', 'status', 'start_time', 'end_time']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        for key, val in six.iteritems(local_var_params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method job_get_jobs" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'namespace' in local_var_params:
            query_params.append(('namespace', local_var_params['namespace']))  # noqa: E501
        if 'job_name' in local_var_params:
            query_params.append(('jobName', local_var_params['job_name']))  # noqa: E501
        if 'status' in local_var_params:
            query_params.append(('status', local_var_params['status']))  # noqa: E501
        if 'start_time' in local_var_params:
            query_params.append(('startTime', local_var_params['start_time']))  # noqa: E501
        if 'end_time' in local_var_params:
            query_params.append(('endTime', local_var_params['end_time']))  # noqa: E501

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json', 'application/xml'])  # noqa: E501

        # Authentication setting
        auth_settings = ['basicAuth', 'oauthAuth']  # noqa: E501

        return self.api_client.call_api(
            '/jobs', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='JobSummaries',  # noqa: E501
            auth_settings=auth_settings,
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats=collection_formats)

    def job_signal_job(self, job_signal_request, **kwargs):  # noqa: E501
        """signalJob  # noqa: E501

        Signals the job with the receive task. <p>Requires EXECUTE permission on namespace</p>  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.job_signal_job(job_signal_request, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param JobSignalRequest job_signal_request: the information needed to signal the job. (required)
        :return: Job
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.job_signal_job_with_http_info(job_signal_request, **kwargs)  # noqa: E501
        else:
            (data) = self.job_signal_job_with_http_info(job_signal_request, **kwargs)  # noqa: E501
            return data

    def job_signal_job_with_http_info(self, job_signal_request, **kwargs):  # noqa: E501
        """signalJob  # noqa: E501

        Signals the job with the receive task. <p>Requires EXECUTE permission on namespace</p>  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.job_signal_job_with_http_info(job_signal_request, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param JobSignalRequest job_signal_request: the information needed to signal the job. (required)
        :return: Job
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['job_signal_request']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        for key, val in six.iteritems(local_var_params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method job_signal_job" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'job_signal_request' is set
        if ('job_signal_request' not in local_var_params or
                local_var_params['job_signal_request'] is None):
            raise ValueError("Missing the required parameter `job_signal_request` when calling `job_signal_job`")  # noqa: E501

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'job_signal_request' in local_var_params:
            body_params = local_var_params['job_signal_request']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json', 'application/xml'])  # noqa: E501

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['application/json', 'application/xml'])  # noqa: E501

        # Authentication setting
        auth_settings = ['basicAuth', 'oauthAuth']  # noqa: E501

        return self.api_client.call_api(
            '/jobs/signal', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Job',  # noqa: E501
            auth_settings=auth_settings,
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats=collection_formats)

    def job_update_job(self, id, job_update_request, **kwargs):  # noqa: E501
        """updateJob  # noqa: E501

        Activates or suspends a job execution. <p>Requires EXECUTE permission on namespace</p>  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.job_update_job(id, job_update_request, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str id: the job id (required)
        :param JobUpdateRequest job_update_request: the job update request (required)
        :return: Job
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.job_update_job_with_http_info(id, job_update_request, **kwargs)  # noqa: E501
        else:
            (data) = self.job_update_job_with_http_info(id, job_update_request, **kwargs)  # noqa: E501
            return data

    def job_update_job_with_http_info(self, id, job_update_request, **kwargs):  # noqa: E501
        """updateJob  # noqa: E501

        Activates or suspends a job execution. <p>Requires EXECUTE permission on namespace</p>  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.job_update_job_with_http_info(id, job_update_request, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str id: the job id (required)
        :param JobUpdateRequest job_update_request: the job update request (required)
        :return: Job
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['id', 'job_update_request']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        for key, val in six.iteritems(local_var_params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method job_update_job" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'id' is set
        if ('id' not in local_var_params or
                local_var_params['id'] is None):
            raise ValueError("Missing the required parameter `id` when calling `job_update_job`")  # noqa: E501
        # verify the required parameter 'job_update_request' is set
        if ('job_update_request' not in local_var_params or
                local_var_params['job_update_request'] is None):
            raise ValueError("Missing the required parameter `job_update_request` when calling `job_update_job`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'id' in local_var_params:
            path_params['id'] = local_var_params['id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'job_update_request' in local_var_params:
            body_params = local_var_params['job_update_request']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json', 'application/xml'])  # noqa: E501

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['application/json', 'application/xml'])  # noqa: E501

        # Authentication setting
        auth_settings = ['basicAuth', 'oauthAuth']  # noqa: E501

        return self.api_client.call_api(
            '/jobs/ids/{id}', 'PUT',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Job',  # noqa: E501
            auth_settings=auth_settings,
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats=collection_formats)
