internal static AzureResource DeserializeAzureResource(JsonElement element) { Optional <string> id = default; Optional <AzureResourcePropertiesBase> resourceProperties = default; TargetServiceType type = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id")) { id = property.Value.GetString(); continue; } if (property.NameEquals("resourceProperties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } resourceProperties = AzureResourcePropertiesBase.DeserializeAzureResourcePropertiesBase(property.Value); continue; } if (property.NameEquals("type")) { type = new TargetServiceType(property.Value.GetString()); continue; } } return(new AzureResource(type, id.Value, resourceProperties.Value)); }
internal static TargetServiceBase DeserializeTargetServiceBase(JsonElement element) { if (element.TryGetProperty("type", out JsonElement discriminator)) { switch (discriminator.GetString()) { case "AzureResource": return(AzureResource.DeserializeAzureResource(element)); case "ConfluentBootstrapServer": return(ConfluentBootstrapServer.DeserializeConfluentBootstrapServer(element)); case "ConfluentSchemaRegistry": return(ConfluentSchemaRegistry.DeserializeConfluentSchemaRegistry(element)); } } TargetServiceType type = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("type")) { type = new TargetServiceType(property.Value.GetString()); continue; } } return(new TargetServiceBase(type)); }
internal static ConfluentBootstrapServer DeserializeConfluentBootstrapServer(JsonElement element) { Optional <string> endpoint = default; TargetServiceType type = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("endpoint")) { endpoint = property.Value.GetString(); continue; } if (property.NameEquals("type")) { type = new TargetServiceType(property.Value.GetString()); continue; } } return(new ConfluentBootstrapServer(type, endpoint.Value)); }