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) { 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); AzureExtensions.FlattenModels(codeModel); //https://github.com/Azure/autorest/issues/2860 //ParameterGroupExtensionHelper.AddParameterGroups(codeModel); AddAzureProperties(codeModel); AzureExtensions.SetDefaultResponses(codeModel); CorrectFilterParameters(codeModel); Base.TransformCodeModel(codeModel); NormalizePaginatedMethods(codeModel); return(codeModel); }