api: add cache timeouts to config API for outposts

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-08-19 23:15:46 +02:00
parent f0bc90738f
commit 6433b5982e
2 changed files with 22 additions and 1 deletions

View File

@ -5,7 +5,7 @@ from django.conf import settings
from django.db import models from django.db import models
from drf_spectacular.utils import extend_schema from drf_spectacular.utils import extend_schema
from kubernetes.config.incluster_config import SERVICE_HOST_ENV_NAME from kubernetes.config.incluster_config import SERVICE_HOST_ENV_NAME
from rest_framework.fields import BooleanField, CharField, ChoiceField, ListField from rest_framework.fields import BooleanField, CharField, ChoiceField, IntegerField, ListField
from rest_framework.permissions import AllowAny from rest_framework.permissions import AllowAny
from rest_framework.request import Request from rest_framework.request import Request
from rest_framework.response import Response from rest_framework.response import Response
@ -33,6 +33,11 @@ class ConfigSerializer(PassiveSerializer):
capabilities = ListField(child=ChoiceField(choices=Capabilities.choices)) capabilities = ListField(child=ChoiceField(choices=Capabilities.choices))
cache_timeout = IntegerField(required=True)
cache_timeout_flows = IntegerField(required=True)
cache_timeout_policies = IntegerField(required=True)
cache_timeout_reputation = IntegerField(required=True)
class ConfigView(APIView): class ConfigView(APIView):
"""Read-only view set that returns the current session's Configs""" """Read-only view set that returns the current session's Configs"""
@ -65,6 +70,10 @@ class ConfigView(APIView):
"error_reporting_environment": CONFIG.y("error_reporting.environment"), "error_reporting_environment": CONFIG.y("error_reporting.environment"),
"error_reporting_send_pii": CONFIG.y("error_reporting.send_pii"), "error_reporting_send_pii": CONFIG.y("error_reporting.send_pii"),
"capabilities": self.get_capabilities(), "capabilities": self.get_capabilities(),
"cache_timeout": int(CONFIG.y("redis.cache_timeout")),
"cache_timeout_flows": int(CONFIG.y("redis.cache_timeout_flows")),
"cache_timeout_policies": int(CONFIG.y("redis.cache_timeout_policies")),
"cache_timeout_reputation": int(CONFIG.y("redis.cache_timeout_reputation")),
} }
) )
return Response(config.data) return Response(config.data)

View File

@ -20625,7 +20625,19 @@ components:
type: array type: array
items: items:
$ref: '#/components/schemas/CapabilitiesEnum' $ref: '#/components/schemas/CapabilitiesEnum'
cache_timeout:
type: integer
cache_timeout_flows:
type: integer
cache_timeout_policies:
type: integer
cache_timeout_reputation:
type: integer
required: required:
- cache_timeout
- cache_timeout_flows
- cache_timeout_policies
- cache_timeout_reputation
- capabilities - capabilities
- error_reporting_enabled - error_reporting_enabled
- error_reporting_environment - error_reporting_environment