in sdk/mysql/Azure.ResourceManager.MySql/src/MySql/Custom/Models/MySqlServerData.Serialization.cs [18:300]
internal static MySqlServerData DeserializeMySqlServerData(JsonElement element, ModelReaderWriterOptions options = null)
{
options ??= new ModelReaderWriterOptions("W");
if (element.ValueKind == JsonValueKind.Null)
{
return null;
}
ManagedServiceIdentity identity = default;
MySqlSku sku = default;
IDictionary<string, string> tags = default;
AzureLocation location = default;
ResourceIdentifier id = default;
string name = default;
ResourceType type = default;
SystemData systemData = default;
string administratorLogin = default;
MySqlServerVersion? version = default;
MySqlSslEnforcementEnum? sslEnforcement = default;
MySqlMinimalTlsVersionEnum? minimalTlsVersion = default;
string byokEnforcement = default;
MySqlInfrastructureEncryption? infrastructureEncryption = default;
MySqlServerState? userVisibleState = default;
string fullyQualifiedDomainName = default;
DateTimeOffset? earliestRestoreDate = default;
MySqlStorageProfile storageProfile = default;
string replicationRole = default;
ResourceIdentifier masterServerId = default;
int? replicaCapacity = default;
MySqlPublicNetworkAccessEnum? publicNetworkAccess = default;
IReadOnlyList<MySqlServerPrivateEndpointConnection> privateEndpointConnections = default;
IDictionary<string, BinaryData> serializedAdditionalRawData = default;
Dictionary<string, BinaryData> additionalPropertiesDictionary = new Dictionary<string, BinaryData>();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("identity"u8))
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
property.ThrowNonNullablePropertyIsNull();
continue;
}
identity = JsonSerializer.Deserialize<ManagedServiceIdentity>(property.Value.ToString());
continue;
}
if (property.NameEquals("sku"u8))
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
property.ThrowNonNullablePropertyIsNull();
continue;
}
sku = MySqlSku.DeserializeMySqlSku(property.Value);
continue;
}
if (property.NameEquals("tags"u8))
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
property.ThrowNonNullablePropertyIsNull();
continue;
}
Dictionary<string, string> dictionary = new Dictionary<string, string>();
foreach (var property0 in property.Value.EnumerateObject())
{
dictionary.Add(property0.Name, property0.Value.GetString());
}
tags = dictionary;
continue;
}
if (property.NameEquals("location"u8))
{
location = new AzureLocation(property.Value.GetString());
continue;
}
if (property.NameEquals("id"u8))
{
id = new ResourceIdentifier(property.Value.GetString());
continue;
}
if (property.NameEquals("name"u8))
{
name = property.Value.GetString();
continue;
}
if (property.NameEquals("type"u8))
{
type = new ResourceType(property.Value.GetString());
continue;
}
if (property.NameEquals("systemData"u8))
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
property.ThrowNonNullablePropertyIsNull();
continue;
}
systemData = JsonSerializer.Deserialize<SystemData>(property.Value.ToString());
continue;
}
if (property.NameEquals("properties"u8))
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
property.ThrowNonNullablePropertyIsNull();
continue;
}
foreach (var property0 in property.Value.EnumerateObject())
{
if (property0.NameEquals("administratorLogin"u8))
{
administratorLogin = property0.Value.GetString();
continue;
}
if (property0.NameEquals("version"u8))
{
if (property0.Value.ValueKind == JsonValueKind.Null)
{
property0.ThrowNonNullablePropertyIsNull();
continue;
}
version = new MySqlServerVersion(property0.Value.GetString());
continue;
}
if (property0.NameEquals("sslEnforcement"u8))
{
if (property0.Value.ValueKind == JsonValueKind.Null)
{
property0.ThrowNonNullablePropertyIsNull();
continue;
}
sslEnforcement = property0.Value.GetString().ToMySqlSslEnforcementEnum();
continue;
}
if (property0.NameEquals("minimalTlsVersion"u8))
{
if (property0.Value.ValueKind == JsonValueKind.Null)
{
property0.ThrowNonNullablePropertyIsNull();
continue;
}
minimalTlsVersion = new MySqlMinimalTlsVersionEnum(property0.Value.GetString());
continue;
}
if (property0.NameEquals("byokEnforcement"u8))
{
byokEnforcement = property0.Value.GetString();
continue;
}
if (property0.NameEquals("infrastructureEncryption"u8))
{
if (property0.Value.ValueKind == JsonValueKind.Null)
{
property0.ThrowNonNullablePropertyIsNull();
continue;
}
infrastructureEncryption = new MySqlInfrastructureEncryption(property0.Value.GetString());
continue;
}
if (property0.NameEquals("userVisibleState"u8))
{
if (property0.Value.ValueKind == JsonValueKind.Null)
{
property0.ThrowNonNullablePropertyIsNull();
continue;
}
userVisibleState = new MySqlServerState(property0.Value.GetString());
continue;
}
if (property0.NameEquals("fullyQualifiedDomainName"u8))
{
fullyQualifiedDomainName = property0.Value.GetString();
continue;
}
if (property0.NameEquals("earliestRestoreDate"u8))
{
if (property0.Value.ValueKind == JsonValueKind.Null)
{
property0.ThrowNonNullablePropertyIsNull();
continue;
}
earliestRestoreDate = property0.Value.GetDateTimeOffset("O");
continue;
}
if (property0.NameEquals("storageProfile"u8))
{
if (property0.Value.ValueKind == JsonValueKind.Null)
{
property0.ThrowNonNullablePropertyIsNull();
continue;
}
storageProfile = MySqlStorageProfile.DeserializeMySqlStorageProfile(property0.Value);
continue;
}
if (property0.NameEquals("replicationRole"u8))
{
replicationRole = property0.Value.GetString();
continue;
}
if (property0.NameEquals("masterServerId"u8))
{
if (property0.Value.ValueKind == JsonValueKind.Null)
{
property0.ThrowNonNullablePropertyIsNull();
continue;
}
// Customized code start
if (string.IsNullOrEmpty(property0.Value.GetString()))
continue;
// Customized code end
masterServerId = new ResourceIdentifier(property0.Value.GetString());
continue;
}
if (property0.NameEquals("replicaCapacity"u8))
{
if (property0.Value.ValueKind == JsonValueKind.Null)
{
property0.ThrowNonNullablePropertyIsNull();
continue;
}
replicaCapacity = property0.Value.GetInt32();
continue;
}
if (property0.NameEquals("publicNetworkAccess"u8))
{
if (property0.Value.ValueKind == JsonValueKind.Null)
{
property0.ThrowNonNullablePropertyIsNull();
continue;
}
publicNetworkAccess = new MySqlPublicNetworkAccessEnum(property0.Value.GetString());
continue;
}
if (property0.NameEquals("privateEndpointConnections"u8))
{
if (property0.Value.ValueKind == JsonValueKind.Null)
{
property0.ThrowNonNullablePropertyIsNull();
continue;
}
List<MySqlServerPrivateEndpointConnection> array = new List<MySqlServerPrivateEndpointConnection>();
foreach (var item in property0.Value.EnumerateArray())
{
array.Add(MySqlServerPrivateEndpointConnection.DeserializeMySqlServerPrivateEndpointConnection(item));
}
privateEndpointConnections = array;
continue;
}
}
continue;
}
if (options.Format != "W")
{
additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText()));
}
}
serializedAdditionalRawData = additionalPropertiesDictionary;
return new MySqlServerData(
id,
name,
type,
systemData,
tags ?? new ChangeTrackingDictionary<string, string>(),
location,
identity,
sku,
administratorLogin,
version,
sslEnforcement,
minimalTlsVersion,
byokEnforcement,
infrastructureEncryption,
userVisibleState,
fullyQualifiedDomainName,
earliestRestoreDate,
storageProfile,
replicationRole,
masterServerId,
replicaCapacity,
publicNetworkAccess,
privateEndpointConnections ?? new ChangeTrackingList<MySqlServerPrivateEndpointConnection>(),
serializedAdditionalRawData);
}