Skip to content

Commit

Permalink
refactor: package rename data_collector to aggregated_collector
Browse files Browse the repository at this point in the history
  • Loading branch information
luisfelipec95 committed Feb 27, 2025
1 parent f4b7063 commit 33dd1b5
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 26 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from celery import shared_task
from django.db.utils import DatabaseError, OperationalError

from eox_core.api.data.data_collector.queries import PREDEFINED_QUERIES
from eox_core.api.data.data_collector.utils import execute_query, post_data_to_api, post_process_query_results
from eox_core.api.data.aggregated_collector.queries import PREDEFINED_QUERIES
from eox_core.api.data.aggregated_collector.utils import execute_query, post_data_to_api, post_process_query_results

logger = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
URL configuration for the Microsite API.
This module defines the URL patterns for the Microsite API,
including versioned endpoints for data_collector.
including versioned endpoints for aggregated_collector.
"""
from django.urls import include, re_path

app_name = 'eox_core' # pylint: disable=invalid-name


urlpatterns = [ # pylint: disable=invalid-name
re_path(r'^v1/', include('eox_core.api.data.data_collector.v1.urls', namespace='eox-data-api-collector-v1')),
re_path(r'^v1/', include('eox_core.api.data.aggregated_collector.v1.urls', namespace='eox-data-api-collector-v1')),
]
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Custom permission classes for the Data Collector API.
Custom permission classes for the Aggregated Collector API.
"""

import logging
Expand All @@ -11,14 +11,14 @@
logger = logging.getLogger(__name__)


class DatacollectorPermission(BasePermission):
class AggregatedCollectorPermission(BasePermission):
"""
Permission class to allow access only if the request contains a valid GitHub Action token.
"""

def has_permission(self, request, view):
auth_header = get_authorization_header(request).decode('utf-8')
auth_token = settings.EOX_CORE_DATA_COLLECT_AUTH_TOKEN
auth_token = settings.EOX_CORE_AGGREGATED_COLLECT_AUTH_TOKEN
if auth_header and auth_header == f"Bearer {auth_token}":
return True
return False
11 changes: 11 additions & 0 deletions eox_core/api/data/aggregated_collector/v1/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""_"""
from django.urls import path

from eox_core.api.data.aggregated_collector.v1.views import AggregatedCollectorView

# pylint: disable=invalid-name
app_name = "aggregated_collector"

urlpatterns = [
path("aggregated-collector/", AggregatedCollectorView.as_view(), name="aggregated_collector"),
]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Views for the Data Collector API (v1).
Views for the Aggregated Collector API (v1).
This module defines the API views for collecting and processing data.
"""
Expand All @@ -11,13 +11,13 @@
from rest_framework.response import Response
from rest_framework.views import APIView

from eox_core.api.data.data_collector.tasks import generate_report
from eox_core.api.data.data_collector.v1.permissions import DatacollectorPermission
from eox_core.api.data.aggregated_collector.tasks import generate_report
from eox_core.api.data.aggregated_collector.v1.permissions import AggregatedCollectorPermission

logger = logging.getLogger(__name__)


class DataCollectorView(APIView):
class AggregatedCollectorView(APIView):
"""
API view to handle data collection requests.
Expand All @@ -27,7 +27,7 @@ class DataCollectorView(APIView):
This view:
- Triggers an async task to execute queries and send results to a specified destination.
"""
permission_classes = [DatacollectorPermission]
permission_classes = [AggregatedCollectorPermission]

def post(self, request):
"""
Expand All @@ -45,8 +45,8 @@ def post(self, request):
status=status.HTTP_403_FORBIDDEN
)

destination_url = getattr(settings, "EOX_CORE_DATA_COLLECT_DESTINATION_URL", None)
token_generation_url = getattr(settings, "EOX_CORE_DATA_COLLECT_TOKEN_URL", None)
destination_url = getattr(settings, "EOX_CORE_AGGREGATED_COLLECT_DESTINATION_URL", None)
token_generation_url = getattr(settings, "EOX_CORE_AGGREGATED_COLLECT_TOKEN_URL", None)

if not destination_url or not token_generation_url:
logger.error("Data collection settings are missing.")
Expand Down
11 changes: 0 additions & 11 deletions eox_core/api/data/data_collector/v1/urls.py

This file was deleted.

2 changes: 1 addition & 1 deletion eox_core/api/data/v1/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
urlpatterns = [ # pylint: disable=invalid-name
re_path(r'^v1/', include((ROUTER.urls, 'eox_core'), namespace='eox-data-api-v1')),
re_path(r'^v1/tasks/(?P<task_id>.*)$', CeleryTasksStatus.as_view(), name="celery-data-api-tasks"),
re_path(r'^', include('eox_core.api.data.data_collector.urls', namespace='eox-data-api-collector')),
re_path(r'^', include('eox_core.api.data.aggregated_collector.urls', namespace='eox-data-api-collector')),
]

0 comments on commit 33dd1b5

Please sign in to comment.