| 52 | @ApiTags('version/images') |
| 53 | @UseGuards(ImageTeamAccessGuard) |
| 54 | export default class ImageHttpController { |
| 55 | constructor(private service: ImageService) {} |
| 56 | |
| 57 | @Get() |
| 58 | @HttpCode(HttpStatus.OK) |
| 59 | @ApiOperation({ |
| 60 | description: |
| 61 | "Fetch details of images within a version. `ProjectId` refers to the project's ID, `versionId` refers to the version's ID. Both, and `teamSlug` are required in the URL.</br></br>Details come in an array, including `name`, `id`, `tag`, `order`, and config details of the image.", |
| 62 | summary: 'Fetch data of all images of a version.', |
| 63 | }) |
| 64 | @ApiOkResponse({ |
| 65 | type: ImageDetailsDto, |
| 66 | isArray: true, |
| 67 | description: 'Data of images listed.', |
| 68 | }) |
| 69 | @ApiForbiddenResponse({ description: 'Unauthorized request for images.' }) |
| 70 | @UuidParams(PARAM_PROJECT_ID, PARAM_VERSION_ID) |
| 71 | async getImagesByVersionId( |
| 72 | @TeamSlug() _: string, |
| 73 | @ProjectId() _projectId: string, |
| 74 | @VersionId() versionId: string, |
| 75 | ): Promise<ImageDetailsDto[]> { |
| 76 | return await this.service.getImagesByVersionId(versionId) |
| 77 | } |
| 78 | |
| 79 | @Get(ROUTE_IMAGE_ID) |
| 80 | @HttpCode(HttpStatus.OK) |
| 81 | @ApiOperation({ |
| 82 | description: |
| 83 | "Fetch details of an image within a version. `projectId` refers to the project's ID, `versionId` refers to the version's ID, `imageId` refers to the image's ID. All, and `teamSlug` are required in the URL.</br></br>Image details consists `name`, `id`, `tag`, `order`, and the config of the image.", |
| 84 | summary: 'Fetch data of an image of a version.', |
| 85 | }) |
| 86 | @ApiOkResponse({ type: ImageDetailsDto, description: 'Data of an image.' }) |
| 87 | @ApiBadRequestResponse({ description: 'Bad request for image details.' }) |
| 88 | @ApiForbiddenResponse({ description: 'Unauthorized request for image details.' }) |
| 89 | @ApiNotFoundResponse({ description: 'Image not found.' }) |
| 90 | @UuidParams(PARAM_PROJECT_ID, PARAM_VERSION_ID, PARAM_IMAGE_ID) |
| 91 | async getImageDetails( |
| 92 | @TeamSlug() _: string, |
| 93 | @ProjectId() _projectId: string, |
| 94 | @VersionId() _versionId: string, |
| 95 | @ImageId() imageId: string, |
| 96 | ): Promise<ImageDetailsDto> { |
| 97 | return await this.service.getImageDetails(imageId) |
| 98 | } |
| 99 | |
| 100 | @Post() |
| 101 | @HttpCode(HttpStatus.CREATED) |
| 102 | @CreatedWithLocation() |
| 103 | @ApiOperation({ |
| 104 | description: |
| 105 | "Add new images to a version. `projectId` refers to the project's ID, `versionId` refers to the version's ID. These, and `teamSlug` are required in the URL. `registryId` refers to the registry's ID, `images` refers to the name(s) of the images you'd like to add. These are required variables in the body.", |
| 106 | summary: 'Add images to a version.', |
| 107 | }) |
| 108 | @ApiBody({ type: AddImagesDto, isArray: true }) |
| 109 | @ApiCreatedResponse({ type: ImageDetailsDto, isArray: true, description: 'New image added.' }) |
| 110 | @ApiBadRequestResponse({ description: 'Bad request for images.' }) |
| 111 | @ApiForbiddenResponse({ description: 'Unauthorized request for images.' }) |
nothing calls this directly
no test coverage detected