Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 1 | 'use strict'; |
| 2 | |
Arielk | eaaf801 | 2018-07-31 12:59:36 +0300 | [diff] [blame] | 3 | export class OperationParameter { |
| 4 | name: string; |
| 5 | type: string; |
| 6 | property: string; |
| 7 | mandatory: boolean; |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 8 | |
Arielk | eaaf801 | 2018-07-31 12:59:36 +0300 | [diff] [blame] | 9 | constructor(param?: OperationParameter) { |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 10 | if (param) { |
Arielk | eaaf801 | 2018-07-31 12:59:36 +0300 | [diff] [blame] | 11 | this.name = param.name; |
| 12 | this.type = param.type; |
| 13 | this.property = param.property; |
| 14 | this.mandatory = param.mandatory; |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 15 | } |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | export interface IOperationParamsList { |
Arielk | eaaf801 | 2018-07-31 12:59:36 +0300 | [diff] [blame] | 20 | listToscaDataDefinition: Array<OperationParameter>; |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | export class OperationModel { |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 24 | operationType: string; |
Arielk | eaaf801 | 2018-07-31 12:59:36 +0300 | [diff] [blame] | 25 | description: string; |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 26 | uniqueId: string; |
| 27 | |
Arielk | eaaf801 | 2018-07-31 12:59:36 +0300 | [diff] [blame] | 28 | inputParams: IOperationParamsList; |
| 29 | outputParams: IOperationParamsList; |
| 30 | |
| 31 | workflowId: string; |
| 32 | workflowVersionId: string; |
| 33 | |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 34 | 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; |
Arielk | eaaf801 | 2018-07-31 12:59:36 +0300 | [diff] [blame] | 41 | this.workflowId = operation.workflowId; |
| 42 | this.workflowVersionId = operation.workflowVersionId; |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 43 | } |
| 44 | } |
| 45 | |
Arielk | eaaf801 | 2018-07-31 12:59:36 +0300 | [diff] [blame] | 46 | public createInputParamsList(inputParams: Array<OperationParameter>): void { |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 47 | this.inputParams = { |
| 48 | listToscaDataDefinition: inputParams |
| 49 | }; |
| 50 | } |
| 51 | |
Arielk | eaaf801 | 2018-07-31 12:59:36 +0300 | [diff] [blame] | 52 | public createOutputParamsList(outputParams: Array<OperationParameter>): void { |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 53 | this.outputParams = { |
Arielk | 502b7b7 | 2018-10-03 14:06:13 +0300 | [diff] [blame^] | 54 | listToscaDataDefinition: _.map(outputParams, output => { |
| 55 | const newOutput = {...output}; |
| 56 | delete newOutput.property; |
| 57 | return newOutput; |
| 58 | }) |
Arielk | 802bd2a | 2018-04-16 15:37:39 +0300 | [diff] [blame] | 59 | }; |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | export interface CreateOperationResponse extends OperationModel { |
| 64 | artifactUUID: string; |
| 65 | } |