blob: 2aa1332f06e5b26e8504d69483722dceaf1e68f6 [file] [log] [blame]
Arielk802bd2a2018-04-16 15:37:39 +03001'use strict';
2
Arielkeaaf8012018-07-31 12:59:36 +03003export class OperationParameter {
4 name: string;
Arielkaefe3912018-10-14 16:50:17 +03005 type: String;
Arielkeaaf8012018-07-31 12:59:36 +03006 property: string;
7 mandatory: boolean;
Arielk802bd2a2018-04-16 15:37:39 +03008
Arielkeaaf8012018-07-31 12:59:36 +03009 constructor(param?: OperationParameter) {
Arielk802bd2a2018-04-16 15:37:39 +030010 if (param) {
Arielkeaaf8012018-07-31 12:59:36 +030011 this.name = param.name;
12 this.type = param.type;
13 this.property = param.property;
14 this.mandatory = param.mandatory;
Arielk802bd2a2018-04-16 15:37:39 +030015 }
16 }
17}
18
19export interface IOperationParamsList {
Arielkeaaf8012018-07-31 12:59:36 +030020 listToscaDataDefinition: Array<OperationParameter>;
Arielk802bd2a2018-04-16 15:37:39 +030021}
22
Arielkaefe3912018-10-14 16:50:17 +030023export class WORKFLOW_ASSOCIATION_OPTIONS {
24 static NONE = 'NONE';
25 static NEW = 'NEW';
26 static EXISTING = 'EXISTING';
27}
28
Arielk802bd2a2018-04-16 15:37:39 +030029export class OperationModel {
Arielk802bd2a2018-04-16 15:37:39 +030030 operationType: string;
Arielkeaaf8012018-07-31 12:59:36 +030031 description: string;
Arielk802bd2a2018-04-16 15:37:39 +030032 uniqueId: string;
33
Arielkeaaf8012018-07-31 12:59:36 +030034 inputParams: IOperationParamsList;
35 outputParams: IOperationParamsList;
36
Arielkaefe3912018-10-14 16:50:17 +030037 workflowAssociationType: string;
Arielkeaaf8012018-07-31 12:59:36 +030038 workflowId: string;
39 workflowVersionId: string;
40
Arielk802bd2a2018-04-16 15:37:39 +030041 constructor(operation?: any) {
42 if (operation) {
Arielk802bd2a2018-04-16 15:37:39 +030043 this.operationType = operation.operationType;
Arielkaefe3912018-10-14 16:50:17 +030044 this.description = operation.description;
Arielk802bd2a2018-04-16 15:37:39 +030045 this.uniqueId = operation.uniqueId;
Arielkaefe3912018-10-14 16:50:17 +030046
47 this.inputParams = operation.inputParams;
48 this.outputParams = operation.outputParams;
49
50 this.workflowAssociationType = operation.workflowAssociationType;
Arielkeaaf8012018-07-31 12:59:36 +030051 this.workflowId = operation.workflowId;
52 this.workflowVersionId = operation.workflowVersionId;
Arielk802bd2a2018-04-16 15:37:39 +030053 }
54 }
55
Arielkeaaf8012018-07-31 12:59:36 +030056 public createInputParamsList(inputParams: Array<OperationParameter>): void {
Arielk802bd2a2018-04-16 15:37:39 +030057 this.inputParams = {
58 listToscaDataDefinition: inputParams
59 };
60 }
61
Arielkeaaf8012018-07-31 12:59:36 +030062 public createOutputParamsList(outputParams: Array<OperationParameter>): void {
Arielk802bd2a2018-04-16 15:37:39 +030063 this.outputParams = {
Arielk502b7b72018-10-03 14:06:13 +030064 listToscaDataDefinition: _.map(outputParams, output => {
65 const newOutput = {...output};
66 delete newOutput.property;
67 return newOutput;
68 })
Arielk802bd2a2018-04-16 15:37:39 +030069 };
70 }
71}
72
73export interface CreateOperationResponse extends OperationModel {
74 artifactUUID: string;
75}