aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/models/nodeModel.ts
blob: ee57ec0384d0ac96e064bd641af10914dac41c25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import {VfcInstanceGroupMap} from "./vfcInstanceGroupMap";

export interface NodeModelResponseInterface {
  customizationUuid: string;
  name: string;
  version: string;
  description: string;
  category: string;
  uuid: string;
  invariantUuid: string;
  max: number;
  min:number;
}
export interface Level1ModelResponseInterface extends NodeModelResponseInterface{
  serviceType: string;
  serviceRole: string;
  subCategory: string;
  customizationUuid: string;
  serviceEcompNaming: boolean;
  type: string;
  modelCustomizationName: string;
  vfcInstanceGroups: VfcInstanceGroupMap;
  properties: Level1ModelProperties;
}
export class NodeModel {
  name: string;
  version: string;
  description: string;
  category: string;
  uuid: string;
  invariantUuid: string;
  max: number;
  min: number;
  customizationUuid?: string;

  constructor(serviceJson?: NodeModelResponseInterface) {
    if (serviceJson) {
      this.customizationUuid = serviceJson.customizationUuid;
      this.name = serviceJson.name;
      this.version = serviceJson.version;
      this.description = serviceJson.description;
      this.category = serviceJson.category;
      this.uuid = serviceJson.uuid;
      this.invariantUuid = serviceJson.invariantUuid;
      this.max = serviceJson.max;
      this.min = serviceJson.min;
    }
  }

}
export class Level1ModelProperties {
  max_instances : number;
  min_instances : number;
}



export class Level1Model extends NodeModel{
  serviceType: string;
  serviceRole: string;
  subCategory: string;
  customizationUuid: string;
  serviceEcompNaming: boolean;
  type: string;
  modelCustomizationName: string;
  vfcInstanceGroups: VfcInstanceGroupMap;
  isEcompGeneratedNaming: boolean;
  constructor(nodeJson?: Level1ModelResponseInterface) {
    super(nodeJson);
    if (nodeJson) {
      this.serviceType = nodeJson.serviceType;
      this.serviceRole = nodeJson.serviceRole;
      this.subCategory = nodeJson.subCategory;
      this.customizationUuid = nodeJson.customizationUuid;
      this.isEcompGeneratedNaming = this.getIsEcompGeneratedNaming(nodeJson);
      this.type = nodeJson.type;
      this.modelCustomizationName = nodeJson.modelCustomizationName;
      this.vfcInstanceGroups = nodeJson.vfcInstanceGroups;
      this.max = 1;
      this.min = 0;
      if (nodeJson.properties) {
        this.min = nodeJson.properties.min_instances || 0;
        this.max = nodeJson.properties.max_instances || 1;
      }


    }
  }
  private getIsEcompGeneratedNaming(vnfJson) {
    const ecompGeneratedNaming = vnfJson.properties.ecomp_generated_naming;
    return ecompGeneratedNaming === "true";
  };
}