From c218a1c29a355ef84164c16d640ce029a42e4ce6 Mon Sep 17 00:00:00 2001 From: AnsibleGuy Date: Sat, 20 Jan 2024 17:02:43 +0100 Subject: [PATCH] lint & doc fixes --- README.md | 2 +- docs/source/usage/2_config.rst | 6 +++++- src/ansible-webui/aw/api_endpoints/base.py | 10 ++++++++++ src/ansible-webui/aw/api_endpoints/key.py | 8 ++++---- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c9412dc..25b9248 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ There are multiple Ansible WebUI products - how do they compare to this product? * **This project** - It is built to be very lightweight. + It is built to be lightweight. As Ansible already requires Python3 - I chose it as primary language. diff --git a/docs/source/usage/2_config.rst b/docs/source/usage/2_config.rst index 3502134..cb78c3a 100644 --- a/docs/source/usage/2_config.rst +++ b/docs/source/usage/2_config.rst @@ -78,6 +78,10 @@ Environmental variables * **AW_RUN_TIMEOUT** - Timeout for the execution of a playbook in seconds. Default: 3600 (1h) + Timeout for the execution of a playbook in seconds. Default: 3.600 (1h) You might want to lower this value to a sane value for your use-cases. + +* **AW_SESSION_TIMEOUT** + + Timeout for WebUI sessions in seconds. Default: 43.200 (12h) diff --git a/src/ansible-webui/aw/api_endpoints/base.py b/src/ansible-webui/aw/api_endpoints/base.py index ae9f8f6..547cb14 100644 --- a/src/ansible-webui/aw/api_endpoints/base.py +++ b/src/ansible-webui/aw/api_endpoints/base.py @@ -1,6 +1,7 @@ from django.conf import settings from django.contrib.auth.models import AnonymousUser from django.core.exceptions import ObjectDoesNotExist +from rest_framework import serializers from rest_framework.permissions import IsAuthenticated from rest_framework_api_key.permissions import BaseHasAPIKey @@ -27,3 +28,12 @@ def get_api_user(request) -> settings.AUTH_USER_MODEL: pass return request.user + + +class BaseResponse(serializers.Serializer): + + def create(self, validated_data): + pass + + def update(self, instance, validated_data): + pass diff --git a/src/ansible-webui/aw/api_endpoints/key.py b/src/ansible-webui/aw/api_endpoints/key.py index 5431d9d..73fec8d 100644 --- a/src/ansible-webui/aw/api_endpoints/key.py +++ b/src/ansible-webui/aw/api_endpoints/key.py @@ -7,15 +7,15 @@ from aw.utils.util import datetime_w_tz from aw.config.hardcoded import KEY_TIME_FORMAT from aw.model.api import AwAPIKey -from aw.api_endpoints.base import API_PERMISSION, get_api_user +from aw.api_endpoints.base import API_PERMISSION, get_api_user, BaseResponse # todo: allow user to add comment to easier identify token -class KeyReadResponse(serializers.Serializer): +class KeyReadResponse(BaseResponse): tokens = serializers.ListSerializer(child=serializers.CharField()) -class KeyWriteResponse(serializers.Serializer): +class KeyWriteResponse(BaseResponse): token = serializers.CharField() secret = serializers.CharField() @@ -50,7 +50,7 @@ def post(self, request): return Response({'token': token, 'key': key}) -class KeyDeleteResponse(serializers.Serializer): +class KeyDeleteResponse(BaseResponse): msg = serializers.CharField()