Tableau Migration SDK 5.1.1
  • Articles
  • Code Samples
  • Python API Reference
  • C# API Reference
Show / Hide Table of Contents
  • Filters
    • Filter projects by name
    • Filter users by SiteRole
    • Filter Custom Views by 'Shared' flag
  • Mappings
    • Username email
    • Rename projects
    • Change projects
  • Transformers
    • Add tags to content
    • Encrypt Extracts
    • Adjust 'Start At' to Scheduled Tasks
    • Change default users for Custom Views
    • Action URL XML Transformer
  • Post-Publish Hooks
    • Update permissions
  • Bulk Post-Publish Hooks
    • Bulk logging
  • Batch Migration Completed Hooks
    • Batch migration logging
  • Migration Action Completed Hooks
    • Migration action logging

Sample: Rename Projects

In this example, the source project named Test is renamed to Production on the destination.

  • Python
  • C#

Mapping Class

from tableau_migration import(
    IProject,
    ContentMappingBase,
    ContentMappingContext)


class ProjectRenameMapping(ContentMappingBase[IProject]):
    def map(self, ctx: ContentMappingContext[IProject]) -> ContentMappingContext[IProject]:
        if not ctx.content_item.name.casefold() == "Test".casefold():
            return ctx
        
        new_location = ctx.content_item.location.rename("Production")
        
        ctx = ctx.map_to(new_location)
        
        return ctx

Registration

plan_builder.mappings.add(ProjectRenameMapping)

See hook registration for more details.

Mapping Class

public class ProjectRenameMapping : ContentMappingBase<IProject>
{
    public ProjectRenameMapping(ISharedResourcesLocalizer localizer, ILogger<IContentMapping<IProject>> logger) : base(localizer, logger)
    { }

    public override async Task<ContentMappingContext<IProject>?> MapAsync(ContentMappingContext<IProject> ctx, CancellationToken cancel)
    {
        if (!String.Equals("Test", ctx.ContentItem.Name, StringComparison.OrdinalIgnoreCase))
        {
            return ctx;
        }

        var newLocation = ctx.ContentItem.Location.Rename("Production");

        ctx = ctx.MapTo(newLocation);

        return await ctx.ToTask();
    }
}

Registration

Learn more.

_planBuilder.Mappings.Add<ProjectRenameMapping, IProject>();

Dependency Injection

Learn more.

services.AddScoped<ProjectRenameMapping>();
  • Edit this page
In this article