# Path: restapi/components/auth/model.py
# class BaseModel(db.Model):
# class APIAuth(BaseModel):
#     def __init__(self, key, ip, description):
#     def __repr__(self):


from restapi.components.auth import model
import base64
import hashlib
import random

__author__ = 'haukurk'



def get_apiauth_object_by_ip(ip):
    """
    Query the datastorage for an API key.
    @param ip: ip address
    @return: apiauth sqlachemy object.
    """
    return model.APIAuth.query.filter_by(ip=ip).first()


def get_apiauth_object_by_key(key):
    """
    Query the datastorage for an API key.
    @param ip: ip address
    @return: apiauth sqlachemy object.
    """
    return model.APIAuth.query.filter_by(key=key).first()


def get_apiauth_object_by_keyid(keyid):
    """
    Query the datastorage for an API key.
    @param ip: ip address
    @return: apiauth sqlachemy object.
    """

# Path: restapi/components/auth/model.py
# class BaseModel(db.Model):
# class APIAuth(BaseModel):
#     def __init__(self, key, ip, description):
#     def __repr__(self):


# Path: restapi/components/auth/helpers.py
from restapi.components.auth import model
import base64
import hashlib
import random


__author__ = 'haukurk'



def get_apiauth_object_by_ip(ip):
    """
    Query the datastorage for an API key.
    @param ip: ip address
    @return: apiauth sqlachemy object.
    """
    return model.APIAuth.query.filter_by(ip=ip).first()


def get_apiauth_object_by_key(key):
    """
    Query the datastorage for an API key.
    @param ip: ip address
    @return: apiauth sqlachemy object.
    """
    return model.APIAuth.query.filter_by(key=key).first()


def get_apiauth_object_by_keyid(keyid):
    """
    Query the datastorage for an API key.
    @param ip: ip address
    @return: apiauth sqlachemy object.
    """

    return model.APIAuth.query.filter_by(id=keyid).first()