# coding: utf-8

"""
    ingestion

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

    OpenAPI spec version: 1.2.0
    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 ingestion.api_client import ApiClient
from ingestion.exceptions import (
    ApiTypeError,
    ApiValueError
)


class ThreadApi(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 getthreads(self, limit, **kwargs):  # noqa: E501
        """List All threads  # noqa: E501

        Gets a list of all `thread` entities.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.getthreads(limit, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int limit: (required)
        :param int page:
        :param str model:
        :return: list[Thread]
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.getthreads_with_http_info(limit, **kwargs)  # noqa: E501
        else:
            (data) = self.getthreads_with_http_info(limit, **kwargs)  # noqa: E501
            return data

    def getthreads_with_http_info(self, limit, **kwargs):  # noqa: E501
        """List All threads  # noqa: E501

        Gets a list of all `thread` entities.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.getthreads_with_http_info(limit, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int limit: (required)
        :param int page:
        :param str model:
        :return: list[Thread]
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['limit', 'page', 'model']  # 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 ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method getthreads" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'limit' is set
        if ('limit' not in local_var_params or
                local_var_params['limit'] is None):
            raise ApiValueError("Missing the required parameter `limit` when calling `getthreads`")  # noqa: E501

        if 'limit' in local_var_params and local_var_params['limit'] > 500:  # noqa: E501
            raise ApiValueError("Invalid value for parameter `limit` when calling `getthreads`, must be a value less than or equal to `500`")  # noqa: E501
        collection_formats = {}

        path_params = {}

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

        return self.api_client.call_api(
            '/modelthreads', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='list[Thread]',  # 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 modelthreads_thread_id_get(self, thread_id, **kwargs):  # noqa: E501
        """Get a Thread  # noqa: E501

        Gets the details of a single instance of a Thread  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.modelthreads_thread_id_get(thread_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str thread_id: The ID of the resource (required)
        :return: Thread
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.modelthreads_thread_id_get_with_http_info(thread_id, **kwargs)  # noqa: E501
        else:
            (data) = self.modelthreads_thread_id_get_with_http_info(thread_id, **kwargs)  # noqa: E501
            return data

    def modelthreads_thread_id_get_with_http_info(self, thread_id, **kwargs):  # noqa: E501
        """Get a Thread  # noqa: E501

        Gets the details of a single instance of a Thread  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.modelthreads_thread_id_get_with_http_info(thread_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str thread_id: The ID of the resource (required)
        :return: Thread
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['thread_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')

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

        collection_formats = {}

        path_params = {}
        if 'thread_id' in local_var_params:
            path_params['thread_id'] = local_var_params['thread_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 = []  # noqa: E501

        return self.api_client.call_api(
            '/modelthreads/{thread_id}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Thread',  # 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)
