Merge branch '19421-restore-old-redirect-key' into main. Closes #19421
[arvados.git] / src / services / workflow-service / workflow-service.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { AxiosInstance } from "axios";
6 import { CommonResourceService } from "services/common-service/common-resource-service";
7 import { WorkflowResource } from 'models/workflow';
8 import { ApiActions } from 'services/api/api-actions';
9 import { LinkService } from 'services/link-service/link-service';
10 import { FilterBuilder } from 'services/api/filter-builder';
11 import { LinkClass } from 'models/link';
12 import { OrderBuilder } from 'services/api/order-builder';
13
14 export class WorkflowService extends CommonResourceService<WorkflowResource> {
15
16     private linksService = new LinkService(this.serverApi, this.actions);
17
18     constructor(serverApi: AxiosInstance, actions: ApiActions) {
19         super(serverApi, "workflows", actions);
20     }
21
22     async presets(workflowUuid: string) {
23
24         const { items: presetLinks } = await this.linksService.list({
25             filters: new FilterBuilder()
26                 .addEqual('tail_uuid', workflowUuid)
27                 .addEqual('link_class', LinkClass.PRESET)
28                 .getFilters()
29         });
30
31         const presetUuids = presetLinks.map(link => link.headUuid);
32
33         return this.list({
34             filters: new FilterBuilder()
35                 .addIn('uuid', presetUuids)
36                 .getFilters(),
37             order: new OrderBuilder<WorkflowResource>()
38                 .addAsc('name')
39                 .getOrder(),
40         });
41
42     }
43
44 }