DiscoverableHook

Apache Airflow Certified

Interface that providers can implement to be discovered by ProvidersManager.

View on GitHub

Last Updated: Mar. 30, 2022

Access Instructions

Install the Apache Airflow provider package into your Airflow environment.

Import the module into your DAG file and instantiate it with your desired params.

Documentation

Interface that providers can implement to be discovered by ProvidersManager.

It is not used by any of the Hooks, but simply methods and class fields described here are implemented by those Hooks. Each method is optional – only implement the ones you need.

The conn_name_attr, default_conn_name, conn_type should be implemented by those Hooks that want to be automatically mapped from the connection_type -> Hook when get_hook method is called with connection_type.

Additionally hook_name should be set when you want the hook to have a custom name in the UI selection Name. If not specified, conn_name will be used.

The “get_ui_field_behaviour” and “get_connection_form_widgets” are optional - override them if you want to customize the Connection Form screen. You can add extra widgets to parse your extra fields via the get_connection_form_widgets method as well as hide or relabel the fields or pre-fill them with placeholders via get_ui_field_behaviour method.

Note that the “get_ui_field_behaviour” and “get_connection_form_widgets” need to be set by each class in the class hierarchy in order to apply widget customizations.

For example, even if you want to use the fields from your parent class, you must explicitly have a method on your class:

@classmethod
def get_ui_field_behaviour(cls):
return super().get_ui_field_behaviour()

You also need to add the Hook class name to list ‘hook_class_names’ in provider.yaml in case you build an internal provider or to return it in dictionary returned by provider_info entrypoint in the package you prepare.

You can see some examples in airflow/providers/jdbc/hooks/jdbc.py.

Was this page helpful?