Skip to content

Commit 43205e9

Browse files
authored
Merge pull request #42 from tableau/release/5.0.0
Release 5.0.0
2 parents 587b9dc + 9460621 commit 43205e9

File tree

158 files changed

+5150
-1444
lines changed

Some content is hidden

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

158 files changed

+5150
-1444
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<Nullable>enable</Nullable>
55
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
66
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
7-
<Version>4.3.1</Version>
7+
<Version>5.0.0</Version>
88
<Authors>Salesforce, Inc.</Authors>
99
<Company>Salesforce, Inc.</Company>
1010
<Copyright>Copyright (c) 2024, Salesforce, Inc. and its licensors</Copyright>

examples/Csharp.ExampleApplication/Csharp.ExampleApplication.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
4+
<TargetFrameworks>net8.0</TargetFrameworks>
55
<!-- Don't warn on ConfigureAwait on console application, Don't require license headers for sample code -->
66
<NoWarn>CA2007,IDE0073</NoWarn>
77
<UserSecretsId>8368baab-103b-45f6-bfb1-f89a537f4f3c</UserSecretsId>
@@ -10,7 +10,7 @@
1010
<ProjectReference Include="../../src/Tableau.Migration/Tableau.Migration.csproj" />
1111
</ItemGroup>
1212
<ItemGroup>
13-
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
13+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
1414
</ItemGroup>
1515
<ItemGroup>
1616
<None Update="appsettings.Development.json">
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
3+
namespace Csharp.ExampleApplication.Hooks.InitializeMigration
4+
{
5+
#region class
6+
7+
public class CustomContext
8+
{
9+
public Guid CustomerId { get; set; }
10+
}
11+
12+
#endregion
13+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.Threading;
3+
using System.Threading.Tasks;
4+
using Microsoft.Extensions.DependencyInjection;
5+
using Tableau.Migration.Engine.Hooks;
6+
7+
namespace Csharp.ExampleApplication.Hooks.InitializeMigration
8+
{
9+
#region class
10+
11+
internal class SetMigrationContextHook : IInitializeMigrationHook
12+
{
13+
public Task<IInitializeMigrationHookResult?> ExecuteAsync(IInitializeMigrationHookResult ctx, CancellationToken cancel)
14+
{
15+
var customContext = ctx.ScopedServices.GetRequiredService<CustomContext>();
16+
customContext.CustomerId = Guid.NewGuid();
17+
18+
return Task.FromResult<IInitializeMigrationHookResult?>(ctx);
19+
}
20+
}
21+
22+
#endregion
23+
}

examples/Csharp.ExampleApplication/MyMigrationApplication.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Csharp.ExampleApplication.Config;
99
using Csharp.ExampleApplication.Hooks.BatchMigrationCompleted;
1010
using Csharp.ExampleApplication.Hooks.Filters;
11+
using Csharp.ExampleApplication.Hooks.InitializeMigration;
1112
using Csharp.ExampleApplication.Hooks.Mappings;
1213
using Csharp.ExampleApplication.Hooks.MigrationActionCompleted;
1314
using Csharp.ExampleApplication.Hooks.PostPublish;
@@ -147,6 +148,11 @@ public async Task StartAsync(CancellationToken cancel)
147148
_planBuilder.Transformers.Add<CustomViewExcludeDefaultUserTransformer, IPublishableCustomView>();
148149
#endregion
149150

151+
// Add initialize migration hooks
152+
#region SetCustomContext-Registration
153+
_planBuilder.Hooks.Add<SetMigrationContextHook>();
154+
#endregion
155+
150156
// Add migration action completed hooks
151157
#region LogMigrationActionsHook-Registration
152158
_planBuilder.Hooks.Add<LogMigrationActionsHook>();

examples/Csharp.ExampleApplication/Program.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Csharp.ExampleApplication.Config;
33
using Csharp.ExampleApplication.Hooks.BatchMigrationCompleted;
44
using Csharp.ExampleApplication.Hooks.Filters;
5+
using Csharp.ExampleApplication.Hooks.InitializeMigration;
56
using Csharp.ExampleApplication.Hooks.Mappings;
67
using Csharp.ExampleApplication.Hooks.MigrationActionCompleted;
78
using Csharp.ExampleApplication.Hooks.PostPublish;
@@ -44,6 +45,14 @@ public static async Task Main(string[] args)
4445
/// <returns>The same service collection as the <paramref name="services"/> parameter.</returns>
4546
public static IServiceCollection AddCustomizations(this IServiceCollection services)
4647
{
48+
#region SetCustomContext-Service-DI
49+
services.AddScoped<CustomContext>();
50+
#endregion
51+
52+
#region SetCustomContext-Hook-DI
53+
services.AddScoped<SetMigrationContextHook>();
54+
#endregion
55+
4756
#region EmailDomainMapping-DI
4857
services.AddScoped<EmailDomainMapping>();
4958
#endregion

examples/DependencyInjection.ExampleApplication/DependencyInjection.ExampleApplication.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
5+
<TargetFrameworks>net8.0</TargetFrameworks>
66
<!-- Don't warn on ConfigureAwait on console application, Don't require license headers for sample code -->
77
<NoWarn>CA2007,IDE0073</NoWarn>
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
11+
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" />
1212
</ItemGroup>
1313

1414
<ItemGroup>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from tableau_migration import(
2+
InitializeMigrationHookBase,
3+
IInitailizeMigrationHookResult
4+
)
5+
6+
from Csharp.ExampleApplication.Hooks.InitializeMigration import CustomContext
7+
8+
class SetMigrationContextHook(InitializeMigrationHookBase):
9+
def execute(self, ctx: IInitailizeMigrationHookResult) -> IInitailizeMigrationHookResult:
10+
ctx.scoped_services._get_service(CustomContext)

examples/Python.ExampleApplication/Python.ExampleApplication.pyproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<Compile Include="hooks\batch_migration_completed\log_migration_batches_hook.py" />
2626
<Compile Include="hooks\filters\default_project_filter.py" />
2727
<Compile Include="hooks\filters\unlicensed_user_filter.py" />
28+
<Compile Include="hooks\initialize_migration\set_custom_context_hook.py" />
2829
<Compile Include="hooks\mappings\change_project_mapping.py" />
2930
<Compile Include="hooks\mappings\email_domain_mapping.py" />
3031
<Compile Include="hooks\mappings\project_rename_mapping.py" />
@@ -60,6 +61,7 @@
6061
<Folder Include="hooks\mappings\" />
6162
<Folder Include="hooks\migration_action_completed\" />
6263
<Folder Include="hooks\batch_migration_completed\" />
64+
<Folder Include="hooks\initialize_migration\" />
6365
<Folder Include="hooks\post_publish\" />
6466
<Folder Include="hooks\transformers\" />
6567
</ItemGroup>

examples/Python.ExampleApplication/print_result.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
from tableau_migration.migration import PyMigrationResult
2-
from tableau_migration import IMigrationManifestEntry, MigrationManifestEntryStatus
3-
from Tableau.Migration.Engine.Pipelines import ServerToCloudMigrationPipeline
1+
from tableau_migration import (
2+
IMigrationManifestEntry,
3+
MigrationManifestEntryStatus,
4+
MigrationResult,
5+
ServerToCloudMigrationPipeline
6+
)
47

5-
def print_result(result: PyMigrationResult):
8+
def print_result(result: MigrationResult):
69
"""Prints the result of a migration."""
710
print(f'Result: {result.status}')
811

9-
for pipeline_content_type in ServerToCloudMigrationPipeline.ContentTypes:
10-
content_type = pipeline_content_type.ContentType
12+
for pipeline_content_type in ServerToCloudMigrationPipeline.content_types():
13+
content_type = pipeline_content_type.content_type
1114

12-
type_entries = [IMigrationManifestEntry(x) for x in result.manifest.entries.ForContentType(content_type)]
15+
type_entries = [IMigrationManifestEntry(x) for x in result.manifest.entries.for_content_type(content_type)]
1316

1417
count_total = len(type_entries)
1518

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "8.0.302",
3+
"version": "8.0.403",
44
"rollForward": "latestMajor"
55
}
66
}

