From 31619fb5aae82712eb288185fe6d5cabbf55d8c5 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 13 Jan 2024 21:11:28 +0100 Subject: [PATCH] use string for status Signed-off-by: Jens Langhammer --- .../events/migrations/0003_systemtask.py | 11 +++++++--- authentik/events/models.py | 12 +++++----- blueprints/schema.json | 4 ++-- schema.yml | 22 +++++++++---------- 4 files changed, 27 insertions(+), 22 deletions(-) diff --git a/authentik/events/migrations/0003_systemtask.py b/authentik/events/migrations/0003_systemtask.py index feaa0cf84..79ca4bf06 100644 --- a/authentik/events/migrations/0003_systemtask.py +++ b/authentik/events/migrations/0003_systemtask.py @@ -1,4 +1,4 @@ -# Generated by Django 5.0.1 on 2024-01-13 19:38 +# Generated by Django 5.0.1 on 2024-01-13 20:14 import uuid @@ -33,8 +33,13 @@ class Migration(migrations.Migration): ("finish_timestamp", models.DateTimeField(auto_now=True)), ( "status", - models.PositiveIntegerField( - choices=[(1, "Successful"), (2, "Warning"), (4, "Error"), (8, "Unknown")] + models.TextField( + choices=[ + ("unknown", "Unknown"), + ("successful", "Successful"), + ("warning", "Warning"), + ("error", "Error"), + ] ), ), ("description", models.TextField(null=True)), diff --git a/authentik/events/models.py b/authentik/events/models.py index 1cddeec39..8d4c70a97 100644 --- a/authentik/events/models.py +++ b/authentik/events/models.py @@ -585,13 +585,13 @@ class NotificationWebhookMapping(PropertyMapping): verbose_name_plural = _("Webhook Mappings") -class TaskStatus(models.IntegerChoices): +class TaskStatus(models.TextChoices): """Possible states of tasks""" - SUCCESSFUL = 1 - WARNING = 2 - ERROR = 4 - UNKNOWN = 8 + UNKNOWN = "unknown" + SUCCESSFUL = "successful" + WARNING = "warning" + ERROR = "error" class SystemTask(SerializerModel, ExpiringModel): @@ -604,7 +604,7 @@ class SystemTask(SerializerModel, ExpiringModel): start_timestamp = models.DateTimeField(auto_now_add=True) finish_timestamp = models.DateTimeField(auto_now=True) - status = models.PositiveIntegerField(choices=TaskStatus.choices) + status = models.TextField(choices=TaskStatus.choices) description = models.TextField(null=True) messages = models.JSONField() diff --git a/blueprints/schema.json b/blueprints/schema.json index 93eb152ac..7322553c5 100644 --- a/blueprints/schema.json +++ b/blueprints/schema.json @@ -3265,10 +3265,10 @@ "status": { "type": "string", "enum": [ + "UNKNOWN", "SUCCESSFUL", "WARNING", - "ERROR", - "UNKNOWN" + "ERROR" ], "title": "Status" }, diff --git a/schema.yml b/schema.yml index 987f18356..31e2afbe5 100644 --- a/schema.yml +++ b/schema.yml @@ -6871,17 +6871,17 @@ paths: - in: query name: status schema: - type: integer + type: string enum: - - 1 - - 2 - - 4 - - 8 + - error + - successful + - unknown + - warning description: |- - * `1` - Successful - * `2` - Warning - * `4` - Error - * `8` - Unknown + * `unknown` - Unknown + * `successful` - Successful + * `warning` - Warning + * `error` - Error - in: query name: uid schema: @@ -42744,16 +42744,16 @@ components: - uuid SystemTaskStatusEnum: enum: + - UNKNOWN - SUCCESSFUL - WARNING - ERROR - - UNKNOWN type: string description: |- + * `UNKNOWN` - UNKNOWN * `SUCCESSFUL` - SUCCESSFUL * `WARNING` - WARNING * `ERROR` - ERROR - * `UNKNOWN` - UNKNOWN TOTPDevice: type: object description: Serializer for totp authenticator devices