Framework/Helpers/SVTMapping.ps1

Set-StrictMode -Version Latest
class SVTMapping
{
    static [string] $VirtualNetworkTypeName = "VirtualNetwork";
    static [string] $ERvNetTypeName = "ERvNet";

    hidden static [hashtable] $SupportedResourceMap = $null;

    static [string] GetResourceTypeEnumItems()
    {
        return ([SVTMapping]::Mapping |
                    Where-Object { -not [string]::IsNullOrEmpty($_.ResourceTypeName) } |
                    ForEach-Object { "$($_.ResourceTypeName.Replace(' ', '')) `r`n" } |
                    Sort-Object);
    }

    static [hashtable] GetSupportedResourceMap()
    {
        if([SVTMapping]::SupportedResourceMap -eq $null){
            $supportedMap = @{}
            foreach($map in [SVTMapping]::Mapping){
                if([string]::IsNullOrWhiteSpace($map.ResourceType) -or [string]::IsNullOrWhiteSpace($map.ResourceTypeName)){
                    continue;
                }
                if($supportedMap.ContainsKey($map.ResourceType)) {continue;}
                $supportedMap.Add($map.ResourceType.ToLower(), $map.ResourceTypeName)
            }
            [SVTMapping]::SupportedResourceMap = $supportedMap
        }
        return [SVTMapping]::SupportedResourceMap
    }

    static [ResourceTypeMapping[]] $Mapping = (
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.Logic/Workflows";
            JsonFileName = "LogicApps.json";
            ClassName = "LogicApps";
            ResourceTypeName = "LogicApps";
        },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.Compute/virtualMachines";
            JsonFileName = "VirtualMachine.json";
            ClassName = "VirtualMachine";
            ResourceTypeName = "VirtualMachine";
        },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.DataLakeStore/accounts";
            JsonFileName = "DataLakeStore.json";
            ClassName = "DataLakeStore";
            ResourceTypeName = "DataLakeStore";
        },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.DataLakeAnalytics/accounts";
            JsonFileName = "DataLakeAnalytics.json";
            ClassName = "DataLakeAnalytics";
            ResourceTypeName = "DataLakeAnalytics";
        },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.KeyVault/vaults";
            JsonFileName = "KeyVault.json";
            ClassName = "KeyVault";
            ResourceTypeName = "KeyVault";
        },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.Sql/servers";
            JsonFileName = "SQLDatabase.json";
            ClassName = "SQLDatabase";
            FixClassName = "SQLDatabaseFix";
            FixFileName = "SQLDatabaseFix.ps1";
            ResourceTypeName = "SQLDatabase";
        },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.Web/sites";
            JsonFileName = "AppService.json";
            ClassName = "AppService";
            FixClassName = "AppServiceFix";
            FixFileName = "AppServiceFix.ps1";
            ResourceTypeName = "AppService";
        },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.DataFactory/dataFactories";
            JsonFileName = "DataFactory.json";
            ClassName = "DataFactory";
            ResourceTypeName = "DataFactory";
        },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.Storage/storageAccounts";
            JsonFileName = "Storage.json";
            ClassName = "Storage";
            ResourceTypeName = "Storage";
            FixClassName = "StorageFix";
            FixFileName = "StorageFix.ps1";
        },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.NotificationHubs/namespaces/notificationHubs";
            JsonFileName = "NotificationHub.json";
            ClassName = "NotificationHub";
            ResourceTypeName = "NotificationHub";
         },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.Cdn/profiles";
            JsonFileName = "CDN.json";
            ClassName = "CDN";
            ResourceTypeName = "CDN";
        },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.Network/virtualNetworks";
            JsonFileName = "VirtualNetwork.json";
            ClassName = "VirtualNetwork";
            ResourceTypeName = [SVTMapping]::VirtualNetworkTypeName;
        },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.Network/virtualNetworks";
            JsonFileName = "ERvNet.json";
            ClassName = "ERvNet";
            ResourceTypeName = [SVTMapping]::ERvNetTypeName;
        },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.AnalysisServices/servers";
            JsonFileName = "AnalysisServices.json";
            ClassName = "AnalysisServices";
            ResourceTypeName = "AnalysisServices";
        },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.Search/searchServices";
            JsonFileName = "Search.json";
            ClassName = "Search";
            ResourceTypeName = "Search";
        },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.Batch/batchAccounts";
            JsonFileName = "Batch.json";
            ClassName = "Batch";
            ResourceTypeName = "Batch";
        },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.ClassicCompute/domainNames";
            JsonFileName = "CloudService.json";
            ClassName = "CloudService";
            ResourceTypeName = "CloudService";
        },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.ServiceBus/namespaces";
            JsonFileName = "ServiceBus.json";
            ClassName = "ServiceBus";
            ResourceTypeName = "ServiceBus";
        },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.Eventhub/namespaces";
            JsonFileName = "EventHub.json";
            ClassName = "EventHub";
            ResourceTypeName = "EventHub";
        },
       [ResourceTypeMapping]@{
            ResourceType = "Microsoft.Cache/Redis";
            JsonFileName = "RedisCache.json";
            ClassName = "RedisCache";
            ResourceTypeName = "RedisCache";
        },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.ServiceFabric/clusters";
            JsonFileName = "ServiceFabric.json";
            ClassName = "ServiceFabric";
            ResourceTypeName = "ServiceFabric";
        },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.Web/connectionGateways";
            JsonFileName = "ODG.json";
            ClassName = "ODG";
            ResourceTypeName = "ODG";
        },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.Network/trafficmanagerprofiles";
            JsonFileName = "TrafficManager.json";
            ClassName = "TrafficManager";
            ResourceTypeName = "TrafficManager";
        },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.StreamAnalytics/streamingjobs";
            JsonFileName = "StreamAnalytics.json";
            ClassName = "StreamAnalytics";
            ResourceTypeName = "StreamAnalytics";
        },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.DocumentDb/databaseAccounts";
            JsonFileName = "CosmosDB.json";
            ClassName = "CosmosDb";
            ResourceTypeName = "CosmosDB";
        },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.Automation/automationAccounts";
            JsonFileName = "Automation.json";
            ClassName = "Automation";
            ResourceTypeName = "Automation";
        },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.Network/loadBalancers";
            JsonFileName = "LoadBalancer.json";
            ClassName = "LoadBalancer";
            ResourceTypeName = "LoadBalancer";
        }
    );

    static [SubscriptionMapping] $SubscriptionMapping =@{
        ClassName = "SubscriptionCore";
        JsonFileName = "SubscriptionCore.json";
        FixClassName = "SubscriptionCoreFix";
        FixFileName = "SubscriptionCoreFix.ps1";
    };
}

Invoke-Expression "enum ResourceTypeName { `r`n All `r`n $([SVTMapping]::GetResourceTypeEnumItems()) }";