mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
feat: asset file apis
This commit is contained in:
+154
@@ -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
@@ -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;
|
||||
}
|
||||
|
||||
Generated
+9
@@ -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