public async Task <Response <NetworkInterface> > GetAsync(string resourceGroupName, string networkInterfaceName, string expand = null, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (networkInterfaceName == null) { throw new ArgumentNullException(nameof(networkInterfaceName)); } using var message = CreateGetRequest(resourceGroupName, networkInterfaceName, expand); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { NetworkInterface 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 = NetworkInterface.DeserializeNetworkInterface(document.RootElement); } return(Response.FromValue(value, message.Response)); }
internal static VirtualMachineTemplateData DeserializeVirtualMachineTemplateData(JsonElement element) { Optional <ExtendedLocation> extendedLocation = default; Optional <string> kind = default; IDictionary <string, string> tags = default; AzureLocation location = default; ResourceIdentifier id = default; string name = default; ResourceType type = default; SystemData systemData = default; Optional <string> uuid = default; Optional <string> vCenterId = default; Optional <string> moRefId = default; Optional <string> inventoryItemId = default; Optional <string> moName = default; Optional <int> memorySizeMB = default; Optional <int> numCPUs = default; Optional <int> numCoresPerSocket = default; Optional <OSType> osType = default; Optional <string> osName = default; Optional <string> folderPath = default; Optional <IReadOnlyList <NetworkInterface> > networkInterfaces = default; Optional <IReadOnlyList <VirtualDisk> > disks = default; Optional <string> customResourceName = default; Optional <string> toolsVersionStatus = default; Optional <string> toolsVersion = default; Optional <FirmwareType> firmwareType = default; Optional <IReadOnlyList <ResourceStatus> > statuses = default; Optional <string> provisioningState = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("extendedLocation")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } extendedLocation = ExtendedLocation.DeserializeExtendedLocation(property.Value); continue; } if (property.NameEquals("kind")) { kind = property.Value.GetString(); continue; } if (property.NameEquals("tags")) { 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("location")) { location = 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 = 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("uuid")) { uuid = property0.Value.GetString(); continue; } if (property0.NameEquals("vCenterId")) { vCenterId = property0.Value.GetString(); continue; } if (property0.NameEquals("moRefId")) { moRefId = property0.Value.GetString(); continue; } if (property0.NameEquals("inventoryItemId")) { inventoryItemId = property0.Value.GetString(); continue; } if (property0.NameEquals("moName")) { moName = property0.Value.GetString(); continue; } if (property0.NameEquals("memorySizeMB")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } memorySizeMB = property0.Value.GetInt32(); continue; } if (property0.NameEquals("numCPUs")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } numCPUs = property0.Value.GetInt32(); continue; } if (property0.NameEquals("numCoresPerSocket")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } numCoresPerSocket = property0.Value.GetInt32(); continue; } if (property0.NameEquals("osType")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } osType = new OSType(property0.Value.GetString()); continue; } if (property0.NameEquals("osName")) { osName = property0.Value.GetString(); continue; } if (property0.NameEquals("folderPath")) { folderPath = property0.Value.GetString(); continue; } if (property0.NameEquals("networkInterfaces")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <NetworkInterface> array = new List <NetworkInterface>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(NetworkInterface.DeserializeNetworkInterface(item)); } networkInterfaces = array; continue; } if (property0.NameEquals("disks")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <VirtualDisk> array = new List <VirtualDisk>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(VirtualDisk.DeserializeVirtualDisk(item)); } disks = array; continue; } if (property0.NameEquals("customResourceName")) { customResourceName = property0.Value.GetString(); continue; } if (property0.NameEquals("toolsVersionStatus")) { toolsVersionStatus = property0.Value.GetString(); continue; } if (property0.NameEquals("toolsVersion")) { toolsVersion = property0.Value.GetString(); continue; } if (property0.NameEquals("firmwareType")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } firmwareType = new FirmwareType(property0.Value.GetString()); continue; } if (property0.NameEquals("statuses")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <ResourceStatus> array = new List <ResourceStatus>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(ResourceStatus.DeserializeResourceStatus(item)); } statuses = array; continue; } if (property0.NameEquals("provisioningState")) { provisioningState = property0.Value.GetString(); continue; } } continue; } } return(new VirtualMachineTemplateData(id, name, type, systemData, tags, location, extendedLocation.Value, kind.Value, uuid.Value, vCenterId.Value, moRefId.Value, inventoryItemId.Value, moName.Value, Optional.ToNullable(memorySizeMB), Optional.ToNullable(numCPUs), Optional.ToNullable(numCoresPerSocket), Optional.ToNullable(osType), osName.Value, folderPath.Value, Optional.ToList(networkInterfaces), Optional.ToList(disks), customResourceName.Value, toolsVersionStatus.Value, toolsVersion.Value, Optional.ToNullable(firmwareType), Optional.ToList(statuses), provisioningState.Value)); }