<commit_before># -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from django.utils.translation import ugettext_lazy as _
import logging

from rest_framework import viewsets
from rest_framework.response import Response
from rest_framework.decorators import action, link

from physical.models import Engine, EngineType

LOG = logging.getLogger(__name__)

class TsuruViewSet(viewsets.ViewSet):
    
    def list(self, request):
        return Response({"status": "list"})
    
    def create(self, request):
        """
         Creates a new instance

         Return codes:
         201: when the instance is successfully created. You don’t need to include any content in the response body.
         500: in case of any failure in the creation process. Make sure you include an explanation for the failure in the response body.
         """
        return Response({"status": "create"})
            
    @action()
    def resources(self, request, pk=None):
        """
        Creates a new instance. The pk is the name of the engine
        
        Return codes:
        201: when the instance is successfully created. You don’t need to include any content in the response body.
        500: in case of any failure in the creation process. Make sure you include an explanation for the failure in the response body.
        """
        LOG.info("Call for %s api" % pk)
        try:
            engine_type = EngineType.objects.get(name=pk)
        except EngineType.DoesNotExist:
            return Response(data={"error": "endpoint not available for %s" % pk}, status=500)
        
        return Response({"status": "ok", "engine_type": engine_type.name})
    
    @link()
    def status(self, request, pk=None):
        return Response({"status": "ok"})
    <commit_msg>fixing urls<commit_after># -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from django.utils.translation import ugettext_lazy as _
import logging

from rest_framework import viewsets
from rest_framework.response import Response
from rest_framework.decorators import action, link

from physical.models import Engine, EngineType

LOG = logging.getLogger(__name__)

class TsuruViewSet(viewsets.ViewSet):
    
    def __check_service_availability(self, service_name):
        """
        Checks the availability of the service.
        Returns engine_type for the service or a response error 500 if not found.
        
        """
        engine_type = None
        try:
            engine_type = EngineType.objects.get(name=service_name)
            return engine_type
        except EngineType.DoesNotExist:
            LOG.warning("endpoint not available for %s" % service_name)
        
        return engine_type


    def list(self, request):
        return Response({"status": "list"})
    
    def create(self, request):
        """
         Creates a new instance

         Return codes:
         201: when the instance is successfully created. You don’t need to include any content in the response body.
         500: in case of any failure in the creation process. Make sure you include an explanation for the failure in the response body.
         """
        return Response({"status": "create"})
            
    @action()
    def resources(self, request, pk=None):
        """
        Creates a new instance. The pk is the name of the engine
        
        Return codes:
        201: when the instance is successfully created. You don’t need to include any content in the response body.
        500: in case of any failure in the creation process. Make sure you include an explanation for the failure in the response body.
        """
        LOG.info("Call for %s api" % pk)
        engine_type = self.__check_service_availability(pk)
        if not engine_type:
            return Response(data={"error": "endpoint not available for %s" % pk}, status=500)

        return Response({"status": "ok", "engine_type": engine_type.name}, status=201)
    
    @link()
    def status(self, request, pk=None):
        engine_type = self.__check_service_availability(pk)
        if not engine_type:
            return Response(data={"error": "endpoint not available for %s" % pk}, status=500)

        return Response(data={"status": "ok"}, status=204)
    
{'fraction_non_alphanumeric': 0.08308121945543402, 'fraction_numerical': 0.010239702117756575, 'mean_word_length': 2.667235494880546, 'pattern_counts': {'":': 13, '<': 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': '1273675', 'n_tokens_mistral': 1154, 'n_tokens_neox': 1112, 'n_words': 432}