Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 5da5b31

Browse files
f-alizadaFarhad Alizada
andauthored
Introduce OriginalName for templateResources with common data processor (#807)
* Introduce OriginalName for templateResources with common data processor * Remove similiar data processors and combine with common Co-authored-by: Farhad Alizada <falizada@microsoft.com>
1 parent 7a3b68f commit 5da5b31

File tree

57 files changed

+195
-349
lines changed

Some content is hidden

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

57 files changed

+195
-349
lines changed

src/ArmTemplates/Common/API/Clients/ApiManagementService/ApiManagementServiceClient.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ public class ApiManagementServiceClient: ApiClientBase, IApiManagementServiceCli
1717
{
1818
const string GetApiManagementServiceByName = "{0}/subscriptions/{1}/resourceGroups/{2}/providers/Microsoft.ApiManagement/service/{3}?api-version={4}";
1919

20-
readonly IApiManagementServiceProcessor apiManagementServiceProcessor;
20+
readonly ITemplateResourceDataProcessor<ApiManagementServiceResource> templateResourceDataProcessor;
2121

2222
public ApiManagementServiceClient(
23-
IHttpClientFactory httpClientFactory,
24-
IApiManagementServiceProcessor apiManagementServiceProcessor): base(httpClientFactory)
23+
IHttpClientFactory httpClientFactory,
24+
ITemplateResourceDataProcessor<ApiManagementServiceResource> templateResourceDataProcessor) : base(httpClientFactory)
2525
{
26-
this.apiManagementServiceProcessor = apiManagementServiceProcessor;
26+
this.templateResourceDataProcessor = templateResourceDataProcessor;
2727
}
2828

2929
public async Task<ApiManagementServiceResource> GetApiManagementServiceAsync(ExtractorParameters extractorParameters)
@@ -34,7 +34,7 @@ public async Task<ApiManagementServiceResource> GetApiManagementServiceAsync(Ext
3434
this.BaseUrl, azSubId, extractorParameters.ResourceGroup, extractorParameters.SourceApimName, GlobalConstants.ApiVersion);
3535

3636
var apiManagementServiceResource = await this.GetResponseAsync<ApiManagementServiceResource>(azToken, requestUrl);
37-
this.apiManagementServiceProcessor.ProcessSingleInstanceData(apiManagementServiceResource, extractorParameters);
37+
this.templateResourceDataProcessor.ProcessSingleData(apiManagementServiceResource);
3838

3939
return apiManagementServiceResource;
4040
}

src/ArmTemplates/Common/API/Clients/ApiSchemas/ApiSchemaClient.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,19 @@
1010
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.Constants;
1111
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.Templates.ApiSchemas;
1212
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Extractor.Models;
13+
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Extractor.Utilities.DataProcessors.Absctraction;
1314

1415
namespace Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.API.Clients.ApiSchemas
1516
{
1617
public class ApiSchemaClient : ApiClientBase, IApiSchemaClient
1718
{
1819
const string GetAllApiSchemasRequest = "{0}/subscriptions/{1}/resourceGroups/{2}/providers/Microsoft.ApiManagement/service/{3}/apis/{4}/schemas?api-version={5}";
20+
21+
readonly ITemplateResourceDataProcessor<ApiSchemaTemplateResource> templateResourceDataProcessor;
1922

20-
public ApiSchemaClient(IHttpClientFactory httpClientFactory) : base(httpClientFactory)
23+
public ApiSchemaClient(IHttpClientFactory httpClientFactory, ITemplateResourceDataProcessor<ApiSchemaTemplateResource> templateResourceDataProcessor) : base(httpClientFactory)
2124
{
25+
this.templateResourceDataProcessor = templateResourceDataProcessor;
2226
}
2327

2428
public async Task<List<ApiSchemaTemplateResource>> GetApiSchemasAsync(string apiName, ExtractorParameters extractorParameters)
@@ -28,7 +32,9 @@ public async Task<List<ApiSchemaTemplateResource>> GetApiSchemasAsync(string api
2832
var requestUrl = string.Format(GetAllApiSchemasRequest,
2933
this.BaseUrl, azSubId, extractorParameters.ResourceGroup, extractorParameters.SourceApimName, apiName, GlobalConstants.ApiVersion);
3034

31-
return await this.GetPagedResponseAsync<ApiSchemaTemplateResource>(azToken, requestUrl);
35+
var apiSchemaTemplateResources = await this.GetPagedResponseAsync<ApiSchemaTemplateResource>(azToken, requestUrl);
36+
this.templateResourceDataProcessor.ProcessData(apiSchemaTemplateResources);
37+
return apiSchemaTemplateResources;
3238
}
3339
}
3440
}

