# coding: utf-8

"""
    Laserfiche API

    Welcome to the Laserfiche API Swagger Playground. You can try out any of our API calls against your live Laserfiche Cloud account. Visit the developer center for more details: <a href=\"https://developer.laserfiche.com\">https://developer.laserfiche.com</a><p><strong>Build# : </strong>561590</p>  # noqa: E501

    OpenAPI spec version: 1-alpha
    
    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 laserfiche_api.api_client import ApiClient


class AttributesApi(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 get_trustee_attribute_key_value_pairs(self, repo_id, **kwargs):  # noqa: E501
        """Get the attribute key value pairs associated with the authenticated user.  # noqa: E501

        - Returns the attribute key value pairs associated with the authenticated user. Alternatively, return only the attribute key value pairs that are associated with the \"Everyone\" group. - Attribute keys can be used with subsequent calls to get specific attribute values. - Allowed OData query options: Select, count, orderby. Optional query parameters : everyone (bool, default false). When true, this route does not return the attributes that are tied to the currently authenticated user, but rather the attributes assigned to the \"Everyone\" group. Note when this true, this response does not include both the \"Everyone\" groups attribute and the currently authenticated user, but only the \"Everyone\" groups.  # 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_trustee_attribute_key_value_pairs(repo_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str repo_id: The requested repository id. (required)
        :param bool everyone: Boolean value that indicates whether to return attributes key value pairs associated with everyone or the currently authenticated user.
        :param str select: Limits the properties returned in the result.
        :param str orderby: Specifies the order in which items are returned. The maximum number of expressions is 5.
        :param bool count: Indicates whether the total count of items within a collection are returned in the result.
        :return: ODataValueOfListOfAttribute
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_trustee_attribute_key_value_pairs_with_http_info(repo_id, **kwargs)  # noqa: E501
        else:
            (data) = self.get_trustee_attribute_key_value_pairs_with_http_info(repo_id, **kwargs)  # noqa: E501
            return data

    def get_trustee_attribute_key_value_pairs_with_http_info(self, repo_id, **kwargs):  # noqa: E501
        """Get the attribute key value pairs associated with the authenticated user.  # noqa: E501

        - Returns the attribute key value pairs associated with the authenticated user. Alternatively, return only the attribute key value pairs that are associated with the \"Everyone\" group. - Attribute keys can be used with subsequent calls to get specific attribute values. - Allowed OData query options: Select, count, orderby. Optional query parameters : everyone (bool, default false). When true, this route does not return the attributes that are tied to the currently authenticated user, but rather the attributes assigned to the \"Everyone\" group. Note when this true, this response does not include both the \"Everyone\" groups attribute and the currently authenticated user, but only the \"Everyone\" groups.  # 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_trustee_attribute_key_value_pairs_with_http_info(repo_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str repo_id: The requested repository id. (required)
        :param bool everyone: Boolean value that indicates whether to return attributes key value pairs associated with everyone or the currently authenticated user.
        :param str select: Limits the properties returned in the result.
        :param str orderby: Specifies the order in which items are returned. The maximum number of expressions is 5.
        :param bool count: Indicates whether the total count of items within a collection are returned in the result.
        :return: ODataValueOfListOfAttribute
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}
        if 'repo_id' in params:
            path_params['repoId'] = params['repo_id']  # noqa: E501

        query_params = []
        if 'everyone' in params:
            query_params.append(('everyone', params['everyone']))  # noqa: E501
        if 'select' in params:
            query_params.append(('$select', params['select']))  # noqa: E501
        if 'orderby' in params:
            query_params.append(('$orderby', params['orderby']))  # noqa: E501
        if 'count' in params:
            query_params.append(('$count', params['count']))  # 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 = ['Authorization']  # noqa: E501

        return self.api_client.call_api(
            '/v1-alpha/Repositories/{repoId}/Attributes', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='ODataValueOfListOfAttribute',  # 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_trustee_attribute_value_by_key(self, repo_id, attribute_key, **kwargs):  # noqa: E501
        """Get an attribute object by key associated with the authenticated user.  # noqa: E501

        - Returns the attribute associated with the key. Alternatively, return the attribute associated with the key within \"Everyone\" group. - Optional query parameters : everyone (bool, default false). When true, the server only searches for the attribute value with the given key upon the authenticated users attributes. If false, only the authenticated users attributes will be queried.  # 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_trustee_attribute_value_by_key(repo_id, attribute_key, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str repo_id: The requested repository id. (required)
        :param str attribute_key: The requested attribute key. (required)
        :param bool everyone: Boolean value that indicates whether to return attributes associated with everyone or the currently authenticated user.
        :return: Attribute
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_trustee_attribute_value_by_key_with_http_info(repo_id, attribute_key, **kwargs)  # noqa: E501
        else:
            (data) = self.get_trustee_attribute_value_by_key_with_http_info(repo_id, attribute_key, **kwargs)  # noqa: E501
            return data

    def get_trustee_attribute_value_by_key_with_http_info(self, repo_id, attribute_key, **kwargs):  # noqa: E501
        """Get an attribute object by key associated with the authenticated user.  # noqa: E501

        - Returns the attribute associated with the key. Alternatively, return the attribute associated with the key within \"Everyone\" group. - Optional query parameters : everyone (bool, default false). When true, the server only searches for the attribute value with the given key upon the authenticated users attributes. If false, only the authenticated users attributes will be queried.  # 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_trustee_attribute_value_by_key_with_http_info(repo_id, attribute_key, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str repo_id: The requested repository id. (required)
        :param str attribute_key: The requested attribute key. (required)
        :param bool everyone: Boolean value that indicates whether to return attributes associated with everyone or the currently authenticated user.
        :return: Attribute
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}
        if 'repo_id' in params:
            path_params['repoId'] = params['repo_id']  # noqa: E501
        if 'attribute_key' in params:
            path_params['attributeKey'] = params['attribute_key']  # noqa: E501

        query_params = []
        if 'everyone' in params:
            query_params.append(('everyone', params['everyone']))  # 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 = ['Authorization']  # noqa: E501

        return self.api_client.call_api(
            '/v1-alpha/Repositories/{repoId}/Attributes/{attributeKey}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='Attribute',  # 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)
