Skip to content

Commit 9ef77fa

Browse files
committed
feat: add hook-name to connection types
1 parent 39c936e commit 9ef77fa

89 files changed

Lines changed: 164 additions & 7 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

airflow-core/src/airflow/api_fastapi/core_api/services/ui/connections.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,10 @@ def hook_meta_data() -> list[ConnectionHookMetaData]:
241241
hook_name = raw_entry.hook_name
242242
hook_class_name = raw_entry.hook_class_name
243243
elif provider_entry:
244-
hook_name = conn_type
244+
hook_name = pm._hook_name_dict.get(conn_type, conn_type)
245245
hook_class_name = provider_entry.hook_class_name
246246
else:
247-
hook_name = conn_type
247+
hook_name = pm._hook_name_dict.get(conn_type, conn_type)
248248
hook_class_name = None
249249

250250
result.append(

airflow-core/src/airflow/provider.yaml.schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,10 @@
378378
"description": "Hook class name that implements the connection type",
379379
"type": "string"
380380
},
381+
"hook-name": {
382+
"description": "Display name for the connection type in the UI (e.g. 'File (path)', 'Slack')",
383+
"type": "string"
384+
},
381385
"ui-field-behaviour": {
382386
"description": "Customizations for standard connection form fields",
383387
"type": "object",

airflow-core/src/airflow/provider_info.schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,10 @@
298298
"hook-class-name": {
299299
"description": "Hook class name that implements the connection type",
300300
"type": "string"
301+
},
302+
"hook-name": {
303+
"description": "Display name for the connection type in the UI",
304+
"type": "string"
301305
}
302306
},
303307
"required": [

airflow-core/src/airflow/providers_manager.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,8 @@ def __init__(self):
413413
self._dialect_provider_dict: dict[str, DialectInfo] = {}
414414
# Keeps dict of hooks keyed by connection type. They are lazy evaluated at access time
415415
self._hooks_lazy_dict: LazyDictWithCache[str, HookInfo | Callable] = LazyDictWithCache()
416+
# Keeps hook display names read from provider.yaml (hook-name field)
417+
self._hook_name_dict: dict[str, str] = {}
416418
# Keeps methods that should be used to add custom widgets tuple of keyed by name of the extra field
417419
self._connection_form_widgets: dict[str, ConnectionFormWidgetInfo] = {}
418420
# Customizations for javascript fields are kept here
@@ -996,6 +998,9 @@ def _load_ui_metadata(self) -> None:
996998
if not connection_type or not hook_class_name:
997999
continue
9981000

1001+
if hook_name := conn_config.get("hook-name"):
1002+
self._hook_name_dict[connection_type] = hook_name
1003+
9991004
if conn_fields := conn_config.get("conn-fields"):
10001005
self._add_widgets(package_name, hook_class_name, connection_type, conn_fields)
10011006

providers/airbyte/src/airflow/providers/airbyte/get_provider_info.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def get_provider_info():
5050
"connection-types": [
5151
{
5252
"hook-class-name": "airflow.providers.airbyte.hooks.airbyte.AirbyteHook",
53+
"hook-name": "Airbyte",
5354
"connection-type": "airbyte",
5455
"ui-field-behaviour": {
5556
"hidden-fields": ["extra", "port"],

providers/alibaba/src/airflow/providers/alibaba/get_provider_info.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,17 @@ def get_provider_info():
9191
"connection-types": [
9292
{
9393
"hook-class-name": "airflow.providers.alibaba.cloud.hooks.oss.OSSHook",
94+
"hook-name": "OSS",
9495
"connection-type": "oss",
9596
},
9697
{
9798
"hook-class-name": "airflow.providers.alibaba.cloud.hooks.analyticdb_spark.AnalyticDBSparkHook",
99+
"hook-name": "AnalyticDB Spark",
98100
"connection-type": "adb_spark",
99101
},
100102
{
101103
"hook-class-name": "airflow.providers.alibaba.cloud.hooks.base_alibaba.AlibabaBaseHook",
104+
"hook-name": "Alibaba Cloud",
102105
"connection-type": "alibaba_cloud",
103106
"conn-fields": {
104107
"access_key_id": {
@@ -113,6 +116,7 @@ def get_provider_info():
113116
},
114117
{
115118
"hook-class-name": "airflow.providers.alibaba.cloud.hooks.maxcompute.MaxComputeHook",
119+
"hook-name": "MaxCompute",
116120
"connection-type": "maxcompute",
117121
"ui-field-behaviour": {
118122
"hidden-fields": ["host", "schema", "login", "password", "port", "extra"],

providers/amazon/src/airflow/providers/amazon/get_provider_info.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,7 @@ def get_provider_info():
10841084
"connection-types": [
10851085
{
10861086
"hook-class-name": "airflow.providers.amazon.aws.hooks.base_aws.AwsGenericHook",
1087+
"hook-name": "Amazon Web Services",
10871088
"connection-type": "aws",
10881089
"ui-field-behaviour": {
10891090
"hidden-fields": ["host", "schema", "port"],
@@ -1097,6 +1098,7 @@ def get_provider_info():
10971098
},
10981099
{
10991100
"hook-class-name": "airflow.providers.amazon.aws.hooks.chime.ChimeWebhookHook",
1101+
"hook-name": "Amazon Chime Webhook",
11001102
"connection-type": "chime",
11011103
"ui-field-behaviour": {
11021104
"hidden-fields": ["login", "port", "extra"],
@@ -1110,6 +1112,7 @@ def get_provider_info():
11101112
},
11111113
{
11121114
"hook-class-name": "airflow.providers.amazon.aws.hooks.emr.EmrHook",
1115+
"hook-name": "Amazon Elastic MapReduce",
11131116
"connection-type": "emr",
11141117
"ui-field-behaviour": {
11151118
"hidden-fields": ["host", "schema", "port", "login", "password"],
@@ -1121,11 +1124,13 @@ def get_provider_info():
11211124
},
11221125
{
11231126
"hook-class-name": "airflow.providers.amazon.aws.hooks.redshift_sql.RedshiftSQLHook",
1127+
"hook-name": "Amazon Redshift",
11241128
"connection-type": "redshift",
11251129
"ui-field-behaviour": {"relabeling": {"login": "User", "schema": "Database"}},
11261130
},
11271131
{
11281132
"hook-class-name": "airflow.providers.amazon.aws.hooks.athena_sql.AthenaSQLHook",
1133+
"hook-name": "Amazon Athena",
11291134
"connection-type": "athena",
11301135
"ui-field-behaviour": {
11311136
"hidden-fields": ["host", "port"],

providers/apache/cassandra/src/airflow/providers/apache/cassandra/get_provider_info.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def get_provider_info():
5353
"connection-types": [
5454
{
5555
"hook-class-name": "airflow.providers.apache.cassandra.hooks.cassandra.CassandraHook",
56+
"hook-name": "Cassandra",
5657
"connection-type": "cassandra",
5758
}
5859
],

providers/apache/drill/src/airflow/providers/apache/drill/get_provider_info.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def get_provider_info():
4444
"connection-types": [
4545
{
4646
"hook-class-name": "airflow.providers.apache.drill.hooks.drill.DrillHook",
47+
"hook-name": "Drill",
4748
"connection-type": "drill",
4849
}
4950
],

providers/apache/druid/src/airflow/providers/apache/druid/get_provider_info.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def get_provider_info():
5050
"connection-types": [
5151
{
5252
"hook-class-name": "airflow.providers.apache.druid.hooks.druid.DruidDbApiHook",
53+
"hook-name": "Druid",
5354
"connection-type": "druid",
5455
}
5556
],

0 commit comments

Comments
 (0)