2021-03-26 13:38:39 +00:00
|
|
|
import 'package:json_annotation/json_annotation.dart';
|
|
|
|
|
|
|
|
part 'hetzner_server_info.g.dart';
|
|
|
|
|
|
|
|
@JsonSerializable()
|
|
|
|
class HetznerServerInfo {
|
2022-06-05 19:36:32 +00:00
|
|
|
HetznerServerInfo(
|
|
|
|
this.id,
|
|
|
|
this.name,
|
|
|
|
this.status,
|
|
|
|
this.created,
|
|
|
|
this.serverType,
|
|
|
|
this.location,
|
|
|
|
this.publicNet,
|
|
|
|
this.volumes,
|
|
|
|
);
|
2021-03-26 13:38:39 +00:00
|
|
|
final int id;
|
|
|
|
final String name;
|
|
|
|
final ServerStatus status;
|
|
|
|
final DateTime created;
|
2022-05-20 22:56:50 +00:00
|
|
|
final List<int> volumes;
|
2021-03-26 13:38:39 +00:00
|
|
|
|
|
|
|
@JsonKey(name: 'server_type')
|
|
|
|
final HetznerServerTypeInfo serverType;
|
|
|
|
|
|
|
|
@JsonKey(name: 'datacenter', fromJson: HetznerServerInfo.locationFromJson)
|
|
|
|
final HetznerLocation location;
|
|
|
|
|
2022-05-19 17:43:25 +00:00
|
|
|
@JsonKey(name: 'public_net')
|
|
|
|
final HetznerPublicNetInfo publicNet;
|
|
|
|
|
2022-06-05 19:36:32 +00:00
|
|
|
static HetznerLocation locationFromJson(final Map json) =>
|
2021-03-26 13:38:39 +00:00
|
|
|
HetznerLocation.fromJson(json['location']);
|
|
|
|
|
2022-06-05 19:36:32 +00:00
|
|
|
static HetznerServerInfo fromJson(final Map<String, dynamic> json) =>
|
2021-03-26 13:38:39 +00:00
|
|
|
_$HetznerServerInfoFromJson(json);
|
|
|
|
}
|
|
|
|
|
2022-05-19 17:43:25 +00:00
|
|
|
@JsonSerializable()
|
|
|
|
class HetznerPublicNetInfo {
|
2022-06-05 19:36:32 +00:00
|
|
|
HetznerPublicNetInfo(this.ipv4);
|
2022-08-29 18:18:07 +00:00
|
|
|
final HetznerIp4? ipv4;
|
2022-05-19 17:43:25 +00:00
|
|
|
|
2022-06-05 19:36:32 +00:00
|
|
|
static HetznerPublicNetInfo fromJson(final Map<String, dynamic> json) =>
|
2022-05-19 17:43:25 +00:00
|
|
|
_$HetznerPublicNetInfoFromJson(json);
|
|
|
|
}
|
|
|
|
|
|
|
|
@JsonSerializable()
|
|
|
|
class HetznerIp4 {
|
2022-06-05 19:36:32 +00:00
|
|
|
HetznerIp4(this.id, this.ip, this.blocked, this.reverseDns);
|
2022-05-19 17:43:25 +00:00
|
|
|
final bool blocked;
|
|
|
|
@JsonKey(name: 'dns_ptr')
|
|
|
|
final String reverseDns;
|
|
|
|
final int id;
|
|
|
|
final String ip;
|
|
|
|
|
2022-06-05 19:36:32 +00:00
|
|
|
static HetznerIp4 fromJson(final Map<String, dynamic> json) =>
|
2022-05-19 17:43:25 +00:00
|
|
|
_$HetznerIp4FromJson(json);
|
|
|
|
}
|
|
|
|
|
2021-03-26 13:38:39 +00:00
|
|
|
enum ServerStatus {
|
|
|
|
running,
|
|
|
|
initializing,
|
|
|
|
starting,
|
|
|
|
stopping,
|
|
|
|
off,
|
|
|
|
deleting,
|
|
|
|
migrating,
|
|
|
|
rebuilding,
|
|
|
|
unknown,
|
|
|
|
}
|
|
|
|
|
|
|
|
@JsonSerializable()
|
|
|
|
class HetznerServerTypeInfo {
|
2023-06-07 03:03:34 +00:00
|
|
|
HetznerServerTypeInfo(
|
|
|
|
this.cores,
|
|
|
|
this.memory,
|
|
|
|
this.disk,
|
|
|
|
this.prices,
|
|
|
|
this.name,
|
|
|
|
this.description,
|
|
|
|
);
|
2021-03-26 13:38:39 +00:00
|
|
|
final int cores;
|
|
|
|
final num memory;
|
|
|
|
final int disk;
|
|
|
|
|
2023-06-07 03:03:34 +00:00
|
|
|
final String name;
|
|
|
|
final String description;
|
|
|
|
|
2021-03-26 13:38:39 +00:00
|
|
|
final List<HetznerPriceInfo> prices;
|
|
|
|
|
2022-06-05 19:36:32 +00:00
|
|
|
static HetznerServerTypeInfo fromJson(final Map<String, dynamic> json) =>
|
2021-03-26 13:38:39 +00:00
|
|
|
_$HetznerServerTypeInfoFromJson(json);
|
|
|
|
}
|
|
|
|
|
|
|
|
@JsonSerializable()
|
|
|
|
class HetznerPriceInfo {
|
2023-06-07 03:03:34 +00:00
|
|
|
HetznerPriceInfo(
|
|
|
|
this.hourly,
|
|
|
|
this.monthly,
|
|
|
|
this.location,
|
|
|
|
);
|
2021-03-26 13:38:39 +00:00
|
|
|
|
|
|
|
@JsonKey(name: 'price_hourly', fromJson: HetznerPriceInfo.getPrice)
|
|
|
|
final double hourly;
|
|
|
|
|
|
|
|
@JsonKey(name: 'price_monthly', fromJson: HetznerPriceInfo.getPrice)
|
|
|
|
final double monthly;
|
|
|
|
|
2023-06-07 03:03:34 +00:00
|
|
|
final String location;
|
|
|
|
|
2022-06-05 19:36:32 +00:00
|
|
|
static HetznerPriceInfo fromJson(final Map<String, dynamic> json) =>
|
2021-03-26 13:38:39 +00:00
|
|
|
_$HetznerPriceInfoFromJson(json);
|
|
|
|
|
2022-06-05 22:40:34 +00:00
|
|
|
static double getPrice(final Map json) =>
|
|
|
|
double.parse(json['gross'] as String);
|
2021-03-26 13:38:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@JsonSerializable()
|
|
|
|
class HetznerLocation {
|
2023-06-07 03:25:34 +00:00
|
|
|
HetznerLocation(
|
|
|
|
this.country,
|
|
|
|
this.city,
|
|
|
|
this.description,
|
|
|
|
this.zone,
|
|
|
|
this.name,
|
|
|
|
);
|
|
|
|
final String name;
|
2021-03-26 13:38:39 +00:00
|
|
|
final String country;
|
|
|
|
final String city;
|
|
|
|
final String description;
|
|
|
|
|
|
|
|
@JsonKey(name: 'network_zone')
|
|
|
|
final String zone;
|
|
|
|
|
2022-06-05 19:36:32 +00:00
|
|
|
static HetznerLocation fromJson(final Map<String, dynamic> json) =>
|
2021-03-26 13:38:39 +00:00
|
|
|
_$HetznerLocationFromJson(json);
|
|
|
|
}
|
2023-06-07 02:35:57 +00:00
|
|
|
|
2023-07-10 09:00:46 +00:00
|
|
|
/// A Volume is a highly-available, scalable, and SSD-based block storage for Servers.
|
|
|
|
///
|
|
|
|
/// Pricing for Volumes depends on the Volume size and Location, not the actual used storage.
|
|
|
|
///
|
|
|
|
/// Please see Hetzner Docs for more details about Volumes.
|
|
|
|
/// https://docs.hetzner.cloud/#volumes
|
2023-06-07 02:35:57 +00:00
|
|
|
@JsonSerializable()
|
|
|
|
class HetznerVolume {
|
|
|
|
HetznerVolume(
|
|
|
|
this.id,
|
2023-06-09 08:11:42 +00:00
|
|
|
this.size,
|
2023-06-07 02:35:57 +00:00
|
|
|
this.serverId,
|
|
|
|
this.name,
|
|
|
|
this.linuxDevice,
|
|
|
|
);
|
2023-07-10 09:00:46 +00:00
|
|
|
|
|
|
|
/// ID of the Resource
|
2023-06-07 02:35:57 +00:00
|
|
|
final int id;
|
2023-07-10 09:00:46 +00:00
|
|
|
|
|
|
|
/// Size in GB of the Volume
|
2023-06-09 08:11:42 +00:00
|
|
|
final int size;
|
2023-07-10 09:00:46 +00:00
|
|
|
|
|
|
|
/// ID of the Server the Volume is attached to, null if it is not attached at all
|
2023-06-07 02:35:57 +00:00
|
|
|
final int? serverId;
|
2023-07-10 09:00:46 +00:00
|
|
|
|
|
|
|
/// Name of the Resource. Is unique per Project.
|
2023-06-07 02:35:57 +00:00
|
|
|
final String name;
|
|
|
|
|
2023-07-10 09:00:46 +00:00
|
|
|
/// Device path on the file system for the Volume
|
2023-06-07 02:35:57 +00:00
|
|
|
@JsonKey(name: 'linux_device')
|
|
|
|
final String? linuxDevice;
|
|
|
|
|
|
|
|
static HetznerVolume fromJson(final Map<String, dynamic> json) =>
|
|
|
|
_$HetznerVolumeFromJson(json);
|
|
|
|
}
|