# Generated by Django 5.1.8 on 2025-09-29 08:18

import django.core.validators
import django.db.models.deletion
import taggit.managers
import utilities.json
from django.db import migrations, models

import netbox_panorama_configpump_plugin.device_config_sync_status.panorama


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ("core", "0012_job_object_type_optional"),
        ("dcim", "0200_populate_mac_addresses"),
        ("extras", "0122_charfield_null_choices"),
    ]

    operations = [
        migrations.CreateModel(
            name="ConnectionTemplate",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False
                    ),
                ),
                ("created", models.DateTimeField(auto_now_add=True, null=True)),
                ("last_updated", models.DateTimeField(auto_now=True, null=True)),
                (
                    "custom_field_data",
                    models.JSONField(
                        blank=True,
                        default=dict,
                        encoder=utilities.json.CustomFieldJSONEncoder,
                    ),
                ),
                ("description", models.CharField(blank=True, max_length=200)),
                ("comments", models.TextField(blank=True)),
                ("name", models.CharField(max_length=100, unique=True)),
                (
                    "panorama_url",
                    models.URLField(
                        validators=[
                            django.core.validators.URLValidator(
                                schemes=["http", "https"]
                            )
                        ]
                    ),
                ),
                ("token_key", models.CharField(max_length=255)),
                (
                    "request_timeout",
                    models.PositiveIntegerField(
                        blank=True,
                        null=True,
                        validators=[
                            django.core.validators.MinValueValidator(1),
                            django.core.validators.MaxValueValidator(3600),
                        ],
                    ),
                ),
                ("file_name_prefix", models.CharField(blank=True, max_length=255)),
                (
                    "platforms",
                    models.ManyToManyField(
                        blank=True,
                        related_name="connection_templates",
                        to="dcim.platform",
                    ),
                ),
                (
                    "tags",
                    taggit.managers.TaggableManager(
                        through="extras.TaggedItem", to="extras.Tag"
                    ),
                ),
            ],
            options={
                "ordering": ("name",),
            },
        ),
        migrations.CreateModel(
            name="Connection",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False
                    ),
                ),
                ("created", models.DateTimeField(auto_now_add=True, null=True)),
                ("last_updated", models.DateTimeField(auto_now=True, null=True)),
                (
                    "custom_field_data",
                    models.JSONField(
                        blank=True,
                        default=dict,
                        encoder=utilities.json.CustomFieldJSONEncoder,
                    ),
                ),
                ("description", models.CharField(blank=True, max_length=200)),
                ("comments", models.TextField(blank=True)),
                ("name", models.CharField(max_length=100, unique=True)),
                (
                    "tags",
                    taggit.managers.TaggableManager(
                        through="extras.TaggedItem", to="extras.Tag"
                    ),
                ),
                (
                    "connection_template",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="connections",
                        to="netbox_panorama_configpump_plugin.connectiontemplate",
                    ),
                ),
            ],
            options={
                "ordering": ("name",),
            },
        ),
        migrations.CreateModel(
            name="DeviceConfigSyncStatus",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False
                    ),
                ),
                ("created", models.DateTimeField(auto_now_add=True, null=True)),
                ("last_updated", models.DateTimeField(auto_now=True, null=True)),
                (
                    "custom_field_data",
                    models.JSONField(
                        blank=True,
                        default=dict,
                        encoder=utilities.json.CustomFieldJSONEncoder,
                    ),
                ),
                (
                    "panorama_configuration",
                    models.TextField(blank=True, default="", null=True),
                ),
                (
                    "lines_added",
                    models.PositiveIntegerField(blank=True, default=0, null=True),
                ),
                (
                    "lines_removed",
                    models.PositiveIntegerField(blank=True, default=0, null=True),
                ),
                (
                    "lines_changed",
                    models.PositiveIntegerField(blank=True, default=0, null=True),
                ),
                ("last_pull", models.DateTimeField(blank=True, null=True)),
                ("last_push", models.DateTimeField(blank=True, null=True)),
                ("config_render_ok", models.BooleanField(default=False)),
                (
                    "connection",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="device_config_sync_statuses",
                        to="netbox_panorama_configpump_plugin.connection",
                    ),
                ),
                (
                    "device",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="device_config_sync_statuses",
                        to="dcim.device",
                    ),
                ),
                (
                    "sync_job",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="device_config_sync_statuses",
                        to="core.job",
                    ),
                ),
                (
                    "tags",
                    taggit.managers.TaggableManager(
                        through="extras.TaggedItem", to="extras.Tag"
                    ),
                ),
            ],
            options={
                "ordering": ("device", "connection"),
                "indexes": [
                    models.Index(
                        fields=["last_pull"], name="idx_configsyncstatus_last_pull"
                    )
                ],
                "constraints": [
                    models.UniqueConstraint(
                        fields=("device",), name="uniq_configsyncstatus_device"
                    )
                ],
            },
            bases=(
                netbox_panorama_configpump_plugin.device_config_sync_status.panorama.PanoramaMixin,
                models.Model,
            ),
        ),
    ]
