# Path: amon/apps/api/models.py



from django.shortcuts import render
from django.contrib import messages
from django.shortcuts import redirect
from django.urls import reverse
from django.contrib.auth.decorators import login_required
from amon.apps.settings.forms import DataRetentionForm, ApiKeyForm, CleanupDataForm
from amon.apps.api.models import api_key_model, api_history_model
        "form": form
    })


@login_required
def api(request):
    api_keys = api_key_model.get_all()

    if request.method == 'POST':
        form = ApiKeyForm(request.POST)
        if form.is_valid():
            form.save()

            messages.add_message(request, messages.INFO, 'API key created')
            redirect_url = reverse('settings_api')

            return redirect(redirect_url)
    else:
        form = ApiKeyForm()
    
    return render(request, 'settings/api.html', {
        "form": form,
        "api_keys": api_keys
    })


@login_required
def api_history(request):
    


# Path: amon/apps/api/models.py



# Path: amon/apps/settings/views.py
from django.shortcuts import render
from django.contrib import messages
from django.shortcuts import redirect
from django.urls import reverse
from django.contrib.auth.decorators import login_required
from amon.apps.settings.forms import DataRetentionForm, ApiKeyForm, CleanupDataForm
from amon.apps.api.models import api_key_model, api_history_model

        "form": form
    })


@login_required
def api(request):
    api_keys = api_key_model.get_all()

    if request.method == 'POST':
        form = ApiKeyForm(request.POST)
        if form.is_valid():
            form.save()

            messages.add_message(request, messages.INFO, 'API key created')
            redirect_url = reverse('settings_api')

            return redirect(redirect_url)
    else:
        form = ApiKeyForm()
    
    return render(request, 'settings/api.html', {
        "form": form,
        "api_keys": api_keys
    })


@login_required
def api_history(request):
    


    result = api_history_model.get_all()