diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Internal/WirePathAttribute.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Internal/WirePathAttribute.cs new file mode 100644 index 0000000000000..c6be2fc6eb6c2 --- /dev/null +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Internal/WirePathAttribute.cs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.MySql +{ + [AttributeUsage(AttributeTargets.Property)] + internal class WirePathAttribute : Attribute + { + private string _wirePath; + + public WirePathAttribute(string wirePath) + { + _wirePath = wirePath; + } + + public override string ToString() + { + return _wirePath; + } + } +} diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlAdvisorListResult.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlAdvisorListResult.Serialization.cs index 22d60f5c5ad97..6917a3162f0db 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlAdvisorListResult.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlAdvisorListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.Models @@ -114,6 +117,107 @@ internal static MySqlAdvisorListResult DeserializeMySqlAdvisorListResult(JsonEle return new MySqlAdvisorListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +226,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlAdvisorListResult)} does not support '{options.Format}' format."); } @@ -138,6 +244,8 @@ MySqlAdvisorListResult IPersistableModel.Create(BinaryDa using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlAdvisorListResult(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlAdvisorListResult)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlConfigurations.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlConfigurations.Serialization.cs index 5fccabf9c30c1..b39ad13609c74 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlConfigurations.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlConfigurations.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.Models @@ -103,6 +106,85 @@ internal static MySqlConfigurations DeserializeMySqlConfigurations(JsonElement e return new MySqlConfigurations(value ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Values), out propertyOverride); + if (Optional.IsCollectionDefined(Values) || hasPropertyOverride) + { + if (Values.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Values) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -111,6 +193,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlConfigurations)} does not support '{options.Format}' format."); } @@ -127,6 +211,8 @@ MySqlConfigurations IPersistableModel.Create(BinaryData dat using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlConfigurations(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlConfigurations)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlConfigurations.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlConfigurations.cs index ef2a76374ffb4..75154028430bc 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlConfigurations.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlConfigurations.cs @@ -62,6 +62,7 @@ internal MySqlConfigurations(IList values, IDictionary The list of server configurations. + [WirePath("value")] public IList Values { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlDatabaseListResult.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlDatabaseListResult.Serialization.cs index 7228e8c17fa06..2948bfb56f8f0 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlDatabaseListResult.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlDatabaseListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.Models @@ -103,6 +106,85 @@ internal static MySqlDatabaseListResult DeserializeMySqlDatabaseListResult(JsonE return new MySqlDatabaseListResult(value ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -111,6 +193,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpt { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlDatabaseListResult)} does not support '{options.Format}' format."); } @@ -127,6 +211,8 @@ MySqlDatabaseListResult IPersistableModel.Create(Binary using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlDatabaseListResult(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlDatabaseListResult)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlFirewallRuleListResult.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlFirewallRuleListResult.Serialization.cs index f83438d81e61a..21136fa1f6bbf 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlFirewallRuleListResult.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlFirewallRuleListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.Models @@ -103,6 +106,85 @@ internal static MySqlFirewallRuleListResult DeserializeMySqlFirewallRuleListResu return new MySqlFirewallRuleListResult(value ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -111,6 +193,8 @@ BinaryData IPersistableModel.Write(ModelReaderWrite { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFirewallRuleListResult)} does not support '{options.Format}' format."); } @@ -127,6 +211,8 @@ MySqlFirewallRuleListResult IPersistableModel.Creat using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlFirewallRuleListResult(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlFirewallRuleListResult)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlLogFile.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlLogFile.Serialization.cs index 5f47827f832c1..23157d9fea18c 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlLogFile.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlLogFile.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; using Azure.ResourceManager.MySql; @@ -223,6 +225,196 @@ internal static MySqlLogFile DeserializeMySqlLogFile(JsonElement element, ModelR serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SizeInKB), out propertyOverride); + if (Optional.IsDefined(SizeInKB) || hasPropertyOverride) + { + builder.Append(" sizeInKB: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SizeInKB.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); + if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) + { + builder.Append(" createdTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastModifiedOn), out propertyOverride); + if (Optional.IsDefined(LastModifiedOn) || hasPropertyOverride) + { + builder.Append(" lastModifiedTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(LastModifiedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LogFileType), out propertyOverride); + if (Optional.IsDefined(LogFileType) || hasPropertyOverride) + { + builder.Append(" type: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (LogFileType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{LogFileType}'''"); + } + else + { + builder.AppendLine($"'{LogFileType}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Uri), out propertyOverride); + if (Optional.IsDefined(Uri) || hasPropertyOverride) + { + builder.Append(" url: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Uri.AbsoluteUri}'"); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -231,6 +423,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions option { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlLogFile)} does not support '{options.Format}' format."); } @@ -247,6 +441,8 @@ MySqlLogFile IPersistableModel.Create(BinaryData data, ModelReader using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlLogFile(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlLogFile)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlLogFile.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlLogFile.cs index 00b6bfb95a35d..361444ce05188 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlLogFile.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlLogFile.cs @@ -74,14 +74,19 @@ internal MySqlLogFile(ResourceIdentifier id, string name, ResourceType resourceT } /// Size of the log file. + [WirePath("properties.sizeInKB")] public long? SizeInKB { get; set; } /// Creation timestamp of the log file. + [WirePath("properties.createdTime")] public DateTimeOffset? CreatedOn { get; } /// Last modified timestamp of the log file. + [WirePath("properties.lastModifiedTime")] public DateTimeOffset? LastModifiedOn { get; } /// Type of the log file. + [WirePath("properties.type")] public string LogFileType { get; set; } /// The url to download the log file from. + [WirePath("properties.url")] public Uri Uri { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlLogFileListResult.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlLogFileListResult.Serialization.cs index d5d656071af21..b95679eed3935 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlLogFileListResult.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlLogFileListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.Models @@ -103,6 +106,85 @@ internal static MySqlLogFileListResult DeserializeMySqlLogFileListResult(JsonEle return new MySqlLogFileListResult(value ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -111,6 +193,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlLogFileListResult)} does not support '{options.Format}' format."); } @@ -127,6 +211,8 @@ MySqlLogFileListResult IPersistableModel.Create(BinaryDa using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlLogFileListResult(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlLogFileListResult)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlNameAvailabilityContent.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlNameAvailabilityContent.cs index c8a031316f2a8..8a013af997e30 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlNameAvailabilityContent.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlNameAvailabilityContent.cs @@ -74,8 +74,10 @@ internal MySqlNameAvailabilityContent() } /// Resource name to verify. + [WirePath("name")] public string Name { get; } /// Resource type used for verification. + [WirePath("type")] public ResourceType? ResourceType { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlNameAvailabilityResult.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlNameAvailabilityResult.Serialization.cs index a2870a9a62060..b78c563c75f4b 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlNameAvailabilityResult.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlNameAvailabilityResult.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.Models @@ -115,6 +117,122 @@ internal static MySqlNameAvailabilityResult DeserializeMySqlNameAvailabilityResu return new MySqlNameAvailabilityResult(message, nameAvailable, reason, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Message), out propertyOverride); + if (Optional.IsDefined(Message) || hasPropertyOverride) + { + builder.Append(" message: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Message.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Message}'''"); + } + else + { + builder.AppendLine($"'{Message}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsNameAvailable), out propertyOverride); + if (Optional.IsDefined(IsNameAvailable) || hasPropertyOverride) + { + builder.Append(" nameAvailable: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsNameAvailable.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); + if (Optional.IsDefined(Reason) || hasPropertyOverride) + { + builder.Append(" reason: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Reason.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Reason}'''"); + } + else + { + builder.AppendLine($"'{Reason}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -123,6 +241,8 @@ BinaryData IPersistableModel.Write(ModelReaderWrite { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlNameAvailabilityResult)} does not support '{options.Format}' format."); } @@ -139,6 +259,8 @@ MySqlNameAvailabilityResult IPersistableModel.Creat using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlNameAvailabilityResult(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlNameAvailabilityResult)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlNameAvailabilityResult.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlNameAvailabilityResult.cs index bf4fbfc650bdc..7ed066d7aad90 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlNameAvailabilityResult.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlNameAvailabilityResult.cs @@ -64,10 +64,13 @@ internal MySqlNameAvailabilityResult(string message, bool? isNameAvailable, stri } /// Error Message. + [WirePath("message")] public string Message { get; } /// Indicates whether the resource name is available. + [WirePath("nameAvailable")] public bool? IsNameAvailable { get; } /// Reason for name being unavailable. + [WirePath("reason")] public string Reason { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlPerformanceTier.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlPerformanceTier.Serialization.cs index d16ea00c90fc0..d8a882fcb4936 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlPerformanceTier.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlPerformanceTier.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.Models @@ -213,6 +216,191 @@ internal static MySqlPerformanceTier DeserializeMySqlPerformanceTier(JsonElement serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Id.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Id}'''"); + } + else + { + builder.AppendLine($"'{Id}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaxBackupRetentionDays), out propertyOverride); + if (Optional.IsDefined(MaxBackupRetentionDays) || hasPropertyOverride) + { + builder.Append(" maxBackupRetentionDays: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{MaxBackupRetentionDays.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinBackupRetentionDays), out propertyOverride); + if (Optional.IsDefined(MinBackupRetentionDays) || hasPropertyOverride) + { + builder.Append(" minBackupRetentionDays: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{MinBackupRetentionDays.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaxStorageInMB), out propertyOverride); + if (Optional.IsDefined(MaxStorageInMB) || hasPropertyOverride) + { + builder.Append(" maxStorageMB: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{MaxStorageInMB.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinLargeStorageInMB), out propertyOverride); + if (Optional.IsDefined(MinLargeStorageInMB) || hasPropertyOverride) + { + builder.Append(" minLargeStorageMB: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{MinLargeStorageInMB.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaxLargeStorageInMB), out propertyOverride); + if (Optional.IsDefined(MaxLargeStorageInMB) || hasPropertyOverride) + { + builder.Append(" maxLargeStorageMB: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{MaxLargeStorageInMB.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinStorageInMB), out propertyOverride); + if (Optional.IsDefined(MinStorageInMB) || hasPropertyOverride) + { + builder.Append(" minStorageMB: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{MinStorageInMB.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServiceLevelObjectives), out propertyOverride); + if (Optional.IsCollectionDefined(ServiceLevelObjectives) || hasPropertyOverride) + { + if (ServiceLevelObjectives.Any() || hasPropertyOverride) + { + builder.Append(" serviceLevelObjectives: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in ServiceLevelObjectives) + { + AppendChildObject(builder, item, options, 4, true, " serviceLevelObjectives: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -221,6 +409,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOption { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlPerformanceTier)} does not support '{options.Format}' format."); } @@ -237,6 +427,8 @@ MySqlPerformanceTier IPersistableModel.Create(BinaryData d using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlPerformanceTier(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlPerformanceTier)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlPerformanceTier.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlPerformanceTier.cs index c432ebbc893e8..26b06bddc2364 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlPerformanceTier.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlPerformanceTier.cs @@ -76,20 +76,28 @@ internal MySqlPerformanceTier(string id, int? maxBackupRetentionDays, int? minBa } /// ID of the performance tier. + [WirePath("id")] public string Id { get; } /// Maximum Backup retention in days for the performance tier edition. + [WirePath("maxBackupRetentionDays")] public int? MaxBackupRetentionDays { get; } /// Minimum Backup retention in days for the performance tier edition. + [WirePath("minBackupRetentionDays")] public int? MinBackupRetentionDays { get; } /// Max storage allowed for a server. + [WirePath("maxStorageMB")] public int? MaxStorageInMB { get; } /// Max storage allowed for a server. + [WirePath("minLargeStorageMB")] public int? MinLargeStorageInMB { get; } /// Max storage allowed for a server. + [WirePath("maxLargeStorageMB")] public int? MaxLargeStorageInMB { get; } /// Max storage allowed for a server. + [WirePath("minStorageMB")] public int? MinStorageInMB { get; } /// Service level objectives associated with the performance tier. + [WirePath("serviceLevelObjectives")] public IReadOnlyList ServiceLevelObjectives { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlPerformanceTierListResult.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlPerformanceTierListResult.Serialization.cs index 44ee21e45548a..a66d52b0d65e2 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlPerformanceTierListResult.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlPerformanceTierListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.Models @@ -103,6 +106,85 @@ internal static MySqlPerformanceTierListResult DeserializeMySqlPerformanceTierLi return new MySqlPerformanceTierListResult(value ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -111,6 +193,8 @@ BinaryData IPersistableModel.Write(ModelReaderWr { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlPerformanceTierListResult)} does not support '{options.Format}' format."); } @@ -127,6 +211,8 @@ MySqlPerformanceTierListResult IPersistableModel using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlPerformanceTierListResult(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlPerformanceTierListResult)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlPerformanceTierServiceLevelObjectives.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlPerformanceTierServiceLevelObjectives.Serialization.cs index 0a796b3ffaf08..e3db9b16359ba 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlPerformanceTierServiceLevelObjectives.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlPerformanceTierServiceLevelObjectives.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.Models @@ -195,6 +197,199 @@ internal static MySqlPerformanceTierServiceLevelObjectives DeserializeMySqlPerfo serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Id.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Id}'''"); + } + else + { + builder.AppendLine($"'{Id}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Edition), out propertyOverride); + if (Optional.IsDefined(Edition) || hasPropertyOverride) + { + builder.Append(" edition: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Edition.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Edition}'''"); + } + else + { + builder.AppendLine($"'{Edition}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VCores), out propertyOverride); + if (Optional.IsDefined(VCores) || hasPropertyOverride) + { + builder.Append(" vCore: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{VCores.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HardwareGeneration), out propertyOverride); + if (Optional.IsDefined(HardwareGeneration) || hasPropertyOverride) + { + builder.Append(" hardwareGeneration: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (HardwareGeneration.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{HardwareGeneration}'''"); + } + else + { + builder.AppendLine($"'{HardwareGeneration}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaxBackupRetentionDays), out propertyOverride); + if (Optional.IsDefined(MaxBackupRetentionDays) || hasPropertyOverride) + { + builder.Append(" maxBackupRetentionDays: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{MaxBackupRetentionDays.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinBackupRetentionDays), out propertyOverride); + if (Optional.IsDefined(MinBackupRetentionDays) || hasPropertyOverride) + { + builder.Append(" minBackupRetentionDays: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{MinBackupRetentionDays.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaxStorageInMB), out propertyOverride); + if (Optional.IsDefined(MaxStorageInMB) || hasPropertyOverride) + { + builder.Append(" maxStorageMB: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{MaxStorageInMB.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinStorageInMB), out propertyOverride); + if (Optional.IsDefined(MinStorageInMB) || hasPropertyOverride) + { + builder.Append(" minStorageMB: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{MinStorageInMB.Value}"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -203,6 +398,8 @@ BinaryData IPersistableModel.Write(M { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlPerformanceTierServiceLevelObjectives)} does not support '{options.Format}' format."); } @@ -219,6 +416,8 @@ MySqlPerformanceTierServiceLevelObjectives IPersistableModel ID for the service level objective. + [WirePath("id")] public string Id { get; } /// Edition of the performance tier. + [WirePath("edition")] public string Edition { get; } /// vCore associated with the service level objective. + [WirePath("vCore")] public int? VCores { get; } /// Hardware generation associated with the service level objective. + [WirePath("hardwareGeneration")] public string HardwareGeneration { get; } /// Maximum Backup retention in days for the performance tier edition. + [WirePath("maxBackupRetentionDays")] public int? MaxBackupRetentionDays { get; } /// Minimum Backup retention in days for the performance tier edition. + [WirePath("minBackupRetentionDays")] public int? MinBackupRetentionDays { get; } /// Max storage allowed for a server. + [WirePath("maxStorageMB")] public int? MaxStorageInMB { get; } /// Max storage allowed for a server. + [WirePath("minStorageMB")] public int? MinStorageInMB { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlPrivateEndpointConnectionListResult.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlPrivateEndpointConnectionListResult.Serialization.cs index 0152b505c4f53..c757bfa0e39c3 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlPrivateEndpointConnectionListResult.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlPrivateEndpointConnectionListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.Models @@ -114,6 +117,107 @@ internal static MySqlPrivateEndpointConnectionListResult DeserializeMySqlPrivate return new MySqlPrivateEndpointConnectionListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +226,8 @@ BinaryData IPersistableModel.Write(Mod { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlPrivateEndpointConnectionListResult)} does not support '{options.Format}' format."); } @@ -138,6 +244,8 @@ MySqlPrivateEndpointConnectionListResult IPersistableModel tags, I } /// Resource tags. + [WirePath("tags")] public IDictionary Tags { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlPrivateLinkResourceListResult.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlPrivateLinkResourceListResult.Serialization.cs index dbde24979e6da..51ed4d93cbe70 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlPrivateLinkResourceListResult.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlPrivateLinkResourceListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.Models @@ -114,6 +117,107 @@ internal static MySqlPrivateLinkResourceListResult DeserializeMySqlPrivateLinkRe return new MySqlPrivateLinkResourceListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +226,8 @@ BinaryData IPersistableModel.Write(ModelRead { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlPrivateLinkResourceListResult)} does not support '{options.Format}' format."); } @@ -138,6 +244,8 @@ MySqlPrivateLinkResourceListResult IPersistableModel(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GroupId), out propertyOverride); + if (Optional.IsDefined(GroupId) || hasPropertyOverride) + { + builder.Append(" groupId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (GroupId.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{GroupId}'''"); + } + else + { + builder.AppendLine($"'{GroupId}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RequiredMembers), out propertyOverride); + if (Optional.IsCollectionDefined(RequiredMembers) || hasPropertyOverride) + { + if (RequiredMembers.Any() || hasPropertyOverride) + { + builder.Append(" requiredMembers: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in RequiredMembers) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +239,8 @@ BinaryData IPersistableModel.Write(ModelRead { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlPrivateLinkResourceProperties)} does not support '{options.Format}' format."); } @@ -138,6 +257,8 @@ MySqlPrivateLinkResourceProperties IPersistableModel The private link resource group id. + [WirePath("groupId")] public string GroupId { get; } /// The private link resource required member names. + [WirePath("requiredMembers")] public IReadOnlyList RequiredMembers { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlPrivateLinkServiceConnectionStateProperty.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlPrivateLinkServiceConnectionStateProperty.Serialization.cs index b2f47a578b41a..408ba89c7ade2 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlPrivateLinkServiceConnectionStateProperty.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlPrivateLinkServiceConnectionStateProperty.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.Models @@ -105,6 +107,129 @@ internal static MySqlPrivateLinkServiceConnectionStateProperty DeserializeMySqlP return new MySqlPrivateLinkServiceConnectionStateProperty(status, description, actionsRequired, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); + if (Optional.IsDefined(Status) || hasPropertyOverride) + { + builder.Append(" status: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Status.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Status}'''"); + } + else + { + builder.AppendLine($"'{Status}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); + if (Optional.IsDefined(Description) || hasPropertyOverride) + { + builder.Append(" description: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Description.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Description}'''"); + } + else + { + builder.AppendLine($"'{Description}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ActionsRequired), out propertyOverride); + if (Optional.IsDefined(ActionsRequired) || hasPropertyOverride) + { + builder.Append(" actionsRequired: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ActionsRequired.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ActionsRequired}'''"); + } + else + { + builder.AppendLine($"'{ActionsRequired}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -113,6 +238,8 @@ BinaryData IPersistableModel.Wri { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlPrivateLinkServiceConnectionStateProperty)} does not support '{options.Format}' format."); } @@ -129,6 +256,8 @@ MySqlPrivateLinkServiceConnectionStateProperty IPersistableModel The private link service connection status. + [WirePath("status")] public string Status { get; set; } /// The private link service connection description. + [WirePath("description")] public string Description { get; set; } /// The actions required for private link service connection. + [WirePath("actionsRequired")] public string ActionsRequired { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlQueryPerformanceInsightResetDataResult.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlQueryPerformanceInsightResetDataResult.Serialization.cs index 7440ca950ae05..c4044ec305c8b 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlQueryPerformanceInsightResetDataResult.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlQueryPerformanceInsightResetDataResult.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.Models @@ -104,6 +106,99 @@ internal static MySqlQueryPerformanceInsightResetDataResult DeserializeMySqlQuer return new MySqlQueryPerformanceInsightResetDataResult(status, message, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); + if (Optional.IsDefined(Status) || hasPropertyOverride) + { + builder.Append(" status: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Status.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Message), out propertyOverride); + if (Optional.IsDefined(Message) || hasPropertyOverride) + { + builder.Append(" message: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Message.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Message}'''"); + } + else + { + builder.AppendLine($"'{Message}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -112,6 +207,8 @@ BinaryData IPersistableModel.Write( { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlQueryPerformanceInsightResetDataResult)} does not support '{options.Format}' format."); } @@ -128,6 +225,8 @@ MySqlQueryPerformanceInsightResetDataResult IPersistableModel Indicates result of the operation. + [WirePath("status")] public MySqlQueryPerformanceInsightResetDataResultState? Status { get; } /// operation message. + [WirePath("message")] public string Message { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlQueryTextListResult.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlQueryTextListResult.Serialization.cs index 4b4d410273ee7..b9f40341df63d 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlQueryTextListResult.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlQueryTextListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.Models @@ -114,6 +117,107 @@ internal static MySqlQueryTextListResult DeserializeMySqlQueryTextListResult(Jso return new MySqlQueryTextListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +226,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOp { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlQueryTextListResult)} does not support '{options.Format}' format."); } @@ -138,6 +244,8 @@ MySqlQueryTextListResult IPersistableModel.Create(Bina using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlQueryTextListResult(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlQueryTextListResult)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlRecommendationActionListResult.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlRecommendationActionListResult.Serialization.cs index 35324c07530f8..a5fa1c3dba094 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlRecommendationActionListResult.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlRecommendationActionListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.Models @@ -114,6 +117,107 @@ internal static MySqlRecommendationActionListResult DeserializeMySqlRecommendati return new MySqlRecommendationActionListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +226,8 @@ BinaryData IPersistableModel.Write(ModelRea { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlRecommendationActionListResult)} does not support '{options.Format}' format."); } @@ -138,6 +244,8 @@ MySqlRecommendationActionListResult IPersistableModel propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastAvailableBackupOn), out propertyOverride); + if (Optional.IsDefined(LastAvailableBackupOn) || hasPropertyOverride) + { + builder.Append(" lastAvailableBackupDateTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(LastAvailableBackupOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServiceLevelObjective), out propertyOverride); + if (Optional.IsDefined(ServiceLevelObjective) || hasPropertyOverride) + { + builder.Append(" serviceLevelObjective: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ServiceLevelObjective.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ServiceLevelObjective}'''"); + } + else + { + builder.AppendLine($"'{ServiceLevelObjective}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Edition), out propertyOverride); + if (Optional.IsDefined(Edition) || hasPropertyOverride) + { + builder.Append(" edition: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Edition.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Edition}'''"); + } + else + { + builder.AppendLine($"'{Edition}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VCores), out propertyOverride); + if (Optional.IsDefined(VCores) || hasPropertyOverride) + { + builder.Append(" vCore: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{VCores.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HardwareGeneration), out propertyOverride); + if (Optional.IsDefined(HardwareGeneration) || hasPropertyOverride) + { + builder.Append(" hardwareGeneration: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (HardwareGeneration.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{HardwareGeneration}'''"); + } + else + { + builder.AppendLine($"'{HardwareGeneration}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Version), out propertyOverride); + if (Optional.IsDefined(Version) || hasPropertyOverride) + { + builder.Append(" version: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Version.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Version}'''"); + } + else + { + builder.AppendLine($"'{Version}'"); + } + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -235,6 +464,8 @@ BinaryData IPersistableModel.Write(ModelRead { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlRecoverableServerResourceData)} does not support '{options.Format}' format."); } @@ -251,6 +482,8 @@ MySqlRecoverableServerResourceData IPersistableModel The last available backup date time. + [WirePath("properties.lastAvailableBackupDateTime")] public DateTimeOffset? LastAvailableBackupOn { get; } /// The service level objective. + [WirePath("properties.serviceLevelObjective")] public string ServiceLevelObjective { get; } /// Edition of the performance tier. + [WirePath("properties.edition")] public string Edition { get; } /// vCore associated with the service level objective. + [WirePath("properties.vCore")] public int? VCores { get; } /// Hardware generation associated with the service level objective. + [WirePath("properties.hardwareGeneration")] public string HardwareGeneration { get; } /// The MySQL version. + [WirePath("properties.version")] public string Version { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerAdministratorListResult.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerAdministratorListResult.Serialization.cs index 23689247556bb..a36dedc802811 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerAdministratorListResult.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerAdministratorListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.Models @@ -103,6 +106,85 @@ internal static MySqlServerAdministratorListResult DeserializeMySqlServerAdminis return new MySqlServerAdministratorListResult(value ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -111,6 +193,8 @@ BinaryData IPersistableModel.Write(ModelRead { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlServerAdministratorListResult)} does not support '{options.Format}' format."); } @@ -127,6 +211,8 @@ MySqlServerAdministratorListResult IPersistableModel The Azure Active Directory identity of the server. Current supported identity types: SystemAssigned. + [WirePath("identity")] public ManagedServiceIdentity Identity { get; set; } /// The SKU (pricing tier) of the server. + [WirePath("sku")] public MySqlSku Sku { get; set; } /// /// Properties of the server. /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. /// The available derived classes include , , and . /// + [WirePath("properties")] public MySqlServerPropertiesForCreate Properties { get; } /// The location the resource resides in. + [WirePath("location")] public AzureLocation Location { get; } /// Application-specific metadata in the form of key-value pairs. + [WirePath("tags")] public IDictionary Tags { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerKeyListResult.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerKeyListResult.Serialization.cs index bbd0034e5058c..11c5c8ff8dad7 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerKeyListResult.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerKeyListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.Models @@ -114,6 +117,107 @@ internal static MySqlServerKeyListResult DeserializeMySqlServerKeyListResult(Jso return new MySqlServerKeyListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +226,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOp { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlServerKeyListResult)} does not support '{options.Format}' format."); } @@ -138,6 +244,8 @@ MySqlServerKeyListResult IPersistableModel.Create(Bina using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlServerKeyListResult(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlServerKeyListResult)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerListResult.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerListResult.Serialization.cs index f556af92f4e18..4bc76aae29664 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerListResult.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.Models @@ -103,6 +106,85 @@ internal static MySqlServerListResult DeserializeMySqlServerListResult(JsonEleme return new MySqlServerListResult(value ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -111,6 +193,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlServerListResult)} does not support '{options.Format}' format."); } @@ -127,6 +211,8 @@ MySqlServerListResult IPersistableModel.Create(BinaryData using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlServerListResult(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlServerListResult)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPatch.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPatch.cs index c1da7ea5ae87a..a707d6cbca7ce 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPatch.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPatch.cs @@ -81,24 +81,34 @@ internal MySqlServerPatch(ManagedServiceIdentity identity, MySqlSku sku, IDictio } /// The Azure Active Directory identity of the server. Current supported identity types: SystemAssigned. + [WirePath("identity")] public ManagedServiceIdentity Identity { get; set; } /// The SKU (pricing tier) of the server. + [WirePath("sku")] public MySqlSku Sku { get; set; } /// Application-specific metadata in the form of key-value pairs. + [WirePath("tags")] public IDictionary Tags { get; } /// Storage profile of a server. + [WirePath("properties.storageProfile")] public MySqlStorageProfile StorageProfile { get; set; } /// The password of the administrator login. + [WirePath("properties.administratorLoginPassword")] public string AdministratorLoginPassword { get; set; } /// The version of a server. + [WirePath("properties.version")] public MySqlServerVersion? Version { get; set; } /// Enable ssl enforcement or not when connect to server. + [WirePath("properties.sslEnforcement")] public MySqlSslEnforcementEnum? SslEnforcement { get; set; } /// Enforce a minimal Tls version for the server. + [WirePath("properties.minimalTlsVersion")] public MySqlMinimalTlsVersionEnum? MinimalTlsVersion { get; set; } /// Whether or not public network access is allowed for this server. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. + [WirePath("properties.publicNetworkAccess")] public MySqlPublicNetworkAccessEnum? PublicNetworkAccess { get; set; } /// The replication role of the server. + [WirePath("properties.replicationRole")] public string ReplicationRole { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPrivateEndpointConnection.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPrivateEndpointConnection.Serialization.cs index 174357fd89ba2..9f9fb007e921b 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPrivateEndpointConnection.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPrivateEndpointConnection.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.Models @@ -108,6 +110,91 @@ internal static MySqlServerPrivateEndpointConnection DeserializeMySqlServerPriva return new MySqlServerPrivateEndpointConnection(id, properties, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); + if (Optional.IsDefined(Properties) || hasPropertyOverride) + { + builder.Append(" properties: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Properties, options, 2, false, " properties: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -116,6 +203,8 @@ BinaryData IPersistableModel.Write(ModelRe { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlServerPrivateEndpointConnection)} does not support '{options.Format}' format."); } @@ -132,6 +221,8 @@ MySqlServerPrivateEndpointConnection IPersistableModel Resource Id of the private endpoint connection. + [WirePath("id")] public ResourceIdentifier Id { get; } /// Private endpoint connection properties. + [WirePath("properties")] public MySqlServerPrivateEndpointConnectionProperties Properties { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPrivateEndpointConnectionProperties.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPrivateEndpointConnectionProperties.Serialization.cs index dfbef117f0e16..047861466eadd 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPrivateEndpointConnectionProperties.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPrivateEndpointConnectionProperties.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; using Azure.ResourceManager.Resources.Models; @@ -124,6 +126,105 @@ internal static MySqlServerPrivateEndpointConnectionProperties DeserializeMySqlS return new MySqlServerPrivateEndpointConnectionProperties(privateEndpoint, privateLinkServiceConnectionState, provisioningState, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateEndpoint), out propertyOverride); + if (Optional.IsDefined(PrivateEndpoint) || hasPropertyOverride) + { + builder.Append(" privateEndpoint: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, PrivateEndpoint, options, 2, false, " privateEndpoint: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateLinkServiceConnectionState), out propertyOverride); + if (Optional.IsDefined(PrivateLinkServiceConnectionState) || hasPropertyOverride) + { + builder.Append(" privateLinkServiceConnectionState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, PrivateLinkServiceConnectionState, options, 2, false, " privateLinkServiceConnectionState: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); + if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) + { + builder.Append(" provisioningState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -132,6 +233,8 @@ BinaryData IPersistableModel.Wri { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlServerPrivateEndpointConnectionProperties)} does not support '{options.Format}' format."); } @@ -148,6 +251,8 @@ MySqlServerPrivateEndpointConnectionProperties IPersistableModel Private endpoint which the connection belongs to. internal WritableSubResource PrivateEndpoint { get; } /// Gets or sets Id. + [WirePath("privateEndpoint.id")] public ResourceIdentifier PrivateEndpointId { get => PrivateEndpoint?.Id; } /// Connection state of the private endpoint connection. + [WirePath("privateLinkServiceConnectionState")] public MySqlServerPrivateLinkServiceConnectionStateProperty PrivateLinkServiceConnectionState { get; } /// State of the private endpoint connection. + [WirePath("provisioningState")] public MySqlPrivateEndpointProvisioningState? ProvisioningState { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPrivateLinkServiceConnectionStateProperty.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPrivateLinkServiceConnectionStateProperty.Serialization.cs index 1911caaf33d1c..cc2f843585e60 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPrivateLinkServiceConnectionStateProperty.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPrivateLinkServiceConnectionStateProperty.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.Models @@ -109,6 +111,110 @@ internal static MySqlServerPrivateLinkServiceConnectionStateProperty Deserialize return new MySqlServerPrivateLinkServiceConnectionStateProperty(status, description, actionsRequired, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); + builder.Append(" status: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Status.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); + if (Optional.IsDefined(Description) || hasPropertyOverride) + { + builder.Append(" description: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Description.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Description}'''"); + } + else + { + builder.AppendLine($"'{Description}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ActionsRequired), out propertyOverride); + if (Optional.IsDefined(ActionsRequired) || hasPropertyOverride) + { + builder.Append(" actionsRequired: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ActionsRequired.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -117,6 +223,8 @@ BinaryData IPersistableModel The private link service connection status. + [WirePath("status")] public MySqlPrivateLinkServiceConnectionStateStatus Status { get; } /// The private link service connection description. + [WirePath("description")] public string Description { get; } /// The actions required for private link service connection. + [WirePath("actionsRequired")] public MySqlPrivateLinkServiceConnectionStateRequiredAction? ActionsRequired { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPropertiesForCreate.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPropertiesForCreate.cs index 84fbb9e22a83a..9f0c62d795629 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPropertiesForCreate.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPropertiesForCreate.cs @@ -76,16 +76,22 @@ internal MySqlServerPropertiesForCreate(MySqlServerVersion? version, MySqlSslEnf } /// Server version. + [WirePath("version")] public MySqlServerVersion? Version { get; set; } /// Enable ssl enforcement or not when connect to server. + [WirePath("sslEnforcement")] public MySqlSslEnforcementEnum? SslEnforcement { get; set; } /// Enforce a minimal Tls version for the server. + [WirePath("minimalTlsVersion")] public MySqlMinimalTlsVersionEnum? MinimalTlsVersion { get; set; } /// Status showing whether the server enabled infrastructure encryption. + [WirePath("infrastructureEncryption")] public MySqlInfrastructureEncryption? InfrastructureEncryption { get; set; } /// Whether or not public network access is allowed for this server. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. + [WirePath("publicNetworkAccess")] public MySqlPublicNetworkAccessEnum? PublicNetworkAccess { get; set; } /// Storage profile of a server. + [WirePath("storageProfile")] public MySqlStorageProfile StorageProfile { get; set; } /// The mode to create a new server. internal MySqlCreateMode CreateMode { get; set; } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPropertiesForDefaultCreate.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPropertiesForDefaultCreate.cs index bba81b128ace3..205b0d7acbb36 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPropertiesForDefaultCreate.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPropertiesForDefaultCreate.cs @@ -52,8 +52,10 @@ internal MySqlServerPropertiesForDefaultCreate() } /// The administrator's login name of a server. Can only be specified when the server is being created (and is required for creation). The login name is required when updating password. + [WirePath("administratorLogin")] public string AdministratorLogin { get; } /// The password of the administrator login. + [WirePath("administratorLoginPassword")] public string AdministratorLoginPassword { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPropertiesForGeoRestore.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPropertiesForGeoRestore.cs index 3f53d919d3d8c..9abe14821b2b8 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPropertiesForGeoRestore.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPropertiesForGeoRestore.cs @@ -48,6 +48,7 @@ internal MySqlServerPropertiesForGeoRestore() } /// The source server id to restore from. + [WirePath("sourceServerId")] public ResourceIdentifier SourceServerId { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPropertiesForReplica.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPropertiesForReplica.cs index 14a71d3e993b7..7d31413dbacd1 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPropertiesForReplica.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPropertiesForReplica.cs @@ -48,6 +48,7 @@ internal MySqlServerPropertiesForReplica() } /// The master server id to create replica from. + [WirePath("sourceServerId")] public ResourceIdentifier SourceServerId { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPropertiesForRestore.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPropertiesForRestore.cs index 866505e83fda9..f58cb43069591 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPropertiesForRestore.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerPropertiesForRestore.cs @@ -52,8 +52,10 @@ internal MySqlServerPropertiesForRestore() } /// The source server id to restore from. + [WirePath("sourceServerId")] public ResourceIdentifier SourceServerId { get; } /// Restore point creation time (ISO8601 format), specifying the time to restore from. + [WirePath("restorePointInTime")] public DateTimeOffset RestorePointInTime { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerSecurityAlertPolicyListResult.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerSecurityAlertPolicyListResult.Serialization.cs index 375950feba684..df09fecbb6a25 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerSecurityAlertPolicyListResult.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlServerSecurityAlertPolicyListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.Models @@ -114,6 +117,107 @@ internal static MySqlServerSecurityAlertPolicyListResult DeserializeMySqlServerS return new MySqlServerSecurityAlertPolicyListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +226,8 @@ BinaryData IPersistableModel.Write(Mod { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlServerSecurityAlertPolicyListResult)} does not support '{options.Format}' format."); } @@ -138,6 +244,8 @@ MySqlServerSecurityAlertPolicyListResult IPersistableModel Represents an server storage profile. + [WirePath("properties.targetServerVersion")] public string TargetServerVersion { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlSku.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlSku.Serialization.cs index 0a85e7b9c1c5f..c3a060c6d6bd0 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlSku.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlSku.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.Models @@ -144,6 +146,157 @@ internal static MySqlSku DeserializeMySqlSku(JsonElement element, ModelReaderWri serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tier), out propertyOverride); + if (Optional.IsDefined(Tier) || hasPropertyOverride) + { + builder.Append(" tier: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Tier.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Capacity), out propertyOverride); + if (Optional.IsDefined(Capacity) || hasPropertyOverride) + { + builder.Append(" capacity: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{Capacity.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Size), out propertyOverride); + if (Optional.IsDefined(Size) || hasPropertyOverride) + { + builder.Append(" size: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Size.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Size}'''"); + } + else + { + builder.AppendLine($"'{Size}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Family), out propertyOverride); + if (Optional.IsDefined(Family) || hasPropertyOverride) + { + builder.Append(" family: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Family.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Family}'''"); + } + else + { + builder.AppendLine($"'{Family}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -152,6 +305,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlSku)} does not support '{options.Format}' format."); } @@ -168,6 +323,8 @@ MySqlSku IPersistableModel.Create(BinaryData data, ModelReaderWriterOp using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlSku(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlSku)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlSku.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlSku.cs index 3505067ab16c7..4e28cde6a1175 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlSku.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlSku.cs @@ -79,14 +79,19 @@ internal MySqlSku() } /// The name of the sku, typically, tier + family + cores, e.g. B_Gen4_1, GP_Gen5_8. + [WirePath("name")] public string Name { get; set; } /// The tier of the particular SKU, e.g. Basic. + [WirePath("tier")] public MySqlSkuTier? Tier { get; set; } /// The scale up/out capacity, representing server's compute units. + [WirePath("capacity")] public int? Capacity { get; set; } /// The size code, to be interpreted by resource as appropriate. + [WirePath("size")] public string Size { get; set; } /// The family of hardware. + [WirePath("family")] public string Family { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlStorageProfile.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlStorageProfile.Serialization.cs index b1d6a5ed4adea..3fb89c39465f1 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlStorageProfile.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlStorageProfile.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.Models @@ -138,6 +140,119 @@ internal static MySqlStorageProfile DeserializeMySqlStorageProfile(JsonElement e return new MySqlStorageProfile(backupRetentionDays, geoRedundantBackup, storageMB, storageAutogrow, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BackupRetentionDays), out propertyOverride); + if (Optional.IsDefined(BackupRetentionDays) || hasPropertyOverride) + { + builder.Append(" backupRetentionDays: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{BackupRetentionDays.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GeoRedundantBackup), out propertyOverride); + if (Optional.IsDefined(GeoRedundantBackup) || hasPropertyOverride) + { + builder.Append(" geoRedundantBackup: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{GeoRedundantBackup.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageInMB), out propertyOverride); + if (Optional.IsDefined(StorageInMB) || hasPropertyOverride) + { + builder.Append(" storageMB: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{StorageInMB.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageAutogrow), out propertyOverride); + if (Optional.IsDefined(StorageAutogrow) || hasPropertyOverride) + { + builder.Append(" storageAutogrow: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{StorageAutogrow.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -146,6 +261,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlStorageProfile)} does not support '{options.Format}' format."); } @@ -162,6 +279,8 @@ MySqlStorageProfile IPersistableModel.Create(BinaryData dat using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlStorageProfile(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlStorageProfile)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlStorageProfile.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlStorageProfile.cs index aa6dbd0e5389a..21e3ced211e79 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlStorageProfile.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlStorageProfile.cs @@ -66,12 +66,16 @@ internal MySqlStorageProfile(int? backupRetentionDays, MySqlGeoRedundantBackup? } /// Backup retention days for the server. + [WirePath("backupRetentionDays")] public int? BackupRetentionDays { get; set; } /// Enable Geo-redundant or not for server backup. + [WirePath("geoRedundantBackup")] public MySqlGeoRedundantBackup? GeoRedundantBackup { get; set; } /// Max storage allowed for a server. + [WirePath("storageMB")] public int? StorageInMB { get; set; } /// Enable Storage Auto Grow. + [WirePath("storageAutogrow")] public MySqlStorageAutogrow? StorageAutogrow { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlTopQueryStatisticsInput.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlTopQueryStatisticsInput.cs index fc5fce6ce3969..80419cff33c13 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlTopQueryStatisticsInput.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlTopQueryStatisticsInput.cs @@ -93,16 +93,22 @@ internal MySqlTopQueryStatisticsInput() } /// Max number of top queries to return. + [WirePath("properties.numberOfTopQueries")] public int NumberOfTopQueries { get; } /// Aggregation function name. + [WirePath("properties.aggregationFunction")] public string AggregationFunction { get; } /// Observed metric name. + [WirePath("properties.observedMetric")] public string ObservedMetric { get; } /// Observation start time. + [WirePath("properties.observationStartTime")] public DateTimeOffset ObservationStartOn { get; } /// Observation end time. + [WirePath("properties.observationEndTime")] public DateTimeOffset ObservationEndOn { get; } /// Aggregation interval type in ISO 8601 format. + [WirePath("properties.aggregationWindow")] public string AggregationWindow { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlTopQueryStatisticsListResult.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlTopQueryStatisticsListResult.Serialization.cs index 0df962fb8c418..291c2046c0997 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlTopQueryStatisticsListResult.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlTopQueryStatisticsListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.Models @@ -114,6 +117,107 @@ internal static MySqlTopQueryStatisticsListResult DeserializeMySqlTopQueryStatis return new MySqlTopQueryStatisticsListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +226,8 @@ BinaryData IPersistableModel.Write(ModelReade { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlTopQueryStatisticsListResult)} does not support '{options.Format}' format."); } @@ -138,6 +244,8 @@ MySqlTopQueryStatisticsListResult IPersistableModel(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +226,8 @@ BinaryData IPersistableModel.Write(ModelReade { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlVirtualNetworkRuleListResult)} does not support '{options.Format}' format."); } @@ -138,6 +244,8 @@ MySqlVirtualNetworkRuleListResult IPersistableModel Observation start time. + [WirePath("properties.observationStartTime")] public DateTimeOffset ObservationStartOn { get; } /// Observation end time. + [WirePath("properties.observationEndTime")] public DateTimeOffset ObservationEndOn { get; } /// Aggregation interval type in ISO 8601 format. + [WirePath("properties.aggregationWindow")] public string AggregationWindow { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlWaitStatisticsListResult.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlWaitStatisticsListResult.Serialization.cs index 8e257ad3a8d90..8c93ac059c7ab 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlWaitStatisticsListResult.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/Models/MySqlWaitStatisticsListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.Models @@ -114,6 +117,107 @@ internal static MySqlWaitStatisticsListResult DeserializeMySqlWaitStatisticsList return new MySqlWaitStatisticsListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +226,8 @@ BinaryData IPersistableModel.Write(ModelReaderWri { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlWaitStatisticsListResult)} does not support '{options.Format}' format."); } @@ -138,6 +244,8 @@ MySqlWaitStatisticsListResult IPersistableModel.C using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlWaitStatisticsListResult(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlWaitStatisticsListResult)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlAdvisorData.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlAdvisorData.Serialization.cs index 4c49fb2053960..0e6cc73523fc8 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlAdvisorData.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlAdvisorData.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.MySql @@ -154,6 +156,127 @@ internal static MySqlAdvisorData DeserializeMySqlAdvisorData(JsonElement element serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); + if (Optional.IsDefined(Properties) || hasPropertyOverride) + { + builder.Append(" properties: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Properties.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -162,6 +285,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions op { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlAdvisorData)} does not support '{options.Format}' format."); } @@ -178,6 +303,8 @@ MySqlAdvisorData IPersistableModel.Create(BinaryData data, Mod using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlAdvisorData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlAdvisorData)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlAdvisorData.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlAdvisorData.cs index 707f114152de9..edb1f7ad74c0c 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlAdvisorData.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlAdvisorData.cs @@ -98,6 +98,7 @@ internal MySqlAdvisorData(ResourceIdentifier id, string name, ResourceType resou /// /// /// + [WirePath("properties")] public BinaryData Properties { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlConfigurationData.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlConfigurationData.Serialization.cs index d14703666f975..518e7c5c9ac05 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlConfigurationData.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlConfigurationData.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.MySql @@ -218,6 +220,248 @@ internal static MySqlConfigurationData DeserializeMySqlConfigurationData(JsonEle serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsDefined(Value) || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Value}'''"); + } + else + { + builder.AppendLine($"'{Value}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); + if (Optional.IsDefined(Description) || hasPropertyOverride) + { + builder.Append(" description: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Description.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Description}'''"); + } + else + { + builder.AppendLine($"'{Description}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultValue), out propertyOverride); + if (Optional.IsDefined(DefaultValue) || hasPropertyOverride) + { + builder.Append(" defaultValue: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (DefaultValue.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{DefaultValue}'''"); + } + else + { + builder.AppendLine($"'{DefaultValue}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DataType), out propertyOverride); + if (Optional.IsDefined(DataType) || hasPropertyOverride) + { + builder.Append(" dataType: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (DataType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{DataType}'''"); + } + else + { + builder.AppendLine($"'{DataType}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowedValues), out propertyOverride); + if (Optional.IsDefined(AllowedValues) || hasPropertyOverride) + { + builder.Append(" allowedValues: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (AllowedValues.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{AllowedValues}'''"); + } + else + { + builder.AppendLine($"'{AllowedValues}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Source), out propertyOverride); + if (Optional.IsDefined(Source) || hasPropertyOverride) + { + builder.Append(" source: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Source.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Source}'''"); + } + else + { + builder.AppendLine($"'{Source}'"); + } + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -226,6 +470,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlConfigurationData)} does not support '{options.Format}' format."); } @@ -242,6 +488,8 @@ MySqlConfigurationData IPersistableModel.Create(BinaryDa using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlConfigurationData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlConfigurationData)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlConfigurationData.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlConfigurationData.cs index d86ccbd6b5e77..4f4f06351ee02 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlConfigurationData.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlConfigurationData.cs @@ -79,16 +79,22 @@ internal MySqlConfigurationData(ResourceIdentifier id, string name, ResourceType } /// Value of the configuration. + [WirePath("properties.value")] public string Value { get; set; } /// Description of the configuration. + [WirePath("properties.description")] public string Description { get; } /// Default value of the configuration. + [WirePath("properties.defaultValue")] public string DefaultValue { get; } /// Data type of the configuration. + [WirePath("properties.dataType")] public string DataType { get; } /// Allowed values of the configuration. + [WirePath("properties.allowedValues")] public string AllowedValues { get; } /// Source of the configuration. + [WirePath("properties.source")] public string Source { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlDatabaseData.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlDatabaseData.Serialization.cs index dd5c5cccad714..5399ab655db45 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlDatabaseData.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlDatabaseData.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.MySql @@ -170,6 +172,160 @@ internal static MySqlDatabaseData DeserializeMySqlDatabaseData(JsonElement eleme serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Charset), out propertyOverride); + if (Optional.IsDefined(Charset) || hasPropertyOverride) + { + builder.Append(" charset: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Charset.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Charset}'''"); + } + else + { + builder.AppendLine($"'{Charset}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Collation), out propertyOverride); + if (Optional.IsDefined(Collation) || hasPropertyOverride) + { + builder.Append(" collation: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Collation.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Collation}'''"); + } + else + { + builder.AppendLine($"'{Collation}'"); + } + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -178,6 +334,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions o { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlDatabaseData)} does not support '{options.Format}' format."); } @@ -194,6 +352,8 @@ MySqlDatabaseData IPersistableModel.Create(BinaryData data, M using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlDatabaseData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlDatabaseData)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlDatabaseData.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlDatabaseData.cs index 6fe6540f887d2..6746252ee39f9 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlDatabaseData.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlDatabaseData.cs @@ -71,8 +71,10 @@ internal MySqlDatabaseData(ResourceIdentifier id, string name, ResourceType reso } /// The charset of the database. + [WirePath("properties.charset")] public string Charset { get; set; } /// The collation of the database. + [WirePath("properties.collation")] public string Collation { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlFirewallRuleData.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlFirewallRuleData.Serialization.cs index 4458d561eae05..5c4874c28d192 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlFirewallRuleData.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlFirewallRuleData.Serialization.cs @@ -9,8 +9,10 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Net; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.MySql @@ -165,6 +167,144 @@ internal static MySqlFirewallRuleData DeserializeMySqlFirewallRuleData(JsonEleme serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartIPAddress), out propertyOverride); + if (Optional.IsDefined(StartIPAddress) || hasPropertyOverride) + { + builder.Append(" startIpAddress: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{StartIPAddress.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndIPAddress), out propertyOverride); + if (Optional.IsDefined(EndIPAddress) || hasPropertyOverride) + { + builder.Append(" endIpAddress: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{EndIPAddress.ToString()}'"); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -173,6 +313,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFirewallRuleData)} does not support '{options.Format}' format."); } @@ -189,6 +331,8 @@ MySqlFirewallRuleData IPersistableModel.Create(BinaryData using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlFirewallRuleData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlFirewallRuleData)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlFirewallRuleData.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlFirewallRuleData.cs index b9da228cb4f33..de0289d7e4e34 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlFirewallRuleData.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlFirewallRuleData.cs @@ -85,8 +85,10 @@ internal MySqlFirewallRuleData() } /// The start IP address of the server firewall rule. Must be IPv4 format. + [WirePath("properties.startIpAddress")] public IPAddress StartIPAddress { get; set; } /// The end IP address of the server firewall rule. Must be IPv4 format. + [WirePath("properties.endIpAddress")] public IPAddress EndIPAddress { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlPrivateEndpointConnectionData.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlPrivateEndpointConnectionData.Serialization.cs index cd254dc4bf985..56f63b723e771 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlPrivateEndpointConnectionData.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlPrivateEndpointConnectionData.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; using Azure.ResourceManager.MySql.Models; using Azure.ResourceManager.Resources.Models; @@ -192,6 +194,166 @@ internal static MySqlPrivateEndpointConnectionData DeserializeMySqlPrivateEndpoi serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateEndpoint), out propertyOverride); + if (Optional.IsDefined(PrivateEndpoint) || hasPropertyOverride) + { + builder.Append(" privateEndpoint: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, PrivateEndpoint, options, 4, false, " privateEndpoint: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConnectionState), out propertyOverride); + if (Optional.IsDefined(ConnectionState) || hasPropertyOverride) + { + builder.Append(" privateLinkServiceConnectionState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, ConnectionState, options, 4, false, " privateLinkServiceConnectionState: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); + if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) + { + builder.Append(" provisioningState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ProvisioningState.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ProvisioningState}'''"); + } + else + { + builder.AppendLine($"'{ProvisioningState}'"); + } + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -200,6 +362,8 @@ BinaryData IPersistableModel.Write(ModelRead { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlPrivateEndpointConnectionData)} does not support '{options.Format}' format."); } @@ -216,6 +380,8 @@ MySqlPrivateEndpointConnectionData IPersistableModel Private endpoint which the connection belongs to. internal WritableSubResource PrivateEndpoint { get; set; } /// Gets or sets Id. + [WirePath("properties.privateEndpoint.id")] public ResourceIdentifier PrivateEndpointId { get => PrivateEndpoint is null ? default : PrivateEndpoint.Id; @@ -89,8 +90,10 @@ public ResourceIdentifier PrivateEndpointId } /// Connection state of the private endpoint connection. + [WirePath("properties.privateLinkServiceConnectionState")] public MySqlPrivateLinkServiceConnectionStateProperty ConnectionState { get; set; } /// State of the private endpoint connection. + [WirePath("properties.provisioningState")] public string ProvisioningState { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlPrivateLinkResourceData.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlPrivateLinkResourceData.Serialization.cs index f0600c853b908..6bfbfe8b7cd6d 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlPrivateLinkResourceData.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlPrivateLinkResourceData.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; using Azure.ResourceManager.MySql.Models; @@ -148,6 +150,127 @@ internal static MySqlPrivateLinkResourceData DeserializeMySqlPrivateLinkResource serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); + if (Optional.IsDefined(Properties) || hasPropertyOverride) + { + builder.Append(" properties: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Properties, options, 2, false, " properties: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -156,6 +279,8 @@ BinaryData IPersistableModel.Write(ModelReaderWrit { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlPrivateLinkResourceData)} does not support '{options.Format}' format."); } @@ -172,6 +297,8 @@ MySqlPrivateLinkResourceData IPersistableModel.Cre using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlPrivateLinkResourceData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlPrivateLinkResourceData)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlPrivateLinkResourceData.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlPrivateLinkResourceData.cs index 2b097f983288a..9bce7660f1ee4 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlPrivateLinkResourceData.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlPrivateLinkResourceData.cs @@ -70,6 +70,7 @@ internal MySqlPrivateLinkResourceData(ResourceIdentifier id, string name, Resour } /// The private link resource group id. + [WirePath("properties")] public MySqlPrivateLinkResourceProperties Properties { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlQueryStatisticData.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlQueryStatisticData.Serialization.cs index 6b5cf54c6d869..da2576e6c9f67 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlQueryStatisticData.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlQueryStatisticData.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.MySql @@ -296,6 +299,319 @@ internal static MySqlQueryStatisticData DeserializeMySqlQueryStatisticData(JsonE serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(QueryId), out propertyOverride); + if (Optional.IsDefined(QueryId) || hasPropertyOverride) + { + builder.Append(" queryId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (QueryId.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{QueryId}'''"); + } + else + { + builder.AppendLine($"'{QueryId}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); + if (Optional.IsDefined(StartOn) || hasPropertyOverride) + { + builder.Append(" startTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndOn), out propertyOverride); + if (Optional.IsDefined(EndOn) || hasPropertyOverride) + { + builder.Append(" endTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(EndOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AggregationFunction), out propertyOverride); + if (Optional.IsDefined(AggregationFunction) || hasPropertyOverride) + { + builder.Append(" aggregationFunction: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (AggregationFunction.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{AggregationFunction}'''"); + } + else + { + builder.AppendLine($"'{AggregationFunction}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DatabaseNames), out propertyOverride); + if (Optional.IsCollectionDefined(DatabaseNames) || hasPropertyOverride) + { + if (DatabaseNames.Any() || hasPropertyOverride) + { + builder.Append(" databaseNames: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in DatabaseNames) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(QueryExecutionCount), out propertyOverride); + if (Optional.IsDefined(QueryExecutionCount) || hasPropertyOverride) + { + builder.Append(" queryExecutionCount: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{QueryExecutionCount.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MetricName), out propertyOverride); + if (Optional.IsDefined(MetricName) || hasPropertyOverride) + { + builder.Append(" metricName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (MetricName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{MetricName}'''"); + } + else + { + builder.AppendLine($"'{MetricName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MetricDisplayName), out propertyOverride); + if (Optional.IsDefined(MetricDisplayName) || hasPropertyOverride) + { + builder.Append(" metricDisplayName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (MetricDisplayName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{MetricDisplayName}'''"); + } + else + { + builder.AppendLine($"'{MetricDisplayName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MetricValue), out propertyOverride); + if (Optional.IsDefined(MetricValue) || hasPropertyOverride) + { + builder.Append(" metricValue: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{MetricValue.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MetricValueUnit), out propertyOverride); + if (Optional.IsDefined(MetricValueUnit) || hasPropertyOverride) + { + builder.Append(" metricValueUnit: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (MetricValueUnit.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{MetricValueUnit}'''"); + } + else + { + builder.AppendLine($"'{MetricValueUnit}'"); + } + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -304,6 +620,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpt { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlQueryStatisticData)} does not support '{options.Format}' format."); } @@ -320,6 +638,8 @@ MySqlQueryStatisticData IPersistableModel.Create(Binary using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlQueryStatisticData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlQueryStatisticData)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlQueryStatisticData.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlQueryStatisticData.cs index 896a2982b954d..b02cc2581918d 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlQueryStatisticData.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlQueryStatisticData.cs @@ -88,24 +88,34 @@ internal MySqlQueryStatisticData(ResourceIdentifier id, string name, ResourceTyp } /// Database query identifier. + [WirePath("properties.queryId")] public string QueryId { get; set; } /// Observation start time. + [WirePath("properties.startTime")] public DateTimeOffset? StartOn { get; set; } /// Observation end time. + [WirePath("properties.endTime")] public DateTimeOffset? EndOn { get; set; } /// Aggregation function name. + [WirePath("properties.aggregationFunction")] public string AggregationFunction { get; set; } /// The list of database names. + [WirePath("properties.databaseNames")] public IList DatabaseNames { get; } /// Number of query executions in this time interval. + [WirePath("properties.queryExecutionCount")] public long? QueryExecutionCount { get; set; } /// Metric name. + [WirePath("properties.metricName")] public string MetricName { get; set; } /// Metric display name. + [WirePath("properties.metricDisplayName")] public string MetricDisplayName { get; set; } /// Metric value. + [WirePath("properties.metricValue")] public double? MetricValue { get; set; } /// Metric value unit. + [WirePath("properties.metricValueUnit")] public string MetricValueUnit { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlQueryTextData.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlQueryTextData.Serialization.cs index 29aae27e2cbe2..124fb4d2e93dc 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlQueryTextData.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlQueryTextData.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.MySql @@ -170,6 +172,160 @@ internal static MySqlQueryTextData DeserializeMySqlQueryTextData(JsonElement ele serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(QueryId), out propertyOverride); + if (Optional.IsDefined(QueryId) || hasPropertyOverride) + { + builder.Append(" queryId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (QueryId.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{QueryId}'''"); + } + else + { + builder.AppendLine($"'{QueryId}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(QueryText), out propertyOverride); + if (Optional.IsDefined(QueryText) || hasPropertyOverride) + { + builder.Append(" queryText: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (QueryText.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{QueryText}'''"); + } + else + { + builder.AppendLine($"'{QueryText}'"); + } + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -178,6 +334,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlQueryTextData)} does not support '{options.Format}' format."); } @@ -194,6 +352,8 @@ MySqlQueryTextData IPersistableModel.Create(BinaryData data, using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlQueryTextData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlQueryTextData)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlQueryTextData.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlQueryTextData.cs index b4543723b1407..343b6becf6060 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlQueryTextData.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlQueryTextData.cs @@ -71,8 +71,10 @@ internal MySqlQueryTextData(ResourceIdentifier id, string name, ResourceType res } /// Query identifier unique to the server. + [WirePath("properties.queryId")] public string QueryId { get; set; } /// Query text. + [WirePath("properties.queryText")] public string QueryText { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlRecommendationActionData.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlRecommendationActionData.Serialization.cs index d6da55cb548c5..1e18aa88b5fc6 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlRecommendationActionData.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlRecommendationActionData.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.MySql @@ -273,6 +276,276 @@ internal static MySqlRecommendationActionData DeserializeMySqlRecommendationActi serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AdvisorName), out propertyOverride); + if (Optional.IsDefined(AdvisorName) || hasPropertyOverride) + { + builder.Append(" advisorName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (AdvisorName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{AdvisorName}'''"); + } + else + { + builder.AppendLine($"'{AdvisorName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SessionId), out propertyOverride); + if (Optional.IsDefined(SessionId) || hasPropertyOverride) + { + builder.Append(" sessionId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SessionId.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ActionId), out propertyOverride); + if (Optional.IsDefined(ActionId) || hasPropertyOverride) + { + builder.Append(" actionId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{ActionId.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); + if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) + { + builder.Append(" createdTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ExpireOn), out propertyOverride); + if (Optional.IsDefined(ExpireOn) || hasPropertyOverride) + { + builder.Append(" expirationTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(ExpireOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); + if (Optional.IsDefined(Reason) || hasPropertyOverride) + { + builder.Append(" reason: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Reason.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Reason}'''"); + } + else + { + builder.AppendLine($"'{Reason}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RecommendationType), out propertyOverride); + if (Optional.IsDefined(RecommendationType) || hasPropertyOverride) + { + builder.Append(" recommendationType: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (RecommendationType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{RecommendationType}'''"); + } + else + { + builder.AppendLine($"'{RecommendationType}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Details), out propertyOverride); + if (Optional.IsCollectionDefined(Details) || hasPropertyOverride) + { + if (Details.Any() || hasPropertyOverride) + { + builder.Append(" details: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in Details) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -281,6 +554,8 @@ BinaryData IPersistableModel.Write(ModelReaderWri { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlRecommendationActionData)} does not support '{options.Format}' format."); } @@ -297,6 +572,8 @@ MySqlRecommendationActionData IPersistableModel.C using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlRecommendationActionData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlRecommendationActionData)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlRecommendationActionData.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlRecommendationActionData.cs index fce95cc4759e1..1a0e04c00ee80 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlRecommendationActionData.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlRecommendationActionData.cs @@ -84,20 +84,28 @@ internal MySqlRecommendationActionData(ResourceIdentifier id, string name, Resou } /// Advisor name. + [WirePath("properties.advisorName")] public string AdvisorName { get; set; } /// Recommendation action session identifier. + [WirePath("properties.sessionId")] public Guid? SessionId { get; set; } /// Recommendation action identifier. + [WirePath("properties.actionId")] public int? ActionId { get; set; } /// Recommendation action creation time. + [WirePath("properties.createdTime")] public DateTimeOffset? CreatedOn { get; set; } /// Recommendation action expiration time. + [WirePath("properties.expirationTime")] public DateTimeOffset? ExpireOn { get; set; } /// Recommendation action reason. + [WirePath("properties.reason")] public string Reason { get; set; } /// Recommendation action type. + [WirePath("properties.recommendationType")] public string RecommendationType { get; set; } /// Recommendation action details. + [WirePath("properties.details")] public IDictionary Details { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlServerAdministratorData.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlServerAdministratorData.Serialization.cs index 91bf9e7dd8ca4..e9bea2d37090d 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlServerAdministratorData.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlServerAdministratorData.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; using Azure.ResourceManager.MySql.Models; @@ -207,6 +209,180 @@ internal static MySqlServerAdministratorData DeserializeMySqlServerAdministrator serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AdministratorType), out propertyOverride); + if (Optional.IsDefined(AdministratorType) || hasPropertyOverride) + { + builder.Append(" administratorType: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{AdministratorType.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LoginAccountName), out propertyOverride); + if (Optional.IsDefined(LoginAccountName) || hasPropertyOverride) + { + builder.Append(" login: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (LoginAccountName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{LoginAccountName}'''"); + } + else + { + builder.AppendLine($"'{LoginAccountName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SecureId), out propertyOverride); + if (Optional.IsDefined(SecureId) || hasPropertyOverride) + { + builder.Append(" sid: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SecureId.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TenantId), out propertyOverride); + if (Optional.IsDefined(TenantId) || hasPropertyOverride) + { + builder.Append(" tenantId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{TenantId.Value.ToString()}'"); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -215,6 +391,8 @@ BinaryData IPersistableModel.Write(ModelReaderWrit { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlServerAdministratorData)} does not support '{options.Format}' format."); } @@ -231,6 +409,8 @@ MySqlServerAdministratorData IPersistableModel.Cre using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlServerAdministratorData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlServerAdministratorData)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlServerAdministratorData.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlServerAdministratorData.cs index 42dd0532001db..ef59db027066c 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlServerAdministratorData.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlServerAdministratorData.cs @@ -76,12 +76,16 @@ internal MySqlServerAdministratorData(ResourceIdentifier id, string name, Resour } /// The type of administrator. + [WirePath("properties.administratorType")] public MySqlAdministratorType? AdministratorType { get; set; } /// The server administrator login account name. + [WirePath("properties.login")] public string LoginAccountName { get; set; } /// The server administrator Sid (Secure ID). + [WirePath("properties.sid")] public Guid? SecureId { get; set; } /// The server Active Directory Administrator tenant id. + [WirePath("properties.tenantId")] public Guid? TenantId { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlServerData.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlServerData.Serialization.cs index 977f5542d6e19..cfc868cacee4e 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlServerData.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlServerData.Serialization.cs @@ -7,8 +7,12 @@ using System; using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql.Models; namespace Azure.ResourceManager.MySql @@ -182,6 +186,442 @@ MySqlServerData IJsonModel.Create(ref Utf8JsonReader reader, Mo return DeserializeMySqlServerData(document.RootElement, options); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); + builder.Append(" location: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Location.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (Optional.IsCollectionDefined(Tags) || hasPropertyOverride) + { + if (Tags.Any() || hasPropertyOverride) + { + builder.Append(" tags: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); + if (Optional.IsDefined(Identity) || hasPropertyOverride) + { + builder.Append(" identity: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Identity, options, 2, false, " identity: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); + if (Optional.IsDefined(Sku) || hasPropertyOverride) + { + builder.Append(" sku: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Sku, options, 2, false, " sku: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AdministratorLogin), out propertyOverride); + if (Optional.IsDefined(AdministratorLogin) || hasPropertyOverride) + { + builder.Append(" administratorLogin: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (AdministratorLogin.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{AdministratorLogin}'''"); + } + else + { + builder.AppendLine($"'{AdministratorLogin}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Version), out propertyOverride); + if (Optional.IsDefined(Version) || hasPropertyOverride) + { + builder.Append(" version: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Version.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SslEnforcement), out propertyOverride); + if (Optional.IsDefined(SslEnforcement) || hasPropertyOverride) + { + builder.Append(" sslEnforcement: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SslEnforcement.Value.ToSerialString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinimalTlsVersion), out propertyOverride); + if (Optional.IsDefined(MinimalTlsVersion) || hasPropertyOverride) + { + builder.Append(" minimalTlsVersion: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{MinimalTlsVersion.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ByokEnforcement), out propertyOverride); + if (Optional.IsDefined(ByokEnforcement) || hasPropertyOverride) + { + builder.Append(" byokEnforcement: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ByokEnforcement.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ByokEnforcement}'''"); + } + else + { + builder.AppendLine($"'{ByokEnforcement}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(InfrastructureEncryption), out propertyOverride); + if (Optional.IsDefined(InfrastructureEncryption) || hasPropertyOverride) + { + builder.Append(" infrastructureEncryption: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{InfrastructureEncryption.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UserVisibleState), out propertyOverride); + if (Optional.IsDefined(UserVisibleState) || hasPropertyOverride) + { + builder.Append(" userVisibleState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{UserVisibleState.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FullyQualifiedDomainName), out propertyOverride); + if (Optional.IsDefined(FullyQualifiedDomainName) || hasPropertyOverride) + { + builder.Append(" fullyQualifiedDomainName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (FullyQualifiedDomainName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{FullyQualifiedDomainName}'''"); + } + else + { + builder.AppendLine($"'{FullyQualifiedDomainName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EarliestRestoreOn), out propertyOverride); + if (Optional.IsDefined(EarliestRestoreOn) || hasPropertyOverride) + { + builder.Append(" earliestRestoreDate: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(EarliestRestoreOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageProfile), out propertyOverride); + if (Optional.IsDefined(StorageProfile) || hasPropertyOverride) + { + builder.Append(" storageProfile: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, StorageProfile, options, 4, false, " storageProfile: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReplicationRole), out propertyOverride); + if (Optional.IsDefined(ReplicationRole) || hasPropertyOverride) + { + builder.Append(" replicationRole: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ReplicationRole.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ReplicationRole}'''"); + } + else + { + builder.AppendLine($"'{ReplicationRole}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MasterServerId), out propertyOverride); + if (Optional.IsDefined(MasterServerId) || hasPropertyOverride) + { + builder.Append(" masterServerId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{MasterServerId.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReplicaCapacity), out propertyOverride); + if (Optional.IsDefined(ReplicaCapacity) || hasPropertyOverride) + { + builder.Append(" replicaCapacity: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{ReplicaCapacity.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublicNetworkAccess), out propertyOverride); + if (Optional.IsDefined(PublicNetworkAccess) || hasPropertyOverride) + { + builder.Append(" publicNetworkAccess: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{PublicNetworkAccess.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateEndpointConnections), out propertyOverride); + if (Optional.IsCollectionDefined(PrivateEndpointConnections) || hasPropertyOverride) + { + if (PrivateEndpointConnections.Any() || hasPropertyOverride) + { + builder.Append(" privateEndpointConnections: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in PrivateEndpointConnections) + { + AppendChildObject(builder, item, options, 6, true, " privateEndpointConnections: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -190,6 +630,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions opt { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlServerData)} does not support '{options.Format}' format."); } @@ -206,6 +648,8 @@ MySqlServerData IPersistableModel.Create(BinaryData data, Model using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlServerData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlServerData)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlServerData.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlServerData.cs index 6fbf6ead5c07c..2ca33ee8ba2a2 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlServerData.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlServerData.cs @@ -111,38 +111,55 @@ internal MySqlServerData() } /// The Azure Active Directory identity of the server. Current supported identity types: SystemAssigned. + [WirePath("identity")] public ManagedServiceIdentity Identity { get; set; } /// The SKU (pricing tier) of the server. + [WirePath("sku")] public MySqlSku Sku { get; set; } /// The administrator's login name of a server. Can only be specified when the server is being created (and is required for creation). + [WirePath("properties.administratorLogin")] public string AdministratorLogin { get; set; } /// Server version. + [WirePath("properties.version")] public MySqlServerVersion? Version { get; set; } /// Enable ssl enforcement or not when connect to server. + [WirePath("properties.sslEnforcement")] public MySqlSslEnforcementEnum? SslEnforcement { get; set; } /// Enforce a minimal Tls version for the server. + [WirePath("properties.minimalTlsVersion")] public MySqlMinimalTlsVersionEnum? MinimalTlsVersion { get; set; } /// Status showing whether the server data encryption is enabled with customer-managed keys. + [WirePath("properties.byokEnforcement")] public string ByokEnforcement { get; } /// Status showing whether the server enabled infrastructure encryption. + [WirePath("properties.infrastructureEncryption")] public MySqlInfrastructureEncryption? InfrastructureEncryption { get; set; } /// A state of a server that is visible to user. + [WirePath("properties.userVisibleState")] public MySqlServerState? UserVisibleState { get; set; } /// The fully qualified domain name of a server. + [WirePath("properties.fullyQualifiedDomainName")] public string FullyQualifiedDomainName { get; set; } /// Earliest restore point creation time (ISO8601 format). + [WirePath("properties.earliestRestoreDate")] public DateTimeOffset? EarliestRestoreOn { get; set; } /// Storage profile of a server. + [WirePath("properties.storageProfile")] public MySqlStorageProfile StorageProfile { get; set; } /// The replication role of the server. + [WirePath("properties.replicationRole")] public string ReplicationRole { get; set; } /// The master server id of a replica server. + [WirePath("properties.masterServerId")] public ResourceIdentifier MasterServerId { get; set; } /// The maximum number of replicas that a master server can have. + [WirePath("properties.replicaCapacity")] public int? ReplicaCapacity { get; set; } /// Whether or not public network access is allowed for this server. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. + [WirePath("properties.publicNetworkAccess")] public MySqlPublicNetworkAccessEnum? PublicNetworkAccess { get; set; } /// List of private endpoint connections on a server. + [WirePath("properties.privateEndpointConnections")] public IReadOnlyList PrivateEndpointConnections { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlServerKeyData.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlServerKeyData.Serialization.cs index 8dd5170da24a9..5d26e712b3144 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlServerKeyData.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlServerKeyData.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; using Azure.ResourceManager.MySql.Models; @@ -207,6 +209,181 @@ internal static MySqlServerKeyData DeserializeMySqlServerKeyData(JsonElement ele serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Kind), out propertyOverride); + if (Optional.IsDefined(Kind) || hasPropertyOverride) + { + builder.Append(" kind: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Kind.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Kind}'''"); + } + else + { + builder.AppendLine($"'{Kind}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ServerKeyType), out propertyOverride); + if (Optional.IsDefined(ServerKeyType) || hasPropertyOverride) + { + builder.Append(" serverKeyType: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ServerKeyType.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Uri), out propertyOverride); + if (Optional.IsDefined(Uri) || hasPropertyOverride) + { + builder.Append(" uri: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Uri.AbsoluteUri}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); + if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) + { + builder.Append(" creationDate: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -215,6 +392,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlServerKeyData)} does not support '{options.Format}' format."); } @@ -231,6 +410,8 @@ MySqlServerKeyData IPersistableModel.Create(BinaryData data, using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlServerKeyData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlServerKeyData)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlServerKeyData.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlServerKeyData.cs index 25940da0be8b3..00fa83160ae2c 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlServerKeyData.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlServerKeyData.cs @@ -76,12 +76,16 @@ internal MySqlServerKeyData(ResourceIdentifier id, string name, ResourceType res } /// Kind of encryption protector used to protect the key. + [WirePath("kind")] public string Kind { get; } /// The key type like 'AzureKeyVault'. + [WirePath("properties.serverKeyType")] public MySqlServerKeyType? ServerKeyType { get; set; } /// The URI of the key. + [WirePath("properties.uri")] public Uri Uri { get; set; } /// The key creation date. + [WirePath("properties.creationDate")] public DateTimeOffset? CreatedOn { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlServerSecurityAlertPolicyData.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlServerSecurityAlertPolicyData.Serialization.cs index d116462b15cfa..aa664de22f22c 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlServerSecurityAlertPolicyData.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlServerSecurityAlertPolicyData.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; using Azure.ResourceManager.MySql.Models; @@ -271,6 +274,273 @@ internal static MySqlServerSecurityAlertPolicyData DeserializeMySqlServerSecurit serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); + if (Optional.IsDefined(State) || hasPropertyOverride) + { + builder.Append(" state: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{State.Value.ToSerialString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DisabledAlerts), out propertyOverride); + if (Optional.IsCollectionDefined(DisabledAlerts) || hasPropertyOverride) + { + if (DisabledAlerts.Any() || hasPropertyOverride) + { + builder.Append(" disabledAlerts: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in DisabledAlerts) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EmailAddresses), out propertyOverride); + if (Optional.IsCollectionDefined(EmailAddresses) || hasPropertyOverride) + { + if (EmailAddresses.Any() || hasPropertyOverride) + { + builder.Append(" emailAddresses: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in EmailAddresses) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SendToEmailAccountAdmins), out propertyOverride); + if (Optional.IsDefined(SendToEmailAccountAdmins) || hasPropertyOverride) + { + builder.Append(" emailAccountAdmins: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = SendToEmailAccountAdmins.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageEndpoint), out propertyOverride); + if (Optional.IsDefined(StorageEndpoint) || hasPropertyOverride) + { + builder.Append(" storageEndpoint: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (StorageEndpoint.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{StorageEndpoint}'''"); + } + else + { + builder.AppendLine($"'{StorageEndpoint}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageAccountAccessKey), out propertyOverride); + if (Optional.IsDefined(StorageAccountAccessKey) || hasPropertyOverride) + { + builder.Append(" storageAccountAccessKey: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (StorageAccountAccessKey.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{StorageAccountAccessKey}'''"); + } + else + { + builder.AppendLine($"'{StorageAccountAccessKey}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RetentionDays), out propertyOverride); + if (Optional.IsDefined(RetentionDays) || hasPropertyOverride) + { + builder.Append(" retentionDays: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{RetentionDays.Value}"); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -279,6 +549,8 @@ BinaryData IPersistableModel.Write(ModelRead { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlServerSecurityAlertPolicyData)} does not support '{options.Format}' format."); } @@ -295,6 +567,8 @@ MySqlServerSecurityAlertPolicyData IPersistableModel Specifies the state of the policy, whether it is enabled or disabled. + [WirePath("properties.state")] public MySqlServerSecurityAlertPolicyState? State { get; set; } /// Specifies an array of alerts that are disabled. Allowed values are: Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly. + [WirePath("properties.disabledAlerts")] public IList DisabledAlerts { get; } /// Specifies an array of e-mail addresses to which the alert is sent. + [WirePath("properties.emailAddresses")] public IList EmailAddresses { get; } /// Specifies that the alert is sent to the account administrators. + [WirePath("properties.emailAccountAdmins")] public bool? SendToEmailAccountAdmins { get; set; } /// Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). This blob storage will hold all Threat Detection audit logs. + [WirePath("properties.storageEndpoint")] public string StorageEndpoint { get; set; } /// Specifies the identifier key of the Threat Detection audit storage account. + [WirePath("properties.storageAccountAccessKey")] public string StorageAccountAccessKey { get; set; } /// Specifies the number of days to keep in the Threat Detection audit logs. + [WirePath("properties.retentionDays")] public int? RetentionDays { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlVirtualNetworkRuleData.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlVirtualNetworkRuleData.Serialization.cs index 4f08d26858a97..a86469316de51 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlVirtualNetworkRuleData.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlVirtualNetworkRuleData.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; using Azure.ResourceManager.MySql.Models; @@ -195,6 +197,159 @@ internal static MySqlVirtualNetworkRuleData DeserializeMySqlVirtualNetworkRuleDa serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VirtualNetworkSubnetId), out propertyOverride); + if (Optional.IsDefined(VirtualNetworkSubnetId) || hasPropertyOverride) + { + builder.Append(" virtualNetworkSubnetId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{VirtualNetworkSubnetId.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IgnoreMissingVnetServiceEndpoint), out propertyOverride); + if (Optional.IsDefined(IgnoreMissingVnetServiceEndpoint) || hasPropertyOverride) + { + builder.Append(" ignoreMissingVnetServiceEndpoint: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IgnoreMissingVnetServiceEndpoint.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); + if (Optional.IsDefined(State) || hasPropertyOverride) + { + builder.Append(" state: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{State.Value.ToString()}'"); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -203,6 +358,8 @@ BinaryData IPersistableModel.Write(ModelReaderWrite { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlVirtualNetworkRuleData)} does not support '{options.Format}' format."); } @@ -219,6 +376,8 @@ MySqlVirtualNetworkRuleData IPersistableModel.Creat using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlVirtualNetworkRuleData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlVirtualNetworkRuleData)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlVirtualNetworkRuleData.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlVirtualNetworkRuleData.cs index c343b96f581e6..4102dd3a8dcf9 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlVirtualNetworkRuleData.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlVirtualNetworkRuleData.cs @@ -74,10 +74,13 @@ internal MySqlVirtualNetworkRuleData(ResourceIdentifier id, string name, Resourc } /// The ARM resource id of the virtual network subnet. + [WirePath("properties.virtualNetworkSubnetId")] public ResourceIdentifier VirtualNetworkSubnetId { get; set; } /// Create firewall rule before the virtual network has vnet service endpoint enabled. + [WirePath("properties.ignoreMissingVnetServiceEndpoint")] public bool? IgnoreMissingVnetServiceEndpoint { get; set; } /// Virtual Network Rule State. + [WirePath("properties.state")] public MySqlVirtualNetworkRuleState? State { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlWaitStatisticData.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlWaitStatisticData.Serialization.cs index 30cea20ba354d..eeaf89833f2b1 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlWaitStatisticData.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlWaitStatisticData.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.MySql @@ -278,6 +280,268 @@ internal static MySqlWaitStatisticData DeserializeMySqlWaitStatisticData(JsonEle serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); + if (Optional.IsDefined(StartOn) || hasPropertyOverride) + { + builder.Append(" startTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndOn), out propertyOverride); + if (Optional.IsDefined(EndOn) || hasPropertyOverride) + { + builder.Append(" endTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(EndOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EventName), out propertyOverride); + if (Optional.IsDefined(EventName) || hasPropertyOverride) + { + builder.Append(" eventName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (EventName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{EventName}'''"); + } + else + { + builder.AppendLine($"'{EventName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EventTypeName), out propertyOverride); + if (Optional.IsDefined(EventTypeName) || hasPropertyOverride) + { + builder.Append(" eventTypeName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (EventTypeName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{EventTypeName}'''"); + } + else + { + builder.AppendLine($"'{EventTypeName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(QueryId), out propertyOverride); + if (Optional.IsDefined(QueryId) || hasPropertyOverride) + { + builder.Append(" queryId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{QueryId.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DatabaseName), out propertyOverride); + if (Optional.IsDefined(DatabaseName) || hasPropertyOverride) + { + builder.Append(" databaseName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (DatabaseName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{DatabaseName}'''"); + } + else + { + builder.AppendLine($"'{DatabaseName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(UserId), out propertyOverride); + if (Optional.IsDefined(UserId) || hasPropertyOverride) + { + builder.Append(" userId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{UserId.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Count), out propertyOverride); + if (Optional.IsDefined(Count) || hasPropertyOverride) + { + builder.Append(" count: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Count.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TotalTimeInMinutes), out propertyOverride); + if (Optional.IsDefined(TotalTimeInMinutes) || hasPropertyOverride) + { + builder.Append(" totalTimeInMs: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{TotalTimeInMinutes.Value.ToString()}'"); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -286,6 +550,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlWaitStatisticData)} does not support '{options.Format}' format."); } @@ -302,6 +568,8 @@ MySqlWaitStatisticData IPersistableModel.Create(BinaryDa using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlWaitStatisticData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlWaitStatisticData)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlWaitStatisticData.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlWaitStatisticData.cs index dba5ebd38a3a1..49c476f41ead2 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlWaitStatisticData.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Generated/MySqlWaitStatisticData.cs @@ -85,22 +85,31 @@ internal MySqlWaitStatisticData(ResourceIdentifier id, string name, ResourceType } /// Observation start time. + [WirePath("properties.startTime")] public DateTimeOffset? StartOn { get; set; } /// Observation end time. + [WirePath("properties.endTime")] public DateTimeOffset? EndOn { get; set; } /// Wait event name. + [WirePath("properties.eventName")] public string EventName { get; set; } /// Wait event type name. + [WirePath("properties.eventTypeName")] public string EventTypeName { get; set; } /// Database query identifier. + [WirePath("properties.queryId")] public long? QueryId { get; set; } /// Database Name. + [WirePath("properties.databaseName")] public string DatabaseName { get; set; } /// Database user identifier. + [WirePath("properties.userId")] public long? UserId { get; set; } /// Wait event count observed in this time interval. + [WirePath("properties.count")] public long? Count { get; set; } /// Total time of wait in milliseconds in this time interval. + [WirePath("properties.totalTimeInMs")] public double? TotalTimeInMinutes { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Internal/WirePathAttribute.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Internal/WirePathAttribute.cs new file mode 100644 index 0000000000000..ed623904d5da7 --- /dev/null +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Internal/WirePathAttribute.cs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.MySql.FlexibleServers +{ + [AttributeUsage(AttributeTargets.Property)] + internal class WirePathAttribute : Attribute + { + private string _wirePath; + + public WirePathAttribute(string wirePath) + { + _wirePath = wirePath; + } + + public override string ToString() + { + return _wirePath; + } + } +} diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/CapabilitySetsList.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/CapabilitySetsList.Serialization.cs index 394f699d35060..15bfbb1da0504 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/CapabilitySetsList.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/CapabilitySetsList.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; using Azure.ResourceManager.MySql.FlexibleServers; @@ -115,6 +118,107 @@ internal static CapabilitySetsList DeserializeCapabilitySetsList(JsonElement ele return new CapabilitySetsList(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -123,6 +227,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(CapabilitySetsList)} does not support '{options.Format}' format."); } @@ -139,6 +245,8 @@ CapabilitySetsList IPersistableModel.Create(BinaryData data, using JsonDocument document = JsonDocument.Parse(data); return DeserializeCapabilitySetsList(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(CapabilitySetsList)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/ImportSourceProperties.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/ImportSourceProperties.Serialization.cs index a36b20a39019c..8a4f6b37cbc39 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/ImportSourceProperties.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/ImportSourceProperties.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.FlexibleServers.Models @@ -130,6 +132,135 @@ internal static ImportSourceProperties DeserializeImportSourceProperties(JsonEle return new ImportSourceProperties(storageType, storageUrl, sasToken, dataDirPath, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageType), out propertyOverride); + if (Optional.IsDefined(StorageType) || hasPropertyOverride) + { + builder.Append(" storageType: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{StorageType.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageUri), out propertyOverride); + if (Optional.IsDefined(StorageUri) || hasPropertyOverride) + { + builder.Append(" storageUrl: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{StorageUri.AbsoluteUri}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SasToken), out propertyOverride); + if (Optional.IsDefined(SasToken) || hasPropertyOverride) + { + builder.Append(" sasToken: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (SasToken.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{SasToken}'''"); + } + else + { + builder.AppendLine($"'{SasToken}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DataDirPath), out propertyOverride); + if (Optional.IsDefined(DataDirPath) || hasPropertyOverride) + { + builder.Append(" dataDirPath: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (DataDirPath.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{DataDirPath}'''"); + } + else + { + builder.AppendLine($"'{DataDirPath}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -138,6 +269,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ImportSourceProperties)} does not support '{options.Format}' format."); } @@ -154,6 +287,8 @@ ImportSourceProperties IPersistableModel.Create(BinaryDa using JsonDocument document = JsonDocument.Parse(data); return DeserializeImportSourceProperties(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ImportSourceProperties)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/ImportSourceProperties.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/ImportSourceProperties.cs index 9fe0f80d4dd21..4a38399a2ce02 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/ImportSourceProperties.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/ImportSourceProperties.cs @@ -66,12 +66,16 @@ internal ImportSourceProperties(ImportSourceStorageType? storageType, Uri storag } /// Storage type of import source. + [WirePath("storageType")] public ImportSourceStorageType? StorageType { get; set; } /// Uri of the import source storage. + [WirePath("storageUrl")] public Uri StorageUri { get; set; } /// Sas token for accessing source storage. Read and list permissions are required for sas token. + [WirePath("sasToken")] public string SasToken { get; set; } /// Relative path of data directory in storage. + [WirePath("dataDirPath")] public string DataDirPath { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerAadAdministratorListResult.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerAadAdministratorListResult.Serialization.cs index 8f27b1dd13f46..3bd196fcacd6c 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerAadAdministratorListResult.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerAadAdministratorListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; using Azure.ResourceManager.MySql.FlexibleServers; @@ -115,6 +118,107 @@ internal static MySqlFlexibleServerAadAdministratorListResult DeserializeMySqlFl return new MySqlFlexibleServerAadAdministratorListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -123,6 +227,8 @@ BinaryData IPersistableModel.Writ { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerAadAdministratorListResult)} does not support '{options.Format}' format."); } @@ -139,6 +245,8 @@ MySqlFlexibleServerAadAdministratorListResult IPersistableModel is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. /// The available derived classes include . /// + [WirePath("targetDetails")] public MySqlFlexibleServerBackupStoreDetails TargetDetails { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerBackupAndExportResult.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerBackupAndExportResult.Serialization.cs index 2679bcd055d74..dcb1bb36aa923 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerBackupAndExportResult.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerBackupAndExportResult.Serialization.cs @@ -8,9 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; using Azure.ResourceManager.MySql; @@ -272,6 +274,238 @@ internal static MySqlFlexibleServerBackupAndExportResult DeserializeMySqlFlexibl serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); + if (Optional.IsDefined(Status) || hasPropertyOverride) + { + builder.Append(" status: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Status.Value.ToSerialString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); + if (Optional.IsDefined(StartOn) || hasPropertyOverride) + { + builder.Append(" startTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndOn), out propertyOverride); + if (Optional.IsDefined(EndOn) || hasPropertyOverride) + { + builder.Append(" endTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(EndOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PercentComplete), out propertyOverride); + if (Optional.IsDefined(PercentComplete) || hasPropertyOverride) + { + builder.Append(" percentComplete: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{PercentComplete.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Error), out propertyOverride); + if (Optional.IsDefined(Error) || hasPropertyOverride) + { + builder.Append(" error: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Error, options, 2, false, " error: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DatasourceSizeInBytes), out propertyOverride); + if (Optional.IsDefined(DatasourceSizeInBytes) || hasPropertyOverride) + { + builder.Append(" datasourceSizeInBytes: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{DatasourceSizeInBytes.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DataTransferredInBytes), out propertyOverride); + if (Optional.IsDefined(DataTransferredInBytes) || hasPropertyOverride) + { + builder.Append(" dataTransferredInBytes: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{DataTransferredInBytes.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BackupMetadata), out propertyOverride); + if (Optional.IsDefined(BackupMetadata) || hasPropertyOverride) + { + builder.Append(" backupMetadata: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (BackupMetadata.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{BackupMetadata}'''"); + } + else + { + builder.AppendLine($"'{BackupMetadata}'"); + } + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -280,6 +514,8 @@ BinaryData IPersistableModel.Write(Mod { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerBackupAndExportResult)} does not support '{options.Format}' format."); } @@ -296,6 +532,8 @@ MySqlFlexibleServerBackupAndExportResult IPersistableModel The operation status. + [WirePath("status")] public MySqlFlexibleServerBackupAndExportOperationStatus? Status { get; set; } /// Start time. + [WirePath("startTime")] public DateTimeOffset? StartOn { get; set; } /// End time. + [WirePath("endTime")] public DateTimeOffset? EndOn { get; set; } /// Operation progress (0-100). + [WirePath("percentComplete")] public double? PercentComplete { get; set; } /// Size of datasource in bytes. + [WirePath("properties.datasourceSizeInBytes")] public long? DatasourceSizeInBytes { get; set; } /// Data transferred in bytes. + [WirePath("properties.dataTransferredInBytes")] public long? DataTransferredInBytes { get; set; } /// Metadata related to backup to be stored for restoring resource in key-value pairs. + [WirePath("properties.backupMetadata")] public string BackupMetadata { get; set; } /// The error object. + [WirePath("error")] public ResponseError Error { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerBackupContentBase.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerBackupContentBase.cs index 4b518cc885de6..1b9c3838965d2 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerBackupContentBase.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerBackupContentBase.cs @@ -71,6 +71,7 @@ internal MySqlFlexibleServerBackupContentBase() } /// Backup Settings. + [WirePath("backupSettings")] public MySqlFlexibleServerBackupSettings BackupSettings { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerBackupListResult.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerBackupListResult.Serialization.cs index a06a378982d8a..bbdc6dbd7b4a6 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerBackupListResult.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerBackupListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; using Azure.ResourceManager.MySql.FlexibleServers; @@ -115,6 +118,107 @@ internal static MySqlFlexibleServerBackupListResult DeserializeMySqlFlexibleServ return new MySqlFlexibleServerBackupListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -123,6 +227,8 @@ BinaryData IPersistableModel.Write(ModelRea { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerBackupListResult)} does not support '{options.Format}' format."); } @@ -139,6 +245,8 @@ MySqlFlexibleServerBackupListResult IPersistableModel propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BackupRetentionDays), out propertyOverride); + if (Optional.IsDefined(BackupRetentionDays) || hasPropertyOverride) + { + builder.Append(" backupRetentionDays: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{BackupRetentionDays.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GeoRedundantBackup), out propertyOverride); + if (Optional.IsDefined(GeoRedundantBackup) || hasPropertyOverride) + { + builder.Append(" geoRedundantBackup: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{GeoRedundantBackup.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EarliestRestoreOn), out propertyOverride); + if (Optional.IsDefined(EarliestRestoreOn) || hasPropertyOverride) + { + builder.Append(" earliestRestoreDate: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(EarliestRestoreOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -131,6 +233,8 @@ BinaryData IPersistableModel.Write(ModelRea { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerBackupProperties)} does not support '{options.Format}' format."); } @@ -147,6 +251,8 @@ MySqlFlexibleServerBackupProperties IPersistableModel Backup retention days for the server. + [WirePath("backupRetentionDays")] public int? BackupRetentionDays { get; set; } /// Whether or not geo redundant backup is enabled. + [WirePath("geoRedundantBackup")] public MySqlFlexibleServerEnableStatusEnum? GeoRedundantBackup { get; set; } /// Earliest restore point creation time (ISO8601 format). + [WirePath("earliestRestoreDate")] public DateTimeOffset? EarliestRestoreOn { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerBackupSettings.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerBackupSettings.cs index 0f015b1d0e829..52d92da6df854 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerBackupSettings.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerBackupSettings.cs @@ -73,8 +73,10 @@ internal MySqlFlexibleServerBackupSettings() } /// The name of the backup. + [WirePath("backupName")] public string BackupName { get; } /// Backup Format for the current backup. (CollatedFormat is INTERNAL – DO NOT USE). + [WirePath("backupFormat")] public MySqlFlexibleServerBackupFormat? BackupFormat { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerCapabilitiesListResult.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerCapabilitiesListResult.Serialization.cs index f34393c65f56e..9d12db809377d 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerCapabilitiesListResult.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerCapabilitiesListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.FlexibleServers.Models @@ -114,6 +117,107 @@ internal static MySqlFlexibleServerCapabilitiesListResult DeserializeMySqlFlexib return new MySqlFlexibleServerCapabilitiesListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +226,8 @@ BinaryData IPersistableModel.Write(Mo { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerCapabilitiesListResult)} does not support '{options.Format}' format."); } @@ -138,6 +244,8 @@ MySqlFlexibleServerCapabilitiesListResult IPersistableModel(), supportedGeoBackupRegions ?? new ChangeTrackingList(), supportedFlexibleServerEditions ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Zone), out propertyOverride); + if (Optional.IsDefined(Zone) || hasPropertyOverride) + { + builder.Append(" zone: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Zone.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Zone}'''"); + } + else + { + builder.AppendLine($"'{Zone}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SupportedHAMode), out propertyOverride); + if (Optional.IsCollectionDefined(SupportedHAMode) || hasPropertyOverride) + { + if (SupportedHAMode.Any() || hasPropertyOverride) + { + builder.Append(" supportedHAMode: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in SupportedHAMode) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SupportedGeoBackupRegions), out propertyOverride); + if (Optional.IsCollectionDefined(SupportedGeoBackupRegions) || hasPropertyOverride) + { + if (SupportedGeoBackupRegions.Any() || hasPropertyOverride) + { + builder.Append(" supportedGeoBackupRegions: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in SupportedGeoBackupRegions) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SupportedFlexibleServerEditions), out propertyOverride); + if (Optional.IsCollectionDefined(SupportedFlexibleServerEditions) || hasPropertyOverride) + { + if (SupportedFlexibleServerEditions.Any() || hasPropertyOverride) + { + builder.Append(" supportedFlexibleServerEditions: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in SupportedFlexibleServerEditions) + { + AppendChildObject(builder, item, options, 4, true, " supportedFlexibleServerEditions: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -172,6 +346,8 @@ BinaryData IPersistableModel.Write(Mode { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerCapabilityProperties)} does not support '{options.Format}' format."); } @@ -188,6 +364,8 @@ MySqlFlexibleServerCapabilityProperties IPersistableModel zone name. + [WirePath("zone")] public string Zone { get; } /// Supported high availability mode. + [WirePath("supportedHAMode")] public IReadOnlyList SupportedHAMode { get; } /// supported geo backup regions. + [WirePath("supportedGeoBackupRegions")] public IReadOnlyList SupportedGeoBackupRegions { get; } /// A list of supported flexible server editions. + [WirePath("supportedFlexibleServerEditions")] public IReadOnlyList SupportedFlexibleServerEditions { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerConfigurationForBatchUpdate.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerConfigurationForBatchUpdate.cs index bbf4f8bae5089..0de09755f5503 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerConfigurationForBatchUpdate.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerConfigurationForBatchUpdate.cs @@ -64,10 +64,13 @@ internal MySqlFlexibleServerConfigurationForBatchUpdate(string name, string valu } /// Name of the configuration. + [WirePath("name")] public string Name { get; set; } /// Value of the configuration. + [WirePath("properties.value")] public string Value { get; set; } /// Source of the configuration. + [WirePath("properties.source")] public string Source { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerConfigurationListForBatchUpdate.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerConfigurationListForBatchUpdate.cs index f74f3faaa32e0..0686b322b724a 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerConfigurationListForBatchUpdate.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerConfigurationListForBatchUpdate.cs @@ -64,8 +64,10 @@ internal MySqlFlexibleServerConfigurationListForBatchUpdate(IList The list of server configurations. + [WirePath("value")] public IList Values { get; } /// Whether to reset all server parameters to default. + [WirePath("resetAllToDefault")] public MySqlFlexibleServerConfigurationResetAllToDefault? ResetAllToDefault { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerConfigurationListResult.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerConfigurationListResult.Serialization.cs index 93e9063025bdf..76907914a99ac 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerConfigurationListResult.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerConfigurationListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; using Azure.ResourceManager.MySql.FlexibleServers; @@ -115,6 +118,107 @@ internal static MySqlFlexibleServerConfigurationListResult DeserializeMySqlFlexi return new MySqlFlexibleServerConfigurationListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Values), out propertyOverride); + if (Optional.IsCollectionDefined(Values) || hasPropertyOverride) + { + if (Values.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Values) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -123,6 +227,8 @@ BinaryData IPersistableModel.Write(M { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerConfigurationListResult)} does not support '{options.Format}' format."); } @@ -139,6 +245,8 @@ MySqlFlexibleServerConfigurationListResult IPersistableModel(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Values), out propertyOverride); + if (Optional.IsCollectionDefined(Values) || hasPropertyOverride) + { + if (Values.Any() || hasPropertyOverride) + { + builder.Append(" values: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Values) + { + AppendChildObject(builder, item, options, 4, true, " values: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -112,6 +194,8 @@ BinaryData IPersistableModel.Write(ModelReade { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerConfigurations)} does not support '{options.Format}' format."); } @@ -128,6 +212,8 @@ MySqlFlexibleServerConfigurations IPersistableModel The list of server configurations. + [WirePath("values")] public IReadOnlyList Values { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerDataEncryption.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerDataEncryption.Serialization.cs index b2e571437398c..408d5b50c2a56 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerDataEncryption.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerDataEncryption.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.FlexibleServers.Models @@ -159,6 +161,119 @@ internal static MySqlFlexibleServerDataEncryption DeserializeMySqlFlexibleServer serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrimaryUserAssignedIdentityId), out propertyOverride); + if (Optional.IsDefined(PrimaryUserAssignedIdentityId) || hasPropertyOverride) + { + builder.Append(" primaryUserAssignedIdentityId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{PrimaryUserAssignedIdentityId.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrimaryKeyUri), out propertyOverride); + if (Optional.IsDefined(PrimaryKeyUri) || hasPropertyOverride) + { + builder.Append(" primaryKeyURI: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{PrimaryKeyUri.AbsoluteUri}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GeoBackupUserAssignedIdentityId), out propertyOverride); + if (Optional.IsDefined(GeoBackupUserAssignedIdentityId) || hasPropertyOverride) + { + builder.Append(" geoBackupUserAssignedIdentityId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{GeoBackupUserAssignedIdentityId.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GeoBackupKeyUri), out propertyOverride); + if (Optional.IsDefined(GeoBackupKeyUri) || hasPropertyOverride) + { + builder.Append(" geoBackupKeyURI: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{GeoBackupKeyUri.AbsoluteUri}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -167,6 +282,8 @@ BinaryData IPersistableModel.Write(ModelReade { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerDataEncryption)} does not support '{options.Format}' format."); } @@ -183,6 +300,8 @@ MySqlFlexibleServerDataEncryption IPersistableModel Primary user identity resource id. + [WirePath("primaryUserAssignedIdentityId")] public ResourceIdentifier PrimaryUserAssignedIdentityId { get; set; } /// Primary key uri. + [WirePath("primaryKeyURI")] public Uri PrimaryKeyUri { get; set; } /// Geo backup user identity resource id as identity can't cross region, need identity in same region as geo backup. + [WirePath("geoBackupUserAssignedIdentityId")] public ResourceIdentifier GeoBackupUserAssignedIdentityId { get; set; } /// Geo backup key uri as key vault can't cross region, need cmk in same region as geo backup. + [WirePath("geoBackupKeyURI")] public Uri GeoBackupKeyUri { get; set; } /// The key type, AzureKeyVault for enable cmk, SystemManaged for disable cmk. + [WirePath("type")] public MySqlFlexibleServerDataEncryptionType? EncryptionType { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerDatabaseListResult.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerDatabaseListResult.Serialization.cs index 6163a04d5c8b9..2451aefa3cc0e 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerDatabaseListResult.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerDatabaseListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; using Azure.ResourceManager.MySql.FlexibleServers; @@ -115,6 +118,107 @@ internal static MySqlFlexibleServerDatabaseListResult DeserializeMySqlFlexibleSe return new MySqlFlexibleServerDatabaseListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -123,6 +227,8 @@ BinaryData IPersistableModel.Write(ModelR { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerDatabaseListResult)} does not support '{options.Format}' format."); } @@ -139,6 +245,8 @@ MySqlFlexibleServerDatabaseListResult IPersistableModel propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SubnetName), out propertyOverride); + if (Optional.IsDefined(SubnetName) || hasPropertyOverride) + { + builder.Append(" subnetName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (SubnetName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{SubnetName}'''"); + } + else + { + builder.AppendLine($"'{SubnetName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Usage), out propertyOverride); + if (Optional.IsDefined(Usage) || hasPropertyOverride) + { + builder.Append(" usage: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Usage.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -112,6 +207,8 @@ BinaryData IPersistableModel.Write(Mode { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerDelegatedSubnetUsage)} does not support '{options.Format}' format."); } @@ -128,6 +225,8 @@ MySqlFlexibleServerDelegatedSubnetUsage IPersistableModel name of the subnet. + [WirePath("subnetName")] public string SubnetName { get; } /// Number of used delegated subnets. + [WirePath("usage")] public long? Usage { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerEditionCapability.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerEditionCapability.Serialization.cs index 0c0ad24c6db85..ffa49fbcc0475 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerEditionCapability.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerEditionCapability.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.FlexibleServers.Models @@ -139,6 +142,129 @@ internal static MySqlFlexibleServerEditionCapability DeserializeMySqlFlexibleSer return new MySqlFlexibleServerEditionCapability(name, supportedStorageEditions ?? new ChangeTrackingList(), supportedServerVersions ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SupportedStorageEditions), out propertyOverride); + if (Optional.IsCollectionDefined(SupportedStorageEditions) || hasPropertyOverride) + { + if (SupportedStorageEditions.Any() || hasPropertyOverride) + { + builder.Append(" supportedStorageEditions: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in SupportedStorageEditions) + { + AppendChildObject(builder, item, options, 4, true, " supportedStorageEditions: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SupportedServerVersions), out propertyOverride); + if (Optional.IsCollectionDefined(SupportedServerVersions) || hasPropertyOverride) + { + if (SupportedServerVersions.Any() || hasPropertyOverride) + { + builder.Append(" supportedServerVersions: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in SupportedServerVersions) + { + AppendChildObject(builder, item, options, 4, true, " supportedServerVersions: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -147,6 +273,8 @@ BinaryData IPersistableModel.Write(ModelRe { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerEditionCapability)} does not support '{options.Format}' format."); } @@ -163,6 +291,8 @@ MySqlFlexibleServerEditionCapability IPersistableModel Server edition name. + [WirePath("name")] public string Name { get; } /// A list of supported storage editions. + [WirePath("supportedStorageEditions")] public IReadOnlyList SupportedStorageEditions { get; } /// A list of supported server versions. + [WirePath("supportedServerVersions")] public IReadOnlyList SupportedServerVersions { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerFirewallRuleListResult.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerFirewallRuleListResult.Serialization.cs index 7a0bbff0bece9..417186071af81 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerFirewallRuleListResult.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerFirewallRuleListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; using Azure.ResourceManager.MySql.FlexibleServers; @@ -115,6 +118,107 @@ internal static MySqlFlexibleServerFirewallRuleListResult DeserializeMySqlFlexib return new MySqlFlexibleServerFirewallRuleListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -123,6 +227,8 @@ BinaryData IPersistableModel.Write(Mo { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerFirewallRuleListResult)} does not support '{options.Format}' format."); } @@ -139,6 +245,8 @@ MySqlFlexibleServerFirewallRuleListResult IPersistableModel SASUriList of storage containers where backup data is to be streamed/copied. + [WirePath("sasUriList")] public IList SasUriList { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerGtidSetContent.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerGtidSetContent.cs index bdffaf46b0f48..c546f4ef28d8e 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerGtidSetContent.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerGtidSetContent.cs @@ -60,6 +60,7 @@ internal MySqlFlexibleServerGtidSetContent(string gtidSet, IDictionary The Gtid set of server. + [WirePath("gtidSet")] public string GtidSet { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerHighAvailability.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerHighAvailability.Serialization.cs index 51ae9d8c32511..f89db4bd19199 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerHighAvailability.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerHighAvailability.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.FlexibleServers.Models @@ -119,6 +121,113 @@ internal static MySqlFlexibleServerHighAvailability DeserializeMySqlFlexibleServ return new MySqlFlexibleServerHighAvailability(mode, state, standbyAvailabilityZone, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Mode), out propertyOverride); + if (Optional.IsDefined(Mode) || hasPropertyOverride) + { + builder.Append(" mode: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Mode.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); + if (Optional.IsDefined(State) || hasPropertyOverride) + { + builder.Append(" state: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{State.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StandbyAvailabilityZone), out propertyOverride); + if (Optional.IsDefined(StandbyAvailabilityZone) || hasPropertyOverride) + { + builder.Append(" standbyAvailabilityZone: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (StandbyAvailabilityZone.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{StandbyAvailabilityZone}'''"); + } + else + { + builder.AppendLine($"'{StandbyAvailabilityZone}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -127,6 +236,8 @@ BinaryData IPersistableModel.Write(ModelRea { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerHighAvailability)} does not support '{options.Format}' format."); } @@ -143,6 +254,8 @@ MySqlFlexibleServerHighAvailability IPersistableModel High availability mode for a server. + [WirePath("mode")] public MySqlFlexibleServerHighAvailabilityMode? Mode { get; set; } /// The state of server high availability. + [WirePath("state")] public MySqlFlexibleServerHighAvailabilityState? State { get; } /// Availability zone of the standby server. + [WirePath("standbyAvailabilityZone")] public string StandbyAvailabilityZone { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerListResult.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerListResult.Serialization.cs index 67ee8eb555b88..cdbb740573ba3 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerListResult.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; using Azure.ResourceManager.MySql.FlexibleServers; @@ -115,6 +118,107 @@ internal static MySqlFlexibleServerListResult DeserializeMySqlFlexibleServerList return new MySqlFlexibleServerListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -123,6 +227,8 @@ BinaryData IPersistableModel.Write(ModelReaderWri { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerListResult)} does not support '{options.Format}' format."); } @@ -139,6 +245,8 @@ MySqlFlexibleServerListResult IPersistableModel.C using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlFlexibleServerListResult(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerListResult)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerLogFile.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerLogFile.Serialization.cs index f4f112f2a9bdd..bae72727921c5 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerLogFile.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerLogFile.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; using Azure.ResourceManager.MySql; @@ -223,6 +225,196 @@ internal static MySqlFlexibleServerLogFile DeserializeMySqlFlexibleServerLogFile serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SizeInKB), out propertyOverride); + if (Optional.IsDefined(SizeInKB) || hasPropertyOverride) + { + builder.Append(" sizeInKB: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SizeInKB.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreatedOn), out propertyOverride); + if (Optional.IsDefined(CreatedOn) || hasPropertyOverride) + { + builder.Append(" createdTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(CreatedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TypePropertiesType), out propertyOverride); + if (Optional.IsDefined(TypePropertiesType) || hasPropertyOverride) + { + builder.Append(" type: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (TypePropertiesType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{TypePropertiesType}'''"); + } + else + { + builder.AppendLine($"'{TypePropertiesType}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LastModifiedOn), out propertyOverride); + if (Optional.IsDefined(LastModifiedOn) || hasPropertyOverride) + { + builder.Append(" lastModifiedTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(LastModifiedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Uri), out propertyOverride); + if (Optional.IsDefined(Uri) || hasPropertyOverride) + { + builder.Append(" url: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Uri.AbsoluteUri}'"); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -231,6 +423,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriter { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerLogFile)} does not support '{options.Format}' format."); } @@ -247,6 +441,8 @@ MySqlFlexibleServerLogFile IPersistableModel.Create( using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlFlexibleServerLogFile(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerLogFile)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerLogFile.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerLogFile.cs index cc92d8715a2da..dde692526d466 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerLogFile.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerLogFile.cs @@ -74,14 +74,19 @@ internal MySqlFlexibleServerLogFile(ResourceIdentifier id, string name, Resource } /// The size in kb of the logFile. + [WirePath("properties.sizeInKB")] public long? SizeInKB { get; set; } /// Creation timestamp of the log file. + [WirePath("properties.createdTime")] public DateTimeOffset? CreatedOn { get; set; } /// Type of the log file. + [WirePath("properties.type")] public string TypePropertiesType { get; set; } /// Last modified timestamp of the log file. + [WirePath("properties.lastModifiedTime")] public DateTimeOffset? LastModifiedOn { get; set; } /// The url to download the log file from. + [WirePath("properties.url")] public Uri Uri { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerLogFileListResult.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerLogFileListResult.Serialization.cs index 8ac9fefd1ad56..3d042fd61362b 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerLogFileListResult.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerLogFileListResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.FlexibleServers.Models @@ -114,6 +117,107 @@ internal static MySqlFlexibleServerLogFileListResult DeserializeMySqlFlexibleSer return new MySqlFlexibleServerLogFileListResult(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsCollectionDefined(Value) || hasPropertyOverride) + { + if (Value.Any() || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Value) + { + AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (Optional.IsDefined(NextLink) || hasPropertyOverride) + { + builder.Append(" nextLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +226,8 @@ BinaryData IPersistableModel.Write(ModelRe { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerLogFileListResult)} does not support '{options.Format}' format."); } @@ -138,6 +244,8 @@ MySqlFlexibleServerLogFileListResult IPersistableModel propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CustomWindow), out propertyOverride); + if (Optional.IsDefined(CustomWindow) || hasPropertyOverride) + { + builder.Append(" customWindow: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (CustomWindow.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{CustomWindow}'''"); + } + else + { + builder.AppendLine($"'{CustomWindow}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartHour), out propertyOverride); + if (Optional.IsDefined(StartHour) || hasPropertyOverride) + { + builder.Append(" startHour: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{StartHour.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartMinute), out propertyOverride); + if (Optional.IsDefined(StartMinute) || hasPropertyOverride) + { + builder.Append(" startMinute: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{StartMinute.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DayOfWeek), out propertyOverride); + if (Optional.IsDefined(DayOfWeek) || hasPropertyOverride) + { + builder.Append(" dayOfWeek: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{DayOfWeek.Value}"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -142,6 +265,8 @@ BinaryData IPersistableModel.Write(ModelRe { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerMaintenanceWindow)} does not support '{options.Format}' format."); } @@ -158,6 +283,8 @@ MySqlFlexibleServerMaintenanceWindow IPersistableModel indicates whether custom window is enabled or disabled. + [WirePath("customWindow")] public string CustomWindow { get; set; } /// start hour for maintenance window. + [WirePath("startHour")] public int? StartHour { get; set; } /// start minute for maintenance window. + [WirePath("startMinute")] public int? StartMinute { get; set; } /// day of week for maintenance window. + [WirePath("dayOfWeek")] public int? DayOfWeek { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerNameAvailabilityContent.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerNameAvailabilityContent.cs index c1b792f42ad50..3efeea19b93b7 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerNameAvailabilityContent.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerNameAvailabilityContent.cs @@ -74,8 +74,10 @@ internal MySqlFlexibleServerNameAvailabilityContent() } /// Resource name to verify. + [WirePath("name")] public string Name { get; } /// Resource type used for verification. + [WirePath("type")] public ResourceType? ResourceType { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerNameAvailabilityResult.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerNameAvailabilityResult.Serialization.cs index c926550226aed..67daa4b31077f 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerNameAvailabilityResult.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerNameAvailabilityResult.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.FlexibleServers.Models @@ -115,6 +117,122 @@ internal static MySqlFlexibleServerNameAvailabilityResult DeserializeMySqlFlexib return new MySqlFlexibleServerNameAvailabilityResult(message, nameAvailable, reason, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Message), out propertyOverride); + if (Optional.IsDefined(Message) || hasPropertyOverride) + { + builder.Append(" message: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Message.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Message}'''"); + } + else + { + builder.AppendLine($"'{Message}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsNameAvailable), out propertyOverride); + if (Optional.IsDefined(IsNameAvailable) || hasPropertyOverride) + { + builder.Append(" nameAvailable: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var boolValue = IsNameAvailable.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Reason), out propertyOverride); + if (Optional.IsDefined(Reason) || hasPropertyOverride) + { + builder.Append(" reason: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Reason.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Reason}'''"); + } + else + { + builder.AppendLine($"'{Reason}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -123,6 +241,8 @@ BinaryData IPersistableModel.Write(Mo { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerNameAvailabilityResult)} does not support '{options.Format}' format."); } @@ -139,6 +259,8 @@ MySqlFlexibleServerNameAvailabilityResult IPersistableModel Error Message. + [WirePath("message")] public string Message { get; } /// Indicates whether the resource name is available. + [WirePath("nameAvailable")] public bool? IsNameAvailable { get; } /// Reason for name being unavailable. + [WirePath("reason")] public string Reason { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerNetwork.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerNetwork.Serialization.cs index aecc1bbec13f6..48c7e5a0bd7a0 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerNetwork.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerNetwork.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.FlexibleServers.Models @@ -123,6 +125,105 @@ internal static MySqlFlexibleServerNetwork DeserializeMySqlFlexibleServerNetwork return new MySqlFlexibleServerNetwork(publicNetworkAccess, delegatedSubnetResourceId, privateDnsZoneResourceId, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PublicNetworkAccess), out propertyOverride); + if (Optional.IsDefined(PublicNetworkAccess) || hasPropertyOverride) + { + builder.Append(" publicNetworkAccess: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{PublicNetworkAccess.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DelegatedSubnetResourceId), out propertyOverride); + if (Optional.IsDefined(DelegatedSubnetResourceId) || hasPropertyOverride) + { + builder.Append(" delegatedSubnetResourceId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{DelegatedSubnetResourceId.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateDnsZoneResourceId), out propertyOverride); + if (Optional.IsDefined(PrivateDnsZoneResourceId) || hasPropertyOverride) + { + builder.Append(" privateDnsZoneResourceId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{PrivateDnsZoneResourceId.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -131,6 +232,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriter { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerNetwork)} does not support '{options.Format}' format."); } @@ -147,6 +250,8 @@ MySqlFlexibleServerNetwork IPersistableModel.Create( using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlFlexibleServerNetwork(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerNetwork)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerNetwork.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerNetwork.cs index 3e1213ab9d904..fb890fabf5a2d 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerNetwork.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerNetwork.cs @@ -65,10 +65,13 @@ internal MySqlFlexibleServerNetwork(MySqlFlexibleServerEnableStatusEnum? publicN } /// Whether or not public network access is allowed for this server. Value is 'Disabled' when server has VNet integration. + [WirePath("publicNetworkAccess")] public MySqlFlexibleServerEnableStatusEnum? PublicNetworkAccess { get; set; } /// Delegated subnet resource id used to setup vnet for a server. + [WirePath("delegatedSubnetResourceId")] public ResourceIdentifier DelegatedSubnetResourceId { get; set; } /// Private DNS zone resource id. + [WirePath("privateDnsZoneResourceId")] public ResourceIdentifier PrivateDnsZoneResourceId { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerPatch.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerPatch.cs index cb41582915bf4..7411d34aaf291 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerPatch.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerPatch.cs @@ -85,28 +85,40 @@ internal MySqlFlexibleServerPatch(ManagedServiceIdentity identity, MySqlFlexible } /// The cmk identity for the server. Current supported identity types: UserAssigned. + [WirePath("identity")] public ManagedServiceIdentity Identity { get; set; } /// The SKU (pricing tier) of the server. + [WirePath("sku")] public MySqlFlexibleServerSku Sku { get; set; } /// Application-specific metadata in the form of key-value pairs. + [WirePath("tags")] public IDictionary Tags { get; } /// The password of the administrator login. + [WirePath("properties.administratorLoginPassword")] public string AdministratorLoginPassword { get; set; } /// Server version. + [WirePath("properties.version")] public MySqlFlexibleServerVersion? Version { get; set; } /// Storage related properties of a server. + [WirePath("properties.storage")] public MySqlFlexibleServerStorage Storage { get; set; } /// Backup related properties of a server. + [WirePath("properties.backup")] public MySqlFlexibleServerBackupProperties Backup { get; set; } /// High availability related properties of a server. + [WirePath("properties.highAvailability")] public MySqlFlexibleServerHighAvailability HighAvailability { get; set; } /// Maintenance window of a server. + [WirePath("properties.maintenanceWindow")] public MySqlFlexibleServerMaintenanceWindow MaintenanceWindow { get; set; } /// The replication role of the server. + [WirePath("properties.replicationRole")] public MySqlFlexibleServerReplicationRole? ReplicationRole { get; set; } /// The Data Encryption for CMK. + [WirePath("properties.dataEncryption")] public MySqlFlexibleServerDataEncryption DataEncryption { get; set; } /// Network related properties of a server. + [WirePath("properties.network")] public MySqlFlexibleServerNetwork Network { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerPrivateDnsZoneSuffixResponse.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerPrivateDnsZoneSuffixResponse.Serialization.cs index d1c22c3ee78a9..7d1f9ffb5ff2d 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerPrivateDnsZoneSuffixResponse.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerPrivateDnsZoneSuffixResponse.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.FlexibleServers.Models @@ -89,6 +91,85 @@ internal static MySqlFlexibleServerPrivateDnsZoneSuffixResponse DeserializeMySql return new MySqlFlexibleServerPrivateDnsZoneSuffixResponse(privateDnsZoneSuffix, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateDnsZoneSuffix), out propertyOverride); + if (Optional.IsDefined(PrivateDnsZoneSuffix) || hasPropertyOverride) + { + builder.Append(" privateDnsZoneSuffix: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (PrivateDnsZoneSuffix.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{PrivateDnsZoneSuffix}'''"); + } + else + { + builder.AppendLine($"'{PrivateDnsZoneSuffix}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -97,6 +178,8 @@ BinaryData IPersistableModel.Wr { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerPrivateDnsZoneSuffixResponse)} does not support '{options.Format}' format."); } @@ -113,6 +196,8 @@ MySqlFlexibleServerPrivateDnsZoneSuffixResponse IPersistableModel Represents the private DNS zone suffix. + [WirePath("privateDnsZoneSuffix")] public string PrivateDnsZoneSuffix { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerRestartParameter.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerRestartParameter.cs index 58b7e839bdc1c..5e50d076ceff7 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerRestartParameter.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerRestartParameter.cs @@ -62,8 +62,10 @@ internal MySqlFlexibleServerRestartParameter(MySqlFlexibleServerEnableStatusEnum } /// Whether or not failover to standby server when restarting a server with high availability enabled. + [WirePath("restartWithFailover")] public MySqlFlexibleServerEnableStatusEnum? RestartWithFailover { get; set; } /// The maximum allowed failover time in seconds. + [WirePath("maxFailoverSeconds")] public int? MaxFailoverSeconds { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerServerVersionCapability.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerServerVersionCapability.Serialization.cs index ad6f741cb0cba..3eefcfb68bdb3 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerServerVersionCapability.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerServerVersionCapability.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.FlexibleServers.Models @@ -114,6 +117,107 @@ internal static MySqlFlexibleServerServerVersionCapability DeserializeMySqlFlexi return new MySqlFlexibleServerServerVersionCapability(name, supportedSkus ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SupportedSkus), out propertyOverride); + if (Optional.IsCollectionDefined(SupportedSkus) || hasPropertyOverride) + { + if (SupportedSkus.Any() || hasPropertyOverride) + { + builder.Append(" supportedSkus: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in SupportedSkus) + { + AppendChildObject(builder, item, options, 4, true, " supportedSkus: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -122,6 +226,8 @@ BinaryData IPersistableModel.Write(M { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerServerVersionCapability)} does not support '{options.Format}' format."); } @@ -138,6 +244,8 @@ MySqlFlexibleServerServerVersionCapability IPersistableModel server version. + [WirePath("name")] public string Name { get; } /// A list of supported Skus. + [WirePath("supportedSkus")] public IReadOnlyList SupportedSkus { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerSku.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerSku.Serialization.cs index 4f606679aa738..3a0211bf6dafd 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerSku.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerSku.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.FlexibleServers.Models { @@ -93,6 +96,96 @@ internal static MySqlFlexibleServerSku DeserializeMySqlFlexibleServerSku(JsonEle return new MySqlFlexibleServerSku(name, tier, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tier), out propertyOverride); + builder.Append(" tier: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Tier.ToString()}'"); + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -101,6 +194,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerSku)} does not support '{options.Format}' format."); } @@ -117,6 +212,8 @@ MySqlFlexibleServerSku IPersistableModel.Create(BinaryDa using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlFlexibleServerSku(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerSku)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerSku.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerSku.cs index 4c149795a94fe..9b9d56b349c9e 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerSku.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerSku.cs @@ -75,8 +75,10 @@ internal MySqlFlexibleServerSku() } /// The name of the sku, e.g. Standard_D32s_v3. + [WirePath("name")] public string Name { get; set; } /// The tier of the particular SKU, e.g. GeneralPurpose. + [WirePath("tier")] public MySqlFlexibleServerSkuTier Tier { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerSkuCapability.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerSkuCapability.Serialization.cs index c65190832d0ab..4f277ce9f5980 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerSkuCapability.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerSkuCapability.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.FlexibleServers.Models @@ -134,6 +136,127 @@ internal static MySqlFlexibleServerSkuCapability DeserializeMySqlFlexibleServerS return new MySqlFlexibleServerSkuCapability(name, vCores, supportedIops, supportedMemoryPerVCoreMB, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VCores), out propertyOverride); + if (Optional.IsDefined(VCores) || hasPropertyOverride) + { + builder.Append(" vCores: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{VCores.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SupportedIops), out propertyOverride); + if (Optional.IsDefined(SupportedIops) || hasPropertyOverride) + { + builder.Append(" supportedIops: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SupportedIops.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SupportedMemoryPerVCoreInMB), out propertyOverride); + if (Optional.IsDefined(SupportedMemoryPerVCoreInMB) || hasPropertyOverride) + { + builder.Append(" supportedMemoryPerVCoreMB: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SupportedMemoryPerVCoreInMB.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -142,6 +265,8 @@ BinaryData IPersistableModel.Write(ModelReader { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerSkuCapability)} does not support '{options.Format}' format."); } @@ -158,6 +283,8 @@ MySqlFlexibleServerSkuCapability IPersistableModel vCore name. + [WirePath("name")] public string Name { get; } /// supported vCores. + [WirePath("vCores")] public long? VCores { get; } /// supported IOPS. + [WirePath("supportedIops")] public long? SupportedIops { get; } /// supported memory per vCore in MB. + [WirePath("supportedMemoryPerVCoreMB")] public long? SupportedMemoryPerVCoreInMB { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerStorage.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerStorage.Serialization.cs index 2f43d9c9d7091..b9251ddb91d04 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerStorage.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerStorage.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.FlexibleServers.Models @@ -171,6 +173,155 @@ internal static MySqlFlexibleServerStorage DeserializeMySqlFlexibleServerStorage serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageSizeInGB), out propertyOverride); + if (Optional.IsDefined(StorageSizeInGB) || hasPropertyOverride) + { + builder.Append(" storageSizeGB: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{StorageSizeInGB.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Iops), out propertyOverride); + if (Optional.IsDefined(Iops) || hasPropertyOverride) + { + builder.Append(" iops: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{Iops.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AutoGrow), out propertyOverride); + if (Optional.IsDefined(AutoGrow) || hasPropertyOverride) + { + builder.Append(" autoGrow: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{AutoGrow.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(LogOnDisk), out propertyOverride); + if (Optional.IsDefined(LogOnDisk) || hasPropertyOverride) + { + builder.Append(" logOnDisk: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{LogOnDisk.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StorageSku), out propertyOverride); + if (Optional.IsDefined(StorageSku) || hasPropertyOverride) + { + builder.Append(" storageSku: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (StorageSku.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{StorageSku}'''"); + } + else + { + builder.AppendLine($"'{StorageSku}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AutoIoScaling), out propertyOverride); + if (Optional.IsDefined(AutoIoScaling) || hasPropertyOverride) + { + builder.Append(" autoIoScaling: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{AutoIoScaling.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -179,6 +330,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriter { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerStorage)} does not support '{options.Format}' format."); } @@ -195,6 +348,8 @@ MySqlFlexibleServerStorage IPersistableModel.Create( using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlFlexibleServerStorage(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerStorage)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerStorage.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerStorage.cs index 28fdc98c2c477..c8ad478a22de1 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerStorage.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerStorage.cs @@ -70,16 +70,22 @@ internal MySqlFlexibleServerStorage(int? storageSizeInGB, int? iops, MySqlFlexib } /// Max storage size allowed for a server. + [WirePath("storageSizeGB")] public int? StorageSizeInGB { get; set; } /// Storage IOPS for a server. + [WirePath("iops")] public int? Iops { get; set; } /// Enable Storage Auto Grow or not. + [WirePath("autoGrow")] public MySqlFlexibleServerEnableStatusEnum? AutoGrow { get; set; } /// Enable Log On Disk or not. + [WirePath("logOnDisk")] public MySqlFlexibleServerEnableStatusEnum? LogOnDisk { get; set; } /// The sku name of the server storage. + [WirePath("storageSku")] public string StorageSku { get; } /// Enable IO Auto Scaling or not. + [WirePath("autoIoScaling")] public MySqlFlexibleServerEnableStatusEnum? AutoIoScaling { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerStorageEditionCapability.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerStorageEditionCapability.Serialization.cs index a6a881a500259..f4926a3b0f88b 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerStorageEditionCapability.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerStorageEditionCapability.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.FlexibleServers.Models @@ -155,6 +157,141 @@ internal static MySqlFlexibleServerStorageEditionCapability DeserializeMySqlFlex serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinStorageSize), out propertyOverride); + if (Optional.IsDefined(MinStorageSize) || hasPropertyOverride) + { + builder.Append(" minStorageSize: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{MinStorageSize.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaxStorageSize), out propertyOverride); + if (Optional.IsDefined(MaxStorageSize) || hasPropertyOverride) + { + builder.Append(" maxStorageSize: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{MaxStorageSize.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MinBackupRetentionDays), out propertyOverride); + if (Optional.IsDefined(MinBackupRetentionDays) || hasPropertyOverride) + { + builder.Append(" minBackupRetentionDays: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{MinBackupRetentionDays.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaxBackupRetentionDays), out propertyOverride); + if (Optional.IsDefined(MaxBackupRetentionDays) || hasPropertyOverride) + { + builder.Append(" maxBackupRetentionDays: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{MaxBackupRetentionDays.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -163,6 +300,8 @@ BinaryData IPersistableModel.Write( { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerStorageEditionCapability)} does not support '{options.Format}' format."); } @@ -179,6 +318,8 @@ MySqlFlexibleServerStorageEditionCapability IPersistableModel storage edition name. + [WirePath("name")] public string Name { get; } /// The minimal supported storage size. + [WirePath("minStorageSize")] public long? MinStorageSize { get; } /// The maximum supported storage size. + [WirePath("maxStorageSize")] public long? MaxStorageSize { get; } /// Minimal backup retention days. + [WirePath("minBackupRetentionDays")] public long? MinBackupRetentionDays { get; } /// Maximum backup retention days. + [WirePath("maxBackupRetentionDays")] public long? MaxBackupRetentionDays { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerValidateBackupResult.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerValidateBackupResult.Serialization.cs index 8bd6a15d694e5..b13a680b102e3 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerValidateBackupResult.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerValidateBackupResult.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.FlexibleServers.Models @@ -108,6 +110,80 @@ internal static MySqlFlexibleServerValidateBackupResult DeserializeMySqlFlexible return new MySqlFlexibleServerValidateBackupResult(numberOfContainers, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NumberOfContainers), out propertyOverride); + if (Optional.IsDefined(NumberOfContainers) || hasPropertyOverride) + { + builder.Append(" numberOfContainers: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{NumberOfContainers.Value}"); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -116,6 +192,8 @@ BinaryData IPersistableModel.Write(Mode { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerValidateBackupResult)} does not support '{options.Format}' format."); } @@ -132,6 +210,8 @@ MySqlFlexibleServerValidateBackupResult IPersistableModel Estimated no of storage containers required for resource data to be backed up. + [WirePath("properties.numberOfContainers")] public int? NumberOfContainers { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerVirtualNetworkSubnetUsageParameter.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerVirtualNetworkSubnetUsageParameter.cs index 7cce281eb414a..8df382f2f8deb 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerVirtualNetworkSubnetUsageParameter.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerVirtualNetworkSubnetUsageParameter.cs @@ -61,6 +61,7 @@ internal MySqlFlexibleServerVirtualNetworkSubnetUsageParameter(ResourceIdentifie } /// Virtual network resource id. + [WirePath("virtualNetworkResourceId")] public ResourceIdentifier VirtualNetworkResourceId { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerVirtualNetworkSubnetUsageResult.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerVirtualNetworkSubnetUsageResult.Serialization.cs index 63a6064417433..3279f4df4c6b0 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerVirtualNetworkSubnetUsageResult.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServerVirtualNetworkSubnetUsageResult.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.FlexibleServers.Models @@ -129,6 +132,121 @@ internal static MySqlFlexibleServerVirtualNetworkSubnetUsageResult DeserializeMy return new MySqlFlexibleServerVirtualNetworkSubnetUsageResult(location, subscriptionId, delegatedSubnetsUsage ?? new ChangeTrackingList(), serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); + if (Optional.IsDefined(Location) || hasPropertyOverride) + { + builder.Append(" location: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Location.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SubscriptionId), out propertyOverride); + if (Optional.IsDefined(SubscriptionId) || hasPropertyOverride) + { + builder.Append(" subscriptionId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (SubscriptionId.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{SubscriptionId}'''"); + } + else + { + builder.AppendLine($"'{SubscriptionId}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DelegatedSubnetsUsage), out propertyOverride); + if (Optional.IsCollectionDefined(DelegatedSubnetsUsage) || hasPropertyOverride) + { + if (DelegatedSubnetsUsage.Any() || hasPropertyOverride) + { + builder.Append(" delegatedSubnetsUsage: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in DelegatedSubnetsUsage) + { + AppendChildObject(builder, item, options, 4, true, " delegatedSubnetsUsage: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -137,6 +255,8 @@ BinaryData IPersistableModel { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerVirtualNetworkSubnetUsageResult)} does not support '{options.Format}' format."); } @@ -153,6 +273,8 @@ MySqlFlexibleServerVirtualNetworkSubnetUsageResult IPersistableModel The location name. + [WirePath("location")] public AzureLocation? Location { get; } /// The subscription id. + [WirePath("subscriptionId")] public string SubscriptionId { get; } /// A list of delegated subnet usage. + [WirePath("delegatedSubnetsUsage")] public IReadOnlyList DelegatedSubnetsUsage { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServersPrivateEndpointConnection.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServersPrivateEndpointConnection.Serialization.cs index 5482b8e3e65a0..4a44419b15a56 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServersPrivateEndpointConnection.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServersPrivateEndpointConnection.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; using Azure.ResourceManager.MySql; using Azure.ResourceManager.Resources.Models; @@ -222,6 +225,193 @@ internal static MySqlFlexibleServersPrivateEndpointConnection DeserializeMySqlFl serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(GroupIds), out propertyOverride); + if (Optional.IsCollectionDefined(GroupIds) || hasPropertyOverride) + { + if (GroupIds.Any() || hasPropertyOverride) + { + builder.Append(" groupIds: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in GroupIds) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateEndpoint), out propertyOverride); + if (Optional.IsDefined(PrivateEndpoint) || hasPropertyOverride) + { + builder.Append(" privateEndpoint: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, PrivateEndpoint, options, 4, false, " privateEndpoint: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ConnectionState), out propertyOverride); + if (Optional.IsDefined(ConnectionState) || hasPropertyOverride) + { + builder.Append(" privateLinkServiceConnectionState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, ConnectionState, options, 4, false, " privateLinkServiceConnectionState: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); + if (Optional.IsDefined(ProvisioningState) || hasPropertyOverride) + { + builder.Append(" provisioningState: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -230,6 +420,8 @@ BinaryData IPersistableModel.Writ { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServersPrivateEndpointConnection)} does not support '{options.Format}' format."); } @@ -246,6 +438,8 @@ MySqlFlexibleServersPrivateEndpointConnection IPersistableModel The group ids for the private endpoint resource. + [WirePath("properties.groupIds")] public IReadOnlyList GroupIds { get; } /// The private endpoint resource. internal SubResource PrivateEndpoint { get; set; } /// Gets Id. + [WirePath("properties.privateEndpoint.id")] public ResourceIdentifier PrivateEndpointId { get => PrivateEndpoint is null ? default : PrivateEndpoint.Id; } /// A collection of information about the state of the connection between service consumer and provider. + [WirePath("properties.privateLinkServiceConnectionState")] public MySqlFlexibleServersPrivateLinkServiceConnectionState ConnectionState { get; set; } /// The provisioning state of the private endpoint connection resource. + [WirePath("properties.provisioningState")] public MySqlFlexibleServersPrivateEndpointConnectionProvisioningState? ProvisioningState { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServersPrivateLinkServiceConnectionState.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServersPrivateLinkServiceConnectionState.Serialization.cs index 19a450d04cd0f..f070a93e7efc5 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServersPrivateLinkServiceConnectionState.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/MySqlFlexibleServersPrivateLinkServiceConnectionState.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.FlexibleServers.Models @@ -115,6 +117,121 @@ internal static MySqlFlexibleServersPrivateLinkServiceConnectionState Deserializ return new MySqlFlexibleServersPrivateLinkServiceConnectionState(status, description, actionsRequired, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); + if (Optional.IsDefined(Status) || hasPropertyOverride) + { + builder.Append(" status: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Status.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); + if (Optional.IsDefined(Description) || hasPropertyOverride) + { + builder.Append(" description: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Description.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Description}'''"); + } + else + { + builder.AppendLine($"'{Description}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ActionsRequired), out propertyOverride); + if (Optional.IsDefined(ActionsRequired) || hasPropertyOverride) + { + builder.Append(" actionsRequired: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (ActionsRequired.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ActionsRequired}'''"); + } + else + { + builder.AppendLine($"'{ActionsRequired}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -123,6 +240,8 @@ BinaryData IPersistableModel Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service. + [WirePath("status")] public MySqlFlexibleServersPrivateEndpointServiceConnectionStatus? Status { get; set; } /// The reason for approval/rejection of the connection. + [WirePath("description")] public string Description { get; set; } /// A message indicating if changes on the service provider require any updates on the consumer. + [WirePath("actionsRequired")] public string ActionsRequired { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/OperationStatusExtendedResult.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/OperationStatusExtendedResult.Serialization.cs index 6b033737fa632..89bd2c75c62b5 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/OperationStatusExtendedResult.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/OperationStatusExtendedResult.Serialization.cs @@ -8,9 +8,12 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.FlexibleServers.Models @@ -269,6 +272,243 @@ internal static OperationStatusExtendedResult DeserializeOperationStatusExtended properties ?? new ChangeTrackingDictionary()); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); + if (Optional.IsCollectionDefined(Properties) || hasPropertyOverride) + { + if (Properties.Any() || hasPropertyOverride) + { + builder.Append(" properties: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in Properties) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + builder.AppendLine($"'{item.Value.ToString()}'"); + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceId), out propertyOverride); + if (Optional.IsDefined(ResourceId) || hasPropertyOverride) + { + builder.Append(" resourceId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ResourceId.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); + if (Optional.IsDefined(Status) || hasPropertyOverride) + { + builder.Append(" status: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Status.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Status}'''"); + } + else + { + builder.AppendLine($"'{Status}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PercentComplete), out propertyOverride); + if (Optional.IsDefined(PercentComplete) || hasPropertyOverride) + { + builder.Append(" percentComplete: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{PercentComplete.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); + if (Optional.IsDefined(StartOn) || hasPropertyOverride) + { + builder.Append(" startTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndOn), out propertyOverride); + if (Optional.IsDefined(EndOn) || hasPropertyOverride) + { + builder.Append(" endTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(EndOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Operations), out propertyOverride); + if (Optional.IsCollectionDefined(Operations) || hasPropertyOverride) + { + if (Operations.Any() || hasPropertyOverride) + { + builder.Append(" operations: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Operations) + { + AppendChildObject(builder, item, options, 4, true, " operations: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Error), out propertyOverride); + if (Optional.IsDefined(Error) || hasPropertyOverride) + { + builder.Append(" error: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Error, options, 2, false, " error: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -277,6 +517,8 @@ BinaryData IPersistableModel.Write(ModelReaderWri { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationStatusExtendedResult)} does not support '{options.Format}' format."); } @@ -293,6 +535,8 @@ OperationStatusExtendedResult IPersistableModel.C using JsonDocument document = JsonDocument.Parse(data); return DeserializeOperationStatusExtendedResult(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(OperationStatusExtendedResult)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/OperationStatusExtendedResult.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/OperationStatusExtendedResult.cs index 3e938d1a6ea25..8349819e2b54a 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/OperationStatusExtendedResult.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/OperationStatusExtendedResult.cs @@ -78,6 +78,7 @@ internal OperationStatusExtendedResult() /// /// /// + [WirePath("properties")] public IReadOnlyDictionary Properties { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/OperationStatusResult.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/OperationStatusResult.Serialization.cs index ad2ed133352da..21d30a5e575e0 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/OperationStatusResult.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/OperationStatusResult.Serialization.cs @@ -8,9 +8,12 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.FlexibleServers.Models @@ -223,6 +226,215 @@ internal static OperationStatusResult DeserializeOperationStatusResult(JsonEleme serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceId), out propertyOverride); + if (Optional.IsDefined(ResourceId) || hasPropertyOverride) + { + builder.Append(" resourceId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ResourceId.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Status), out propertyOverride); + if (Optional.IsDefined(Status) || hasPropertyOverride) + { + builder.Append(" status: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Status.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Status}'''"); + } + else + { + builder.AppendLine($"'{Status}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PercentComplete), out propertyOverride); + if (Optional.IsDefined(PercentComplete) || hasPropertyOverride) + { + builder.Append(" percentComplete: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{PercentComplete.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartOn), out propertyOverride); + if (Optional.IsDefined(StartOn) || hasPropertyOverride) + { + builder.Append(" startTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(StartOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndOn), out propertyOverride); + if (Optional.IsDefined(EndOn) || hasPropertyOverride) + { + builder.Append(" endTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(EndOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Operations), out propertyOverride); + if (Optional.IsCollectionDefined(Operations) || hasPropertyOverride) + { + if (Operations.Any() || hasPropertyOverride) + { + builder.Append(" operations: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in Operations) + { + AppendChildObject(builder, item, options, 4, true, " operations: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Error), out propertyOverride); + if (Optional.IsDefined(Error) || hasPropertyOverride) + { + builder.Append(" error: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Error, options, 2, false, " error: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -231,6 +443,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(OperationStatusResult)} does not support '{options.Format}' format."); } @@ -247,6 +461,8 @@ OperationStatusResult IPersistableModel.Create(BinaryData using JsonDocument document = JsonDocument.Parse(data); return DeserializeOperationStatusResult(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(OperationStatusResult)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/OperationStatusResult.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/OperationStatusResult.cs index 82218fb2b6bb9..fa471994f981a 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/OperationStatusResult.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/OperationStatusResult.cs @@ -90,22 +90,31 @@ internal OperationStatusResult() } /// Fully qualified ID for the async operation. + [WirePath("id")] public ResourceIdentifier Id { get; } /// Fully qualified ID of the resource against which the original async operation was started. + [WirePath("resourceId")] public ResourceIdentifier ResourceId { get; } /// Name of the async operation. + [WirePath("name")] public string Name { get; } /// Operation status. + [WirePath("status")] public string Status { get; } /// Percent of the operation that is complete. + [WirePath("percentComplete")] public float? PercentComplete { get; } /// The start time of the operation. + [WirePath("startTime")] public DateTimeOffset? StartOn { get; } /// The end time of the operation. + [WirePath("endTime")] public DateTimeOffset? EndOn { get; } /// The operations list. + [WirePath("operations")] public IReadOnlyList Operations { get; } /// If present, details of the operation error. + [WirePath("error")] public ResponseError Error { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/ServerEditionCapabilityV2.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/ServerEditionCapabilityV2.Serialization.cs index 7a6a4aa75a8b5..fecf6b622cc87 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/ServerEditionCapabilityV2.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/ServerEditionCapabilityV2.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.FlexibleServers.Models @@ -171,6 +174,165 @@ internal static ServerEditionCapabilityV2 DeserializeServerEditionCapabilityV2(J serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultSku), out propertyOverride); + if (Optional.IsDefined(DefaultSku) || hasPropertyOverride) + { + builder.Append(" defaultSku: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (DefaultSku.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{DefaultSku}'''"); + } + else + { + builder.AppendLine($"'{DefaultSku}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultStorageSize), out propertyOverride); + if (Optional.IsDefined(DefaultStorageSize) || hasPropertyOverride) + { + builder.Append(" defaultStorageSize: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{DefaultStorageSize.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SupportedStorageEditions), out propertyOverride); + if (Optional.IsCollectionDefined(SupportedStorageEditions) || hasPropertyOverride) + { + if (SupportedStorageEditions.Any() || hasPropertyOverride) + { + builder.Append(" supportedStorageEditions: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in SupportedStorageEditions) + { + AppendChildObject(builder, item, options, 4, true, " supportedStorageEditions: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SupportedSkus), out propertyOverride); + if (Optional.IsCollectionDefined(SupportedSkus) || hasPropertyOverride) + { + if (SupportedSkus.Any() || hasPropertyOverride) + { + builder.Append(" supportedSkus: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in SupportedSkus) + { + AppendChildObject(builder, item, options, 4, true, " supportedSkus: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -179,6 +341,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterO { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ServerEditionCapabilityV2)} does not support '{options.Format}' format."); } @@ -195,6 +359,8 @@ ServerEditionCapabilityV2 IPersistableModel.Create(Bi using JsonDocument document = JsonDocument.Parse(data); return DeserializeServerEditionCapabilityV2(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ServerEditionCapabilityV2)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/ServerEditionCapabilityV2.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/ServerEditionCapabilityV2.cs index dd720da3e5900..a071d728fafe6 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/ServerEditionCapabilityV2.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/ServerEditionCapabilityV2.cs @@ -71,14 +71,19 @@ internal ServerEditionCapabilityV2(string name, string defaultSku, int? defaultS } /// Server edition name. + [WirePath("name")] public string Name { get; } /// Default Sku name. + [WirePath("defaultSku")] public string DefaultSku { get; } /// Default storage size. + [WirePath("defaultStorageSize")] public int? DefaultStorageSize { get; } /// A list of supported storage editions. + [WirePath("supportedStorageEditions")] public IReadOnlyList SupportedStorageEditions { get; } /// A list of supported Skus. + [WirePath("supportedSkus")] public IReadOnlyList SupportedSkus { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/ServerVersionCapabilityV2.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/ServerVersionCapabilityV2.Serialization.cs index 92d59e0005bca..38d6a7b98e7b6 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/ServerVersionCapabilityV2.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/ServerVersionCapabilityV2.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.FlexibleServers.Models @@ -89,6 +91,85 @@ internal static ServerVersionCapabilityV2 DeserializeServerVersionCapabilityV2(J return new ServerVersionCapabilityV2(name, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -97,6 +178,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterO { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(ServerVersionCapabilityV2)} does not support '{options.Format}' format."); } @@ -113,6 +196,8 @@ ServerVersionCapabilityV2 IPersistableModel.Create(Bi using JsonDocument document = JsonDocument.Parse(data); return DeserializeServerVersionCapabilityV2(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(ServerVersionCapabilityV2)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/ServerVersionCapabilityV2.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/ServerVersionCapabilityV2.cs index 1f54f627ff0db..e4780d64b7c68 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/ServerVersionCapabilityV2.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/ServerVersionCapabilityV2.cs @@ -60,6 +60,7 @@ internal ServerVersionCapabilityV2(string name, IDictionary } /// server version. + [WirePath("name")] public string Name { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/SkuCapabilityV2.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/SkuCapabilityV2.Serialization.cs index 2ad3cff98719e..1190401976d8d 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/SkuCapabilityV2.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/SkuCapabilityV2.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MySql; namespace Azure.ResourceManager.MySql.FlexibleServers.Models @@ -191,6 +194,197 @@ internal static SkuCapabilityV2 DeserializeSkuCapabilityV2(JsonElement element, serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(VCores), out propertyOverride); + if (Optional.IsDefined(VCores) || hasPropertyOverride) + { + builder.Append(" vCores: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{VCores.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SupportedIops), out propertyOverride); + if (Optional.IsDefined(SupportedIops) || hasPropertyOverride) + { + builder.Append(" supportedIops: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SupportedIops.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SupportedMemoryPerVCoreMB), out propertyOverride); + if (Optional.IsDefined(SupportedMemoryPerVCoreMB) || hasPropertyOverride) + { + builder.Append(" supportedMemoryPerVCoreMB: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SupportedMemoryPerVCoreMB.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SupportedZones), out propertyOverride); + if (Optional.IsCollectionDefined(SupportedZones) || hasPropertyOverride) + { + if (SupportedZones.Any() || hasPropertyOverride) + { + builder.Append(" supportedZones: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in SupportedZones) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SupportedHAMode), out propertyOverride); + if (Optional.IsCollectionDefined(SupportedHAMode) || hasPropertyOverride) + { + if (SupportedHAMode.Any() || hasPropertyOverride) + { + builder.Append(" supportedHAMode: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in SupportedHAMode) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -199,6 +393,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions opt { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(SkuCapabilityV2)} does not support '{options.Format}' format."); } @@ -215,6 +411,8 @@ SkuCapabilityV2 IPersistableModel.Create(BinaryData data, Model using JsonDocument document = JsonDocument.Parse(data); return DeserializeSkuCapabilityV2(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(SkuCapabilityV2)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/SkuCapabilityV2.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/SkuCapabilityV2.cs index ef1a01201950e..042821c0d11ca 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/SkuCapabilityV2.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/Models/SkuCapabilityV2.cs @@ -73,16 +73,22 @@ internal SkuCapabilityV2(string name, long? vCores, long? supportedIops, long? s } /// vCore name. + [WirePath("name")] public string Name { get; } /// supported vCores. + [WirePath("vCores")] public long? VCores { get; } /// supported IOPS. + [WirePath("supportedIops")] public long? SupportedIops { get; } /// supported memory per vCore in MB. + [WirePath("supportedMemoryPerVCoreMB")] public long? SupportedMemoryPerVCoreMB { get; } /// Supported zones. + [WirePath("supportedZones")] public IReadOnlyList SupportedZones { get; } /// Supported high availability mode. + [WirePath("supportedHAMode")] public IReadOnlyList SupportedHAMode { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServerAadAdministratorData.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServerAadAdministratorData.Serialization.cs index c8f97475c2534..c7dc144cd60a2 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServerAadAdministratorData.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServerAadAdministratorData.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; using Azure.ResourceManager.MySql; using Azure.ResourceManager.MySql.FlexibleServers.Models; @@ -220,6 +222,202 @@ internal static MySqlFlexibleServerAadAdministratorData DeserializeMySqlFlexible serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AdministratorType), out propertyOverride); + if (Optional.IsDefined(AdministratorType) || hasPropertyOverride) + { + builder.Append(" administratorType: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{AdministratorType.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Login), out propertyOverride); + if (Optional.IsDefined(Login) || hasPropertyOverride) + { + builder.Append(" login: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Login.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Login}'''"); + } + else + { + builder.AppendLine($"'{Login}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sid), out propertyOverride); + if (Optional.IsDefined(Sid) || hasPropertyOverride) + { + builder.Append(" sid: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Sid.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Sid}'''"); + } + else + { + builder.AppendLine($"'{Sid}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(TenantId), out propertyOverride); + if (Optional.IsDefined(TenantId) || hasPropertyOverride) + { + builder.Append(" tenantId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{TenantId.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IdentityResourceId), out propertyOverride); + if (Optional.IsDefined(IdentityResourceId) || hasPropertyOverride) + { + builder.Append(" identityResourceId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{IdentityResourceId.ToString()}'"); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -228,6 +426,8 @@ BinaryData IPersistableModel.Write(Mode { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerAadAdministratorData)} does not support '{options.Format}' format."); } @@ -244,6 +444,8 @@ MySqlFlexibleServerAadAdministratorData IPersistableModel Type of the sever administrator. + [WirePath("properties.administratorType")] public MySqlFlexibleServerAdministratorType? AdministratorType { get; set; } /// Login name of the server administrator. + [WirePath("properties.login")] public string Login { get; set; } /// SID (object ID) of the server administrator. + [WirePath("properties.sid")] public string Sid { get; set; } /// Tenant ID of the administrator. + [WirePath("properties.tenantId")] public Guid? TenantId { get; set; } /// The resource id of the identity used for AAD Authentication. + [WirePath("properties.identityResourceId")] public ResourceIdentifier IdentityResourceId { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServerBackupData.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServerBackupData.Serialization.cs index 1cd6ad529ed9e..990d735e092b5 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServerBackupData.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServerBackupData.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; using Azure.ResourceManager.MySql; @@ -187,6 +189,175 @@ internal static MySqlFlexibleServerBackupData DeserializeMySqlFlexibleServerBack serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BackupType), out propertyOverride); + if (Optional.IsDefined(BackupType) || hasPropertyOverride) + { + builder.Append(" backupType: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (BackupType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{BackupType}'''"); + } + else + { + builder.AppendLine($"'{BackupType}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CompletedOn), out propertyOverride); + if (Optional.IsDefined(CompletedOn) || hasPropertyOverride) + { + builder.Append(" completedTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(CompletedOn.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Source), out propertyOverride); + if (Optional.IsDefined(Source) || hasPropertyOverride) + { + builder.Append(" source: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Source.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Source}'''"); + } + else + { + builder.AppendLine($"'{Source}'"); + } + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -195,6 +366,8 @@ BinaryData IPersistableModel.Write(ModelReaderWri { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerBackupData)} does not support '{options.Format}' format."); } @@ -211,6 +384,8 @@ MySqlFlexibleServerBackupData IPersistableModel.C using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlFlexibleServerBackupData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerBackupData)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServerBackupData.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServerBackupData.cs index 20af21d33c33f..3d27327230820 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServerBackupData.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServerBackupData.cs @@ -73,10 +73,13 @@ internal MySqlFlexibleServerBackupData(ResourceIdentifier id, string name, Resou } /// Backup type. + [WirePath("properties.backupType")] public string BackupType { get; set; } /// Backup completed time (ISO8601 format). + [WirePath("properties.completedTime")] public DateTimeOffset? CompletedOn { get; set; } /// Backup source. + [WirePath("properties.source")] public string Source { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServerConfigurationData.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServerConfigurationData.Serialization.cs index 3144020c07486..79c8daa3eb9af 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServerConfigurationData.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServerConfigurationData.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; using Azure.ResourceManager.MySql; using Azure.ResourceManager.MySql.FlexibleServers.Models; @@ -296,6 +298,326 @@ internal static MySqlFlexibleServerConfigurationData DeserializeMySqlFlexibleSer serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (Optional.IsDefined(Value) || hasPropertyOverride) + { + builder.Append(" value: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Value}'''"); + } + else + { + builder.AppendLine($"'{Value}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentValue), out propertyOverride); + if (Optional.IsDefined(CurrentValue) || hasPropertyOverride) + { + builder.Append(" currentValue: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (CurrentValue.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{CurrentValue}'''"); + } + else + { + builder.AppendLine($"'{CurrentValue}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); + if (Optional.IsDefined(Description) || hasPropertyOverride) + { + builder.Append(" description: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Description.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Description}'''"); + } + else + { + builder.AppendLine($"'{Description}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DocumentationLink), out propertyOverride); + if (Optional.IsDefined(DocumentationLink) || hasPropertyOverride) + { + builder.Append(" documentationLink: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (DocumentationLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{DocumentationLink}'''"); + } + else + { + builder.AppendLine($"'{DocumentationLink}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DefaultValue), out propertyOverride); + if (Optional.IsDefined(DefaultValue) || hasPropertyOverride) + { + builder.Append(" defaultValue: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (DefaultValue.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{DefaultValue}'''"); + } + else + { + builder.AppendLine($"'{DefaultValue}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DataType), out propertyOverride); + if (Optional.IsDefined(DataType) || hasPropertyOverride) + { + builder.Append(" dataType: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (DataType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{DataType}'''"); + } + else + { + builder.AppendLine($"'{DataType}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowedValues), out propertyOverride); + if (Optional.IsDefined(AllowedValues) || hasPropertyOverride) + { + builder.Append(" allowedValues: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (AllowedValues.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{AllowedValues}'''"); + } + else + { + builder.AppendLine($"'{AllowedValues}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Source), out propertyOverride); + if (Optional.IsDefined(Source) || hasPropertyOverride) + { + builder.Append(" source: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Source.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsReadOnly), out propertyOverride); + if (Optional.IsDefined(IsReadOnly) || hasPropertyOverride) + { + builder.Append(" isReadOnly: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{IsReadOnly.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsConfigPendingRestart), out propertyOverride); + if (Optional.IsDefined(IsConfigPendingRestart) || hasPropertyOverride) + { + builder.Append(" isConfigPendingRestart: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{IsConfigPendingRestart.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsDynamicConfig), out propertyOverride); + if (Optional.IsDefined(IsDynamicConfig) || hasPropertyOverride) + { + builder.Append(" isDynamicConfig: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{IsDynamicConfig.Value.ToString()}'"); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -304,6 +626,8 @@ BinaryData IPersistableModel.Write(ModelRe { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerConfigurationData)} does not support '{options.Format}' format."); } @@ -320,6 +644,8 @@ MySqlFlexibleServerConfigurationData IPersistableModel Value of the configuration. + [WirePath("properties.value")] public string Value { get; set; } /// Current value of the configuration. + [WirePath("properties.currentValue")] public string CurrentValue { get; set; } /// Description of the configuration. + [WirePath("properties.description")] public string Description { get; } /// The link used to get the document from community or Azure site. + [WirePath("properties.documentationLink")] public string DocumentationLink { get; } /// Default value of the configuration. + [WirePath("properties.defaultValue")] public string DefaultValue { get; } /// Data type of the configuration. + [WirePath("properties.dataType")] public string DataType { get; } /// Allowed values of the configuration. + [WirePath("properties.allowedValues")] public string AllowedValues { get; } /// Source of the configuration. + [WirePath("properties.source")] public MySqlFlexibleServerConfigurationSource? Source { get; set; } /// If is the configuration read only. + [WirePath("properties.isReadOnly")] public MySqlFlexibleServerConfigReadOnlyState? IsReadOnly { get; } /// If is the configuration pending restart or not. + [WirePath("properties.isConfigPendingRestart")] public MySqlFlexibleServerConfigPendingRestartState? IsConfigPendingRestart { get; } /// If is the configuration dynamic. + [WirePath("properties.isDynamicConfig")] public MySqlFlexibleServerConfigDynamicState? IsDynamicConfig { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServerData.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServerData.Serialization.cs index d595f894ec894..1dbff6083f168 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServerData.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServerData.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; using Azure.ResourceManager.MySql; using Azure.ResourceManager.MySql.FlexibleServers.Models; @@ -514,6 +517,498 @@ internal static MySqlFlexibleServerData DeserializeMySqlFlexibleServerData(JsonE serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); + builder.Append(" location: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Location.ToString()}'"); + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (Optional.IsCollectionDefined(Tags) || hasPropertyOverride) + { + if (Tags.Any() || hasPropertyOverride) + { + builder.Append(" tags: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Identity), out propertyOverride); + if (Optional.IsDefined(Identity) || hasPropertyOverride) + { + builder.Append(" identity: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Identity, options, 2, false, " identity: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); + if (Optional.IsDefined(Sku) || hasPropertyOverride) + { + builder.Append(" sku: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Sku, options, 2, false, " sku: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AdministratorLogin), out propertyOverride); + if (Optional.IsDefined(AdministratorLogin) || hasPropertyOverride) + { + builder.Append(" administratorLogin: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (AdministratorLogin.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{AdministratorLogin}'''"); + } + else + { + builder.AppendLine($"'{AdministratorLogin}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AdministratorLoginPassword), out propertyOverride); + if (Optional.IsDefined(AdministratorLoginPassword) || hasPropertyOverride) + { + builder.Append(" administratorLoginPassword: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (AdministratorLoginPassword.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{AdministratorLoginPassword}'''"); + } + else + { + builder.AppendLine($"'{AdministratorLoginPassword}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Version), out propertyOverride); + if (Optional.IsDefined(Version) || hasPropertyOverride) + { + builder.Append(" version: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Version.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AvailabilityZone), out propertyOverride); + if (Optional.IsDefined(AvailabilityZone) || hasPropertyOverride) + { + builder.Append(" availabilityZone: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (AvailabilityZone.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{AvailabilityZone}'''"); + } + else + { + builder.AppendLine($"'{AvailabilityZone}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CreateMode), out propertyOverride); + if (Optional.IsDefined(CreateMode) || hasPropertyOverride) + { + builder.Append(" createMode: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{CreateMode.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SourceServerResourceId), out propertyOverride); + if (Optional.IsDefined(SourceServerResourceId) || hasPropertyOverride) + { + builder.Append(" sourceServerResourceId: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SourceServerResourceId.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RestorePointInTime), out propertyOverride); + if (Optional.IsDefined(RestorePointInTime) || hasPropertyOverride) + { + builder.Append(" restorePointInTime: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + var formattedDateTimeString = TypeFormatters.ToString(RestorePointInTime.Value, "o"); + builder.AppendLine($"'{formattedDateTimeString}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReplicationRole), out propertyOverride); + if (Optional.IsDefined(ReplicationRole) || hasPropertyOverride) + { + builder.Append(" replicationRole: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{ReplicationRole.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ReplicaCapacity), out propertyOverride); + if (Optional.IsDefined(ReplicaCapacity) || hasPropertyOverride) + { + builder.Append(" replicaCapacity: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"{ReplicaCapacity.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DataEncryption), out propertyOverride); + if (Optional.IsDefined(DataEncryption) || hasPropertyOverride) + { + builder.Append(" dataEncryption: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, DataEncryption, options, 4, false, " dataEncryption: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); + if (Optional.IsDefined(State) || hasPropertyOverride) + { + builder.Append(" state: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{State.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FullyQualifiedDomainName), out propertyOverride); + if (Optional.IsDefined(FullyQualifiedDomainName) || hasPropertyOverride) + { + builder.Append(" fullyQualifiedDomainName: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (FullyQualifiedDomainName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{FullyQualifiedDomainName}'''"); + } + else + { + builder.AppendLine($"'{FullyQualifiedDomainName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Storage), out propertyOverride); + if (Optional.IsDefined(Storage) || hasPropertyOverride) + { + builder.Append(" storage: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Storage, options, 4, false, " storage: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Backup), out propertyOverride); + if (Optional.IsDefined(Backup) || hasPropertyOverride) + { + builder.Append(" backup: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Backup, options, 4, false, " backup: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(HighAvailability), out propertyOverride); + if (Optional.IsDefined(HighAvailability) || hasPropertyOverride) + { + builder.Append(" highAvailability: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, HighAvailability, options, 4, false, " highAvailability: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Network), out propertyOverride); + if (Optional.IsDefined(Network) || hasPropertyOverride) + { + builder.Append(" network: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, Network, options, 4, false, " network: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateEndpointConnections), out propertyOverride); + if (Optional.IsCollectionDefined(PrivateEndpointConnections) || hasPropertyOverride) + { + if (PrivateEndpointConnections.Any() || hasPropertyOverride) + { + builder.Append(" privateEndpointConnections: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in PrivateEndpointConnections) + { + AppendChildObject(builder, item, options, 6, true, " privateEndpointConnections: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MaintenanceWindow), out propertyOverride); + if (Optional.IsDefined(MaintenanceWindow) || hasPropertyOverride) + { + builder.Append(" maintenanceWindow: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, MaintenanceWindow, options, 4, false, " maintenanceWindow: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ImportSourceProperties), out propertyOverride); + if (Optional.IsDefined(ImportSourceProperties) || hasPropertyOverride) + { + builder.Append(" importSourceProperties: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + AppendChildObject(builder, ImportSourceProperties, options, 4, false, " importSourceProperties: "); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -522,6 +1017,8 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpt { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerData)} does not support '{options.Format}' format."); } @@ -538,6 +1035,8 @@ MySqlFlexibleServerData IPersistableModel.Create(Binary using JsonDocument document = JsonDocument.Parse(data); return DeserializeMySqlFlexibleServerData(document.RootElement, options); } + case "bicep": + throw new InvalidOperationException("Bicep deserialization is not supported for this type."); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerData)} does not support '{options.Format}' format."); } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServerData.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServerData.cs index 49c77d7d87594..46f98175d1eaa 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServerData.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServerData.cs @@ -120,46 +120,67 @@ internal MySqlFlexibleServerData() } /// The cmk identity for the server. Current supported identity types: UserAssigned. + [WirePath("identity")] public ManagedServiceIdentity Identity { get; set; } /// The SKU (pricing tier) of the server. + [WirePath("sku")] public MySqlFlexibleServerSku Sku { get; set; } /// The administrator's login name of a server. Can only be specified when the server is being created (and is required for creation). + [WirePath("properties.administratorLogin")] public string AdministratorLogin { get; set; } /// The password of the administrator login (required for server creation). + [WirePath("properties.administratorLoginPassword")] public string AdministratorLoginPassword { get; set; } /// Server version. + [WirePath("properties.version")] public MySqlFlexibleServerVersion? Version { get; set; } /// availability Zone information of the server. + [WirePath("properties.availabilityZone")] public string AvailabilityZone { get; set; } /// The mode to create a new MySQL server. + [WirePath("properties.createMode")] public MySqlFlexibleServerCreateMode? CreateMode { get; set; } /// The source MySQL server id. + [WirePath("properties.sourceServerResourceId")] public ResourceIdentifier SourceServerResourceId { get; set; } /// Restore point creation time (ISO8601 format), specifying the time to restore from. + [WirePath("properties.restorePointInTime")] public DateTimeOffset? RestorePointInTime { get; set; } /// The replication role. + [WirePath("properties.replicationRole")] public MySqlFlexibleServerReplicationRole? ReplicationRole { get; set; } /// The maximum number of replicas that a primary server can have. + [WirePath("properties.replicaCapacity")] public int? ReplicaCapacity { get; } /// The Data Encryption for CMK. + [WirePath("properties.dataEncryption")] public MySqlFlexibleServerDataEncryption DataEncryption { get; set; } /// The state of a server. + [WirePath("properties.state")] public MySqlFlexibleServerState? State { get; } /// The fully qualified domain name of a server. + [WirePath("properties.fullyQualifiedDomainName")] public string FullyQualifiedDomainName { get; } /// Storage related properties of a server. + [WirePath("properties.storage")] public MySqlFlexibleServerStorage Storage { get; set; } /// Backup related properties of a server. + [WirePath("properties.backup")] public MySqlFlexibleServerBackupProperties Backup { get; set; } /// High availability related properties of a server. + [WirePath("properties.highAvailability")] public MySqlFlexibleServerHighAvailability HighAvailability { get; set; } /// Network related properties of a server. + [WirePath("properties.network")] public MySqlFlexibleServerNetwork Network { get; set; } /// PrivateEndpointConnections related properties of a server. + [WirePath("properties.privateEndpointConnections")] public IReadOnlyList PrivateEndpointConnections { get; } /// Maintenance window of a server. + [WirePath("properties.maintenanceWindow")] public MySqlFlexibleServerMaintenanceWindow MaintenanceWindow { get; set; } /// Source properties for import from storage. + [WirePath("properties.importSourceProperties")] public ImportSourceProperties ImportSourceProperties { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServerDatabaseData.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServerDatabaseData.Serialization.cs index ea05b0642d828..542e4c3554c6a 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServerDatabaseData.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServerDatabaseData.Serialization.cs @@ -8,8 +8,10 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; using Azure.ResourceManager.MySql; @@ -171,6 +173,160 @@ internal static MySqlFlexibleServerDatabaseData DeserializeMySqlFlexibleServerDa serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Charset), out propertyOverride); + if (Optional.IsDefined(Charset) || hasPropertyOverride) + { + builder.Append(" charset: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Charset.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Charset}'''"); + } + else + { + builder.AppendLine($"'{Charset}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Collation), out propertyOverride); + if (Optional.IsDefined(Collation) || hasPropertyOverride) + { + builder.Append(" collation: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Collation.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Collation}'''"); + } + else + { + builder.AppendLine($"'{Collation}'"); + } + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -179,6 +335,8 @@ BinaryData IPersistableModel.Write(ModelReaderW { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerDatabaseData)} does not support '{options.Format}' format."); } @@ -195,6 +353,8 @@ MySqlFlexibleServerDatabaseData IPersistableModel The charset of the database. + [WirePath("properties.charset")] public string Charset { get; set; } /// The collation of the database. + [WirePath("properties.collation")] public string Collation { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServerFirewallRuleData.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServerFirewallRuleData.Serialization.cs index 2439481b0497a..796a3cb0ee72f 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServerFirewallRuleData.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServerFirewallRuleData.Serialization.cs @@ -9,8 +9,10 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Net; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; using Azure.ResourceManager.MySql; @@ -166,6 +168,144 @@ internal static MySqlFlexibleServerFirewallRuleData DeserializeMySqlFlexibleServ serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(StartIPAddress), out propertyOverride); + if (Optional.IsDefined(StartIPAddress) || hasPropertyOverride) + { + builder.Append(" startIpAddress: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{StartIPAddress.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EndIPAddress), out propertyOverride); + if (Optional.IsDefined(EndIPAddress) || hasPropertyOverride) + { + builder.Append(" endIpAddress: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{EndIPAddress.ToString()}'"); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -174,6 +314,8 @@ BinaryData IPersistableModel.Write(ModelRea { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServerFirewallRuleData)} does not support '{options.Format}' format."); } @@ -190,6 +332,8 @@ MySqlFlexibleServerFirewallRuleData IPersistableModel The start IP address of the server firewall rule. Must be IPv4 format. + [WirePath("properties.startIpAddress")] public IPAddress StartIPAddress { get; set; } /// The end IP address of the server firewall rule. Must be IPv4 format. + [WirePath("properties.endIpAddress")] public IPAddress EndIPAddress { get; set; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServersCapabilityData.Serialization.cs b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServersCapabilityData.Serialization.cs index 8cef4ce411f59..7606c346e2152 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServersCapabilityData.Serialization.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/MySqlFlexibleServers/Generated/MySqlFlexibleServersCapabilityData.Serialization.cs @@ -8,8 +8,11 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; +using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Models; using Azure.ResourceManager.MySql; using Azure.ResourceManager.MySql.FlexibleServers.Models; @@ -226,6 +229,195 @@ internal static MySqlFlexibleServersCapabilityData DeserializeMySqlFlexibleServe serializedAdditionalRawData); } + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.ParameterOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (Optional.IsDefined(Name) || hasPropertyOverride) + { + builder.Append(" name: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (Optional.IsDefined(Id) || hasPropertyOverride) + { + builder.Append(" id: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (Optional.IsDefined(SystemData) || hasPropertyOverride) + { + builder.Append(" systemData: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SupportedGeoBackupRegions), out propertyOverride); + if (Optional.IsCollectionDefined(SupportedGeoBackupRegions) || hasPropertyOverride) + { + if (SupportedGeoBackupRegions.Any() || hasPropertyOverride) + { + builder.Append(" supportedGeoBackupRegions: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in SupportedGeoBackupRegions) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SupportedFlexibleServerEditions), out propertyOverride); + if (Optional.IsCollectionDefined(SupportedFlexibleServerEditions) || hasPropertyOverride) + { + if (SupportedFlexibleServerEditions.Any() || hasPropertyOverride) + { + builder.Append(" supportedFlexibleServerEditions: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in SupportedFlexibleServerEditions) + { + AppendChildObject(builder, item, options, 6, true, " supportedFlexibleServerEditions: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SupportedServerVersions), out propertyOverride); + if (Optional.IsCollectionDefined(SupportedServerVersions) || hasPropertyOverride) + { + if (SupportedServerVersions.Any() || hasPropertyOverride) + { + builder.Append(" supportedServerVersions: "); + if (hasPropertyOverride) + { + builder.AppendLine($"{propertyOverride}"); + } + else + { + builder.AppendLine("["); + foreach (var item in SupportedServerVersions) + { + AppendChildObject(builder, item, options, 6, true, " supportedServerVersions: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + private void AppendChildObject(StringBuilder stringBuilder, object childObject, ModelReaderWriterOptions options, int spaces, bool indentFirstLine, string formattedPropertyName) + { + string indent = new string(' ', spaces); + int emptyObjectLength = 2 + spaces + Environment.NewLine.Length + Environment.NewLine.Length; + int length = stringBuilder.Length; + bool inMultilineString = false; + + BinaryData data = ModelReaderWriter.Write(childObject, options); + string[] lines = data.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + if (inMultilineString) + { + if (line.Contains("'''")) + { + inMultilineString = false; + } + stringBuilder.AppendLine(line); + continue; + } + if (line.Contains("'''")) + { + inMultilineString = true; + stringBuilder.AppendLine($"{indent}{line}"); + continue; + } + if (i == 0 && !indentFirstLine) + { + stringBuilder.AppendLine($"{line}"); + } + else + { + stringBuilder.AppendLine($"{indent}{line}"); + } + } + if (stringBuilder.Length == length + emptyObjectLength) + { + stringBuilder.Length = stringBuilder.Length - emptyObjectLength - formattedPropertyName.Length; + } + } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; @@ -234,6 +426,8 @@ BinaryData IPersistableModel.Write(ModelRead { case "J": return ModelReaderWriter.Write(this, options); + case "bicep": + return SerializeBicep(options); default: throw new FormatException($"The model {nameof(MySqlFlexibleServersCapabilityData)} does not support '{options.Format}' format."); } @@ -250,6 +444,8 @@ MySqlFlexibleServersCapabilityData IPersistableModel supported geo backup regions. + [WirePath("properties.supportedGeoBackupRegions")] public IReadOnlyList SupportedGeoBackupRegions { get; } /// A list of supported flexible server editions. + [WirePath("properties.supportedFlexibleServerEditions")] public IReadOnlyList SupportedFlexibleServerEditions { get; } /// A list of supported server versions. + [WirePath("properties.supportedServerVersions")] public IReadOnlyList SupportedServerVersions { get; } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/src/autorest.md b/sdk/mysql/Azure.ResourceManager.MySql/src/autorest.md index 97fac2809d4bc..97880fdefd088 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/src/autorest.md +++ b/sdk/mysql/Azure.ResourceManager.MySql/src/autorest.md @@ -11,6 +11,7 @@ library-name: MySql #mgmt-debug: # show-serialized-names: true use-model-reader-writer: true +enable-bicep-serialization: true batch: - tag: package-2020-01-01