-
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 2 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, | ||
|
|
@@ -34,12 +35,16 @@ import { Scope } from 'src/shared/enums/scopes.enum'; | |
| import { Roles } from 'src/shared/guards/tokenRoles.guard'; | ||
| import { JwtUser } from 'src/shared/modules/global/jwt.service'; | ||
| import { User } from 'src/shared/decorators/user.decorator'; | ||
| import { SubmissionScanCompleteOrchestrator } from 'src/shared/modules/global/submission-scan-complete.orchestrator'; | ||
|
|
||
| @ApiTags('ai_workflow') | ||
| @ApiBearerAuth() | ||
| @Controller('/workflows') | ||
| export class AiWorkflowController { | ||
| constructor(private readonly aiWorkflowService: AiWorkflowService) {} | ||
| constructor( | ||
| private readonly aiWorkflowService: AiWorkflowService, | ||
| private readonly orchestrator: SubmissionScanCompleteOrchestrator, | ||
| ) {} | ||
|
|
||
| @Post() | ||
| @Roles(UserRole.Admin) | ||
|
|
@@ -207,6 +212,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({ | ||
|
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. We shall have a 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: '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' }) | ||
|
|
@@ -394,4 +474,9 @@ export class AiWorkflowController { | |
| body, | ||
| ); | ||
| } | ||
|
|
||
| @Get('/submission/:submissionId') | ||
vas3a marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| triggerOrchestration(@Param('submissionId') submissionId: string) { | ||
vas3a marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return this.orchestrator.orchestrateScanComplete(submissionId); | ||
| } | ||
| } | ||


Uh oh!
There was an error while loading. Please reload this page.