<commit_before>import django_filters

from rest_framework import viewsets

from nodeconductor.structure import views as structure_views
from nodeconductor.openstack import models, serializers


class OpenStackServiceViewSet(structure_views.BaseServiceViewSet):
    queryset = models.OpenStackService.objects.all()
    serializer_class = serializers.ServiceSerializer
    import_serializer_class = serializers.InstanceImportSerializer


class OpenStackServiceProjectLinkViewSet(structure_views.BaseServiceProjectLinkViewSet):
    queryset = models.OpenStackServiceProjectLink.objects.all()
    serializer_class = serializers.ServiceProjectLinkSerializer


class FlavorViewSet(viewsets.ReadOnlyModelViewSet):
    queryset = models.Flavor.objects.all()
    serializer_class = serializers.FlavorSerializer
    lookup_field = 'uuid'


class ImageViewSet(viewsets.ReadOnlyModelViewSet):
    queryset = models.Image.objects.all()
    serializer_class = serializers.ImageSerializer<commit_msg>Add filters for service and service-project link<commit_after>import django_filters

from rest_framework import viewsets

from nodeconductor.core import filters as core_filters
from nodeconductor.structure import views as structure_views
from nodeconductor.openstack import models, serializers


class OpenStackServiceFilter(django_filters.FilterSet):
    name = django_filters.CharFilter(
        name='settings__name'
    )
    customer = django_filters.CharFilter(
        name='settings__customer__uuid'
    )
    customer_url = core_filters.URLFilter(
        viewset=structure_views.CustomerViewSet,
        name='settings__customer__uuid'
    )

    class Meta(object):
        model = models.OpenStackService
        fields = [
            'name',
            'customer_url',
        ]

class OpenStackServiceViewSet(structure_views.BaseServiceViewSet):
    queryset = models.OpenStackService.objects.all()
    serializer_class = serializers.ServiceSerializer
    import_serializer_class = serializers.InstanceImportSerializer
    filter_class = OpenStackServiceFilter


class OpenStackServiceProjectLinkFilter(django_filters.FilterSet):
    service = django_filters.CharFilter(
        name='service__uuid'
    )
    service_url = core_filters.URLFilter(
        viewset=OpenStackServiceViewSet,
        name='service__uuid'
    )
    project = django_filters.CharFilter(
        name='project__uuid'
    )
    project_url = core_filters.URLFilter(
        viewset=structure_views.ProjectViewSet,
        name='project__uuid'
    )

    class Meta(object):
        model = models.OpenStackServiceProjectLink
        fields = [
            'service',
            'service_url',
            'project',
            'project_url'
        ]

class OpenStackServiceProjectLinkViewSet(structure_views.BaseServiceProjectLinkViewSet):
    queryset = models.OpenStackServiceProjectLink.objects.all()
    serializer_class = serializers.ServiceProjectLinkSerializer
    filter_class = OpenStackServiceProjectLinkFilter


class FlavorViewSet(viewsets.ReadOnlyModelViewSet):
    queryset = models.Flavor.objects.all()
    serializer_class = serializers.FlavorSerializer
    lookup_field = 'uuid'


class ImageViewSet(viewsets.ReadOnlyModelViewSet):
    queryset = models.Image.objects.all()
    serializer_class = serializers.ImageSerializer
{'fraction_non_alphanumeric': 0.0662451068955134, 'fraction_numerical': 0.0, 'mean_word_length': 4.273015873015873, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4418387', 'n_tokens_mistral': 884, 'n_tokens_neox': 867, 'n_words': 149}