# Generated by Django 5.2.9 on 2026-01-05 00:21

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("content", "0003_initial"),
        ("groups", "0002_initial"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="WebRequestSampler",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_user_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                ("slug", models.SlugField(max_length=100, unique=True)),
                ("label", models.CharField(max_length=150)),
                ("description", models.TextField(blank=True)),
                (
                    "sampling_period_minutes",
                    models.PositiveIntegerField(
                        blank=True,
                        help_text="Minutes between automatic samples. Leave blank to disable scheduling.",
                        null=True,
                    ),
                ),
                ("last_sampled_at", models.DateTimeField(blank=True, null=True)),
                (
                    "owner",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="owned_web_request_samplers",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "security_group",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="web_request_samplers",
                        to="groups.securitygroup",
                    ),
                ),
            ],
            options={
                "verbose_name": "Web Request Sampler",
                "verbose_name_plural": "Web Request Samplers",
                "ordering": ["label"],
            },
        ),
        migrations.CreateModel(
            name="WebRequestStep",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_user_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                ("order", models.PositiveIntegerField(default=0)),
                ("slug", models.SlugField(max_length=100)),
                ("name", models.CharField(blank=True, max_length=150)),
                (
                    "curl_command",
                    models.TextField(
                        help_text="Full cURL command or arguments to execute when sampling."
                    ),
                ),
                (
                    "save_as_content",
                    models.BooleanField(
                        default=False,
                        help_text="Store the response body as a Content Sample attachment.",
                    ),
                ),
                (
                    "attachment_kind",
                    models.CharField(
                        choices=[
                            ("TEXT", "Text"),
                            ("IMAGE", "Image"),
                            ("AUDIO", "Audio"),
                        ],
                        default="TEXT",
                        help_text="Kind to assign when saving the response as a Content Sample.",
                        max_length=10,
                    ),
                ),
                (
                    "sampler",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="steps",
                        to="content.webrequestsampler",
                    ),
                ),
            ],
            options={
                "verbose_name": "Web Request Step",
                "verbose_name_plural": "Web Request Steps",
                "ordering": ["order", "id"],
                "unique_together": {("sampler", "slug")},
            },
        ),
        migrations.CreateModel(
            name="WebSample",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_user_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                ("document", models.JSONField(default=dict)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                (
                    "executed_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="web_samples",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "sampler",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="web_samples",
                        to="content.webrequestsampler",
                    ),
                ),
            ],
            options={
                "verbose_name": "Web Sample",
                "verbose_name_plural": "Web Samples",
                "ordering": ["-created_at"],
            },
        ),
        migrations.CreateModel(
            name="WebSampleAttachment",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_user_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                ("uri", models.CharField(max_length=500)),
                (
                    "content_sample",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="web_attachments",
                        to="content.contentsample",
                    ),
                ),
                (
                    "sample",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="attachments",
                        to="content.websample",
                    ),
                ),
                (
                    "step",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to="content.webrequeststep",
                    ),
                ),
            ],
            options={
                "verbose_name": "Web Sample Attachment",
                "verbose_name_plural": "Web Sample Attachments",
            },
        ),
    ]