src/Documentation/articles/hooks/custom_hooks.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@ Here are some important things to know when writing custom hooks:
1111
## [Python](#tab/Python)
1212

1313
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.
14-
For example: [`PyContentFilterBase`](~/api-python/reference/tableau_migration.migration_engine_hooks_filters_interop.PyContentFilterBase.md) has been imported as `tableau_migration.PyContentFilterBase`.
14+
For example: [`PyContentFilterBase`](~/api-python/reference/tableau_migration.migration_engine_hooks_filters_interop.PyContentFilterBase.md) has been imported as `tableau_migration.ContentFilterBase`.
1515

1616
#### Pre-Migration
1717

18-
| Type | Base Class | Code Samples |
19-
|---------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------|
20-
| [Filters](~/api-python/reference/tableau_migration.migration_engine_hooks_filters_interop.md) | [`ContentFilterBase<TContent>`](~/api-python/reference/tableau_migration.migration_engine_hooks_filters_interop.PyContentFilterBase.md) | [Code Samples/Filters](~/samples/filters/index.md) |
21-
| [Mappings](~/api-python/reference/tableau_migration.migration_engine_hooks_mappings_interop.md) | [`ContentMappingBase<TContent>`](~/api-python/reference/tableau_migration.migration_engine_hooks_mappings_interop.PyContentMappingBase.md) | [Code Samples/Mappings](~/samples/mappings/index.md) |
22-
| [Transformers](~/api-python/reference/tableau_migration.migration_engine_hooks_transformers_interop.md) | [`ContentTransformerBase<TPublish>`](~/api-python/reference/tableau_migration.migration_engine_hooks_transformers_interop.PyContentTransformerBase.md) | [Code Samples/Transformers](~/samples/transformers/index.md) |
18+
| Type | Base Class | Code Samples |
19+
|---------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------|
20+
| [Initialize Migration](~/api-python/reference/tableau_migration.migration_engine_hooks_interop.md) | [`InitializeMigrationHookBase`](~/api-python/reference/tableau_migration.migration_engine_hooks_interop.PyInitializeMigrationHookBase.md) | [Code Samples/Initialize Migration](~/samples/initialize-migration/index.md) |
21+
| [Filters](~/api-python/reference/tableau_migration.migration_engine_hooks_filters_interop.md) | [`ContentFilterBase<TContent>`](~/api-python/reference/tableau_migration.migration_engine_hooks_filters_interop.PyContentFilterBase.md) | [Code Samples/Filters](~/samples/filters/index.md) |
22+
| [Mappings](~/api-python/reference/tableau_migration.migration_engine_hooks_mappings_interop.md) | [`ContentMappingBase<TContent>`](~/api-python/reference/tableau_migration.migration_engine_hooks_mappings_interop.PyContentMappingBase.md) | [Code Samples/Mappings](~/samples/mappings/index.md) |
23+
| [Transformers](~/api-python/reference/tableau_migration.migration_engine_hooks_transformers_interop.md) | [`ContentTransformerBase<TPublish>`](~/api-python/reference/tableau_migration.migration_engine_hooks_transformers_interop.PyContentTransformerBase.md) | [Code Samples/Transformers](~/samples/transformers/index.md) |
2324

