getDatabase method
Returns the database name of organization, or null if it does not exist (HTTP 404).
GET /v1/organizations/{organization}/databases/{name}
organizationのデータベースnameを取得します。存在しない場合(HTTP 404)はnullを返します。
Implementation
Future<TursoDatabaseInfo?> getDatabase(
String organization, {
required String name,
}) async {
final response = await _request(
"GET",
"${_databasesPath(organization)}/${Uri.encodeComponent(name)}",
);
if (response.statusCode == HttpStatus.notFound) {
return null;
}
if (response.statusCode < 200 || response.statusCode >= 300) {
throw TursoPlatformApiException(
statusCode: response.statusCode,
body: response.body,
operation: "get database `$name`",
);
}
final decoded = jsonDecode(response.body);
final database = decoded is Map ? decoded["database"] : null;
if (database is! Map) {
throw const FormatException(
"Unexpected response format of the Turso databases API.");
}
return TursoDatabaseInfo.fromJson(database);
}