Framework/Helpers/SVTMapping.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
Set-StrictMode -Version Latest
class SVTMapping
{
    static [string] $VirtualNetworkTypeName = "VirtualNetwork";
    static [string] $ERvNetTypeName = "ERvNet";
    static [string] $LogicAppsTypeName = "LogicApps";
    static [string] $APIConnectionTypeName = "APIConnection";

    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($null -eq [SVTMapping]::SupportedResourceMap){
            $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 = [SVTMapping]::LogicAppsTypeName;
        },
        [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.DataFactory/factories";
            JsonFileName = "DataFactoryV2.json";
            ClassName = "DataFactoryV2";
            ResourceTypeName = "DataFactoryV2";
        }, 
        [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";
            FixClassName = "CDNFix";
            FixFileName = "CDNFix.ps1";
        },
        [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";
            FixClassName = "RedisCacheFix";
            FixFileName = "RedisCacheFix.ps1";
        },
        [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";
            FixClassName = "TrafficManagerFix";
            FixFileName = "TrafficManagerFix.ps1";
        
        },
        [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";
        },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.Web/connections";
            JsonFileName = "APIConnection.json";
            ClassName = "APIConnection";
            ResourceTypeName = [SVTMapping]::APIConnectionTypeName;
        },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.BotService/botServices";
            JsonFileName = "BotService.json";
            ClassName = "BotService";
            ResourceTypeName = "BotService";
        },
        [ResourceTypeMapping]@{
            ResourceType = "AzSKCfg";
            ClassName = "AzSKCfg";
            JsonFileName = "AzSKCfg.json";
            ResourceTypeName = "AzSKCfg";
        },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.ContainerInstance/containerGroups";
            ClassName = "ContainerInstances";
            JsonFileName = "ContainerInstances.json";
            ResourceTypeName = "ContainerInstances";
        },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.ContainerRegistry/registries";
            ClassName = "ContainerRegistry";
            JsonFileName = "ContainerRegistry.json";
            ResourceTypeName = "ContainerRegistry";
            FixClassName = "ContainerRegistryFix";
            FixFileName = "ContainerRegistryFix.ps1";
        },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.Databricks/workspaces";
            ClassName = "Databricks";
            JsonFileName = "Databricks.json";
            ResourceTypeName = "Databricks";
        },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.HDInsight/clusters";
            ClassName = "HDInsight";
            JsonFileName = "HDInsight.json";
            ResourceTypeName = "HDInsight";
        },
        [ResourceTypeMapping]@{
            ResourceType = "";
            ClassName = "";
            JsonFileName = "ApplicationProxy.json";
            ResourceTypeName = "";
        },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.ApiManagement/service";
            ClassName = "APIManagement";
            JsonFileName = "APIManagement.json";
            ResourceTypeName = "APIManagement";
        },
        [ResourceTypeMapping]@{
            ResourceType = "Microsoft.ContainerService/ManagedClusters";
            ClassName = "KubernetesService";
            JsonFileName = "KubernetesService.json";
            ResourceTypeName = "KubernetesService";
        },
     [ResourceTypeMapping]@{
            ResourceType = "Microsoft.DBforPostgreSQL/servers";
            ClassName = "DBForPostgreSQL";
            JsonFileName = "DBForPostgreSQL.json";
            ResourceTypeName = "DBForPostgreSQL";
    },
     [ResourceTypeMapping]@{
            ResourceType = "Microsoft.DBforMySQL/servers";
            ClassName = "DBForMySql";
            JsonFileName = "DBForMySql.json";
            ResourceTypeName = "DBForMySql";
    },
    [ResourceTypeMapping]@{
        ResourceType = "Microsoft.Compute/virtualMachineScaleSets";
        JsonFileName = "VirtualMachineScaleSet.json";
        ClassName = "VirtualMachineScaleSet";
        ResourceTypeName = "VirtualMachineScaleSet";
    }
    );

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

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