Tableau Migration SDK 5.1.1
  • Articles
  • Code Samples
  • Python API Reference
  • C# API Reference
Show / Hide Table of Contents
  • SDK Terminology
  • Configuration
  • Plan Validation
  • Logging
  • Hooks
    • Custom Hooks
    • Example Hook Use Cases
    • Python Hook Update from v3 to v4+
  • User Authentication
  • Custom View File
  • Dependency Injection
  • Troubleshooting

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.
  • Python
  • C#

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

Type Base Class Code Samples
Initialize Migration InitializeMigrationHookBase Code Samples/Initialize Migration
Filters ContentFilterBase<TContent> Code Samples/Filters
Mappings ContentMappingBase<TContent> Code Samples/Mappings
Transformers ContentTransformerBase<TPublish> Code Samples/Transformers

Post-Migration

Type Base Class Code Samples
Post-Publish ContentItemPostPublishHookBase<TPublish, TResult> Code Samples/Post-Publish Hooks
Bulk Post-Publish BulkPostPublishHookBase<TSource> Code Samples/Bulk Post-Publish
Batch Migration Completed ContentBatchMigrationCompletedHookBase<TContent> Code Samples/Batch Completed
Migration Action Completed MigrationActionCompletedHookBase Code Samples/Action Completed

Registration

To register Python hooks, register the object with the appropriate hook type list in the plan builder.

Pre-Migration

Type Base Class Interface Code Samples
Initialize Migration None IInitializeMigrationHook Code Samples/Initialize Migration
Filters ContentFilterBase<TContent> IContentFilter<TContent> Code Samples/Filters
Mappings ContentMappingBase<TContent> IContentMapping<TContent> Code Samples/Mappings
Transformers ContentTransformerBase<TPublish> IContentTransformer<TPublish> Code Samples/Transformers

Post-Migration

Type Base Class Interface Code Samples
Post-Publish ContentItemPostPublishHookBase<TPublish, TResult> IContentItemPostPublishHook<TContent> Code Samples/Post-Publish Hooks
Bulk Post-Publish BulkPostPublishHookBase<TSource> IBulkPostPublishHook<TSource> Code Samples/Bulk Post-Publish
Batch Migration Completed None IContentBatchMigrationCompletedHook<TContent> Code Samples/Batch Completed
Migration Action Completed None IMigrationActionCompletedHook Code Samples/Action Completed

Registration

You can implement, register, and call hooks in the following ways:

  1. 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.
  2. 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.
  3. 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.
  • Edit this page
In this article