detachDisk method

Future<DetachDiskResult> detachDisk({
  1. required String diskName,
})

Detaches a stopped block storage disk from a Lightsail instance. Make sure to unmount any file systems on the device within your operating system before stopping the instance and detaching the disk.

The detach disk operation supports tag-based access control via resource tags applied to the resource identified by disk name. For more information, see the Lightsail Dev Guide.

May throw ServiceException. May throw InvalidInputException. May throw NotFoundException. May throw OperationFailureException. May throw AccessDeniedException. May throw AccountSetupInProgressException. May throw UnauthenticatedException.

Parameter diskName : The unique name of the disk you want to detach from your instance (e.g., my-disk).

Implementation

Future<DetachDiskResult> detachDisk({
  required String diskName,
}) async {
  ArgumentError.checkNotNull(diskName, 'diskName');
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'Lightsail_20161128.DetachDisk'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'diskName': diskName,
    },
  );

  return DetachDiskResult.fromJson(jsonResponse.body);
}