-
Notifications
You must be signed in to change notification settings - Fork 9
PM-2213 - fetch workflowRun attachments #121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import { | |
ValidationPipe, | ||
Query, | ||
Param, | ||
StreamableFile, | ||
} from '@nestjs/common'; | ||
import { | ||
ApiBearerAuth, | ||
|
@@ -207,6 +208,81 @@ export class AiWorkflowController { | |
return this.aiWorkflowService.updateWorkflowRun(workflowId, runId, body); | ||
} | ||
|
||
@Get('/:workflowId/runs/:runId/attachments') | ||
@Roles( | ||
UserRole.Admin, | ||
UserRole.Copilot, | ||
UserRole.ProjectManager, | ||
UserRole.Reviewer, | ||
UserRole.Submitter, | ||
UserRole.User, | ||
) | ||
@Scopes(Scope.ReadWorkflowRun) | ||
@ApiOperation({ | ||
summary: 'List all attachments linked to the specific run', | ||
}) | ||
@ApiParam({ | ||
name: 'runId', | ||
description: 'The ID of the run to fetch the attachments for', | ||
required: true, | ||
}) | ||
@ApiResponse({ | ||
status: 200, | ||
description: 'The AI workflow run attachments.', | ||
}) | ||
@ApiResponse({ status: 403, description: 'Forbidden.' }) | ||
async getRunAttachments( | ||
@Param('workflowId') workflowId: string, | ||
@Param('runId') runId: string, | ||
@User() user: JwtUser, | ||
) { | ||
return await this.aiWorkflowService.getWorkflowRunAttachments( | ||
workflowId, | ||
runId, | ||
user, | ||
); | ||
} | ||
|
||
@Get('/:workflowId/runs/:runId/attachments/:attachmentId/zip') | ||
@Roles( | ||
UserRole.Admin, | ||
UserRole.Copilot, | ||
UserRole.ProjectManager, | ||
UserRole.Reviewer, | ||
UserRole.Submitter, | ||
UserRole.User, | ||
) | ||
@Scopes(Scope.ReadWorkflowRun) | ||
@ApiOperation({ | ||
summary: 'Download an attachment archive linked to the specific run', | ||
vas3a marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}) | ||
@ApiParam({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again we need to add workflowId and runId to docs call signature. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kkartunov in the new swagger version, these annotations are used only to add description. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
name: 'attachmentId', | ||
description: 'The ID of the workflow run attachment to download', | ||
required: true, | ||
}) | ||
@ApiResponse({ | ||
status: 302, | ||
description: 'Redirect to the blob to download', | ||
}) | ||
@ApiResponse({ status: 403, description: 'Forbidden.' }) | ||
async downloadRunAttachment( | ||
@Param('workflowId') workflowId: string, | ||
@Param('runId') runId: string, | ||
@Param('attachmentId') attachmentId: string, | ||
@User() user: JwtUser, | ||
) { | ||
const zipResponse = | ||
await this.aiWorkflowService.downloadWorkflowRunAttachment( | ||
workflowId, | ||
runId, | ||
attachmentId, | ||
user, | ||
); | ||
|
||
return new StreamableFile(zipResponse.data); | ||
} | ||
|
||
@Post('/:workflowId/runs/:runId/items') | ||
@Scopes(Scope.CreateWorkflowRun) | ||
@ApiOperation({ summary: 'Create AIWorkflowRunItems in batch' }) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shall have a
@ApiParam
forworkflowId
right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As bellow, the params are automatically added by swagger when you use

@Param('workflowId') workflowId: string,
in the method signature. I used @ApiParam to enhance the description in here.