2023-12-29 23:45:33 +00:00
|
|
|
import '../models/build.dart';
|
2023-12-29 17:13:51 +00:00
|
|
|
import 'api_client.dart';
|
|
|
|
|
|
|
|
extension BuildsAPI on ApiClient {
|
2023-12-30 21:23:42 +00:00
|
|
|
Future<List<Build>> listAllBuilds({int? pkgID, int? limit}) async {
|
|
|
|
String uri = "/builds?";
|
|
|
|
if (pkgID != null) {
|
|
|
|
uri += "pkgid=$pkgID";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (limit != null) {
|
|
|
|
uri += "limit=$limit";
|
|
|
|
}
|
|
|
|
|
|
|
|
final resp = await getRawClient().get(uri);
|
2023-12-29 17:13:51 +00:00
|
|
|
|
|
|
|
final responseObject = resp.data as List;
|
|
|
|
final List<Build> packages =
|
2023-12-29 23:45:33 +00:00
|
|
|
responseObject.map((e) => Build.fromJson(e)).toList(growable: false);
|
2023-12-29 17:13:51 +00:00
|
|
|
return packages;
|
|
|
|
}
|
2023-12-30 15:46:13 +00:00
|
|
|
|
|
|
|
Future<Build> getBuild(int id) async {
|
2024-02-17 18:50:15 +00:00
|
|
|
final resp = await getRawClient().get("/build/${id}");
|
2023-12-30 15:46:13 +00:00
|
|
|
return Build.fromJson(resp.data);
|
|
|
|
}
|
|
|
|
|
2024-02-17 18:50:15 +00:00
|
|
|
Future<bool> deleteBuild(int id) async {
|
|
|
|
final resp = await getRawClient().delete("/build/${id}");
|
|
|
|
return resp.statusCode == 400;
|
|
|
|
}
|
|
|
|
|
2023-12-30 15:46:13 +00:00
|
|
|
Future<String> getOutput({int? line, required int buildID}) async {
|
2024-02-17 18:50:15 +00:00
|
|
|
String uri = "/build/$buildID/output";
|
2023-12-30 15:46:13 +00:00
|
|
|
if (line != null) {
|
2024-02-17 18:50:15 +00:00
|
|
|
uri += "?startline=$line";
|
2023-12-30 15:46:13 +00:00
|
|
|
}
|
|
|
|
final resp = await getRawClient().get(uri);
|
|
|
|
return resp.data.toString();
|
|
|
|
}
|
2023-12-29 17:13:51 +00:00
|
|
|
}
|