# coding: utf-8

"""
    Cloudera Manager API

    <h1>Cloudera Manager API v57</h1>       <p>Introduced in Cloudera Manager 7.13.1</p>       <p><a href=\"http://www.cloudera.com/documentation.html\">Cloudera Product Documentation</a></p>  # noqa: E501

    OpenAPI spec version: 7.13.1
    
    Generated by: https://github.com/swagger-api/swagger-codegen.git
"""

from __future__ import absolute_import

import re  # noqa: F401

# python 2 and python 3 compatibility library
import six

from cm_client.api_client import ApiClient


class CommandsResourceApi(object):
    """NOTE: This class is auto generated by the swagger code generator program.

    Do not edit the class manually.
    Ref: https://github.com/swagger-api/swagger-codegen
    """

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

    def abort_command(self, command_id, **kwargs):  # noqa: E501
        """Abort a running command.  # noqa: E501

        Abort a running command.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.abort_command(command_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int command_id: The command id. (required)
        :return: ApiCommand
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.abort_command_with_http_info(command_id, **kwargs)  # noqa: E501
        else:
            (data) = self.abort_command_with_http_info(command_id, **kwargs)  # noqa: E501
            return data

    def abort_command_with_http_info(self, command_id, **kwargs):  # noqa: E501
        """Abort a running command.  # noqa: E501

        Abort a running command.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.abort_command_with_http_info(command_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int command_id: The command id. (required)
        :return: ApiCommand
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

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

        collection_formats = {}

        path_params = {}
        if 'command_id' in params:
            path_params['commandId'] = params['command_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

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

        # Authentication setting
        auth_settings = ['basic']  # noqa: E501

        return self.api_client.call_api(
            '/commands/{commandId}/abort', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='ApiCommand',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def find_command_by_correlation_id(self, correlation_id, **kwargs):  # noqa: E501
        """Retrieve command by the correlation ID that was provided at command creation.  # noqa: E501

        Retrieve command by the correlation ID that was provided at command creation. Used to recover command references when the command ID is not available.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.find_command_by_correlation_id(correlation_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str correlation_id: Correlation ID provided at command creation (required)
        :param int start_time: Timestamp from which the command was started
        :return: ApiCommand
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.find_command_by_correlation_id_with_http_info(correlation_id, **kwargs)  # noqa: E501
        else:
            (data) = self.find_command_by_correlation_id_with_http_info(correlation_id, **kwargs)  # noqa: E501
            return data

    def find_command_by_correlation_id_with_http_info(self, correlation_id, **kwargs):  # noqa: E501
        """Retrieve command by the correlation ID that was provided at command creation.  # noqa: E501

        Retrieve command by the correlation ID that was provided at command creation. Used to recover command references when the command ID is not available.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.find_command_by_correlation_id_with_http_info(correlation_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str correlation_id: Correlation ID provided at command creation (required)
        :param int start_time: Timestamp from which the command was started
        :return: ApiCommand
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['correlation_id', 'start_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')

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

        collection_formats = {}

        path_params = {}
        if 'correlation_id' in params:
            path_params['correlationId'] = params['correlation_id']  # noqa: E501

        query_params = []
        if 'start_time' in params:
            query_params.append(('startTime', params['start_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'])  # noqa: E501

        # Authentication setting
        auth_settings = ['basic']  # noqa: E501

        return self.api_client.call_api(
            '/commands/commandByCorrelationId/{correlationId}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='ApiCommand',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def get_command_result_data(self, command_id, **kwargs):  # noqa: E501
        """Download the end result of a command.  # noqa: E501

        Download the end result of a command.  Content-Type header is explicitly set in the implementation instead of using annotation. In case the MIME type is not set for the command result, application/octet-stream is set.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_command_result_data(command_id, async_req=True)
        >>> result = thread.get()

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

    def get_command_result_data_with_http_info(self, command_id, **kwargs):  # noqa: E501
        """Download the end result of a command.  # noqa: E501

        Download the end result of a command.  Content-Type header is explicitly set in the implementation instead of using annotation. In case the MIME type is not set for the command result, application/octet-stream is set.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_command_result_data_with_http_info(command_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int command_id: The command id. (required)
        :return: str
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

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

        collection_formats = {}

        path_params = {}
        if 'command_id' in params:
            path_params['commandId'] = params['command_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

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

        # Authentication setting
        auth_settings = ['basic']  # noqa: E501

        return self.api_client.call_api(
            '/commands/{commandId}/download', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='str',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def get_command_with_steps(self, command_id, **kwargs):  # noqa: E501
        """Retrieve detailed information of an asynchronous command including the command steps.  # noqa: E501

        Retrieve detailed information of an asynchronous command including the command steps.  <p>Cloudera Manager keeps the results and statuses of asynchronous commands, which have non-negative command IDs. On the other hand, synchronous commands complete immediately, and their results are passed back in the return object of the command execution API call. Outside of that return object, there is no way to check the result of a synchronous command.</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.get_command_with_steps(command_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int command_id: The command id. (required)
        :return: ApiCommandWithSteps
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_command_with_steps_with_http_info(command_id, **kwargs)  # noqa: E501
        else:
            (data) = self.get_command_with_steps_with_http_info(command_id, **kwargs)  # noqa: E501
            return data

    def get_command_with_steps_with_http_info(self, command_id, **kwargs):  # noqa: E501
        """Retrieve detailed information of an asynchronous command including the command steps.  # noqa: E501

        Retrieve detailed information of an asynchronous command including the command steps.  <p>Cloudera Manager keeps the results and statuses of asynchronous commands, which have non-negative command IDs. On the other hand, synchronous commands complete immediately, and their results are passed back in the return object of the command execution API call. Outside of that return object, there is no way to check the result of a synchronous command.</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.get_command_with_steps_with_http_info(command_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int command_id: The command id. (required)
        :return: ApiCommandWithSteps
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

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

        collection_formats = {}

        path_params = {}
        if 'command_id' in params:
            path_params['commandId'] = params['command_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

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

        # Authentication setting
        auth_settings = ['basic']  # noqa: E501

        return self.api_client.call_api(
            '/commands/{commandId}/steps', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='ApiCommandWithSteps',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def get_standard_error(self, command_id, **kwargs):  # noqa: E501
        """Download a zip-compressed archive of standard error outputs for the command's one-off processes.  # noqa: E501

        Download a zip-compressed archive of standard error outputs for the command's one-off processes.  Log files are returned zipped together.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_standard_error(command_id, async_req=True)
        >>> result = thread.get()

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

    def get_standard_error_with_http_info(self, command_id, **kwargs):  # noqa: E501
        """Download a zip-compressed archive of standard error outputs for the command's one-off processes.  # noqa: E501

        Download a zip-compressed archive of standard error outputs for the command's one-off processes.  Log files are returned zipped together.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_standard_error_with_http_info(command_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int command_id: The command id. (required)
        :return: str
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

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

        collection_formats = {}

        path_params = {}
        if 'command_id' in params:
            path_params['commandId'] = params['command_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/octet-stream'])  # noqa: E501

        # Authentication setting
        auth_settings = ['basic']  # noqa: E501

        return self.api_client.call_api(
            '/commands/{commandId}/logs/stderr', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='str',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def get_standard_output(self, command_id, **kwargs):  # noqa: E501
        """Download a zip-compressed archive of standard outputs for the command's one-off processes.  # noqa: E501

        Download a zip-compressed archive of standard outputs for the command's one-off processes.  Log files are returned zipped together.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_standard_output(command_id, async_req=True)
        >>> result = thread.get()

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

    def get_standard_output_with_http_info(self, command_id, **kwargs):  # noqa: E501
        """Download a zip-compressed archive of standard outputs for the command's one-off processes.  # noqa: E501

        Download a zip-compressed archive of standard outputs for the command's one-off processes.  Log files are returned zipped together.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_standard_output_with_http_info(command_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int command_id: The command id. (required)
        :return: str
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

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

        collection_formats = {}

        path_params = {}
        if 'command_id' in params:
            path_params['commandId'] = params['command_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/octet-stream'])  # noqa: E501

        # Authentication setting
        auth_settings = ['basic']  # noqa: E501

        return self.api_client.call_api(
            '/commands/{commandId}/logs/stdout', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='str',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def read_command(self, command_id, **kwargs):  # noqa: E501
        """Retrieve detailed information on an asynchronous command.  # noqa: E501

        Retrieve detailed information on an asynchronous command.  <p>Cloudera Manager keeps the results and statuses of asynchronous commands, which have non-negative command IDs. On the other hand, synchronous commands complete immediately, and their results are passed back in the return object of the command execution API call. Outside of that return object, there is no way to check the result of a synchronous command.</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.read_command(command_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int command_id: The command id. (required)
        :return: ApiCommand
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.read_command_with_http_info(command_id, **kwargs)  # noqa: E501
        else:
            (data) = self.read_command_with_http_info(command_id, **kwargs)  # noqa: E501
            return data

    def read_command_with_http_info(self, command_id, **kwargs):  # noqa: E501
        """Retrieve detailed information on an asynchronous command.  # noqa: E501

        Retrieve detailed information on an asynchronous command.  <p>Cloudera Manager keeps the results and statuses of asynchronous commands, which have non-negative command IDs. On the other hand, synchronous commands complete immediately, and their results are passed back in the return object of the command execution API call. Outside of that return object, there is no way to check the result of a synchronous command.</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.read_command_with_http_info(command_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int command_id: The command id. (required)
        :return: ApiCommand
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

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

        collection_formats = {}

        path_params = {}
        if 'command_id' in params:
            path_params['commandId'] = params['command_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

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

        # Authentication setting
        auth_settings = ['basic']  # noqa: E501

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

    def read_commands(self, **kwargs):  # noqa: E501
        """Retrieve detailed information on all recent commands.  # noqa: E501

        Retrieve detailed information on all recent commands.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.read_commands(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int end_time: timestamp of the command end time
        :param int limit: command count to return (from offset)
        :param str name: the command name, unique for the command class HdfsCreateSnapshotCommand#COMMAND_NAME
        :param int offset: command position to start
        :param int start_time: timestamp of the command start time
        :param bool success: whether the command was successful, if already finished
        :return: ApiCommandList
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.read_commands_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.read_commands_with_http_info(**kwargs)  # noqa: E501
            return data

    def read_commands_with_http_info(self, **kwargs):  # noqa: E501
        """Retrieve detailed information on all recent commands.  # noqa: E501

        Retrieve detailed information on all recent commands.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.read_commands_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int end_time: timestamp of the command end time
        :param int limit: command count to return (from offset)
        :param str name: the command name, unique for the command class HdfsCreateSnapshotCommand#COMMAND_NAME
        :param int offset: command position to start
        :param int start_time: timestamp of the command start time
        :param bool success: whether the command was successful, if already finished
        :return: ApiCommandList
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['end_time', 'limit', 'name', 'offset', 'start_time', 'success']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

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

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'end_time' in params:
            query_params.append(('endTime', params['end_time']))  # noqa: E501
        if 'limit' in params:
            query_params.append(('limit', params['limit']))  # noqa: E501
        if 'name' in params:
            query_params.append(('name', params['name']))  # noqa: E501
        if 'offset' in params:
            query_params.append(('offset', params['offset']))  # noqa: E501
        if 'start_time' in params:
            query_params.append(('startTime', params['start_time']))  # noqa: E501
        if 'success' in params:
            query_params.append(('success', params['success']))  # 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'])  # noqa: E501

        # Authentication setting
        auth_settings = ['basic']  # noqa: E501

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

    def replication_report(self, command_id, **kwargs):  # noqa: E501
        """Get the replication report CSV files.  # noqa: E501

        Get the replication report CSV files.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.replication_report(command_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int command_id: The command id. (required)
        :param str type: The requested report type.
        :return: str
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.replication_report_with_http_info(command_id, **kwargs)  # noqa: E501
        else:
            (data) = self.replication_report_with_http_info(command_id, **kwargs)  # noqa: E501
            return data

    def replication_report_with_http_info(self, command_id, **kwargs):  # noqa: E501
        """Get the replication report CSV files.  # noqa: E501

        Get the replication report CSV files.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.replication_report_with_http_info(command_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int command_id: The command id. (required)
        :param str type: The requested report type.
        :return: str
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

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

        collection_formats = {}

        path_params = {}
        if 'command_id' in params:
            path_params['commandId'] = params['command_id']  # noqa: E501

        query_params = []
        if 'type' in params:
            query_params.append(('type', params['type']))  # 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'])  # noqa: E501

        # Authentication setting
        auth_settings = ['basic']  # noqa: E501

        return self.api_client.call_api(
            '/commands/{commandId}/replicationReport', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='str',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def retry(self, command_id, **kwargs):  # noqa: E501
        """Try to rerun a command.  # noqa: E501

        Try to rerun a command.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.retry(command_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int command_id: ID of the command that needs to be run. (required)
        :return: ApiCommand
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.retry_with_http_info(command_id, **kwargs)  # noqa: E501
        else:
            (data) = self.retry_with_http_info(command_id, **kwargs)  # noqa: E501
            return data

    def retry_with_http_info(self, command_id, **kwargs):  # noqa: E501
        """Try to rerun a command.  # noqa: E501

        Try to rerun a command.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.retry_with_http_info(command_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int command_id: ID of the command that needs to be run. (required)
        :return: ApiCommand
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

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

        collection_formats = {}

        path_params = {}
        if 'command_id' in params:
            path_params['commandId'] = params['command_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

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

        # Authentication setting
        auth_settings = ['basic']  # noqa: E501

        return self.api_client.call_api(
            '/commands/{commandId}/retry', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='ApiCommand',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)
