Skip to content

Commit

Permalink
Follow BaseHook connection fields method signature in child classes (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Taragolis committed Dec 11, 2023
1 parent f39cdcc commit cd476ac
Show file tree
Hide file tree
Showing 45 changed files with 137 additions and 133 deletions.
4 changes: 2 additions & 2 deletions airflow/providers/amazon/aws/hooks/base_aws.py
Expand Up @@ -812,8 +812,8 @@ def decorator_f(self, *args, **kwargs):

return retry_decorator

@staticmethod
def get_ui_field_behaviour() -> dict[str, Any]:
@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
"""Return custom UI field behaviour for AWS Connection."""
return {
"hidden_fields": ["host", "schema", "port"],
Expand Down
4 changes: 2 additions & 2 deletions airflow/providers/amazon/aws/hooks/emr.py
Expand Up @@ -205,8 +205,8 @@ def test_connection(self):
)
return False, msg

@staticmethod
def get_ui_field_behaviour() -> dict[str, Any]:
@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
"""Return custom UI field behaviour for Amazon Elastic MapReduce Connection."""
return {
"hidden_fields": ["host", "schema", "port", "login", "password"],
Expand Down
4 changes: 2 additions & 2 deletions airflow/providers/amazon/aws/hooks/redshift_sql.py
Expand Up @@ -62,8 +62,8 @@ def __init__(self, *args, aws_conn_id: str = "aws_default", **kwargs) -> None:
super().__init__(*args, **kwargs)
self.aws_conn_id = aws_conn_id

@staticmethod
def get_ui_field_behaviour() -> dict:
@classmethod
def get_ui_field_behaviour(cls) -> dict:
"""Get custom field behavior."""
return {
"hidden_fields": [],
Expand Down
4 changes: 2 additions & 2 deletions airflow/providers/apache/kafka/hooks/base.py
Expand Up @@ -42,8 +42,8 @@ def __init__(self, kafka_config_id=default_conn_name, *args, **kwargs):
self.kafka_config_id = kafka_config_id
self.get_conn

@staticmethod
def get_ui_field_behaviour() -> dict[str, Any]:
@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
"""Return custom field behaviour."""
return {
"hidden_fields": ["schema", "login", "password", "port", "host"],
Expand Down
8 changes: 4 additions & 4 deletions airflow/providers/apache/spark/hooks/spark_connect.py
Expand Up @@ -37,8 +37,8 @@ class SparkConnectHook(BaseHook, LoggingMixin):
conn_type = "spark_connect"
hook_name = "Spark Connect"

@staticmethod
def get_ui_field_behaviour() -> dict[str, Any]:
@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
"""Return custom field behaviour."""
return {
"hidden_fields": [
Expand All @@ -47,8 +47,8 @@ def get_ui_field_behaviour() -> dict[str, Any]:
"relabeling": {"password": "Token", "login": "User ID"},
}

@staticmethod
def get_connection_form_widgets() -> dict[str, Any]:
@classmethod
def get_connection_form_widgets(cls) -> dict[str, Any]:
"""Returns connection widgets to add to connection form."""
from flask_babel import lazy_gettext
from wtforms import BooleanField
Expand Down
4 changes: 2 additions & 2 deletions airflow/providers/apache/spark/hooks/spark_submit.py
Expand Up @@ -87,8 +87,8 @@ class SparkSubmitHook(BaseHook, LoggingMixin):
conn_type = "spark"
hook_name = "Spark"

@staticmethod
def get_ui_field_behaviour() -> dict[str, Any]:
@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
"""Return custom field behaviour."""
return {
"hidden_fields": ["schema", "login", "password"],
Expand Down
8 changes: 4 additions & 4 deletions airflow/providers/apprise/hooks/apprise.py
Expand Up @@ -110,8 +110,8 @@ def notify(
def get_conn(self) -> None:
raise NotImplementedError()

@staticmethod
def get_connection_form_widgets() -> dict[str, Any]:
@classmethod
def get_connection_form_widgets(cls) -> dict[str, Any]:
"""Return connection widgets to add to connection form."""
from flask_appbuilder.fieldwidgets import BS3PasswordFieldWidget
from flask_babel import lazy_gettext
Expand All @@ -127,8 +127,8 @@ def get_connection_form_widgets() -> dict[str, Any]:
),
}

@staticmethod
def get_ui_field_behaviour() -> dict[str, Any]:
@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
return {
"hidden_fields": ["host", "schema", "login", "password", "port", "extra"],
"relabeling": {},
Expand Down
4 changes: 2 additions & 2 deletions airflow/providers/arangodb/hooks/arangodb.py
Expand Up @@ -134,8 +134,8 @@ def create_graph(self, name):
self.log.info("Graph already exists: %s", name)
return False

@staticmethod
def get_ui_field_behaviour() -> dict[str, Any]:
@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
return {
"hidden_fields": ["port", "extra"],
"relabeling": {
Expand Down
8 changes: 4 additions & 4 deletions airflow/providers/asana/hooks/asana.py
Expand Up @@ -58,8 +58,8 @@ def _get_field(self, extras: dict, field_name: str):
def get_conn(self) -> Client:
return self.client

@staticmethod
def get_connection_form_widgets() -> dict[str, Any]:
@classmethod
def get_connection_form_widgets(cls) -> dict[str, Any]:
"""Return connection widgets to add to connection form."""
from flask_appbuilder.fieldwidgets import BS3TextFieldWidget
from flask_babel import lazy_gettext
Expand All @@ -70,8 +70,8 @@ def get_connection_form_widgets() -> dict[str, Any]:
"project": StringField(lazy_gettext("Project"), widget=BS3TextFieldWidget()),
}

@staticmethod
def get_ui_field_behaviour() -> dict[str, Any]:
@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
"""Return custom field behaviour."""
return {
"hidden_fields": ["port", "host", "login", "schema"],
Expand Down
4 changes: 2 additions & 2 deletions airflow/providers/cloudant/hooks/cloudant.py
Expand Up @@ -40,8 +40,8 @@ class CloudantHook(BaseHook):
conn_type = "cloudant"
hook_name = "Cloudant"

@staticmethod
def get_ui_field_behaviour() -> dict[str, Any]:
@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
"""Return custom field behaviour."""
return {
"hidden_fields": ["port", "extra"],
Expand Down
8 changes: 4 additions & 4 deletions airflow/providers/cncf/kubernetes/hooks/kubernetes.py
Expand Up @@ -86,8 +86,8 @@ class KubernetesHook(BaseHook, PodOperatorHookProtocol):

DEFAULT_NAMESPACE = "default"

@staticmethod
def get_connection_form_widgets() -> dict[str, Any]:
@classmethod
def get_connection_form_widgets(cls) -> dict[str, Any]:
"""Return connection widgets to add to connection form."""
from flask_appbuilder.fieldwidgets import BS3TextFieldWidget
from flask_babel import lazy_gettext
Expand All @@ -111,8 +111,8 @@ def get_connection_form_widgets() -> dict[str, Any]:
),
}

@staticmethod
def get_ui_field_behaviour() -> dict[str, Any]:
@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
"""Return custom field behaviour."""
return {
"hidden_fields": ["host", "schema", "login", "password", "port", "extra"],
Expand Down
4 changes: 2 additions & 2 deletions airflow/providers/cohere/hooks/cohere.py
Expand Up @@ -66,8 +66,8 @@ def create_embeddings(
embeddings = response.embeddings
return embeddings

@staticmethod
def get_ui_field_behaviour() -> dict[str, Any]:
@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
return {
"hidden_fields": ["schema", "login", "port", "extra"],
"relabeling": {
Expand Down
8 changes: 4 additions & 4 deletions airflow/providers/datadog/hooks/datadog.py
Expand Up @@ -158,8 +158,8 @@ def post_event(
self.validate_response(response)
return response

@staticmethod
def get_connection_form_widgets() -> dict[str, Any]:
@classmethod
def get_connection_form_widgets(cls) -> dict[str, Any]:
"""Return connection widgets to add to connection form."""
from flask_appbuilder.fieldwidgets import BS3TextFieldWidget
from flask_babel import lazy_gettext
Expand All @@ -172,8 +172,8 @@ def get_connection_form_widgets() -> dict[str, Any]:
"source_type_name": StringField(lazy_gettext("Source type name"), widget=BS3TextFieldWidget()),
}

@staticmethod
def get_ui_field_behaviour() -> dict[str, Any]:
@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
"""Return custom field behaviour."""
return {
"hidden_fields": ["schema", "login", "password", "port", "extra"],
Expand Down
4 changes: 2 additions & 2 deletions airflow/providers/dbt/cloud/hooks/dbt.py
Expand Up @@ -174,8 +174,8 @@ class DbtCloudHook(HttpHook):
conn_type = "dbt_cloud"
hook_name = "dbt Cloud"

@staticmethod
def get_ui_field_behaviour() -> dict[str, Any]:
@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
"""Build custom field behavior for the dbt Cloud connection form in the Airflow UI."""
return {
"hidden_fields": ["schema", "port", "extra"],
Expand Down
4 changes: 2 additions & 2 deletions airflow/providers/docker/hooks/docker.py
Expand Up @@ -166,8 +166,8 @@ def __login(self, client, conn: Connection) -> None:
self.log.error("Login failed")
raise

@staticmethod
def get_connection_form_widgets() -> dict[str, Any]:
@classmethod
def get_connection_form_widgets(cls) -> dict[str, Any]:
"""Return connection form widgets."""
from flask_appbuilder.fieldwidgets import BS3TextFieldWidget
from flask_babel import lazy_gettext
Expand Down
4 changes: 2 additions & 2 deletions airflow/providers/github/hooks/github.py
Expand Up @@ -68,8 +68,8 @@ def get_conn(self) -> GithubClient:

return self.client

@staticmethod
def get_ui_field_behaviour() -> dict:
@classmethod
def get_ui_field_behaviour(cls) -> dict:
"""Return custom field behaviour."""
return {
"hidden_fields": ["schema", "port", "login", "extra"],
Expand Down
4 changes: 2 additions & 2 deletions airflow/providers/google/cloud/hooks/compute_ssh.py
Expand Up @@ -96,8 +96,8 @@ class ComputeEngineSSHHook(SSHHook):
conn_type = "gcpssh"
hook_name = "Google Cloud SSH"

@staticmethod
def get_ui_field_behaviour() -> dict[str, Any]:
@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
return {
"hidden_fields": ["host", "schema", "login", "password", "port", "extra"],
"relabeling": {},
Expand Down
8 changes: 4 additions & 4 deletions airflow/providers/google/common/hooks/base_google.py
Expand Up @@ -188,8 +188,8 @@ class GoogleBaseHook(BaseHook):
conn_type = "google_cloud_platform"
hook_name = "Google Cloud"

@staticmethod
def get_connection_form_widgets() -> dict[str, Any]:
@classmethod
def get_connection_form_widgets(cls) -> dict[str, Any]:
"""Returns connection widgets to add to connection form."""
from flask_appbuilder.fieldwidgets import BS3PasswordFieldWidget, BS3TextFieldWidget
from flask_babel import lazy_gettext
Expand Down Expand Up @@ -221,8 +221,8 @@ def get_connection_form_widgets() -> dict[str, Any]:
),
}

@staticmethod
def get_ui_field_behaviour() -> dict[str, Any]:
@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
"""Returns custom field behaviour."""
return {
"hidden_fields": ["host", "schema", "login", "password", "port", "extra"],
Expand Down
4 changes: 2 additions & 2 deletions airflow/providers/grpc/hooks/grpc.py
Expand Up @@ -51,8 +51,8 @@ class GrpcHook(BaseHook):
conn_type = "grpc"
hook_name = "GRPC Connection"

@staticmethod
def get_connection_form_widgets() -> dict[str, Any]:
@classmethod
def get_connection_form_widgets(cls) -> dict[str, Any]:
"""Returns connection widgets to add to connection form."""
from flask_appbuilder.fieldwidgets import BS3TextFieldWidget
from flask_babel import lazy_gettext
Expand Down
4 changes: 2 additions & 2 deletions airflow/providers/hashicorp/hooks/vault.py
Expand Up @@ -403,8 +403,8 @@ def get_connection_form_widgets(cls) -> dict[str, Any]:
"use_tls": BooleanField(lazy_gettext("Use TLS"), default=True),
}

@staticmethod
def get_ui_field_behaviour() -> dict[str, Any]:
@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
"""Returns custom field behaviour."""
return {
"hidden_fields": ["extra"],
Expand Down
4 changes: 2 additions & 2 deletions airflow/providers/jdbc/hooks/jdbc.py
Expand Up @@ -74,8 +74,8 @@ def __init__(
self._driver_path = driver_path
self._driver_class = driver_class

@staticmethod
def get_ui_field_behaviour() -> dict[str, Any]:
@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
"""Get custom field behaviour."""
return {
"hidden_fields": ["port", "schema"],
Expand Down
8 changes: 4 additions & 4 deletions airflow/providers/jenkins/hooks/jenkins.py
Expand Up @@ -32,8 +32,8 @@ class JenkinsHook(BaseHook):
conn_type = "jenkins"
hook_name = "Jenkins"

@staticmethod
def get_connection_form_widgets() -> dict[str, Any]:
@classmethod
def get_connection_form_widgets(cls) -> dict[str, Any]:
"""Returns connection widgets to add to connection form."""
from flask_babel import lazy_gettext
from wtforms import BooleanField
Expand All @@ -45,8 +45,8 @@ def get_connection_form_widgets() -> dict[str, Any]:
),
}

@staticmethod
def get_ui_field_behaviour() -> dict[str, Any]:
@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
"""Returns custom field behaviour."""
return {
"hidden_fields": ["schema", "extra"],
Expand Down
8 changes: 4 additions & 4 deletions airflow/providers/microsoft/azure/hooks/asb.py
Expand Up @@ -45,9 +45,9 @@ class BaseAzureServiceBusHook(BaseHook):
conn_type = "azure_service_bus"
hook_name = "Azure Service Bus"

@staticmethod
@classmethod
@add_managed_identity_connection_widgets
def get_connection_form_widgets() -> dict[str, Any]:
def get_connection_form_widgets(cls) -> dict[str, Any]:
"""Returns connection widgets to add to connection form."""
from flask_appbuilder.fieldwidgets import BS3TextFieldWidget
from flask_babel import lazy_gettext
Expand All @@ -60,8 +60,8 @@ def get_connection_form_widgets() -> dict[str, Any]:
"credential": PasswordField(lazy_gettext("Credential"), widget=BS3TextFieldWidget()),
}

@staticmethod
def get_ui_field_behaviour() -> dict[str, Any]:
@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
"""Returns custom field behaviour."""
return {
"hidden_fields": ["port", "host", "extra", "login", "password"],
Expand Down
8 changes: 4 additions & 4 deletions airflow/providers/microsoft/azure/hooks/base_azure.py
Expand Up @@ -47,9 +47,9 @@ class AzureBaseHook(BaseHook):
conn_type = "azure"
hook_name = "Azure"

@staticmethod
@classmethod
@add_managed_identity_connection_widgets
def get_connection_form_widgets() -> dict[str, Any]:
def get_connection_form_widgets(cls) -> dict[str, Any]:
"""Returns connection widgets to add to connection form."""
from flask_appbuilder.fieldwidgets import BS3TextFieldWidget
from flask_babel import lazy_gettext
Expand All @@ -60,8 +60,8 @@ def get_connection_form_widgets() -> dict[str, Any]:
"subscriptionId": StringField(lazy_gettext("Azure Subscription ID"), widget=BS3TextFieldWidget()),
}

@staticmethod
def get_ui_field_behaviour() -> dict[str, Any]:
@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
"""Returns custom field behaviour."""
import json

Expand Down
4 changes: 2 additions & 2 deletions airflow/providers/microsoft/azure/hooks/container_registry.py
Expand Up @@ -46,9 +46,9 @@ class AzureContainerRegistryHook(BaseHook):
conn_type = "azure_container_registry"
hook_name = "Azure Container Registry"

@staticmethod
@classmethod
@add_managed_identity_connection_widgets
def get_connection_form_widgets() -> dict[str, Any]:
def get_connection_form_widgets(cls) -> dict[str, Any]:
"""Returns connection widgets to add to connection form."""
from flask_appbuilder.fieldwidgets import BS3TextFieldWidget
from flask_babel import lazy_gettext
Expand Down
8 changes: 4 additions & 4 deletions airflow/providers/microsoft/azure/hooks/container_volume.py
Expand Up @@ -43,9 +43,9 @@ class AzureContainerVolumeHook(BaseHook):
conn_type = "azure_container_volume"
hook_name = "Azure Container Volume"

@staticmethod
@classmethod
@add_managed_identity_connection_widgets
def get_connection_form_widgets() -> dict[str, Any]:
def get_connection_form_widgets(cls) -> dict[str, Any]:
"""Returns connection widgets to add to connection form."""
from flask_appbuilder.fieldwidgets import BS3PasswordFieldWidget, BS3TextFieldWidget
from flask_babel import lazy_gettext
Expand All @@ -65,8 +65,8 @@ def get_connection_form_widgets() -> dict[str, Any]:
),
}

@staticmethod
def get_ui_field_behaviour() -> dict[str, Any]:
@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
"""Returns custom field behaviour."""
return {
"hidden_fields": ["schema", "port", "host", "extra"],
Expand Down

0 comments on commit cd476ac

Please sign in to comment.