mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
Generated
+6
-6
@@ -56,10 +56,10 @@ import 'package:openapi/api.dart';
|
||||
//defaultApiClient.getAuthentication<HttpBearerAuth>('bearer').setAccessToken(yourTokenGeneratorFunction);
|
||||
|
||||
final api_instance = APIKeysApi();
|
||||
final aPIKeyCreateDto = APIKeyCreateDto(); // APIKeyCreateDto |
|
||||
final apiKeyCreateDto = ApiKeyCreateDto(); // ApiKeyCreateDto |
|
||||
|
||||
try {
|
||||
final result = api_instance.createApiKey(aPIKeyCreateDto);
|
||||
final result = api_instance.createApiKey(apiKeyCreateDto);
|
||||
print(result);
|
||||
} catch (e) {
|
||||
print('Exception when calling APIKeysApi->createApiKey: $e\n');
|
||||
@@ -319,10 +319,6 @@ Class | Method | HTTP request | Description
|
||||
|
||||
## Documentation For Models
|
||||
|
||||
- [APIKeyCreateDto](doc//APIKeyCreateDto.md)
|
||||
- [APIKeyCreateResponseDto](doc//APIKeyCreateResponseDto.md)
|
||||
- [APIKeyResponseDto](doc//APIKeyResponseDto.md)
|
||||
- [APIKeyUpdateDto](doc//APIKeyUpdateDto.md)
|
||||
- [ActivityCreateDto](doc//ActivityCreateDto.md)
|
||||
- [ActivityResponseDto](doc//ActivityResponseDto.md)
|
||||
- [ActivityStatisticsResponseDto](doc//ActivityStatisticsResponseDto.md)
|
||||
@@ -338,6 +334,10 @@ Class | Method | HTTP request | Description
|
||||
- [AlbumsAddAssetsResponseDto](doc//AlbumsAddAssetsResponseDto.md)
|
||||
- [AlbumsResponse](doc//AlbumsResponse.md)
|
||||
- [AlbumsUpdate](doc//AlbumsUpdate.md)
|
||||
- [ApiKeyCreateDto](doc//ApiKeyCreateDto.md)
|
||||
- [ApiKeyCreateResponseDto](doc//ApiKeyCreateResponseDto.md)
|
||||
- [ApiKeyResponseDto](doc//ApiKeyResponseDto.md)
|
||||
- [ApiKeyUpdateDto](doc//ApiKeyUpdateDto.md)
|
||||
- [AssetBulkDeleteDto](doc//AssetBulkDeleteDto.md)
|
||||
- [AssetBulkUpdateDto](doc//AssetBulkUpdateDto.md)
|
||||
- [AssetBulkUploadCheckDto](doc//AssetBulkUploadCheckDto.md)
|
||||
|
||||
Generated
+4
-4
@@ -68,10 +68,6 @@ part 'api/users_admin_api.dart';
|
||||
part 'api/views_api.dart';
|
||||
part 'api/workflows_api.dart';
|
||||
|
||||
part 'model/api_key_create_dto.dart';
|
||||
part 'model/api_key_create_response_dto.dart';
|
||||
part 'model/api_key_response_dto.dart';
|
||||
part 'model/api_key_update_dto.dart';
|
||||
part 'model/activity_create_dto.dart';
|
||||
part 'model/activity_response_dto.dart';
|
||||
part 'model/activity_statistics_response_dto.dart';
|
||||
@@ -87,6 +83,10 @@ part 'model/albums_add_assets_dto.dart';
|
||||
part 'model/albums_add_assets_response_dto.dart';
|
||||
part 'model/albums_response.dart';
|
||||
part 'model/albums_update.dart';
|
||||
part 'model/api_key_create_dto.dart';
|
||||
part 'model/api_key_create_response_dto.dart';
|
||||
part 'model/api_key_response_dto.dart';
|
||||
part 'model/api_key_update_dto.dart';
|
||||
part 'model/asset_bulk_delete_dto.dart';
|
||||
part 'model/asset_bulk_update_dto.dart';
|
||||
part 'model/asset_bulk_upload_check_dto.dart';
|
||||
|
||||
Generated
+21
-21
@@ -24,13 +24,13 @@ class APIKeysApi {
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [APIKeyCreateDto] aPIKeyCreateDto (required):
|
||||
Future<Response> createApiKeyWithHttpInfo(APIKeyCreateDto aPIKeyCreateDto,) async {
|
||||
/// * [ApiKeyCreateDto] apiKeyCreateDto (required):
|
||||
Future<Response> createApiKeyWithHttpInfo(ApiKeyCreateDto apiKeyCreateDto,) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final apiPath = r'/api-keys';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object? postBody = aPIKeyCreateDto;
|
||||
Object? postBody = apiKeyCreateDto;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@@ -56,9 +56,9 @@ class APIKeysApi {
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [APIKeyCreateDto] aPIKeyCreateDto (required):
|
||||
Future<APIKeyCreateResponseDto?> createApiKey(APIKeyCreateDto aPIKeyCreateDto,) async {
|
||||
final response = await createApiKeyWithHttpInfo(aPIKeyCreateDto,);
|
||||
/// * [ApiKeyCreateDto] apiKeyCreateDto (required):
|
||||
Future<ApiKeyCreateResponseDto?> createApiKey(ApiKeyCreateDto apiKeyCreateDto,) async {
|
||||
final response = await createApiKeyWithHttpInfo(apiKeyCreateDto,);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
}
|
||||
@@ -66,7 +66,7 @@ class APIKeysApi {
|
||||
// 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), 'APIKeyCreateResponseDto',) as APIKeyCreateResponseDto;
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ApiKeyCreateResponseDto',) as ApiKeyCreateResponseDto;
|
||||
|
||||
}
|
||||
return null;
|
||||
@@ -163,7 +163,7 @@ class APIKeysApi {
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [String] id (required):
|
||||
Future<APIKeyResponseDto?> getApiKey(String id,) async {
|
||||
Future<ApiKeyResponseDto?> getApiKey(String id,) async {
|
||||
final response = await getApiKeyWithHttpInfo(id,);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@@ -172,7 +172,7 @@ class APIKeysApi {
|
||||
// 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), 'APIKeyResponseDto',) as APIKeyResponseDto;
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ApiKeyResponseDto',) as ApiKeyResponseDto;
|
||||
|
||||
}
|
||||
return null;
|
||||
@@ -211,7 +211,7 @@ class APIKeysApi {
|
||||
/// List all API keys
|
||||
///
|
||||
/// Retrieve all API keys of the current user.
|
||||
Future<List<APIKeyResponseDto>?> getApiKeys() async {
|
||||
Future<List<ApiKeyResponseDto>?> getApiKeys() async {
|
||||
final response = await getApiKeysWithHttpInfo();
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@@ -221,8 +221,8 @@ class APIKeysApi {
|
||||
// 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<APIKeyResponseDto>') as List)
|
||||
.cast<APIKeyResponseDto>()
|
||||
return (await apiClient.deserializeAsync(responseBody, 'List<ApiKeyResponseDto>') as List)
|
||||
.cast<ApiKeyResponseDto>()
|
||||
.toList(growable: false);
|
||||
|
||||
}
|
||||
@@ -262,7 +262,7 @@ class APIKeysApi {
|
||||
/// Retrieve the current API key
|
||||
///
|
||||
/// Retrieve the API key that is used to access this endpoint.
|
||||
Future<APIKeyResponseDto?> getMyApiKey() async {
|
||||
Future<ApiKeyResponseDto?> getMyApiKey() async {
|
||||
final response = await getMyApiKeyWithHttpInfo();
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@@ -271,7 +271,7 @@ class APIKeysApi {
|
||||
// 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), 'APIKeyResponseDto',) as APIKeyResponseDto;
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ApiKeyResponseDto',) as ApiKeyResponseDto;
|
||||
|
||||
}
|
||||
return null;
|
||||
@@ -287,14 +287,14 @@ class APIKeysApi {
|
||||
///
|
||||
/// * [String] id (required):
|
||||
///
|
||||
/// * [APIKeyUpdateDto] aPIKeyUpdateDto (required):
|
||||
Future<Response> updateApiKeyWithHttpInfo(String id, APIKeyUpdateDto aPIKeyUpdateDto,) async {
|
||||
/// * [ApiKeyUpdateDto] apiKeyUpdateDto (required):
|
||||
Future<Response> updateApiKeyWithHttpInfo(String id, ApiKeyUpdateDto apiKeyUpdateDto,) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final apiPath = r'/api-keys/{id}'
|
||||
.replaceAll('{id}', id);
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object? postBody = aPIKeyUpdateDto;
|
||||
Object? postBody = apiKeyUpdateDto;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@@ -322,9 +322,9 @@ class APIKeysApi {
|
||||
///
|
||||
/// * [String] id (required):
|
||||
///
|
||||
/// * [APIKeyUpdateDto] aPIKeyUpdateDto (required):
|
||||
Future<APIKeyResponseDto?> updateApiKey(String id, APIKeyUpdateDto aPIKeyUpdateDto,) async {
|
||||
final response = await updateApiKeyWithHttpInfo(id, aPIKeyUpdateDto,);
|
||||
/// * [ApiKeyUpdateDto] apiKeyUpdateDto (required):
|
||||
Future<ApiKeyResponseDto?> updateApiKey(String id, ApiKeyUpdateDto apiKeyUpdateDto,) async {
|
||||
final response = await updateApiKeyWithHttpInfo(id, apiKeyUpdateDto,);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
}
|
||||
@@ -332,7 +332,7 @@ class APIKeysApi {
|
||||
// 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), 'APIKeyResponseDto',) as APIKeyResponseDto;
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ApiKeyResponseDto',) as ApiKeyResponseDto;
|
||||
|
||||
}
|
||||
return null;
|
||||
|
||||
Generated
+2
-2
@@ -731,7 +731,7 @@ class UsersApi {
|
||||
|
||||
/// Update current user
|
||||
///
|
||||
/// Update the current user making teh API request.
|
||||
/// Update the current user making the API request.
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
///
|
||||
@@ -765,7 +765,7 @@ class UsersApi {
|
||||
|
||||
/// Update current user
|
||||
///
|
||||
/// Update the current user making teh API request.
|
||||
/// Update the current user making the API request.
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
|
||||
Generated
+8
-8
@@ -182,14 +182,6 @@ class ApiClient {
|
||||
return valueString == 'true' || valueString == '1';
|
||||
case 'DateTime':
|
||||
return value is DateTime ? value : DateTime.tryParse(value);
|
||||
case 'APIKeyCreateDto':
|
||||
return APIKeyCreateDto.fromJson(value);
|
||||
case 'APIKeyCreateResponseDto':
|
||||
return APIKeyCreateResponseDto.fromJson(value);
|
||||
case 'APIKeyResponseDto':
|
||||
return APIKeyResponseDto.fromJson(value);
|
||||
case 'APIKeyUpdateDto':
|
||||
return APIKeyUpdateDto.fromJson(value);
|
||||
case 'ActivityCreateDto':
|
||||
return ActivityCreateDto.fromJson(value);
|
||||
case 'ActivityResponseDto':
|
||||
@@ -220,6 +212,14 @@ class ApiClient {
|
||||
return AlbumsResponse.fromJson(value);
|
||||
case 'AlbumsUpdate':
|
||||
return AlbumsUpdate.fromJson(value);
|
||||
case 'ApiKeyCreateDto':
|
||||
return ApiKeyCreateDto.fromJson(value);
|
||||
case 'ApiKeyCreateResponseDto':
|
||||
return ApiKeyCreateResponseDto.fromJson(value);
|
||||
case 'ApiKeyResponseDto':
|
||||
return ApiKeyResponseDto.fromJson(value);
|
||||
case 'ApiKeyUpdateDto':
|
||||
return ApiKeyUpdateDto.fromJson(value);
|
||||
case 'AssetBulkDeleteDto':
|
||||
return AssetBulkDeleteDto.fromJson(value);
|
||||
case 'AssetBulkUpdateDto':
|
||||
|
||||
+19
-19
@@ -10,9 +10,9 @@
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
class APIKeyCreateDto {
|
||||
/// Returns a new [APIKeyCreateDto] instance.
|
||||
APIKeyCreateDto({
|
||||
class ApiKeyCreateDto {
|
||||
/// Returns a new [ApiKeyCreateDto] instance.
|
||||
ApiKeyCreateDto({
|
||||
this.name,
|
||||
this.permissions = const [],
|
||||
});
|
||||
@@ -30,7 +30,7 @@ class APIKeyCreateDto {
|
||||
List<Permission> permissions;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is APIKeyCreateDto &&
|
||||
bool operator ==(Object other) => identical(this, other) || other is ApiKeyCreateDto &&
|
||||
other.name == name &&
|
||||
_deepEquality.equals(other.permissions, permissions);
|
||||
|
||||
@@ -41,7 +41,7 @@ class APIKeyCreateDto {
|
||||
(permissions.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'APIKeyCreateDto[name=$name, permissions=$permissions]';
|
||||
String toString() => 'ApiKeyCreateDto[name=$name, permissions=$permissions]';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final json = <String, dynamic>{};
|
||||
@@ -54,15 +54,15 @@ class APIKeyCreateDto {
|
||||
return json;
|
||||
}
|
||||
|
||||
/// Returns a new [APIKeyCreateDto] instance and imports its values from
|
||||
/// Returns a new [ApiKeyCreateDto] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static APIKeyCreateDto? fromJson(dynamic value) {
|
||||
upgradeDto(value, "APIKeyCreateDto");
|
||||
static ApiKeyCreateDto? fromJson(dynamic value) {
|
||||
upgradeDto(value, "ApiKeyCreateDto");
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
return APIKeyCreateDto(
|
||||
return ApiKeyCreateDto(
|
||||
name: mapValueOfType<String>(json, r'name'),
|
||||
permissions: Permission.listFromJson(json[r'permissions']),
|
||||
);
|
||||
@@ -70,11 +70,11 @@ class APIKeyCreateDto {
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<APIKeyCreateDto> listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <APIKeyCreateDto>[];
|
||||
static List<ApiKeyCreateDto> listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <ApiKeyCreateDto>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = APIKeyCreateDto.fromJson(row);
|
||||
final value = ApiKeyCreateDto.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
@@ -83,12 +83,12 @@ class APIKeyCreateDto {
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, APIKeyCreateDto> mapFromJson(dynamic json) {
|
||||
final map = <String, APIKeyCreateDto>{};
|
||||
static Map<String, ApiKeyCreateDto> mapFromJson(dynamic json) {
|
||||
final map = <String, ApiKeyCreateDto>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = APIKeyCreateDto.fromJson(entry.value);
|
||||
final value = ApiKeyCreateDto.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
@@ -97,14 +97,14 @@ class APIKeyCreateDto {
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of APIKeyCreateDto-objects as value to a dart map
|
||||
static Map<String, List<APIKeyCreateDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<APIKeyCreateDto>>{};
|
||||
// maps a json object with a list of ApiKeyCreateDto-objects as value to a dart map
|
||||
static Map<String, List<ApiKeyCreateDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<ApiKeyCreateDto>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
// ignore: parameter_assignments
|
||||
json = json.cast<String, dynamic>();
|
||||
for (final entry in json.entries) {
|
||||
map[entry.key] = APIKeyCreateDto.listFromJson(entry.value, growable: growable,);
|
||||
map[entry.key] = ApiKeyCreateDto.listFromJson(entry.value, growable: growable,);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
|
||||
+21
-21
@@ -10,20 +10,20 @@
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
class APIKeyCreateResponseDto {
|
||||
/// Returns a new [APIKeyCreateResponseDto] instance.
|
||||
APIKeyCreateResponseDto({
|
||||
class ApiKeyCreateResponseDto {
|
||||
/// Returns a new [ApiKeyCreateResponseDto] instance.
|
||||
ApiKeyCreateResponseDto({
|
||||
required this.apiKey,
|
||||
required this.secret,
|
||||
});
|
||||
|
||||
APIKeyResponseDto apiKey;
|
||||
ApiKeyResponseDto apiKey;
|
||||
|
||||
/// API key secret (only shown once)
|
||||
String secret;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is APIKeyCreateResponseDto &&
|
||||
bool operator ==(Object other) => identical(this, other) || other is ApiKeyCreateResponseDto &&
|
||||
other.apiKey == apiKey &&
|
||||
other.secret == secret;
|
||||
|
||||
@@ -34,7 +34,7 @@ class APIKeyCreateResponseDto {
|
||||
(secret.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'APIKeyCreateResponseDto[apiKey=$apiKey, secret=$secret]';
|
||||
String toString() => 'ApiKeyCreateResponseDto[apiKey=$apiKey, secret=$secret]';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final json = <String, dynamic>{};
|
||||
@@ -43,27 +43,27 @@ class APIKeyCreateResponseDto {
|
||||
return json;
|
||||
}
|
||||
|
||||
/// Returns a new [APIKeyCreateResponseDto] instance and imports its values from
|
||||
/// Returns a new [ApiKeyCreateResponseDto] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static APIKeyCreateResponseDto? fromJson(dynamic value) {
|
||||
upgradeDto(value, "APIKeyCreateResponseDto");
|
||||
static ApiKeyCreateResponseDto? fromJson(dynamic value) {
|
||||
upgradeDto(value, "ApiKeyCreateResponseDto");
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
return APIKeyCreateResponseDto(
|
||||
apiKey: APIKeyResponseDto.fromJson(json[r'apiKey'])!,
|
||||
return ApiKeyCreateResponseDto(
|
||||
apiKey: ApiKeyResponseDto.fromJson(json[r'apiKey'])!,
|
||||
secret: mapValueOfType<String>(json, r'secret')!,
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<APIKeyCreateResponseDto> listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <APIKeyCreateResponseDto>[];
|
||||
static List<ApiKeyCreateResponseDto> listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <ApiKeyCreateResponseDto>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = APIKeyCreateResponseDto.fromJson(row);
|
||||
final value = ApiKeyCreateResponseDto.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
@@ -72,12 +72,12 @@ class APIKeyCreateResponseDto {
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, APIKeyCreateResponseDto> mapFromJson(dynamic json) {
|
||||
final map = <String, APIKeyCreateResponseDto>{};
|
||||
static Map<String, ApiKeyCreateResponseDto> mapFromJson(dynamic json) {
|
||||
final map = <String, ApiKeyCreateResponseDto>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = APIKeyCreateResponseDto.fromJson(entry.value);
|
||||
final value = ApiKeyCreateResponseDto.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
@@ -86,14 +86,14 @@ class APIKeyCreateResponseDto {
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of APIKeyCreateResponseDto-objects as value to a dart map
|
||||
static Map<String, List<APIKeyCreateResponseDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<APIKeyCreateResponseDto>>{};
|
||||
// maps a json object with a list of ApiKeyCreateResponseDto-objects as value to a dart map
|
||||
static Map<String, List<ApiKeyCreateResponseDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<ApiKeyCreateResponseDto>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
// ignore: parameter_assignments
|
||||
json = json.cast<String, dynamic>();
|
||||
for (final entry in json.entries) {
|
||||
map[entry.key] = APIKeyCreateResponseDto.listFromJson(entry.value, growable: growable,);
|
||||
map[entry.key] = ApiKeyCreateResponseDto.listFromJson(entry.value, growable: growable,);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
|
||||
+19
-19
@@ -10,9 +10,9 @@
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
class APIKeyResponseDto {
|
||||
/// Returns a new [APIKeyResponseDto] instance.
|
||||
APIKeyResponseDto({
|
||||
class ApiKeyResponseDto {
|
||||
/// Returns a new [ApiKeyResponseDto] instance.
|
||||
ApiKeyResponseDto({
|
||||
required this.createdAt,
|
||||
required this.id,
|
||||
required this.name,
|
||||
@@ -36,7 +36,7 @@ class APIKeyResponseDto {
|
||||
DateTime updatedAt;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is APIKeyResponseDto &&
|
||||
bool operator ==(Object other) => identical(this, other) || other is ApiKeyResponseDto &&
|
||||
other.createdAt == createdAt &&
|
||||
other.id == id &&
|
||||
other.name == name &&
|
||||
@@ -53,7 +53,7 @@ class APIKeyResponseDto {
|
||||
(updatedAt.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'APIKeyResponseDto[createdAt=$createdAt, id=$id, name=$name, permissions=$permissions, updatedAt=$updatedAt]';
|
||||
String toString() => 'ApiKeyResponseDto[createdAt=$createdAt, id=$id, name=$name, permissions=$permissions, updatedAt=$updatedAt]';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final json = <String, dynamic>{};
|
||||
@@ -69,15 +69,15 @@ class APIKeyResponseDto {
|
||||
return json;
|
||||
}
|
||||
|
||||
/// Returns a new [APIKeyResponseDto] instance and imports its values from
|
||||
/// Returns a new [ApiKeyResponseDto] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static APIKeyResponseDto? fromJson(dynamic value) {
|
||||
upgradeDto(value, "APIKeyResponseDto");
|
||||
static ApiKeyResponseDto? fromJson(dynamic value) {
|
||||
upgradeDto(value, "ApiKeyResponseDto");
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
return APIKeyResponseDto(
|
||||
return ApiKeyResponseDto(
|
||||
createdAt: mapDateTime(json, r'createdAt', r'/^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$/')!,
|
||||
id: mapValueOfType<String>(json, r'id')!,
|
||||
name: mapValueOfType<String>(json, r'name')!,
|
||||
@@ -88,11 +88,11 @@ class APIKeyResponseDto {
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<APIKeyResponseDto> listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <APIKeyResponseDto>[];
|
||||
static List<ApiKeyResponseDto> listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <ApiKeyResponseDto>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = APIKeyResponseDto.fromJson(row);
|
||||
final value = ApiKeyResponseDto.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
@@ -101,12 +101,12 @@ class APIKeyResponseDto {
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, APIKeyResponseDto> mapFromJson(dynamic json) {
|
||||
final map = <String, APIKeyResponseDto>{};
|
||||
static Map<String, ApiKeyResponseDto> mapFromJson(dynamic json) {
|
||||
final map = <String, ApiKeyResponseDto>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = APIKeyResponseDto.fromJson(entry.value);
|
||||
final value = ApiKeyResponseDto.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
@@ -115,14 +115,14 @@ class APIKeyResponseDto {
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of APIKeyResponseDto-objects as value to a dart map
|
||||
static Map<String, List<APIKeyResponseDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<APIKeyResponseDto>>{};
|
||||
// maps a json object with a list of ApiKeyResponseDto-objects as value to a dart map
|
||||
static Map<String, List<ApiKeyResponseDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<ApiKeyResponseDto>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
// ignore: parameter_assignments
|
||||
json = json.cast<String, dynamic>();
|
||||
for (final entry in json.entries) {
|
||||
map[entry.key] = APIKeyResponseDto.listFromJson(entry.value, growable: growable,);
|
||||
map[entry.key] = ApiKeyResponseDto.listFromJson(entry.value, growable: growable,);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
|
||||
+19
-19
@@ -10,9 +10,9 @@
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
class APIKeyUpdateDto {
|
||||
/// Returns a new [APIKeyUpdateDto] instance.
|
||||
APIKeyUpdateDto({
|
||||
class ApiKeyUpdateDto {
|
||||
/// Returns a new [ApiKeyUpdateDto] instance.
|
||||
ApiKeyUpdateDto({
|
||||
this.name,
|
||||
this.permissions = const [],
|
||||
});
|
||||
@@ -30,7 +30,7 @@ class APIKeyUpdateDto {
|
||||
List<Permission> permissions;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is APIKeyUpdateDto &&
|
||||
bool operator ==(Object other) => identical(this, other) || other is ApiKeyUpdateDto &&
|
||||
other.name == name &&
|
||||
_deepEquality.equals(other.permissions, permissions);
|
||||
|
||||
@@ -41,7 +41,7 @@ class APIKeyUpdateDto {
|
||||
(permissions.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'APIKeyUpdateDto[name=$name, permissions=$permissions]';
|
||||
String toString() => 'ApiKeyUpdateDto[name=$name, permissions=$permissions]';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final json = <String, dynamic>{};
|
||||
@@ -54,15 +54,15 @@ class APIKeyUpdateDto {
|
||||
return json;
|
||||
}
|
||||
|
||||
/// Returns a new [APIKeyUpdateDto] instance and imports its values from
|
||||
/// Returns a new [ApiKeyUpdateDto] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static APIKeyUpdateDto? fromJson(dynamic value) {
|
||||
upgradeDto(value, "APIKeyUpdateDto");
|
||||
static ApiKeyUpdateDto? fromJson(dynamic value) {
|
||||
upgradeDto(value, "ApiKeyUpdateDto");
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
return APIKeyUpdateDto(
|
||||
return ApiKeyUpdateDto(
|
||||
name: mapValueOfType<String>(json, r'name'),
|
||||
permissions: Permission.listFromJson(json[r'permissions']),
|
||||
);
|
||||
@@ -70,11 +70,11 @@ class APIKeyUpdateDto {
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<APIKeyUpdateDto> listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <APIKeyUpdateDto>[];
|
||||
static List<ApiKeyUpdateDto> listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <ApiKeyUpdateDto>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = APIKeyUpdateDto.fromJson(row);
|
||||
final value = ApiKeyUpdateDto.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
@@ -83,12 +83,12 @@ class APIKeyUpdateDto {
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, APIKeyUpdateDto> mapFromJson(dynamic json) {
|
||||
final map = <String, APIKeyUpdateDto>{};
|
||||
static Map<String, ApiKeyUpdateDto> mapFromJson(dynamic json) {
|
||||
final map = <String, ApiKeyUpdateDto>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = APIKeyUpdateDto.fromJson(entry.value);
|
||||
final value = ApiKeyUpdateDto.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
@@ -97,14 +97,14 @@ class APIKeyUpdateDto {
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of APIKeyUpdateDto-objects as value to a dart map
|
||||
static Map<String, List<APIKeyUpdateDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<APIKeyUpdateDto>>{};
|
||||
// maps a json object with a list of ApiKeyUpdateDto-objects as value to a dart map
|
||||
static Map<String, List<ApiKeyUpdateDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<ApiKeyUpdateDto>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
// ignore: parameter_assignments
|
||||
json = json.cast<String, dynamic>();
|
||||
for (final entry in json.entries) {
|
||||
map[entry.key] = APIKeyUpdateDto.listFromJson(entry.value, growable: growable,);
|
||||
map[entry.key] = ApiKeyUpdateDto.listFromJson(entry.value, growable: growable,);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
|
||||
+102
-102
@@ -2441,7 +2441,7 @@
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/APIKeyResponseDto"
|
||||
"$ref": "#/components/schemas/ApiKeyResponseDto"
|
||||
},
|
||||
"type": "array"
|
||||
}
|
||||
@@ -2490,7 +2490,7 @@
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/APIKeyCreateDto"
|
||||
"$ref": "#/components/schemas/ApiKeyCreateDto"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -2501,7 +2501,7 @@
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/APIKeyCreateResponseDto"
|
||||
"$ref": "#/components/schemas/ApiKeyCreateResponseDto"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -2551,7 +2551,7 @@
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/APIKeyResponseDto"
|
||||
"$ref": "#/components/schemas/ApiKeyResponseDto"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -2663,7 +2663,7 @@
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/APIKeyResponseDto"
|
||||
"$ref": "#/components/schemas/ApiKeyResponseDto"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -2721,7 +2721,7 @@
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/APIKeyUpdateDto"
|
||||
"$ref": "#/components/schemas/ApiKeyUpdateDto"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -2732,7 +2732,7 @@
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/APIKeyResponseDto"
|
||||
"$ref": "#/components/schemas/ApiKeyResponseDto"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -13831,7 +13831,7 @@
|
||||
"x-immich-state": "Stable"
|
||||
},
|
||||
"put": {
|
||||
"description": "Update the current user making teh API request.",
|
||||
"description": "Update the current user making the API request.",
|
||||
"operationId": "updateMyUser",
|
||||
"parameters": [],
|
||||
"requestBody": {
|
||||
@@ -15090,100 +15090,6 @@
|
||||
}
|
||||
},
|
||||
"schemas": {
|
||||
"APIKeyCreateDto": {
|
||||
"properties": {
|
||||
"name": {
|
||||
"description": "API key name",
|
||||
"type": "string"
|
||||
},
|
||||
"permissions": {
|
||||
"description": "List of permissions",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/Permission"
|
||||
},
|
||||
"minItems": 1,
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"permissions"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"APIKeyCreateResponseDto": {
|
||||
"properties": {
|
||||
"apiKey": {
|
||||
"$ref": "#/components/schemas/APIKeyResponseDto"
|
||||
},
|
||||
"secret": {
|
||||
"description": "API key secret (only shown once)",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"apiKey",
|
||||
"secret"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"APIKeyResponseDto": {
|
||||
"properties": {
|
||||
"createdAt": {
|
||||
"description": "Creation date",
|
||||
"example": "2024-01-01T00:00:00.000Z",
|
||||
"format": "date-time",
|
||||
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"description": "API key ID",
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"description": "API key name",
|
||||
"type": "string"
|
||||
},
|
||||
"permissions": {
|
||||
"description": "List of permissions",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/Permission"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"updatedAt": {
|
||||
"description": "Last update date",
|
||||
"example": "2024-01-01T00:00:00.000Z",
|
||||
"format": "date-time",
|
||||
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"createdAt",
|
||||
"id",
|
||||
"name",
|
||||
"permissions",
|
||||
"updatedAt"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"APIKeyUpdateDto": {
|
||||
"properties": {
|
||||
"name": {
|
||||
"description": "API key name",
|
||||
"type": "string"
|
||||
},
|
||||
"permissions": {
|
||||
"description": "List of permissions",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/Permission"
|
||||
},
|
||||
"minItems": 1,
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"ActivityCreateDto": {
|
||||
"description": "Activity create",
|
||||
"properties": {
|
||||
@@ -15564,6 +15470,100 @@
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"ApiKeyCreateDto": {
|
||||
"properties": {
|
||||
"name": {
|
||||
"description": "API key name",
|
||||
"type": "string"
|
||||
},
|
||||
"permissions": {
|
||||
"description": "List of permissions",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/Permission"
|
||||
},
|
||||
"minItems": 1,
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"permissions"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"ApiKeyCreateResponseDto": {
|
||||
"properties": {
|
||||
"apiKey": {
|
||||
"$ref": "#/components/schemas/ApiKeyResponseDto"
|
||||
},
|
||||
"secret": {
|
||||
"description": "API key secret (only shown once)",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"apiKey",
|
||||
"secret"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"ApiKeyResponseDto": {
|
||||
"properties": {
|
||||
"createdAt": {
|
||||
"description": "Creation date",
|
||||
"example": "2024-01-01T00:00:00.000Z",
|
||||
"format": "date-time",
|
||||
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"description": "API key ID",
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"description": "API key name",
|
||||
"type": "string"
|
||||
},
|
||||
"permissions": {
|
||||
"description": "List of permissions",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/Permission"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"updatedAt": {
|
||||
"description": "Last update date",
|
||||
"example": "2024-01-01T00:00:00.000Z",
|
||||
"format": "date-time",
|
||||
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"createdAt",
|
||||
"id",
|
||||
"name",
|
||||
"permissions",
|
||||
"updatedAt"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"ApiKeyUpdateDto": {
|
||||
"properties": {
|
||||
"name": {
|
||||
"description": "API key name",
|
||||
"type": "string"
|
||||
},
|
||||
"permissions": {
|
||||
"description": "List of permissions",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/Permission"
|
||||
},
|
||||
"minItems": 1,
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"AssetBulkDeleteDto": {
|
||||
"properties": {
|
||||
"force": {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Post, Put } from '@nestjs/common';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { Endpoint, HistoryBuilder } from 'src/decorators';
|
||||
import { APIKeyCreateDto, APIKeyCreateResponseDto, APIKeyResponseDto, APIKeyUpdateDto } from 'src/dtos/api-key.dto';
|
||||
import { ApiKeyCreateDto, ApiKeyCreateResponseDto, ApiKeyResponseDto, ApiKeyUpdateDto } from 'src/dtos/api-key.dto';
|
||||
import { AuthDto } from 'src/dtos/auth.dto';
|
||||
import { ApiTag, Permission } from 'src/enum';
|
||||
import { Auth, Authenticated } from 'src/middleware/auth.guard';
|
||||
@@ -20,7 +20,7 @@ export class ApiKeyController {
|
||||
description: 'Creates a new API key. It will be limited to the permissions specified.',
|
||||
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
||||
})
|
||||
createApiKey(@Auth() auth: AuthDto, @Body() dto: APIKeyCreateDto): Promise<APIKeyCreateResponseDto> {
|
||||
createApiKey(@Auth() auth: AuthDto, @Body() dto: ApiKeyCreateDto): Promise<ApiKeyCreateResponseDto> {
|
||||
return this.service.create(auth, dto);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ export class ApiKeyController {
|
||||
description: 'Retrieve all API keys of the current user.',
|
||||
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
||||
})
|
||||
getApiKeys(@Auth() auth: AuthDto): Promise<APIKeyResponseDto[]> {
|
||||
getApiKeys(@Auth() auth: AuthDto): Promise<ApiKeyResponseDto[]> {
|
||||
return this.service.getAll(auth);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ export class ApiKeyController {
|
||||
description: 'Retrieve the API key that is used to access this endpoint.',
|
||||
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
||||
})
|
||||
async getMyApiKey(@Auth() auth: AuthDto): Promise<APIKeyResponseDto> {
|
||||
async getMyApiKey(@Auth() auth: AuthDto): Promise<ApiKeyResponseDto> {
|
||||
return this.service.getMine(auth);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ export class ApiKeyController {
|
||||
description: 'Retrieve an API key by its ID. The current user must own this API key.',
|
||||
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
||||
})
|
||||
getApiKey(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<APIKeyResponseDto> {
|
||||
getApiKey(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<ApiKeyResponseDto> {
|
||||
return this.service.getById(auth, id);
|
||||
}
|
||||
|
||||
@@ -67,8 +67,8 @@ export class ApiKeyController {
|
||||
updateApiKey(
|
||||
@Auth() auth: AuthDto,
|
||||
@Param() { id }: UUIDParamDto,
|
||||
@Body() dto: APIKeyUpdateDto,
|
||||
): Promise<APIKeyResponseDto> {
|
||||
@Body() dto: ApiKeyUpdateDto,
|
||||
): Promise<ApiKeyResponseDto> {
|
||||
return this.service.update(auth, id, dto);
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ export class UserController {
|
||||
@Authenticated({ permission: Permission.UserUpdate })
|
||||
@Endpoint({
|
||||
summary: 'Update current user',
|
||||
description: 'Update the current user making teh API request.',
|
||||
description: 'Update the current user making the API request.',
|
||||
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
||||
})
|
||||
updateMyUser(@Auth() auth: AuthDto, @Body() dto: UserUpdateMeDto): Promise<UserAdminResponseDto> {
|
||||
|
||||
@@ -5,21 +5,21 @@ import z from 'zod';
|
||||
|
||||
const PermissionSchema = z.enum(Permission).describe('List of permissions').meta({ id: 'Permission' });
|
||||
|
||||
const APIKeyCreateSchema = z
|
||||
const ApiKeyCreateSchema = z
|
||||
.object({
|
||||
name: z.string().optional().describe('API key name'),
|
||||
permissions: z.array(PermissionSchema).min(1).describe('List of permissions'),
|
||||
})
|
||||
.meta({ id: 'APIKeyCreateDto' });
|
||||
.meta({ id: 'ApiKeyCreateDto' });
|
||||
|
||||
const APIKeyUpdateSchema = z
|
||||
const ApiKeyUpdateSchema = z
|
||||
.object({
|
||||
name: z.string().optional().describe('API key name'),
|
||||
permissions: z.array(PermissionSchema).min(1).optional().describe('List of permissions'),
|
||||
})
|
||||
.meta({ id: 'APIKeyUpdateDto' });
|
||||
.meta({ id: 'ApiKeyUpdateDto' });
|
||||
|
||||
const APIKeyResponseSchema = z
|
||||
const ApiKeyResponseSchema = z
|
||||
.object({
|
||||
id: z.string().describe('API key ID'),
|
||||
name: z.string().describe('API key name'),
|
||||
@@ -27,16 +27,16 @@ const APIKeyResponseSchema = z
|
||||
updatedAt: isoDatetimeToDate.describe('Last update date'),
|
||||
permissions: z.array(PermissionSchema).describe('List of permissions'),
|
||||
})
|
||||
.meta({ id: 'APIKeyResponseDto' });
|
||||
.meta({ id: 'ApiKeyResponseDto' });
|
||||
|
||||
const APIKeyCreateResponseSchema = z
|
||||
const ApiKeyCreateResponseSchema = z
|
||||
.object({
|
||||
secret: z.string().describe('API key secret (only shown once)'),
|
||||
apiKey: APIKeyResponseSchema,
|
||||
apiKey: ApiKeyResponseSchema,
|
||||
})
|
||||
.meta({ id: 'APIKeyCreateResponseDto' });
|
||||
.meta({ id: 'ApiKeyCreateResponseDto' });
|
||||
|
||||
export class APIKeyCreateDto extends createZodDto(APIKeyCreateSchema) {}
|
||||
export class APIKeyUpdateDto extends createZodDto(APIKeyUpdateSchema) {}
|
||||
export class APIKeyResponseDto extends createZodDto(APIKeyResponseSchema) {}
|
||||
export class APIKeyCreateResponseDto extends createZodDto(APIKeyCreateResponseSchema) {}
|
||||
export class ApiKeyCreateDto extends createZodDto(ApiKeyCreateSchema) {}
|
||||
export class ApiKeyUpdateDto extends createZodDto(ApiKeyUpdateSchema) {}
|
||||
export class ApiKeyResponseDto extends createZodDto(ApiKeyResponseSchema) {}
|
||||
export class ApiKeyCreateResponseDto extends createZodDto(ApiKeyCreateResponseSchema) {}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { BadRequestException, ForbiddenException, Injectable } from '@nestjs/common';
|
||||
import { ApiKey } from 'src/database';
|
||||
import { APIKeyCreateDto, APIKeyCreateResponseDto, APIKeyResponseDto, APIKeyUpdateDto } from 'src/dtos/api-key.dto';
|
||||
import { ApiKeyCreateDto, ApiKeyCreateResponseDto, ApiKeyResponseDto, ApiKeyUpdateDto } from 'src/dtos/api-key.dto';
|
||||
import { AuthDto } from 'src/dtos/auth.dto';
|
||||
import { Permission } from 'src/enum';
|
||||
import { BaseService } from 'src/services/base.service';
|
||||
@@ -8,7 +8,7 @@ import { isGranted } from 'src/utils/access';
|
||||
|
||||
@Injectable()
|
||||
export class ApiKeyService extends BaseService {
|
||||
async create(auth: AuthDto, dto: APIKeyCreateDto): Promise<APIKeyCreateResponseDto> {
|
||||
async create(auth: AuthDto, dto: ApiKeyCreateDto): Promise<ApiKeyCreateResponseDto> {
|
||||
const token = this.cryptoRepository.randomBytesAsText(32);
|
||||
const hashed = this.cryptoRepository.hashSha256(token);
|
||||
|
||||
@@ -26,7 +26,7 @@ export class ApiKeyService extends BaseService {
|
||||
return { secret: token, apiKey: this.map(entity) };
|
||||
}
|
||||
|
||||
async update(auth: AuthDto, id: string, dto: APIKeyUpdateDto): Promise<APIKeyResponseDto> {
|
||||
async update(auth: AuthDto, id: string, dto: ApiKeyUpdateDto): Promise<ApiKeyResponseDto> {
|
||||
const exists = await this.apiKeyRepository.getById(auth.user.id, id);
|
||||
if (!exists) {
|
||||
throw new BadRequestException('API Key not found');
|
||||
@@ -54,7 +54,7 @@ export class ApiKeyService extends BaseService {
|
||||
await this.apiKeyRepository.delete(auth.user.id, id);
|
||||
}
|
||||
|
||||
async getMine(auth: AuthDto): Promise<APIKeyResponseDto> {
|
||||
async getMine(auth: AuthDto): Promise<ApiKeyResponseDto> {
|
||||
if (!auth.apiKey) {
|
||||
throw new ForbiddenException('Not authenticated with an API Key');
|
||||
}
|
||||
@@ -67,7 +67,7 @@ export class ApiKeyService extends BaseService {
|
||||
return this.map(key);
|
||||
}
|
||||
|
||||
async getById(auth: AuthDto, id: string): Promise<APIKeyResponseDto> {
|
||||
async getById(auth: AuthDto, id: string): Promise<ApiKeyResponseDto> {
|
||||
const key = await this.apiKeyRepository.getById(auth.user.id, id);
|
||||
if (!key) {
|
||||
throw new BadRequestException('API Key not found');
|
||||
@@ -75,12 +75,12 @@ export class ApiKeyService extends BaseService {
|
||||
return this.map(key);
|
||||
}
|
||||
|
||||
async getAll(auth: AuthDto): Promise<APIKeyResponseDto[]> {
|
||||
async getAll(auth: AuthDto): Promise<ApiKeyResponseDto[]> {
|
||||
const keys = await this.apiKeyRepository.getByUserId(auth.user.id);
|
||||
return keys.map((key) => this.map(key));
|
||||
}
|
||||
|
||||
private map(entity: ApiKey): APIKeyResponseDto {
|
||||
private map(entity: ApiKey): ApiKeyResponseDto {
|
||||
return {
|
||||
id: entity.id,
|
||||
name: entity.name,
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
import DeviceList from './device-list.svelte';
|
||||
import OAuthSettings from './oauth-settings.svelte';
|
||||
import PartnerSettings from './partner-settings.svelte';
|
||||
import UserAPIKeyList from './user-api-key-list.svelte';
|
||||
import UserApiKeyList from './user-api-key-list.svelte';
|
||||
import UserProfileSettings from './user-profile-settings.svelte';
|
||||
|
||||
interface Props {
|
||||
@@ -72,7 +72,7 @@
|
||||
</SettingAccordion>
|
||||
|
||||
<SettingAccordion icon={mdiApi} key="api-keys" title={$t('api_keys')} subtitle={$t('manage_your_api_keys')}>
|
||||
<UserAPIKeyList bind:keys />
|
||||
<UserApiKeyList bind:keys />
|
||||
</SettingAccordion>
|
||||
|
||||
<SettingAccordion
|
||||
|
||||
Reference in New Issue
Block a user