89c84f10d0
* managed: move flowexporter to managed Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * *: implement SerializerModel in all models Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * managed: add initial api Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * managed: start blueprint Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * managed: spec Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * version blueprint Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * yep Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * remove v2, improve v1 Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * start custom tag, more rebrand Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * add default flows Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * move blueprints out of website Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * try new things Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * add !lookup, fix web Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * update and cleanup default Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * fix tags in lists Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * don't save field if its set to default value Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * more flow cleanup Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * format web Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * fix missing serializer for sms Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * ignore _set fields Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * remove custom file extension Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * migrate default flow to tenant Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * include blueprints Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * fix tests Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
77 lines
2.2 KiB
Python
77 lines
2.2 KiB
Python
"""Managed Object models"""
|
|
from uuid import uuid4
|
|
|
|
from django.contrib.postgres.fields import ArrayField
|
|
from django.db import models
|
|
from django.utils.translation import gettext_lazy as _
|
|
from rest_framework.serializers import Serializer
|
|
|
|
from authentik.lib.models import CreatedUpdatedModel, SerializerModel
|
|
|
|
|
|
class ManagedModel(models.Model):
|
|
"""Model which can be managed by authentik exclusively"""
|
|
|
|
managed = models.TextField(
|
|
default=None,
|
|
null=True,
|
|
verbose_name=_("Managed by authentik"),
|
|
help_text=_(
|
|
(
|
|
"Objects which are managed by authentik. These objects are created and updated "
|
|
"automatically. This is flag only indicates that an object can be overwritten by "
|
|
"migrations. You can still modify the objects via the API, but expect changes "
|
|
"to be overwritten in a later update."
|
|
)
|
|
),
|
|
unique=True,
|
|
)
|
|
|
|
class Meta:
|
|
|
|
abstract = True
|
|
|
|
|
|
class BlueprintInstanceStatus(models.TextChoices):
|
|
"""Instance status"""
|
|
|
|
SUCCESSFUL = "successful"
|
|
WARNING = "warning"
|
|
ERROR = "error"
|
|
UNKNOWN = "unknown"
|
|
|
|
|
|
class BlueprintInstance(SerializerModel, ManagedModel, CreatedUpdatedModel):
|
|
"""Instance of a single blueprint. Can be parameterized via context attribute when
|
|
blueprint in `path` has inputs."""
|
|
|
|
instance_uuid = models.UUIDField(primary_key=True, editable=False, default=uuid4)
|
|
|
|
name = models.TextField()
|
|
path = models.TextField()
|
|
context = models.JSONField()
|
|
last_applied = models.DateTimeField(auto_now=True)
|
|
status = models.TextField(choices=BlueprintInstanceStatus.choices)
|
|
enabled = models.BooleanField(default=True)
|
|
managed_models = ArrayField(models.TextField())
|
|
|
|
@property
|
|
def serializer(self) -> Serializer:
|
|
from authentik.blueprints.api import BlueprintInstanceSerializer
|
|
|
|
return BlueprintInstanceSerializer
|
|
|
|
def __str__(self) -> str:
|
|
return f"Blueprint Instance {self.name}"
|
|
|
|
class Meta:
|
|
|
|
verbose_name = _("Blueprint Instance")
|
|
verbose_name_plural = _("Blueprint Instances")
|
|
unique_together = (
|
|
(
|
|
"name",
|
|
"path",
|
|
),
|
|
)
|