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