src/ArmTemplates/Common/API/Clients/ApiVersionSet/ApiVersionSetClient.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,19 @@
1010
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.Constants;
1111
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.Templates.ApiVersionSet;
1212
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Extractor.Models;
13+
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Extractor.Utilities.DataProcessors.Absctraction;
1314

1415
namespace Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.API.Clients.ApiVersionSet
1516
{
1617
public class ApiVersionSetClient : ApiClientBase, IApiVersionSetClient
1718
{
1819
const string GetAllVersionSetsRequest = "{0}/subscriptions/{1}/resourceGroups/{2}/providers/Microsoft.ApiManagement/service/{3}/apiVersionSets?api-version={4}";
1920

20-
public ApiVersionSetClient(IHttpClientFactory httpClientFactory) : base(httpClientFactory)
21+
readonly ITemplateResourceDataProcessor<ApiVersionSetTemplateResource> templateResourceDataProcessor;
22+
23+
public ApiVersionSetClient(IHttpClientFactory httpClientFactory, ITemplateResourceDataProcessor<ApiVersionSetTemplateResource> templateResourceDataProcessor) : base(httpClientFactory)
2124
{
25+
this.templateResourceDataProcessor = templateResourceDataProcessor;
2226
}
2327

2428
public async Task<List<ApiVersionSetTemplateResource>> GetAllAsync(ExtractorParameters extractorParameters)
@@ -28,7 +32,9 @@ public async Task<List<ApiVersionSetTemplateResource>> GetAllAsync(ExtractorPara
2832
string requestUrl = string.Format(GetAllVersionSetsRequest,
2933
this.BaseUrl, azSubId, extractorParameters.ResourceGroup, extractorParameters.SourceApimName, GlobalConstants.ApiVersion);
3034

31-
return await this.GetPagedResponseAsync<ApiVersionSetTemplateResource>(azToken, requestUrl);
35+
var apiVersionSetTemplateresources = await this.GetPagedResponseAsync<ApiVersionSetTemplateResource>(azToken, requestUrl);
36+
this.templateResourceDataProcessor.ProcessData(apiVersionSetTemplateresources);
37+
return apiVersionSetTemplateresources;
3238
}
3339
}
3440
}

src/ArmTemplates/Common/API/Clients/AuthorizationServer/AuthorizationServerClient.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,19 @@
1010
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.Constants;
1111
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.Templates.AuthorizationServer;
1212
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Extractor.Models;
13+
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Extractor.Utilities.DataProcessors.Absctraction;
1314

1415
namespace Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.API.Clients.AuthorizationServer
1516
{
1617
public class AuthorizationServerClient : ApiClientBase, IAuthorizationServerClient
1718
{
1819
const string GetAllAuthorizationServersRequest = "{0}/subscriptions/{1}/resourceGroups/{2}/providers/Microsoft.ApiManagement/service/{3}/authorizationServers?api-version={4}";
1920

20-
public AuthorizationServerClient(IHttpClientFactory httpClientFactory) : base(httpClientFactory)
21+
readonly ITemplateResourceDataProcessor<AuthorizationServerTemplateResource> templateResourceDataProcessor;
22+
23+
public AuthorizationServerClient(IHttpClientFactory httpClientFactory, ITemplateResourceDataProcessor<AuthorizationServerTemplateResource> templateResourceDataProcessor) : base(httpClientFactory)
2124
{
25+
this.templateResourceDataProcessor = templateResourceDataProcessor;
2226
}
2327

2428
public async Task<List<AuthorizationServerTemplateResource>> GetAllAsync(ExtractorParameters extractorParameters)
@@ -28,7 +32,9 @@ public async Task<List<AuthorizationServerTemplateResource>> GetAllAsync(Extract
2832
var requestUrl = string.Format(GetAllAuthorizationServersRequest,
2933
this.BaseUrl, azSubId, extractorParameters.ResourceGroup, extractorParameters.SourceApimName, GlobalConstants.ApiVersion);
3034

31-
return await this.GetPagedResponseAsync<AuthorizationServerTemplateResource>(azToken, requestUrl);
35+
var authServerTemplateResources = await this.GetPagedResponseAsync<AuthorizationServerTemplateResource>(azToken, requestUrl);
36+
this.templateResourceDataProcessor.ProcessData(authServerTemplateResources);
37+
return authServerTemplateResources;
3238
}
3339
}
3440
}

