Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 1 | import {VfcInstanceGroupMap} from "./vfcInstanceGroupMap"; |
| 2 | |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 3 | export interface NodeModelResponseInterface { |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 4 | customizationUuid: string; |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 5 | name: string; |
| 6 | version: string; |
| 7 | description: string; |
| 8 | category: string; |
| 9 | uuid: string; |
| 10 | invariantUuid: string; |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 11 | max: number; |
| 12 | min:number; |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 13 | } |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 14 | export interface Level1ModelResponseInterface extends NodeModelResponseInterface{ |
| 15 | serviceType: string; |
| 16 | serviceRole: string; |
| 17 | subCategory: string; |
| 18 | customizationUuid: string; |
| 19 | serviceEcompNaming: boolean; |
| 20 | type: string; |
| 21 | modelCustomizationName: string; |
| 22 | vfcInstanceGroups: VfcInstanceGroupMap; |
| 23 | properties: Level1ModelProperties; |
| 24 | } |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 25 | export class NodeModel { |
| 26 | name: string; |
| 27 | version: string; |
| 28 | description: string; |
| 29 | category: string; |
| 30 | uuid: string; |
| 31 | invariantUuid: string; |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 32 | max: number; |
| 33 | min: number; |
| 34 | customizationUuid?: string; |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 35 | |
| 36 | constructor(serviceJson?: NodeModelResponseInterface) { |
| 37 | if (serviceJson) { |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 38 | this.customizationUuid = serviceJson.customizationUuid; |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 39 | this.name = serviceJson.name; |
| 40 | this.version = serviceJson.version; |
| 41 | this.description = serviceJson.description; |
| 42 | this.category = serviceJson.category; |
| 43 | this.uuid = serviceJson.uuid; |
| 44 | this.invariantUuid = serviceJson.invariantUuid; |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 45 | this.max = serviceJson.max; |
| 46 | this.min = serviceJson.min; |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 47 | } |
| 48 | } |
| 49 | |
| 50 | } |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 51 | export class Level1ModelProperties { |
| 52 | max_instances : number; |
| 53 | min_instances : number; |
| 54 | } |
| 55 | |
| 56 | |
| 57 | |
| 58 | export class Level1Model extends NodeModel{ |
| 59 | serviceType: string; |
| 60 | serviceRole: string; |
| 61 | subCategory: string; |
| 62 | customizationUuid: string; |
| 63 | serviceEcompNaming: boolean; |
| 64 | type: string; |
| 65 | modelCustomizationName: string; |
| 66 | vfcInstanceGroups: VfcInstanceGroupMap; |
| 67 | isEcompGeneratedNaming: boolean; |
| 68 | constructor(nodeJson?: Level1ModelResponseInterface) { |
| 69 | super(nodeJson); |
| 70 | if (nodeJson) { |
| 71 | this.serviceType = nodeJson.serviceType; |
| 72 | this.serviceRole = nodeJson.serviceRole; |
| 73 | this.subCategory = nodeJson.subCategory; |
| 74 | this.customizationUuid = nodeJson.customizationUuid; |
| 75 | this.isEcompGeneratedNaming = this.getIsEcompGeneratedNaming(nodeJson); |
| 76 | this.type = nodeJson.type; |
| 77 | this.modelCustomizationName = nodeJson.modelCustomizationName; |
| 78 | this.vfcInstanceGroups = nodeJson.vfcInstanceGroups; |
| 79 | this.max = 1; |
| 80 | this.min = 0; |
| 81 | if (nodeJson.properties) { |
| 82 | this.min = nodeJson.properties.min_instances || 0; |
| 83 | this.max = nodeJson.properties.max_instances || 1; |
| 84 | } |
| 85 | |
| 86 | |
| 87 | } |
| 88 | } |
| 89 | private getIsEcompGeneratedNaming(vnfJson) { |
Ittay Stern | f792671 | 2019-07-07 19:23:03 +0300 | [diff] [blame] | 90 | let ecompGeneratedNaming; |
| 91 | if (vnfJson.properties) { |
| 92 | ecompGeneratedNaming = vnfJson.properties.ecomp_generated_naming; |
| 93 | } |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 94 | return ecompGeneratedNaming === "true"; |
| 95 | }; |
| 96 | } |