mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-08 00:51:20 +00:00
chore: Replace dynamic blobs with HetznerServerInfo
This commit is contained in:
parent
fa4939d7c6
commit
875a9e2e86
|
@ -343,7 +343,7 @@ class HetznerApi extends ServerProviderApi with VolumeProviderApi {
|
|||
);
|
||||
}
|
||||
|
||||
Future<GenericResult> createServer({
|
||||
Future<GenericResult<HetznerServerInfo?>> createServer({
|
||||
required final String dnsApiToken,
|
||||
required final String dnsProviderType,
|
||||
required final String serverApiToken,
|
||||
|
@ -357,6 +357,7 @@ class HetznerApi extends ServerProviderApi with VolumeProviderApi {
|
|||
}) async {
|
||||
final String stagingAcme = StagingOptions.stagingAcme ? 'true' : 'false';
|
||||
Response? serverCreateResponse;
|
||||
HetznerServerInfo? serverInfo;
|
||||
DioError? hetznerError;
|
||||
bool success = false;
|
||||
|
||||
|
@ -383,6 +384,9 @@ class HetznerApi extends ServerProviderApi with VolumeProviderApi {
|
|||
print('Decoded data: $data');
|
||||
|
||||
serverCreateResponse = await client.post('/servers', data: data);
|
||||
serverInfo = HetznerServerInfo.fromJson(
|
||||
serverCreateResponse.data['server'],
|
||||
);
|
||||
success = true;
|
||||
} on DioError catch (e) {
|
||||
print(e);
|
||||
|
@ -400,7 +404,7 @@ class HetznerApi extends ServerProviderApi with VolumeProviderApi {
|
|||
}
|
||||
|
||||
return GenericResult(
|
||||
data: serverCreateResponse?.data,
|
||||
data: serverInfo,
|
||||
success: success && hetznerError == null,
|
||||
code: serverCreateResponse?.statusCode ??
|
||||
hetznerError?.response?.statusCode,
|
||||
|
|
|
@ -526,8 +526,8 @@ class HetznerServerProvider extends ServerProvider {
|
|||
}
|
||||
|
||||
final serverDetails = ServerHostingDetails(
|
||||
id: serverResult.data['server']['id'],
|
||||
ip4: serverResult.data['server']['public_net']['ipv4']['ip'],
|
||||
id: serverResult.data!.id,
|
||||
ip4: serverResult.data!.publicNet.ipv4!.ip,
|
||||
createTime: DateTime.now(),
|
||||
volume: ServerVolume(
|
||||
id: volume.id,
|
||||
|
|
Loading…
Reference in a new issue