mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-09 01:21:14 +00:00
refactor(backups): Rename BackbaleCredential to BackupsCredential
Also adding provider field
This commit is contained in:
parent
4a7f986ff4
commit
a5bb654a76
|
@ -4,7 +4,7 @@ import 'dart:typed_data';
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
import 'package:hive_flutter/hive_flutter.dart';
|
import 'package:hive_flutter/hive_flutter.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/backblaze_bucket.dart';
|
import 'package:selfprivacy/logic/models/hive/backblaze_bucket.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/backblaze_credential.dart';
|
import 'package:selfprivacy/logic/models/hive/backups_credential.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/server_details.dart';
|
import 'package:selfprivacy/logic/models/hive/server_details.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/user.dart';
|
import 'package:selfprivacy/logic/models/hive/user.dart';
|
||||||
|
@ -111,7 +111,7 @@ class BNames {
|
||||||
/// A [ServerHostingDetails] field of [serverInstallationBox] box.
|
/// A [ServerHostingDetails] field of [serverInstallationBox] box.
|
||||||
static String serverDetails = 'hetznerServer';
|
static String serverDetails = 'hetznerServer';
|
||||||
|
|
||||||
/// A [BackblazeCredential] field of [serverInstallationBox] box.
|
/// A [BackupsCredential] field of [serverInstallationBox] box.
|
||||||
static String backblazeCredential = 'backblazeKey';
|
static String backblazeCredential = 'backblazeKey';
|
||||||
|
|
||||||
/// A [BackblazeBucket] field of [serverInstallationBox] box.
|
/// A [BackblazeBucket] field of [serverInstallationBox] box.
|
||||||
|
|
|
@ -4,7 +4,7 @@ import 'package:dio/dio.dart';
|
||||||
import 'package:selfprivacy/config/get_it_config.dart';
|
import 'package:selfprivacy/config/get_it_config.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/api_generic_result.dart';
|
import 'package:selfprivacy/logic/api_maps/api_generic_result.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/api_map.dart';
|
import 'package:selfprivacy/logic/api_maps/rest_maps/api_map.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/backblaze_credential.dart';
|
import 'package:selfprivacy/logic/models/hive/backups_credential.dart';
|
||||||
|
|
||||||
export 'package:selfprivacy/logic/api_maps/api_generic_result.dart';
|
export 'package:selfprivacy/logic/api_maps/api_generic_result.dart';
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ class BackblazeApi extends ApiMap {
|
||||||
responseType: ResponseType.json,
|
responseType: ResponseType.json,
|
||||||
);
|
);
|
||||||
if (isWithToken) {
|
if (isWithToken) {
|
||||||
final BackblazeCredential? backblazeCredential =
|
final BackupsCredential? backblazeCredential =
|
||||||
getIt<ApiConfigModel>().backblazeCredential;
|
getIt<ApiConfigModel>().backblazeCredential;
|
||||||
final String token = backblazeCredential!.applicationKey;
|
final String token = backblazeCredential!.applicationKey;
|
||||||
options.headers = {'Authorization': 'Basic $token'};
|
options.headers = {'Authorization': 'Basic $token'};
|
||||||
|
@ -56,7 +56,7 @@ class BackblazeApi extends ApiMap {
|
||||||
|
|
||||||
Future<BackblazeApiAuth> getAuthorizationToken() async {
|
Future<BackblazeApiAuth> getAuthorizationToken() async {
|
||||||
final Dio client = await getClient();
|
final Dio client = await getClient();
|
||||||
final BackblazeCredential? backblazeCredential =
|
final BackupsCredential? backblazeCredential =
|
||||||
getIt<ApiConfigModel>().backblazeCredential;
|
getIt<ApiConfigModel>().backblazeCredential;
|
||||||
if (backblazeCredential == null) {
|
if (backblazeCredential == null) {
|
||||||
throw Exception('Backblaze credential is null');
|
throw Exception('Backblaze credential is null');
|
||||||
|
@ -121,7 +121,7 @@ class BackblazeApi extends ApiMap {
|
||||||
// Create bucket
|
// Create bucket
|
||||||
Future<String> createBucket(final String bucketName) async {
|
Future<String> createBucket(final String bucketName) async {
|
||||||
final BackblazeApiAuth auth = await getAuthorizationToken();
|
final BackblazeApiAuth auth = await getAuthorizationToken();
|
||||||
final BackblazeCredential? backblazeCredential =
|
final BackupsCredential? backblazeCredential =
|
||||||
getIt<ApiConfigModel>().backblazeCredential;
|
getIt<ApiConfigModel>().backblazeCredential;
|
||||||
final Dio client = await getClient();
|
final Dio client = await getClient();
|
||||||
client.options.baseUrl = auth.apiUrl;
|
client.options.baseUrl = auth.apiUrl;
|
||||||
|
|
|
@ -3,7 +3,7 @@ import 'package:cubit_form/cubit_form.dart';
|
||||||
import 'package:selfprivacy/config/get_it_config.dart';
|
import 'package:selfprivacy/config/get_it_config.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/backblaze.dart';
|
import 'package:selfprivacy/logic/api_maps/rest_maps/backblaze.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/backblaze_credential.dart';
|
import 'package:selfprivacy/logic/models/hive/backups_credential.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
|
||||||
class BackblazeFormCubit extends FormCubit {
|
class BackblazeFormCubit extends FormCubit {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import 'package:selfprivacy/logic/api_maps/rest_maps/dns_providers/dns_provider_
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/server_providers/server_provider.dart';
|
import 'package:selfprivacy/logic/api_maps/rest_maps/server_providers/server_provider.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/server_providers/server_provider_api_settings.dart';
|
import 'package:selfprivacy/logic/api_maps/rest_maps/server_providers/server_provider_api_settings.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/staging_options.dart';
|
import 'package:selfprivacy/logic/api_maps/staging_options.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/backblaze_credential.dart';
|
import 'package:selfprivacy/logic/models/hive/backups_credential.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/server_details.dart';
|
import 'package:selfprivacy/logic/models/hive/server_details.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/user.dart';
|
import 'package:selfprivacy/logic/models/hive/user.dart';
|
||||||
|
@ -228,9 +228,10 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void setBackblazeKey(final String keyId, final String applicationKey) async {
|
void setBackblazeKey(final String keyId, final String applicationKey) async {
|
||||||
final BackblazeCredential backblazeCredential = BackblazeCredential(
|
final BackupsCredential backblazeCredential = BackupsCredential(
|
||||||
keyId: keyId,
|
keyId: keyId,
|
||||||
applicationKey: applicationKey,
|
applicationKey: applicationKey,
|
||||||
|
provider: BackupsProvider.backblaze,
|
||||||
);
|
);
|
||||||
await repository.saveBackblazeKey(backblazeCredential);
|
await repository.saveBackblazeKey(backblazeCredential);
|
||||||
if (state is ServerInstallationRecovery) {
|
if (state is ServerInstallationRecovery) {
|
||||||
|
@ -735,7 +736,7 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void finishRecoveryProcess(
|
void finishRecoveryProcess(
|
||||||
final BackblazeCredential backblazeCredential,
|
final BackupsCredential backblazeCredential,
|
||||||
) async {
|
) async {
|
||||||
await repository.saveIsServerStarted(true);
|
await repository.saveIsServerStarted(true);
|
||||||
await repository.saveIsServerResetedFirstTime(true);
|
await repository.saveIsServerResetedFirstTime(true);
|
||||||
|
|
|
@ -16,7 +16,7 @@ import 'package:selfprivacy/logic/api_maps/graphql_maps/server_api/server_api.da
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/server_providers/server_provider.dart';
|
import 'package:selfprivacy/logic/api_maps/rest_maps/server_providers/server_provider.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/staging_options.dart';
|
import 'package:selfprivacy/logic/api_maps/staging_options.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/backblaze_credential.dart';
|
import 'package:selfprivacy/logic/models/hive/backups_credential.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/server_details.dart';
|
import 'package:selfprivacy/logic/models/hive/server_details.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/user.dart';
|
import 'package:selfprivacy/logic/models/hive/user.dart';
|
||||||
|
@ -49,7 +49,7 @@ class ServerInstallationRepository {
|
||||||
final ServerDomain? serverDomain = getIt<ApiConfigModel>().serverDomain;
|
final ServerDomain? serverDomain = getIt<ApiConfigModel>().serverDomain;
|
||||||
final ServerProvider? serverProvider =
|
final ServerProvider? serverProvider =
|
||||||
getIt<ApiConfigModel>().serverProvider;
|
getIt<ApiConfigModel>().serverProvider;
|
||||||
final BackblazeCredential? backblazeCredential =
|
final BackupsCredential? backblazeCredential =
|
||||||
getIt<ApiConfigModel>().backblazeCredential;
|
getIt<ApiConfigModel>().backblazeCredential;
|
||||||
final ServerHostingDetails? serverDetails =
|
final ServerHostingDetails? serverDetails =
|
||||||
getIt<ApiConfigModel>().serverDetails;
|
getIt<ApiConfigModel>().serverDetails;
|
||||||
|
@ -228,7 +228,7 @@ class ServerInstallationRepository {
|
||||||
final User rootUser,
|
final User rootUser,
|
||||||
final String domainName,
|
final String domainName,
|
||||||
final String dnsApiToken,
|
final String dnsApiToken,
|
||||||
final BackblazeCredential backblazeCredential, {
|
final BackupsCredential backblazeCredential, {
|
||||||
required final void Function() onCancel,
|
required final void Function() onCancel,
|
||||||
required final Future<void> Function(ServerHostingDetails serverDetails)
|
required final Future<void> Function(ServerHostingDetails serverDetails)
|
||||||
onSuccess,
|
onSuccess,
|
||||||
|
@ -706,7 +706,7 @@ class ServerInstallationRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> saveBackblazeKey(
|
Future<void> saveBackblazeKey(
|
||||||
final BackblazeCredential backblazeCredential,
|
final BackupsCredential backblazeCredential,
|
||||||
) async {
|
) async {
|
||||||
await getIt<ApiConfigModel>().storeBackblazeCredential(backblazeCredential);
|
await getIt<ApiConfigModel>().storeBackblazeCredential(backblazeCredential);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ abstract class ServerInstallationState extends Equatable {
|
||||||
final String? providerApiToken;
|
final String? providerApiToken;
|
||||||
final String? dnsApiToken;
|
final String? dnsApiToken;
|
||||||
final String? serverTypeIdentificator;
|
final String? serverTypeIdentificator;
|
||||||
final BackblazeCredential? backblazeCredential;
|
final BackupsCredential? backblazeCredential;
|
||||||
final ServerDomain? serverDomain;
|
final ServerDomain? serverDomain;
|
||||||
final User? rootUser;
|
final User? rootUser;
|
||||||
final ServerHostingDetails? serverDetails;
|
final ServerHostingDetails? serverDetails;
|
||||||
|
@ -161,7 +161,7 @@ class ServerInstallationNotFinished extends ServerInstallationState {
|
||||||
final String? providerApiToken,
|
final String? providerApiToken,
|
||||||
final String? serverTypeIdentificator,
|
final String? serverTypeIdentificator,
|
||||||
final String? dnsApiToken,
|
final String? dnsApiToken,
|
||||||
final BackblazeCredential? backblazeCredential,
|
final BackupsCredential? backblazeCredential,
|
||||||
final ServerDomain? serverDomain,
|
final ServerDomain? serverDomain,
|
||||||
final User? rootUser,
|
final User? rootUser,
|
||||||
final ServerHostingDetails? serverDetails,
|
final ServerHostingDetails? serverDetails,
|
||||||
|
@ -226,7 +226,7 @@ class ServerInstallationFinished extends ServerInstallationState {
|
||||||
required String super.providerApiToken,
|
required String super.providerApiToken,
|
||||||
required String super.serverTypeIdentificator,
|
required String super.serverTypeIdentificator,
|
||||||
required String super.dnsApiToken,
|
required String super.dnsApiToken,
|
||||||
required BackblazeCredential super.backblazeCredential,
|
required BackupsCredential super.backblazeCredential,
|
||||||
required ServerDomain super.serverDomain,
|
required ServerDomain super.serverDomain,
|
||||||
required User super.rootUser,
|
required User super.rootUser,
|
||||||
required ServerHostingDetails super.serverDetails,
|
required ServerHostingDetails super.serverDetails,
|
||||||
|
@ -309,7 +309,7 @@ class ServerInstallationRecovery extends ServerInstallationState {
|
||||||
final String? providerApiToken,
|
final String? providerApiToken,
|
||||||
final String? serverTypeIdentificator,
|
final String? serverTypeIdentificator,
|
||||||
final String? dnsApiToken,
|
final String? dnsApiToken,
|
||||||
final BackblazeCredential? backblazeCredential,
|
final BackupsCredential? backblazeCredential,
|
||||||
final ServerDomain? serverDomain,
|
final ServerDomain? serverDomain,
|
||||||
final User? rootUser,
|
final User? rootUser,
|
||||||
final ServerHostingDetails? serverDetails,
|
final ServerHostingDetails? serverDetails,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:selfprivacy/config/hive_config.dart';
|
import 'package:selfprivacy/config/hive_config.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/backblaze_bucket.dart';
|
import 'package:selfprivacy/logic/models/hive/backblaze_bucket.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/backblaze_credential.dart';
|
import 'package:selfprivacy/logic/models/hive/backups_credential.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/server_details.dart';
|
import 'package:selfprivacy/logic/models/hive/server_details.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ class ApiConfigModel {
|
||||||
ServerProvider? get serverProvider => _serverProvider;
|
ServerProvider? get serverProvider => _serverProvider;
|
||||||
DnsProvider? get dnsProvider => _dnsProvider;
|
DnsProvider? get dnsProvider => _dnsProvider;
|
||||||
|
|
||||||
BackblazeCredential? get backblazeCredential => _backblazeCredential;
|
BackupsCredential? get backblazeCredential => _backblazeCredential;
|
||||||
ServerDomain? get serverDomain => _serverDomain;
|
ServerDomain? get serverDomain => _serverDomain;
|
||||||
BackblazeBucket? get backblazeBucket => _backblazeBucket;
|
BackblazeBucket? get backblazeBucket => _backblazeBucket;
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ class ApiConfigModel {
|
||||||
ServerProvider? _serverProvider;
|
ServerProvider? _serverProvider;
|
||||||
DnsProvider? _dnsProvider;
|
DnsProvider? _dnsProvider;
|
||||||
ServerHostingDetails? _serverDetails;
|
ServerHostingDetails? _serverDetails;
|
||||||
BackblazeCredential? _backblazeCredential;
|
BackupsCredential? _backblazeCredential;
|
||||||
ServerDomain? _serverDomain;
|
ServerDomain? _serverDomain;
|
||||||
BackblazeBucket? _backblazeBucket;
|
BackblazeBucket? _backblazeBucket;
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ class ApiConfigModel {
|
||||||
_serverLocation = serverLocation;
|
_serverLocation = serverLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> storeBackblazeCredential(final BackblazeCredential value) async {
|
Future<void> storeBackblazeCredential(final BackupsCredential value) async {
|
||||||
await _box.put(BNames.backblazeCredential, value);
|
await _box.put(BNames.backblazeCredential, value);
|
||||||
_backblazeCredential = value;
|
_backblazeCredential = value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,3 +12,4 @@
|
||||||
100. DnsProvider
|
100. DnsProvider
|
||||||
101. ServerProvider
|
101. ServerProvider
|
||||||
102. UserType
|
102. UserType
|
||||||
|
103. BackupsProvider
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
import 'package:hive/hive.dart';
|
|
||||||
|
|
||||||
part 'backblaze_credential.g.dart';
|
|
||||||
|
|
||||||
@HiveType(typeId: 4)
|
|
||||||
class BackblazeCredential {
|
|
||||||
BackblazeCredential({required this.keyId, required this.applicationKey});
|
|
||||||
|
|
||||||
@HiveField(0)
|
|
||||||
final String keyId;
|
|
||||||
|
|
||||||
@HiveField(1)
|
|
||||||
final String applicationKey;
|
|
||||||
|
|
||||||
String get encodedApiKey => encodedBackblazeKey(keyId, applicationKey);
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() => '$keyId: $encodedApiKey';
|
|
||||||
}
|
|
||||||
|
|
||||||
String encodedBackblazeKey(final String? keyId, final String? applicationKey) {
|
|
||||||
final String apiKey = '$keyId:$applicationKey';
|
|
||||||
final String encodedApiKey = base64.encode(utf8.encode(apiKey));
|
|
||||||
return encodedApiKey;
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
||||||
|
|
||||||
part of 'backblaze_credential.dart';
|
|
||||||
|
|
||||||
// **************************************************************************
|
|
||||||
// TypeAdapterGenerator
|
|
||||||
// **************************************************************************
|
|
||||||
|
|
||||||
class BackblazeCredentialAdapter extends TypeAdapter<BackblazeCredential> {
|
|
||||||
@override
|
|
||||||
final int typeId = 4;
|
|
||||||
|
|
||||||
@override
|
|
||||||
BackblazeCredential read(BinaryReader reader) {
|
|
||||||
final numOfFields = reader.readByte();
|
|
||||||
final fields = <int, dynamic>{
|
|
||||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
|
||||||
};
|
|
||||||
return BackblazeCredential(
|
|
||||||
keyId: fields[0] as String,
|
|
||||||
applicationKey: fields[1] as String,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void write(BinaryWriter writer, BackblazeCredential obj) {
|
|
||||||
writer
|
|
||||||
..writeByte(2)
|
|
||||||
..writeByte(0)
|
|
||||||
..write(obj.keyId)
|
|
||||||
..writeByte(1)
|
|
||||||
..write(obj.applicationKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => typeId.hashCode;
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) =>
|
|
||||||
identical(this, other) ||
|
|
||||||
other is BackblazeCredentialAdapter &&
|
|
||||||
runtimeType == other.runtimeType &&
|
|
||||||
typeId == other.typeId;
|
|
||||||
}
|
|
51
lib/logic/models/hive/backups_credential.dart
Normal file
51
lib/logic/models/hive/backups_credential.dart
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:hive/hive.dart';
|
||||||
|
import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/schema.graphql.dart';
|
||||||
|
|
||||||
|
part 'backups_credential.g.dart';
|
||||||
|
|
||||||
|
@HiveType(typeId: 4)
|
||||||
|
class BackupsCredential {
|
||||||
|
BackupsCredential({required this.keyId, required this.applicationKey, required this.provider});
|
||||||
|
|
||||||
|
@HiveField(0)
|
||||||
|
final String keyId;
|
||||||
|
|
||||||
|
@HiveField(1)
|
||||||
|
final String applicationKey;
|
||||||
|
|
||||||
|
@HiveField(2, defaultValue: BackupsProvider.backblaze)
|
||||||
|
final BackupsProvider provider;
|
||||||
|
|
||||||
|
String get encodedApiKey => encodedBackblazeKey(keyId, applicationKey);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() => '$keyId: $encodedApiKey';
|
||||||
|
}
|
||||||
|
|
||||||
|
String encodedBackblazeKey(final String? keyId, final String? applicationKey) {
|
||||||
|
final String apiKey = '$keyId:$applicationKey';
|
||||||
|
final String encodedApiKey = base64.encode(utf8.encode(apiKey));
|
||||||
|
return encodedApiKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
@HiveType(typeId: 103)
|
||||||
|
enum BackupsProvider {
|
||||||
|
@HiveField(0)
|
||||||
|
none,
|
||||||
|
@HiveField(1)
|
||||||
|
memory,
|
||||||
|
@HiveField(2)
|
||||||
|
file,
|
||||||
|
@HiveField(3)
|
||||||
|
backblaze;
|
||||||
|
|
||||||
|
factory BackupsProvider.fromGraphQL(final Enum$BackupProvider provider) => switch (provider) {
|
||||||
|
Enum$BackupProvider.NONE => none,
|
||||||
|
Enum$BackupProvider.MEMORY => memory,
|
||||||
|
Enum$BackupProvider.FILE => file,
|
||||||
|
Enum$BackupProvider.BACKBLAZE => backblaze,
|
||||||
|
Enum$BackupProvider.$unknown => none
|
||||||
|
};
|
||||||
|
}
|
93
lib/logic/models/hive/backups_credential.g.dart
Normal file
93
lib/logic/models/hive/backups_credential.g.dart
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
|
||||||
|
part of 'backups_credential.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// TypeAdapterGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
class BackblazeCredentialAdapter extends TypeAdapter<BackblazeCredential> {
|
||||||
|
@override
|
||||||
|
final int typeId = 4;
|
||||||
|
|
||||||
|
@override
|
||||||
|
BackblazeCredential read(BinaryReader reader) {
|
||||||
|
final numOfFields = reader.readByte();
|
||||||
|
final fields = <int, dynamic>{
|
||||||
|
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||||
|
};
|
||||||
|
return BackblazeCredential(
|
||||||
|
keyId: fields[0] as String,
|
||||||
|
applicationKey: fields[1] as String,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void write(BinaryWriter writer, BackblazeCredential obj) {
|
||||||
|
writer
|
||||||
|
..writeByte(2)
|
||||||
|
..writeByte(0)
|
||||||
|
..write(obj.keyId)
|
||||||
|
..writeByte(1)
|
||||||
|
..write(obj.applicationKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => typeId.hashCode;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) =>
|
||||||
|
identical(this, other) ||
|
||||||
|
other is BackblazeCredentialAdapter &&
|
||||||
|
runtimeType == other.runtimeType &&
|
||||||
|
typeId == other.typeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
class BackupsProviderAdapter extends TypeAdapter<BackupsProvider> {
|
||||||
|
@override
|
||||||
|
final int typeId = 103;
|
||||||
|
|
||||||
|
@override
|
||||||
|
BackupsProvider read(BinaryReader reader) {
|
||||||
|
switch (reader.readByte()) {
|
||||||
|
case 0:
|
||||||
|
return BackupsProvider.none;
|
||||||
|
case 1:
|
||||||
|
return BackupsProvider.memory;
|
||||||
|
case 2:
|
||||||
|
return BackupsProvider.file;
|
||||||
|
case 3:
|
||||||
|
return BackupsProvider.backblaze;
|
||||||
|
default:
|
||||||
|
return BackupsProvider.none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void write(BinaryWriter writer, BackupsProvider obj) {
|
||||||
|
switch (obj) {
|
||||||
|
case BackupsProvider.none:
|
||||||
|
writer.writeByte(0);
|
||||||
|
break;
|
||||||
|
case BackupsProvider.memory:
|
||||||
|
writer.writeByte(1);
|
||||||
|
break;
|
||||||
|
case BackupsProvider.file:
|
||||||
|
writer.writeByte(2);
|
||||||
|
break;
|
||||||
|
case BackupsProvider.backblaze:
|
||||||
|
writer.writeByte(3);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => typeId.hashCode;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) =>
|
||||||
|
identical(this, other) ||
|
||||||
|
other is BackupsProviderAdapter &&
|
||||||
|
runtimeType == other.runtimeType &&
|
||||||
|
typeId == other.typeId;
|
||||||
|
}
|
Loading…
Reference in a new issue