public async Task <Response <VpnSiteLink> > GetAsync(string resourceGroupName, string vpnSiteName, string vpnSiteLinkName, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (vpnSiteName == null) { throw new ArgumentNullException(nameof(vpnSiteName)); } if (vpnSiteLinkName == null) { throw new ArgumentNullException(nameof(vpnSiteLinkName)); } using var message = CreateGetRequest(resourceGroupName, vpnSiteName, vpnSiteLinkName); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { VpnSiteLink value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); if (document.RootElement.ValueKind == JsonValueKind.Null) { value = null; } else { value = VpnSiteLink.DeserializeVpnSiteLink(document.RootElement); } return(Response.FromValue(value, message.Response)); }
internal static VpnSiteData DeserializeVpnSiteData(JsonElement element) { Optional <string> etag = default; Optional <string> id = default; Optional <string> name = default; Optional <string> type = default; Optional <string> location = default; Optional <IDictionary <string, string> > tags = default; Optional <WritableSubResource> virtualWan = default; Optional <DeviceProperties> deviceProperties = default; Optional <string> ipAddress = default; Optional <string> siteKey = default; Optional <AddressSpace> addressSpace = default; Optional <BgpSettings> bgpProperties = default; Optional <ProvisioningState> provisioningState = default; Optional <bool> isSecuritySite = default; Optional <IList <VpnSiteLink> > vpnSiteLinks = default; Optional <O365PolicyProperties> o365Policy = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("etag")) { etag = property.Value.GetString(); continue; } if (property.NameEquals("id")) { id = property.Value.GetString(); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("type")) { type = property.Value.GetString(); continue; } if (property.NameEquals("location")) { location = property.Value.GetString(); continue; } if (property.NameEquals("tags")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } Dictionary <string, string> dictionary = new Dictionary <string, string>(); foreach (var property0 in property.Value.EnumerateObject()) { dictionary.Add(property0.Name, property0.Value.GetString()); } tags = dictionary; continue; } if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } foreach (var property0 in property.Value.EnumerateObject()) { if (property0.NameEquals("virtualWan")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } virtualWan = JsonSerializer.Deserialize <WritableSubResource>(property0.Value.ToString()); continue; } if (property0.NameEquals("deviceProperties")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } deviceProperties = DeviceProperties.DeserializeDeviceProperties(property0.Value); continue; } if (property0.NameEquals("ipAddress")) { ipAddress = property0.Value.GetString(); continue; } if (property0.NameEquals("siteKey")) { siteKey = property0.Value.GetString(); continue; } if (property0.NameEquals("addressSpace")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } addressSpace = AddressSpace.DeserializeAddressSpace(property0.Value); continue; } if (property0.NameEquals("bgpProperties")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } bgpProperties = BgpSettings.DeserializeBgpSettings(property0.Value); continue; } if (property0.NameEquals("provisioningState")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } provisioningState = new ProvisioningState(property0.Value.GetString()); continue; } if (property0.NameEquals("isSecuritySite")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } isSecuritySite = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("vpnSiteLinks")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <VpnSiteLink> array = new List <VpnSiteLink>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(VpnSiteLink.DeserializeVpnSiteLink(item)); } vpnSiteLinks = array; continue; } if (property0.NameEquals("o365Policy")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } o365Policy = O365PolicyProperties.DeserializeO365PolicyProperties(property0.Value); continue; } } continue; } } return(new VpnSiteData(id.Value, name.Value, type.Value, location.Value, Optional.ToDictionary(tags), etag.Value, virtualWan, deviceProperties.Value, ipAddress.Value, siteKey.Value, addressSpace.Value, bgpProperties.Value, Optional.ToNullable(provisioningState), Optional.ToNullable(isSecuritySite), Optional.ToList(vpnSiteLinks), o365Policy.Value)); }