selfprivacy.org.app/lib/logic/models/hive/server_details.dart
NaiJi f40ed08b02 feat(volume): Implement volume endpoints for Digital Ocean
volumeId type in VolumeApiProvider interfaces is now replaced with String from int to support Digital Ocean's UUID notation
2022-10-12 04:56:08 +00:00

87 lines
1.6 KiB
Dart

import 'package:hive/hive.dart';
part 'server_details.g.dart';
@HiveType(typeId: 2)
class ServerHostingDetails {
ServerHostingDetails({
required this.ip4,
required this.id,
required this.createTime,
required this.volume,
required this.apiToken,
required this.provider,
this.startTime,
});
@HiveField(0)
final String ip4;
@HiveField(1)
final int id;
@HiveField(3)
final DateTime? createTime;
@HiveField(2)
final DateTime? startTime;
@HiveField(4)
final ServerVolume volume;
@HiveField(5)
final String apiToken;
@HiveField(6, defaultValue: ServerProvider.hetzner)
final ServerProvider provider;
ServerHostingDetails copyWith({final DateTime? startTime}) =>
ServerHostingDetails(
startTime: startTime ?? this.startTime,
createTime: createTime,
id: id,
ip4: ip4,
volume: volume,
apiToken: apiToken,
provider: provider,
);
@override
String toString() => id.toString();
}
@HiveType(typeId: 5)
class ServerVolume {
ServerVolume({
required this.id,
required this.name,
required this.sizeByte,
required this.serverId,
required this.linuxDevice,
this.uuid,
});
@HiveField(1)
int id;
@HiveField(2)
String name;
@HiveField(3, defaultValue: 10737418240) // 10 Gb
int sizeByte;
@HiveField(4, defaultValue: null)
int? serverId;
@HiveField(5, defaultValue: null)
String? linuxDevice;
@HiveField(6, defaultValue: null)
String? uuid;
}
@HiveType(typeId: 101)
enum ServerProvider {
@HiveField(0)
unknown,
@HiveField(1)
hetzner,
@HiveField(2)
digitalOcean,
}