mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-03-17 12:04:49 +00:00
feat(digital-ocean): Implement system endpoints for digital ocean
This commit is contained in:
parent
e4ed69d151
commit
bb846b08c1
1 changed files with 14 additions and 28 deletions
|
@ -197,11 +197,6 @@ class DigitalOceanApi extends ServerProviderApi with VolumeProviderApi {
|
||||||
Future<bool> attachVolume(final ServerVolume volume, final int serverId) async {
|
Future<bool> attachVolume(final ServerVolume volume, final int serverId) async {
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
||||||
final ServerVolume? volumeToAttach = await getVolume(volume.uuid!);
|
|
||||||
if (volumeToAttach == null) {
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Response dbPostResponse;
|
final Response dbPostResponse;
|
||||||
final Dio client = await getClient();
|
final Dio client = await getClient();
|
||||||
try {
|
try {
|
||||||
|
@ -209,7 +204,7 @@ class DigitalOceanApi extends ServerProviderApi with VolumeProviderApi {
|
||||||
'/volumes/actions',
|
'/volumes/actions',
|
||||||
data: {
|
data: {
|
||||||
'type': 'attach',
|
'type': 'attach',
|
||||||
'volume_name': volumeToAttach.name,
|
'volume_name': volume.name,
|
||||||
'region': region,
|
'region': region,
|
||||||
'droplet_id': serverId,
|
'droplet_id': serverId,
|
||||||
},
|
},
|
||||||
|
@ -229,11 +224,6 @@ class DigitalOceanApi extends ServerProviderApi with VolumeProviderApi {
|
||||||
Future<bool> detachVolume(final ServerVolume volume) async {
|
Future<bool> detachVolume(final ServerVolume volume) async {
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
||||||
final ServerVolume? volumeToAttach = await getVolume(volume.uuid!);
|
|
||||||
if (volumeToAttach == null) {
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Response dbPostResponse;
|
final Response dbPostResponse;
|
||||||
final Dio client = await getClient();
|
final Dio client = await getClient();
|
||||||
try {
|
try {
|
||||||
|
@ -241,7 +231,8 @@ class DigitalOceanApi extends ServerProviderApi with VolumeProviderApi {
|
||||||
'/volumes/actions',
|
'/volumes/actions',
|
||||||
data: {
|
data: {
|
||||||
'type': 'detach',
|
'type': 'detach',
|
||||||
'droplet_id': volumeToAttach.serverId,
|
'volume_name': volume.name,
|
||||||
|
'droplet_id': volume.serverId,
|
||||||
'region': region,
|
'region': region,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -267,6 +258,7 @@ class DigitalOceanApi extends ServerProviderApi with VolumeProviderApi {
|
||||||
'/volumes/actions',
|
'/volumes/actions',
|
||||||
data: {
|
data: {
|
||||||
'type': 'resize',
|
'type': 'resize',
|
||||||
|
'volume_name': volume.name,
|
||||||
'size_gigabytes': sizeGb,
|
'size_gigabytes': sizeGb,
|
||||||
'region': region,
|
'region': region,
|
||||||
},
|
},
|
||||||
|
@ -375,7 +367,10 @@ class DigitalOceanApi extends ServerProviderApi with VolumeProviderApi {
|
||||||
|
|
||||||
final Dio client = await getClient();
|
final Dio client = await getClient();
|
||||||
try {
|
try {
|
||||||
await client.post('/servers/${server.id}/actions/reset');
|
await client.post('/droplets/${server.id}/actions',
|
||||||
|
data: {
|
||||||
|
'type': 'reboot',
|
||||||
|
},);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(e);
|
print(e);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -391,7 +386,11 @@ class DigitalOceanApi extends ServerProviderApi with VolumeProviderApi {
|
||||||
|
|
||||||
final Dio client = await getClient();
|
final Dio client = await getClient();
|
||||||
try {
|
try {
|
||||||
await client.post('/servers/${server.id}/actions/poweron');
|
await client.post('/droplets/${server.id}/actions',
|
||||||
|
data: {
|
||||||
|
'type': 'power_on',
|
||||||
|
},
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(e);
|
print(e);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -582,19 +581,6 @@ class DigitalOceanApi extends ServerProviderApi with VolumeProviderApi {
|
||||||
required final ServerHostingDetails serverDetails,
|
required final ServerHostingDetails serverDetails,
|
||||||
required final ServerDomain domain,
|
required final ServerDomain domain,
|
||||||
}) async {
|
}) async {
|
||||||
final Dio client = await getClient();
|
/// TODO remove from provider interface
|
||||||
try {
|
|
||||||
await client.post(
|
|
||||||
'/servers/${serverDetails.id}/actions/change_dns_ptr',
|
|
||||||
data: {
|
|
||||||
'ip': serverDetails.ip4,
|
|
||||||
'dns_ptr': domain.domainName,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
} catch (e) {
|
|
||||||
print(e);
|
|
||||||
} finally {
|
|
||||||
close(client);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue