# Generated by Django 5.0.9 on 2024-11-25 13:28

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ("dcim", "0191_module_bay_rebuild"),
        ("extras", "0121_customfield_related_object_filter"),
        ("virtualization", "0040_convert_disk_size"),
    ]

    operations = [
        migrations.CreateModel(
            name="AuthorizedKey",
            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,
                    ),
                ),
                ("public_key", models.TextField()),
                ("username", models.CharField(blank=True, default="", max_length=200)),
                (
                    "description",
                    models.CharField(blank=True, default="", max_length=200),
                ),
                ("comments", models.TextField(blank=True, default="")),
                (
                    "tags",
                    taggit.managers.TaggableManager(
                        through="extras.TaggedItem", to="extras.Tag"
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="AuthorizedKeyDevice",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False
                    ),
                ),
                (
                    "custom_field_data",
                    models.JSONField(
                        blank=True,
                        default=dict,
                        encoder=utilities.json.CustomFieldJSONEncoder,
                    ),
                ),
                (
                    "authorized_key",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="netbox_authorized_keys.authorizedkey",
                    ),
                ),
                (
                    "device",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, to="dcim.device"
                    ),
                ),
                (
                    "tags",
                    taggit.managers.TaggableManager(
                        through="extras.TaggedItem", to="extras.Tag"
                    ),
                ),
            ],
            options={
                "unique_together": {("authorized_key", "device")},
            },
        ),
        migrations.AddField(
            model_name="authorizedkey",
            name="devices",
            field=models.ManyToManyField(
                blank=True,
                related_name="authorized_keys",
                through="netbox_authorized_keys.AuthorizedKeyDevice",
                to="dcim.device",
            ),
        ),
        migrations.CreateModel(
            name="AuthorizedKeyVirtualMachine",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False
                    ),
                ),
                (
                    "custom_field_data",
                    models.JSONField(
                        blank=True,
                        default=dict,
                        encoder=utilities.json.CustomFieldJSONEncoder,
                    ),
                ),
                (
                    "authorized_key",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="netbox_authorized_keys.authorizedkey",
                    ),
                ),
                (
                    "tags",
                    taggit.managers.TaggableManager(
                        through="extras.TaggedItem", to="extras.Tag"
                    ),
                ),
                (
                    "virtual_machine",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="virtualization.virtualmachine",
                    ),
                ),
            ],
            options={
                "unique_together": {("authorized_key", "virtual_machine")},
            },
        ),
        migrations.AddField(
            model_name="authorizedkey",
            name="virtual_machines",
            field=models.ManyToManyField(
                blank=True,
                related_name="authorized_keys",
                through="netbox_authorized_keys.AuthorizedKeyVirtualMachine",
                to="virtualization.virtualmachine",
            ),
        ),
    ]
