Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

from __future__ import annotations

from typing import Any

from airflow.exceptions import AirflowException, AirflowOptionalProviderFeatureException
from airflow.hooks.base import BaseHook

Expand Down Expand Up @@ -46,6 +48,29 @@ class LevelDBHook(BaseHook):
conn_type = "leveldb"
hook_name = "LevelDB"

@classmethod
def get_connection_form_widgets(cls) -> dict[str, Any]:
"""Return connection widgets to add to LevelDB connection form."""
from flask_babel import lazy_gettext
from wtforms import BooleanField

return {
"create_if_missing": BooleanField(
lazy_gettext("Create a database if it does not exist"), default=False
),
"error_if_exists": BooleanField(
lazy_gettext("Raise an exception if the database already exists"), default=False
),
}

@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
"""Return custom UI field behaviour for LevelDB connection."""
return {
"hidden_fields": ["login", "password", "schema", "port"],
"relabeling": {},
}

def __init__(self, leveldb_conn_id: str = default_conn_name):
super().__init__()
self.leveldb_conn_id = leveldb_conn_id
Expand Down
Loading