-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add heartbeat to authoring api (#34449)
* feat: add heartbeat to authoring api
- Loading branch information
1 parent
eb26333
commit df3c38c
Showing
3 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
cms/djangoapps/contentstore/rest_api/v0/views/api_heartbeat.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
""" View For Getting the Status of The Authoring API """ | ||
import edx_api_doc_tools as apidocs | ||
from rest_framework.views import APIView | ||
from rest_framework.request import Request | ||
from rest_framework.response import Response | ||
from rest_framework import status | ||
from openedx.core.lib.api.view_utils import DeveloperErrorViewMixin, view_auth_classes | ||
import cms.djangoapps.contentstore.toggles as toggles | ||
|
||
|
||
class APIHeartBeatView(DeveloperErrorViewMixin, APIView): | ||
""" | ||
View for getting the Authoring API's status | ||
""" | ||
|
||
@apidocs.schema( | ||
parameters=[], | ||
responses={ | ||
200: "The API is online", | ||
401: "The requester is not authenticated.", | ||
403: "The API is not availible", | ||
}, | ||
) | ||
@view_auth_classes(is_authenticated=True) | ||
def get(self, request: Request): | ||
""" | ||
Get an object containing the Authoring API's status | ||
**Example Request** | ||
GET /api/contentstore/v0/heartbeat | ||
**Response Values** | ||
If the request is successful, an HTTP 200 "OK" response is returned. | ||
The HTTP 200 response contains a single dict with the "authoring_api_enabled" value "True". | ||
**Example Response** | ||
```json | ||
{ | ||
"authoring_api_enabled": "True" | ||
} | ||
``` | ||
""" | ||
if toggles.use_studio_content_api(): | ||
return Response({'status': 'heartbeat successful'}, status=status.HTTP_200_OK) | ||
return Response(status=status.HTTP_403_FORBIDDEN) |