forked from apache/airflow
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AIP84: UI endpoint for config (apache#44265)
* AIP84:UI endpoint for config * remove show_trigger_form_if_no_params * flatten the dict
- Loading branch information
1 parent
00fd540
commit 4f8cb6e
Showing
12 changed files
with
939 additions
and
369 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
from __future__ import annotations | ||
|
||
from pydantic import BaseModel | ||
|
||
|
||
class ConfigResponse(BaseModel): | ||
"""configuration serializer.""" | ||
|
||
navbar_color: str | ||
navbar_text_color: str | ||
navbar_hover_color: str | ||
navbar_text_hover_color: str | ||
navbar_logo_text_color: str | ||
page_size: int | ||
auto_refresh_interval: int | ||
default_ui_timezone: str | ||
hide_paused_dags_by_default: bool | ||
instance_name: str | ||
instance_name_has_markup: bool | ||
enable_swagger_ui: bool | ||
require_confirmation_dag_change: bool | ||
default_wrap: bool | ||
warn_deployment_exposure: bool | ||
audit_view_excluded_events: str | ||
audit_view_included_events: str | ||
is_k8s: bool | ||
test_connection: str | ||
state_color_mapping: dict |
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
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,71 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
from __future__ import annotations | ||
|
||
from typing import Any | ||
|
||
from fastapi import status | ||
|
||
from airflow.api_fastapi.common.router import AirflowRouter | ||
from airflow.api_fastapi.core_api.datamodels.ui.config import ConfigResponse | ||
from airflow.api_fastapi.core_api.openapi.exceptions import create_openapi_http_exception_doc | ||
from airflow.configuration import conf | ||
from airflow.settings import IS_K8S_OR_K8SCELERY_EXECUTOR, STATE_COLORS | ||
|
||
config_router = AirflowRouter(tags=["Config"]) | ||
|
||
WEBSERVER_CONFIG_KEYS = [ | ||
"navbar_color", | ||
"page_size", | ||
"auto_refresh_interval", | ||
"default_ui_timezone", | ||
"hide_paused_dags_by_default", | ||
"warn_deployment_exposure", | ||
"default_wrap", | ||
"require_confirmation_dag_change", | ||
"enable_swagger_ui", | ||
"instance_name_has_markup", | ||
"navbar_text_color", | ||
"navbar_hover_color", | ||
"navbar_text_hover_color", | ||
"navbar_logo_text_color", | ||
] | ||
|
||
|
||
@config_router.get( | ||
"/config", | ||
include_in_schema=False, | ||
responses=create_openapi_http_exception_doc([status.HTTP_404_NOT_FOUND]), | ||
) | ||
def get_configs() -> ConfigResponse: | ||
"""Get configs for UI.""" | ||
conf_dict = conf.as_dict() | ||
|
||
config = {key: conf_dict["webserver"].get(key) for key in WEBSERVER_CONFIG_KEYS} | ||
|
||
additional_config: dict[str, Any] = { | ||
"instance_name": conf.get("webserver", "instance_name", fallback="Airflow"), | ||
"audit_view_included_events": conf.get("webserver", "audit_view_included_events", fallback=""), | ||
"audit_view_excluded_events": conf.get("webserver", "audit_view_excluded_events", fallback=""), | ||
"test_connection": conf.get("core", "test_connection", fallback="Disabled"), | ||
"state_color_mapping": STATE_COLORS, | ||
"is_k8s": IS_K8S_OR_K8SCELERY_EXECUTOR, | ||
} | ||
|
||
config.update({key: value for key, value in additional_config.items()}) | ||
|
||
return ConfigResponse.model_validate(config) |
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
Oops, something went wrong.