cloudmunch_sdk_v3 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. checksums.yaml +7 -0
  2. data/lib/cloudmunch_Ruby_sdk_v2/AppAbstract.rb +146 -0
  3. data/lib/cloudmunch_Ruby_sdk_v2/AppContext.rb +59 -0
  4. data/lib/cloudmunch_Ruby_sdk_v2/AssetHelper.rb +127 -0
  5. data/lib/cloudmunch_Ruby_sdk_v2/CloudmunchConstants.rb +24 -0
  6. data/lib/cloudmunch_Ruby_sdk_v2/CloudmunchService.rb +249 -0
  7. data/lib/cloudmunch_Ruby_sdk_v2/ElasticBeanStalkServer.rb +52 -0
  8. data/lib/cloudmunch_Ruby_sdk_v2/EnvironmentHelper.rb +292 -0
  9. data/lib/cloudmunch_Ruby_sdk_v2/InsightHelper.rb +770 -0
  10. data/lib/cloudmunch_Ruby_sdk_v2/IntegrationHelper.rb +69 -0
  11. data/lib/cloudmunch_Ruby_sdk_v2/PluginLoaderAbstract.rb +140 -0
  12. data/lib/cloudmunch_Ruby_sdk_v2/PluginReporterAbstract.rb +141 -0
  13. data/lib/cloudmunch_Ruby_sdk_v2/RoleHelper.rb +170 -0
  14. data/lib/cloudmunch_Ruby_sdk_v2/Server.rb +77 -0
  15. data/lib/cloudmunch_Ruby_sdk_v2/ServerHelper.rb +284 -0
  16. data/lib/cloudmunch_Ruby_sdk_v2/ServiceProvider.rb +25 -0
  17. data/lib/cloudmunch_Ruby_sdk_v2/Util.rb +119 -0
  18. data/lib/cloudmunch_Ruby_sdk_v2/doc/AppAbstract.html +1062 -0
  19. data/lib/cloudmunch_Ruby_sdk_v2/doc/AppContext.html +1402 -0
  20. data/lib/cloudmunch_Ruby_sdk_v2/doc/AssetHelper.html +694 -0
  21. data/lib/cloudmunch_Ruby_sdk_v2/doc/Cloudmunch.html +117 -0
  22. data/lib/cloudmunch_Ruby_sdk_v2/doc/CloudmunchConstants.html +184 -0
  23. data/lib/cloudmunch_Ruby_sdk_v2/doc/CloudmunchService.html +1195 -0
  24. data/lib/cloudmunch_Ruby_sdk_v2/doc/ElasticBeanStalkServer.html +1375 -0
  25. data/lib/cloudmunch_Ruby_sdk_v2/doc/InsightHelper.html +2889 -0
  26. data/lib/cloudmunch_Ruby_sdk_v2/doc/IntegrationHelper.html +400 -0
  27. data/lib/cloudmunch_Ruby_sdk_v2/doc/RoleHelper.html +809 -0
  28. data/lib/cloudmunch_Ruby_sdk_v2/doc/Server.html +2302 -0
  29. data/lib/cloudmunch_Ruby_sdk_v2/doc/ServerHelper.html +1181 -0
  30. data/lib/cloudmunch_Ruby_sdk_v2/doc/ServiceProvider.html +328 -0
  31. data/lib/cloudmunch_Ruby_sdk_v2/doc/Util.html +540 -0
  32. data/lib/cloudmunch_Ruby_sdk_v2/doc/_index.html +214 -0
  33. data/lib/cloudmunch_Ruby_sdk_v2/doc/class_list.html +58 -0
  34. data/lib/cloudmunch_Ruby_sdk_v2/doc/css/common.css +1 -0
  35. data/lib/cloudmunch_Ruby_sdk_v2/doc/css/full_list.css +57 -0
  36. data/lib/cloudmunch_Ruby_sdk_v2/doc/css/style.css +339 -0
  37. data/lib/cloudmunch_Ruby_sdk_v2/doc/file_list.html +57 -0
  38. data/lib/cloudmunch_Ruby_sdk_v2/doc/frames.html +26 -0
  39. data/lib/cloudmunch_Ruby_sdk_v2/doc/index.html +214 -0
  40. data/lib/cloudmunch_Ruby_sdk_v2/doc/js/app.js +219 -0
  41. data/lib/cloudmunch_Ruby_sdk_v2/doc/js/full_list.js +181 -0
  42. data/lib/cloudmunch_Ruby_sdk_v2/doc/js/jquery.js +4 -0
  43. data/lib/cloudmunch_Ruby_sdk_v2/doc/method_list.html +993 -0
  44. data/lib/cloudmunch_Ruby_sdk_v2/doc/top-level-namespace.html +114 -0
  45. data/lib/cloudmunch_Ruby_sdk_v2/version.rb +3 -0
  46. data/lib/cloudmunch_Ruby_sdk_v3/AppAbstract.rb +146 -0
  47. data/lib/cloudmunch_Ruby_sdk_v3/AppContext.rb +59 -0
  48. data/lib/cloudmunch_Ruby_sdk_v3/AssetHelper.rb +127 -0
  49. data/lib/cloudmunch_Ruby_sdk_v3/CloudmunchConstants.rb +24 -0
  50. data/lib/cloudmunch_Ruby_sdk_v3/CloudmunchService.rb +300 -0
  51. data/lib/cloudmunch_Ruby_sdk_v3/ElasticBeanStalkServer.rb +52 -0
  52. data/lib/cloudmunch_Ruby_sdk_v3/EnvironmentHelper.rb +292 -0
  53. data/lib/cloudmunch_Ruby_sdk_v3/InsightHelper.rb +770 -0
  54. data/lib/cloudmunch_Ruby_sdk_v3/IntegrationHelper.rb +69 -0
  55. data/lib/cloudmunch_Ruby_sdk_v3/PluginLoaderAbstract.rb +140 -0
  56. data/lib/cloudmunch_Ruby_sdk_v3/PluginReporterAbstract.rb +141 -0
  57. data/lib/cloudmunch_Ruby_sdk_v3/RoleHelper.rb +170 -0
  58. data/lib/cloudmunch_Ruby_sdk_v3/Server.rb +77 -0
  59. data/lib/cloudmunch_Ruby_sdk_v3/ServerHelper.rb +284 -0
  60. data/lib/cloudmunch_Ruby_sdk_v3/ServiceProvider.rb +25 -0
  61. data/lib/cloudmunch_Ruby_sdk_v3/Util.rb +119 -0
  62. data/lib/cloudmunch_Ruby_sdk_v3/doc/AppAbstract.html +1062 -0
  63. data/lib/cloudmunch_Ruby_sdk_v3/doc/AppContext.html +1402 -0
  64. data/lib/cloudmunch_Ruby_sdk_v3/doc/AssetHelper.html +694 -0
  65. data/lib/cloudmunch_Ruby_sdk_v3/doc/Cloudmunch.html +117 -0
  66. data/lib/cloudmunch_Ruby_sdk_v3/doc/CloudmunchConstants.html +184 -0
  67. data/lib/cloudmunch_Ruby_sdk_v3/doc/CloudmunchService.html +1195 -0
  68. data/lib/cloudmunch_Ruby_sdk_v3/doc/ElasticBeanStalkServer.html +1375 -0
  69. data/lib/cloudmunch_Ruby_sdk_v3/doc/InsightHelper.html +2889 -0
  70. data/lib/cloudmunch_Ruby_sdk_v3/doc/IntegrationHelper.html +400 -0
  71. data/lib/cloudmunch_Ruby_sdk_v3/doc/RoleHelper.html +809 -0
  72. data/lib/cloudmunch_Ruby_sdk_v3/doc/Server.html +2302 -0
  73. data/lib/cloudmunch_Ruby_sdk_v3/doc/ServerHelper.html +1181 -0
  74. data/lib/cloudmunch_Ruby_sdk_v3/doc/ServiceProvider.html +328 -0
  75. data/lib/cloudmunch_Ruby_sdk_v3/doc/Util.html +540 -0
  76. data/lib/cloudmunch_Ruby_sdk_v3/doc/_index.html +214 -0
  77. data/lib/cloudmunch_Ruby_sdk_v3/doc/class_list.html +58 -0
  78. data/lib/cloudmunch_Ruby_sdk_v3/doc/css/common.css +1 -0
  79. data/lib/cloudmunch_Ruby_sdk_v3/doc/css/full_list.css +57 -0
  80. data/lib/cloudmunch_Ruby_sdk_v3/doc/css/style.css +339 -0
  81. data/lib/cloudmunch_Ruby_sdk_v3/doc/file_list.html +57 -0
  82. data/lib/cloudmunch_Ruby_sdk_v3/doc/frames.html +26 -0
  83. data/lib/cloudmunch_Ruby_sdk_v3/doc/index.html +214 -0
  84. data/lib/cloudmunch_Ruby_sdk_v3/doc/js/app.js +219 -0
  85. data/lib/cloudmunch_Ruby_sdk_v3/doc/js/full_list.js +181 -0
  86. data/lib/cloudmunch_Ruby_sdk_v3/doc/js/jquery.js +4 -0
  87. data/lib/cloudmunch_Ruby_sdk_v3/doc/method_list.html +993 -0
  88. data/lib/cloudmunch_Ruby_sdk_v3/doc/top-level-namespace.html +114 -0
  89. data/lib/cloudmunch_Ruby_sdk_v3/version.rb +3 -0
  90. data/lib/cloudmunch_sdk.rb +5 -0
  91. data/lib/cloudmunch_sdk_v3.rb +5 -0
  92. metadata +194 -0
