# coding: utf-8

"""
    Hopsworks api

    No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)  # noqa: E501

    OpenAPI spec version: 1.1.0-SNAPSHOT
    
    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 swagger_client.api_client import ApiClient


class TensorFlowServingServiceApi(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 create_or_update(self, body, project_id, **kwargs):  # noqa: E501
        """Create or update a serving instance  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.create_or_update(body, project_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param RepresentsAServingModel body: serving specification (required)
        :param int project_id: (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.create_or_update_with_http_info(body, project_id, **kwargs)  # noqa: E501
        else:
            (data) = self.create_or_update_with_http_info(body, project_id, **kwargs)  # noqa: E501
            return data

    def create_or_update_with_http_info(self, body, project_id, **kwargs):  # noqa: E501
        """Create or update a serving instance  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.create_or_update_with_http_info(body, project_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param RepresentsAServingModel body: serving specification (required)
        :param int project_id: (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['body', 'project_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 create_or_update" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'body' is set
        if ('body' not in params or
                params['body'] is None):
            raise ValueError("Missing the required parameter `body` when calling `create_or_update`")  # noqa: E501
        # verify the required parameter 'project_id' is set
        if ('project_id' not in params or
                params['project_id'] is None):
            raise ValueError("Missing the required parameter `project_id` when calling `create_or_update`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'project_id' in params:
            path_params['projectId'] = params['project_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'body' in params:
            body_params = params['body']
        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['application/json'])  # noqa: E501

        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/project/{projectId}/serving', 'PUT',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type=None,  # 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 delete_serving(self, serving_id, project_id, **kwargs):  # noqa: E501
        """Delete a serving instance  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.delete_serving(serving_id, project_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int serving_id: Id of the serving instance (required)
        :param int project_id: (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.delete_serving_with_http_info(serving_id, project_id, **kwargs)  # noqa: E501
        else:
            (data) = self.delete_serving_with_http_info(serving_id, project_id, **kwargs)  # noqa: E501
            return data

    def delete_serving_with_http_info(self, serving_id, project_id, **kwargs):  # noqa: E501
        """Delete a serving instance  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.delete_serving_with_http_info(serving_id, project_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int serving_id: Id of the serving instance (required)
        :param int project_id: (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['serving_id', 'project_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 delete_serving" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'serving_id' is set
        if ('serving_id' not in params or
                params['serving_id'] is None):
            raise ValueError("Missing the required parameter `serving_id` when calling `delete_serving`")  # noqa: E501
        # verify the required parameter 'project_id' is set
        if ('project_id' not in params or
                params['project_id'] is None):
            raise ValueError("Missing the required parameter `project_id` when calling `delete_serving`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'serving_id' in params:
            path_params['servingId'] = params['serving_id']  # noqa: E501
        if 'project_id' in params:
            path_params['projectId'] = params['project_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/project/{projectId}/serving/{servingId}', 'DELETE',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type=None,  # 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_serving(self, serving_id, project_id, **kwargs):  # noqa: E501
        """Get info about a serving instance for the project  # 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_serving(serving_id, project_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int serving_id: Id of the Serving instance (required)
        :param int project_id: (required)
        :return: RepresentsAServingModel
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_serving_with_http_info(serving_id, project_id, **kwargs)  # noqa: E501
        else:
            (data) = self.get_serving_with_http_info(serving_id, project_id, **kwargs)  # noqa: E501
            return data

    def get_serving_with_http_info(self, serving_id, project_id, **kwargs):  # noqa: E501
        """Get info about a serving instance for the project  # 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_serving_with_http_info(serving_id, project_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int serving_id: Id of the Serving instance (required)
        :param int project_id: (required)
        :return: RepresentsAServingModel
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['serving_id', 'project_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_serving" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'serving_id' is set
        if ('serving_id' not in params or
                params['serving_id'] is None):
            raise ValueError("Missing the required parameter `serving_id` when calling `get_serving`")  # noqa: E501
        # verify the required parameter 'project_id' is set
        if ('project_id' not in params or
                params['project_id'] is None):
            raise ValueError("Missing the required parameter `project_id` when calling `get_serving`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'serving_id' in params:
            path_params['servingId'] = params['serving_id']  # noqa: E501
        if 'project_id' in params:
            path_params['projectId'] = params['project_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(
            '/project/{projectId}/serving/{servingId}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='RepresentsAServingModel',  # 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_servings(self, project_id, **kwargs):  # noqa: E501
        """Get the list of serving instances for the project  # 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_servings(project_id, async_req=True)
        >>> result = thread.get()

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

    def get_servings_with_http_info(self, project_id, **kwargs):  # noqa: E501
        """Get the list of serving instances for the project  # 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_servings_with_http_info(project_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int project_id: (required)
        :return: list[RepresentsAServingModel]
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['project_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_servings" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'project_id' is set
        if ('project_id' not in params or
                params['project_id'] is None):
            raise ValueError("Missing the required parameter `project_id` when calling `get_servings`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'project_id' in params:
            path_params['projectId'] = params['project_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(
            '/project/{projectId}/serving', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='list[RepresentsAServingModel]',  # 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 start_or_stop(self, serving_id, action, project_id, **kwargs):  # noqa: E501
        """Start or stop a Serving instance  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.start_or_stop(serving_id, action, project_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int serving_id: ID of the Serving instance to start/stop (required)
        :param str action: Action (required)
        :param int project_id: (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.start_or_stop_with_http_info(serving_id, action, project_id, **kwargs)  # noqa: E501
        else:
            (data) = self.start_or_stop_with_http_info(serving_id, action, project_id, **kwargs)  # noqa: E501
            return data

    def start_or_stop_with_http_info(self, serving_id, action, project_id, **kwargs):  # noqa: E501
        """Start or stop a Serving instance  # noqa: E501

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.start_or_stop_with_http_info(serving_id, action, project_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int serving_id: ID of the Serving instance to start/stop (required)
        :param str action: Action (required)
        :param int project_id: (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['serving_id', 'action', 'project_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 start_or_stop" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'serving_id' is set
        if ('serving_id' not in params or
                params['serving_id'] is None):
            raise ValueError("Missing the required parameter `serving_id` when calling `start_or_stop`")  # noqa: E501
        # verify the required parameter 'action' is set
        if ('action' not in params or
                params['action'] is None):
            raise ValueError("Missing the required parameter `action` when calling `start_or_stop`")  # noqa: E501
        # verify the required parameter 'project_id' is set
        if ('project_id' not in params or
                params['project_id'] is None):
            raise ValueError("Missing the required parameter `project_id` when calling `start_or_stop`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'serving_id' in params:
            path_params['servingId'] = params['serving_id']  # noqa: E501
        if 'project_id' in params:
            path_params['projectId'] = params['project_id']  # noqa: E501

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

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/project/{projectId}/serving/{servingId}', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type=None,  # 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)
