internal ContainerInfo(DateTimeOffset?currentTimeStamp, DateTimeOffset?previousTimeStamp, ContainerCpuStatistics currentCpuStats, ContainerCpuStatistics previousCpuStats, ContainerMemoryStatistics memoryStats, string name, string id, ContainerNetworkInterfaceStatistics eth0) { CurrentTimeStamp = currentTimeStamp; PreviousTimeStamp = previousTimeStamp; CurrentCpuStats = currentCpuStats; PreviousCpuStats = previousCpuStats; MemoryStats = memoryStats; Name = name; Id = id; Eth0 = eth0; }
internal static ContainerInfo DeserializeContainerInfo(JsonElement element) { Optional <DateTimeOffset> currentTimeStamp = default; Optional <DateTimeOffset> previousTimeStamp = default; Optional <ContainerCpuStatistics> currentCpuStats = default; Optional <ContainerCpuStatistics> previousCpuStats = default; Optional <ContainerMemoryStatistics> memoryStats = default; Optional <string> name = default; Optional <string> id = default; Optional <ContainerNetworkInterfaceStatistics> eth0 = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("currentTimeStamp")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } currentTimeStamp = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("previousTimeStamp")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } previousTimeStamp = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("currentCpuStats")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } currentCpuStats = ContainerCpuStatistics.DeserializeContainerCpuStatistics(property.Value); continue; } if (property.NameEquals("previousCpuStats")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } previousCpuStats = ContainerCpuStatistics.DeserializeContainerCpuStatistics(property.Value); continue; } if (property.NameEquals("memoryStats")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } memoryStats = ContainerMemoryStatistics.DeserializeContainerMemoryStatistics(property.Value); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("id")) { id = property.Value.GetString(); continue; } if (property.NameEquals("eth0")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } eth0 = ContainerNetworkInterfaceStatistics.DeserializeContainerNetworkInterfaceStatistics(property.Value); continue; } } return(new ContainerInfo(Optional.ToNullable(currentTimeStamp), Optional.ToNullable(previousTimeStamp), currentCpuStats.Value, previousCpuStats.Value, memoryStats.Value, name.Value, id.Value, eth0.Value)); }