Skip to content

Commit ca71922

Browse files
api: add REST API parameters to Swagger docs for monitoring dashboard endpoint
fixes #715
1 parent 6f6fd7e commit ca71922

File tree

1 file changed

+48
-0
lines changed
  • openwisp_monitoring/monitoring/api

1 file changed

+48
-0
lines changed

openwisp_monitoring/monitoring/api/views.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from cache_memoize import cache_memoize
22
from django.db.models import Q
3+
from drf_yasg import openapi
4+
from drf_yasg.utils import swagger_auto_schema
35
from rest_framework.exceptions import NotFound, PermissionDenied
46
from rest_framework.permissions import IsAuthenticated
57
from rest_framework.views import APIView
@@ -181,6 +183,52 @@ def _get_user_managed_orgs(self, request):
181183
return []
182184
return orgs
183185

186+
@swagger_auto_schema(
187+
manual_parameters=[
188+
openapi.Parameter(
189+
"organization_slug",
190+
openapi.IN_QUERY,
191+
description="Organization slug (e.g. PHYTunes)",
192+
type=openapi.TYPE_STRING,
193+
required=False,
194+
),
195+
openapi.Parameter(
196+
"location_id",
197+
openapi.IN_QUERY,
198+
description="Location ID",
199+
type=openapi.TYPE_STRING,
200+
required=False,
201+
),
202+
openapi.Parameter(
203+
"floorplan_id",
204+
openapi.IN_QUERY,
205+
description="Floor plan ID.",
206+
type=openapi.TYPE_STRING,
207+
required=False,
208+
),
209+
openapi.Parameter(
210+
"time",
211+
openapi.IN_QUERY,
212+
description="Timeframe in days (e.g. 1d means 1 day and same goes with higher)",
213+
type=openapi.TYPE_STRING,
214+
required=False,
215+
),
216+
openapi.Parameter(
217+
"start",
218+
openapi.IN_QUERY,
219+
description="Start time in YYYY-MM-DD H:M:S format",
220+
type=openapi.TYPE_STRING,
221+
required=False,
222+
),
223+
openapi.Parameter(
224+
"end",
225+
openapi.IN_QUERY,
226+
description="End time in YYYY-MM-DD H:M:S format",
227+
type=openapi.TYPE_STRING,
228+
required=False,
229+
),
230+
]
231+
)
184232
def get(self, request, *args, **kwargs):
185233
response = super().get(request, *args, **kwargs)
186234
if not request.GET.get("csv"):

0 commit comments

Comments
 (0)