import 'package:selfprivacy/logic/api_maps/generic_result.dart'; import 'package:selfprivacy/logic/models/callback_dialogue_branching.dart'; import 'package:selfprivacy/logic/models/disk_size.dart'; import 'package:selfprivacy/logic/models/hive/server_details.dart'; import 'package:selfprivacy/logic/models/launch_installation_data.dart'; import 'package:selfprivacy/logic/models/metrics.dart'; import 'package:selfprivacy/logic/models/price.dart'; import 'package:selfprivacy/logic/models/server_basic_info.dart'; import 'package:selfprivacy/logic/models/server_metadata.dart'; import 'package:selfprivacy/logic/models/server_provider_location.dart'; import 'package:selfprivacy/logic/models/server_type.dart'; export 'package:selfprivacy/logic/api_maps/generic_result.dart'; export 'package:selfprivacy/logic/models/launch_installation_data.dart'; abstract class ServerProvider { /// Returns an assigned enum value, respectively to which /// provider implements [ServerProvider] interface. ServerProviderType get type; /// Returns [ServerBasicInfo] of all available machines /// assigned to the authorized user. /// /// Only with public IPv4 addresses. Future>> getServers(); /// Returns actual [ServerType] of the /// requested server entry assigned /// to the authorized user. Future> getServerType(final int serverId); /// Tries to launch installation of SelfPrivacy on /// the requested server entry for the authorized account. /// Depending on a server provider, the algorithm /// and instructions vary drastically. /// /// If successly launched, stores new server information. /// /// If failure, returns error dialogue information to /// write in ServerInstallationState. Future> launchInstallation( final LaunchInstallationData installationData, ); /// Tries to delete the requested server entry /// from the authorized account, including all assigned /// storage extensions. /// /// If failure, returns error dialogue information to /// write in ServerInstallationState. Future> deleteServer( final String hostname, ); /// Tries to access an account linked to the provided token. /// /// To generate a token for your account follow instructions of your /// server provider respectfully. /// /// If success, saves it for future usage. Future> tryInitApiByToken(final String token); /// Tries to assign the location shortcode for future usage. /// /// If API wasn't initialized with token by [tryInitApiByToken] beforehand, /// returns 'Not authorized!' error. Future> trySetServerLocation(final String location); /// Returns all available server locations /// of the authorized user's server provider. Future>> getAvailableLocations(); /// Returns [ServerType] of all available /// machine configurations available to the authorized account /// within the requested provider location, /// accessed from [getAvailableLocations]. Future>> getServerTypes({ required final ServerProviderLocation location, }); /// Tries to power on the requested accessible machine. /// /// If success, returns [DateTime] of when the server /// answered the request. Future> powerOn(final int serverId); /// Tries to restart the requested accessible machine. /// /// If success, returns [DateTime] of when the server /// answered the request. Future> restart(final int serverId); /// Returns [Price] information map of all additional resources, excluding /// main server type pricing Future> getAdditionalPricing(); /// Returns [ServerVolume] of all available volumes /// assigned to the authorized user and attached to active machine. Future>> getVolumes({final String? status}); /// Tries to create an empty unattached [ServerVolume]. /// /// If success, returns this volume information. Future> createVolume(final int gb); /// Tries to delete the requested accessible [ServerVolume]. Future> deleteVolume(final ServerVolume volume); /// Tries to resize the requested accessible [ServerVolume] /// to the provided size **(not by!)**, must be greater than current size. Future> resizeVolume( final ServerVolume volume, final DiskSize size, ); /// Tries to attach the requested accessible [ServerVolume] /// to an accessible machine by the provided identificator. Future> attachVolume( final ServerVolume volume, final int serverId, ); /// Tries to attach the requested accessible [ServerVolume] /// from any machine. Future> detachVolume(final ServerVolume volume); /// Returns metedata of an accessible machine by the provided identificator /// to show on ServerDetailsScreen. Future>> getMetadata( final int serverId, ); /// Returns information about cpu and bandwidth load within the provided /// time period of the requested accessible machine. Future> getMetrics( final int serverId, final DateTime start, final DateTime end, ); GenericResult get success => GenericResult(success: true, data: true); }