1
0
mirror of https://github.com/immich-app/immich.git synced 2025-07-14 07:04:24 +02:00

feat(server): user and server license endpoints (#10682)

* feat: user license endpoints

* feat: server license endpoints

* chore: pr feedback

* chore: add more test cases

* chore: add prod license public keys

* chore: open-api generation
This commit is contained in:
Zack Pollard
2024-07-01 18:43:16 +01:00
committed by GitHub
parent 4193b0dede
commit 3b37b70626
40 changed files with 1474 additions and 18 deletions

View File

@ -0,0 +1,106 @@
//
// 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 LicenseKeyDto {
/// Returns a new [LicenseKeyDto] instance.
LicenseKeyDto({
required this.activationKey,
required this.licenseKey,
});
String activationKey;
String licenseKey;
@override
bool operator ==(Object other) => identical(this, other) || other is LicenseKeyDto &&
other.activationKey == activationKey &&
other.licenseKey == licenseKey;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(activationKey.hashCode) +
(licenseKey.hashCode);
@override
String toString() => 'LicenseKeyDto[activationKey=$activationKey, licenseKey=$licenseKey]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'activationKey'] = this.activationKey;
json[r'licenseKey'] = this.licenseKey;
return json;
}
/// Returns a new [LicenseKeyDto] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static LicenseKeyDto? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
return LicenseKeyDto(
activationKey: mapValueOfType<String>(json, r'activationKey')!,
licenseKey: mapValueOfType<String>(json, r'licenseKey')!,
);
}
return null;
}
static List<LicenseKeyDto> listFromJson(dynamic json, {bool growable = false,}) {
final result = <LicenseKeyDto>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = LicenseKeyDto.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
static Map<String, LicenseKeyDto> mapFromJson(dynamic json) {
final map = <String, LicenseKeyDto>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = LicenseKeyDto.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
}
}
return map;
}
// maps a json object with a list of LicenseKeyDto-objects as value to a dart map
static Map<String, List<LicenseKeyDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<LicenseKeyDto>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = LicenseKeyDto.listFromJson(entry.value, growable: growable,);
}
}
return map;
}
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'activationKey',
'licenseKey',
};
}

View File

@ -0,0 +1,114 @@
//
// 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 LicenseResponseDto {
/// Returns a new [LicenseResponseDto] instance.
LicenseResponseDto({
required this.activatedAt,
required this.activationKey,
required this.licenseKey,
});
DateTime activatedAt;
String activationKey;
String licenseKey;
@override
bool operator ==(Object other) => identical(this, other) || other is LicenseResponseDto &&
other.activatedAt == activatedAt &&
other.activationKey == activationKey &&
other.licenseKey == licenseKey;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(activatedAt.hashCode) +
(activationKey.hashCode) +
(licenseKey.hashCode);
@override
String toString() => 'LicenseResponseDto[activatedAt=$activatedAt, activationKey=$activationKey, licenseKey=$licenseKey]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'activatedAt'] = this.activatedAt.toUtc().toIso8601String();
json[r'activationKey'] = this.activationKey;
json[r'licenseKey'] = this.licenseKey;
return json;
}
/// Returns a new [LicenseResponseDto] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static LicenseResponseDto? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
return LicenseResponseDto(
activatedAt: mapDateTime(json, r'activatedAt', r'')!,
activationKey: mapValueOfType<String>(json, r'activationKey')!,
licenseKey: mapValueOfType<String>(json, r'licenseKey')!,
);
}
return null;
}
static List<LicenseResponseDto> listFromJson(dynamic json, {bool growable = false,}) {
final result = <LicenseResponseDto>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = LicenseResponseDto.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
static Map<String, LicenseResponseDto> mapFromJson(dynamic json) {
final map = <String, LicenseResponseDto>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = LicenseResponseDto.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
}
}
return map;
}
// maps a json object with a list of LicenseResponseDto-objects as value to a dart map
static Map<String, List<LicenseResponseDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<LicenseResponseDto>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = LicenseResponseDto.listFromJson(entry.value, growable: growable,);
}
}
return map;
}
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'activatedAt',
'activationKey',
'licenseKey',
};
}

View File

