internal static ValueSecretInfo DeserializeValueSecretInfo(JsonElement element) { Optional <string> value = default; SecretType secretType = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value")) { if (property.Value.ValueKind == JsonValueKind.Null) { value = null; continue; } value = property.Value.GetString(); continue; } if (property.NameEquals("secretType")) { secretType = new SecretType(property.Value.GetString()); continue; } } return(new ValueSecretInfo(secretType, value.Value)); }
internal static SecretInfoBase DeserializeSecretInfoBase(JsonElement element) { if (element.TryGetProperty("secretType", out JsonElement discriminator)) { switch (discriminator.GetString()) { case "keyVaultSecretReference": return(KeyVaultSecretReferenceSecretInfo.DeserializeKeyVaultSecretReferenceSecretInfo(element)); case "keyVaultSecretUri": return(KeyVaultSecretUriSecretInfo.DeserializeKeyVaultSecretUriSecretInfo(element)); case "rawValue": return(ValueSecretInfo.DeserializeValueSecretInfo(element)); } } SecretType secretType = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("secretType")) { secretType = new SecretType(property.Value.GetString()); continue; } } return(new SecretInfoBase(secretType)); }
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { writer.WriteStartObject(); writer.WritePropertyName("secretType"); writer.WriteStringValue(SecretType.ToString()); writer.WriteEndObject(); }
internal static KeyVaultSecretReferenceSecretInfo DeserializeKeyVaultSecretReferenceSecretInfo(JsonElement element) { Optional <string> name = default; Optional <string> version = default; SecretType secretType = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("version")) { version = property.Value.GetString(); continue; } if (property.NameEquals("secretType")) { secretType = new SecretType(property.Value.GetString()); continue; } } return(new KeyVaultSecretReferenceSecretInfo(secretType, name.Value, version.Value)); }
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { writer.WriteStartObject(); if (Optional.IsDefined(Value)) { writer.WritePropertyName("value"); writer.WriteStringValue(Value); } writer.WritePropertyName("secretType"); writer.WriteStringValue(SecretType.ToString()); writer.WriteEndObject(); }
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { writer.WriteStartObject(); if (Optional.IsDefined(Name)) { writer.WritePropertyName("name"); writer.WriteStringValue(Name); } if (Optional.IsDefined(Version)) { if (Version != null) { writer.WritePropertyName("version"); writer.WriteStringValue(Version); } else { writer.WriteNull("version"); } } writer.WritePropertyName("secretType"); writer.WriteStringValue(SecretType.ToString()); writer.WriteEndObject(); }