Skip to content

Commit

Permalink
[api] Add new check_config API endpoint to validate Hue configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Harshg999 committed Feb 25, 2025
1 parent b9cc76e commit 3ff151d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
13 changes: 12 additions & 1 deletion desktop/core/src/desktop/api2.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
set_user_preferences,
uuid_default,
)
from desktop.views import get_banner_message, serve_403_error
from desktop.views import get_banner_message, serve_403_error, _get_config_errors
from filebrowser.conf import (
CONCURRENT_MAX_CONNECTIONS,
ENABLE_EXTRACT_UPLOADED_ARCHIVE,
Expand Down Expand Up @@ -1392,3 +1392,14 @@ def _paginate(request, queryset):
limit = int(request.GET.get('limit', 0))

return __paginate(page, limit, queryset)


@api_error_handler
def check_config(request):
"""Returns the configuration directory and the list of validation errors."""
response = {
'hue_config_dir': os.path.realpath(os.getenv("HUE_CONF_DIR", get_desktop_root("conf"))),
'config_error_list': _get_config_errors(request, cache=False),
}

return JsonResponse(response)
6 changes: 6 additions & 0 deletions desktop/core/src/desktop/api_public.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ def download_hue_logs(request):
return logs_api.download_hue_logs(django_request)


@api_view(["POST"])
def check_config(request):
django_request = get_django_request(request)
return desktop_api.check_config(django_request)


# Editor


Expand Down
1 change: 1 addition & 0 deletions desktop/core/src/desktop/api_public_urls_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
re_path(r'^logs/?$', api_public.get_hue_logs, name='core_get_hue_logs'),
re_path(r'^logs/download/?$', api_public.download_hue_logs, name='core_download_hue_logs'),
re_path(r'^get_config/?$', api_public.get_config),
re_path(r'^check_config/?$', api_public.check_config, name='core_check_config'),
re_path(r'^get_namespaces/(?P<interface>[\w\-]+)/?$', api_public.get_context_namespaces), # To remove
]

Expand Down

0 comments on commit 3ff151d

Please sign in to comment.