diff options
| author | 2020-07-15 13:10:44 +0200 | |
|---|---|---|
| committer | 2020-07-15 13:10:44 +0200 | |
| commit | cb5416bf54e512a66d36b72bff6f7b12a1c8cacd (patch) | |
| tree | 2f095932aeea5940ed8f5d8143462377fe2e2897 /pydis_site/apps/api/viewsets/bot | |
| parent | Merge branch 'master' into whitelist_system (diff) | |
Allowlist viewset.
https://github.com/python-discord/site/issues/305
Diffstat (limited to 'pydis_site/apps/api/viewsets/bot')
| -rw-r--r-- | pydis_site/apps/api/viewsets/bot/allowlist.py | 54 | 
1 files changed, 54 insertions, 0 deletions
| diff --git a/pydis_site/apps/api/viewsets/bot/allowlist.py b/pydis_site/apps/api/viewsets/bot/allowlist.py new file mode 100644 index 00000000..9b907d05 --- /dev/null +++ b/pydis_site/apps/api/viewsets/bot/allowlist.py @@ -0,0 +1,54 @@ +from rest_framework.viewsets import ModelViewSet + +from pydis_site.apps.api.models.bot.allowlist import AllowList +from pydis_site.apps.api.serializers import AllowListSerializer + + +class AllowListViewSet(ModelViewSet): +    """ +    View providing CRUD operations on items whitelisted or blacklisted by our bot. + +    ## Routes +    ### GET /bot/allowlists +    Returns all allowlist items in the database. + +    #### Response format +    >>> [ +    ...     { +    ...         'id': "2309268224", +    ...         'created_at': "01-01-2020 ...", +    ...         'updated_at': "01-01-2020 ...", +    ...         'type': "file_format", +    ...         'allowed': 'true', +    ...         'content': ".jpeg", +    ...     }, +    ...     ... +    ... ] + +    #### Status codes +    - 200: returned on success + +    ### POST /bot/allowedlists +    Adds a single allowedlist item to the database. + +    #### Request body +    >>> { +    ...         'type': str, +    ...         'allowed': bool, +    ...         'content': str, +    ... } + +    #### Status codes +    - 201: returned on success +    - 400: if one of the given fields is invalid + +    ### DELETE /bot/allowedlists/<title:str> +    Deletes the tag with the given `title`. + +    #### Status codes +    - 204: returned on success +    - 404: if a tag with the given `title` does not exist +    """ + +    serializer_class = AllowListSerializer +    queryset = AllowList.objects.all() | 