src/ArmTemplates/Common/API/Clients/Backend/BackendClient.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,19 @@
1010
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.Constants;
1111
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.Templates.Backend;
1212
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Extractor.Models;
13+
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Extractor.Utilities.DataProcessors.Absctraction;
1314

1415
namespace Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.API.Clients.Backend
1516
{
1617
public class BackendClient : ApiClientBase, IBackendClient
1718
{
1819
const string GetAllBackendsRequest = "{0}/subscriptions/{1}/resourceGroups/{2}/providers/Microsoft.ApiManagement/service/{3}/backends?api-version={4}";
1920

20-
public BackendClient(IHttpClientFactory httpClientFactory) : base(httpClientFactory)
21+
readonly ITemplateResourceDataProcessor<BackendTemplateResource> templateResourceDataProcessor;
22+
23+
public BackendClient(IHttpClientFactory httpClientFactory, ITemplateResourceDataProcessor<BackendTemplateResource> templateResourceDataProcessor) : base(httpClientFactory)
2124
{
25+
this.templateResourceDataProcessor = templateResourceDataProcessor;
2226
}
2327

2428
public async Task<List<BackendTemplateResource>> GetAllAsync(ExtractorParameters extractorParameters)
@@ -28,7 +32,10 @@ public async Task<List<BackendTemplateResource>> GetAllAsync(ExtractorParameters
2832
var requestUrl = string.Format(GetAllBackendsRequest,
2933
this.BaseUrl, azSubId, extractorParameters.ResourceGroup, extractorParameters.SourceApimName, GlobalConstants.ApiVersion);
3034

31-
return await this.GetPagedResponseAsync<BackendTemplateResource>(azToken, requestUrl);
35+
var backendTemplateResources = await this.GetPagedResponseAsync<BackendTemplateResource>(azToken, requestUrl);
36+
this.templateResourceDataProcessor.ProcessData(backendTemplateResources);
37+
38+
return backendTemplateResources;
3239
}
3340
}
3441
}

src/ArmTemplates/Common/API/Clients/Diagnostics/DiagnosticClient.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.Constants;
1111
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.TemplateModels;
1212
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Extractor.Models;
13+
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Extractor.Utilities.DataProcessors.Absctraction;
1314

