internal static SecurityRule DeserializeSecurityRule(JsonElement element) { string name = default; string etag = default; string id = default; string description = default; SecurityRuleProtocol?protocol = default; string sourcePortRange = default; string destinationPortRange = default; string sourceAddressPrefix = default; IList <string> sourceAddressPrefixes = default; IList <ApplicationSecurityGroup> sourceApplicationSecurityGroups = default; string destinationAddressPrefix = default; IList <string> destinationAddressPrefixes = default; IList <ApplicationSecurityGroup> destinationApplicationSecurityGroups = default; IList <string> sourcePortRanges = default; IList <string> destinationPortRanges = default; SecurityRuleAccess?access = default; int?priority = default; SecurityRuleDirection?direction = default; ProvisioningState? provisioningState = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } name = property.Value.GetString(); continue; } if (property.NameEquals("etag")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } etag = property.Value.GetString(); continue; } if (property.NameEquals("id")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } id = property.Value.GetString(); continue; } if (property.NameEquals("properties")) { foreach (var property0 in property.Value.EnumerateObject()) { if (property0.NameEquals("description")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } description = property0.Value.GetString(); continue; } if (property0.NameEquals("protocol")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } protocol = new SecurityRuleProtocol(property0.Value.GetString()); continue; } if (property0.NameEquals("sourcePortRange")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } sourcePortRange = property0.Value.GetString(); continue; } if (property0.NameEquals("destinationPortRange")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } destinationPortRange = property0.Value.GetString(); continue; } if (property0.NameEquals("sourceAddressPrefix")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } sourceAddressPrefix = property0.Value.GetString(); continue; } if (property0.NameEquals("sourceAddressPrefixes")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } List <string> array = new List <string>(); foreach (var item in property0.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(item.GetString()); } } sourceAddressPrefixes = array; continue; } if (property0.NameEquals("sourceApplicationSecurityGroups")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } List <ApplicationSecurityGroup> array = new List <ApplicationSecurityGroup>(); foreach (var item in property0.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(ApplicationSecurityGroup.DeserializeApplicationSecurityGroup(item)); } } sourceApplicationSecurityGroups = array; continue; } if (property0.NameEquals("destinationAddressPrefix")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } destinationAddressPrefix = property0.Value.GetString(); continue; } if (property0.NameEquals("destinationAddressPrefixes")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } List <string> array = new List <string>(); foreach (var item in property0.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(item.GetString()); } } destinationAddressPrefixes = array; continue; } if (property0.NameEquals("destinationApplicationSecurityGroups")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } List <ApplicationSecurityGroup> array = new List <ApplicationSecurityGroup>(); foreach (var item in property0.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(ApplicationSecurityGroup.DeserializeApplicationSecurityGroup(item)); } } destinationApplicationSecurityGroups = array; continue; } if (property0.NameEquals("sourcePortRanges")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } List <string> array = new List <string>(); foreach (var item in property0.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(item.GetString()); } } sourcePortRanges = array; continue; } if (property0.NameEquals("destinationPortRanges")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } List <string> array = new List <string>(); foreach (var item in property0.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(item.GetString()); } } destinationPortRanges = array; continue; } if (property0.NameEquals("access")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } access = new SecurityRuleAccess(property0.Value.GetString()); continue; } if (property0.NameEquals("priority")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } priority = property0.Value.GetInt32(); continue; } if (property0.NameEquals("direction")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } direction = new SecurityRuleDirection(property0.Value.GetString()); continue; } if (property0.NameEquals("provisioningState")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } provisioningState = new ProvisioningState(property0.Value.GetString()); continue; } } continue; } } return(new SecurityRule(id, name, etag, description, protocol, sourcePortRange, destinationPortRange, sourceAddressPrefix, sourceAddressPrefixes, sourceApplicationSecurityGroups, destinationAddressPrefix, destinationAddressPrefixes, destinationApplicationSecurityGroups, sourcePortRanges, destinationPortRanges, access, priority, direction, provisioningState)); }
internal static EffectiveNetworkSecurityRule DeserializeEffectiveNetworkSecurityRule(JsonElement element) { Optional <string> name = default; Optional <EffectiveSecurityRuleProtocol> protocol = default; Optional <string> sourcePortRange = default; Optional <string> destinationPortRange = default; Optional <IReadOnlyList <string> > sourcePortRanges = default; Optional <IReadOnlyList <string> > destinationPortRanges = default; Optional <string> sourceAddressPrefix = default; Optional <string> destinationAddressPrefix = default; Optional <IReadOnlyList <string> > sourceAddressPrefixes = default; Optional <IReadOnlyList <string> > destinationAddressPrefixes = default; Optional <IReadOnlyList <string> > expandedSourceAddressPrefix = default; Optional <IReadOnlyList <string> > expandedDestinationAddressPrefix = default; Optional <SecurityRuleAccess> access = default; Optional <int> priority = default; Optional <SecurityRuleDirection> direction = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("protocol")) { protocol = new EffectiveSecurityRuleProtocol(property.Value.GetString()); continue; } if (property.NameEquals("sourcePortRange")) { sourcePortRange = property.Value.GetString(); continue; } if (property.NameEquals("destinationPortRange")) { destinationPortRange = property.Value.GetString(); continue; } if (property.NameEquals("sourcePortRanges")) { List <string> array = new List <string>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(item.GetString()); } sourcePortRanges = array; continue; } if (property.NameEquals("destinationPortRanges")) { List <string> array = new List <string>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(item.GetString()); } destinationPortRanges = array; continue; } if (property.NameEquals("sourceAddressPrefix")) { sourceAddressPrefix = property.Value.GetString(); continue; } if (property.NameEquals("destinationAddressPrefix")) { destinationAddressPrefix = property.Value.GetString(); continue; } if (property.NameEquals("sourceAddressPrefixes")) { List <string> array = new List <string>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(item.GetString()); } sourceAddressPrefixes = array; continue; } if (property.NameEquals("destinationAddressPrefixes")) { List <string> array = new List <string>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(item.GetString()); } destinationAddressPrefixes = array; continue; } if (property.NameEquals("expandedSourceAddressPrefix")) { List <string> array = new List <string>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(item.GetString()); } expandedSourceAddressPrefix = array; continue; } if (property.NameEquals("expandedDestinationAddressPrefix")) { List <string> array = new List <string>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(item.GetString()); } expandedDestinationAddressPrefix = array; continue; } if (property.NameEquals("access")) { access = new SecurityRuleAccess(property.Value.GetString()); continue; } if (property.NameEquals("priority")) { priority = property.Value.GetInt32(); continue; } if (property.NameEquals("direction")) { direction = new SecurityRuleDirection(property.Value.GetString()); continue; } } return(new EffectiveNetworkSecurityRule(name.Value, Optional.ToNullable(protocol), sourcePortRange.Value, destinationPortRange.Value, Optional.ToList(sourcePortRanges), Optional.ToList(destinationPortRanges), sourceAddressPrefix.Value, destinationAddressPrefix.Value, Optional.ToList(sourceAddressPrefixes), Optional.ToList(destinationAddressPrefixes), Optional.ToList(expandedSourceAddressPrefix), Optional.ToList(expandedDestinationAddressPrefix), Optional.ToNullable(access), Optional.ToNullable(priority), Optional.ToNullable(direction))); }
internal static SecurityRule DeserializeSecurityRule(JsonElement element) { Optional <string> name = default; Optional <string> etag = default; Optional <string> id = default; Optional <string> description = default; Optional <SecurityRuleProtocol> protocol = default; Optional <string> sourcePortRange = default; Optional <string> destinationPortRange = default; Optional <string> sourceAddressPrefix = default; Optional <IList <string> > sourceAddressPrefixes = default; Optional <IList <ApplicationSecurityGroup> > sourceApplicationSecurityGroups = default; Optional <string> destinationAddressPrefix = default; Optional <IList <string> > destinationAddressPrefixes = default; Optional <IList <ApplicationSecurityGroup> > destinationApplicationSecurityGroups = default; Optional <IList <string> > sourcePortRanges = default; Optional <IList <string> > destinationPortRanges = default; Optional <SecurityRuleAccess> access = default; Optional <int> priority = default; Optional <SecurityRuleDirection> direction = default; Optional <ProvisioningState> provisioningState = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("etag")) { etag = property.Value.GetString(); continue; } if (property.NameEquals("id")) { id = property.Value.GetString(); continue; } if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } foreach (var property0 in property.Value.EnumerateObject()) { if (property0.NameEquals("description")) { description = property0.Value.GetString(); continue; } if (property0.NameEquals("protocol")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } protocol = new SecurityRuleProtocol(property0.Value.GetString()); continue; } if (property0.NameEquals("sourcePortRange")) { sourcePortRange = property0.Value.GetString(); continue; } if (property0.NameEquals("destinationPortRange")) { destinationPortRange = property0.Value.GetString(); continue; } if (property0.NameEquals("sourceAddressPrefix")) { sourceAddressPrefix = property0.Value.GetString(); continue; } if (property0.NameEquals("sourceAddressPrefixes")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <string> array = new List <string>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(item.GetString()); } sourceAddressPrefixes = array; continue; } if (property0.NameEquals("sourceApplicationSecurityGroups")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <ApplicationSecurityGroup> array = new List <ApplicationSecurityGroup>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(ApplicationSecurityGroup.DeserializeApplicationSecurityGroup(item)); } sourceApplicationSecurityGroups = array; continue; } if (property0.NameEquals("destinationAddressPrefix")) { destinationAddressPrefix = property0.Value.GetString(); continue; } if (property0.NameEquals("destinationAddressPrefixes")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <string> array = new List <string>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(item.GetString()); } destinationAddressPrefixes = array; continue; } if (property0.NameEquals("destinationApplicationSecurityGroups")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <ApplicationSecurityGroup> array = new List <ApplicationSecurityGroup>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(ApplicationSecurityGroup.DeserializeApplicationSecurityGroup(item)); } destinationApplicationSecurityGroups = array; continue; } if (property0.NameEquals("sourcePortRanges")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <string> array = new List <string>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(item.GetString()); } sourcePortRanges = array; continue; } if (property0.NameEquals("destinationPortRanges")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <string> array = new List <string>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(item.GetString()); } destinationPortRanges = array; continue; } if (property0.NameEquals("access")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } access = new SecurityRuleAccess(property0.Value.GetString()); continue; } if (property0.NameEquals("priority")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } priority = property0.Value.GetInt32(); continue; } if (property0.NameEquals("direction")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } direction = new SecurityRuleDirection(property0.Value.GetString()); continue; } if (property0.NameEquals("provisioningState")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } provisioningState = new ProvisioningState(property0.Value.GetString()); continue; } } continue; } } return(new SecurityRule(id.Value, name.Value, etag.Value, description.Value, Optional.ToNullable(protocol), sourcePortRange.Value, destinationPortRange.Value, sourceAddressPrefix.Value, Optional.ToList(sourceAddressPrefixes), Optional.ToList(sourceApplicationSecurityGroups), destinationAddressPrefix.Value, Optional.ToList(destinationAddressPrefixes), Optional.ToList(destinationApplicationSecurityGroups), Optional.ToList(sourcePortRanges), Optional.ToList(destinationPortRanges), Optional.ToNullable(access), Optional.ToNullable(priority), Optional.ToNullable(direction), Optional.ToNullable(provisioningState))); }
internal static EffectiveNetworkSecurityRule DeserializeEffectiveNetworkSecurityRule(JsonElement element) { string name = default; EffectiveSecurityRuleProtocol?protocol = default; string sourcePortRange = default; string destinationPortRange = default; IReadOnlyList <string> sourcePortRanges = default; IReadOnlyList <string> destinationPortRanges = default; string sourceAddressPrefix = default; string destinationAddressPrefix = default; IReadOnlyList <string> sourceAddressPrefixes = default; IReadOnlyList <string> destinationAddressPrefixes = default; IReadOnlyList <string> expandedSourceAddressPrefix = default; IReadOnlyList <string> expandedDestinationAddressPrefix = default; SecurityRuleAccess? access = default; int?priority = default; SecurityRuleDirection?direction = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } name = property.Value.GetString(); continue; } if (property.NameEquals("protocol")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } protocol = new EffectiveSecurityRuleProtocol(property.Value.GetString()); continue; } if (property.NameEquals("sourcePortRange")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } sourcePortRange = property.Value.GetString(); continue; } if (property.NameEquals("destinationPortRange")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } destinationPortRange = property.Value.GetString(); continue; } if (property.NameEquals("sourcePortRanges")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <string> array = new List <string>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(item.GetString()); } } sourcePortRanges = array; continue; } if (property.NameEquals("destinationPortRanges")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <string> array = new List <string>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(item.GetString()); } } destinationPortRanges = array; continue; } if (property.NameEquals("sourceAddressPrefix")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } sourceAddressPrefix = property.Value.GetString(); continue; } if (property.NameEquals("destinationAddressPrefix")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } destinationAddressPrefix = property.Value.GetString(); continue; } if (property.NameEquals("sourceAddressPrefixes")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <string> array = new List <string>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(item.GetString()); } } sourceAddressPrefixes = array; continue; } if (property.NameEquals("destinationAddressPrefixes")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <string> array = new List <string>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(item.GetString()); } } destinationAddressPrefixes = array; continue; } if (property.NameEquals("expandedSourceAddressPrefix")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <string> array = new List <string>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(item.GetString()); } } expandedSourceAddressPrefix = array; continue; } if (property.NameEquals("expandedDestinationAddressPrefix")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <string> array = new List <string>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(item.GetString()); } } expandedDestinationAddressPrefix = array; continue; } if (property.NameEquals("access")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } access = new SecurityRuleAccess(property.Value.GetString()); continue; } if (property.NameEquals("priority")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } priority = property.Value.GetInt32(); continue; } if (property.NameEquals("direction")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } direction = new SecurityRuleDirection(property.Value.GetString()); continue; } } return(new EffectiveNetworkSecurityRule(name, protocol, sourcePortRange, destinationPortRange, sourcePortRanges, destinationPortRanges, sourceAddressPrefix, destinationAddressPrefix, sourceAddressPrefixes, destinationAddressPrefixes, expandedSourceAddressPrefix, expandedDestinationAddressPrefix, access, priority, direction)); }