2022-07-14 13:34:08 +00:00
|
|
|
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';
|
2022-10-11 20:11:13 +00:00
|
|
|
import 'package:selfprivacy/logic/api_maps/rest_maps/server_providers/digital_ocean/digital_ocean_factory.dart';
|
2022-07-14 13:34:08 +00:00
|
|
|
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';
|
2022-07-12 12:54:16 +00:00
|
|
|
import 'package:selfprivacy/logic/models/hive/server_details.dart';
|
2022-07-14 13:34:08 +00:00
|
|
|
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
|
|
|
|
|
|
|
class UnknownApiProviderException implements Exception {
|
|
|
|
UnknownApiProviderException(this.message);
|
|
|
|
final String message;
|
|
|
|
}
|
2022-07-12 12:54:16 +00:00
|
|
|
|
|
|
|
class ApiFactoryCreator {
|
2022-07-14 13:34:08 +00:00
|
|
|
static ServerProviderApiFactory createServerProviderApiFactory(
|
2022-07-12 12:54:16 +00:00
|
|
|
final ServerProvider provider,
|
|
|
|
) {
|
|
|
|
switch (provider) {
|
|
|
|
case ServerProvider.hetzner:
|
|
|
|
return HetznerApiFactory();
|
2022-10-11 20:11:13 +00:00
|
|
|
case ServerProvider.digitalOcean:
|
|
|
|
return DigitalOceanApiFactory();
|
2022-07-14 13:34:08 +00:00
|
|
|
case ServerProvider.unknown:
|
|
|
|
throw UnknownApiProviderException('Unknown server provider');
|
2022-07-12 12:54:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-14 13:34:08 +00:00
|
|
|
static DnsProviderApiFactory createDnsProviderApiFactory(
|
|
|
|
final DnsProvider provider,
|
|
|
|
) {
|
|
|
|
switch (provider) {
|
|
|
|
case DnsProvider.cloudflare:
|
|
|
|
return CloudflareApiFactory();
|
|
|
|
case DnsProvider.unknown:
|
|
|
|
throw UnknownApiProviderException('Unknown DNS provider');
|
|
|
|
}
|
|
|
|
}
|
2022-07-12 12:54:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class VolumeApiFactoryCreator {
|
|
|
|
static VolumeProviderApiFactory createVolumeProviderApiFactory(
|
|
|
|
final ServerProvider provider,
|
|
|
|
) {
|
|
|
|
switch (provider) {
|
|
|
|
case ServerProvider.hetzner:
|
|
|
|
return HetznerApiFactory();
|
2022-10-11 20:11:13 +00:00
|
|
|
case ServerProvider.digitalOcean:
|
|
|
|
return DigitalOceanApiFactory();
|
2022-07-14 13:34:08 +00:00
|
|
|
case ServerProvider.unknown:
|
|
|
|
throw UnknownApiProviderException('Unknown volume provider');
|
2022-07-12 12:54:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|