-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
136 changed files
with
9,974 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
examples/Csharp.ExampleApplication/Hooks/Transformers/SimpleScheduleStartAtTransformer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.Logging; | ||
using Tableau.Migration.Content.Schedules; | ||
using Tableau.Migration.Content.Schedules.Cloud; | ||
using Tableau.Migration.Engine.Hooks.Transformers; | ||
using Tableau.Migration.Resources; | ||
|
||
namespace Csharp.ExampleApplication.Hooks.Transformers | ||
{ | ||
#region class | ||
public class SimpleScheduleStartAtTransformer<T> | ||
: ContentTransformerBase<T> | ||
where T : IWithSchedule<ICloudSchedule> | ||
{ | ||
private readonly ILogger<IContentTransformer<T>>? _logger; | ||
|
||
public SimpleScheduleStartAtTransformer( | ||
ISharedResourcesLocalizer localizer, | ||
ILogger<IContentTransformer<T>> logger) | ||
: base( | ||
localizer, | ||
logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
public override async Task<T?> TransformAsync( | ||
T itemToTransform, | ||
CancellationToken cancel) | ||
{ | ||
// In this example, the `Start At` time is in the UTC time zone. | ||
if (itemToTransform.Schedule.FrequencyDetails.StartAt is not null) | ||
{ | ||
// A simple conversion to the EDT time zone. | ||
var updatedStartAt = itemToTransform.Schedule.FrequencyDetails.StartAt.Value.AddHours(-4); | ||
|
||
_logger?.LogInformation( | ||
@"Adjusting the 'Start At' from {previousStartAt} to {updatedStartAt}.", | ||
itemToTransform.Schedule.FrequencyDetails.StartAt.Value, | ||
updatedStartAt); | ||
|
||
itemToTransform.Schedule.FrequencyDetails.StartAt = updatedStartAt; | ||
} | ||
|
||
return await Task.FromResult(itemToTransform); | ||
} | ||
} | ||
#endregion | ||
} |
15 changes: 15 additions & 0 deletions
15
examples/Python.ExampleApplication/Hooks/transformers/schedule_startat_transformer.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from datetime import time | ||
from tableau_migration import ( | ||
ContentTransformerBase, | ||
ICloudExtractRefreshTask | ||
) | ||
|
||
class SimpleScheduleStartAtTransformer(ContentTransformerBase[ICloudExtractRefreshTask]): | ||
def transform(self, itemToTransform: ICloudExtractRefreshTask) -> ICloudExtractRefreshTask: | ||
# In this example, the `Start At` time is in the UTC time zone. | ||
if itemToTransform.schedule.frequency_details.start_at: | ||
prev_start_at = itemToTransform.schedule.frequency_details.start_at | ||
# A simple conversion to the EDT time zone. | ||
itemToTransform.schedule.frequency_details.start_at = time(prev_start_at.hour - 4, prev_start_at.minute, prev_start_at.second, prev_start_at.microsecond); | ||
|
||
return itemToTransform |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Basic Configuration | ||
|
||
## Migration Plan | ||
|
||
The migration plan is a required input in the migration process. It defines the Source and Destination servers and the hooks executed during the migration. Consider the Migration Plan as the steps the Migration SDK follows to migrate the information from a given source to a given destination. | ||
|
||
The [`IMigrationPlan`](xref:Tableau.Migration.IMigrationPlan) interface defines the Migration Plan structure. The easiest way to generate a new Migration Plan is using [`MigrationPlanBuilder`](xref:Tableau.Migration.Engine.MigrationPlanBuilder). Following are the steps needed before [building](#build) a new plan: | ||
|
||
- [Define the required Source server](#source). | ||
- [Define the required Destination server](#destination). | ||
- [Define the required Migration Type](#migration-type). | ||
|
||
### Source | ||
|
||
The method [`MigrationPlanBuilder.FromSourceTableauServer`](xref:Tableau.Migration.Engine.MigrationPlanBuilder.FromSourceTableauServer(System.Uri,System.String,System.String,System.String,System.Boolean)) defines the source server by instantiating a new [`TableauSiteConnectionConfiguration`](xref:Tableau.Migration.Api.TableauSiteConnectionConfiguration) with the following parameters: | ||
|
||
- **serverUrl** | ||
- **siteContentUrl:**(optional) | ||
- **accessTokenName** | ||
- **accessToken** | ||
|
||
### Destination | ||
|
||
The method [`MigrationPlanBuilder.ToDestinationTableauCloud`](xref:Tableau.Migration.Engine.MigrationPlanBuilder.ToDestinationTableauCloud(System.Uri,System.String,System.String,System.String,System.Boolean)) defines the destination server by instantiating a new [`TableauSiteConnectionConfiguration`](xref:Tableau.Migration.Api.TableauSiteConnectionConfiguration) with the following parameters: | ||
|
||
- **podUrl** | ||
- **siteContentUrl** The site name on Tableau Cloud. | ||
- **accessTokenName** | ||
- **accessToken** | ||
|
||
> [!Important] | ||
> Personal access tokens (PATs) are long-lived authentication tokens that allow you to sign in to the Tableau REST API without requiring hard-coded credentials or interactive sign-in. Revoke and generate a new PAT every day to keep your server secure. Access tokens should not be stored in plain text in application configuration files, and should instead use secure alternatives such as encryption or a secrets management system. If the source and destination sites are on the same server, separate PATs should be used. | ||
### Migration Type | ||
|
||
The method [`MigrationPlanBuilder.ForServerToCloud`](xref:Tableau.Migration.Engine.MigrationPlanBuilder.ForServerToCloud) will define the migration type and load all default hooks for a **Server to Cloud** migration. | ||
|
||
### Build | ||
|
||
The method [`MigrationPlanBuilder.Build`](xref:Tableau.Migration.Engine.MigrationPlanBuilder.Build) generates a Migration Plan ready to be used as an input to a migration process. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Introduction | ||
|
||
Welcome to the developer documentation for the Tableau Migration SDK. The Migration SDK is primarily written in C# using the [.NET](https://dotnet.microsoft.com/en-us/learn/dotnet/what-is-dotnet-framework) Framework. It includes a [Python API](~/api-python/index.md) to enable interoperability with Python. | ||
|
||
## Supported languages | ||
|
||
You can develop your migration application using one of the supported languages | ||
|
||
- [Python](https://www.python.org/) | ||
- C# using the [.NET Framework](https://dotnet.microsoft.com/en-us/learn/dotnet/what-is-dotnet-framework) | ||
|
||
## Prerequisites | ||
|
||
To develop your application using the [Migration SDK](https://github.com/tableau/tableau-migration-sdk), you should | ||
|
||
- Understand framework and language concepts for one of the languages the SDK supports. | ||
- Be able to design and write applications in one of the supported languages. | ||
- Understand how to import and use third party packages | ||
- Understand logging and general troubleshooting of applications. | ||
|
||
## Quick Start | ||
|
||
- Install a [.NET Runtime](https://dotnet.microsoft.com/en-us/download). | ||
- Install the Migration SDK | ||
|
||
## [Python](#tab/Python) | ||
|
||
Install using PIP | ||
- [PIP CLI](https://pip.pypa.io/en/stable/cli/pip_install): `pip install tableau_migration` | ||
|
||
## [C#](#tab/CSharp) | ||
|
||
Install using NuGet | ||
- [dotnet CLI](https://learn.microsoft.com/en-us/nuget/quickstart/install-and-use-a-package-using-the-dotnet-cli): `dotnet add package Tableau.Migration` | ||
- [Nuget Package Manager](https://learn.microsoft.com/en-us/nuget/quickstart/install-and-use-a-package-in-visual-studio): Search for `Tableau.Migration`. | ||
|
||
--- | ||
|
||
- Use the sample code in one of the [Reference](#getting-started-and-api-reference) sections to get started. | ||
- Use the [Resource](#resources) sections to further customize your application. | ||
|
||
## Getting started and API Reference | ||
|
||
- [Python API Reference](~/api-python/index.md) : Getting started sample and the complete Python API Reference for comprehensive documentation. | ||
- [C# API Reference](~/api-csharp/index.md): Getting started sample and the complete C# API Reference for detailed documentation. | ||
|
||
## Resources | ||
|
||
- [Articles](~/articles/index.md): Articles covering a range of topics, including customization of the Migration SDK. | ||
- [Code Samples](~/samples/index.md): Code samples to kickstart your development process. | ||
|
||
## Source Code | ||
|
||
The Tableau Migration SDK is open source. The source code is in our [GitHub repo](https://github.com/tableau/tableau-migration-sdk). | ||
|
||
## Contributing | ||
|
||
Refer to this handy [contribution guide](https://github.com/tableau/tableau-migration-sdk/blob/main/CONTRIBUTING.md) if you would like to contribute to the Migration SDK. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Batch Migration Completed | ||
|
||
Batch Migration Completed Hooks allow custom logic to run when a migration batch completes. | ||
|
||
The following samples cover some common scenarios: | ||
|
||
- [Sample: Migration batch logging](~/samples/batch-migration-completed/log_migration_batches.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Bulk Post-Publish Hooks | ||
|
||
Bulk post-publish hooks allow you to update content item batches after they are migrated to the destination. | ||
|
||
The following samples cover some common scenarios: | ||
|
||
- [Sample: Bulk logging](~/samples/bulk-post-publish/bulk_logging.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Filters | ||
|
||
Filters allow you to skip migrating certain content items. | ||
|
||
> [!Note] | ||
> Filters do not have a cascading effect. You will need to write similar filters for the related content items as well. | ||
The following samples cover some common scenarios: | ||
|
||
- [Sample: Filter projects by name](~/samples/filters/filter_projects_by_name.md) | ||
|
||
- [Sample: Filter users by site role](~/samples/filters/filter_users_by_site_role.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Code Samples | ||
|
||
Once you have started building your migration using the example code in [C#](~/api-csharp/index.md) or [Python](~/api-python/index.md), you may want to further customize your migration using hooks. This section provides code samples to assist you. | ||
|
||
[Learn more about hooks here.](~/articles/hooks/index.md) | ||
|
||
## Hook Registration | ||
|
||
To use hooks, you need to register them with the [plan builder](~/articles/configuration.md#migration-plan). | ||
|
||
The process of registering hooks differs slightly between C# and Python, as described below. | ||
|
||
# [Python](#tab/Python) | ||
|
||
In Python, injecting an object into the class constructor is not supported, and in most cases, it is unnecessary. | ||
|
||
To register a Python hook object, simply create the object and add it to the appropriate hook type collection. | ||
|
||
**Generic Form:** `plan_builder.[hook type collection].add([hook object])` | ||
|
||
**Example:** | ||
``` | ||
plan_builder.filters.add(UnlicensedUsersFilter) | ||
``` | ||
|
||
# [C#](#tab/CSharp) | ||
|
||
In C#, the hook object should be registered with Dependency Injection (DI). This allows hooks to have any object injected into the constructor without concern for the source of the object. | ||
|
||
Learn more about [dependency injection](~/articles/dependency_injection.md). | ||
|
||
To register your hook object with the dependency injection service provider, simply add it. | ||
|
||
**Generic Form:** `services.AddScoped<[Object type]>();` | ||
|
||
**Example:** | ||
``` | ||
services.AddScoped<UnlicensedUsersFilter>(); | ||
``` | ||
|
||
Once the hook is registered with DI, it must be added to the appropriate [hook collection](~/articles/hooks/custom_hooks.md). | ||
|
||
**Generic Form:** `_planBuilder.[hook type collection].Add<[object name], [hook type]>();` | ||
|
||
**Example:** | ||
``` | ||
_planBuilder.Filters.Add<UnlicensedUsersFilter, IUser>(); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Mappings | ||
|
||
Mappings allow you to change the locations of content items before they are migrated to the destination. | ||
|
||
> [!Note] | ||
> Mappings do not have a cascading effect. You will need to write similar mappings for the related content items as well. | ||
The following samples cover some common scenarios: | ||
|
||
- [Sample: Username email](~/samples/mappings/username_email_mapping.md) | ||
- [Sample: Rename projects](~/samples/mappings/rename_projects.md) | ||
- [Sample: Change projects](~/samples/mappings/change_projects.md) |
7 changes: 7 additions & 0 deletions
7
src/Documentation/samples/migration-action-completed/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Migration Action Completed | ||
|
||
Migration Action Completed Hooks allow custom logic to run when a migration action completes. | ||
|
||
The following samples cover some common scenarios: | ||
|
||
- [Sample: Migration action logging](~/samples/migration-action-completed/log_migration_actions.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Post-Publish Hooks | ||
|
||
Post-publish hooks allow you to update content items after they are migrated to the destination. | ||
|
||
The following samples cover some common scenarios: | ||
|
||
- [Sample: Update permissions](~/samples/post-publish/update_permissions.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Transformers | ||
|
||
Transformers allow you to update content items before they are migrated to the destination. | ||
|
||
The following samples cover some common scenarios: | ||
|
||
- [Sample: Add tags to content](~/samples/transformers/migrated_tag_transformer.md) | ||
- [Sample: Encrypt Extracts](~/samples/transformers/encrypt_extracts_transformer.md) | ||
- [Sample: Adjust 'Start At' to Scheduled Tasks](~/samples/transformers/start_at_transformer.md) |
42 changes: 42 additions & 0 deletions
42
src/Documentation/samples/transformers/start_at_transformer.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Sample: Adjust 'Start At' to Scheduled Tasks | ||
|
||
This sample demonstrates how to adjust the 'Start At' of a Scheduled Task. | ||
|
||
Both the Python and C# transformer classes inherit from a base class responsible for the core functionality. | ||
|
||
## [Python](#tab/Python) | ||
|
||
### Transformer Class | ||
|
||
To adjust the 'Start At' in Python, you can use the following transformer class: | ||
|
||
[!code-python[](../../../../examples/Python.ExampleApplication/hooks/transformers/schedule_startat_transformer.py)] | ||
|
||
### Registration | ||
|
||
Refer to the [documentation](~/samples/index.md?tabs=Python#hook-registration) for instructions on registering the transformer. | ||
|
||
[//]: <> (Adding this as code as regions are not supported in python snippets) | ||
```Python | ||
plan_builder.transformers.add(SimpleScheduleStartAtTransformer) | ||
``` | ||
|
||
## [C#](#tab/CSharp) | ||
|
||
### Transformer Class | ||
|
||
In C#, the transformer class for adjusting the 'Start At' of a given Scheduled Task is implemented as follows: | ||
|
||
[!code-csharp[](../../../../examples/Csharp.ExampleApplication/Hooks/Transformers/SimpleScheduleStartAtTransformer.cs#class)] | ||
|
||
### Registration | ||
|
||
To register the transformer in C#, follow the guidance provided in the [documentation](~/samples/index.md?tabs=CSharp#hook-registration). | ||
|
||
[!code-csharp[](../../../../examples/Csharp.ExampleApplication/MyMigrationApplication.cs#StartAtTransformer-Registration)] | ||
|
||
### Dependency Injection | ||
|
||
Learn more about dependency injection [here](~/articles/dependency_injection.md). | ||
|
||
[!code-csharp[](../../../../examples/Csharp.ExampleApplication/Program.cs#StartAtTransformer-DI)] |
30 changes: 30 additions & 0 deletions
30
src/Documentation/templates/tableau/partials/navbar-li.tmpl.partial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{{!Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license.}} | ||
|
||
<ul class="nav level{{level}} navbar-nav"> | ||
{{#items}} | ||
{{^dropdown}} | ||
<li {{#active}}class="active"{{/active}}> | ||
{{^leaf}} | ||
<span class="expand-stub"></span> | ||
{{/leaf}} | ||
{{#topicHref}} | ||
<a href="{{topicHref}}" title="{{name}}">{{name}}</a> | ||
{{/topicHref}} | ||
{{^topicHref}} | ||
<a>{{{name}}}</a> | ||
{{/topicHref}} | ||
{{^leaf}} | ||
{{>partials/navbar-li}} | ||
{{/leaf}} | ||
</li> | ||
{{/dropdown}} | ||
{{#dropdown}} | ||
<li class="dropdown"> | ||
<a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">{{name}} <span class="caret"></span></a> | ||
<ul class="dropdown-menu level{{level}}"> | ||
{{>partials/dd-li}} | ||
</ul> | ||
</li> | ||
{{/dropdown}} | ||
{{/items}} | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/Documentation/_build | ||
/Documentation/_static | ||
/Python.pyproj.user | ||
/Documentation/generated |
Oops, something went wrong.