1415
namespace Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.API.Clients.Diagnostics
1516
{
@@ -18,8 +19,11 @@ public class DiagnosticClient : ApiClientBase, IDiagnosticClient
1819
const string GetAllDiagnosticsRequest = "{0}/subscriptions/{1}/resourceGroups/{2}/providers/Microsoft.ApiManagement/service/{3}/diagnostics?api-version={4}";
1920
const string GetDiagnosticsLinkedToApiRequest = "{0}/subscriptions/{1}/resourceGroups/{2}/providers/Microsoft.ApiManagement/service/{3}/apis/{4}/diagnostics?api-version={5}";
2021

21-
public DiagnosticClient(IHttpClientFactory httpClientFactory) : base(httpClientFactory)
22+
readonly ITemplateResourceDataProcessor<DiagnosticTemplateResource> templateResourceDataProcessor;
23+
24+
public DiagnosticClient(IHttpClientFactory httpClientFactory, ITemplateResourceDataProcessor<DiagnosticTemplateResource> templateResourceDataProcessor) : base(httpClientFactory)
2225
{
26+
this.templateResourceDataProcessor = templateResourceDataProcessor;
2327
}
2428

2529
public async Task<List<DiagnosticTemplateResource>> GetApiDiagnosticsAsync(string apiName, ExtractorParameters extractorParameters)
@@ -29,7 +33,9 @@ public async Task<List<DiagnosticTemplateResource>> GetApiDiagnosticsAsync(strin
2933
string requestUrl = string.Format(GetDiagnosticsLinkedToApiRequest,
3034
this.BaseUrl, azSubId, extractorParameters.ResourceGroup, extractorParameters.SourceApimName, apiName, GlobalConstants.ApiVersion);
3135

32-
return await this.GetPagedResponseAsync<DiagnosticTemplateResource>(azToken, requestUrl);
36+
var diagnosticTemplateResources = await this.GetPagedResponseAsync<DiagnosticTemplateResource>(azToken, requestUrl);
37+
this.templateResourceDataProcessor.ProcessData(diagnosticTemplateResources);
38+
return diagnosticTemplateResources;
3339
}
3440

3541
public async Task<List<DiagnosticTemplateResource>> GetAllAsync(ExtractorParameters extractorParameters)
@@ -39,7 +45,9 @@ public async Task<List<DiagnosticTemplateResource>> GetAllAsync(ExtractorParamet
3945
var requestUrl = string.Format(GetAllDiagnosticsRequest,
4046
this.BaseUrl, azSubId, extractorParameters.ResourceGroup, extractorParameters.SourceApimName, GlobalConstants.ApiVersion);
4147

42-
return await this.GetPagedResponseAsync<DiagnosticTemplateResource>(azToken, requestUrl);
48+
var diagnosticTemplateResources = await this.GetPagedResponseAsync<DiagnosticTemplateResource>(azToken, requestUrl);
49+
this.templateResourceDataProcessor.ProcessData(diagnosticTemplateResources);
50+
return diagnosticTemplateResources;
4351
}
4452
}
4553
}

src/ArmTemplates/Common/API/Clients/Gateway/GatewayClient.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.Extensions;
1313
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.Templates.Gateway;
1414
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Extractor.Models;
15+
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Extractor.Utilities.DataProcessors.Absctraction;
1516
using Microsoft.Extensions.Logging;
1617

1718
namespace Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.API.Clients.Gateway
@@ -22,15 +23,18 @@ public class GatewayClient : ApiClientBase, IGatewayClient
2223

2324
readonly ILogger<GatewayClient> logger;
2425
readonly IApisClient apisClient;
26+
readonly ITemplateResourceDataProcessor<GatewayTemplateResource> templateResourceDataProcessor;
2527

2628
public GatewayClient(
2729
IHttpClientFactory httpClientFactory,
2830
ILogger<GatewayClient> logger,
29-
IApisClient apisClient
30-
): base(httpClientFactory)
31+
IApisClient apisClient,
32+
ITemplateResourceDataProcessor<GatewayTemplateResource> templateResourceDataProcessor
33+
) : base(httpClientFactory)
3134
{
3235
this.logger = logger;
3336
this.apisClient = apisClient;
37+
this.templateResourceDataProcessor = templateResourceDataProcessor;
3438
}
3539

3640
public async Task<List<GatewayTemplateResource>> GetAllAsync(ExtractorParameters extractorParameters)
@@ -40,7 +44,9 @@ public async Task<List<GatewayTemplateResource>> GetAllAsync(ExtractorParameters
4044
string requestUrl = string.Format(GetAllGatewaysRequest,
4145
this.BaseUrl, azSubId, extractorParameters.ResourceGroup, extractorParameters.SourceApimName, GlobalConstants.ApiVersion);
4246

43-
return await this.GetPagedResponseAsync<GatewayTemplateResource>(azToken, requestUrl);
47+
var gatewatTemplateResources = await this.GetPagedResponseAsync<GatewayTemplateResource>(azToken, requestUrl);
48+
this.templateResourceDataProcessor.ProcessData(gatewatTemplateResources);
49+
return gatewatTemplateResources;
4450
}
4551

4652
/// <summary>

