# Generated by Django 3.2.18 on 2023-03-09 18:25

import apps.webhooks.models.webhook
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
import mirage.fields


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('user_management', '0009_organization_cluster_slug'),
    ]

    operations = [
        migrations.CreateModel(
            name='Webhook',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('public_primary_key', models.CharField(default=apps.webhooks.models.webhook.generate_public_primary_key_for_webhook, max_length=20, unique=True, validators=[django.core.validators.MinLengthValidator(13)])),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('deleted_at', models.DateTimeField(blank=True, null=True)),
                ('name', models.CharField(default=None, max_length=100, null=True)),
                ('username', models.CharField(default=None, max_length=100, null=True)),
                ('password', mirage.fields.EncryptedCharField(default=None, max_length=200, null=True)),
                ('authorization_header', mirage.fields.EncryptedCharField(default=None, max_length=1000, null=True)),
                ('trigger_template', models.TextField(default=None, null=True)),
                ('headers', models.TextField(default=None, null=True)),
                ('url', models.TextField(default=None, null=True)),
                ('data', models.TextField(default=None, null=True)),
                ('forward_all', models.BooleanField(default=True)),
                ('http_method', models.CharField(default='POST', max_length=32)),
                ('trigger_type', models.IntegerField(choices=[(0, 'Escalation step'), (1, 'Triggered'), (2, 'Acknowledged'), (3, 'Resolved'), (4, 'Silenced'), (5, 'Unsilenced'), (6, 'Unresolved')], default=None, null=True)),
                ('organization', models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='webhooks', to='user_management.organization')),
                ('team', models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='webhooks', to='user_management.team')),
                ('user', models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='webhooks', to='user_management.user')),
            ],
            options={
                'unique_together': {('name', 'organization')},
            },
        ),
        migrations.CreateModel(
            name='WebhookLog',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('last_run_at', models.DateTimeField(blank=True, null=True)),
                ('input_data', models.JSONField(default=None)),
                ('url', models.TextField(default=None, null=True)),
                ('trigger', models.TextField(default=None, null=True)),
                ('headers', models.TextField(default=None, null=True)),
                ('data', models.TextField(default=None, null=True)),
                ('response_status', models.CharField(default=None, max_length=100, null=True)),
                ('response', models.TextField(default=None, null=True)),
                ('webhook', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='logs', to='webhooks.webhook')),
            ],
        ),
    ]
