mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2024-08-21 12:31:51 +00:00
55 lines
2.1 KiB
Dart
55 lines
2.1 KiB
Dart
import 'package:selfprivacy/logic/api_maps/rest_maps/api_factory_settings.dart';
|
|
import 'package:selfprivacy/logic/api_maps/rest_maps/dns_providers/cloudflare/cloudflare_factory.dart';
|
|
import 'package:selfprivacy/logic/api_maps/rest_maps/dns_providers/dns_provider_factory.dart';
|
|
import 'package:selfprivacy/logic/api_maps/rest_maps/server_providers/digital_ocean/digital_ocean_factory.dart';
|
|
import 'package:selfprivacy/logic/api_maps/rest_maps/server_providers/hetzner/hetzner_factory.dart';
|
|
import 'package:selfprivacy/logic/api_maps/rest_maps/server_providers/server_provider_factory.dart';
|
|
import 'package:selfprivacy/logic/models/hive/server_details.dart';
|
|
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
|
|
|
class UnknownApiProviderException implements Exception {
|
|
UnknownApiProviderException(this.message);
|
|
final String message;
|
|
}
|
|
|
|
class ApiFactoryCreator {
|
|
static ServerProviderApiFactory createServerProviderApiFactory(
|
|
final ServerProviderApiFactorySettings settings,
|
|
) {
|
|
switch (settings.provider) {
|
|
case ServerProvider.hetzner:
|
|
return HetznerApiFactory(region: settings.location);
|
|
case ServerProvider.digitalOcean:
|
|
return DigitalOceanApiFactory(region: settings.location);
|
|
case ServerProvider.unknown:
|
|
throw UnknownApiProviderException('Unknown server provider');
|
|
}
|
|
}
|
|
|
|
static DnsProviderApiFactory createDnsProviderApiFactory(
|
|
final DnsProviderApiFactorySettings settings,
|
|
) {
|
|
switch (settings.provider) {
|
|
case DnsProvider.cloudflare:
|
|
return CloudflareApiFactory();
|
|
case DnsProvider.unknown:
|
|
throw UnknownApiProviderException('Unknown DNS provider');
|
|
}
|
|
}
|
|
}
|
|
|
|
class VolumeApiFactoryCreator {
|
|
static VolumeProviderApiFactory createVolumeProviderApiFactory(
|
|
final ServerProviderApiFactorySettings settings,
|
|
) {
|
|
switch (settings.provider) {
|
|
case ServerProvider.hetzner:
|
|
return HetznerApiFactory();
|
|
case ServerProvider.digitalOcean:
|
|
return DigitalOceanApiFactory();
|
|
case ServerProvider.unknown:
|
|
throw UnknownApiProviderException('Unknown volume provider');
|
|
}
|
|
}
|
|
}
|