@ -21,6 +21,7 @@ class ServerAboutResponseDto {
this.ffmpeg,
this.imagemagick,
this.libvips,
required this.licensed,
this.nodejs,
this.repository,
this.repositoryUrl,
@ -95,6 +96,8 @@ class ServerAboutResponseDto {
///
String? libvips;
bool licensed;
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
@ -157,6 +160,7 @@ class ServerAboutResponseDto {
other.ffmpeg == ffmpeg &&
other.imagemagick == imagemagick &&
other.libvips == libvips &&
other.licensed == licensed &&
other.nodejs == nodejs &&
other.repository == repository &&
other.repositoryUrl == repositoryUrl &&
@ -177,6 +181,7 @@ class ServerAboutResponseDto {
(ffmpeg == null ? 0 : ffmpeg!.hashCode) +
(imagemagick == null ? 0 : imagemagick!.hashCode) +
(libvips == null ? 0 : libvips!.hashCode) +
(licensed.hashCode) +
(nodejs == null ? 0 : nodejs!.hashCode) +
(repository == null ? 0 : repository!.hashCode) +
(repositoryUrl == null ? 0 : repositoryUrl!.hashCode) +
@ -187,7 +192,7 @@ class ServerAboutResponseDto {
(versionUrl.hashCode);
@override
String toString() => 'ServerAboutResponseDto[build=$build, buildImage=$buildImage, buildImageUrl=$buildImageUrl, buildUrl=$buildUrl, exiftool=$exiftool, ffmpeg=$ffmpeg, imagemagick=$imagemagick, libvips=$libvips, nodejs=$nodejs, repository=$repository, repositoryUrl=$repositoryUrl, sourceCommit=$sourceCommit, sourceRef=$sourceRef, sourceUrl=$sourceUrl, version=$version, versionUrl=$versionUrl]';
String toString() => 'ServerAboutResponseDto[build=$build, buildImage=$buildImage, buildImageUrl=$buildImageUrl, buildUrl=$buildUrl, exiftool=$exiftool, ffmpeg=$ffmpeg, imagemagick=$imagemagick, libvips=$libvips, licensed=$licensed, nodejs=$nodejs, repository=$repository, repositoryUrl=$repositoryUrl, sourceCommit=$sourceCommit, sourceRef=$sourceRef, sourceUrl=$sourceUrl, version=$version, versionUrl=$versionUrl]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@ -231,6 +236,7 @@ class ServerAboutResponseDto {
} else {
// json[r'libvips'] = null;
}
json[r'licensed'] = this.licensed;
if (this.nodejs != null) {
json[r'nodejs'] = this.nodejs;
} else {
@ -282,6 +288,7 @@ class ServerAboutResponseDto {
ffmpeg: mapValueOfType<String>(json, r'ffmpeg'),
imagemagick: mapValueOfType<String>(json, r'imagemagick'),
libvips: mapValueOfType<String>(json, r'libvips'),
licensed: mapValueOfType<bool>(json, r'licensed')!,
nodejs: mapValueOfType<String>(json, r'nodejs'),
repository: mapValueOfType<String>(json, r'repository'),
repositoryUrl: mapValueOfType<String>(json, r'repositoryUrl'),
@ -337,6 +344,7 @@ class ServerAboutResponseDto {
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'licensed',
'version',
'versionUrl',
};

View File

@ -19,6 +19,7 @@ class UserAdminResponseDto {
required this.email,
required this.id,
required this.isAdmin,
required this.license,
required this.name,
required this.oauthId,
required this.profileImagePath,
@ -42,6 +43,8 @@ class UserAdminResponseDto {
bool isAdmin;
UserLicense? license;
String name;
String oauthId;
@ -68,6 +71,7 @@ class UserAdminResponseDto {
other.email == email &&
other.id == id &&
other.isAdmin == isAdmin &&
other.license == license &&
other.name == name &&
other.oauthId == oauthId &&
other.profileImagePath == profileImagePath &&
@ -87,6 +91,7 @@ class UserAdminResponseDto {
(email.hashCode) +
(id.hashCode) +
(isAdmin.hashCode) +
(license == null ? 0 : license!.hashCode) +
(name.hashCode) +
(oauthId.hashCode) +
(profileImagePath.hashCode) +
@ -98,7 +103,7 @@ class UserAdminResponseDto {
(updatedAt.hashCode);
@override
String toString() => 'UserAdminResponseDto[avatarColor=$avatarColor, createdAt=$createdAt, deletedAt=$deletedAt, email=$email, id=$id, isAdmin=$isAdmin, name=$name, oauthId=$oauthId, profileImagePath=$profileImagePath, quotaSizeInBytes=$quotaSizeInBytes, quotaUsageInBytes=$quotaUsageInBytes, shouldChangePassword=$shouldChangePassword, status=$status, storageLabel=$storageLabel, updatedAt=$updatedAt]';
String toString() => 'UserAdminResponseDto[avatarColor=$avatarColor, createdAt=$createdAt, deletedAt=$deletedAt, email=$email, id=$id, isAdmin=$isAdmin, license=$license, name=$name, oauthId=$oauthId, profileImagePath=$profileImagePath, quotaSizeInBytes=$quotaSizeInBytes, quotaUsageInBytes=$quotaUsageInBytes, shouldChangePassword=$shouldChangePassword, status=$status, storageLabel=$storageLabel, updatedAt=$updatedAt]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@ -112,6 +117,11 @@ class UserAdminResponseDto {
json[r'email'] = this.email;
json[r'id'] = this.id;
json[r'isAdmin'] = this.isAdmin;
if (this.license != null) {
json[r'license'] = this.license;
} else {
// json[r'license'] = null;
}
json[r'name'] = this.name;
json[r'oauthId'] = this.oauthId;
json[r'profileImagePath'] = this.profileImagePath;
@ -150,6 +160,7 @@ class UserAdminResponseDto {
email: mapValueOfType<String>(json, r'email')!,
id: mapValueOfType<String>(json, r'id')!,
isAdmin: mapValueOfType<bool>(json, r'isAdmin')!,
license: UserLicense.fromJson(json[r'license']),
name: mapValueOfType<String>(json, r'name')!,
oauthId: mapValueOfType<String>(json, r'oauthId')!,
profileImagePath: mapValueOfType<String>(json, r'profileImagePath')!,
@ -212,6 +223,7 @@ class UserAdminResponseDto {
'email',
'id',
'isAdmin',
'license',
'name',
'oauthId',
'profileImagePath',

114
mobile/openapi/lib/model/user_license.dart generated Normal file
View File

@ -0,0 +1,114 @@
//
// 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 UserLicense {
/// Returns a new [UserLicense] instance.
UserLicense({
required this.activatedAt,
required this.activationKey,
required this.licenseKey,
});
DateTime activatedAt;
String activationKey;
String licenseKey;
@override
bool operator ==(Object other) => identical(this, other) || other is UserLicense &&
other.activatedAt == activatedAt &&
other.activationKey == activationKey &&
other.licenseKey == licenseKey;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(activatedAt.hashCode) +
(activationKey.hashCode) +
(licenseKey.hashCode);
@override
String toString() => 'UserLicense[activatedAt=$activatedAt, activationKey=$activationKey, licenseKey=$licenseKey]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'activatedAt'] = this.activatedAt.toUtc().toIso8601String();
json[r'activationKey'] = this.activationKey;
json[r'licenseKey'] = this.licenseKey;
return json;
}
/// Returns a new [UserLicense] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static UserLicense? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
return UserLicense(
activatedAt: mapDateTime(json, r'activatedAt', r'')!,
activationKey: mapValueOfType<String>(json, r'activationKey')!,
licenseKey: mapValueOfType<String>(json, r'licenseKey')!,
);
}
return null;
}
static List<UserLicense> listFromJson(dynamic json, {bool growable = false,}) {
final result = <UserLicense>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = UserLicense.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
static Map<String, UserLicense> mapFromJson(dynamic json) {
final map = <String, UserLicense>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = UserLicense.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
}
}
return map;
}
// maps a json object with a list of UserLicense-objects as value to a dart map
static Map<String, List<UserLicense>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<UserLicense>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = UserLicense.listFromJson(entry.value, growable: growable,);
}
}
return map;
}
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'activatedAt',
'activationKey',
'licenseKey',
};
}