src/ArmTemplates/Common/API/Clients/IdentityProviders/IdentityProviderClient.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ public class IdentityProviderClient : ApiClientBase, IIdentityProviderClient
2020
const string GetAllIdentityProvidersRequest = "{0}/subscriptions/{1}/resourceGroups/{2}/providers/Microsoft.ApiManagement/service/{3}/identityProviders?api-version={4}";
2121
const string ListIdentyProviderSecret = "{0}/subscriptions/{1}/resourceGroups/{2}/providers/Microsoft.ApiManagement/service/{3}/identityProviders/{4}/listSecrets?api-version={5}";
2222

23-
readonly IIdentityProviderProcessor identityProviderProcessor;
23+
readonly ITemplateResourceDataProcessor<IdentityProviderResource> templateResourceDataProcessor;
2424

2525
public IdentityProviderClient(
2626
IHttpClientFactory httpClientFactory,
27-
IIdentityProviderProcessor identityProviderProcessor): base(httpClientFactory)
27+
ITemplateResourceDataProcessor<IdentityProviderResource> templateResourceDataProcessor) : base(httpClientFactory)
2828
{
29-
this.identityProviderProcessor = identityProviderProcessor;
29+
this.templateResourceDataProcessor = templateResourceDataProcessor;
3030
}
3131

3232
public async Task<List<IdentityProviderResource>> GetAllAsync(ExtractorParameters extractorParameters)
@@ -37,7 +37,7 @@ public async Task<List<IdentityProviderResource>> GetAllAsync(ExtractorParameter
3737
this.BaseUrl, azSubId, extractorParameters.ResourceGroup, extractorParameters.SourceApimName, GlobalConstants.ApiVersion);
3838

3939
var identityProviderTemplates = await this.GetPagedResponseAsync<IdentityProviderResource>(azToken, requestUrl);
40-
this.identityProviderProcessor.ProcessData(identityProviderTemplates, extractorParameters);
40+
this.templateResourceDataProcessor.ProcessData(identityProviderTemplates);
4141

4242
return identityProviderTemplates;
4343
}

src/ArmTemplates/Common/API/Clients/Loggers/LoggerClient.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,19 @@
1010
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.Constants;
1111
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.Templates.Logger;
1212
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Extractor.Models;
13+
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Extractor.Utilities.DataProcessors;
14+
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Extractor.Utilities.DataProcessors.Absctraction;
1315

1416
namespace Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.API.Clients.Loggers
1517
{
1618
public class LoggerClient : ApiClientBase, ILoggerClient
1719
{
1820
const string GetAllLoggersRequest = "{0}/subscriptions/{1}/resourceGroups/{2}/providers/Microsoft.ApiManagement/service/{3}/loggers?api-version={4}";
1921

20-
public LoggerClient(IHttpClientFactory httpClientFactory) : base(httpClientFactory)
22+
readonly ITemplateResourceDataProcessor<LoggerTemplateResource> templateResourceDataProcessor;
23+
public LoggerClient(IHttpClientFactory httpClientFactory, ITemplateResourceDataProcessor<LoggerTemplateResource> templateResourceDataProcessor) : base(httpClientFactory)
2124
{
25+
this.templateResourceDataProcessor = templateResourceDataProcessor;
2226
}
2327

2428
public async Task<List<LoggerTemplateResource>> GetAllAsync(ExtractorParameters extractorParameters)
@@ -28,8 +32,9 @@ public async Task<List<LoggerTemplateResource>> GetAllAsync(ExtractorParameters
2832
string requestUrl = string.Format(GetAllLoggersRequest,
2933
this.BaseUrl, azSubId, extractorParameters.ResourceGroup, extractorParameters.SourceApimName, GlobalConstants.ApiVersion);
3034

31-
return await this.GetPagedResponseAsync<LoggerTemplateResource>(azToken, requestUrl);
32-
35+
var loggerTemplateResources = await this.GetPagedResponseAsync<LoggerTemplateResource>(azToken, requestUrl);
36+
this.templateResourceDataProcessor.ProcessData(loggerTemplateResources);
37+
return loggerTemplateResources;
3338
}
3439
}
3540
}

0 commit comments

Comments
 (0)