getVersion method

Future<KoolbaseObjectVersion> getVersion({
  1. required String bucket,
  2. required String path,
  3. required String versionId,
})

Fetch metadata for a single version by id. Works against both the current row and any history row — the response's isCurrent tells you which.

Implementation

Future<KoolbaseObjectVersion> getVersion({
  required String bucket,
  required String path,
  required String versionId,
}) async {
  final res = await koolbaseHttp
      .get(
        _query('/v1/sdk/storage/object-versions/${Uri.encodeComponent(versionId)}',
            {'bucket': bucket, 'path': path}),
        headers: await _headers(),
      )
      .timeout(const Duration(seconds: 10));

  if (res.statusCode != 200) {
    throw await _error(res, fallbackMessage: 'Failed to fetch version');
  }
  return KoolbaseObjectVersion.fromJson(
      jsonDecode(res.body) as Map<String, dynamic>);
}