Custom Hooks
Important Classes
Here are some important things to know when writing custom hooks:
- Interfaces: These interfaces expose supported methods. You can implement these directly or inherit available base classes. This applies to C# only.
- Base Classes: These classes can be inherited, allowing you to write your implementation in the overridden methods. You do not need to implement the interface explicitly if you use these.
- Code Samples: We have provided some simple code samples. You can use these as a starting point for your hooks.
The base classes can be used as they are linked in the API reference. However, for ease of use, all base classes have been imported into the tableau_migration namespace without the Py prefix.
For example: PyContentFilterBase has been imported as tableau_migration.ContentFilterBase.
Pre-Migration
Post-Migration
Registration
To register Python hooks, register the object with the appropriate hook type list in the plan builder.
Pre-Migration
Post-Migration
Registration
You can implement, register, and call hooks in the following ways:
- Object: The caller supplies an object that implements a suitable interface. This is the most straightforward way to register. However, the caller must manage the object’s lifecycle and dependencies.
- Factory: The caller supplies a type, with or without a factory function to create an object, that implements a suitable interface. This allows for the injection of SDK dependencies such as the manifest, content finders, etc. The lifecycle is managed by the DI container in the SDK (more details on .NET service lifetimes are here). Before adding the type, you must register the type on the DI container with the corresponding lifecycle.
- Callback: The caller supplies a callback function that conforms to the
ExecuteAsync method of the hook interface. This is essentially a functional version of #1. Internally, the SDK wraps the callback in a transient object to execute the function.