from rest_framework import serializers

from devices.fields import DeviceGroupRelatedField
from devices.models.device import DeviceGroup
from devices.models.firewall import ArmaIndustrialFirewall


class FirewallSerializer(serializers.ModelSerializer):
    group = DeviceGroupRelatedField(queryset=DeviceGroup.objects.all(), default=None, allow_null=True)

    class Meta:
        model = ArmaIndustrialFirewall
        exclude = ['type']
        read_only_fields = ['website', 'version', 'remote_name', 'identification_number', 'hash_number', 'flavour',
                            'email', 'copyright_years', 'copyright_url', 'copyright_owner', 'architecture', 'abi']


class CheckFirewallConnectionSerializer(serializers.Serializer):
    ip = serializers.IPAddressField()
    key = serializers.CharField(default='')
    secret = serializers.CharField(default='')


class AifUploadConfigSerializer(serializers.Serializer):
    conffile = serializers.FileField()


class AifUploadIdsRulesetsSerializer(serializers.Serializer):
    rulesets = serializers.FileField()
