1010using Microsoft . Azure . Management . ApiManagement . ArmTemplates . Common . Extensions ;
1111using Microsoft . Azure . Management . ApiManagement . ArmTemplates . Common . FileHandlers ;
1212using Microsoft . Azure . Management . ApiManagement . ArmTemplates . Common . Templates . Abstractions ;
13+ using Microsoft . Azure . Management . ApiManagement . ArmTemplates . Common . Templates . ApiManagementService ;
1314using Microsoft . Azure . Management . ApiManagement . ArmTemplates . Common . Templates . Apis ;
1415using Microsoft . Azure . Management . ApiManagement . ArmTemplates . Common . Templates . ApiVersionSet ;
1516using Microsoft . Azure . Management . ApiManagement . ArmTemplates . Common . Templates . AuthorizationServer ;
@@ -62,6 +63,7 @@ public class ExtractorExecutor
6263 readonly IGatewayExtractor gatewayExtractor ;
6364 readonly IGatewayApiExtractor gatewayApiExtractor ;
6465 readonly IIdentityProviderExtractor identityProviderExtractor ;
66+ readonly IApiManagementServiceExtractor apiManagementServiceExtractor ;
6567
6668 public ExtractorExecutor (
6769 ILogger < ExtractorExecutor > logger ,
@@ -83,7 +85,8 @@ public ExtractorExecutor(
8385 IApiRevisionExtractor apiRevisionExtractor ,
8486 IGatewayExtractor gatewayExtractor ,
8587 IGatewayApiExtractor gatewayApiExtractor ,
86- IIdentityProviderExtractor identityProviderExtractor )
88+ IIdentityProviderExtractor identityProviderExtractor ,
89+ IApiManagementServiceExtractor apiManagementServiceExtractor )
8790 {
8891 this . logger = logger ;
8992 this . apisClient = apisClient ;
@@ -105,6 +108,7 @@ public ExtractorExecutor(
105108 this . gatewayExtractor = gatewayExtractor ;
106109 this . gatewayApiExtractor = gatewayApiExtractor ;
107110 this . identityProviderExtractor = identityProviderExtractor ;
111+ this . apiManagementServiceExtractor = apiManagementServiceExtractor ;
108112 }
109113
110114 /// <summary>
@@ -131,7 +135,8 @@ public static ExtractorExecutor BuildExtractorExecutor(
131135 IApiRevisionExtractor apiRevisionExtractor = null ,
132136 IGatewayExtractor gatewayExtractor = null ,
133137 IGatewayApiExtractor gatewayApiExtractor = null ,
134- IIdentityProviderExtractor identityProviderExtractor = null )
138+ IIdentityProviderExtractor identityProviderExtractor = null ,
139+ IApiManagementServiceExtractor apiManagementServiceExtractor = null )
135140 => new ExtractorExecutor (
136141 logger ,
137142 apisClient ,
@@ -152,7 +157,8 @@ public static ExtractorExecutor BuildExtractorExecutor(
152157 apiRevisionExtractor ,
153158 gatewayExtractor ,
154159 gatewayApiExtractor ,
155- identityProviderExtractor ) ;
160+ identityProviderExtractor ,
161+ apiManagementServiceExtractor ) ;
156162
157163 public void SetExtractorParameters ( ExtractorParameters extractorParameters )
158164 {
@@ -728,6 +734,23 @@ await FileWriter.SaveAsJsonAsync(
728734 return gatewayApiTemplate ;
729735 }
730736
737+ public async Task < Template < ApiManagementServiceResources > > GenerateApiManagementServiceTemplate ( string baseFilesGenerationDirectory )
738+ {
739+ this . logger . LogInformation ( "Started generation of ApiManagement service template..." ) ;
740+ var apiManagementServiceTemplate = await this . apiManagementServiceExtractor . GenerateApiManagementServicesTemplateAsync ( this . extractorParameters ) ;
741+
742+ if ( apiManagementServiceTemplate ? . HasResources ( ) == true )
743+ {
744+ await FileWriter . SaveAsJsonAsync (
745+ apiManagementServiceTemplate ,
746+ directory : baseFilesGenerationDirectory ,
747+ fileName : this . extractorParameters . FileNames . ApiManagementService ) ;
748+ }
749+
750+ this . logger . LogInformation ( "Finished generation of identity providers template..." ) ;
751+ return apiManagementServiceTemplate ;
752+ }
753+
731754 /// <summary>
732755 /// Generates split api templates / folders for each api in this sourceApim
733756 /// </summary>
@@ -910,6 +933,7 @@ async Task GenerateTemplates(
910933 var identityProviderTemplate = await this . GenerateIdentityProviderTemplateAsync ( baseFilesGenerationDirectory ) ;
911934 await this . GenerateGatewayTemplateAsync ( singleApiName , baseFilesGenerationDirectory ) ;
912935 await this . GenerateGatewayApiTemplateAsync ( singleApiName , multipleApiNames , baseFilesGenerationDirectory ) ;
936+ await this . GenerateApiManagementServiceTemplate ( baseFilesGenerationDirectory ) ;
913937 await this . GenerateParametersTemplateAsync ( apisToExtract , loggerTemplate . TypedResources , backendTemplate . TypedResources , namedValueTemplate . TypedResources , identityProviderTemplate . TypedResources , baseFilesGenerationDirectory ) ;
914938
915939 await this . GenerateMasterTemplateAsync (
0 commit comments