# coding: utf-8

"""
    Collibra Catalog Classification API

    Version 2 of the Catalog Classification API offers functionality related to the classification process and facilitates searching for and managing the associations between a data class and a data category. Use version 1 of the API for managing classifications and legacy data classes.   # noqa: E501

    OpenAPI spec version: 2.0.0-unstable
    
    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 collibra_catalog_classification.api_client import ApiClient


class ClassificationDataCategoryApi(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 connect_data_category_data_class(self, data_class_id, **kwargs):  # noqa: E501
        """Associate data class with data category  # noqa: E501

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

        :param async_req bool
        :param str data_class_id: The ID of the data class to which the data category will be associated. (required)
        :param str body: The ID of the data category to be associated with the data class.
        :return: DataClassDataCategoryConnection
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.connect_data_category_data_class_with_http_info(data_class_id, **kwargs)  # noqa: E501
        else:
            (data) = self.connect_data_category_data_class_with_http_info(data_class_id, **kwargs)  # noqa: E501
            return data

    def connect_data_category_data_class_with_http_info(self, data_class_id, **kwargs):  # noqa: E501
        """Associate data class with data category  # noqa: E501

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

        :param async_req bool
        :param str data_class_id: The ID of the data class to which the data category will be associated. (required)
        :param str body: The ID of the data category to be associated with the data class.
        :return: DataClassDataCategoryConnection
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}
        if 'data_class_id' in params:
            path_params['dataClassId'] = params['data_class_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 `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 = ['basicAuth']  # noqa: E501

        return self.api_client.call_api(
            '/dataClasses/{dataClassId}/dataCategories', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='DataClassDataCategoryConnection',  # 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 disconnect_data_category_data_class(self, data_class_id, data_category_id, **kwargs):  # noqa: E501
        """Remove existing association between a data class and a data category  # noqa: E501

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

        :param async_req bool
        :param str data_class_id: The ID of the data class from which the data category will be removed. (required)
        :param str data_category_id: The ID of the data category to be removed. (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.disconnect_data_category_data_class_with_http_info(data_class_id, data_category_id, **kwargs)  # noqa: E501
        else:
            (data) = self.disconnect_data_category_data_class_with_http_info(data_class_id, data_category_id, **kwargs)  # noqa: E501
            return data

    def disconnect_data_category_data_class_with_http_info(self, data_class_id, data_category_id, **kwargs):  # noqa: E501
        """Remove existing association between a data class and a data category  # noqa: E501

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

        :param async_req bool
        :param str data_class_id: The ID of the data class from which the data category will be removed. (required)
        :param str data_category_id: The ID of the data category to be removed. (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}
        if 'data_class_id' in params:
            path_params['dataClassId'] = params['data_class_id']  # noqa: E501
        if 'data_category_id' in params:
            path_params['dataCategoryId'] = params['data_category_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 = ['basicAuth']  # noqa: E501

        return self.api_client.call_api(
            '/dataClasses/{dataClassId}/dataCategories/{dataCategoryId}', '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_association_data_class_data_category(self, **kwargs):  # noqa: E501
        """Retrieve the association with a data category and a data class.  # 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_association_data_class_data_category(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str data_category_id: The ID of the data category for which you want to see the associated data classes.
        :param str data_class_id: The ID of the data class for which you want to see the associated data categories.
        :param int offset: The index of the first result to retrieve.  If not set (offset = <code>0</code>), results are retrieved starting from row <code>0</code>. 
        :param int limit: The maximum number of results to retrieve.  If not set, the default limit  (limit = <code>0</code>) is used. The maximum value for this parameter is <code>1000<code>. 
        :return: DataClassDataCategoryConnectionsPagedResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_association_data_class_data_category_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.get_association_data_class_data_category_with_http_info(**kwargs)  # noqa: E501
            return data

    def get_association_data_class_data_category_with_http_info(self, **kwargs):  # noqa: E501
        """Retrieve the association with a data category and a data class.  # 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_association_data_class_data_category_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str data_category_id: The ID of the data category for which you want to see the associated data classes.
        :param str data_class_id: The ID of the data class for which you want to see the associated data categories.
        :param int offset: The index of the first result to retrieve.  If not set (offset = <code>0</code>), results are retrieved starting from row <code>0</code>. 
        :param int limit: The maximum number of results to retrieve.  If not set, the default limit  (limit = <code>0</code>) is used. The maximum value for this parameter is <code>1000<code>. 
        :return: DataClassDataCategoryConnectionsPagedResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['data_category_id', 'data_class_id', 'offset', 'limit']  # 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_association_data_class_data_category" % key
                )
            params[key] = val
        del params['kwargs']

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'data_category_id' in params:
            query_params.append(('dataCategoryId', params['data_category_id']))  # noqa: E501
        if 'data_class_id' in params:
            query_params.append(('dataClassId', params['data_class_id']))  # noqa: E501
        if 'offset' in params:
            query_params.append(('offset', params['offset']))  # noqa: E501
        if 'limit' in params:
            query_params.append(('limit', params['limit']))  # 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 = ['basicAuth']  # noqa: E501

        return self.api_client.call_api(
            '/dataClasses/dataCategories', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='DataClassDataCategoryConnectionsPagedResponse',  # 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)
