/// <summary> /// Normalizes client model using Azure-specific extensions. /// </summary> /// <param name="codeModelient">Service client</param> /// <param name="settings">AutoRest settings</param> /// <param name="codeNamer">AutoRest settings</param> /// <returns></returns> public static void NormalizeAzureClientModel(CodeModel codeModel) { var settings = Settings.Instance; using (NewContext) { settings = new Settings().LoadFrom(settings); settings.AddCredentials = true; if (codeModel == null) { throw new ArgumentNullException("codeModel"); } // This extension from general extensions must be run prior to Azure specific extensions. ProcessParameterizedHost(codeModel); ProcessClientRequestIdExtension(codeModel); UpdateHeadMethods(codeModel); ParseODataExtension(codeModel); ProcessGlobalParameters(codeModel); FlattenModels(codeModel); FlattenMethodParameters(codeModel); ParameterGroupExtensionHelper.AddParameterGroups(codeModel); AddLongRunningOperations(codeModel); AddAzureProperties(codeModel); SetDefaultResponses(codeModel); AddPageableMethod(codeModel); } }
/// <summary> /// Normalizes client model using Azure-specific extensions. /// </summary> /// <param name="serviceClient">Service client</param> /// <param name="settings">AutoRest settings</param> /// <param name="codeNamer">AutoRest settings</param> /// <returns></returns> public static void NormalizeAzureClientModel(ServiceClient serviceClient, Settings settings, CodeNamer codeNamer) { if (serviceClient == null) { throw new ArgumentNullException("serviceClient"); } if (settings == null) { throw new ArgumentNullException("settings"); } if (codeNamer == null) { throw new ArgumentNullException("codeNamer"); } settings.AddCredentials = true; // This extension from general extensions must be run prior to Azure specific extensions. ProcessParameterizedHost(serviceClient, settings); ProcessClientRequestIdExtension(serviceClient); UpdateHeadMethods(serviceClient); ParseODataExtension(serviceClient); ProcessGlobalParameters(serviceClient); FlattenModels(serviceClient); FlattenMethodParameters(serviceClient, settings); ParameterGroupExtensionHelper.AddParameterGroups(serviceClient); AddLongRunningOperations(serviceClient); AddAzureProperties(serviceClient); SetDefaultResponses(serviceClient); AddPageableMethod(serviceClient, codeNamer); }
public override CodeModelPya TransformCodeModel(CodeModel cm) { var codeModel = (CodeModelPya)cm; TransformPagingMethods(codeModel); // We do most of "NormalizeAzureClientModel", but not everything // since some is handled manually here Settings.Instance.AddCredentials = true; // This extension from general extensions must be run prior to Azure specific extensions. AzureExtensions.ProcessParameterizedHost(codeModel); AzureExtensions.ProcessClientRequestIdExtension(codeModel); AzureExtensions.UpdateHeadMethods(codeModel); AzureExtensions.ParseODataExtension(codeModel); AzureExtensions.ProcessGlobalParameters(codeModel); AzureExtensions.FlattenModels(codeModel); AzureExtensions.FlattenMethodParameters(codeModel); ParameterGroupExtensionHelper.AddParameterGroups(codeModel); // AzureExtensions.AddLongRunningOperations(codeModel); -- Replaced by Python version AddAzureProperties(codeModel); AzureExtensions.SetDefaultResponses(codeModel); // AzureExtensions.AddPageableMethod(codeModel); -- Replaced by Python version // End of mock "NormalizeAzureClientModel" CorrectFilterParameters(codeModel); Base.TransformCodeModel(codeModel); NormalizePaginatedMethods(codeModel); return(codeModel); }
public override CodeModelJv TransformCodeModel(CodeModel cm) { var codeModel = cm as CodeModelJva; // we're guaranteed to be in our language-specific context here. Settings.Instance.AddCredentials = true; // This extension from general extensions must be run prior to Azure specific extensions. AzureExtensions.ProcessParameterizedHost(codeModel); AzureExtensions.ProcessClientRequestIdExtension(codeModel); AzureExtensions.UpdateHeadMethods(codeModel); AzureExtensions.ProcessGlobalParameters(codeModel); AzureExtensions.FlattenModels(codeModel); AzureExtensions.FlattenMethodParameters(codeModel); ParameterGroupExtensionHelper.AddParameterGroups(codeModel); AddLongRunningOperations(codeModel); AzureExtensions.AddAzureProperties(codeModel); AzureExtensions.SetDefaultResponses(codeModel); // set Parent on responses (required for pageable) foreach (MethodJva method in codeModel.Methods) { foreach (ResponseJva response in method.Responses.Values) { response.Parent = method; } (method.DefaultResponse as ResponseJva).Parent = method; method.ReturnTypeJva.Parent = method; } AzureExtensions.AddPageableMethod(codeModel); // pluralize method groups foreach (var mg in codeModel.Operations) { mg.Name.OnGet += name => name.IsNullOrEmpty() || name.EndsWith("s", StringComparison.OrdinalIgnoreCase) ? $"{name}" : $"{name}s"; } NormalizePaginatedMethods(codeModel, codeModel.pageClasses); // determine inner models NormalizeTopLevelTypes(codeModel); // param order (PATH first) foreach (MethodJva method in codeModel.Methods) { var ps = method.Parameters.ToList(); method.ClearParameters(); foreach (var p in ps.Where(x => x.Location == ParameterLocation.Path)) { method.Add(p); } foreach (var p in ps.Where(x => x.Location != ParameterLocation.Path)) { method.Add(p); } } return(codeModel); }
/// <summary> /// Normalizes client model by updating names and types to be language specific. /// </summary> /// <param name="serviceClient"></param> public override void NormalizeClientModel(ServiceClient serviceClient) { // Don't add pagable/longrunning method since we already handle ourself. Settings.AddCredentials = true; AzureExtensions.UpdateHeadMethods(serviceClient); AzureExtensions.ParseODataExtension(serviceClient); Extensions.FlattenModels(serviceClient); ParameterGroupExtensionHelper.AddParameterGroups(serviceClient); AzureExtensions.AddAzureProperties(serviceClient); AzureExtensions.SetDefaultResponses(serviceClient); CorrectFilterParameters(serviceClient); base.NormalizeClientModel(serviceClient); NormalizeApiVersion(serviceClient); NormalizePaginatedMethods(serviceClient); }
/// <summary> /// Normalizes client model by updating names and types to be language specific. /// </summary> /// <param name="serviceClient"></param> public override void NormalizeClientModel(ServiceClient serviceClient) { Settings.AddCredentials = true; // This extension from general extensions must be run prior to Azure specific extensions. AzureExtensions.ProcessParameterizedHost(serviceClient, Settings); AzureExtensions.ProcessClientRequestIdExtension(serviceClient); AzureExtensions.UpdateHeadMethods(serviceClient); AzureExtensions.FlattenModels(serviceClient); AzureExtensions.FlattenMethodParameters(serviceClient, Settings); ParameterGroupExtensionHelper.AddParameterGroups(serviceClient); AzureExtensions.AddLongRunningOperations(serviceClient); AzureExtensions.AddAzureProperties(serviceClient); AzureExtensions.SetDefaultResponses(serviceClient); AzureExtensions.AddPageableMethod(serviceClient, _namer); _namer.NormalizeClientModel(serviceClient); _namer.ResolveNameCollisions(serviceClient, Settings.Namespace, Settings.Namespace + ".Models"); _namer.NormalizePaginatedMethods(serviceClient, pageClasses); }
public override CodeModelPya TransformCodeModel(CodeModel cm) { var codeModel = (CodeModelPya)cm; TransformPagingMethods(codeModel); // Don't add pagable/longrunning method since we already handle ourself. Settings.Instance.AddCredentials = true; AzureExtensions.ProcessClientRequestIdExtension(codeModel); AzureExtensions.UpdateHeadMethods(codeModel); AzureExtensions.ParseODataExtension(codeModel); SwaggerExtensions.FlattenModels(codeModel); ParameterGroupExtensionHelper.AddParameterGroups(codeModel); AddAzureProperties(codeModel); AzureExtensions.SetDefaultResponses(codeModel); CorrectFilterParameters(codeModel); Base.TransformCodeModel(codeModel); NormalizePaginatedMethods(codeModel); return(codeModel); }