# Path: locksmith/common.py
# def apicall(url, signkey, **params):
#     params['signature'] = get_signature(params, signkey)
#     data = sorted([(k,v) for k,v in params.iteritems()])
#     body = urllib.urlencode(data)
#     urllib2.urlopen(url, body)


import datetime
from urlparse import urljoin
from django.core.management.base import BaseCommand, CommandError
from django.conf import settings
from django.db.models import get_model, Count
from locksmith.common import apicall

APP = getattr(settings, 'LOCKSMITH_STATS_APP', 'api')
MODEL = getattr(settings, 'LOCKSMITH_STATS_MODEL', 'LogEntry')
DATE_FIELD = getattr(settings, 'LOCKSMITH_STATS_DATE_FIELD', 'timestamp')
ENDPOINT_FIELD = getattr(settings, 'LOCKSMITH_STATS_ENDPOINT_FIELD', 'method')
USER_FIELD = getattr(settings, 'LOCKSMITH_STATS_USER_FIELD', 'caller_key')


# Path: locksmith/common.py
# def apicall(url, signkey, **params):
#     params['signature'] = get_signature(params, signkey)
#     data = sorted([(k,v) for k,v in params.iteritems()])
#     body = urllib.urlencode(data)
#     urllib2.urlopen(url, body)


# Path: locksmith/auth/management/commands/apireport.py
import datetime
from urlparse import urljoin
from django.core.management.base import BaseCommand, CommandError
from django.conf import settings
from django.db.models import get_model, Count
from locksmith.common import apicall


APP = getattr(settings, 'LOCKSMITH_STATS_APP', 'api')
MODEL = getattr(settings, 'LOCKSMITH_STATS_MODEL', 'LogEntry')
DATE_FIELD = getattr(settings, 'LOCKSMITH_STATS_DATE_FIELD', 'timestamp')
ENDPOINT_FIELD = getattr(settings, 'LOCKSMITH_STATS_ENDPOINT_FIELD', 'method')
USER_FIELD = getattr(settings, 'LOCKSMITH_STATS_USER_FIELD', 'caller_key')


LogModel = get_model(APP, MODEL)