1
0
mirror of https://github.com/immich-app/immich.git synced 2025-08-09 23:17:29 +02:00

refactor: deprecate /server-info and replace with /server-info/storage (#9645)

This commit is contained in:
Zack Pollard
2024-05-22 10:25:55 +01:00
committed by GitHub
parent a341ab0050
commit a3e7e8cc31
19 changed files with 265 additions and 99 deletions

View File

@@ -35,6 +35,7 @@ part 'api/album_api.dart';
part 'api/asset_api.dart';
part 'api/audit_api.dart';
part 'api/authentication_api.dart';
part 'api/deprecated_api.dart';
part 'api/download_api.dart';
part 'api/duplicate_api.dart';
part 'api/face_api.dart';
@@ -180,10 +181,10 @@ part 'model/search_response_dto.dart';
part 'model/search_suggestion_type.dart';
part 'model/server_config_dto.dart';
part 'model/server_features_dto.dart';
part 'model/server_info_response_dto.dart';
part 'model/server_media_types_response_dto.dart';
part 'model/server_ping_response.dart';
part 'model/server_stats_response_dto.dart';
part 'model/server_storage_response_dto.dart';
part 'model/server_theme_dto.dart';
part 'model/server_version_response_dto.dart';
part 'model/session_response_dto.dart';

View File

@@ -0,0 +1,62 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.18
// ignore_for_file: unused_element, unused_import
// ignore_for_file: always_put_required_named_parameters_first
// ignore_for_file: constant_identifier_names
// ignore_for_file: lines_longer_than_80_chars
part of openapi.api;
class DeprecatedApi {
DeprecatedApi([ApiClient? apiClient]) : apiClient = apiClient ?? defaultApiClient;
final ApiClient apiClient;
/// This property was deprecated in v1.106.0
///
/// Note: This method returns the HTTP [Response].
Future<Response> getServerInfoWithHttpInfo() async {
// ignore: prefer_const_declarations
final path = r'/server-info';
// ignore: prefer_final_locals
Object? postBody;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
const contentTypes = <String>[];
return apiClient.invokeAPI(
path,
'GET',
queryParams,
postBody,
headerParams,
formParams,
contentTypes.isEmpty ? null : contentTypes.first,
);
}
/// This property was deprecated in v1.106.0
Future<ServerStorageResponseDto?> getServerInfo() async {
final response = await getServerInfoWithHttpInfo();
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ServerStorageResponseDto',) as ServerStorageResponseDto;
}
return null;
}
}

View File

