mirror of
https://github.com/eduardogsilva/wireguard_webadmin.git
synced 2026-02-20 19:46:17 +00:00
Add api_v2 app with ApiKey model and initial migration
This commit is contained in:
0
api_v2/__init__.py
Normal file
0
api_v2/__init__.py
Normal file
1
api_v2/admin.py
Normal file
1
api_v2/admin.py
Normal file
@@ -0,0 +1 @@
|
||||
# Register your models here.
|
||||
6
api_v2/apps.py
Normal file
6
api_v2/apps.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class ApiV2Config(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'api_v2'
|
||||
33
api_v2/migrations/0001_initial.py
Normal file
33
api_v2/migrations/0001_initial.py
Normal file
@@ -0,0 +1,33 @@
|
||||
# Generated by Django 5.2.11 on 2026-02-09 23:31
|
||||
|
||||
import uuid
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('wireguard', '0032_remove_peer_enabled_by_schedule'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='ApiKey',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=64, unique=True)),
|
||||
('token', models.UUIDField(default=uuid.uuid4, unique=True)),
|
||||
('allow_restart', models.BooleanField(default=True)),
|
||||
('allow_reload', models.BooleanField(default=True)),
|
||||
('allow_export', models.BooleanField(default=True)),
|
||||
('enabled', models.BooleanField(default=True)),
|
||||
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
|
||||
('created', models.DateTimeField(auto_now_add=True)),
|
||||
('updated', models.DateTimeField(auto_now=True)),
|
||||
('allowed_instances', models.ManyToManyField(blank=True, related_name='api_keys', to='wireguard.wireguardinstance')),
|
||||
],
|
||||
),
|
||||
]
|
||||
0
api_v2/migrations/__init__.py
Normal file
0
api_v2/migrations/__init__.py
Normal file
21
api_v2/models.py
Normal file
21
api_v2/models.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import uuid
|
||||
|
||||
from django.db import models
|
||||
|
||||
from wireguard.models import WireGuardInstance
|
||||
|
||||
|
||||
class ApiKey(models.Model):
|
||||
name = models.CharField(max_length=64, unique=True)
|
||||
token = models.UUIDField(default=uuid.uuid4, unique=True)
|
||||
allowed_instances = models.ManyToManyField(WireGuardInstance, blank=True, related_name='api_keys')
|
||||
allow_restart = models.BooleanField(default=True)
|
||||
allow_reload = models.BooleanField(default=True)
|
||||
allow_export = models.BooleanField(default=True)
|
||||
enabled = models.BooleanField(default=True)
|
||||
|
||||
uuid = models.UUIDField(default=uuid.uuid4, editable=False, unique=True)
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
updated = models.DateTimeField(auto_now=True)
|
||||
def __str__(self):
|
||||
return self.name
|
||||
1
api_v2/tests.py
Normal file
1
api_v2/tests.py
Normal file
@@ -0,0 +1 @@
|
||||
# Create your tests here.
|
||||
1
api_v2/views.py
Normal file
1
api_v2/views.py
Normal file
@@ -0,0 +1 @@
|
||||
# Create your views here.
|
||||
@@ -49,7 +49,8 @@ INSTALLED_APPS = [
|
||||
'cluster',
|
||||
'api',
|
||||
'routing_templates',
|
||||
'scheduler.apps.SchedulerConfig'
|
||||
'scheduler.apps.SchedulerConfig',
|
||||
'api_v2'
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
||||
Reference in New Issue
Block a user