Enhance API structure and documentation: Added new tags for Account, Integration, Automation, Linker, Optimizer, and Publisher; updated billing endpoints for admin and customer; improved API reference documentation; fixed endpoint paths in frontend services.
This commit is contained in:
@@ -8,6 +8,7 @@ from rest_framework.response import Response
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.utils import timezone
|
||||
from drf_spectacular.utils import extend_schema
|
||||
|
||||
from igny8_core.business.automation.models import AutomationConfig, AutomationRun
|
||||
from igny8_core.business.automation.services import AutomationService
|
||||
@@ -30,6 +31,7 @@ class AutomationViewSet(viewsets.ViewSet):
|
||||
site = get_object_or_404(Site, id=site_id, account=request.user.account)
|
||||
return site, None
|
||||
|
||||
@extend_schema(tags=['Automation'])
|
||||
@action(detail=False, methods=['get'])
|
||||
def config(self, request):
|
||||
"""
|
||||
@@ -68,6 +70,7 @@ class AutomationViewSet(viewsets.ViewSet):
|
||||
'next_run_at': config.next_run_at,
|
||||
})
|
||||
|
||||
@extend_schema(tags=['Automation'])
|
||||
@action(detail=False, methods=['put'])
|
||||
def update_config(self, request):
|
||||
"""
|
||||
@@ -142,6 +145,7 @@ class AutomationViewSet(viewsets.ViewSet):
|
||||
'next_run_at': config.next_run_at,
|
||||
})
|
||||
|
||||
@extend_schema(tags=['Automation'])
|
||||
@action(detail=False, methods=['post'])
|
||||
def run_now(self, request):
|
||||
"""
|
||||
@@ -175,6 +179,7 @@ class AutomationViewSet(viewsets.ViewSet):
|
||||
status=status.HTTP_500_INTERNAL_SERVER_ERROR
|
||||
)
|
||||
|
||||
@extend_schema(tags=['Automation'])
|
||||
@action(detail=False, methods=['get'])
|
||||
def current_run(self, request):
|
||||
"""
|
||||
@@ -211,6 +216,7 @@ class AutomationViewSet(viewsets.ViewSet):
|
||||
}
|
||||
})
|
||||
|
||||
@extend_schema(tags=['Automation'])
|
||||
@action(detail=False, methods=['post'])
|
||||
def pause(self, request):
|
||||
"""
|
||||
@@ -234,6 +240,7 @@ class AutomationViewSet(viewsets.ViewSet):
|
||||
status=status.HTTP_404_NOT_FOUND
|
||||
)
|
||||
|
||||
@extend_schema(tags=['Automation'])
|
||||
@action(detail=False, methods=['post'])
|
||||
def resume(self, request):
|
||||
"""
|
||||
@@ -262,6 +269,7 @@ class AutomationViewSet(viewsets.ViewSet):
|
||||
status=status.HTTP_404_NOT_FOUND
|
||||
)
|
||||
|
||||
@extend_schema(tags=['Automation'])
|
||||
@action(detail=False, methods=['get'])
|
||||
def history(self, request):
|
||||
"""
|
||||
@@ -291,6 +299,7 @@ class AutomationViewSet(viewsets.ViewSet):
|
||||
]
|
||||
})
|
||||
|
||||
@extend_schema(tags=['Automation'])
|
||||
@action(detail=False, methods=['get'])
|
||||
def logs(self, request):
|
||||
"""
|
||||
@@ -323,6 +332,7 @@ class AutomationViewSet(viewsets.ViewSet):
|
||||
status=status.HTTP_404_NOT_FOUND
|
||||
)
|
||||
|
||||
@extend_schema(tags=['Automation'])
|
||||
@action(detail=False, methods=['get'])
|
||||
def estimate(self, request):
|
||||
"""
|
||||
@@ -342,6 +352,7 @@ class AutomationViewSet(viewsets.ViewSet):
|
||||
'sufficient': site.account.credits >= (estimated_credits * 1.2)
|
||||
})
|
||||
|
||||
@extend_schema(tags=['Automation'])
|
||||
@action(detail=False, methods=['get'])
|
||||
def pipeline_overview(self, request):
|
||||
"""
|
||||
@@ -504,6 +515,7 @@ class AutomationViewSet(viewsets.ViewSet):
|
||||
]
|
||||
})
|
||||
|
||||
@extend_schema(tags=['Automation'])
|
||||
@action(detail=False, methods=['get'], url_path='current_processing')
|
||||
def current_processing(self, request):
|
||||
"""
|
||||
@@ -547,6 +559,7 @@ class AutomationViewSet(viewsets.ViewSet):
|
||||
status=status.HTTP_500_INTERNAL_SERVER_ERROR
|
||||
)
|
||||
|
||||
@extend_schema(tags=['Automation'])
|
||||
@action(detail=False, methods=['post'], url_path='pause')
|
||||
def pause_automation(self, request):
|
||||
"""
|
||||
@@ -596,6 +609,7 @@ class AutomationViewSet(viewsets.ViewSet):
|
||||
status=status.HTTP_500_INTERNAL_SERVER_ERROR
|
||||
)
|
||||
|
||||
@extend_schema(tags=['Automation'])
|
||||
@action(detail=False, methods=['post'], url_path='resume')
|
||||
def resume_automation(self, request):
|
||||
"""
|
||||
@@ -649,6 +663,7 @@ class AutomationViewSet(viewsets.ViewSet):
|
||||
status=status.HTTP_500_INTERNAL_SERVER_ERROR
|
||||
)
|
||||
|
||||
@extend_schema(tags=['Automation'])
|
||||
@action(detail=False, methods=['post'], url_path='cancel')
|
||||
def cancel_automation(self, request):
|
||||
"""
|
||||
|
||||
@@ -11,14 +11,21 @@ from .views import (
|
||||
AdminBillingViewSet,
|
||||
AccountPaymentMethodViewSet,
|
||||
)
|
||||
from igny8_core.modules.billing.views import (
|
||||
CreditBalanceViewSet,
|
||||
CreditUsageViewSet,
|
||||
)
|
||||
|
||||
router = DefaultRouter()
|
||||
router.register(r'invoices', InvoiceViewSet, basename='invoice')
|
||||
router.register(r'payments', PaymentViewSet, basename='payment')
|
||||
router.register(r'credit-packages', CreditPackageViewSet, basename='credit-package')
|
||||
router.register(r'transactions', CreditTransactionViewSet, basename='transaction')
|
||||
router.register(r'admin', AdminBillingViewSet, basename='admin-billing')
|
||||
router.register(r'payment-methods', AccountPaymentMethodViewSet, basename='payment-method')
|
||||
# Canonical credits endpoints (unified billing)
|
||||
router.register(r'credits/balance', CreditBalanceViewSet, basename='credit-balance')
|
||||
router.register(r'credits/usage', CreditUsageViewSet, basename='credit-usage')
|
||||
router.register(r'credits/transactions', CreditTransactionViewSet, basename='credit-transactions')
|
||||
|
||||
urlpatterns = [
|
||||
# Country/config-driven available methods (legacy alias)
|
||||
|
||||
@@ -9,6 +9,7 @@ from rest_framework.permissions import IsAuthenticated
|
||||
from django.http import HttpResponse
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.db import models
|
||||
from drf_spectacular.utils import extend_schema, extend_schema_view
|
||||
|
||||
from .models import (
|
||||
Invoice,
|
||||
@@ -366,6 +367,14 @@ class CreditTransactionViewSet(viewsets.ViewSet):
|
||||
})
|
||||
|
||||
|
||||
@extend_schema_view(
|
||||
invoices=extend_schema(tags=['Admin Billing']),
|
||||
payments=extend_schema(tags=['Admin Billing']),
|
||||
pending_payments=extend_schema(tags=['Admin Billing']),
|
||||
approve_payment=extend_schema(tags=['Admin Billing']),
|
||||
reject_payment=extend_schema(tags=['Admin Billing']),
|
||||
stats=extend_schema(tags=['Admin Billing']),
|
||||
)
|
||||
class AdminBillingViewSet(viewsets.ViewSet):
|
||||
"""Admin billing management"""
|
||||
permission_classes = [IsAuthenticated]
|
||||
|
||||
Reference in New Issue
Block a user