From f5d9bebd845b54a9e3d942a691dd37f8c9c42a4a Mon Sep 17 00:00:00 2001 From: mertalev <101130780+mertalev@users.noreply.github.com> Date: Mon, 19 May 2025 15:20:18 -0400 Subject: [PATCH] openapi --- mobile/openapi/README.md | 3 + mobile/openapi/lib/api.dart | 1 + mobile/openapi/lib/api/duplicates_api.dart | 72 +++++++++++++ mobile/openapi/lib/api_client.dart | 2 + .../lib/model/deduplicate_all_dto.dart | 101 ++++++++++++++++++ open-api/immich-openapi-specs.json | 75 +++++++++++++ open-api/typescript-sdk/src/fetch-client.ts | 18 ++++ 7 files changed, 272 insertions(+) create mode 100644 mobile/openapi/lib/model/deduplicate_all_dto.dart diff --git a/mobile/openapi/README.md b/mobile/openapi/README.md index 620fc97664..270b3f1589 100644 --- a/mobile/openapi/README.md +++ b/mobile/openapi/README.md @@ -122,7 +122,9 @@ Class | Method | HTTP request | Description *DeprecatedApi* | [**getRandom**](doc//DeprecatedApi.md#getrandom) | **GET** /assets/random | *DownloadApi* | [**downloadArchive**](doc//DownloadApi.md#downloadarchive) | **POST** /download/archive | *DownloadApi* | [**getDownloadInfo**](doc//DownloadApi.md#getdownloadinfo) | **POST** /download/info | +*DuplicatesApi* | [**deduplicateAll**](doc//DuplicatesApi.md#deduplicateall) | **POST** /duplicates/bulk/deduplicate | *DuplicatesApi* | [**getAssetDuplicates**](doc//DuplicatesApi.md#getassetduplicates) | **GET** /duplicates | +*DuplicatesApi* | [**keepAll**](doc//DuplicatesApi.md#keepall) | **POST** /duplicates/bulk/keep | *FacesApi* | [**createFace**](doc//FacesApi.md#createface) | **POST** /faces | *FacesApi* | [**deleteFace**](doc//FacesApi.md#deleteface) | **DELETE** /faces/{id} | *FacesApi* | [**getFaces**](doc//FacesApi.md#getfaces) | **GET** /faces | @@ -327,6 +329,7 @@ Class | Method | HTTP request | Description - [CreateLibraryDto](doc//CreateLibraryDto.md) - [CreateProfileImageResponseDto](doc//CreateProfileImageResponseDto.md) - [DatabaseBackupConfig](doc//DatabaseBackupConfig.md) + - [DeduplicateAllDto](doc//DeduplicateAllDto.md) - [DownloadArchiveInfo](doc//DownloadArchiveInfo.md) - [DownloadInfoDto](doc//DownloadInfoDto.md) - [DownloadResponse](doc//DownloadResponse.md) diff --git a/mobile/openapi/lib/api.dart b/mobile/openapi/lib/api.dart index 8710298d7d..cac92d04b9 100644 --- a/mobile/openapi/lib/api.dart +++ b/mobile/openapi/lib/api.dart @@ -122,6 +122,7 @@ part 'model/create_album_dto.dart'; part 'model/create_library_dto.dart'; part 'model/create_profile_image_response_dto.dart'; part 'model/database_backup_config.dart'; +part 'model/deduplicate_all_dto.dart'; part 'model/download_archive_info.dart'; part 'model/download_info_dto.dart'; part 'model/download_response.dart'; diff --git a/mobile/openapi/lib/api/duplicates_api.dart b/mobile/openapi/lib/api/duplicates_api.dart index 715c6d6112..abe2369e6f 100644 --- a/mobile/openapi/lib/api/duplicates_api.dart +++ b/mobile/openapi/lib/api/duplicates_api.dart @@ -16,6 +16,45 @@ class DuplicatesApi { final ApiClient apiClient; + /// Performs an HTTP 'POST /duplicates/bulk/deduplicate' operation and returns the [Response]. + /// Parameters: + /// + /// * [DeduplicateAllDto] deduplicateAllDto (required): + Future deduplicateAllWithHttpInfo(DeduplicateAllDto deduplicateAllDto,) async { + // ignore: prefer_const_declarations + final apiPath = r'/duplicates/bulk/deduplicate'; + + // ignore: prefer_final_locals + Object? postBody = deduplicateAllDto; + + final queryParams = []; + final headerParams = {}; + final formParams = {}; + + const contentTypes = ['application/json']; + + + return apiClient.invokeAPI( + apiPath, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentTypes.isEmpty ? null : contentTypes.first, + ); + } + + /// Parameters: + /// + /// * [DeduplicateAllDto] deduplicateAllDto (required): + Future deduplicateAll(DeduplicateAllDto deduplicateAllDto,) async { + final response = await deduplicateAllWithHttpInfo(deduplicateAllDto,); + if (response.statusCode >= HttpStatus.badRequest) { + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); + } + } + /// Performs an HTTP 'GET /duplicates' operation and returns the [Response]. Future getAssetDuplicatesWithHttpInfo() async { // ignore: prefer_const_declarations @@ -59,4 +98,37 @@ class DuplicatesApi { } return null; } + + /// Performs an HTTP 'POST /duplicates/bulk/keep' operation and returns the [Response]. + Future keepAllWithHttpInfo() async { + // ignore: prefer_const_declarations + final apiPath = r'/duplicates/bulk/keep'; + + // ignore: prefer_final_locals + Object? postBody; + + final queryParams = []; + final headerParams = {}; + final formParams = {}; + + const contentTypes = []; + + + return apiClient.invokeAPI( + apiPath, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentTypes.isEmpty ? null : contentTypes.first, + ); + } + + Future keepAll() async { + final response = await keepAllWithHttpInfo(); + if (response.statusCode >= HttpStatus.badRequest) { + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); + } + } } diff --git a/mobile/openapi/lib/api_client.dart b/mobile/openapi/lib/api_client.dart index a3b1c41ca6..5de76579ff 100644 --- a/mobile/openapi/lib/api_client.dart +++ b/mobile/openapi/lib/api_client.dart @@ -300,6 +300,8 @@ class ApiClient { return CreateProfileImageResponseDto.fromJson(value); case 'DatabaseBackupConfig': return DatabaseBackupConfig.fromJson(value); + case 'DeduplicateAllDto': + return DeduplicateAllDto.fromJson(value); case 'DownloadArchiveInfo': return DownloadArchiveInfo.fromJson(value); case 'DownloadInfoDto': diff --git a/mobile/openapi/lib/model/deduplicate_all_dto.dart b/mobile/openapi/lib/model/deduplicate_all_dto.dart new file mode 100644 index 0000000000..7bc63ce227 --- /dev/null +++ b/mobile/openapi/lib/model/deduplicate_all_dto.dart @@ -0,0 +1,101 @@ +// +// 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 DeduplicateAllDto { + /// Returns a new [DeduplicateAllDto] instance. + DeduplicateAllDto({ + this.assetIdsToKeep = const [], + }); + + List assetIdsToKeep; + + @override + bool operator ==(Object other) => identical(this, other) || other is DeduplicateAllDto && + _deepEquality.equals(other.assetIdsToKeep, assetIdsToKeep); + + @override + int get hashCode => + // ignore: unnecessary_parenthesis + (assetIdsToKeep.hashCode); + + @override + String toString() => 'DeduplicateAllDto[assetIdsToKeep=$assetIdsToKeep]'; + + Map toJson() { + final json = {}; + json[r'assetIdsToKeep'] = this.assetIdsToKeep; + return json; + } + + /// Returns a new [DeduplicateAllDto] instance and imports its values from + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static DeduplicateAllDto? fromJson(dynamic value) { + upgradeDto(value, "DeduplicateAllDto"); + if (value is Map) { + final json = value.cast(); + + return DeduplicateAllDto( + assetIdsToKeep: json[r'assetIdsToKeep'] is Iterable + ? (json[r'assetIdsToKeep'] as Iterable).cast().toList(growable: false) + : const [], + ); + } + return null; + } + + static List listFromJson(dynamic json, {bool growable = false,}) { + final result = []; + if (json is List && json.isNotEmpty) { + for (final row in json) { + final value = DeduplicateAllDto.fromJson(row); + if (value != null) { + result.add(value); + } + } + } + return result.toList(growable: growable); + } + + static Map mapFromJson(dynamic json) { + final map = {}; + if (json is Map && json.isNotEmpty) { + json = json.cast(); // ignore: parameter_assignments + for (final entry in json.entries) { + final value = DeduplicateAllDto.fromJson(entry.value); + if (value != null) { + map[entry.key] = value; + } + } + } + return map; + } + + // maps a json object with a list of DeduplicateAllDto-objects as value to a dart map + static Map> mapListFromJson(dynamic json, {bool growable = false,}) { + final map = >{}; + if (json is Map && json.isNotEmpty) { + // ignore: parameter_assignments + json = json.cast(); + for (final entry in json.entries) { + map[entry.key] = DeduplicateAllDto.listFromJson(entry.value, growable: growable,); + } + } + return map; + } + + /// The list of required keys that must be present in a JSON. + static const requiredKeys = { + 'assetIdsToKeep', + }; +} + diff --git a/open-api/immich-openapi-specs.json b/open-api/immich-openapi-specs.json index 5de3987367..6437ff673f 100644 --- a/open-api/immich-openapi-specs.json +++ b/open-api/immich-openapi-specs.json @@ -2732,6 +2732,66 @@ ] } }, + "/duplicates/bulk/deduplicate": { + "post": { + "operationId": "deduplicateAll", + "parameters": [], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DeduplicateAllDto" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "" + } + }, + "security": [ + { + "bearer": [] + }, + { + "cookie": [] + }, + { + "api_key": [] + } + ], + "tags": [ + "Duplicates" + ] + } + }, + "/duplicates/bulk/keep": { + "post": { + "operationId": "keepAll", + "parameters": [], + "responses": { + "201": { + "description": "" + } + }, + "security": [ + { + "bearer": [] + }, + { + "cookie": [] + }, + { + "api_key": [] + } + ], + "tags": [ + "Duplicates" + ] + } + }, "/faces": { "get": { "operationId": "getFaces", @@ -9655,6 +9715,21 @@ ], "type": "object" }, + "DeduplicateAllDto": { + "properties": { + "assetIdsToKeep": { + "items": { + "format": "uuid", + "type": "string" + }, + "type": "array" + } + }, + "required": [ + "assetIdsToKeep" + ], + "type": "object" + }, "DownloadArchiveInfo": { "properties": { "assetIds": { diff --git a/open-api/typescript-sdk/src/fetch-client.ts b/open-api/typescript-sdk/src/fetch-client.ts index c293b2aa6c..48c4e209d3 100644 --- a/open-api/typescript-sdk/src/fetch-client.ts +++ b/open-api/typescript-sdk/src/fetch-client.ts @@ -560,6 +560,9 @@ export type DuplicateResponseDto = { assets: AssetResponseDto[]; duplicateId: string; }; +export type DeduplicateAllDto = { + assetIdsToKeep: string[]; +}; export type PersonResponseDto = { birthDate: string | null; /** This property was added in v1.126.0 */ @@ -2176,6 +2179,21 @@ export function getAssetDuplicates(opts?: Oazapfts.RequestOpts) { ...opts })); } +export function deduplicateAll({ deduplicateAllDto }: { + deduplicateAllDto: DeduplicateAllDto; +}, opts?: Oazapfts.RequestOpts) { + return oazapfts.ok(oazapfts.fetchText("/duplicates/bulk/deduplicate", oazapfts.json({ + ...opts, + method: "POST", + body: deduplicateAllDto + }))); +} +export function keepAll(opts?: Oazapfts.RequestOpts) { + return oazapfts.ok(oazapfts.fetchText("/duplicates/bulk/keep", { + ...opts, + method: "POST" + })); +} export function getFaces({ id }: { id: string; }, opts?: Oazapfts.RequestOpts) {