2023-05-25 03:02:10 +00:00
|
|
|
import 'package:selfprivacy/logic/api_maps/generic_result.dart';
|
|
|
|
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
|
|
|
import 'package:selfprivacy/logic/models/json/dns_records.dart';
|
|
|
|
export 'package:selfprivacy/logic/api_maps/generic_result.dart';
|
|
|
|
|
|
|
|
abstract class DnsProvider {
|
2023-06-29 18:38:46 +00:00
|
|
|
/// Returns an assigned enum value, respectively to which
|
|
|
|
/// provider implements [DnsProvider] interface.
|
2023-06-02 05:44:34 +00:00
|
|
|
DnsProviderType get type;
|
2023-06-29 18:38:46 +00:00
|
|
|
|
2023-11-27 15:00:05 +00:00
|
|
|
/// Returns a full url to a guide on how to setup
|
|
|
|
/// DNS provider nameservers
|
|
|
|
String get howToRegistar;
|
|
|
|
|
2023-06-29 18:38:46 +00:00
|
|
|
/// Tries to access an account linked to the provided token.
|
|
|
|
///
|
|
|
|
/// To generate a token for your account follow instructions of your
|
|
|
|
/// DNS provider respectfully.
|
|
|
|
///
|
|
|
|
/// If success, saves it for future usage.
|
2023-05-25 03:02:10 +00:00
|
|
|
Future<GenericResult<bool>> tryInitApiByToken(final String token);
|
2023-07-05 09:34:35 +00:00
|
|
|
|
|
|
|
/// Returns list of all available domain entries assigned to the account.
|
2023-11-09 12:31:30 +00:00
|
|
|
Future<GenericResult<List<ServerDomain>>> domainList();
|
2023-07-05 09:34:35 +00:00
|
|
|
|
2024-01-15 08:52:28 +00:00
|
|
|
/// Tries to create domain records
|
|
|
|
/// by our records list.
|
2023-07-05 09:34:35 +00:00
|
|
|
///
|
|
|
|
/// Doesn't check for duplication, cleaning has
|
|
|
|
/// to be done beforehand by [removeDomainRecords]
|
|
|
|
Future<GenericResult<void>> createDomainRecords({
|
2024-01-15 08:52:28 +00:00
|
|
|
required final List<DnsRecord> records,
|
2023-05-25 03:02:10 +00:00
|
|
|
required final ServerDomain domain,
|
|
|
|
});
|
2023-07-05 09:34:35 +00:00
|
|
|
|
2024-01-15 08:52:28 +00:00
|
|
|
/// Tries to remove all records of requested
|
|
|
|
/// domain that match our records list.
|
2023-07-05 09:34:35 +00:00
|
|
|
Future<GenericResult<void>> removeDomainRecords({
|
2024-01-15 08:52:28 +00:00
|
|
|
required final List<DnsRecord> records,
|
2023-05-25 03:02:10 +00:00
|
|
|
required final ServerDomain domain,
|
|
|
|
});
|
2023-07-05 09:34:35 +00:00
|
|
|
|
|
|
|
/// Returns list of all [DnsRecord] entries assigned to requested domain.
|
|
|
|
Future<GenericResult<List<DnsRecord>>> getDnsRecords({
|
2023-05-25 03:02:10 +00:00
|
|
|
required final ServerDomain domain,
|
|
|
|
});
|
2023-07-05 09:34:35 +00:00
|
|
|
|
|
|
|
/// Tries to create or update a domain record needed
|
|
|
|
/// on requested domain.
|
|
|
|
///
|
|
|
|
/// Doesn't check for duplication, cleaning has
|
|
|
|
/// to be done beforehand by [removeDomainRecords]
|
2023-05-25 03:02:10 +00:00
|
|
|
Future<GenericResult<void>> setDnsRecord(
|
|
|
|
final DnsRecord record,
|
|
|
|
final ServerDomain domain,
|
|
|
|
);
|
2024-07-18 14:26:31 +00:00
|
|
|
|
|
|
|
/// Tries to update existing domain records
|
|
|
|
///
|
|
|
|
/// If [oldRecords] is provided, it will also remove the records that
|
|
|
|
/// are not in [newRecords
|
|
|
|
Future<GenericResult<void>> updateDnsRecords({
|
|
|
|
required final List<DnsRecord> newRecords,
|
|
|
|
required final ServerDomain domain,
|
|
|
|
final List<DnsRecord>? oldRecords,
|
|
|
|
});
|
2023-05-25 03:02:10 +00:00
|
|
|
}
|