# Path: amivapi/auth/auth.py
# class AdminOnlyAuth(AmivTokenAuth):
#     """Auth class to use if no access at all is given for non admins of a
#     resource."""
#     def create_user_lookup_filter(self, user):
#         """If this hook gets called, the user is not an admin for this resource.
#         Therefore no results should be given. To give a more precise error
#         message, we abort. Otherwise normal users would just see an empty list.
#         """
#         return None
# 
# Path: amivapi/utils.py
# def register_domain(app, domain):
#     """Add all resources in a domain to the app.
# 
#     The domain has to be deep-copied first because eve will modify it
#     (since it heavily relies on setdefault()), which can cause problems
#     especially in test environments, since the defaults don't get properly
#     erase sometimes.
# 
#     TODO: Make tests better maybe so this is no problem anymore?
# 
#     Args:
#         app (Eve object): The app to extend
#         domain (dict): The domain to be added to the app, will not be changed
#     """
#     domain_copy = deepcopy(domain)
# 
#     for resource, settings in domain_copy.items():
#         # Add default for the resource title:
#         # Capitalize like Eve does with item titles
#         settings.setdefault('resource_title', resource.capitalize())
# 
#         app.register_resource(resource, settings)
#         _better_schema_defaults(app, resource, settings)


from datetime import datetime as dt
from flask import abort, current_app, g
from amivapi.auth.auth import AdminOnlyAuth
from amivapi.utils import register_domain
    from secrets import token_urlsafe
    from amivapi.utils import token_urlsafe
(this would grant the API key rights to see all users and see
and modify/delete all sessions).

> **IMPORTANT: The most powerful permission**
>
> If you grant an API key `readwrite` permissions to API keys, this key will
> be able to create new API keys with any permissions and also modify it's
> own permissions!
>
> As a result, **`readwrite` permissions for api keys should only be assigned
> with great care**!

Just like [sessions](#tag/Session), API keys return a token which can be
sent in the header
[as described above](#section/Authentication-and-Authorization).
""")


apikeydomain = {
    'apikeys': {
        'resource_title': 'API Keys',
        'item_title': 'API Key',

        'description': description,

        'public_methods': [],
        'public_item_methods': [],
        'resource_methods': ['GET', 'POST'],
        'item_methods': ['GET', 'PATCH', 'DELETE'],


# Path: amivapi/auth/auth.py
# class AdminOnlyAuth(AmivTokenAuth):
#     """Auth class to use if no access at all is given for non admins of a
#     resource."""
#     def create_user_lookup_filter(self, user):
#         """If this hook gets called, the user is not an admin for this resource.
#         Therefore no results should be given. To give a more precise error
#         message, we abort. Otherwise normal users would just see an empty list.
#         """
#         return None
# 
# Path: amivapi/utils.py
# def register_domain(app, domain):
#     """Add all resources in a domain to the app.
# 
#     The domain has to be deep-copied first because eve will modify it
#     (since it heavily relies on setdefault()), which can cause problems
#     especially in test environments, since the defaults don't get properly
#     erase sometimes.
# 
#     TODO: Make tests better maybe so this is no problem anymore?
# 
#     Args:
#         app (Eve object): The app to extend
#         domain (dict): The domain to be added to the app, will not be changed
#     """
#     domain_copy = deepcopy(domain)
# 
#     for resource, settings in domain_copy.items():
#         # Add default for the resource title:
#         # Capitalize like Eve does with item titles
#         settings.setdefault('resource_title', resource.capitalize())
# 
#         app.register_resource(resource, settings)
#         _better_schema_defaults(app, resource, settings)


# Path: amivapi/auth/apikeys.py
from datetime import datetime as dt
from flask import abort, current_app, g
from amivapi.auth.auth import AdminOnlyAuth
from amivapi.utils import register_domain
    from secrets import token_urlsafe
    from amivapi.utils import token_urlsafe

(this would grant the API key rights to see all users and see
and modify/delete all sessions).

> **IMPORTANT: The most powerful permission**
>
> If you grant an API key `readwrite` permissions to API keys, this key will
> be able to create new API keys with any permissions and also modify it's
> own permissions!
>
> As a result, **`readwrite` permissions for api keys should only be assigned
> with great care**!

Just like [sessions](#tag/Session), API keys return a token which can be
sent in the header
[as described above](#section/Authentication-and-Authorization).
""")


apikeydomain = {
    'apikeys': {
        'resource_title': 'API Keys',
        'item_title': 'API Key',

        'description': description,

        'public_methods': [],
        'public_item_methods': [],
        'resource_methods': ['GET', 'POST'],
        'item_methods': ['GET', 'PATCH', 'DELETE'],


        'authentication': AdminOnlyAuth,