blob: f15f0b13b54beb7518be55b392b5c5da0035075d [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;
5 type: string;
6 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
23export class OperationModel {
Arielk802bd2a2018-04-16 15:37:39 +030024 operationType: string;
Arielkeaaf8012018-07-31 12:59:36 +030025 description: string;
Arielk802bd2a2018-04-16 15:37:39 +030026 uniqueId: string;
27
Arielkeaaf8012018-07-31 12:59:36 +030028 inputParams: IOperationParamsList;
29 outputParams: IOperationParamsList;
30
31 workflowId: string;
32 workflowVersionId: string;
33
Arielk802bd2a2018-04-16 15:37:39 +030034 constructor(operation?: any) {
35 if (operation) {
36 this.description = operation.description;
37 this.inputParams = operation.inputParams;
38 this.operationType = operation.operationType;
39 this.outputParams = operation.outputParams;
40 this.uniqueId = operation.uniqueId;
Arielkeaaf8012018-07-31 12:59:36 +030041 this.workflowId = operation.workflowId;
42 this.workflowVersionId = operation.workflowVersionId;
Arielk802bd2a2018-04-16 15:37:39 +030043 }
44 }
45
Arielkeaaf8012018-07-31 12:59:36 +030046 public createInputParamsList(inputParams: Array<OperationParameter>): void {
Arielk802bd2a2018-04-16 15:37:39 +030047 this.inputParams = {
48 listToscaDataDefinition: inputParams
49 };
50 }
51
Arielkeaaf8012018-07-31 12:59:36 +030052 public createOutputParamsList(outputParams: Array<OperationParameter>): void {
Arielk802bd2a2018-04-16 15:37:39 +030053 this.outputParams = {
Arielk502b7b72018-10-03 14:06:13 +030054 listToscaDataDefinition: _.map(outputParams, output => {
55 const newOutput = {...output};
56 delete newOutput.property;
57 return newOutput;
58 })
Arielk802bd2a2018-04-16 15:37:39 +030059 };
60 }
61}
62
63export interface CreateOperationResponse extends OperationModel {
64 artifactUUID: string;
65}