mirror of
https://github.com/immich-app/immich.git
synced 2026-01-13 05:26:35 -08:00
feat: endpoint versioning (#23858)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Post, Put, Query } from '@nestjs/common';
|
||||
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { Endpoint, HistoryBuilder } from 'src/decorators';
|
||||
import { BulkIdResponseDto, BulkIdsDto } from 'src/dtos/asset-ids.response.dto';
|
||||
import { AuthDto } from 'src/dtos/auth.dto';
|
||||
import {
|
||||
@@ -21,10 +22,11 @@ export class MemoryController {
|
||||
|
||||
@Get()
|
||||
@Authenticated({ permission: Permission.MemoryRead })
|
||||
@ApiOperation({
|
||||
@Endpoint({
|
||||
summary: 'Retrieve memories',
|
||||
description:
|
||||
'Retrieve a list of memories. Memories are sorted descending by creation date by default, although they can also be sorted in ascending order, or randomly.',
|
||||
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
||||
})
|
||||
searchMemories(@Auth() auth: AuthDto, @Query() dto: MemorySearchDto): Promise<MemoryResponseDto[]> {
|
||||
return this.service.search(auth, dto);
|
||||
@@ -32,10 +34,11 @@ export class MemoryController {
|
||||
|
||||
@Post()
|
||||
@Authenticated({ permission: Permission.MemoryCreate })
|
||||
@ApiOperation({
|
||||
@Endpoint({
|
||||
summary: 'Create a memory',
|
||||
description:
|
||||
'Create a new memory by providing a name, description, and a list of asset IDs to include in the memory.',
|
||||
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
||||
})
|
||||
createMemory(@Auth() auth: AuthDto, @Body() dto: MemoryCreateDto): Promise<MemoryResponseDto> {
|
||||
return this.service.create(auth, dto);
|
||||
@@ -43,9 +46,10 @@ export class MemoryController {
|
||||
|
||||
@Get('statistics')
|
||||
@Authenticated({ permission: Permission.MemoryStatistics })
|
||||
@ApiOperation({
|
||||
@Endpoint({
|
||||
summary: 'Retrieve memories statistics',
|
||||
description: 'Retrieve statistics about memories, such as total count and other relevant metrics.',
|
||||
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
||||
})
|
||||
memoriesStatistics(@Auth() auth: AuthDto, @Query() dto: MemorySearchDto): Promise<MemoryStatisticsResponseDto> {
|
||||
return this.service.statistics(auth, dto);
|
||||
@@ -53,9 +57,10 @@ export class MemoryController {
|
||||
|
||||
@Get(':id')
|
||||
@Authenticated({ permission: Permission.MemoryRead })
|
||||
@ApiOperation({
|
||||
@Endpoint({
|
||||
summary: 'Retrieve a memory',
|
||||
description: 'Retrieve a specific memory by its ID.',
|
||||
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
||||
})
|
||||
getMemory(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<MemoryResponseDto> {
|
||||
return this.service.get(auth, id);
|
||||
@@ -63,9 +68,10 @@ export class MemoryController {
|
||||
|
||||
@Put(':id')
|
||||
@Authenticated({ permission: Permission.MemoryUpdate })
|
||||
@ApiOperation({
|
||||
@Endpoint({
|
||||
summary: 'Update a memory',
|
||||
description: 'Update an existing memory by its ID.',
|
||||
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
||||
})
|
||||
updateMemory(
|
||||
@Auth() auth: AuthDto,
|
||||
@@ -78,9 +84,10 @@ export class MemoryController {
|
||||
@Delete(':id')
|
||||
@Authenticated({ permission: Permission.MemoryDelete })
|
||||
@HttpCode(HttpStatus.NO_CONTENT)
|
||||
@ApiOperation({
|
||||
@Endpoint({
|
||||
summary: 'Delete a memory',
|
||||
description: 'Delete a specific memory by its ID.',
|
||||
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
||||
})
|
||||
deleteMemory(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<void> {
|
||||
return this.service.remove(auth, id);
|
||||
@@ -88,9 +95,10 @@ export class MemoryController {
|
||||
|
||||
@Put(':id/assets')
|
||||
@Authenticated({ permission: Permission.MemoryAssetCreate })
|
||||
@ApiOperation({
|
||||
@Endpoint({
|
||||
summary: 'Add assets to a memory',
|
||||
description: 'Add a list of asset IDs to a specific memory.',
|
||||
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
||||
})
|
||||
addMemoryAssets(
|
||||
@Auth() auth: AuthDto,
|
||||
@@ -103,9 +111,10 @@ export class MemoryController {
|
||||
@Delete(':id/assets')
|
||||
@Authenticated({ permission: Permission.MemoryAssetDelete })
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@ApiOperation({
|
||||
@Endpoint({
|
||||
summary: 'Remove assets from a memory',
|
||||
description: 'Remove a list of asset IDs from a specific memory.',
|
||||
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
||||
})
|
||||
removeMemoryAssets(
|
||||
@Auth() auth: AuthDto,
|
||||
|
||||
Reference in New Issue
Block a user