예제 #1
0
        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));
        }
예제 #2
0
        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));
        }
예제 #3
0
 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));
        }
예제 #5
0
 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();
 }