attachDisk method
Attaches an existing Disk resource to an instance. You must first create the disk before you can attach it. It is not possible to create and attach a disk at the same time. For more information, readAdding a persistent disk to your instance.
Throws a http.ClientException if there were problems communicating with
the API service. Throws a ServiceException if the API method failed for
any reason.
Implementation
Future<Operation> attachDisk(AttachDiskInstanceRequest request) async {
final url = _endPoint.replace(
path:
'/compute/v1/projects/${request.project}/zones/${request.zone}/instances/${request.instance}/attachDisk',
queryParameters: {
if (request.forceAttach case final $1?) 'forceAttach': '${$1}',
'requestId': ?request.requestId,
},
);
final response = await _client.post(
url,
body: request.attachedDiskResource,
);
return Operation.fromJson(response);
}