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