@@ -98,7 +98,9 @@ class ServerInfoApi {
return null;
}
/// Performs an HTTP 'GET /server-info' operation and returns the [Response].
/// This property was deprecated in v1.106.0
///
/// Note: This method returns the HTTP [Response].
Future<Response> getServerInfoWithHttpInfo() async {
// ignore: prefer_const_declarations
final path = r'/server-info';
@@ -124,7 +126,8 @@ class ServerInfoApi {
);
}
Future<ServerInfoResponseDto?> getServerInfo() async {
/// This property was deprecated in v1.106.0
Future<ServerStorageResponseDto?> getServerInfo() async {
final response = await getServerInfoWithHttpInfo();
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
@@ -133,7 +136,7 @@ class ServerInfoApi {
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ServerInfoResponseDto',) as ServerInfoResponseDto;
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ServerStorageResponseDto',) as ServerStorageResponseDto;
}
return null;
@@ -221,6 +224,47 @@ class ServerInfoApi {
return null;
}
/// Performs an HTTP 'GET /server-info/storage' operation and returns the [Response].
Future<Response> getStorageWithHttpInfo() async {
// ignore: prefer_const_declarations
final path = r'/server-info/storage';
// ignore: prefer_final_locals
Object? postBody;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
const contentTypes = <String>[];
return apiClient.invokeAPI(
path,
'GET',
queryParams,
postBody,
headerParams,
formParams,
contentTypes.isEmpty ? null : contentTypes.first,
);
}
Future<ServerStorageResponseDto?> getStorage() async {
final response = await getStorageWithHttpInfo();
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ServerStorageResponseDto',) as ServerStorageResponseDto;
}
return null;
}
/// Performs an HTTP 'GET /server-info/media-types' operation and returns the [Response].
Future<Response> getSupportedMediaTypesWithHttpInfo() async {
// ignore: prefer_const_declarations

View File

@@ -428,14 +428,14 @@ class ApiClient {
return ServerConfigDto.fromJson(value);
case 'ServerFeaturesDto':
return ServerFeaturesDto.fromJson(value);
case 'ServerInfoResponseDto':
return ServerInfoResponseDto.fromJson(value);
case 'ServerMediaTypesResponseDto':
return ServerMediaTypesResponseDto.fromJson(value);
case 'ServerPingResponse':
return ServerPingResponse.fromJson(value);
case 'ServerStatsResponseDto':
return ServerStatsResponseDto.fromJson(value);
case 'ServerStorageResponseDto':
return ServerStorageResponseDto.fromJson(value);
case 'ServerThemeDto':
return ServerThemeDto.fromJson(value);
case 'ServerVersionResponseDto':

View File

@@ -10,9 +10,9 @@
part of openapi.api;
class ServerInfoResponseDto {
/// Returns a new [ServerInfoResponseDto] instance.
ServerInfoResponseDto({
class ServerStorageResponseDto {
/// Returns a new [ServerStorageResponseDto] instance.
ServerStorageResponseDto({
required this.diskAvailable,
required this.diskAvailableRaw,
required this.diskSize,
@@ -37,7 +37,7 @@ class ServerInfoResponseDto {
int diskUseRaw;
@override
bool operator ==(Object other) => identical(this, other) || other is ServerInfoResponseDto &&
bool operator ==(Object other) => identical(this, other) || other is ServerStorageResponseDto &&
other.diskAvailable == diskAvailable &&
other.diskAvailableRaw == diskAvailableRaw &&
other.diskSize == diskSize &&
@@ -58,7 +58,7 @@ class ServerInfoResponseDto {
(diskUseRaw.hashCode);
@override
String toString() => 'ServerInfoResponseDto[diskAvailable=$diskAvailable, diskAvailableRaw=$diskAvailableRaw, diskSize=$diskSize, diskSizeRaw=$diskSizeRaw, diskUsagePercentage=$diskUsagePercentage, diskUse=$diskUse, diskUseRaw=$diskUseRaw]';
String toString() => 'ServerStorageResponseDto[diskAvailable=$diskAvailable, diskAvailableRaw=$diskAvailableRaw, diskSize=$diskSize, diskSizeRaw=$diskSizeRaw, diskUsagePercentage=$diskUsagePercentage, diskUse=$diskUse, diskUseRaw=$diskUseRaw]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@@ -72,14 +72,14 @@ class ServerInfoResponseDto {
return json;
}
/// Returns a new [ServerInfoResponseDto] instance and imports its values from
/// Returns a new [ServerStorageResponseDto] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static ServerInfoResponseDto? fromJson(dynamic value) {
static ServerStorageResponseDto? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
return ServerInfoResponseDto(
return ServerStorageResponseDto(
diskAvailable: mapValueOfType<String>(json, r'diskAvailable')!,
diskAvailableRaw: mapValueOfType<int>(json, r'diskAvailableRaw')!,
diskSize: mapValueOfType<String>(json, r'diskSize')!,
@@ -92,11 +92,11 @@ class ServerInfoResponseDto {
return null;
}
static List<ServerInfoResponseDto> listFromJson(dynamic json, {bool growable = false,}) {
final result = <ServerInfoResponseDto>[];
static List<ServerStorageResponseDto> listFromJson(dynamic json, {bool growable = false,}) {
final result = <ServerStorageResponseDto>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = ServerInfoResponseDto.fromJson(row);
final value = ServerStorageResponseDto.fromJson(row);
if (value != null) {
result.add(value);
}
@@ -105,12 +105,12 @@ class ServerInfoResponseDto {
return result.toList(growable: growable);
}
static Map<String, ServerInfoResponseDto> mapFromJson(dynamic json) {
final map = <String, ServerInfoResponseDto>{};
static Map<String, ServerStorageResponseDto> mapFromJson(dynamic json) {
final map = <String, ServerStorageResponseDto>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = ServerInfoResponseDto.fromJson(entry.value);
final value = ServerStorageResponseDto.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
@@ -119,14 +119,14 @@ class ServerInfoResponseDto {
return map;
}
// maps a json object with a list of ServerInfoResponseDto-objects as value to a dart map
static Map<String, List<ServerInfoResponseDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<ServerInfoResponseDto>>{};
// maps a json object with a list of ServerStorageResponseDto-objects as value to a dart map
static Map<String, List<ServerStorageResponseDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<ServerStorageResponseDto>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = ServerInfoResponseDto.listFromJson(entry.value, growable: growable,);
map[entry.key] = ServerStorageResponseDto.listFromJson(entry.value, growable: growable,);
}
}
return map;