|
14 | 14 | from django.db import connection
|
15 | 15 | from django.http import JsonResponse
|
16 | 16 | from django.shortcuts import redirect, render
|
17 |
| -from django.views.decorators.http import require_GET |
| 17 | +from drf_yasg.utils import swagger_auto_schema |
18 | 18 | from rest_framework import status
|
19 |
| -from rest_framework.decorators import api_view |
| 19 | +from rest_framework.decorators import api_view, permission_classes |
| 20 | +from rest_framework.permissions import AllowAny |
20 | 21 |
|
21 | 22 | from seed.celery import app
|
22 | 23 | from seed.decorators import ajax_request
|
23 | 24 | from seed.lib.superperms.orgs.decorators import has_perm_class
|
24 | 25 | from seed.utils.api import api_endpoint
|
| 26 | +from seed.utils.api_schema import AutoSchemaHelper |
25 | 27 | from seed.utils.users import get_js_role
|
26 | 28 |
|
27 | 29 | _log = logging.getLogger(__name__)
|
@@ -124,6 +126,42 @@ def celery_queue(request):
|
124 | 126 | return JsonResponse(results)
|
125 | 127 |
|
126 | 128 |
|
| 129 | +@swagger_auto_schema( |
| 130 | + method="GET", |
| 131 | + responses={ |
| 132 | + 200: AutoSchemaHelper.schema_factory( |
| 133 | + { |
| 134 | + "status": "string", |
| 135 | + "postgres": "string", |
| 136 | + "celery": "string", |
| 137 | + "redis": "string", |
| 138 | + }, |
| 139 | + example={ |
| 140 | + "status": "healthy", |
| 141 | + "postgres": "success", |
| 142 | + "celery": "success", |
| 143 | + "redis": "success", |
| 144 | + }, |
| 145 | + ), |
| 146 | + 418: AutoSchemaHelper.schema_factory( |
| 147 | + { |
| 148 | + "status": "string", |
| 149 | + "postgres": "string", |
| 150 | + "celery": "string", |
| 151 | + "redis": "string", |
| 152 | + }, |
| 153 | + example={ |
| 154 | + "status": "unhealthy", |
| 155 | + "postgres": "success", |
| 156 | + "celery": "error", |
| 157 | + "redis": "success", |
| 158 | + }, |
| 159 | + ), |
| 160 | + }, |
| 161 | +) |
| 162 | +@api_view(["GET"]) |
| 163 | +@permission_classes([AllowAny]) |
| 164 | +@ajax_request |
127 | 165 | def health_check(request):
|
128 | 166 | """
|
129 | 167 | Perform a health check without requiring authentication
|
@@ -158,11 +196,22 @@ def health_check(request):
|
158 | 196 | )
|
159 | 197 |
|
160 | 198 |
|
| 199 | +@swagger_auto_schema( |
| 200 | + method="GET", |
| 201 | + responses={ |
| 202 | + 200: AutoSchemaHelper.schema_factory( |
| 203 | + { |
| 204 | + "allow_signup": "boolean", |
| 205 | + } |
| 206 | + ) |
| 207 | + }, |
| 208 | +) |
| 209 | +@api_view(["GET"]) |
| 210 | +@permission_classes([AllowAny]) |
161 | 211 | @ajax_request
|
162 |
| -@require_GET |
163 | 212 | def config(request):
|
164 | 213 | """
|
165 |
| - Returns readonly django settings |
| 214 | + Returns readonly django settings without requiring authentication |
166 | 215 | """
|
167 | 216 |
|
168 | 217 | return {
|
|
0 commit comments