mirror of
https://github.com/immich-app/immich.git
synced 2025-12-26 01:11:47 +03: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 { BulkIdsDto } from 'src/dtos/asset-ids.response.dto';
|
||||
import { AuthDto } from 'src/dtos/auth.dto';
|
||||
import { StackCreateDto, StackResponseDto, StackSearchDto, StackUpdateDto } from 'src/dtos/stack.dto';
|
||||
@@ -15,9 +16,10 @@ export class StackController {
|
||||
|
||||
@Get()
|
||||
@Authenticated({ permission: Permission.StackRead })
|
||||
@ApiOperation({
|
||||
@Endpoint({
|
||||
summary: 'Retrieve stacks',
|
||||
description: 'Retrieve a list of stacks.',
|
||||
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
||||
})
|
||||
searchStacks(@Auth() auth: AuthDto, @Query() query: StackSearchDto): Promise<StackResponseDto[]> {
|
||||
return this.service.search(auth, query);
|
||||
@@ -25,10 +27,11 @@ export class StackController {
|
||||
|
||||
@Post()
|
||||
@Authenticated({ permission: Permission.StackCreate })
|
||||
@ApiOperation({
|
||||
@Endpoint({
|
||||
summary: 'Create a stack',
|
||||
description:
|
||||
'Create a new stack by providing a name and a list of asset IDs to include in the stack. If any of the provided asset IDs are primary assets of an existing stack, the existing stack will be merged into the newly created stack.',
|
||||
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
||||
})
|
||||
createStack(@Auth() auth: AuthDto, @Body() dto: StackCreateDto): Promise<StackResponseDto> {
|
||||
return this.service.create(auth, dto);
|
||||
@@ -37,9 +40,10 @@ export class StackController {
|
||||
@Delete()
|
||||
@Authenticated({ permission: Permission.StackDelete })
|
||||
@HttpCode(HttpStatus.NO_CONTENT)
|
||||
@ApiOperation({
|
||||
@Endpoint({
|
||||
summary: 'Delete stacks',
|
||||
description: 'Delete multiple stacks by providing a list of stack IDs.',
|
||||
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
||||
})
|
||||
deleteStacks(@Auth() auth: AuthDto, @Body() dto: BulkIdsDto): Promise<void> {
|
||||
return this.service.deleteAll(auth, dto);
|
||||
@@ -47,9 +51,10 @@ export class StackController {
|
||||
|
||||
@Get(':id')
|
||||
@Authenticated({ permission: Permission.StackRead })
|
||||
@ApiOperation({
|
||||
@Endpoint({
|
||||
summary: 'Retrieve a stack',
|
||||
description: 'Retrieve a specific stack by its ID.',
|
||||
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
||||
})
|
||||
getStack(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<StackResponseDto> {
|
||||
return this.service.get(auth, id);
|
||||
@@ -57,9 +62,10 @@ export class StackController {
|
||||
|
||||
@Put(':id')
|
||||
@Authenticated({ permission: Permission.StackUpdate })
|
||||
@ApiOperation({
|
||||
@Endpoint({
|
||||
summary: 'Update a stack',
|
||||
description: 'Update an existing stack by its ID.',
|
||||
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
||||
})
|
||||
updateStack(
|
||||
@Auth() auth: AuthDto,
|
||||
@@ -72,9 +78,10 @@ export class StackController {
|
||||
@Delete(':id')
|
||||
@Authenticated({ permission: Permission.StackDelete })
|
||||
@HttpCode(HttpStatus.NO_CONTENT)
|
||||
@ApiOperation({
|
||||
@Endpoint({
|
||||
summary: 'Delete a stack',
|
||||
description: 'Delete a specific stack by its ID.',
|
||||
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
||||
})
|
||||
deleteStack(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<void> {
|
||||
return this.service.delete(auth, id);
|
||||
@@ -83,9 +90,10 @@ export class StackController {
|
||||
@Delete(':id/assets/:assetId')
|
||||
@Authenticated({ permission: Permission.StackUpdate })
|
||||
@HttpCode(HttpStatus.NO_CONTENT)
|
||||
@ApiOperation({
|
||||
@Endpoint({
|
||||
summary: 'Remove an asset from a stack',
|
||||
description: 'Remove a specific asset from a stack by providing the stack ID and asset ID.',
|
||||
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
||||
})
|
||||
removeAssetFromStack(@Auth() auth: AuthDto, @Param() dto: UUIDAssetIDParamDto): Promise<void> {
|
||||
return this.service.removeAsset(auth, dto);
|
||||
|
||||
Reference in New Issue
Block a user