# coding: utf-8

"""
    Workspace Data Service

    This page lists both current and proposed APIs. The proposed APIs which have not yet been implemented are marked as deprecated. This is incongruous, but by using the deprecated flag, we can force swagger-ui to display those endpoints differently.  Error codes and responses for proposed APIs are likely to change as we gain more clarity on their implementation.  As of v0.2, all APIs are subject to change without notice.   # noqa: E501

    The version of the OpenAPI document: v0.2
    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 wds_client.api_client import ApiClient
from wds_client.exceptions import (  # noqa: F401
    ApiTypeError,
    ApiValueError
)


class RecordsApi(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 batch_write_records(self, instanceid, v, type, batch_operation, **kwargs):  # noqa: E501
        """Batch write records  # noqa: E501

        Perform a batch of upsert / delete operations on multiple records  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.batch_write_records(instanceid, v, type, batch_operation, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str instanceid: WDS instance id; by convention equal to workspace id (required)
        :param str v: API version (required)
        :param str type: Record type (required)
        :param list[BatchOperation] batch_operation: A list of batch operations to perform on records (required)
        :param str primary_key: the column to uniquely identify a record
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: BatchResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        return self.batch_write_records_with_http_info(instanceid, v, type, batch_operation, **kwargs)  # noqa: E501

    def batch_write_records_with_http_info(self, instanceid, v, type, batch_operation, **kwargs):  # noqa: E501
        """Batch write records  # noqa: E501

        Perform a batch of upsert / delete operations on multiple records  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.batch_write_records_with_http_info(instanceid, v, type, batch_operation, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str instanceid: WDS instance id; by convention equal to workspace id (required)
        :param str v: API version (required)
        :param str type: Record type (required)
        :param list[BatchOperation] batch_operation: A list of batch operations to perform on records (required)
        :param str primary_key: the column to uniquely identify a record
        :param _return_http_data_only: response data without head status code
                                       and headers
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: tuple(BatchResponse, status_code(int), headers(HTTPHeaderDict))
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = [
            'instanceid',
            'v',
            'type',
            'batch_operation',
            'primary_key'
        ]
        all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_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 batch_write_records" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'instanceid' is set
        if self.api_client.client_side_validation and ('instanceid' not in local_var_params or  # noqa: E501
                                                        local_var_params['instanceid'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `instanceid` when calling `batch_write_records`")  # noqa: E501
        # verify the required parameter 'v' is set
        if self.api_client.client_side_validation and ('v' not in local_var_params or  # noqa: E501
                                                        local_var_params['v'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `v` when calling `batch_write_records`")  # noqa: E501
        # verify the required parameter 'type' is set
        if self.api_client.client_side_validation and ('type' not in local_var_params or  # noqa: E501
                                                        local_var_params['type'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `type` when calling `batch_write_records`")  # noqa: E501
        # verify the required parameter 'batch_operation' is set
        if self.api_client.client_side_validation and ('batch_operation' not in local_var_params or  # noqa: E501
                                                        local_var_params['batch_operation'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `batch_operation` when calling `batch_write_records`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'instanceid' in local_var_params:
            path_params['instanceid'] = local_var_params['instanceid']  # noqa: E501
        if 'v' in local_var_params:
            path_params['v'] = local_var_params['v']  # noqa: E501
        if 'type' in local_var_params:
            path_params['type'] = local_var_params['type']  # noqa: E501

        query_params = []
        if 'primary_key' in local_var_params and local_var_params['primary_key'] is not None:  # noqa: E501
            query_params.append(('primaryKey', local_var_params['primary_key']))  # noqa: E501

        header_params = {}

        form_params = []
        local_var_files = {}

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

        # 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(
            '/{instanceid}/batch/{v}/{type}', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='BatchResponse',  # 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 create_or_replace_record(self, instanceid, v, type, id, record_request, **kwargs):  # noqa: E501
        """Create or replace record  # noqa: E501

        Creates or replaces the record using the specified type and id. If the record already exists, its entire set of attributes will be overwritten by the attributes in the request body. TODO: add a query parameter to allow/disallow overwriting existing records?   # 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_replace_record(instanceid, v, type, id, record_request, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str instanceid: WDS instance id; by convention equal to workspace id (required)
        :param str v: API version (required)
        :param str type: Record type (required)
        :param str id: Record id (required)
        :param RecordRequest record_request: A record's attributes to upload (required)
        :param str primary_key: the column to uniquely identify a record
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: RecordResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        return self.create_or_replace_record_with_http_info(instanceid, v, type, id, record_request, **kwargs)  # noqa: E501

    def create_or_replace_record_with_http_info(self, instanceid, v, type, id, record_request, **kwargs):  # noqa: E501
        """Create or replace record  # noqa: E501

        Creates or replaces the record using the specified type and id. If the record already exists, its entire set of attributes will be overwritten by the attributes in the request body. TODO: add a query parameter to allow/disallow overwriting existing records?   # 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_replace_record_with_http_info(instanceid, v, type, id, record_request, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str instanceid: WDS instance id; by convention equal to workspace id (required)
        :param str v: API version (required)
        :param str type: Record type (required)
        :param str id: Record id (required)
        :param RecordRequest record_request: A record's attributes to upload (required)
        :param str primary_key: the column to uniquely identify a record
        :param _return_http_data_only: response data without head status code
                                       and headers
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: tuple(RecordResponse, status_code(int), headers(HTTPHeaderDict))
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = [
            'instanceid',
            'v',
            'type',
            'id',
            'record_request',
            'primary_key'
        ]
        all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_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 create_or_replace_record" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'instanceid' is set
        if self.api_client.client_side_validation and ('instanceid' not in local_var_params or  # noqa: E501
                                                        local_var_params['instanceid'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `instanceid` when calling `create_or_replace_record`")  # noqa: E501
        # verify the required parameter 'v' is set
        if self.api_client.client_side_validation and ('v' not in local_var_params or  # noqa: E501
                                                        local_var_params['v'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `v` when calling `create_or_replace_record`")  # noqa: E501
        # verify the required parameter 'type' is set
        if self.api_client.client_side_validation and ('type' not in local_var_params or  # noqa: E501
                                                        local_var_params['type'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `type` when calling `create_or_replace_record`")  # noqa: E501
        # verify the required parameter 'id' is set
        if self.api_client.client_side_validation and ('id' not in local_var_params or  # noqa: E501
                                                        local_var_params['id'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `id` when calling `create_or_replace_record`")  # noqa: E501
        # verify the required parameter 'record_request' is set
        if self.api_client.client_side_validation and ('record_request' not in local_var_params or  # noqa: E501
                                                        local_var_params['record_request'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `record_request` when calling `create_or_replace_record`")  # noqa: E501

        collection_formats = {}

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

        query_params = []
        if 'primary_key' in local_var_params and local_var_params['primary_key'] is not None:  # noqa: E501
            query_params.append(('primaryKey', local_var_params['primary_key']))  # noqa: E501

        header_params = {}

        form_params = []
        local_var_files = {}

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

        # 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(
            '/{instanceid}/records/{v}/{type}/{id}', 'PUT',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='RecordResponse',  # 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 delete_record(self, instanceid, v, type, id, **kwargs):  # noqa: E501
        """Delete record  # noqa: E501

        Deletes the record at the specified type and id.  # 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_record(instanceid, v, type, id, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str instanceid: WDS instance id; by convention equal to workspace id (required)
        :param str v: API version (required)
        :param str type: Record type (required)
        :param str id: Record id (required)
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        return self.delete_record_with_http_info(instanceid, v, type, id, **kwargs)  # noqa: E501

    def delete_record_with_http_info(self, instanceid, v, type, id, **kwargs):  # noqa: E501
        """Delete record  # noqa: E501

        Deletes the record at the specified type and id.  # 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_record_with_http_info(instanceid, v, type, id, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str instanceid: WDS instance id; by convention equal to workspace id (required)
        :param str v: API version (required)
        :param str type: Record type (required)
        :param str id: Record id (required)
        :param _return_http_data_only: response data without head status code
                                       and headers
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = [
            'instanceid',
            'v',
            'type',
            'id'
        ]
        all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_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 delete_record" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'instanceid' is set
        if self.api_client.client_side_validation and ('instanceid' not in local_var_params or  # noqa: E501
                                                        local_var_params['instanceid'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `instanceid` when calling `delete_record`")  # noqa: E501
        # verify the required parameter 'v' is set
        if self.api_client.client_side_validation and ('v' not in local_var_params or  # noqa: E501
                                                        local_var_params['v'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `v` when calling `delete_record`")  # noqa: E501
        # verify the required parameter 'type' is set
        if self.api_client.client_side_validation and ('type' not in local_var_params or  # noqa: E501
                                                        local_var_params['type'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `type` when calling `delete_record`")  # noqa: E501
        # verify the required parameter 'id' is set
        if self.api_client.client_side_validation and ('id' not in local_var_params or  # noqa: E501
                                                        local_var_params['id'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `id` when calling `delete_record`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'instanceid' in local_var_params:
            path_params['instanceid'] = local_var_params['instanceid']  # noqa: E501
        if 'v' in local_var_params:
            path_params['v'] = local_var_params['v']  # noqa: E501
        if 'type' in local_var_params:
            path_params['type'] = local_var_params['type']  # noqa: E501
        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
        # 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(
            '/{instanceid}/records/{v}/{type}/{id}', '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=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 get_record(self, instanceid, v, type, id, **kwargs):  # noqa: E501
        """Get record  # noqa: E501

        Retrieves a single record by its type and id  # 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_record(instanceid, v, type, id, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str instanceid: WDS instance id; by convention equal to workspace id (required)
        :param str v: API version (required)
        :param str type: Record type (required)
        :param str id: Record id (required)
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: RecordResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        return self.get_record_with_http_info(instanceid, v, type, id, **kwargs)  # noqa: E501

    def get_record_with_http_info(self, instanceid, v, type, id, **kwargs):  # noqa: E501
        """Get record  # noqa: E501

        Retrieves a single record by its type and id  # 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_record_with_http_info(instanceid, v, type, id, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str instanceid: WDS instance id; by convention equal to workspace id (required)
        :param str v: API version (required)
        :param str type: Record type (required)
        :param str id: Record id (required)
        :param _return_http_data_only: response data without head status code
                                       and headers
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: tuple(RecordResponse, status_code(int), headers(HTTPHeaderDict))
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = [
            'instanceid',
            'v',
            'type',
            'id'
        ]
        all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_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 get_record" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'instanceid' is set
        if self.api_client.client_side_validation and ('instanceid' not in local_var_params or  # noqa: E501
                                                        local_var_params['instanceid'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `instanceid` when calling `get_record`")  # noqa: E501
        # verify the required parameter 'v' is set
        if self.api_client.client_side_validation and ('v' not in local_var_params or  # noqa: E501
                                                        local_var_params['v'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `v` when calling `get_record`")  # noqa: E501
        # verify the required parameter 'type' is set
        if self.api_client.client_side_validation and ('type' not in local_var_params or  # noqa: E501
                                                        local_var_params['type'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `type` when calling `get_record`")  # noqa: E501
        # verify the required parameter 'id' is set
        if self.api_client.client_side_validation and ('id' not in local_var_params or  # noqa: E501
                                                        local_var_params['id'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `id` when calling `get_record`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'instanceid' in local_var_params:
            path_params['instanceid'] = local_var_params['instanceid']  # noqa: E501
        if 'v' in local_var_params:
            path_params['v'] = local_var_params['v']  # noqa: E501
        if 'type' in local_var_params:
            path_params['type'] = local_var_params['type']  # noqa: E501
        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
        # 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(
            '/{instanceid}/records/{v}/{type}/{id}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='RecordResponse',  # 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 get_records_as_tsv(self, instanceid, v, type, **kwargs):  # noqa: E501
        """Retrieve all records in record type as tsv.  # noqa: E501

        Streams all records in a record type to a tsv format.  # 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_records_as_tsv(instanceid, v, type, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str instanceid: WDS instance id; by convention equal to workspace id (required)
        :param str v: API version (required)
        :param str type: Record type (required)
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: file
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        return self.get_records_as_tsv_with_http_info(instanceid, v, type, **kwargs)  # noqa: E501

    def get_records_as_tsv_with_http_info(self, instanceid, v, type, **kwargs):  # noqa: E501
        """Retrieve all records in record type as tsv.  # noqa: E501

        Streams all records in a record type to a tsv format.  # 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_records_as_tsv_with_http_info(instanceid, v, type, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str instanceid: WDS instance id; by convention equal to workspace id (required)
        :param str v: API version (required)
        :param str type: Record type (required)
        :param _return_http_data_only: response data without head status code
                                       and headers
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: tuple(file, status_code(int), headers(HTTPHeaderDict))
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = [
            'instanceid',
            'v',
            'type'
        ]
        all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_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 get_records_as_tsv" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'instanceid' is set
        if self.api_client.client_side_validation and ('instanceid' not in local_var_params or  # noqa: E501
                                                        local_var_params['instanceid'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `instanceid` when calling `get_records_as_tsv`")  # noqa: E501
        # verify the required parameter 'v' is set
        if self.api_client.client_side_validation and ('v' not in local_var_params or  # noqa: E501
                                                        local_var_params['v'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `v` when calling `get_records_as_tsv`")  # noqa: E501
        # verify the required parameter 'type' is set
        if self.api_client.client_side_validation and ('type' not in local_var_params or  # noqa: E501
                                                        local_var_params['type'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `type` when calling `get_records_as_tsv`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'instanceid' in local_var_params:
            path_params['instanceid'] = local_var_params['instanceid']  # noqa: E501
        if 'v' in local_var_params:
            path_params['v'] = local_var_params['v']  # noqa: E501
        if 'type' in local_var_params:
            path_params['type'] = local_var_params['type']  # 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(
            ['text/tab-separated-values', 'application/json'])  # noqa: E501

        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/{instanceid}/tsv/{v}/{type}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='file',  # 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 query_records(self, instanceid, v, type, search_request, **kwargs):  # noqa: E501
        """Query records  # noqa: E501

        Paginated list of records matching the criteria supplied in the request body  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.query_records(instanceid, v, type, search_request, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str instanceid: WDS instance id; by convention equal to workspace id (required)
        :param str v: API version (required)
        :param str type: Record type (required)
        :param SearchRequest search_request: A paginated search request (required)
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: RecordQueryResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        return self.query_records_with_http_info(instanceid, v, type, search_request, **kwargs)  # noqa: E501

    def query_records_with_http_info(self, instanceid, v, type, search_request, **kwargs):  # noqa: E501
        """Query records  # noqa: E501

        Paginated list of records matching the criteria supplied in the request body  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.query_records_with_http_info(instanceid, v, type, search_request, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str instanceid: WDS instance id; by convention equal to workspace id (required)
        :param str v: API version (required)
        :param str type: Record type (required)
        :param SearchRequest search_request: A paginated search request (required)
        :param _return_http_data_only: response data without head status code
                                       and headers
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: tuple(RecordQueryResponse, status_code(int), headers(HTTPHeaderDict))
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = [
            'instanceid',
            'v',
            'type',
            'search_request'
        ]
        all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_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 query_records" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'instanceid' is set
        if self.api_client.client_side_validation and ('instanceid' not in local_var_params or  # noqa: E501
                                                        local_var_params['instanceid'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `instanceid` when calling `query_records`")  # noqa: E501
        # verify the required parameter 'v' is set
        if self.api_client.client_side_validation and ('v' not in local_var_params or  # noqa: E501
                                                        local_var_params['v'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `v` when calling `query_records`")  # noqa: E501
        # verify the required parameter 'type' is set
        if self.api_client.client_side_validation and ('type' not in local_var_params or  # noqa: E501
                                                        local_var_params['type'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `type` when calling `query_records`")  # noqa: E501
        # verify the required parameter 'search_request' is set
        if self.api_client.client_side_validation and ('search_request' not in local_var_params or  # noqa: E501
                                                        local_var_params['search_request'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `search_request` when calling `query_records`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'instanceid' in local_var_params:
            path_params['instanceid'] = local_var_params['instanceid']  # noqa: E501
        if 'v' in local_var_params:
            path_params['v'] = local_var_params['v']  # noqa: E501
        if 'type' in local_var_params:
            path_params['type'] = local_var_params['type']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

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

        # 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(
            '/{instanceid}/search/{v}/{type}', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='RecordQueryResponse',  # 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 update_record(self, instanceid, v, type, id, record_request, **kwargs):  # noqa: E501
        """Update record  # noqa: E501

        Updates the record of the specified type and id. Any attributes included in the request body will be created or overwritten. Attributes not included in the request body will be untouched in the database. No attributes will be deleted. To delete attributes, use the PUT api instead.   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.update_record(instanceid, v, type, id, record_request, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str instanceid: WDS instance id; by convention equal to workspace id (required)
        :param str v: API version (required)
        :param str type: Record type (required)
        :param str id: Record id (required)
        :param RecordRequest record_request: A record's attributes to upload (required)
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: RecordResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        return self.update_record_with_http_info(instanceid, v, type, id, record_request, **kwargs)  # noqa: E501

    def update_record_with_http_info(self, instanceid, v, type, id, record_request, **kwargs):  # noqa: E501
        """Update record  # noqa: E501

        Updates the record of the specified type and id. Any attributes included in the request body will be created or overwritten. Attributes not included in the request body will be untouched in the database. No attributes will be deleted. To delete attributes, use the PUT api instead.   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.update_record_with_http_info(instanceid, v, type, id, record_request, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str instanceid: WDS instance id; by convention equal to workspace id (required)
        :param str v: API version (required)
        :param str type: Record type (required)
        :param str id: Record id (required)
        :param RecordRequest record_request: A record's attributes to upload (required)
        :param _return_http_data_only: response data without head status code
                                       and headers
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: tuple(RecordResponse, status_code(int), headers(HTTPHeaderDict))
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = [
            'instanceid',
            'v',
            'type',
            'id',
            'record_request'
        ]
        all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_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 update_record" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'instanceid' is set
        if self.api_client.client_side_validation and ('instanceid' not in local_var_params or  # noqa: E501
                                                        local_var_params['instanceid'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `instanceid` when calling `update_record`")  # noqa: E501
        # verify the required parameter 'v' is set
        if self.api_client.client_side_validation and ('v' not in local_var_params or  # noqa: E501
                                                        local_var_params['v'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `v` when calling `update_record`")  # noqa: E501
        # verify the required parameter 'type' is set
        if self.api_client.client_side_validation and ('type' not in local_var_params or  # noqa: E501
                                                        local_var_params['type'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `type` when calling `update_record`")  # noqa: E501
        # verify the required parameter 'id' is set
        if self.api_client.client_side_validation and ('id' not in local_var_params or  # noqa: E501
                                                        local_var_params['id'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `id` when calling `update_record`")  # noqa: E501
        # verify the required parameter 'record_request' is set
        if self.api_client.client_side_validation and ('record_request' not in local_var_params or  # noqa: E501
                                                        local_var_params['record_request'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `record_request` when calling `update_record`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'instanceid' in local_var_params:
            path_params['instanceid'] = local_var_params['instanceid']  # noqa: E501
        if 'v' in local_var_params:
            path_params['v'] = local_var_params['v']  # noqa: E501
        if 'type' in local_var_params:
            path_params['type'] = local_var_params['type']  # noqa: E501
        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 'record_request' in local_var_params:
            body_params = local_var_params['record_request']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # 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(
            '/{instanceid}/records/{v}/{type}/{id}', 'PATCH',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='RecordResponse',  # 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 upload_tsv(self, instanceid, v, type, records, **kwargs):  # noqa: E501
        """Import records to a record type from a tsv file  # noqa: E501

        Upload a tsv to modify or create records in a record type.  This operation will insert or update records.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.upload_tsv(instanceid, v, type, records, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str instanceid: WDS instance id; by convention equal to workspace id (required)
        :param str v: API version (required)
        :param str type: Record type (required)
        :param file records: A valid TSV import file (required)
        :param str primary_key: the column to uniquely identify a record
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: TsvUploadResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        return self.upload_tsv_with_http_info(instanceid, v, type, records, **kwargs)  # noqa: E501

    def upload_tsv_with_http_info(self, instanceid, v, type, records, **kwargs):  # noqa: E501
        """Import records to a record type from a tsv file  # noqa: E501

        Upload a tsv to modify or create records in a record type.  This operation will insert or update records.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.upload_tsv_with_http_info(instanceid, v, type, records, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str instanceid: WDS instance id; by convention equal to workspace id (required)
        :param str v: API version (required)
        :param str type: Record type (required)
        :param file records: A valid TSV import file (required)
        :param str primary_key: the column to uniquely identify a record
        :param _return_http_data_only: response data without head status code
                                       and headers
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: tuple(TsvUploadResponse, status_code(int), headers(HTTPHeaderDict))
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = [
            'instanceid',
            'v',
            'type',
            'records',
            'primary_key'
        ]
        all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_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 upload_tsv" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'instanceid' is set
        if self.api_client.client_side_validation and ('instanceid' not in local_var_params or  # noqa: E501
                                                        local_var_params['instanceid'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `instanceid` when calling `upload_tsv`")  # noqa: E501
        # verify the required parameter 'v' is set
        if self.api_client.client_side_validation and ('v' not in local_var_params or  # noqa: E501
                                                        local_var_params['v'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `v` when calling `upload_tsv`")  # noqa: E501
        # verify the required parameter 'type' is set
        if self.api_client.client_side_validation and ('type' not in local_var_params or  # noqa: E501
                                                        local_var_params['type'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `type` when calling `upload_tsv`")  # noqa: E501
        # verify the required parameter 'records' is set
        if self.api_client.client_side_validation and ('records' not in local_var_params or  # noqa: E501
                                                        local_var_params['records'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `records` when calling `upload_tsv`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'instanceid' in local_var_params:
            path_params['instanceid'] = local_var_params['instanceid']  # noqa: E501
        if 'v' in local_var_params:
            path_params['v'] = local_var_params['v']  # noqa: E501
        if 'type' in local_var_params:
            path_params['type'] = local_var_params['type']  # noqa: E501

        query_params = []
        if 'primary_key' in local_var_params and local_var_params['primary_key'] is not None:  # noqa: E501
            query_params.append(('primaryKey', local_var_params['primary_key']))  # noqa: E501

        header_params = {}

        form_params = []
        local_var_files = {}
        if 'records' in local_var_params:
            local_var_files['records'] = local_var_params['records']  # noqa: E501

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

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['multipart/form-data'])  # noqa: E501

        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/{instanceid}/tsv/{v}/{type}', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='TsvUploadResponse',  # 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)
