53 lines
1.4 KiB
Dart
53 lines
1.4 KiB
Dart
import '../internal/json_utils.dart';
|
|
|
|
/// Detailed image data from `GET /libpod/images/{name}/json`.
|
|
final class ImageDetails {
|
|
/// Creates image details.
|
|
const ImageDetails({
|
|
required this.id,
|
|
required this.digest,
|
|
required this.repoTags,
|
|
required this.repoDigests,
|
|
required this.createdAt,
|
|
required this.size,
|
|
required this.raw,
|
|
});
|
|
|
|
/// Image ID.
|
|
final String id;
|
|
|
|
/// Image digest.
|
|
final String digest;
|
|
|
|
/// Known image tags.
|
|
final List<String> repoTags;
|
|
|
|
/// Known image digests.
|
|
final List<String> repoDigests;
|
|
|
|
/// Creation timestamp if present.
|
|
final DateTime? createdAt;
|
|
|
|
/// Image size in bytes.
|
|
final int size;
|
|
|
|
/// Raw payload.
|
|
final Map<String, Object?> raw;
|
|
|
|
/// Builds [ImageDetails] from JSON.
|
|
factory ImageDetails.fromJson(Map<String, Object?> json) {
|
|
return ImageDetails(
|
|
id: asString(json['Id']) ?? asString(json['ID']) ?? '',
|
|
digest: asString(json['Digest']) ?? asString(json['digest']) ?? '',
|
|
repoTags: asJsonList(
|
|
json['RepoTags'],
|
|
).map(asString).whereType<String>().toList(growable: false),
|
|
repoDigests: asJsonList(
|
|
json['RepoDigests'],
|
|
).map(asString).whereType<String>().toList(growable: false),
|
|
createdAt: DateTime.tryParse(asString(json['Created']) ?? ''),
|
|
size: asInt(json['Size']) ?? asInt(json['size']) ?? 0,
|
|
raw: json,
|
|
);
|
|
}
|
|
}
|