@@ -0,0 +1,770 @@
1
+ #!/usr/bin/ruby
2
+ require 'logger'
3
+ require 'json'
4
+ require_relative 'Util'
5
+
6
+ module InsightHelper
7
+ include Util
8
+
9
+ ##################################################################################
10
+ ###
11
+ ###
12
+ ### createInsight(insightName)
13
+ ### createInsightDataStore(insightID, dataStoreName)
14
+ ### createInsightDataStoreExtract(insightID, dataStoreID, extractName)
15
+ ### createInsightReport(insightID, reportName)
16
+ ### createInsightReportCard(insightID, reportID, cardName)
17
+ ### createInsightReportKeyMetric(insightID, reportID, keyMetricName)
18
+ ###
19
+ ###
20
+ ### getDataStoreID(insightID, dataStoreName)
21
+ ### getExtractID(insightID, dataStoreID, extractName)
22
+ ### getReportID(insightID, reportName)
23
+ ### getReportCardID(insightID, reportID, cardName)
24
+ ### getKeyMetricID(insightID, reportID, keyMetricName)
25
+ ###
26
+ ###
27
+ ### getInsights(paramHash)
28
+ ### getInsightDataStores(paramHash)
29
+ ### getInsightDataStoreExtracts(paramHash)
30
+ ### getInsightReports(paramHash)
31
+ ### getInsightReportCards(paramHash)
32
+ ### getInsightReportKeyMetrics(paramHash)
33
+ ###
34
+ ###
35
+ ### updateInsight(insightID, data)
36
+ ### updateInsightDataStore(insightID, dataStoreID, data)
37
+ ### updateInsightDataStoreExtract(insightID, dataStoreID, extractID, data)
38
+ ### updateInsightReport(insightID, reportID, data)
39
+ ### updateInsightReportCard(insightID, reportID, cardID, data)
40
+ ### updateInsightReportKeyMetric(insightID, reportID, keyMetricID, data)
41
+ ###
42
+ ### getListOfDatesForADuration(durationUnitNameStr, durationUnitNumber)
43
+ ### getInsightReportDataTemplateHash(reportTypeStr)
44
+ ### getInsightReportMetaTemplateHash(reportTypeStr)
45
+ ### getInsightReportVisualizationMapTemplateHash(reportTypeStr)
46
+ ##################################################################################
47
+
48
+
49
+
50
+
51
+ ###################################################################################
52
+ #### createInsight(insightName)
53
+ #### Creates An Insight space in Server Workspace
54
+ #### Needed in Loader plugins
55
+ ###################################################################################
56
+ def createInsight(insightName)
57
+ if !insightName.nil?
58
+ insightID = nil
59
+ insightID = getInsightID(insightName)
60
+
61
+ if !insightID.nil?
62
+ log("DEBUG", "Insight with name "+insightName+" already exists!")
63
+ return insightID
64
+ else
65
+ paramHash = {}
66
+ paramHash["context"] = "resources"
67
+ paramHash["data"] = {"name" => insightName}
68
+ insight = updateCloudmunchData(paramHash)
69
+
70
+ if insight["id"].nil?
71
+ log("DEBUG", "Unable to create insight : "+insightName+"! refer log for more details")
72
+ return nil
73
+ else
74
+ return insight["id"]
75
+ end
76
+ end
77
+ else
78
+ log("DEBUG", "Insights name is needed for creating an insight")
79
+ return nil
80
+ end
81
+ end
82
+
83
+ ###################################################################################
84
+ #### createInsightDataStore(insightID, dataStoreName)
85
+ #### Creates An Insight DataStore in Server Workspace
86
+ #### Needed in Loader plugins
87
+ ###################################################################################
88
+ def createInsightDataStore(insightID, dataStoreName)
89
+ if !dataStoreName.nil? && !dataStoreName.empty? && !insightID.nil?
90
+ dataStoreID = nil
91
+ dataStoreID = getDataStoreID(insightID, dataStoreName)
92
+
93
+ if !dataStoreID.nil?
94
+ log("DEBUG", "Data store with name "+dataStoreName+" already exists!")
95
+ return dataStoreID
96
+ else
97
+ paramHash = {}
98
+ paramHash["context"] = "resources"
99
+ paramHash["contextID"] = insightID
100
+ paramHash["subContext"] = "datastores"
101
+ paramHash["data"] = {"name" => dataStoreName}
102
+ dataStore = updateCloudmunchData(paramHash)
103
+
104
+ if dataStore.nil?
105
+ return nil
106
+ else
107
+ return dataStore["id"]
108
+ end
109
+ end
110
+ else
111
+ log("DEBUG", "Datastore name and insights id is needed for creating a data store")
112
+ return nil
113
+ end
114
+ end
115
+
116
+ ###################################################################################
117
+ #### createInsightDataStoreExtract(insightID, dataStoreID, extractName)
118
+ #### Creates An Insight DataStore Extract in Server Workspace
119
+ #### Needed In Loader Plugins
120
+ ###################################################################################
121
+ def createInsightDataStoreExtract(insightID, dataStoreID, extractName)
122
+ if !extractName.nil? && !extractName.empty? && !insightID.nil? && !dataStoreID.nil?
123
+
124
+ extractID = nil
125
+ extractID = getExtractID(insightID, dataStoreID, extractName)
126
+
127
+ if !extractID.nil?
128
+ return extractID
129
+ else
130
+ paramHash = Hash.new
131
+ paramHash["context"] = "resources"
132
+ paramHash["contextID"] = insightID
133
+ paramHash["subContext"] = "datastores"
134
+ paramHash["subContextID"] = dataStoreID
135
+ paramHash["leafContext"] = "extracts"
136
+ paramHash["data"] = {"name" => extractName}
137
+
138
+ log("DEBUG", "Attempting creation of extract with name " + extractName + "...")
139
+ extract = updateCloudmunchData(paramHash)
140
+
141
+ if extract["id"].nil? then return nil else extract["id"] end
142
+ end
143
+ else
144
+ log("DEBUG", "Extract name, insights id and datastore id is needed for creating an extract")
145
+ return nil
146
+ end
147
+ end
148
+
149
+
150
+ ###################################################################################
151
+ #### createInsightReport(insightID, reportName)
152
+ #### Creates An Insight Report in Server Workspace
153
+ #### Needed In Reporter Plugins
154
+ ###################################################################################
155
+ def createInsightReport(insightID, reportName)
156
+ if !reportName.nil? && !reportName.empty? && !insightID.nil?
157
+
158
+ reportID = nil
159
+ reportID = getReportID(insightID, reportName)
160
+
161
+ if !reportID.nil?
162
+ return reportID
163
+ else
164
+ paramHash = Hash.new
165
+ paramHash["context"] = "resources"
166
+ paramHash["contextID"] = insightID
167
+ paramHash["subContext"] = "insight_reports"
168
+ paramHash["data"] = {"name" => reportName}
169
+
170
+ log("DEBUG", "Attempting creation of report with name " + reportName + "...")
171
+ report = updateCloudmunchData(paramHash)
172
+
173
+ if report["id"].nil? then return nil else report["id"] end
174
+ end
175
+ else
176
+ log("DEBUG", "Report name and insight id is needed for creating a report")
177
+ return nil
178
+ end
179
+ end
180
+
181
+ ###################################################################################
182
+ #### createInsightReportCard(insightID, reportID, cardName)
183
+ #### Creates An Insight Report Card in Server Workspace
184
+ #### Needed In Reporter Plugins
185
+ ###################################################################################
186
+ def createInsightReportCard(insightID, reportID, cardName)
187
+ if !cardName.nil? && !cardName.empty? && !insightID.nil? && !reportID.nil?
188
+
189
+ cardID = nil
190
+ cardID = getReportCardID(insightID, reportID, cardName)
191
+
192
+ if !cardID.nil?
193
+ return cardID
194
+ else
195
+ paramHash = Hash.new
196
+ paramHash["context"] = "resources"
197
+ paramHash["contextID"] = insightID
198
+ paramHash["subContext"] = "insight_reports"
199
+ paramHash["subContextID"] = reportID
200
+ paramHash["leafContext"] = "insight_cards"
201
+ paramHash["data"] = {"name" => cardName}
202
+
203
+ log("DEBUG", "Attempting creation of report card with name " + cardName + "...")
204
+ card = updateCloudmunchData(paramHash)
205
+
206
+ if card["id"].nil? then return nil else card["id"] end
207
+ end
208
+ else
209
+ log("DEBUG", "Extract name, insight id and report id is needed for creating a report card")
210
+ return nil
211
+ end
212
+ end
213
+
214
+
215
+
216
+ ###################################################################################
217
+ #### createInsightReportKeyMetric(insightID, reportID, keyMetricName)
218
+ #### Creates An Insight Report Key Metric in Server Workspace
219
+ #### Needed In Reporter Plugins
220
+ ###################################################################################
221
+ def createInsightReportKeyMetric(insightID, reportID, keyMetricName)
222
+ if !keyMetricName.nil? && !keyMetricName.empty? && !insightID.nil? && !reportID.nil?
223
+
224
+ keyMetricID = nil
225
+ keyMetricID = getReportKeyMetricID(insightID, reportID, keyMetricName)
226
+
227
+ if !keyMetricID.nil?
228
+ return keyMetricID
229
+ else
230
+ paramHash = Hash.new
231
+ paramHash["context"] = "resources"
232
+ paramHash["contextID"] = insightID
233
+ paramHash["subContext"] = "insight_reports"
234
+ paramHash["subContextID"] = reportID
235
+ paramHash["leafContext"] = "insight_cards"
236
+ paramHash["data"] = {"name" => keyMetricName}
237
+
238
+ log("DEBUG", "Attempting creation of report key metric with name " + keyMetricName + "...")
239
+ keyMetric = updateCloudmunchData(paramHash)
240
+
241
+ if keyMetric["id"].nil? then return nil else keyMetric["id"] end
242
+ end
243
+ else
244
+ log("DEBUG", "Key metric name, insight id and report id is needed for creating a report key metric")
245
+ return nil
246
+ end
247
+ end
248
+
249
+
250
+ ###################################################################################
251
+ #### getDataStoreID(insightID, dataStoreName)
252
+ #### Gets DataStore ID for a given DataStore
253
+ #### <NOTE>
254
+ ###################################################################################
255
+ def getDataStoreID(insightID, dataStoreName)
256
+ if insightID.nil? || dataStoreName.nil?
257
+ log("DEBUG", "insight id and datastore name is needed to get datastore id")
258
+ return nil
259
+ end
260
+
261
+ paramHash = Hash.new
262
+ paramHash["insightID"] = insightID
263
+ paramHash["filter"] = {"name" => dataStoreName}
264
+ paramHash["count"] = 1
265
+ paramHash["fields"] = "id"
266
+
267
+ dataStore = getInsightDataStores(paramHash)
268
+
269
+ if dataStore.nil?
270
+ log("DEBUG", "Data store with name "+dataStoreName+" does not exist")
271
+ return nil
272
+ elsif (dataStore.kind_of?(Array)) && (dataStore.length.to_i > 0)
273
+ return dataStore[0]["id"]
274
+ else
275
+ log("DEBUG", "Data store with name "+dataStoreName+" does not exist")
276
+ return nil
277
+ end
278
+ end
279
+
280
+ ###################################################################################
281
+ #### getExtractID(insightID, dataStoreID, extractName)
282
+ #### Gets Extract ID for a given extract in a DataStore
283
+ #### <NOTE>
284
+ ###################################################################################
285
+ def getExtractID(insightID, dataStoreID, extractName)
286
+ if insightID.nil? || dataStoreID.nil? || extractName.nil?
287
+ log("DEBUG", "insight id, datastore id and extract name is needed to get extract id")
288
+ return nil
289
+ end
290
+
291
+ extract = nil
292
+ paramHash = Hash.new
293
+ paramHash["insightID"] = insightID
294
+ paramHash["dataStoreID"] = dataStoreID
295
+ paramHash["filter"] = {"name" => extractName}
296
+ paramHash["count"] = 1
297
+ paramHash["fields"] = "id"
298
+
299
+ extract = getInsightDataStoreExtracts(paramHash)
300
+
301
+ if extract.nil?
302
+ log("DEBUG", "Extract with name "+extractName+" does not exist")
303
+ return nil
304
+ elsif (extract.kind_of?(Array)) && (extract.length.to_i > 0)
305
+ return extract[0]["id"]
306
+ else
307
+ log("DEBUG", "Extract with name "+extractName+" does not exist")
308
+ return nil
309
+ end
310
+ end
311
+
312
+ ###################################################################################
313
+ #### getReportID(insightID, reportName)
314
+ #### Gets Report ID for a given report
315
+ #### <NOTE>
316
+ ###################################################################################
317
+ def getReportID(insightID, reportName)
318
+ if insightID.nil? || reportName.nil?
319
+ log("DEBUG", "insight id and report name is needed to get report id")
320
+ return nil
321
+ end
322
+
323
+ paramHash = Hash.new
324
+ paramHash["insightID"] = insightID
325
+ paramHash["filter"] = {"name" => reportName}
326
+ paramHash["count"] = 1
327
+ paramHash["fields"] = "id"
328
+
329
+ report = getInsightReports(paramHash)
330
+
331
+ if report.nil?
332
+ log("DEBUG", "Report with name "+reportName+" does not exist")
333
+ return nil
334
+ elsif (report.kind_of?(Array)) && (report.length.to_i > 0)
335
+ return report[0]["id"]
336
+ else
337
+ log("DEBUG", "Report with name "+reportName+" does not exist")
338
+ return nil
339
+ end
340
+ end
341
+
342
+
343
+
344
+ ###################################################################################
345
+ #### getReportCardID(insightID, reportID, cardName)
346
+ #### Gets Report Card ID for a given report card
347
+ #### <NOTE>
348
+ ###################################################################################
349
+ def getReportCardID(insightID, reportID, cardName)
350
+ if insightID.nil? || reportID.nil? || cardName.nil?
351
+ log("DEBUG", "insight id, report id and card name is needed to get report card id")
352
+ return nil
353
+ end
354
+
355
+ card = nil
356
+ paramHash = Hash.new
357
+ paramHash["insightID"] = insightID
358
+ paramHash["reportID"] = reportID
359
+ paramHash["filter"] = {"name" => cardName}
360
+ paramHash["count"] = 1
361
+ paramHash["fields"] = "id"
362
+
363
+ card = getInsightReportCards(paramHash)
364
+
365
+ if card.nil?
366
+ log("DEBUG", "Report with name "+cardName+" does not exist")
367
+ return nil
368
+ elsif (card.kind_of?(Array)) && (card.length.to_i > 0)
369
+ return card[0]["id"]
370
+ else
371
+ log("DEBUG", "Report with name "+cardName+" does not exist")
372
+ return nil
373
+ end
374
+ end
375
+
376
+ ###################################################################################
377
+ #### getKeyMetricID(insightID, reportID, keyMetricName)
378
+ #### Gets Key Metric ID for a given report card
379
+ #### <NOTE>
380
+ ###################################################################################
381
+ def getKeyMetricID(insightID, reportID, keyMetricName)
382
+ paramHash = Hash.new
383
+ paramHash["insightID"] = insightID
384
+ paramHash["reportID"] = reportID
385
+ paramHash["filter"] = {"name" => keyMetricName}
386
+ paramHash["count"] = 1
387
+ paramHash["fields"] = "id"
388
+
389
+ keyMetric = getInsightReportCards(paramHash)
390
+ if keyMetric.nil? || !keyMetric.any?
391
+ log("DEBUG", "Report key metric with name "+keyMetricName+" does not exist")
392
+ return nil
393
+ else
394
+ return keyMetric[0]["id"]
395
+ end
396
+ end
397
+
398
+ ###################################################################################
399
+ #### getInsights(paramHash)
400
+ #### Get Insights from Server Workspace
401
+ #### Needed In Reporter Plugins
402
+ ###################################################################################
403
+ def getInsights(paramHash)
404
+ # /insights/{insight_id}
405
+ paraminsightID = paramHash["insightID"].nil? ? nil : paramHash["insightID"]
406
+
407
+ paramFormatted = Hash.new
408
+ paramFormatted = paramHash
409
+ paramFormatted["context"] = "resources"
410
+
411
+ if !paraminsightID.nil? && !paraminsightID.empty?
412
+ paramFormatted["contextID"] = paramInsightID
413
+ end
414
+
415
+ return getCloudmunchData(paramFormatted)
416
+ end
417
+
418
+
419
+ ###################################################################################
420
+ #### getInsightDataStores(paramHash)
421
+ #### Get Insight DataStores from Server Workspace
422
+ #### Needed In Reporter Plugins
423
+ ###################################################################################
424
+ def getInsightDataStores(paramHash)
425
+ # /insights/{insight_id}/datastores/{datastore_id}
426
+ paramInsightID = paramHash["insightID"].nil? ? nil : paramHash["insightID"]
427
+
428
+ if paramInsightID.nil? || paramInsightID.empty?
429
+ log("DEBUG", "Insight id is not provided")
430
+ return nil
431
+ end
432
+
433
+ paramFormatted = Hash.new
434
+ paramFormatted = paramHash
435
+ paramFormatted["context"] = "resources"
436
+ paramFormatted["subContext"] = "datastores"
437
+ paramFormatted["contextID"] = paramInsightID
438
+
439
+ if !paramHash["dataStoreID"].nil?
440
+ paramFormatted["subContextID"] = paramHash["dataStoreID"]
441
+ end
442
+ return getCloudmunchData(paramFormatted)
443
+ end
444
+
445
+ ###################################################################################
446
+ #### getInsightDataStoreExtracts(paramHash)
447
+ #### Get Insight DataStore Extracts from Server Workspace
448
+ #### Needed In Reporter Plugins
449
+ ###################################################################################
450
+ def getInsightDataStoreExtracts(paramHash)
451
+ # /insights/{insight_id}/datastores/{datastore_id}/extracts/{extract_id}
452
+ paramDataStoreId = paramHash["dataStoreID"].nil? ? nil : paramHash["dataStoreID"]
453
+ paramInsightID = paramHash["insightID"].nil? ? nil : paramHash["insightID"]
454
+
455
+ serverurl = nil
456
+
457
+ if paramInsightID.nil? || paramInsightID.empty? || paramDataStoreId.nil? || paramDataStoreId.empty?
458
+ log("DEBUG", "Insight id and datastore id is needed to gets its extract details")
459
+ return nil
460
+ end
461
+
462
+ paramFormatted = Hash.new
463
+ paramFormatted = paramHash
464
+ paramFormatted["context"] = "resources"
465
+ paramFormatted["subContext"] = "datastores"
466
+ paramFormatted["leafContext"] = "extracts"
467
+ paramFormatted["contextID"] = paramInsightID
468
+ paramFormatted["subContextID"] = paramDataStoreId
469
+
470
+ if !paramHash["extractID"].nil?
471
+ paramFormatted["leafContextID"] = paramHash["extractID"]
472
+ end
473
+
474
+ return getCloudmunchData(paramFormatted)
475
+ end
476
+
477
+ ###################################################################################
478
+ #### getInsightReports(paramHash)
479
+ #### Get Insight Reports from Server Workspace
480
+ #### Needed In Reporter Plugins
481
+ ###################################################################################
482
+ def getInsightReports(paramHash)
483
+ # /applications/{application_id}/insights/{insight_id}/insight_reports/{insight_report_id}
484
+ paramInsightID = paramHash["insightID"].nil? ? nil : paramHash["insightID"]
485
+
486
+ if paramInsightID.nil? || paramInsightID.empty?
487
+ log("DEBUG", "Insight id is needed to gets its report details")
488
+ return nil
489
+ end
490
+
491
+ paramFormatted = Hash.new
492
+ paramFormatted = paramHash
493
+ paramFormatted["context"] = "resources"
494
+ paramFormatted["subContext"] = "insight_reports"
495
+ paramFormatted["contextID"] = paramInsightID
496
+
497
+ if !paramHash["reportID"].nil?
498
+ paramFormatted["subContextID"] = paramHash["reportID"]
499
+ end
500
+
501
+ return getCloudmunchData(paramFormatted)
502
+ end
503
+
504
+ ###################################################################################
505
+ #### getInsightReportCards(paramHash)
506
+ #### Get Insight Report Cards from Server Workspace
507
+ #### Needed In Reporter Plugins
508
+ ###################################################################################
509
+ def getInsightReportCards(paramHash)
510
+ # /applications/{application_id}/insights/{insight_id}/insight_reports/{insight_report_id}/insight_cards/{insight_card_id}
511
+ paramReportId = paramHash["reportID"].nil? ? nil : paramHash["reportID"]
512
+ paramInsightID = paramHash["insightID"].nil? ? nil : paramHash["insightID"]
513
+
514
+ if paramInsightID.nil? || paramInsightID.empty? || paramReportId.nil? || paramReportId.empty?
515
+ log("DEBUG", "Insight id and report id is needed to gets its report card details")
516
+ return nil
517
+ end
518
+
519
+ paramFormatted = Hash.new
520
+ paramFormatted = paramHash
521
+ paramFormatted["context"] = "resources"
522
+ paramFormatted["subContext"] = "insight_reports"
523
+ paramFormatted["leafContext"] = "insight_cards"
524
+ paramFormatted["contextID"] = paramInsightID
525
+ paramFormatted["subContextID"] = paramReportId
526
+
527
+ if !paramHash["cardID"].nil?
528
+ paramFormatted["leafContextID"] = paramHash["cardID"]
529
+ end
530
+
531
+ return getCloudmunchData(paramFormatted)
532
+ end
533
+
534
+ ###################################################################################
535
+ #### getInsightReportKeyMetrics(paramHash)
536
+ #### Get Insight Report Key Metrics from Server Workspace
537
+ #### Needed In Reporter Plugins
538
+ ###################################################################################
539
+ def getInsightReportKeyMetrics(paramHash)
540
+ # /applications/{application_id}/insights/{insight_id}/insight_reports/{insight_report_id}/key_metrics/{key_metric_id}
541
+ paramReportId = paramHash["reportID"].nil? ? nil : paramHash["reportID"]
542
+ paramInsightID = paramHash["insightID"].nil? ? nil : paramHash["insightID"]
543
+
544
+ if paramInsightID.nil? || paramInsightID.empty? || paramReportId.nil? || paramReportId.empty?
545
+ log("DEBUG", "Insight id and report id is needed to gets its report key metric details")
546
+ return nil
547
+ end
548
+
549
+ paramFormatted = Hash.new
550
+ paramFormatted = paramHash
551
+ paramFormatted["context"] = "resources"
552
+ paramFormatted["subContext"] = "insight_reports"
553
+ paramFormatted["leafContext"] = "key_metrics"
554
+ paramFormatted["contextID"] = paramInsightID
555
+ paramFormatted["subContextID"] = paramReportId
556
+
557
+ if !paramHash["keyMetricID"].nil?
558
+ paramFormatted["leafContextID"] = paramHash["keyMetricID"]
559
+ end
560
+
561
+ return getCloudmunchData(paramFormatted)
562
+ end
563
+
564
+ ###################################################################################
565
+ #### updateInsight(insightID, data)
566
+ #### Updates Insight Into Server Workspace
567
+ #### Needed In Reporter Plugins
568
+ ###################################################################################
569
+ def updateInsight(insightID, data)
570
+ # /applications/{application_id}/insights/{insight_id}
571
+
572
+ if (insightID.nil? || insightID.empty?) && data.nil?
573
+ log("DEBUG", "Insight id and data is needed to be update an existing data store")
574
+ return nil
575
+ end
576
+
577
+ paramHash = {}
578
+ paramHash["context"] = "resources"
579
+ paramHash["contextID"] = insightID
580
+ paramHash["data"] = data
581
+ return updateCloudmunchData(paramHash)
582
+ end
583
+
584
+
585
+ ###################################################################################
586
+ #### updateInsightDataStore(insightID, dataStoreID, data)
587
+ #### Updates Insight DataStore Into Server Workspace
588
+ #### Needed In Reporter Plugins
589
+ ###################################################################################
590
+ def updateInsightDataStore(insightID, dataStoreID, data)
591
+ # /applications/{application_id}/insights/{insight_id}/datastores/{datastore_id}
592
+
593
+ if (insightID.nil? || insightID.empty?) && (dataStoreID.nil? || dataStoreID.empty?) && data.nil?
594
+ log("DEBUG", "Insight id, datastore id and data is needed to be update an existing data store")
595
+ return nil
596
+ end
597
+ paramHash = {}
598
+ paramHash["context"] = "resources"
599
+ paramHash["contextID"] = insightID
600
+ paramHash["subContext"] = "datastores"
601
+ paramHash["subContextID"] = dataStoreID
602
+ paramHash["data"] = data
603
+ return updateCloudmunchData(paramHash)
604
+ end
605
+
606
+ ###################################################################################
607
+ #### updateInsightDataStoreExtract(insightID, dataStoreID, extractID, data)
608
+ #### Updates Insight DataStore Extract In Server Workspace
609
+ #### Needed In Reporter Plugins
610
+ ###################################################################################
611
+ def updateInsightDataStoreExtract(insightID, dataStoreID, extractID, data)
612
+ # /insights/{insight_id}/datastores/{datastore_id}/extracts/{extract_id}
613
+
614
+ if (insightID.nil? || insightID.empty?) && (dataStoreID.nil? || dataStoreID.empty?) && (extractID.nil? || extractID.empty?) && data.nil?
615
+ log("DEBUG", "Insight id, datastore id, extract id and data is needed to be update an existing extract")
616
+ return nil
617
+ end
618
+ paramHash = {}
619
+ paramHash["context"] = "resources"
620
+ paramHash["contextID"] = insightID
621
+ paramHash["subContext"] = "datastores"
622
+ paramHash["subContextID"] = dataStoreID
623
+ paramHash["leafContext"] = "extracts"
624
+ paramHash["leafContextID"] = extractID
625
+ paramHash["data"] = data
626
+ return updateCloudmunchData(paramHash)
627
+ end
628
+
629
+ ###################################################################################
630
+ #### updateInsightReport(insightID, reportID, data)
631
+ #### Updates Insight Report In Server Workspace
632
+ #### Needed In Reporter Plugins
633
+ ###################################################################################
634
+ def updateInsightReport(insightID, reportID, data)
635
+ # /applications/{application_id}/insights/{insight_id}/insight_reports/{insight_report_id}
636
+
637
+ if (insightID.nil? || insightID.empty?) && (reportID.nil? || reportID.empty?) && data.nil?
638
+ log("DEBUG", "Insight id, report id and data is needed to be update an existing report")
639
+ return nil
640
+ end
641
+ paramHash = {}
642
+ paramHash["context"] = "resources"
643
+ paramHash["contextID"] = insightID
644
+ paramHash["subContext"] = "insight_reports"
645
+ paramHash["subContextID"] = reportID
646
+ paramHash["data"] = data
647
+ return updateCloudmunchData(paramHash)
648
+ end
649
+
650
+
651
+ ###################################################################################
652
+ #### updateInsightReportCard(insightID, reportID, cardID, data)
653
+ #### Updates Insight Report Card In Server Workspace
654
+ #### Needed In Reporter Plugins
655
+ ###################################################################################
656
+ def updateInsightReportCard(insightID, reportID, cardID, data)
657
+ # /applications/{application_id}/insights/{insight_id}/insight_reports/{insight_report_id}/insight_cards/{insight_card_id}
658
+
659
+ if (insightID.nil? || insightID.empty?) && (reportID.nil? || reportID.empty?) && (cardID.nil? || cardID.empty?) && data.nil?
660
+ log("DEBUG", "Insight id, report id, cardID and data is needed to be update an existing report card")
661
+ return nil
662
+ end
663
+
664
+ paramHash = {}
665
+ paramHash["context"] = "resources"
666
+ paramHash["contextID"] = insightID
667
+ paramHash["subContext"] = "insight_reports"
668
+ paramHash["subContextID"] = reportID
669
+ paramHash["leafContext"] = "insight_cards"
670
+ paramHash["leafContextID"] = cardID
671
+ paramHash["data"] = data
672
+ return updateCloudmunchData(paramHash)
673
+ end
674
+
675
+ ###################################################################################
676
+ #### updateInsightReportKeyMetric(insightID, reportID, keyMetricID, data)
677
+ #### Updates Insight Report KeyMetric In Server Workspace
678
+ #### Needed In Reporter Plugins
679
+ ###################################################################################
680
+ def updateInsightReportKeyMetric(insightID, reportID, keyMetricID, data)
681
+ # /applications/{application_id}/insights/{insight_id}/insight_reports/{insight_report_id}/key_metrics/{key_metric_id}
682
+
683
+ if (insightID.nil? || insightID.empty?) && (reportID.nil? || reportID.empty?) && (keyMetricID.nil? || keyMetricID.empty?) && data.nil?
684
+ log("DEBUG", "Insight id, report id, keyMetricID and data is needed to be update an existing report key metric")
685
+ return nil
686
+ end
687
+
688
+ paramHash = {}
689
+ paramHash["context"] = "resources"
690
+ paramHash["contextID"] = insightID
691
+ paramHash["subContext"] = "insight_reports"
692
+ paramHash["subContextID"] = reportID
693
+ paramHash["leafContext"] = "key_metrics"
694
+ paramHash["leafContextID"] = keyMetricID
695
+ paramHash["data"] = data
696
+ return updateCloudmunchData(paramHash)
697
+ end
698
+
699
+ ###################################################################################
700
+ #### getListOfDatesForADuration(durationUnitNameStr, durationUnitNumber)
701
+ #### durationUnitNameStr : days | weeks | months
702
+ #### durationUnitNumber : Eg. 1 to N
703
+ #### Get List(Array) of Dates (history) for a given duration from current day
704
+ #### Needed In Reporter Plugins
705
+ ###################################################################################
706
+ def getListOfDatesForADuration(durationUnitNameStr, durationUnitNumber)
707
+ log("info", __method__.to_s + " method is invoked from InsightsGitHubOrgsReposWithSize")
708
+ $i = 0
709
+ duration_arr = []
710
+ $curr_date = Date.today
711
+ $tmp_unit = nil
712
+ $tmp_days_in_month = nil
713
+
714
+ case durationUnitNameStr.downcase
715
+ when "days"
716
+ while $i < durationUnitNumber
717
+ $tmp_unit = $curr_date.strftime("%Y-%m-%d")
718
+ duration_arr[$i] = $tmp_unit
719
+ $curr_date -= 1
720
+ $i += 1
721
+ end
722
+ when "weeks"
723
+ while $i < durationUnitNumber
724
+ $tmp_unit = $curr_date.strftime("%Y-%m-%d")
725
+ duration_arr[$i] = $tmp_unit
726
+ $curr_date -= 7
727
+ $i += 1
728
+ end
729
+ when "months"
730
+ while $i < durationUnitNumber
731
+ $tmp_unit = $curr_date.strftime("%Y-%m-%d")
732
+ $tmp_days_in_month = $curr_date.day
733
+ duration_arr[$i] = $tmp_unit
734
+ $curr_date -= $tmp_days_in_month
735
+ $i += 1
736
+ end
737
+ end
738
+
739
+ return duration_arr
740
+ end
741
+
742
+ ###################################################################################
743
+ #### getInsightReportDataTemplateHash(reportTypeStr)
744
+ #### Gets the data template Hash that needs to be filled in for a given report type
745
+ #### Needed In Reporter Plugins
746
+ ###################################################################################
747
+ def getInsightReportDataTemplateHash(reportTypeStr)
748
+
749
+ end
750
+
751
+ ###################################################################################
752
+ #### getInsightReportMetaTemplateHash(reportTypeStr)
753
+ #### Gets the meta template Hash that needs to be filled in for a given report type
754
+ #### Needed In Reporter Plugins
755
+ ###################################################################################
756
+ def getInsightReportMetaTemplateHash(reportTypeStr)
757
+
758
+ end
759
+
760
+ ###################################################################################
761
+ #### getInsightReportVisualizationMapTemplateHash(reportTypeStr)
762
+ #### Gets the visualization map template Hash that needs to be filled in for a given report type
763
+ #### Needed In Reporter Plugins
764
+ ###################################################################################
765
+ def getInsightReportVisualizationMapTemplateHash(reportTypeStr)
766
+
767
+ end
768
+
769
+ end
770
+