# Generated by Django 5.2.6 on 2025-10-06 14:10

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


class Migration(migrations.Migration):

    dependencies = [
        ('recruitment', '0020_delete_job'),
    ]

    operations = [
        migrations.AddField(
            model_name='source',
            name='api_key',
            field=models.CharField(blank=True, help_text='API key for authentication (will be encrypted)', max_length=255, null=True, verbose_name='API Key'),
        ),
        migrations.AddField(
            model_name='source',
            name='api_secret',
            field=models.CharField(blank=True, help_text='API secret for authentication (will be encrypted)', max_length=255, null=True, verbose_name='API Secret'),
        ),
        migrations.AddField(
            model_name='source',
            name='description',
            field=models.TextField(blank=True, help_text='A description of the source', verbose_name='Description'),
        ),
        migrations.AddField(
            model_name='source',
            name='integration_version',
            field=models.CharField(blank=True, help_text='Version of the integration protocol', max_length=50, verbose_name='Integration Version'),
        ),
        migrations.AddField(
            model_name='source',
            name='ip_address',
            field=models.GenericIPAddressField(blank=True, help_text='The IP address of the source', null=True, verbose_name='IP Address'),
        ),
        migrations.AddField(
            model_name='source',
            name='is_active',
            field=models.BooleanField(default=True, help_text='Whether this source is active for integration', verbose_name='Active'),
        ),
        migrations.AddField(
            model_name='source',
            name='last_sync_at',
            field=models.DateTimeField(blank=True, help_text='Timestamp of the last successful synchronization', null=True, verbose_name='Last Sync At'),
        ),
        migrations.AddField(
            model_name='source',
            name='source_type',
            field=models.CharField(default='erp', help_text='e.g., ATS, ERP ', max_length=100, verbose_name='Source Type'),
            preserve_default=False,
        ),
        migrations.AddField(
            model_name='source',
            name='sync_status',
            field=models.CharField(blank=True, choices=[('IDLE', 'Idle'), ('SYNCING', 'Syncing'), ('ERROR', 'Error'), ('DISABLED', 'Disabled')], default='IDLE', max_length=20, verbose_name='Sync Status'),
        ),
        migrations.AddField(
            model_name='source',
            name='trusted_ips',
            field=models.GenericIPAddressField(blank=True, help_text='Comma-separated list of trusted IP addresses', null=True, verbose_name='Trusted IP Addresses'),
        ),
        migrations.CreateModel(
            name='IntegrationLog',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('action', models.CharField(choices=[('REQUEST', 'Request'), ('RESPONSE', 'Response'), ('ERROR', 'Error'), ('SYNC', 'Sync'), ('CREATE_JOB', 'Create Job'), ('UPDATE_JOB', 'Update Job')], max_length=20, verbose_name='Action')),
                ('endpoint', models.CharField(blank=True, max_length=255, verbose_name='Endpoint')),
                ('method', models.CharField(blank=True, max_length=10, verbose_name='HTTP Method')),
                ('request_data', models.JSONField(blank=True, null=True, verbose_name='Request Data')),
                ('response_data', models.JSONField(blank=True, null=True, verbose_name='Response Data')),
                ('status_code', models.CharField(blank=True, max_length=10, verbose_name='Status Code')),
                ('error_message', models.TextField(blank=True, verbose_name='Error Message')),
                ('ip_address', models.GenericIPAddressField(verbose_name='IP Address')),
                ('user_agent', models.CharField(blank=True, max_length=255, verbose_name='User Agent')),
                ('processing_time', models.FloatField(blank=True, null=True, verbose_name='Processing Time (seconds)')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('source', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='integration_logs', to='recruitment.source', verbose_name='Source')),
            ],
            options={
                'verbose_name': 'Integration Log',
                'verbose_name_plural': 'Integration Logs',
                'ordering': ['-created_at'],
            },
        ),
    ]