2425
#### Post-Migration
2526

@@ -38,11 +39,12 @@ To register Python hooks, register the object with the appropriate hook type lis
3839

3940
#### Pre-Migration
4041

41-
| Type | Base Class | Interface | Code Samples |
42-
|---------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------|
43-
| [Filters](xref:Tableau.Migration.Engine.Hooks.Filters) | [`ContentFilterBase<TContent>`](xref:Tableau.Migration.Engine.Hooks.Filters.ContentFilterBase`1) | [`IContentFilter<TContent>`](xref:Tableau.Migration.Engine.Hooks.Filters.IContentFilter`1) | [Code Samples/Filters](~/samples/filters/index.md) |
44-
| [Mappings](xref:Tableau.Migration.Engine.Hooks.Mappings) | [`ContentMappingBase<TContent>`](xref:Tableau.Migration.Engine.Hooks.Mappings.ContentMappingBase`1) | [`IContentMapping<TContent>`](xref:Tableau.Migration.Engine.Hooks.Mappings.IContentMapping`1) | [Code Samples/Mappings](~/samples/mappings/index.md) |
45-
| [Transformers](xref:Tableau.Migration.Engine.Hooks.Transformers) | [`ContentTransformerBase<TPublish>`](xref:Tableau.Migration.Engine.Hooks.Transformers.ContentTransformerBase`1) | [`IContentTransformer<TPublish>`](xref:Tableau.Migration.Engine.Hooks.Transformers.IContentTransformer`1) | [Code Samples/Transformers](~/samples/transformers/index.md) |
42+
| Type | Base Class | Interface | Code Samples |
43+
|---------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------|
44+
| [Initialize Migration](xref:Tableau.Migration.Engine.Hooks) | None | [`IInitializeMigrationHook`](xref:Tableau.Migration.Engine.Hooks.IInitializeMigrationHook) | [Code Samples/Initialize Migration](~/samples/initialize-migration/index.md) |
45+
| [Filters](xref:Tableau.Migration.Engine.Hooks.Filters) | [`ContentFilterBase<TContent>`](xref:Tableau.Migration.Engine.Hooks.Filters.ContentFilterBase`1) | [`IContentFilter<TContent>`](xref:Tableau.Migration.Engine.Hooks.Filters.IContentFilter`1) | [Code Samples/Filters](~/samples/filters/index.md) |
46+
| [Mappings](xref:Tableau.Migration.Engine.Hooks.Mappings) | [`ContentMappingBase<TContent>`](xref:Tableau.Migration.Engine.Hooks.Mappings.ContentMappingBase`1) | [`IContentMapping<TContent>`](xref:Tableau.Migration.Engine.Hooks.Mappings.IContentMapping`1) | [Code Samples/Mappings](~/samples/mappings/index.md) |
47+
| [Transformers](xref:Tableau.Migration.Engine.Hooks.Transformers) | [`ContentTransformerBase<TPublish>`](xref:Tableau.Migration.Engine.Hooks.Transformers.ContentTransformerBase`1) | [`IContentTransformer<TPublish>`](xref:Tableau.Migration.Engine.Hooks.Transformers.IContentTransformer`1) | [Code Samples/Transformers](~/samples/transformers/index.md) |
4648

