48 lines
1.2 KiB
Dart
48 lines
1.2 KiB
Dart
import 'package:term_remote_ctl/core/network/agent_api_client.dart';
|
|
|
|
import 'project.dart';
|
|
|
|
class ProjectRepository {
|
|
ProjectRepository(this._client);
|
|
|
|
final AgentApiClient _client;
|
|
|
|
Future<List<Project>> listProjects() async {
|
|
final projects = await _client.listProjects();
|
|
return projects.map(Project.fromJson).toList(growable: false);
|
|
}
|
|
|
|
Future<Project> createProject({
|
|
required String name,
|
|
required String workingDirectory,
|
|
}) async {
|
|
final project = await _client.createProject(
|
|
name: name,
|
|
workingDirectory: workingDirectory,
|
|
);
|
|
return Project.fromJson(project);
|
|
}
|
|
|
|
Future<Project> updateProject({
|
|
required String projectId,
|
|
required String name,
|
|
required String workingDirectory,
|
|
}) async {
|
|
final project = await _client.updateProject(
|
|
projectId: projectId,
|
|
name: name,
|
|
workingDirectory: workingDirectory,
|
|
);
|
|
return Project.fromJson(project);
|
|
}
|
|
|
|
Future<ProjectDetail> getProjectDetail(String projectId) async {
|
|
final detail = await _client.getProjectDetail(projectId);
|
|
return ProjectDetail.fromJson(detail);
|
|
}
|
|
|
|
Future<void> deleteProject(String projectId) {
|
|
return _client.deleteProject(projectId);
|
|
}
|
|
}
|