Enhance operations to associate workflows
[sdc.git] / catalog-ui / src / app / models / operation.ts
1 'use strict';
2
3 export class OperationParameter {
4     name: string;
5     type: string;
6     property: string;
7     mandatory: boolean;
8
9     constructor(param?: OperationParameter) {
10         if (param) {
11             this.name = param.name;
12             this.type = param.type;
13             this.property = param.property;
14             this.mandatory = param.mandatory;
15         }
16     }
17 }
18
19 export interface IOperationParamsList {
20     listToscaDataDefinition: Array<OperationParameter>;
21 }
22
23 export class OperationModel {
24     operationType: string;
25     description: string;
26     uniqueId: string;
27
28     inputParams: IOperationParamsList;
29     outputParams: IOperationParamsList;
30
31     workflowId: string;
32     workflowVersionId: string;
33
34     protected OperationTypeEnum: Array<String> = [
35         'Create',
36         'Delete',
37         'Instantiate',
38         'Start',
39         'Stop'
40     ];
41
42     constructor(operation?: any) {
43         if (operation) {
44             this.description = operation.description;
45             this.inputParams = operation.inputParams;
46             this.operationType = operation.operationType;
47             this.outputParams = operation.outputParams;
48             this.uniqueId = operation.uniqueId;
49             this.workflowId = operation.workflowId;
50             this.workflowVersionId = operation.workflowVersionId;
51         }
52     }
53
54     public createInputParamsList(inputParams: Array<OperationParameter>): void {
55         this.inputParams = {
56             listToscaDataDefinition: inputParams
57         };
58     }
59
60     public createOutputParamsList(outputParams: Array<OperationParameter>): void {
61         this.outputParams = {
62             listToscaDataDefinition: outputParams
63         };
64     }
65 }
66
67 export interface CreateOperationResponse extends OperationModel {
68     artifactUUID: string;
69 }