4749
#### Post-Migration
4850

src/Documentation/articles/hooks/index.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@ These types of hooks run on content items.
3535

3636
These types of hooks run before or after certain migration events.
3737

38+
- Migration Initialized: Executed after preflight validation is completed successfully, but before any migration actions are started.
39+
3840
- Post-Publish: Run on the destination content after the items for the content type have been published.
3941

40-
- Bulk Post-Publish: Execute after publishing a batch of content, when bulk publishing is supported. You can make changes to the published set of items with this type of hook. You can write this type of hook for content types such as Users.
42+
- Bulk Post-Publish: Executed after publishing a batch of content, when bulk publishing is supported. You can make changes to the published set of items with this type of hook. You can write this type of hook for content types such as Users.
4143

42-
- Migration Action Completed: Execute after the migration of each content type.
44+
- Migration Action Completed: Executed after the migration of each content type.
4345

44-
- Batch Migration Completed: Execute after the completion of the migration of a batch of Tableau’s content.
46+
- Batch Migration Completed: Executed after the completion of the migration of a batch of Tableau’s content.
4547

4648
## Hook execution flow
4749

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Initialize Migration
2+
3+
Initialize Migration Hooks allow custom logic to run after a migration startup has been validated but before any migration work is performed.
4+
5+
The following samples cover some common scenarios:
6+
7+
- [Sample: Set Custom Migration Scoped Context](~/samples/initialize-migration/set_custom_context.md)
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Sample: Set Custom Migration Scoped Context
2+
3+
This example demonstrates how to set custom context in the migration scoped dependency injection container using an initialize migration hook.
4+
This is useful when other hooks like filters are registered with dependency injection and rely on migration scoped services.
5+
6+
# [Python](#tab/Python)
7+
8+
#### Custom Context Service Class
9+
10+
[!code-csharp[](../../../../examples/Csharp.ExampleApplication/Hooks/InitializeMigration/CustomContext.cs#class)]
11+
12+
#### Custom Context Service Class Dependency Injection
13+
14+
[Learn more.](~/articles/dependency_injection.md)
15+
16+
[!code-csharp[](../../../../examples/Csharp.ExampleApplication/Program.cs#SetCustomContext-Service-DI)]
17+
18+
#### Initialize Migration Hook Class
19+
20+
[!code-python[](../../../../examples/Python.ExampleApplication/hooks/initialize_migration/set_custom_context_hook.py)]
21+
22+
#### Registration
23+
24+
[Learn more.](~/samples/index.md?tabs=Python#hook-registration)
25+
26+
[//]: <> (Adding this as code as regions are not supported in Python snippets)
27+
```Python
28+
plan_builder.hooks.add(SetMigrationContextHook)
29+
```
30+
31+
# [C#](#tab/CSharp)
32+
33+
#### Custom Context Service Class
34+
35+
[!code-csharp[](../../../../examples/Csharp.ExampleApplication/Hooks/InitializeMigration/CustomContext.cs#class)]
36+
37+
#### Custom Context Service Class Dependency Injection
38+
39+
[Learn more.](~/articles/dependency_injection.md)
40+
41+
[!code-csharp[](../../../../examples/Csharp.ExampleApplication/Program.cs#SetCustomContext-Service-DI)]
42+
43+
#### Initialize Migration Hook Class
44+
45+
[!code-csharp[](../../../../examples/Csharp.ExampleApplication/Hooks/InitializeMigration/SetMigrationContextHook.cs#class)]
46+
47+
#### Registration
48+
49+
[Learn more.](~/samples/index.md?tabs=CSharp#hook-registration)
50+
51+
[!code-csharp[](../../../../examples/Csharp.ExampleApplication/MyMigrationApplication.cs#SetCustomContext-Registration)]
52+
53+
#### Dependency Injection
54+
55+
[Learn more.](~/articles/dependency_injection.md)
56+
57+
[!code-csharp[](../../../../examples/Csharp.ExampleApplication/Program.cs#SetCustomContext-Hook-DI)]

0 commit comments

Comments
 (0)