ExpressRouteConnection IOperationSource <ExpressRouteConnection> .CreateResult(Response response, CancellationToken cancellationToken) { using var document = JsonDocument.Parse(response.ContentStream); var data = ExpressRouteConnectionData.DeserializeExpressRouteConnectionData(document.RootElement); return(new ExpressRouteConnection(_client, data)); }
public async Task <Response <ExpressRouteConnectionData> > GetAsync(string subscriptionId, string resourceGroupName, string expressRouteGatewayName, string connectionName, CancellationToken cancellationToken = default) { if (subscriptionId == null) { throw new ArgumentNullException(nameof(subscriptionId)); } if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (expressRouteGatewayName == null) { throw new ArgumentNullException(nameof(expressRouteGatewayName)); } if (connectionName == null) { throw new ArgumentNullException(nameof(connectionName)); } using var message = CreateGetRequest(subscriptionId, resourceGroupName, expressRouteGatewayName, connectionName); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { ExpressRouteConnectionData value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = ExpressRouteConnectionData.DeserializeExpressRouteConnectionData(document.RootElement); return(Response.FromValue(value, message.Response)); }
internal static ExpressRouteGatewayData DeserializeExpressRouteGatewayData(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 <ExpressRouteGatewayPropertiesAutoScaleConfiguration> autoScaleConfiguration = default; Optional <IReadOnlyList <ExpressRouteConnectionData> > expressRouteConnections = default; Optional <ProvisioningState> provisioningState = default; Optional <WritableSubResource> virtualHub = 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("autoScaleConfiguration")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } autoScaleConfiguration = ExpressRouteGatewayPropertiesAutoScaleConfiguration.DeserializeExpressRouteGatewayPropertiesAutoScaleConfiguration(property0.Value); continue; } if (property0.NameEquals("expressRouteConnections")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <ExpressRouteConnectionData> array = new List <ExpressRouteConnectionData>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(ExpressRouteConnectionData.DeserializeExpressRouteConnectionData(item)); } expressRouteConnections = array; continue; } if (property0.NameEquals("provisioningState")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } provisioningState = new ProvisioningState(property0.Value.GetString()); continue; } if (property0.NameEquals("virtualHub")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } virtualHub = JsonSerializer.Deserialize <WritableSubResource>(property0.Value.ToString()); continue; } } continue; } } return(new ExpressRouteGatewayData(id.Value, name.Value, type.Value, location.Value, Optional.ToDictionary(tags), etag.Value, autoScaleConfiguration.Value, Optional.ToList(expressRouteConnections), Optional.ToNullable(provisioningState), virtualHub)); }