Example #1
0
 internal SnapshotRestoreRequest(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, string kind, string snapshotTime, SnapshotRecoverySource recoverySource, bool?overwrite, bool?recoverConfiguration, bool?ignoreConflictingHostNames, bool?useDRSecondary) : base(id, name, resourceType, systemData, kind)
 {
     SnapshotTime               = snapshotTime;
     RecoverySource             = recoverySource;
     Overwrite                  = overwrite;
     RecoverConfiguration       = recoverConfiguration;
     IgnoreConflictingHostNames = ignoreConflictingHostNames;
     UseDRSecondary             = useDRSecondary;
 }
Example #2
0
        internal static SnapshotRestoreRequest DeserializeSnapshotRestoreRequest(JsonElement element)
        {
            Optional <string>  kind         = default;
            ResourceIdentifier id           = default;
            string             name         = default;
            ResourceType       type         = default;
            SystemData         systemData   = default;
            Optional <string>  snapshotTime = default;
            Optional <SnapshotRecoverySource> recoverySource = default;
            Optional <bool> overwrite                  = default;
            Optional <bool> recoverConfiguration       = default;
            Optional <bool> ignoreConflictingHostNames = default;
            Optional <bool> useDRSecondary             = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("kind"))
                {
                    kind = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = new ResourceType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("systemData"))
                {
                    systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString());
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("snapshotTime"))
                        {
                            snapshotTime = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("recoverySource"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            recoverySource = SnapshotRecoverySource.DeserializeSnapshotRecoverySource(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("overwrite"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            overwrite = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("recoverConfiguration"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            recoverConfiguration = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("ignoreConflictingHostNames"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            ignoreConflictingHostNames = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("useDRSecondary"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            useDRSecondary = property0.Value.GetBoolean();
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new SnapshotRestoreRequest(id, name, type, systemData, kind.Value, snapshotTime.Value, recoverySource.Value, Optional.ToNullable(overwrite), Optional.ToNullable(recoverConfiguration), Optional.ToNullable(ignoreConflictingHostNames), Optional.ToNullable(useDRSecondary)));
        }