-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathschema.cds
424 lines (377 loc) · 27.2 KB
/
schema.cds
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
namespace db;
using types from './types';
using ManageAlertsService from '../srv/manageAlertsService';
/**
* Services, Metrics and Measures
*/
entity BTPServices {
key reportYearMonth : String @title : 'Month';
key serviceId : String @title : 'ID';
serviceName : String @title : 'Service';
key retrieved : Date @title : 'Date';
key interval : types.TInterval @title : 'Reading';
lastSynced : DateTime @cds.on.insert: $now @cds.on.update: $now;
virtual namesCommercialMetrics : String @Core.Computed;
virtual hideCommercialInfo : Boolean;
virtual hideGlobalAccountDistribution : Boolean;
virtual hideCommercialSpaceAllocation : Boolean;
virtual hideServiceInstanceDistribution : Boolean;
// Used to display History on the Object Page
history : Association to many BTPServices
on history.serviceId = serviceId;
// Composition only used to leverage delete cascade
commercialMetricsComposition : Composition of many CommercialMetrics
on commercialMetricsComposition.toService = $self;
technicalMetricsComposition : Composition of many TechnicalMetrics
on technicalMetricsComposition.toService = $self;
// Used to display list of Metrics in Object Page.
commercialMetrics : Association to many CommercialMetrics
on commercialMetrics.toService = $self
and commercialMetrics.measureId <> '_combined_';
commercialMetricsHistory : Association to many CommercialMetrics
on commercialMetricsHistory.toService.serviceId = serviceId
and commercialMetricsHistory.measureId <> '_combined_';
// Used to display list of Metrics in Object Page.
technicalMetrics : Association to many TechnicalMetrics
on technicalMetrics.toService = $self
and technicalMetrics.measureId <> '_combined_';
technicalMetricsHistory : Association to many TechnicalMetrics
on technicalMetricsHistory.toService.serviceId = serviceId
and technicalMetricsHistory.measureId <> '_combined_';
// Used in timeline chart in Object Page:
cmHistoryByMetricAll : Association to many CommercialMeasures
on cmHistoryByMetricAll.toMetric.toService.serviceId = serviceId
and cmHistoryByMetricAll.level = 'Global Account'
and cmHistoryByMetricAll.toMetric.measureId <> '_combined_';
cmHistoryByMetricDaily : Association to many CommercialMeasures
on cmHistoryByMetricDaily.toMetric.toService.serviceId = serviceId
and cmHistoryByMetricDaily.toMetric.toService.interval = 'Daily'
and cmHistoryByMetricDaily.level = 'Global Account'
and cmHistoryByMetricDaily.toMetric.measureId <> '_combined_';
cmHistoryByMetricMonthly : Association to many CommercialMeasures
on cmHistoryByMetricMonthly.toMetric.toService.serviceId = serviceId
and cmHistoryByMetricMonthly.toMetric.toService.interval = 'Monthly'
and cmHistoryByMetricMonthly.level = 'Global Account'
and cmHistoryByMetricMonthly.toMetric.measureId <> '_combined_';
// Used to display the breakdowns per level on the Object Page:
cmByMetricByLevel : Association to many CommercialMeasures
on cmByMetricByLevel.toMetric.toService.reportYearMonth = reportYearMonth
and cmByMetricByLevel.toMetric.toService.retrieved = retrieved
and cmByMetricByLevel.toMetric.toService.interval = interval
and cmByMetricByLevel.toMetric.toService.serviceId = serviceId
and cmByMetricByLevel.toMetric.measureId <> '_combined_';
tmByMetricByLevel : Association to many TechnicalMeasures
on tmByMetricByLevel.toMetric.toService.reportYearMonth = reportYearMonth
and tmByMetricByLevel.toMetric.toService.retrieved = retrieved
and tmByMetricByLevel.toMetric.toService.interval = interval
and tmByMetricByLevel.toMetric.toService.serviceId = serviceId
and tmByMetricByLevel.toMetric.measureId <> '_combined_';
// Used to display measures on the List View, and account name and measures and graphs on the Object Page:
cmByLevel : Association to many CommercialMeasures
on cmByLevel.toMetric.toService.reportYearMonth = reportYearMonth
and cmByLevel.toMetric.toService.retrieved = retrieved
and cmByLevel.toMetric.toService.interval = interval
and cmByLevel.toMetric.toService.serviceId = serviceId
and cmByLevel.toMetric.measureId = '_combined_';
tmByLevel : Association to many TechnicalMeasures
on tmByLevel.toMetric.toService.reportYearMonth = reportYearMonth
and tmByLevel.toMetric.toService.retrieved = retrieved
and tmByLevel.toMetric.toService.interval = interval
and tmByLevel.toMetric.toService.serviceId = serviceId
and tmByLevel.toMetric.measureId = '_combined_';
}
entity CommercialMetrics {
key toService : Association to BTPServices;
key measureId : String @title: 'ID'; // equals to '_combined_' in case multiple metrics are summed up
metricName : String @title: 'Metric';
tags : many types.TTag @title: 'Platform Tags';
virtual tagStrings : String @title: 'Platform Tags';
virtual hideGlobalAccountDistribution : Boolean;
virtual hideCommercialSpaceAllocation : Boolean;
virtual hideServiceInstanceDistribution : Boolean;
forecastSetting : Association to one ForecastSettings
on forecastSetting.serviceId = toService.serviceId
and forecastSetting.measureId = measureId;
// Used to map commercial metrics to a technical metric for downstream allocation to Space level
technicalMetricForAllocation : Association to one AllocationSettings
on technicalMetricForAllocation.serviceId = toService.serviceId
and technicalMetricForAllocation.cMeasureId = measureId;
// Used to display measures on the Service Object Page and Metric Object Page
commercialMeasures : Composition of many CommercialMeasures
on commercialMeasures.toMetric = $self;
// Used to display History on the Object Page
history : Association to many CommercialMetrics
on history.toService.serviceId = toService.serviceId
and history.measureId = measureId;
}
entity TechnicalMetrics {
key toService : Association to BTPServices;
key measureId : String @title: 'ID'; // equals to '_combined_' in case multiple metrics are summed up
metricName : String @title: 'Metric';
tags : many types.TTag @title: 'Platform Tags';
virtual tagStrings : String @title: 'Platform Tags';
virtual hideGlobalAccountDistribution : Boolean;
virtual hideServiceInstanceDistribution : Boolean;
// Used to display measures on the Service Object Page and Metric Object Page
technicalMeasures : Composition of many TechnicalMeasures
on technicalMeasures.toMetric = $self;
// Used to display History on the Object Page
history : Association to many TechnicalMetrics
on history.toService.serviceId = toService.serviceId
and history.measureId = measureId;
}
entity CommercialMeasures {
key toMetric : Association to CommercialMetrics;
key level : types.TAggregationLevel @title: 'Level';
key id : String;
name : String @title: 'Name';
currency : String @title: 'Currency';
unit : String @title: 'Unit';
plans : String @title: 'Plans';
measure : {
cost : Decimal(20, 2) @title: 'Cost' @Measures.ISOCurrency: currency;
usage : Decimal(20, 2) @title: 'Usage';
actualUsage : Decimal(20, 2) @title: 'Actual Usage';
chargedBlocks : Decimal(20, 2) @title: 'Charged Blocks';
paygCost : Decimal(20, 2) @title: 'Overcharged' @Measures.ISOCurrency: currency;
cloudCreditsCost : Decimal(20, 2) @title: 'Consumed Credits' @Measures.ISOCurrency: currency;
};
forecast : {
cost : Decimal(20, 2) @title: 'Forecasted Cost' @Measures.ISOCurrency: currency;
usage : Decimal(20, 2) @title: 'Forecasted Usage';
actualUsage : Decimal(20, 2) @title: 'Forecasted Actual Usage';
chargedBlocks : Decimal(20, 2) @title: 'Forecasted Charged Blocks';
};
delta : {
measure : {
cost : Decimal(20, 2) @title: 'Delta Cost' @Measures.ISOCurrency: currency;
usage : Decimal(20, 2) @title: 'Delta Usage';
actualUsage : Decimal(20, 2) @title: 'Delta Actual Usage';
chargedBlocks : Decimal(20, 2) @title: 'Delta Charged Blocks';
costPct : Integer @title: 'Delta Cost %' @Measures.Unit : '%';
usagePct : Integer @title: 'Delta Usage %' @Measures.Unit : '%';
actualUsagePct : Integer @title: 'Delta Actual Usage %' @Measures.Unit : '%';
chargedBlocksPct : Integer @title: 'Delta Charged Blocks %' @Measures.Unit : '%';
};
forecast : {
cost : Decimal(20, 2) @title: 'Delta Forecasted Cost' @Measures.ISOCurrency: currency;
usage : Decimal(20, 2) @title: 'Delta Forecasted Usage';
actualUsage : Decimal(20, 2) @title: 'Delta Forecasted Actual Usage';
chargedBlocks : Decimal(20, 2) @title: 'Delta Forecasted Charged Blocks';
costPct : Integer @title: 'Delta Forecasted Cost %' @Measures.Unit : '%';
usagePct : Integer @title: 'Delta Forecasted Usage %' @Measures.Unit : '%';
actualUsagePct : Integer @title: 'Delta Forecasted Actual Usage %' @Measures.Unit : '%';
chargedBlocksPct : Integer @title: 'Delta Forecasted Charged Blocks %' @Measures.Unit : '%';
};
};
max_cost : Decimal(20, 2) default null @title: 'Previous Max Cost' @Measures.ISOCurrency: currency;
forecastPct : Integer @title: 'Forecasted' @Measures.Unit : '%';
virtual forecastPctCriticality : Integer;
virtual deltaActualsCriticality : Integer;
virtual deltaForecastCriticality : Integer;
virtual costChart : types.TBulletChart;
accountStructureItem : Association to one AccountStructureItems
on accountStructureItem.ID = id;
// Used as quick link for the forecast calculation
forecastSetting : Association to one ForecastSettings
on forecastSetting.serviceId = toMetric.toService.serviceId
and forecastSetting.measureId = toMetric.measureId;
}
entity TechnicalMeasures {
key toMetric : Association to TechnicalMetrics;
key level : types.TAggregationLevel @title: 'Level';
key id : String;
name : String @title: 'Name';
unit : String @title: 'Unit';
plans : String @title: 'Plans';
measure : {
usage : Decimal(20, 2) @title: 'Usage';
};
delta : {
measure : {
usage : Decimal(20, 2) @title: 'Delta Usage';
usagePct : Integer @title: 'Delta Usage %' @Measures.Unit: '%';
};
};
virtual deltaActualsCriticality : Integer;
accountStructureItem : Association to one AccountStructureItems
on accountStructureItem.ID = id;
}
entity ForecastSettings {
key serviceId : String @title: 'Service';
key measureId : String @title: 'Metric';
method : types.TForecastMethod @title: 'Method';
/**
* Zero or positive number indicating the rate of continued usage:
* - 0: Same as 'excluded'
* - < 1: the usage of the remaining days will be lower than the usage of the past days (degressive)
* - = 1: the usage of the remaining days will be similar to the usage of the past days (linear)
* - \> 1: the usage of the remaining days will be higher than the usage of the past days (progressive)
*/
degressionFactor : Double @title: 'Degression Factor';
@title: 'Forecast Relevance'
statusText : String = (method = 'Excluded' ? 'Not Forecasted' : (method = 'TimeDegressive' ? method || ' [' || degressionFactor || ']' : method))
}
// Contract entity to maintain mapping between commercial metric and technical metric for downstream cost allocation
entity AllocationSettings {
key serviceId : String;
key cMeasureId : String;
mode : String; // placeholder for future extensions
tServiceId : String; // placeholder for future extensions
tMeasureId : String;
metricName : String;
}
/**
* Alerts
*/
entity Alerts {
key ID : UUID @UI.Hidden @Core.Computed;
active : Boolean default true @title : 'Enabled';
virtual activeCriticality : Integer;
name : String @title : 'Name';
alertType : types.TAlertType @title : 'Measurement Type';
levelScope : types.TAggregationLevel @title : 'Filter Hierarchy';
levelMode : types.TInExclude @title : 'Filter Mode';
levelItems : Composition of many AlertLevelItems
on levelItems.toAlert = $self;
serviceScope : types.TServiceScopes @title : 'Level of detail';
serviceMode : types.TInExclude @title : 'Filter Mode';
serviceItems : Composition of many AlertServiceItems
on serviceItems.toAlert = $self;
thresholds : Composition of many AlertThresholds
on thresholds.toAlert = $self @title : 'Thresholds';
modifiedAt : Timestamp @cds.on.insert: $now @cds.on.update: $now @title: 'Changed On';
modifiedBy : String(255) @cds.on.insert: $user @cds.on.update: $user @title: 'Changed By';
virtual simulation : types.TAlertSimulation;
}
entity AlertLevelItems {
key toAlert : Association to Alerts;
key itemID : String @Common.Text: toItem.name @Common.TextArrangement: #TextOnly;
toItem : Association to one ManageAlertsService.LevelNames
on toItem.id = itemID;
}
entity AlertServiceItems {
key toAlert : Association to Alerts;
key itemID : String @Common.Text: toItem.name @Common.TextArrangement: #TextOnly;
toItem : Association to one ManageAlertsService.ServiceAndMetricNames
on toItem.id = itemID;
}
entity AlertThresholds {
key ID : UUID @UI.Hidden @Core.Computed;
key toAlert : Association to Alerts @UI.Hidden;
property : String @title: 'Property';
amount : Decimal(20, 2) @title: 'Amount';
operator : String(2) default '>=' @title: 'Operator';
virtual text : String;
}
/**
* Account structure and Tags
*/
entity AccountStructureItems {
key ID : String @title: 'ID';
parentID : String @title: 'Parent ID';
toParent : Association to one AccountStructureItems
on toParent.ID = parentID;
treeLevel : Integer @UI.Hidden;
treeState : String default 'expanded' @UI.Hidden;
region : String @title: 'Region';
environment : String @title: 'Env';
name : String @title: 'Name';
level : types.TAccountStructureLevels @title: 'Type';
excluded : Boolean default false @title: 'Exclude';
lifecycle : String default 'Unset' @title: 'Lifecycle';
virtual tagTextManaged0 : String @title: 'Lines of Business';
virtual tagTextManaged1 : String @title: 'Cost Centers';
virtual tagTextManaged2 : String @title: 'placeholder 2';
virtual tagTextManaged3 : String @title: 'placeholder 3';
virtual tagTextManaged4 : String @title: 'placeholder 4';
virtual tagTextManaged5 : String @title: 'placeholder 5';
virtual tagTextManaged6 : String @title: 'placeholder 6';
virtual tagTextManaged7 : String @title: 'placeholder 7';
virtual tagTextManaged8 : String @title: 'placeholder 8';
virtual tagTextManaged9 : String @title: 'placeholder 9';
virtual tagTextCustomTags : String @title: 'Custom Tags';
managedTagAllocations : Composition of many ManagedTagAllocations
on managedTagAllocations.toAccountStructureItem = $self;
customTags : Composition of many CustomTags
on customTags.toAccountStructureItem = $self;
label : String = level || ': ' || name @title: 'Hierarchy';
icon : String = (level = 'Customer' ? 'sap-icon://account' : (level = 'Global Account' ? 'sap-icon://world' : (level = 'Directory' ? 'sap-icon://folder-blank' : (level = 'Datacenter' ? 'sap-icon://building' : (level = 'Sub Account' ? 'sap-icon://product' : (level = 'Space' ? 'sap-icon://cloud' : (level = 'Environment' ? 'sap-icon://it-host' : (level = 'Service' ? 'sap-icon://action-settings' : (level = 'Service (alloc.)' ? 'sap-icon://settings' : (level = 'Instance' ? 'sap-icon://tri-state' : ('sap-icon://question-mark'))))))))))) stored;
}
entity ManagedTagAllocations {
key ID : UUID @Core.Computed @title: 'Tag ID';
toAccountStructureItem : Association to AccountStructureItems;
name : String @title : 'Name';
value : String @title : 'Value';
pct : Integer default 100 not null @Measures.Unit: '%' @title: 'Pct.' @assert.range: [
0,
100
];
}
entity CustomTags {
key ID : UUID @Core.Computed;
toAccountStructureItem : Association to AccountStructureItems;
name : String @title: 'Name';
value : String @title: 'Value';
}
/**
* Contract credits information
*/
// Raw API data
entity CloudCreditsDetailsResponseObjects {
key globalAccountId : String;
globalAccountName : String;
contracts : Composition of many ContractResponseObjects
on contracts.toCloudCreditsDetailsResponseObject = $self;
valueUpdates : Composition of many ContractCreditValues
on valueUpdates.toParent = $self;
}
// Raw API data
entity ContractResponseObjects {
key ID : UUID @Core.Computed;
toCloudCreditsDetailsResponseObject : Association to CloudCreditsDetailsResponseObjects;
contractStartDate : String;
contractEndDate : String;
currency : String;
phases : Composition of many PhasesResponseObjects
on phases.toContractResponseObject = $self;
}
// Raw API data
entity PhasesResponseObjects {
key toContractResponseObject : Association to ContractResponseObjects;
key phaseStartDate : String;
phaseEndDate : String;
phaseUpdates : Composition of many PhaseUpdates
on phaseUpdates.toPhasesResponseObject = $self;
}
// Raw API data
entity PhaseUpdates {
key ID : UUID default SYSUUID() @Core.Computed;
toPhasesResponseObject : Association to PhasesResponseObjects;
balance : Decimal(20, 2);
cloudCreditsForPhase : Decimal(20, 2);
phaseUpdatedOn : String;
}
// Generated actual values from raw API data
entity ContractCreditValues {
key toParent : Association to CloudCreditsDetailsResponseObjects;
key yearMonth : String;
contractStartDate : Date;
contractEndDate : Date;
currency : String;
phaseStartDate : Date;
phaseEndDate : Date;
phaseUpdatedOn : Date;
cloudCreditsForPhase : Decimal(20, 2);
balance : Decimal(20, 2);
status : types.TCreditStatus;
}
/**
* Code lists
*/
entity CodeLists {
key list : String @UI.Hidden;
key code : String @title: 'Item';
key context : String;
description : String @title: 'Description';
}