109 lines
3 KiB
Dart
109 lines
3 KiB
Dart
part of 'podman_client.dart';
|
|
|
|
extension PodmanClientManifestApi on PodmanClient {
|
|
/// Creates a manifest list.
|
|
Future<ManifestCreateResult> createManifest(
|
|
String name, {
|
|
ManifestCreateOptions options = const ManifestCreateOptions(),
|
|
Duration? timeout,
|
|
}) async {
|
|
final response = await _send(
|
|
method: HttpMethod.post,
|
|
path: '/manifests/${_encodePath(name)}',
|
|
queryParameters: options.toQueryParameters(),
|
|
expectedStatusCodes: const <int>{200, 201},
|
|
timeout: timeout,
|
|
);
|
|
|
|
return ManifestCreateResult.fromJson(
|
|
_decodeObject(response.bodyText, '/manifests/$name'),
|
|
);
|
|
}
|
|
|
|
/// Whether a manifest list exists.
|
|
Future<bool> manifestExists(String name, {Duration? timeout}) async {
|
|
final response = await _send(
|
|
method: HttpMethod.get,
|
|
path: '/manifests/${_encodePath(name)}/exists',
|
|
expectedStatusCodes: const <int>{204, 404},
|
|
timeout: timeout,
|
|
);
|
|
return response.statusCode == 204;
|
|
}
|
|
|
|
/// Inspects a manifest list.
|
|
Future<ManifestDetails> inspectManifest(
|
|
String name, {
|
|
bool? tlsVerify,
|
|
Duration? timeout,
|
|
}) async {
|
|
final payload = await _getObject(
|
|
'/manifests/${_encodePath(name)}/json',
|
|
queryParameters: <String, List<String>>{
|
|
if (tlsVerify != null) 'tlsVerify': <String>['$tlsVerify'],
|
|
},
|
|
timeout: timeout,
|
|
);
|
|
return ManifestDetails.fromJson(payload);
|
|
}
|
|
|
|
/// Pushes a manifest list to a registry.
|
|
Future<ManifestPushResult> pushManifest(
|
|
String name,
|
|
String destination, {
|
|
bool all = true,
|
|
bool? tlsVerify,
|
|
bool quiet = true,
|
|
Duration? timeout,
|
|
}) async {
|
|
final response = await _send(
|
|
method: HttpMethod.post,
|
|
path:
|
|
'/manifests/${_encodePath(name)}/registry/${_encodePath(destination)}',
|
|
queryParameters: <String, List<String>>{
|
|
'all': <String>['$all'],
|
|
'quiet': <String>['$quiet'],
|
|
if (tlsVerify != null) 'tlsVerify': <String>['$tlsVerify'],
|
|
},
|
|
expectedStatusCodes: const <int>{200},
|
|
timeout: timeout,
|
|
);
|
|
|
|
return ManifestPushResult.fromJson(
|
|
_decodeObject(
|
|
response.bodyText,
|
|
'/manifests/$name/registry/$destination',
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Deletes a manifest list.
|
|
Future<ManifestDeleteResult> deleteManifest(
|
|
String name, {
|
|
bool ignoreMissing = false,
|
|
Duration? timeout,
|
|
}) async {
|
|
final response = await _send(
|
|
method: HttpMethod.delete,
|
|
path: '/manifests/${_encodePath(name)}',
|
|
expectedStatusCodes: ignoreMissing
|
|
? const <int>{200, 202, 204, 404}
|
|
: const <int>{200, 202, 204},
|
|
timeout: timeout,
|
|
);
|
|
|
|
if (response.bodyText.trim().isEmpty) {
|
|
return const ManifestDeleteResult(
|
|
deleted: <String>[],
|
|
untagged: <String>[],
|
|
exitCode: 0,
|
|
errors: <String>[],
|
|
raw: <String, Object?>{},
|
|
);
|
|
}
|
|
|
|
return ManifestDeleteResult.fromJson(
|
|
_decodeObject(response.bodyText, '/manifests/$name'),
|
|
);
|
|
}
|
|
}
|