# coding: utf-8

"""
    \"Data Governance Center: REST API v2\"

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

    OpenAPI spec version: 2.0
    
    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 AttachmentsApi(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 resource_attachment_resource_add_attachment_post(self, **kwargs):  # noqa: E501
        """Adds new attachment.  # noqa: E501

        Adds new attachment.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.resource_attachment_resource_add_attachment_post(async=True)
        >>> result = thread.get()

        :param async bool
        :param file file: the file - attachment content
        :param str file_name: the display name of the file of this attachment
        :param str resource_id: the id of the resource the attachment should refer to
        :param str resource_type: the type of the resource the attachment should refer to
        :param  body: 
        :return: JsonAttachmentImpl
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.resource_attachment_resource_add_attachment_post_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.resource_attachment_resource_add_attachment_post_with_http_info(**kwargs)  # noqa: E501
            return data

    def resource_attachment_resource_add_attachment_post_with_http_info(self, **kwargs):  # noqa: E501
        """Adds new attachment.  # noqa: E501

        Adds new attachment.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.resource_attachment_resource_add_attachment_post_with_http_info(async=True)
        >>> result = thread.get()

        :param async bool
        :param file file: the file - attachment content
        :param str file_name: the display name of the file of this attachment
        :param str resource_id: the id of the resource the attachment should refer to
        :param str resource_type: the type of the resource the attachment should refer to
        :param  body: 
        :return: JsonAttachmentImpl
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['file', 'file_name', 'resource_id', 'resource_type', 'body']  # noqa: E501
        all_params.append('async')
        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 resource_attachment_resource_add_attachment_post" % key
                )
            params[key] = val
        del params['kwargs']

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}
        if 'file' in params:
            local_var_files['file'] = params['file']  # noqa: E501
        if 'file_name' in params:
            form_params.append(('fileName', params['file_name']))  # noqa: E501
        if 'resource_id' in params:
            form_params.append(('resourceId', params['resource_id']))  # noqa: E501
        if 'resource_type' in params:
            form_params.append(('resourceType', params['resource_type']))  # noqa: E501

        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
            ['multipart/form-data'])  # noqa: E501

        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/attachments', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='JsonAttachmentImpl',  # noqa: E501
            auth_settings=auth_settings,
            async=params.get('async'),
            _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 resource_attachment_resource_find_attachments_get(self, **kwargs):  # noqa: E501
        """Returns attachments matching the given search criteria.  # noqa: E501

        Returns attachments matching the given search criteria. Only parameters that are specified in this request and have not <code>null</code> values are used for filtering. All other parameters are ignored. The returned attachments satisfy all constraints that are specified in this search criteria. By default a result containing 1000 attachments is returned.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.resource_attachment_resource_find_attachments_get(async=True)
        >>> result = thread.get()

        :param async bool
        :param str base_resource_id: The <code>id</code> of the resource the attachment refers to
        :param str file_content_type: The type of the content of the file representing searched attachment
        :param str file_name: The name of the file representing searched attachment
        :param int limit: The maximum number of results to retrieve. If not set (value = <tt>0</tt>), the default limit will be used
        :param int offset: The first result to retrieve. If not set (value = <tt>0</tt>), results will be retrieved starting from row <tt>0</tt>
        :param str sort_field: The field that should be used as reference for sorting
        :param str sort_order: The order of sorting
        :param float upload_date: The date of attachment upload. It is the timestamp (in UTC time standard)
        :param str user_id: The <code>id</code> of the user who uploaded the attachment
        :return: JsonAttachmentImpl
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.resource_attachment_resource_find_attachments_get_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.resource_attachment_resource_find_attachments_get_with_http_info(**kwargs)  # noqa: E501
            return data

    def resource_attachment_resource_find_attachments_get_with_http_info(self, **kwargs):  # noqa: E501
        """Returns attachments matching the given search criteria.  # noqa: E501

        Returns attachments matching the given search criteria. Only parameters that are specified in this request and have not <code>null</code> values are used for filtering. All other parameters are ignored. The returned attachments satisfy all constraints that are specified in this search criteria. By default a result containing 1000 attachments is returned.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.resource_attachment_resource_find_attachments_get_with_http_info(async=True)
        >>> result = thread.get()

        :param async bool
        :param str base_resource_id: The <code>id</code> of the resource the attachment refers to
        :param str file_content_type: The type of the content of the file representing searched attachment
        :param str file_name: The name of the file representing searched attachment
        :param int limit: The maximum number of results to retrieve. If not set (value = <tt>0</tt>), the default limit will be used
        :param int offset: The first result to retrieve. If not set (value = <tt>0</tt>), results will be retrieved starting from row <tt>0</tt>
        :param str sort_field: The field that should be used as reference for sorting
        :param str sort_order: The order of sorting
        :param float upload_date: The date of attachment upload. It is the timestamp (in UTC time standard)
        :param str user_id: The <code>id</code> of the user who uploaded the attachment
        :return: JsonAttachmentImpl
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['base_resource_id', 'file_content_type', 'file_name', 'limit', 'offset', 'sort_field', 'sort_order', 'upload_date', 'user_id']  # noqa: E501
        all_params.append('async')
        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 resource_attachment_resource_find_attachments_get" % key
                )
            params[key] = val
        del params['kwargs']

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'base_resource_id' in params:
            query_params.append(('baseResourceId', params['base_resource_id']))  # noqa: E501
        if 'file_content_type' in params:
            query_params.append(('fileContentType', params['file_content_type']))  # noqa: E501
        if 'file_name' in params:
            query_params.append(('fileName', params['file_name']))  # noqa: E501
        if 'limit' in params:
            query_params.append(('limit', params['limit']))  # noqa: E501
        if 'offset' in params:
            query_params.append(('offset', params['offset']))  # noqa: E501
        if 'sort_field' in params:
            query_params.append(('sortField', params['sort_field']))  # noqa: E501
        if 'sort_order' in params:
            query_params.append(('sortOrder', params['sort_order']))  # noqa: E501
        if 'upload_date' in params:
            query_params.append(('uploadDate', params['upload_date']))  # noqa: E501
        if 'user_id' in params:
            query_params.append(('userId', params['user_id']))  # noqa: E501

        header_params = {}

        form_params = []
        local_var_files = {}

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

        # Authentication setting
        auth_settings = []  # noqa: E501

        return self.api_client.call_api(
            '/attachments', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='JsonAttachmentImpl',  # noqa: E501
            auth_settings=auth_settings,
            async=params.get('async'),
            _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 resource_attachment_resource_get_attachment_content_get(self, attachment_id, **kwargs):  # noqa: E501
        """Returns content of the attachment identified by given id.  # noqa: E501

        Returns content of the attachment identified by given id.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.resource_attachment_resource_get_attachment_content_get(attachment_id, async=True)
        >>> result = thread.get()

        :param async bool
        :param str attachment_id: the <code>id</code> of the attachment (required)
        :return: file
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.resource_attachment_resource_get_attachment_content_get_with_http_info(attachment_id, **kwargs)  # noqa: E501
        else:
            (data) = self.resource_attachment_resource_get_attachment_content_get_with_http_info(attachment_id, **kwargs)  # noqa: E501
            return data

    def resource_attachment_resource_get_attachment_content_get_with_http_info(self, attachment_id, **kwargs):  # noqa: E501
        """Returns content of the attachment identified by given id.  # noqa: E501

        Returns content of the attachment identified by given id.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.resource_attachment_resource_get_attachment_content_get_with_http_info(attachment_id, async=True)
        >>> result = thread.get()

        :param async bool
        :param str attachment_id: the <code>id</code> of the attachment (required)
        :return: file
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}
        if 'attachment_id' in params:
            path_params['attachmentId'] = params['attachment_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(
            '/attachments/{attachmentId}/file', '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=params.get('async'),
            _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 resource_attachment_resource_get_attachment_get(self, attachment_id, **kwargs):  # noqa: E501
        """Returns information about the attachment identified by id.  # noqa: E501

        Returns information about the attachment identified by id.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.resource_attachment_resource_get_attachment_get(attachment_id, async=True)
        >>> result = thread.get()

        :param async bool
        :param str attachment_id: the <code>id</code> of the attachment (required)
        :return: JsonAttachmentImpl
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.resource_attachment_resource_get_attachment_get_with_http_info(attachment_id, **kwargs)  # noqa: E501
        else:
            (data) = self.resource_attachment_resource_get_attachment_get_with_http_info(attachment_id, **kwargs)  # noqa: E501
            return data

    def resource_attachment_resource_get_attachment_get_with_http_info(self, attachment_id, **kwargs):  # noqa: E501
        """Returns information about the attachment identified by id.  # noqa: E501

        Returns information about the attachment identified by id.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.resource_attachment_resource_get_attachment_get_with_http_info(attachment_id, async=True)
        >>> result = thread.get()

        :param async bool
        :param str attachment_id: the <code>id</code> of the attachment (required)
        :return: JsonAttachmentImpl
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}
        if 'attachment_id' in params:
            path_params['attachmentId'] = params['attachment_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(
            '/attachments/{attachmentId}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='JsonAttachmentImpl',  # noqa: E501
            auth_settings=auth_settings,
            async=params.get('async'),
            _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 resource_attachment_resource_remove_attachment_delete(self, attachment_id, **kwargs):  # noqa: E501
        """Removes attachment identified by given id.  # noqa: E501

        Removes attachment identified by given id.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.resource_attachment_resource_remove_attachment_delete(attachment_id, async=True)
        >>> result = thread.get()

        :param async bool
        :param str attachment_id: the <code>id</code> of the attachment to remove (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.resource_attachment_resource_remove_attachment_delete_with_http_info(attachment_id, **kwargs)  # noqa: E501
        else:
            (data) = self.resource_attachment_resource_remove_attachment_delete_with_http_info(attachment_id, **kwargs)  # noqa: E501
            return data

    def resource_attachment_resource_remove_attachment_delete_with_http_info(self, attachment_id, **kwargs):  # noqa: E501
        """Removes attachment identified by given id.  # noqa: E501

        Removes attachment identified by given id.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.resource_attachment_resource_remove_attachment_delete_with_http_info(attachment_id, async=True)
        >>> result = thread.get()

        :param async bool
        :param str attachment_id: the <code>id</code> of the attachment to remove (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}
        if 'attachment_id' in params:
            path_params['attachmentId'] = params['attachment_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(
            '/attachments/{attachmentId}', '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=params.get('async'),
            _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)
