part of 'server_api.dart'; mixin BackupsApi on GraphQLApiMap { Future> getBackups() async { List backups; QueryResult response; try { final GraphQLClient client = await getClient(); response = await client.query$AllBackupSnapshots(); if (response.hasException) { final message = response.exception.toString(); print(message); backups = []; } final List parsed = response.parsedData!.backup.allSnapshots .map( ( final Query$AllBackupSnapshots$backup$allSnapshots snapshot, ) => Backup.fromGraphQL(snapshot), ) .toList(); backups = parsed; } catch (e) { print(e); backups = []; } return backups; } Future getBackupsConfiguration() async { BackupConfiguration? backupConfiguration; QueryResult response; try { final GraphQLClient client = await getClient(); response = await client.query$BackupConfiguration(); if (response.hasException) { final message = response.exception.toString(); print(message); backupConfiguration = null; } final BackupConfiguration parsed = BackupConfiguration.fromGraphQL( response.parsedData!.backup.configuration, ); backupConfiguration = parsed; } catch (e) { print(e); backupConfiguration = null; } return backupConfiguration; } Future forceBackupListReload() async { try { final GraphQLClient client = await getClient(); await client.mutate$ForceSnapshotsReload(); } catch (e) { print(e); return GenericResult( success: false, data: null, message: e.toString(), ); } return GenericResult( success: true, data: null, ); } Future> startBackup(final String serviceId) async { QueryResult response; GenericResult? result; try { final GraphQLClient client = await getClient(); final variables = Variables$Mutation$StartBackup(serviceId: serviceId); final options = Options$Mutation$StartBackup(variables: variables); response = await client.mutate$StartBackup(options); if (response.hasException) { final message = response.exception.toString(); print(message); result = GenericResult( success: false, data: null, message: message, ); } result = GenericResult( success: true, data: ServerJob.fromGraphQL( response.parsedData!.backup.startBackup.job!, ), ); } catch (e) { print(e); result = GenericResult( success: false, data: null, message: e.toString(), ); } return result; } Future setAutobackupPeriod({final int? period}) async { QueryResult response; GenericResult? result; try { final GraphQLClient client = await getClient(); final variables = Variables$Mutation$SetAutobackupPeriod(period: period); final options = Options$Mutation$SetAutobackupPeriod(variables: variables); response = await client.mutate$SetAutobackupPeriod(options); if (response.hasException) { final message = response.exception.toString(); print(message); result = GenericResult( success: false, data: null, message: message, ); } result = GenericResult( success: true, data: null, ); } catch (e) { print(e); result = GenericResult( success: false, data: null, message: e.toString(), ); } return result; } Future setAutobackupQuotas( final AutobackupQuotas quotas, ) async { QueryResult response; GenericResult? result; try { final GraphQLClient client = await getClient(); final variables = Variables$Mutation$setAutobackupQuotas( quotas: Input$AutobackupQuotasInput( last: quotas.last, daily: quotas.daily, weekly: quotas.weekly, monthly: quotas.monthly, yearly: quotas.yearly, ), ); final options = Options$Mutation$setAutobackupQuotas(variables: variables); response = await client.mutate$setAutobackupQuotas(options); if (response.hasException) { final message = response.exception.toString(); print(message); result = GenericResult( success: false, data: null, message: message, ); } result = GenericResult( success: true, data: null, ); } catch (e) { print(e); result = GenericResult( success: false, data: null, message: e.toString(), ); } return result; } Future removeRepository() async { try { final GraphQLClient client = await getClient(); await client.mutate$RemoveRepository(); } catch (e) { print(e); return GenericResult( success: false, data: null, message: e.toString(), ); } return GenericResult( success: true, data: null, ); } Future initializeRepository( final InitializeRepositoryInput input, ) async { QueryResult response; GenericResult? result; try { final GraphQLClient client = await getClient(); final variables = Variables$Mutation$InitializeRepository( repository: Input$InitializeRepositoryInput( locationId: input.locationId, locationName: input.locationName, login: input.login, password: input.password, provider: input.provider.toGraphQL(), ), ); final options = Options$Mutation$InitializeRepository(variables: variables); response = await client.mutate$InitializeRepository(options); if (response.hasException) { final message = response.exception.toString(); print(message); result = GenericResult( success: false, data: null, message: message, ); } result = GenericResult( success: true, data: null, ); } catch (e) { print(e); result = GenericResult( success: false, data: null, message: e.toString(), ); } return result; } Future> restoreBackup( final String snapshotId, final BackupRestoreStrategy strategy, ) async { QueryResult response; GenericResult? result; try { final GraphQLClient client = await getClient(); final variables = Variables$Mutation$RestoreBackup( snapshotId: snapshotId, strategy: strategy.toGraphQL, ); final options = Options$Mutation$RestoreBackup(variables: variables); response = await client.mutate$RestoreBackup(options); if (response.hasException) { final message = response.exception.toString(); print(message); result = GenericResult( success: false, data: null, message: message, ); } result = GenericResult( success: true, data: ServerJob.fromGraphQL( response.parsedData!.backup.restoreBackup.job!, ), ); } catch (e) { print(e); result = GenericResult( success: false, data: null, message: e.toString(), ); } return result; } Future> forgetSnapshot( final String snapshotId, ) async { QueryResult response; GenericResult? result; try { final GraphQLClient client = await getClient(); final variables = Variables$Mutation$ForgetSnapshot( snapshotId: snapshotId, ); final options = Options$Mutation$ForgetSnapshot(variables: variables); response = await client.mutate$ForgetSnapshot(options); if (response.hasException) { final message = response.exception.toString(); print(message); result = GenericResult( success: false, data: null, message: message, ); } result = GenericResult( success: true, data: response.parsedData!.backup.forgetSnapshot.success, ); } catch (e) { print(e); result = GenericResult( success: false, data: null, message: e.toString(), ); } return result; } }