mirror of
https://github.com/immich-app/immich.git
synced 2026-02-11 11:27:56 +03:00
feat: asset file apis
This commit is contained in:
6
mobile/openapi/README.md
generated
6
mobile/openapi/README.md
generated
@@ -95,6 +95,10 @@ Class | Method | HTTP request | Description
|
||||
*AlbumsApi* | [**removeUserFromAlbum**](doc//AlbumsApi.md#removeuserfromalbum) | **DELETE** /albums/{id}/user/{userId} | Remove user from album
|
||||
*AlbumsApi* | [**updateAlbumInfo**](doc//AlbumsApi.md#updatealbuminfo) | **PATCH** /albums/{id} | Update an album
|
||||
*AlbumsApi* | [**updateAlbumUser**](doc//AlbumsApi.md#updatealbumuser) | **PUT** /albums/{id}/user/{userId} | Update user role
|
||||
*AssetFilesApi* | [**deleteAssetFile**](doc//AssetFilesApi.md#deleteassetfile) | **DELETE** /asset-files/{id} | Delete an asset file
|
||||
*AssetFilesApi* | [**downloadAssetFile**](doc//AssetFilesApi.md#downloadassetfile) | **GET** /asset-files/{id}/download | Download an asset file
|
||||
*AssetFilesApi* | [**getAssetFile**](doc//AssetFilesApi.md#getassetfile) | **GET** /asset-files/{id} | Retrieve an asset file
|
||||
*AssetFilesApi* | [**searchAssetFiles**](doc//AssetFilesApi.md#searchassetfiles) | **GET** /asset-files | Retrieve an asset file
|
||||
*AssetsApi* | [**checkBulkUpload**](doc//AssetsApi.md#checkbulkupload) | **POST** /assets/bulk-upload-check | Check bulk upload
|
||||
*AssetsApi* | [**checkExistingAssets**](doc//AssetsApi.md#checkexistingassets) | **POST** /assets/exist | Check existing assets
|
||||
*AssetsApi* | [**copyAsset**](doc//AssetsApi.md#copyasset) | **PUT** /assets/copy | Copy asset
|
||||
@@ -369,6 +373,8 @@ Class | Method | HTTP request | Description
|
||||
- [AssetFaceUpdateDto](doc//AssetFaceUpdateDto.md)
|
||||
- [AssetFaceUpdateItem](doc//AssetFaceUpdateItem.md)
|
||||
- [AssetFaceWithoutPersonResponseDto](doc//AssetFaceWithoutPersonResponseDto.md)
|
||||
- [AssetFileResponseDto](doc//AssetFileResponseDto.md)
|
||||
- [AssetFileType](doc//AssetFileType.md)
|
||||
- [AssetFullSyncDto](doc//AssetFullSyncDto.md)
|
||||
- [AssetIdsDto](doc//AssetIdsDto.md)
|
||||
- [AssetIdsResponseDto](doc//AssetIdsResponseDto.md)
|
||||
|
||||
3
mobile/openapi/lib/api.dart
generated
3
mobile/openapi/lib/api.dart
generated
@@ -33,6 +33,7 @@ part 'auth/http_bearer_auth.dart';
|
||||
part 'api/api_keys_api.dart';
|
||||
part 'api/activities_api.dart';
|
||||
part 'api/albums_api.dart';
|
||||
part 'api/asset_files_api.dart';
|
||||
part 'api/assets_api.dart';
|
||||
part 'api/authentication_api.dart';
|
||||
part 'api/authentication_admin_api.dart';
|
||||
@@ -109,6 +110,8 @@ part 'model/asset_face_response_dto.dart';
|
||||
part 'model/asset_face_update_dto.dart';
|
||||
part 'model/asset_face_update_item.dart';
|
||||
part 'model/asset_face_without_person_response_dto.dart';
|
||||
part 'model/asset_file_response_dto.dart';
|
||||
part 'model/asset_file_type.dart';
|
||||
part 'model/asset_full_sync_dto.dart';
|
||||
part 'model/asset_ids_dto.dart';
|
||||
part 'model/asset_ids_response_dto.dart';
|
||||
|
||||
271
mobile/openapi/lib/api/asset_files_api.dart
generated
Normal file
271
mobile/openapi/lib/api/asset_files_api.dart
generated
Normal file
@@ -0,0 +1,271 @@
|
||||
//
|
||||
// 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 AssetFilesApi {
|
||||
AssetFilesApi([ApiClient? apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
|
||||
final ApiClient apiClient;
|
||||
|
||||
/// Delete an asset file
|
||||
///
|
||||
/// Delete a file and remove it from the database.
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [String] id (required):
|
||||
Future<Response> deleteAssetFileWithHttpInfo(String id,) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final apiPath = r'/asset-files/{id}'
|
||||
.replaceAll('{id}', id);
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
const contentTypes = <String>[];
|
||||
|
||||
|
||||
return apiClient.invokeAPI(
|
||||
apiPath,
|
||||
'DELETE',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
);
|
||||
}
|
||||
|
||||
/// Delete an asset file
|
||||
///
|
||||
/// Delete a file and remove it from the database.
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [String] id (required):
|
||||
Future<void> deleteAssetFile(String id,) async {
|
||||
final response = await deleteAssetFileWithHttpInfo(id,);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
}
|
||||
}
|
||||
|
||||
/// Download an asset file
|
||||
///
|
||||
/// Serve the contents of a specific asset file.
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [String] id (required):
|
||||
Future<Response> downloadAssetFileWithHttpInfo(String id,) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final apiPath = r'/asset-files/{id}/download'
|
||||
.replaceAll('{id}', id);
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
const contentTypes = <String>[];
|
||||
|
||||
|
||||
return apiClient.invokeAPI(
|
||||
apiPath,
|
||||
'GET',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
);
|
||||
}
|
||||
|
||||
/// Download an asset file
|
||||
///
|
||||
/// Serve the contents of a specific asset file.
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [String] id (required):
|
||||
Future<MultipartFile?> downloadAssetFile(String id,) async {
|
||||
final response = await downloadAssetFileWithHttpInfo(id,);
|
||||
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), 'MultipartFile',) as MultipartFile;
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Retrieve an asset file
|
||||
///
|
||||
/// Returns a metadata about a specific asset file.
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [String] id (required):
|
||||
Future<Response> getAssetFileWithHttpInfo(String id,) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final apiPath = r'/asset-files/{id}'
|
||||
.replaceAll('{id}', id);
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
const contentTypes = <String>[];
|
||||
|
||||
|
||||
return apiClient.invokeAPI(
|
||||
apiPath,
|
||||
'GET',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
);
|
||||
}
|
||||
|
||||
/// Retrieve an asset file
|
||||
///
|
||||
/// Returns a metadata about a specific asset file.
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [String] id (required):
|
||||
Future<AssetFileResponseDto?> getAssetFile(String id,) async {
|
||||
final response = await getAssetFileWithHttpInfo(id,);
|
||||
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), 'AssetFileResponseDto',) as AssetFileResponseDto;
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Retrieve an asset file
|
||||
///
|
||||
/// Returns a metadata about a specific asset file.
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [String] assetId (required):
|
||||
/// Asset ID to filter files by
|
||||
///
|
||||
/// * [bool] isEdited:
|
||||
/// The file was generated from an edit
|
||||
///
|
||||
/// * [bool] isProgressive:
|
||||
/// The file is a progressively encoded JPEG
|
||||
///
|
||||
/// * [AssetFileType] type:
|
||||
/// Filter by type of file
|
||||
Future<Response> searchAssetFilesWithHttpInfo(String assetId, { bool? isEdited, bool? isProgressive, AssetFileType? type, }) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final apiPath = r'/asset-files';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
queryParams.addAll(_queryParams('', 'assetId', assetId));
|
||||
if (isEdited != null) {
|
||||
queryParams.addAll(_queryParams('', 'isEdited', isEdited));
|
||||
}
|
||||
if (isProgressive != null) {
|
||||
queryParams.addAll(_queryParams('', 'isProgressive', isProgressive));
|
||||
}
|
||||
if (type != null) {
|
||||
queryParams.addAll(_queryParams('', 'type', type));
|
||||
}
|
||||
|
||||
const contentTypes = <String>[];
|
||||
|
||||
|
||||
return apiClient.invokeAPI(
|
||||
apiPath,
|
||||
'GET',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
);
|
||||
}
|
||||
|
||||
/// Retrieve an asset file
|
||||
///
|
||||
/// Returns a metadata about a specific asset file.
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [String] assetId (required):
|
||||
/// Asset ID to filter files by
|
||||
///
|
||||
/// * [bool] isEdited:
|
||||
/// The file was generated from an edit
|
||||
///
|
||||
/// * [bool] isProgressive:
|
||||
/// The file is a progressively encoded JPEG
|
||||
///
|
||||
/// * [AssetFileType] type:
|
||||
/// Filter by type of file
|
||||
Future<List<AssetFileResponseDto>?> searchAssetFiles(String assetId, { bool? isEdited, bool? isProgressive, AssetFileType? type, }) async {
|
||||
final response = await searchAssetFilesWithHttpInfo(assetId, isEdited: isEdited, isProgressive: isProgressive, type: type, );
|
||||
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) {
|
||||
final responseBody = await _decodeBodyBytes(response);
|
||||
return (await apiClient.deserializeAsync(responseBody, 'List<AssetFileResponseDto>') as List)
|
||||
.cast<AssetFileResponseDto>()
|
||||
.toList(growable: false);
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
4
mobile/openapi/lib/api_client.dart
generated
4
mobile/openapi/lib/api_client.dart
generated
@@ -264,6 +264,10 @@ class ApiClient {
|
||||
return AssetFaceUpdateItem.fromJson(value);
|
||||
case 'AssetFaceWithoutPersonResponseDto':
|
||||
return AssetFaceWithoutPersonResponseDto.fromJson(value);
|
||||
case 'AssetFileResponseDto':
|
||||
return AssetFileResponseDto.fromJson(value);
|
||||
case 'AssetFileType':
|
||||
return AssetFileTypeTypeTransformer().decode(value);
|
||||
case 'AssetFullSyncDto':
|
||||
return AssetFullSyncDto.fromJson(value);
|
||||
case 'AssetIdsDto':
|
||||
|
||||
3
mobile/openapi/lib/api_helper.dart
generated
3
mobile/openapi/lib/api_helper.dart
generated
@@ -61,6 +61,9 @@ String parameterToString(dynamic value) {
|
||||
if (value is AssetEditAction) {
|
||||
return AssetEditActionTypeTransformer().encode(value).toString();
|
||||
}
|
||||
if (value is AssetFileType) {
|
||||
return AssetFileTypeTypeTransformer().encode(value).toString();
|
||||
}
|
||||
if (value is AssetJobName) {
|
||||
return AssetJobNameTypeTransformer().encode(value).toString();
|
||||
}
|
||||
|
||||
154
mobile/openapi/lib/model/asset_file_response_dto.dart
generated
Normal file
154
mobile/openapi/lib/model/asset_file_response_dto.dart
generated
Normal file
@@ -0,0 +1,154 @@
|
||||
//
|
||||
// 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 AssetFileResponseDto {
|
||||
/// Returns a new [AssetFileResponseDto] instance.
|
||||
AssetFileResponseDto({
|
||||
required this.createdAt,
|
||||
required this.id,
|
||||
required this.isEdited,
|
||||
required this.isProgressive,
|
||||
required this.path,
|
||||
required this.type,
|
||||
required this.updatedAt,
|
||||
});
|
||||
|
||||
/// Creation date
|
||||
DateTime createdAt;
|
||||
|
||||
/// Asset file ID
|
||||
String id;
|
||||
|
||||
/// The file was generated from an edit
|
||||
bool isEdited;
|
||||
|
||||
/// The file is a progressively encoded JPEG
|
||||
bool isProgressive;
|
||||
|
||||
/// File path
|
||||
String path;
|
||||
|
||||
/// Type of file
|
||||
AssetFileType type;
|
||||
|
||||
/// Update date
|
||||
DateTime updatedAt;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is AssetFileResponseDto &&
|
||||
other.createdAt == createdAt &&
|
||||
other.id == id &&
|
||||
other.isEdited == isEdited &&
|
||||
other.isProgressive == isProgressive &&
|
||||
other.path == path &&
|
||||
other.type == type &&
|
||||
other.updatedAt == updatedAt;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
(createdAt.hashCode) +
|
||||
(id.hashCode) +
|
||||
(isEdited.hashCode) +
|
||||
(isProgressive.hashCode) +
|
||||
(path.hashCode) +
|
||||
(type.hashCode) +
|
||||
(updatedAt.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'AssetFileResponseDto[createdAt=$createdAt, id=$id, isEdited=$isEdited, isProgressive=$isProgressive, path=$path, type=$type, updatedAt=$updatedAt]';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final json = <String, dynamic>{};
|
||||
json[r'createdAt'] = this.createdAt.toUtc().toIso8601String();
|
||||
json[r'id'] = this.id;
|
||||
json[r'isEdited'] = this.isEdited;
|
||||
json[r'isProgressive'] = this.isProgressive;
|
||||
json[r'path'] = this.path;
|
||||
json[r'type'] = this.type;
|
||||
json[r'updatedAt'] = this.updatedAt.toUtc().toIso8601String();
|
||||
return json;
|
||||
}
|
||||
|
||||
/// Returns a new [AssetFileResponseDto] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static AssetFileResponseDto? fromJson(dynamic value) {
|
||||
upgradeDto(value, "AssetFileResponseDto");
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
return AssetFileResponseDto(
|
||||
createdAt: mapDateTime(json, r'createdAt', r'')!,
|
||||
id: mapValueOfType<String>(json, r'id')!,
|
||||
isEdited: mapValueOfType<bool>(json, r'isEdited')!,
|
||||
isProgressive: mapValueOfType<bool>(json, r'isProgressive')!,
|
||||
path: mapValueOfType<String>(json, r'path')!,
|
||||
type: AssetFileType.fromJson(json[r'type'])!,
|
||||
updatedAt: mapDateTime(json, r'updatedAt', r'')!,
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<AssetFileResponseDto> listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <AssetFileResponseDto>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = AssetFileResponseDto.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, AssetFileResponseDto> mapFromJson(dynamic json) {
|
||||
final map = <String, AssetFileResponseDto>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = AssetFileResponseDto.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of AssetFileResponseDto-objects as value to a dart map
|
||||
static Map<String, List<AssetFileResponseDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<AssetFileResponseDto>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
// ignore: parameter_assignments
|
||||
json = json.cast<String, dynamic>();
|
||||
for (final entry in json.entries) {
|
||||
map[entry.key] = AssetFileResponseDto.listFromJson(entry.value, growable: growable,);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
'createdAt',
|
||||
'id',
|
||||
'isEdited',
|
||||
'isProgressive',
|
||||
'path',
|
||||
'type',
|
||||
'updatedAt',
|
||||
};
|
||||
}
|
||||
|
||||
91
mobile/openapi/lib/model/asset_file_type.dart
generated
Normal file
91
mobile/openapi/lib/model/asset_file_type.dart
generated
Normal file
@@ -0,0 +1,91 @@
|
||||
//
|
||||
// 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 AssetFileType {
|
||||
/// Instantiate a new enum with the provided [value].
|
||||
const AssetFileType._(this.value);
|
||||
|
||||
/// The underlying value of this enum member.
|
||||
final String value;
|
||||
|
||||
@override
|
||||
String toString() => value;
|
||||
|
||||
String toJson() => value;
|
||||
|
||||
static const fullsize = AssetFileType._(r'fullsize');
|
||||
static const preview = AssetFileType._(r'preview');
|
||||
static const thumbnail = AssetFileType._(r'thumbnail');
|
||||
static const sidecar = AssetFileType._(r'sidecar');
|
||||
|
||||
/// List of all possible values in this [enum][AssetFileType].
|
||||
static const values = <AssetFileType>[
|
||||
fullsize,
|
||||
preview,
|
||||
thumbnail,
|
||||
sidecar,
|
||||
];
|
||||
|
||||
static AssetFileType? fromJson(dynamic value) => AssetFileTypeTypeTransformer().decode(value);
|
||||
|
||||
static List<AssetFileType> listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <AssetFileType>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = AssetFileType.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
}
|
||||
|
||||
/// Transformation class that can [encode] an instance of [AssetFileType] to String,
|
||||
/// and [decode] dynamic data back to [AssetFileType].
|
||||
class AssetFileTypeTypeTransformer {
|
||||
factory AssetFileTypeTypeTransformer() => _instance ??= const AssetFileTypeTypeTransformer._();
|
||||
|
||||
const AssetFileTypeTypeTransformer._();
|
||||
|
||||
String encode(AssetFileType data) => data.value;
|
||||
|
||||
/// Decodes a [dynamic value][data] to a AssetFileType.
|
||||
///
|
||||
/// If [allowNull] is true and the [dynamic value][data] cannot be decoded successfully,
|
||||
/// then null is returned. However, if [allowNull] is false and the [dynamic value][data]
|
||||
/// cannot be decoded successfully, then an [UnimplementedError] is thrown.
|
||||
///
|
||||
/// The [allowNull] is very handy when an API changes and a new enum value is added or removed,
|
||||
/// and users are still using an old app with the old code.
|
||||
AssetFileType? decode(dynamic data, {bool allowNull = true}) {
|
||||
if (data != null) {
|
||||
switch (data) {
|
||||
case r'fullsize': return AssetFileType.fullsize;
|
||||
case r'preview': return AssetFileType.preview;
|
||||
case r'thumbnail': return AssetFileType.thumbnail;
|
||||
case r'sidecar': return AssetFileType.sidecar;
|
||||
default:
|
||||
if (!allowNull) {
|
||||
throw ArgumentError('Unknown enum value to decode: $data');
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Singleton [AssetFileTypeTypeTransformer] instance.
|
||||
static AssetFileTypeTypeTransformer? _instance;
|
||||
}
|
||||
|
||||
9
mobile/openapi/lib/model/permission.dart
generated
9
mobile/openapi/lib/model/permission.dart
generated
@@ -44,6 +44,9 @@ class Permission {
|
||||
static const assetPeriodReplace = Permission._(r'asset.replace');
|
||||
static const assetPeriodCopy = Permission._(r'asset.copy');
|
||||
static const assetPeriodDerive = Permission._(r'asset.derive');
|
||||
static const assetFilePeriodRead = Permission._(r'assetFile.read');
|
||||
static const assetFilePeriodDelete = Permission._(r'assetFile.delete');
|
||||
static const assetFilePeriodDownload = Permission._(r'assetFile.download');
|
||||
static const assetPeriodEditPeriodGet = Permission._(r'asset.edit.get');
|
||||
static const assetPeriodEditPeriodCreate = Permission._(r'asset.edit.create');
|
||||
static const assetPeriodEditPeriodDelete = Permission._(r'asset.edit.delete');
|
||||
@@ -203,6 +206,9 @@ class Permission {
|
||||
assetPeriodReplace,
|
||||
assetPeriodCopy,
|
||||
assetPeriodDerive,
|
||||
assetFilePeriodRead,
|
||||
assetFilePeriodDelete,
|
||||
assetFilePeriodDownload,
|
||||
assetPeriodEditPeriodGet,
|
||||
assetPeriodEditPeriodCreate,
|
||||
assetPeriodEditPeriodDelete,
|
||||
@@ -397,6 +403,9 @@ class PermissionTypeTransformer {
|
||||
case r'asset.replace': return Permission.assetPeriodReplace;
|
||||
case r'asset.copy': return Permission.assetPeriodCopy;
|
||||
case r'asset.derive': return Permission.assetPeriodDerive;
|
||||
case r'assetFile.read': return Permission.assetFilePeriodRead;
|
||||
case r'assetFile.delete': return Permission.assetFilePeriodDelete;
|
||||
case r'assetFile.download': return Permission.assetFilePeriodDownload;
|
||||
case r'asset.edit.get': return Permission.assetPeriodEditPeriodGet;
|
||||
case r'asset.edit.create': return Permission.assetPeriodEditPeriodCreate;
|
||||
case r'asset.edit.delete': return Permission.assetPeriodEditPeriodDelete;
|
||||
|
||||
Reference in New Issue
Block a user