# coding: utf-8

"""
    Knetik Platform API Documentation latest 

    This is the spec for the Knetik API.  Use this in conjunction with the documentation found at https://knetikcloud.com.

    OpenAPI spec version: latest 
    Contact: support@knetik.com
    Generated by: https://github.com/swagger-api/swagger-codegen.git
"""


from __future__ import absolute_import

import sys
import os
import re

# python 2 and python 3 compatibility library
from six import iteritems

from ..api_client import ApiClient


class UsersInventoryApi(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 add_item_to_user_inventory(self, id, **kwargs):
        """
        Adds an item to the user inventory
        The inventory is fulfilled asynchronously UNLESS the invoice is explicitely skipped. Depending on the use case, it might require the client to verify that the entitlement was added after the fact or configure a BRE rule to get a notification in real time. <br><br><b>Permissions Needed:</b> INVENTORY_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.add_item_to_user_inventory(id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int id: The id of the user (required)
        :param UserInventoryAddRequest user_inventory_add_request: The user inventory add request object
        :return: InvoiceResource
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.add_item_to_user_inventory_with_http_info(id, **kwargs)
        else:
            (data) = self.add_item_to_user_inventory_with_http_info(id, **kwargs)
            return data

    def add_item_to_user_inventory_with_http_info(self, id, **kwargs):
        """
        Adds an item to the user inventory
        The inventory is fulfilled asynchronously UNLESS the invoice is explicitely skipped. Depending on the use case, it might require the client to verify that the entitlement was added after the fact or configure a BRE rule to get a notification in real time. <br><br><b>Permissions Needed:</b> INVENTORY_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.add_item_to_user_inventory_with_http_info(id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int id: The id of the user (required)
        :param UserInventoryAddRequest user_inventory_add_request: The user inventory add request object
        :return: InvoiceResource
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['id', 'user_inventory_add_request']
        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 iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method add_item_to_user_inventory" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'id' is set
        if ('id' not in params) or (params['id'] is None):
            raise ValueError("Missing the required parameter `id` when calling `add_item_to_user_inventory`")


        collection_formats = {}

        path_params = {}
        if 'id' in params:
            path_params['id'] = params['id']

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'user_inventory_add_request' in params:
            body_params = params['user_inventory_add_request']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/users/{id}/inventory', 'POST',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='InvoiceResource',
                                        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 check_user_entitlement_item(self, user_id, item_id, **kwargs):
        """
        Check for access to an item without consuming
        Useful for pre-check and accounts for all various buisness rules. <br><br><b>Permissions Needed:</b> INVENTORY_ADMIN or owner
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.check_user_entitlement_item(user_id, item_id, async=True)
        >>> result = thread.get()

        :param async bool
        :param str user_id: The id of the user to check for or 'me' for logged in user (required)
        :param int item_id: The id of the item (required)
        :param str sku: The specific sku of an entitlement list addition to check entitlement for. This is of very limited and specific use and should generally be left out
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.check_user_entitlement_item_with_http_info(user_id, item_id, **kwargs)
        else:
            (data) = self.check_user_entitlement_item_with_http_info(user_id, item_id, **kwargs)
            return data

    def check_user_entitlement_item_with_http_info(self, user_id, item_id, **kwargs):
        """
        Check for access to an item without consuming
        Useful for pre-check and accounts for all various buisness rules. <br><br><b>Permissions Needed:</b> INVENTORY_ADMIN or owner
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.check_user_entitlement_item_with_http_info(user_id, item_id, async=True)
        >>> result = thread.get()

        :param async bool
        :param str user_id: The id of the user to check for or 'me' for logged in user (required)
        :param int item_id: The id of the item (required)
        :param str sku: The specific sku of an entitlement list addition to check entitlement for. This is of very limited and specific use and should generally be left out
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['user_id', 'item_id', 'sku']
        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 iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method check_user_entitlement_item" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'user_id' is set
        if ('user_id' not in params) or (params['user_id'] is None):
            raise ValueError("Missing the required parameter `user_id` when calling `check_user_entitlement_item`")
        # verify the required parameter 'item_id' is set
        if ('item_id' not in params) or (params['item_id'] is None):
            raise ValueError("Missing the required parameter `item_id` when calling `check_user_entitlement_item`")


        collection_formats = {}

        path_params = {}
        if 'user_id' in params:
            path_params['user_id'] = params['user_id']
        if 'item_id' in params:
            path_params['item_id'] = params['item_id']

        query_params = []
        if 'sku' in params:
            query_params.append(('sku', params['sku']))

        header_params = {}

        form_params = []
        local_var_files = {}

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

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/users/{user_id}/entitlements/{item_id}/check', 'GET',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type=None,
                                        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 create_entitlement_item(self, **kwargs):
        """
        Create an entitlement item
        <b>Permissions Needed:</b> INVENTORY_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.create_entitlement_item(async=True)
        >>> result = thread.get()

        :param async bool
        :param bool cascade: Whether to cascade group changes, such as in the limited gettable behavior. A 400 error will return otherwise if the group is already in use with different values.
        :param EntitlementItem entitlement_item: The entitlement item object
        :return: EntitlementItem
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.create_entitlement_item_with_http_info(**kwargs)
        else:
            (data) = self.create_entitlement_item_with_http_info(**kwargs)
            return data

    def create_entitlement_item_with_http_info(self, **kwargs):
        """
        Create an entitlement item
        <b>Permissions Needed:</b> INVENTORY_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.create_entitlement_item_with_http_info(async=True)
        >>> result = thread.get()

        :param async bool
        :param bool cascade: Whether to cascade group changes, such as in the limited gettable behavior. A 400 error will return otherwise if the group is already in use with different values.
        :param EntitlementItem entitlement_item: The entitlement item object
        :return: EntitlementItem
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['cascade', 'entitlement_item']
        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 iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method create_entitlement_item" % key
                )
            params[key] = val
        del params['kwargs']


        collection_formats = {}

        path_params = {}

        query_params = []
        if 'cascade' in params:
            query_params.append(('cascade', params['cascade']))

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'entitlement_item' in params:
            body_params = params['entitlement_item']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/entitlements', 'POST',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='EntitlementItem',
                                        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 create_entitlement_template(self, **kwargs):
        """
        Create an entitlement template
        Entitlement templates define a type of entitlement and the properties they have. <br><br><b>Permissions Needed:</b> TEMPLATE_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.create_entitlement_template(async=True)
        >>> result = thread.get()

        :param async bool
        :param ItemTemplateResource template: The entitlement template to be created
        :return: ItemTemplateResource
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.create_entitlement_template_with_http_info(**kwargs)
        else:
            (data) = self.create_entitlement_template_with_http_info(**kwargs)
            return data

    def create_entitlement_template_with_http_info(self, **kwargs):
        """
        Create an entitlement template
        Entitlement templates define a type of entitlement and the properties they have. <br><br><b>Permissions Needed:</b> TEMPLATE_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.create_entitlement_template_with_http_info(async=True)
        >>> result = thread.get()

        :param async bool
        :param ItemTemplateResource template: The entitlement template to be created
        :return: ItemTemplateResource
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['template']
        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 iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method create_entitlement_template" % key
                )
            params[key] = val
        del params['kwargs']


        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'template' in params:
            body_params = params['template']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/entitlements/templates', 'POST',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='ItemTemplateResource',
                                        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 delete_entitlement_item(self, entitlement_id, **kwargs):
        """
        Delete an entitlement item
        <b>Permissions Needed:</b> INVENTORY_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.delete_entitlement_item(entitlement_id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int entitlement_id: The id of the entitlement (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.delete_entitlement_item_with_http_info(entitlement_id, **kwargs)
        else:
            (data) = self.delete_entitlement_item_with_http_info(entitlement_id, **kwargs)
            return data

    def delete_entitlement_item_with_http_info(self, entitlement_id, **kwargs):
        """
        Delete an entitlement item
        <b>Permissions Needed:</b> INVENTORY_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.delete_entitlement_item_with_http_info(entitlement_id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int entitlement_id: The id of the entitlement (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['entitlement_id']
        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 iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method delete_entitlement_item" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'entitlement_id' is set
        if ('entitlement_id' not in params) or (params['entitlement_id'] is None):
            raise ValueError("Missing the required parameter `entitlement_id` when calling `delete_entitlement_item`")


        collection_formats = {}

        path_params = {}
        if 'entitlement_id' in params:
            path_params['entitlement_id'] = params['entitlement_id']

        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'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/entitlements/{entitlement_id}', 'DELETE',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type=None,
                                        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 delete_entitlement_template(self, id, **kwargs):
        """
        Delete an entitlement template
        If cascade = 'detach', it will force delete the template even if it's attached to other objects. <br><br><b>Permissions Needed:</b> TEMPLATE_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.delete_entitlement_template(id, async=True)
        >>> result = thread.get()

        :param async bool
        :param str id: The id of the template (required)
        :param str cascade: The value needed to delete used templates
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.delete_entitlement_template_with_http_info(id, **kwargs)
        else:
            (data) = self.delete_entitlement_template_with_http_info(id, **kwargs)
            return data

    def delete_entitlement_template_with_http_info(self, id, **kwargs):
        """
        Delete an entitlement template
        If cascade = 'detach', it will force delete the template even if it's attached to other objects. <br><br><b>Permissions Needed:</b> TEMPLATE_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.delete_entitlement_template_with_http_info(id, async=True)
        >>> result = thread.get()

        :param async bool
        :param str id: The id of the template (required)
        :param str cascade: The value needed to delete used templates
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['id', 'cascade']
        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 iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method delete_entitlement_template" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'id' is set
        if ('id' not in params) or (params['id'] is None):
            raise ValueError("Missing the required parameter `id` when calling `delete_entitlement_template`")


        collection_formats = {}

        path_params = {}
        if 'id' in params:
            path_params['id'] = params['id']

        query_params = []
        if 'cascade' in params:
            query_params.append(('cascade', params['cascade']))

        header_params = {}

        form_params = []
        local_var_files = {}

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

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/entitlements/templates/{id}', 'DELETE',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type=None,
                                        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 get_entitlement_item(self, entitlement_id, **kwargs):
        """
        Get a single entitlement item
        <b>Permissions Needed:</b> ANY
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.get_entitlement_item(entitlement_id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int entitlement_id: The id of the entitlement (required)
        :return: EntitlementItem
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.get_entitlement_item_with_http_info(entitlement_id, **kwargs)
        else:
            (data) = self.get_entitlement_item_with_http_info(entitlement_id, **kwargs)
            return data

    def get_entitlement_item_with_http_info(self, entitlement_id, **kwargs):
        """
        Get a single entitlement item
        <b>Permissions Needed:</b> ANY
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.get_entitlement_item_with_http_info(entitlement_id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int entitlement_id: The id of the entitlement (required)
        :return: EntitlementItem
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['entitlement_id']
        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 iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_entitlement_item" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'entitlement_id' is set
        if ('entitlement_id' not in params) or (params['entitlement_id'] is None):
            raise ValueError("Missing the required parameter `entitlement_id` when calling `get_entitlement_item`")


        collection_formats = {}

        path_params = {}
        if 'entitlement_id' in params:
            path_params['entitlement_id'] = params['entitlement_id']

        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'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/entitlements/{entitlement_id}', 'GET',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='EntitlementItem',
                                        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 get_entitlement_items(self, **kwargs):
        """
        List and search entitlement items
        <b>Permissions Needed:</b> ANY
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.get_entitlement_items(async=True)
        >>> result = thread.get()

        :param async bool
        :param str filter_template: Filter for entitlements using a specified template
        :param int size: The number of objects returned per page
        :param int page: The number of the page returned, starting with 1
        :param str order: A comma separated list of sorting requirements in priority order, each entry matching PROPERTY_NAME:[ASC|DESC]
        :return: PageResourceEntitlementItem
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.get_entitlement_items_with_http_info(**kwargs)
        else:
            (data) = self.get_entitlement_items_with_http_info(**kwargs)
            return data

    def get_entitlement_items_with_http_info(self, **kwargs):
        """
        List and search entitlement items
        <b>Permissions Needed:</b> ANY
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.get_entitlement_items_with_http_info(async=True)
        >>> result = thread.get()

        :param async bool
        :param str filter_template: Filter for entitlements using a specified template
        :param int size: The number of objects returned per page
        :param int page: The number of the page returned, starting with 1
        :param str order: A comma separated list of sorting requirements in priority order, each entry matching PROPERTY_NAME:[ASC|DESC]
        :return: PageResourceEntitlementItem
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['filter_template', 'size', 'page', 'order']
        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 iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_entitlement_items" % key
                )
            params[key] = val
        del params['kwargs']


        collection_formats = {}

        path_params = {}

        query_params = []
        if 'filter_template' in params:
            query_params.append(('filter_template', params['filter_template']))
        if 'size' in params:
            query_params.append(('size', params['size']))
        if 'page' in params:
            query_params.append(('page', params['page']))
        if 'order' in params:
            query_params.append(('order', params['order']))

        header_params = {}

        form_params = []
        local_var_files = {}

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

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/entitlements', 'GET',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='PageResourceEntitlementItem',
                                        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 get_entitlement_template(self, id, **kwargs):
        """
        Get a single entitlement template
        <b>Permissions Needed:</b> TEMPLATE_ADMIN or ACHIEVEMENTS_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.get_entitlement_template(id, async=True)
        >>> result = thread.get()

        :param async bool
        :param str id: The id of the template (required)
        :return: ItemTemplateResource
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.get_entitlement_template_with_http_info(id, **kwargs)
        else:
            (data) = self.get_entitlement_template_with_http_info(id, **kwargs)
            return data

    def get_entitlement_template_with_http_info(self, id, **kwargs):
        """
        Get a single entitlement template
        <b>Permissions Needed:</b> TEMPLATE_ADMIN or ACHIEVEMENTS_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.get_entitlement_template_with_http_info(id, async=True)
        >>> result = thread.get()

        :param async bool
        :param str id: The id of the template (required)
        :return: ItemTemplateResource
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['id']
        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 iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_entitlement_template" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'id' is set
        if ('id' not in params) or (params['id'] is None):
            raise ValueError("Missing the required parameter `id` when calling `get_entitlement_template`")


        collection_formats = {}

        path_params = {}
        if 'id' in params:
            path_params['id'] = params['id']

        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'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/entitlements/templates/{id}', 'GET',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='ItemTemplateResource',
                                        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 get_entitlement_templates(self, **kwargs):
        """
        List and search entitlement templates
        <b>Permissions Needed:</b> TEMPLATE_ADMIN or ACHIEVEMENTS_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.get_entitlement_templates(async=True)
        >>> result = thread.get()

        :param async bool
        :param int size: The number of objects returned per page
        :param int page: The number of the page returned, starting with 1
        :param str order: A comma separated list of sorting requirements in priority order, each entry matching PROPERTY_NAME:[ASC|DESC]
        :return: PageResourceItemTemplateResource
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.get_entitlement_templates_with_http_info(**kwargs)
        else:
            (data) = self.get_entitlement_templates_with_http_info(**kwargs)
            return data

    def get_entitlement_templates_with_http_info(self, **kwargs):
        """
        List and search entitlement templates
        <b>Permissions Needed:</b> TEMPLATE_ADMIN or ACHIEVEMENTS_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.get_entitlement_templates_with_http_info(async=True)
        >>> result = thread.get()

        :param async bool
        :param int size: The number of objects returned per page
        :param int page: The number of the page returned, starting with 1
        :param str order: A comma separated list of sorting requirements in priority order, each entry matching PROPERTY_NAME:[ASC|DESC]
        :return: PageResourceItemTemplateResource
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['size', 'page', 'order']
        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 iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_entitlement_templates" % key
                )
            params[key] = val
        del params['kwargs']


        collection_formats = {}

        path_params = {}

        query_params = []
        if 'size' in params:
            query_params.append(('size', params['size']))
        if 'page' in params:
            query_params.append(('page', params['page']))
        if 'order' in params:
            query_params.append(('order', params['order']))

        header_params = {}

        form_params = []
        local_var_files = {}

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

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/entitlements/templates', 'GET',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='PageResourceItemTemplateResource',
                                        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 get_user_inventories(self, id, **kwargs):
        """
        List the user inventory entries for a given user
        <b>Permissions Needed:</b> INVENTORY_ADMIN or owner
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.get_user_inventories(id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int id: The id of the user (required)
        :param bool inactive: If true, accepts inactive user inventories
        :param int size: The number of objects returned per page
        :param int page: The number of the page returned, starting with 1
        :param str filter_item_name: Filter by items whose name starts with a string
        :param int filter_item_id: Filter by item id
        :param str filter_username: Filter by entries owned by the user with the specified username
        :param str filter_group: Filter by entries owned by the users in a given group, by unique name
        :param str filter_date: A comma separated string without spaces.  First value is the operator to search on, second value is the log start date, a unix timestamp in seconds. Can be repeated for a range, eg: GT,123,LT,456  Allowed operators: (GT, LT, EQ, GOE, LOE).
        :return: PageResourceUserInventoryResource
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.get_user_inventories_with_http_info(id, **kwargs)
        else:
            (data) = self.get_user_inventories_with_http_info(id, **kwargs)
            return data

    def get_user_inventories_with_http_info(self, id, **kwargs):
        """
        List the user inventory entries for a given user
        <b>Permissions Needed:</b> INVENTORY_ADMIN or owner
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.get_user_inventories_with_http_info(id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int id: The id of the user (required)
        :param bool inactive: If true, accepts inactive user inventories
        :param int size: The number of objects returned per page
        :param int page: The number of the page returned, starting with 1
        :param str filter_item_name: Filter by items whose name starts with a string
        :param int filter_item_id: Filter by item id
        :param str filter_username: Filter by entries owned by the user with the specified username
        :param str filter_group: Filter by entries owned by the users in a given group, by unique name
        :param str filter_date: A comma separated string without spaces.  First value is the operator to search on, second value is the log start date, a unix timestamp in seconds. Can be repeated for a range, eg: GT,123,LT,456  Allowed operators: (GT, LT, EQ, GOE, LOE).
        :return: PageResourceUserInventoryResource
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['id', 'inactive', 'size', 'page', 'filter_item_name', 'filter_item_id', 'filter_username', 'filter_group', 'filter_date']
        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 iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_user_inventories" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'id' is set
        if ('id' not in params) or (params['id'] is None):
            raise ValueError("Missing the required parameter `id` when calling `get_user_inventories`")


        collection_formats = {}

        path_params = {}
        if 'id' in params:
            path_params['id'] = params['id']

        query_params = []
        if 'inactive' in params:
            query_params.append(('inactive', params['inactive']))
        if 'size' in params:
            query_params.append(('size', params['size']))
        if 'page' in params:
            query_params.append(('page', params['page']))
        if 'filter_item_name' in params:
            query_params.append(('filter_item_name', params['filter_item_name']))
        if 'filter_item_id' in params:
            query_params.append(('filter_item_id', params['filter_item_id']))
        if 'filter_username' in params:
            query_params.append(('filter_username', params['filter_username']))
        if 'filter_group' in params:
            query_params.append(('filter_group', params['filter_group']))
        if 'filter_date' in params:
            query_params.append(('filter_date', params['filter_date']))

        header_params = {}

        form_params = []
        local_var_files = {}

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

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/users/{id}/inventory', 'GET',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='PageResourceUserInventoryResource',
                                        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 get_user_inventory(self, user_id, id, **kwargs):
        """
        Get an inventory entry
        <b>Permissions Needed:</b> INVENTORY_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.get_user_inventory(user_id, id, async=True)
        >>> result = thread.get()

        :param async bool
        :param str user_id: The id of the inventory owner or 'me' for the logged in user (required)
        :param int id: The id of the user inventory (required)
        :return: UserInventoryResource
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.get_user_inventory_with_http_info(user_id, id, **kwargs)
        else:
            (data) = self.get_user_inventory_with_http_info(user_id, id, **kwargs)
            return data

    def get_user_inventory_with_http_info(self, user_id, id, **kwargs):
        """
        Get an inventory entry
        <b>Permissions Needed:</b> INVENTORY_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.get_user_inventory_with_http_info(user_id, id, async=True)
        >>> result = thread.get()

        :param async bool
        :param str user_id: The id of the inventory owner or 'me' for the logged in user (required)
        :param int id: The id of the user inventory (required)
        :return: UserInventoryResource
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['user_id', 'id']
        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 iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_user_inventory" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'user_id' is set
        if ('user_id' not in params) or (params['user_id'] is None):
            raise ValueError("Missing the required parameter `user_id` when calling `get_user_inventory`")
        # verify the required parameter 'id' is set
        if ('id' not in params) or (params['id'] is None):
            raise ValueError("Missing the required parameter `id` when calling `get_user_inventory`")


        collection_formats = {}

        path_params = {}
        if 'user_id' in params:
            path_params['user_id'] = params['user_id']
        if 'id' in params:
            path_params['id'] = params['id']

        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'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/users/{user_id}/inventory/{id}', 'GET',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='UserInventoryResource',
                                        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 get_user_inventory_log(self, user_id, id, **kwargs):
        """
        List the log entries for this inventory entry
        <b>Permissions Needed:</b> INVENTORY_ADMIN or owner
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.get_user_inventory_log(user_id, id, async=True)
        >>> result = thread.get()

        :param async bool
        :param str user_id: The id of the inventory owner or 'me' for the logged in user (required)
        :param int id: The id of the user inventory (required)
        :param int size: The number of objects returned per page
        :param int page: The number of the page returned, starting with 1
        :return: PageResourceUserItemLogResource
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.get_user_inventory_log_with_http_info(user_id, id, **kwargs)
        else:
            (data) = self.get_user_inventory_log_with_http_info(user_id, id, **kwargs)
            return data

    def get_user_inventory_log_with_http_info(self, user_id, id, **kwargs):
        """
        List the log entries for this inventory entry
        <b>Permissions Needed:</b> INVENTORY_ADMIN or owner
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.get_user_inventory_log_with_http_info(user_id, id, async=True)
        >>> result = thread.get()

        :param async bool
        :param str user_id: The id of the inventory owner or 'me' for the logged in user (required)
        :param int id: The id of the user inventory (required)
        :param int size: The number of objects returned per page
        :param int page: The number of the page returned, starting with 1
        :return: PageResourceUserItemLogResource
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['user_id', 'id', 'size', 'page']
        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 iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_user_inventory_log" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'user_id' is set
        if ('user_id' not in params) or (params['user_id'] is None):
            raise ValueError("Missing the required parameter `user_id` when calling `get_user_inventory_log`")
        # verify the required parameter 'id' is set
        if ('id' not in params) or (params['id'] is None):
            raise ValueError("Missing the required parameter `id` when calling `get_user_inventory_log`")


        collection_formats = {}

        path_params = {}
        if 'user_id' in params:
            path_params['user_id'] = params['user_id']
        if 'id' in params:
            path_params['id'] = params['id']

        query_params = []
        if 'size' in params:
            query_params.append(('size', params['size']))
        if 'page' in params:
            query_params.append(('page', params['page']))

        header_params = {}

        form_params = []
        local_var_files = {}

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

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/users/{user_id}/inventory/{id}/log', 'GET',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='PageResourceUserItemLogResource',
                                        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 get_users_inventory(self, **kwargs):
        """
        List the user inventory entries for all users
        <b>Permissions Needed:</b> INVENTORY_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.get_users_inventory(async=True)
        >>> result = thread.get()

        :param async bool
        :param bool inactive: If true, accepts inactive user inventories
        :param int size: The number of objects returned per page
        :param int page: The number of the page returned, starting with 1
        :param str filter_item_name: Filter by items whose name starts with a string
        :param int filter_item_id: Filter by item id
        :param str filter_username: Filter by entries owned by the user with the specified username
        :param str filter_group: Filter by entries owned by the users in a given group, by unique name
        :param str filter_date: A comma separated string without spaces.  First value is the operator to search on, second value is the log start date, a unix timestamp in seconds. Can be repeated for a range, eg: GT,123,LT,456  Allowed operators: (GT, LT, EQ, GOE, LOE).
        :return: PageResourceUserInventoryResource
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.get_users_inventory_with_http_info(**kwargs)
        else:
            (data) = self.get_users_inventory_with_http_info(**kwargs)
            return data

    def get_users_inventory_with_http_info(self, **kwargs):
        """
        List the user inventory entries for all users
        <b>Permissions Needed:</b> INVENTORY_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.get_users_inventory_with_http_info(async=True)
        >>> result = thread.get()

        :param async bool
        :param bool inactive: If true, accepts inactive user inventories
        :param int size: The number of objects returned per page
        :param int page: The number of the page returned, starting with 1
        :param str filter_item_name: Filter by items whose name starts with a string
        :param int filter_item_id: Filter by item id
        :param str filter_username: Filter by entries owned by the user with the specified username
        :param str filter_group: Filter by entries owned by the users in a given group, by unique name
        :param str filter_date: A comma separated string without spaces.  First value is the operator to search on, second value is the log start date, a unix timestamp in seconds. Can be repeated for a range, eg: GT,123,LT,456  Allowed operators: (GT, LT, EQ, GOE, LOE).
        :return: PageResourceUserInventoryResource
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['inactive', 'size', 'page', 'filter_item_name', 'filter_item_id', 'filter_username', 'filter_group', 'filter_date']
        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 iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_users_inventory" % key
                )
            params[key] = val
        del params['kwargs']


        collection_formats = {}

        path_params = {}

        query_params = []
        if 'inactive' in params:
            query_params.append(('inactive', params['inactive']))
        if 'size' in params:
            query_params.append(('size', params['size']))
        if 'page' in params:
            query_params.append(('page', params['page']))
        if 'filter_item_name' in params:
            query_params.append(('filter_item_name', params['filter_item_name']))
        if 'filter_item_id' in params:
            query_params.append(('filter_item_id', params['filter_item_id']))
        if 'filter_username' in params:
            query_params.append(('filter_username', params['filter_username']))
        if 'filter_group' in params:
            query_params.append(('filter_group', params['filter_group']))
        if 'filter_date' in params:
            query_params.append(('filter_date', params['filter_date']))

        header_params = {}

        form_params = []
        local_var_files = {}

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

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/inventories', 'GET',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='PageResourceUserInventoryResource',
                                        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 grant_user_entitlement(self, user_id, grant_request, **kwargs):
        """
        Grant an entitlement
        <b>Permissions Needed:</b> INVENTORY_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.grant_user_entitlement(user_id, grant_request, async=True)
        >>> result = thread.get()

        :param async bool
        :param int user_id: The id of the user to grant the entitlement to (required)
        :param EntitlementGrantRequest grant_request: grantRequest (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.grant_user_entitlement_with_http_info(user_id, grant_request, **kwargs)
        else:
            (data) = self.grant_user_entitlement_with_http_info(user_id, grant_request, **kwargs)
            return data

    def grant_user_entitlement_with_http_info(self, user_id, grant_request, **kwargs):
        """
        Grant an entitlement
        <b>Permissions Needed:</b> INVENTORY_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.grant_user_entitlement_with_http_info(user_id, grant_request, async=True)
        >>> result = thread.get()

        :param async bool
        :param int user_id: The id of the user to grant the entitlement to (required)
        :param EntitlementGrantRequest grant_request: grantRequest (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['user_id', 'grant_request']
        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 iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method grant_user_entitlement" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'user_id' is set
        if ('user_id' not in params) or (params['user_id'] is None):
            raise ValueError("Missing the required parameter `user_id` when calling `grant_user_entitlement`")
        # verify the required parameter 'grant_request' is set
        if ('grant_request' not in params) or (params['grant_request'] is None):
            raise ValueError("Missing the required parameter `grant_request` when calling `grant_user_entitlement`")


        collection_formats = {}

        path_params = {}
        if 'user_id' in params:
            path_params['user_id'] = params['user_id']

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'grant_request' in params:
            body_params = params['grant_request']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/users/{user_id}/entitlements', 'POST',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type=None,
                                        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 update_entitlement_item(self, entitlement_id, **kwargs):
        """
        Update an entitlement item
        <b>Permissions Needed:</b> INVENTORY_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.update_entitlement_item(entitlement_id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int entitlement_id: The id of the entitlement (required)
        :param bool cascade: Whether to cascade group changes, such as in the limited gettable behavior. A 400 error will return otherwise if the group is already in use with different values.
        :param EntitlementItem entitlement_item: The entitlement item object
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.update_entitlement_item_with_http_info(entitlement_id, **kwargs)
        else:
            (data) = self.update_entitlement_item_with_http_info(entitlement_id, **kwargs)
            return data

    def update_entitlement_item_with_http_info(self, entitlement_id, **kwargs):
        """
        Update an entitlement item
        <b>Permissions Needed:</b> INVENTORY_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.update_entitlement_item_with_http_info(entitlement_id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int entitlement_id: The id of the entitlement (required)
        :param bool cascade: Whether to cascade group changes, such as in the limited gettable behavior. A 400 error will return otherwise if the group is already in use with different values.
        :param EntitlementItem entitlement_item: The entitlement item object
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['entitlement_id', 'cascade', 'entitlement_item']
        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 iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method update_entitlement_item" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'entitlement_id' is set
        if ('entitlement_id' not in params) or (params['entitlement_id'] is None):
            raise ValueError("Missing the required parameter `entitlement_id` when calling `update_entitlement_item`")


        collection_formats = {}

        path_params = {}
        if 'entitlement_id' in params:
            path_params['entitlement_id'] = params['entitlement_id']

        query_params = []
        if 'cascade' in params:
            query_params.append(('cascade', params['cascade']))

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'entitlement_item' in params:
            body_params = params['entitlement_item']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/entitlements/{entitlement_id}', 'PUT',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type=None,
                                        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 update_entitlement_template(self, id, **kwargs):
        """
        Update an entitlement template
        <b>Permissions Needed:</b> TEMPLATE_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.update_entitlement_template(id, async=True)
        >>> result = thread.get()

        :param async bool
        :param str id: The id of the template (required)
        :param ItemTemplateResource template: The updated template
        :return: ItemTemplateResource
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.update_entitlement_template_with_http_info(id, **kwargs)
        else:
            (data) = self.update_entitlement_template_with_http_info(id, **kwargs)
            return data

    def update_entitlement_template_with_http_info(self, id, **kwargs):
        """
        Update an entitlement template
        <b>Permissions Needed:</b> TEMPLATE_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.update_entitlement_template_with_http_info(id, async=True)
        >>> result = thread.get()

        :param async bool
        :param str id: The id of the template (required)
        :param ItemTemplateResource template: The updated template
        :return: ItemTemplateResource
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['id', 'template']
        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 iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method update_entitlement_template" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'id' is set
        if ('id' not in params) or (params['id'] is None):
            raise ValueError("Missing the required parameter `id` when calling `update_entitlement_template`")


        collection_formats = {}

        path_params = {}
        if 'id' in params:
            path_params['id'] = params['id']

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'template' in params:
            body_params = params['template']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/entitlements/templates/{id}', 'PUT',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='ItemTemplateResource',
                                        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 update_user_inventory_behavior_data(self, user_id, id, **kwargs):
        """
        Set the behavior data for an inventory entry
        <b>Permissions Needed:</b> INVENTORY_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.update_user_inventory_behavior_data(user_id, id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int user_id: The id of the user (required)
        :param int id: The id of the user inventory (required)
        :param object data: The data map
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.update_user_inventory_behavior_data_with_http_info(user_id, id, **kwargs)
        else:
            (data) = self.update_user_inventory_behavior_data_with_http_info(user_id, id, **kwargs)
            return data

    def update_user_inventory_behavior_data_with_http_info(self, user_id, id, **kwargs):
        """
        Set the behavior data for an inventory entry
        <b>Permissions Needed:</b> INVENTORY_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.update_user_inventory_behavior_data_with_http_info(user_id, id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int user_id: The id of the user (required)
        :param int id: The id of the user inventory (required)
        :param object data: The data map
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['user_id', 'id', 'data']
        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 iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method update_user_inventory_behavior_data" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'user_id' is set
        if ('user_id' not in params) or (params['user_id'] is None):
            raise ValueError("Missing the required parameter `user_id` when calling `update_user_inventory_behavior_data`")
        # verify the required parameter 'id' is set
        if ('id' not in params) or (params['id'] is None):
            raise ValueError("Missing the required parameter `id` when calling `update_user_inventory_behavior_data`")


        collection_formats = {}

        path_params = {}
        if 'user_id' in params:
            path_params['user_id'] = params['user_id']
        if 'id' in params:
            path_params['id'] = params['id']

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'data' in params:
            body_params = params['data']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/users/{user_id}/inventory/{id}/behavior-data', 'PUT',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type=None,
                                        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 update_user_inventory_expires(self, user_id, id, **kwargs):
        """
        Set the expiration date
        Will change the current grace period for a subscription but not the bill date (possibly even ending before having the chance to re-bill). <br><br><b>Permissions Needed:</b> INVENTORY_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.update_user_inventory_expires(user_id, id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int user_id: user_id (required)
        :param int id: The id of the user inventory (required)
        :param int timestamp: The new expiration date as a unix timestamp in seconds. May be null (no body).
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.update_user_inventory_expires_with_http_info(user_id, id, **kwargs)
        else:
            (data) = self.update_user_inventory_expires_with_http_info(user_id, id, **kwargs)
            return data

    def update_user_inventory_expires_with_http_info(self, user_id, id, **kwargs):
        """
        Set the expiration date
        Will change the current grace period for a subscription but not the bill date (possibly even ending before having the chance to re-bill). <br><br><b>Permissions Needed:</b> INVENTORY_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.update_user_inventory_expires_with_http_info(user_id, id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int user_id: user_id (required)
        :param int id: The id of the user inventory (required)
        :param int timestamp: The new expiration date as a unix timestamp in seconds. May be null (no body).
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['user_id', 'id', 'timestamp']
        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 iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method update_user_inventory_expires" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'user_id' is set
        if ('user_id' not in params) or (params['user_id'] is None):
            raise ValueError("Missing the required parameter `user_id` when calling `update_user_inventory_expires`")
        # verify the required parameter 'id' is set
        if ('id' not in params) or (params['id'] is None):
            raise ValueError("Missing the required parameter `id` when calling `update_user_inventory_expires`")


        collection_formats = {}

        path_params = {}
        if 'user_id' in params:
            path_params['user_id'] = params['user_id']
        if 'id' in params:
            path_params['id'] = params['id']

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'timestamp' in params:
            body_params = params['timestamp']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/users/{user_id}/inventory/{id}/expires', 'PUT',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type=None,
                                        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 update_user_inventory_status(self, user_id, id, **kwargs):
        """
        Set the status for an inventory entry
        <b>Permissions Needed:</b> INVENTORY_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.update_user_inventory_status(user_id, id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int user_id: The id of the user (required)
        :param int id: The id of the user inventory (required)
        :param InventoryStatusWrapper inventory_status: The inventory status object
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.update_user_inventory_status_with_http_info(user_id, id, **kwargs)
        else:
            (data) = self.update_user_inventory_status_with_http_info(user_id, id, **kwargs)
            return data

    def update_user_inventory_status_with_http_info(self, user_id, id, **kwargs):
        """
        Set the status for an inventory entry
        <b>Permissions Needed:</b> INVENTORY_ADMIN
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.update_user_inventory_status_with_http_info(user_id, id, async=True)
        >>> result = thread.get()

        :param async bool
        :param int user_id: The id of the user (required)
        :param int id: The id of the user inventory (required)
        :param InventoryStatusWrapper inventory_status: The inventory status object
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['user_id', 'id', 'inventory_status']
        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 iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method update_user_inventory_status" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'user_id' is set
        if ('user_id' not in params) or (params['user_id'] is None):
            raise ValueError("Missing the required parameter `user_id` when calling `update_user_inventory_status`")
        # verify the required parameter 'id' is set
        if ('id' not in params) or (params['id'] is None):
            raise ValueError("Missing the required parameter `id` when calling `update_user_inventory_status`")


        collection_formats = {}

        path_params = {}
        if 'user_id' in params:
            path_params['user_id'] = params['user_id']
        if 'id' in params:
            path_params['id'] = params['id']

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'inventory_status' in params:
            body_params = params['inventory_status']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/users/{user_id}/inventory/{id}/status', 'PUT',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type=None,
                                        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 use_user_entitlement_item(self, user_id, item_id, **kwargs):
        """
        Use an item
        <b>Permissions Needed:</b> INVENTORY_ADMIN or owner
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.use_user_entitlement_item(user_id, item_id, async=True)
        >>> result = thread.get()

        :param async bool
        :param str user_id: The id of the user to check for or 'me' for logged in user (required)
        :param int item_id: The id of the item (required)
        :param str sku: The specific sku of an entitlement_list addition to check entitlement for. This is of very limited and specific use and should generally be left out
        :param str info: Any additional info to add to the log about this use
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async'):
            return self.use_user_entitlement_item_with_http_info(user_id, item_id, **kwargs)
        else:
            (data) = self.use_user_entitlement_item_with_http_info(user_id, item_id, **kwargs)
            return data

    def use_user_entitlement_item_with_http_info(self, user_id, item_id, **kwargs):
        """
        Use an item
        <b>Permissions Needed:</b> INVENTORY_ADMIN or owner
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async=True
        >>> thread = api.use_user_entitlement_item_with_http_info(user_id, item_id, async=True)
        >>> result = thread.get()

        :param async bool
        :param str user_id: The id of the user to check for or 'me' for logged in user (required)
        :param int item_id: The id of the item (required)
        :param str sku: The specific sku of an entitlement_list addition to check entitlement for. This is of very limited and specific use and should generally be left out
        :param str info: Any additional info to add to the log about this use
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['user_id', 'item_id', 'sku', 'info']
        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 iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method use_user_entitlement_item" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'user_id' is set
        if ('user_id' not in params) or (params['user_id'] is None):
            raise ValueError("Missing the required parameter `user_id` when calling `use_user_entitlement_item`")
        # verify the required parameter 'item_id' is set
        if ('item_id' not in params) or (params['item_id'] is None):
            raise ValueError("Missing the required parameter `item_id` when calling `use_user_entitlement_item`")


        collection_formats = {}

        path_params = {}
        if 'user_id' in params:
            path_params['user_id'] = params['user_id']
        if 'item_id' in params:
            path_params['item_id'] = params['item_id']

        query_params = []
        if 'sku' in params:
            query_params.append(('sku', params['sku']))
        if 'info' in params:
            query_params.append(('info', params['info']))

        header_params = {}

        form_params = []
        local_var_files = {}

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

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = ['oauth2_client_credentials_grant', 'oauth2_password_grant']

        return self.api_client.call_api('/users/{user_id}/entitlements/{item_id}/use', 'POST',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type=None,
                                        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)
