blob: 109babb06802bcd33f71e833cd7903282b2f196e [file] [log] [blame]
aribeiro5c1f5752020-11-19 13:28:43 +00001/*
2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2021 Nordix Foundation
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * SPDX-License-Identifier: Apache-2.0
17 * ============LICENSE_END=========================================================
18 */
19
20'use strict';
21
aribeiro1de16922021-10-01 11:30:49 +010022import {ArtifactModel} from "./artifacts";
23
aribeiro5c1f5752020-11-19 13:28:43 +000024export class InputOperationParameter {
25 name: string;
26 type: string;
27 inputId: string;
28 toscaDefaultValue?: string;
29
30 constructor(param?: any) {
31 if (param) {
32 this.name = param.name;
33 this.type = param.type;
34 this.inputId = param.inputId;
35 this.toscaDefaultValue = param.toscaDefaultValue;
36 }
37 console.info("InputOperationParameter Constructor: ", param)
38 }
39}
40
aribeiro1de16922021-10-01 11:30:49 +010041export class PropertyOperationParameter {
42 name: string;
43 type: string;
44 value?: string;
45 propertyId: string;
46
47 constructor(param?: any) {
48 if (param) {
49 this.name = param.name;
50 this.type = param.type;
51 this.value = param.value;
52 this.propertyId = param.propertyId;
53 }
54 }
55}
56
aribeiro5c1f5752020-11-19 13:28:43 +000057export interface IOperationParamsList {
58 listToscaDataDefinition: Array<InputOperationParameter>;
59}
60
61export class BEInterfaceOperationModel {
62 name: string;
63 description: string;
64 uniqueId: string;
65 inputs: IOperationParamsList;
aribeiro1de16922021-10-01 11:30:49 +010066 implementation: ArtifactModel;
aribeiro5c1f5752020-11-19 13:28:43 +000067
68 constructor(operation?: any) {
69 if (operation) {
70 this.name = operation.name;
71 this.description = operation.description;
72 this.uniqueId = operation.uniqueId;
73 this.inputs = operation.inputs;
74 this.implementation = operation.implementation;
75 }
76 }
77}
78
79export class InterfaceOperationModel extends BEInterfaceOperationModel {
80 interfaceType: string;
81 interfaceId: string;
82 operationType: string;
83 description: string;
84 uniqueId: string;
aribeiro5c1f5752020-11-19 13:28:43 +000085 inputParams: IOperationParamsList;
aribeiro1de16922021-10-01 11:30:49 +010086 implementation: ArtifactModel;
aribeiro5c1f5752020-11-19 13:28:43 +000087
88 constructor(operation?: any) {
89 super(operation);
90 if (operation) {
91 this.interfaceId = operation.interfaceId;
92 this.interfaceType = operation.interfaceType;
93 this.description = operation.description;
94 this.operationType = operation.operationType;
95 this.uniqueId = operation.uniqueId;
96 this.inputParams = operation.inputParams;
aribeiro1de16922021-10-01 11:30:49 +010097 this.implementation = operation.implementation;
aribeiro5c1f5752020-11-19 13:28:43 +000098 }
99 }
100
101 public displayType(): string {
102 return displayType(this.interfaceType);
103 }
104}
105
aribeiro5c1f5752020-11-19 13:28:43 +0000106export class ComponentInstanceInterfaceModel {
107 type: string;
108 uniqueId: string;
109 operations: Array<InterfaceOperationModel>;
110
111 constructor(interfaceOperation?: any) {
112 if (interfaceOperation) {
113 this.type = interfaceOperation.type;
114 this.uniqueId = interfaceOperation.uniqueId;
115 this.operations = interfaceOperation.operations;
116 }
117 }
118
119 public displayType(): string {
120 return displayType(this.type);
121 }
122}
123
124const displayType = (type:string) => type && type.substr(type.lastIndexOf('.') + 1);