1 import * as moment from 'moment';
2 import * as _ from 'lodash';
4 export class InstantiationTemplatesRowModel {
5 readonly jobId: string;
6 readonly userId ?: string;
7 readonly createDate ?: string;
8 readonly instanceName ?: string;
9 readonly instantiationStatus?: string;
10 readonly summary?: string;
11 readonly region?: string;
12 readonly tenant?: string;
13 readonly aicZone?: string;
16 this.jobId = data.jobId;
17 this.userId = !_.isNil(data.created) ? data.userId : null;
18 this.createDate = !_.isNil(data.created) ? moment(data.created).format("YYYY-MM-DD HH:mm:ss") : null;
19 this.instanceName = this.getInstanceName(data.serviceInstanceName);
20 this.instantiationStatus = !_.isNil(data.jobStatus) ? data.jobStatus : null;
22 this.region = this.getRegion(data.regionId, data.owningEntityName);
23 this.tenant = !_.isNil(data.tenantName) ? data.tenantName : null;
24 this.aicZone = !_.isNil(data.aicZoneName) ? data.aicZoneName : null;
29 /**************************************************************************************************
30 return the LCP region and in brackets the cloud owner removing the “att-“ with capital letters.
31 **************************************************************************************************/
32 getCloudOwner = (owningEntityName: string): string => {
33 const splitByAtt: string[] = owningEntityName.split('att-');
34 let owning: string = splitByAtt[splitByAtt.length - 1];
35 return owning.toUpperCase();
38 getRegion = (regionId: string, owningEntityName: string): string => {
39 const convertOwning = !_.isNil(owningEntityName) ? `(${this.getCloudOwner(owningEntityName)})` : '';
40 return `${regionId} ${convertOwning}`.trim();
44 getInstanceName = (instanceName?: string): string => {
45 if (_.isNil(instanceName)) {
46 return '<Automatically generated>';