Commit a9844ae2 authored by John Red Medrano's avatar John Red Medrano

added queryparams ids on application endpoints

parent bc67b379
......@@ -2,7 +2,7 @@ from django.urls import path, include
from rest_framework.routers import DefaultRouter
from api.viewsets.services import APIServiceViewSet
from api.viewsets.endpoints import APIEndpointViewSet
from api.viewsets.applications import ApplicationViewSet, GroupDependentViewSet
from api.viewsets.applications import ApplicationViewSet, MainApplicationViewSet
from api.views import (
APIGatewayList, APIGatewaySlugDetail, APIGatewaySlugModelDetail
)
......@@ -11,7 +11,7 @@ router = DefaultRouter()
router.register(r'applications', ApplicationViewSet)
router.register(r'services', APIServiceViewSet)
router.register(r'endpoint', APIEndpointViewSet)
router.register(r'group-dependent', GroupDependentViewSet)
router.register(r'main-application', MainApplicationViewSet)
urlpatterns = [
path('', include(router.urls)),
......
......@@ -50,11 +50,17 @@ class ApplicationViewSet(viewsets.ModelViewSet):
def list(self, request, *args, **kwargs):
try:
queryset = Application.objects.filter(deleted_at__exact=None)
ids = self.request.query_params.get(
'ids', None
)
if not queryset.exists():
message = status_message_response(
200, 'success', 'No records found', []
)
return Response(message)
if ids is not None:
ids = ids.split(',')
queryset = queryset.filter(id__in=ids)
page = self.paginate_queryset(queryset)
if page is not None:
......@@ -237,7 +243,7 @@ class ApplicationViewSet(viewsets.ModelViewSet):
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
class GroupDependentViewSet(viewsets.ModelViewSet):
class MainApplicationViewSet(viewsets.ModelViewSet):
queryset = Application.objects.all()
serializer_class = GroupDependentSerializer
......
......@@ -32,5 +32,5 @@ DATABASES = {
AUTHENTICATOR_IP = config['SERVICE']['AUTHENTICATOR_IP']
AUTHENTICATOR_PATH = '/api/v1/authenticator'
VALIDATE_TOKEN_URL = f'http://{AUTHENTICATOR_IP}{AUTHENTICATOR_PATH}/validate-token/'
ACCOUNT_GROUP = f'http://{AUTHENTICATOR_IP}{AUTHENTICATOR_PATH}/application-dependent'
VALIDATE_TOKEN_URL = f'http://{AUTHENTICATOR_IP}{AUTHENTICATOR_PATH}/authenticator-validate-token/'
ACCOUNT_GROUP = f'http://{AUTHENTICATOR_IP}{AUTHENTICATOR_PATH}/authenticator-group'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment