Module: InsightHelper

Includes:
Util
Included in:
AppAbstract
Defined in:
lib/cloudmunch_Ruby_sdk_v2/InsightHelper.rb,
lib/cloudmunch_Ruby_sdk_v3/InsightHelper.rb

Instance Method Summary collapse

Methods included from Util

getJSONArgs, log, logClose, logInit, logIt, openJSONFile

Instance Method Details

#createInsight(insightName) ⇒ Object

createInsight(insightName) Creates An Insight space in Server Workspace Needed in Loader plugins



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
# File 'lib/cloudmunch_Ruby_sdk_v2/InsightHelper.rb', line 56

def createInsight(insightName)
  if !insightName.nil?
    insightID = nil
    insightID = getInsightID(insightName)
    
    if !insightID.nil?
      log("DEBUG", "Insight with name "+insightName+" already exists!")
      return insightID
    else
      paramHash = {}
      paramHash["context"]    = "insights"
      paramHash["data"]       = {"name" => insightName}
      insight = updateCloudmunchData(paramHash)
      
      if insight["id"].nil?
        log("DEBUG", "Unable to create insight : "+insightName+"! refer log for more details")
        return nil
      else
        return insight["id"]
      end
    end
  else
      log("DEBUG", "Insights name is needed for creating an insight")
      return nil
  end
end

#createInsightDataStore(insightID, dataStoreName) ⇒ Object

createInsightDataStore(insightID, dataStoreName) Creates An Insight DataStore in Server Workspace Needed in Loader plugins



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
# File 'lib/cloudmunch_Ruby_sdk_v2/InsightHelper.rb', line 88

def createInsightDataStore(insightID, dataStoreName)
  if !dataStoreName.nil? && !dataStoreName.empty? && !insightID.nil?
    dataStoreID = nil
    dataStoreID = getDataStoreID(insightID, dataStoreName)
    
    if !dataStoreID.nil?
      log("DEBUG", "Data store with name "+dataStoreName+" already exists!")
      return dataStoreID
    else
      paramHash = {}
      paramHash["context"]    = "insights"
      paramHash["contextID"]  = insightID
      paramHash["subContext"] = "datastores"
      paramHash["data"]       = {"name" => dataStoreName}
      dataStore = updateCloudmunchData(paramHash)
      
      if dataStore.nil?
        return nil
      else
        return dataStore["id"]
      end
    end
  else
      log("DEBUG", "Datastore name and insights id is needed for creating a data store")
      return nil
  end
end

#createInsightDataStoreExtract(insightID, dataStoreID, extractName) ⇒ Object

createInsightDataStoreExtract(insightID, dataStoreID, extractName) Creates An Insight DataStore Extract in Server Workspace Needed In Loader Plugins



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
# File 'lib/cloudmunch_Ruby_sdk_v2/InsightHelper.rb', line 121

def createInsightDataStoreExtract(insightID, dataStoreID, extractName)
  if !extractName.nil? && !extractName.empty? && !insightID.nil?  && !dataStoreID.nil?

    extractID = nil
    extractID = getExtractID(insightID, dataStoreID, extractName)
    
    if !extractID.nil?
      return extractID
    else
      paramHash = Hash.new
      paramHash["context"]      = "insights"
      paramHash["contextID"]    = insightID
      paramHash["subContext"]   = "datastores"
      paramHash["subContextID"] = dataStoreID
      paramHash["leafContext"]  = "extracts"
      paramHash["data"]         = {"name" => extractName}

      log("DEBUG", "Attempting creation of extract with name " + extractName + "...")
      extract = updateCloudmunchData(paramHash)

      if extract["id"].nil? then return nil else extract["id"] end
    end
  else
      log("DEBUG", "Extract name, insights id and datastore id is needed for creating an extract")
      return nil
  end
end

#createInsightDataStoreExtractAndSaveData(insightID, dataStoreID, extractName, data) ⇒ Object

createInsightDataStoreExtractAndSaveData(insightID, dataStoreID, extractName, data) Creates An Insight DataStore Extract in Server Workspace and save the given data Needed In Loader Plugins



155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/cloudmunch_Ruby_sdk_v3/InsightHelper.rb', line 155

def createInsightDataStoreExtractAndSaveData(insightID, dataStoreID, extractName, data)
  if !extractName.nil? && !extractName.empty? && !insightID.nil?  && !dataStoreID.nil? && !data.nil?
      paramHash = Hash.new
      paramHash["context"]      = "resources"
      paramHash["contextID"]    = insightID
      paramHash["subContext"]   = "datastores"
      paramHash["subContextID"] = dataStoreID
      paramHash["leafContext"]  = "extracts"
      paramHash["data"] = data
      paramHash["data"]["name"] = extractName
      
      log("DEBUG", "Extract with name #{extractName} created and data is stored into it...")
      return updateCloudmunchData(paramHash)
  else
    log("DEBUG", "Check if resourdID, dataStoreID, extractName and data are not nil...")
    return nil
  end
end

#createInsightReport(insightID, reportName) ⇒ Object

createInsightReport(insightID, reportName) Creates An Insight Report in Server Workspace Needed In Reporter Plugins



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
# File 'lib/cloudmunch_Ruby_sdk_v2/InsightHelper.rb', line 155

def createInsightReport(insightID, reportName)
  if !reportName.nil? && !reportName.empty? && !insightID.nil?

    reportID = nil
    reportID = getReportID(insightID, reportName)
    
    if !reportID.nil?
      return reportID
    else
      paramHash = Hash.new
      paramHash["context"]     = "insights"
      paramHash["contextID"]   = insightID
      paramHash["subContext"]  = "insight_reports"
      paramHash["data"]        = {"name" => reportName}

      log("DEBUG", "Attempting creation of report with name " + reportName + "...")
      report = updateCloudmunchData(paramHash)

      if report["id"].nil? then return nil else report["id"] end
    end
  else
      log("DEBUG", "Report name and insight id is needed for creating a report")
      return nil
  end
end

#createInsightReportCard(insightID, reportID, cardName) ⇒ Object

createInsightReportCard(insightID, reportID, cardName) Creates An Insight Report Card in Server Workspace Needed In Reporter Plugins



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
# File 'lib/cloudmunch_Ruby_sdk_v2/InsightHelper.rb', line 186

def createInsightReportCard(insightID, reportID, cardName)
  if !cardName.nil? && !cardName.empty? && !insightID.nil?  && !reportID.nil?

    cardID = nil
    cardID = getReportCardID(insightID, reportID, cardName)
    
    if !cardID.nil?
      return cardID
    else
      paramHash = Hash.new
      paramHash["context"]      = "insights"
      paramHash["contextID"]    = insightID
      paramHash["subContext"]   = "insight_reports"
      paramHash["subContextID"] = reportID
      paramHash["leafContext"]  = "insight_cards"
      paramHash["data"]         = {"name" => cardName}

      log("DEBUG", "Attempting creation of report card with name " + cardName + "...")
      card = updateCloudmunchData(paramHash)

      if card["id"].nil? then return nil else card["id"] end
    end
  else
      log("DEBUG", "Extract name, insight id and report id is needed for creating a report card")
      return nil
  end
end

#createInsightReportKeyMetric(insightID, reportID, keyMetricName) ⇒ Object

createInsightReportKeyMetric(insightID, reportID, keyMetricName) Creates An Insight Report Key Metric in Server Workspace Needed In Reporter Plugins



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
# File 'lib/cloudmunch_Ruby_sdk_v2/InsightHelper.rb', line 221

def createInsightReportKeyMetric(insightID, reportID, keyMetricName)
  if !keyMetricName.nil? && !keyMetricName.empty? && !insightID.nil?  && !reportID.nil?

    keyMetricID = nil
    keyMetricID = getReportKeyMetricID(insightID, reportID, keyMetricName)
    
    if !keyMetricID.nil?
      return keyMetricID
    else
      paramHash = Hash.new
      paramHash["context"]      = "insights"
      paramHash["contextID"]    = insightID
      paramHash["subContext"]   = "insight_reports"
      paramHash["subContextID"] = reportID
      paramHash["leafContext"]  = "insight_cards"
      paramHash["data"]         = {"name" => keyMetricName}

      log("DEBUG", "Attempting creation of report key metric with name " + keyMetricName + "...")
      keyMetric = updateCloudmunchData(paramHash)

      if keyMetric["id"].nil? then return nil else keyMetric["id"] end
    end
  else
      log("DEBUG", "Key metric name, insight id and report id is needed for creating a report key metric")
      return nil
  end
end

#getDataStoreID(insightID, dataStoreName) ⇒ Object

getDataStoreID(insightID, dataStoreName) Gets DataStore ID for a given DataStore <NOTE>



255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# File 'lib/cloudmunch_Ruby_sdk_v2/InsightHelper.rb', line 255

def getDataStoreID(insightID, dataStoreName)
    if insightID.nil? || dataStoreName.nil?
      log("DEBUG", "insight id and datastore name is needed to get datastore id")
      return nil
    end

    paramHash = Hash.new
    paramHash["insightID"] = insightID
    paramHash["filter"] = {"name" => dataStoreName} 
    paramHash["count"]  = 1
    paramHash["fields"] = "id" 

    dataStore = getInsightDataStores(paramHash)
    
    if dataStore.nil? 
      log("DEBUG", "Data store with name "+dataStoreName+" does not exist")
      return nil
    elsif (dataStore.kind_of?(Array)) && (dataStore.length.to_i > 0)
      return dataStore[0]["id"]
    else
      log("DEBUG", "Data store with name "+dataStoreName+" does not exist")
      return nil
    end
end

#getExtractID(insightID, dataStoreID, extractName) ⇒ Object

getExtractID(insightID, dataStoreID, extractName) Gets Extract ID for a given extract in a DataStore <NOTE>



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
# File 'lib/cloudmunch_Ruby_sdk_v2/InsightHelper.rb', line 285

def getExtractID(insightID, dataStoreID, extractName)
    if insightID.nil? || dataStoreID.nil? || extractName.nil?
      log("DEBUG", "insight id, datastore id and extract name is needed to get extract id")
      return nil
    end

    extract = nil
    paramHash = Hash.new
    paramHash["insightID"]   = insightID
    paramHash["dataStoreID"] = dataStoreID
    paramHash["filter"] = {"name" => extractName}
    paramHash["count"]  = 1
    paramHash["fields"] = "id" 

    extract = getInsightDataStoreExtracts(paramHash)

    if extract.nil? 
      log("DEBUG", "Extract with name "+extractName+" does not exist")
      return nil
    elsif (extract.kind_of?(Array)) && (extract.length.to_i > 0)
      return extract[0]["id"]
    else
      log("DEBUG", "Extract with name "+extractName+" does not exist")
      return nil
    end
end

#getInsightDataStoreExtracts(paramHash) ⇒ Object

getInsightDataStoreExtracts(paramHash) Get Insight DataStore Extracts from Server Workspace Needed In Reporter Plugins



450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
# File 'lib/cloudmunch_Ruby_sdk_v2/InsightHelper.rb', line 450

def getInsightDataStoreExtracts(paramHash)
  # /insights/{insight_id}/datastores/{datastore_id}/extracts/{extract_id}
  paramDataStoreId = paramHash["dataStoreID"].nil? ? nil : paramHash["dataStoreID"]
  paramInsightID   = paramHash["insightID"].nil? ? nil : paramHash["insightID"]

  serverurl   = nil

  if paramInsightID.nil? || paramInsightID.empty? || paramDataStoreId.nil? || paramDataStoreId.empty?
    log("DEBUG", "Insight id and datastore id is needed to gets its extract details")
    return nil
  end

  paramFormatted = Hash.new
  paramFormatted = paramHash
  paramFormatted["context"]      = "insights"
  paramFormatted["subContext"]   = "datastores"
  paramFormatted["leafContext"]  = "extracts"
  paramFormatted["contextID"]    = paramInsightID
  paramFormatted["subContextID"] = paramDataStoreId
  
  if !paramHash["extractID"].nil?
    paramFormatted["leafContextID"] = paramHash["extractID"]
  end

  return getCloudmunchData(paramFormatted)
end

#getInsightDataStores(paramHash) ⇒ Object

getInsightDataStores(paramHash) Get Insight DataStores from Server Workspace Needed In Reporter Plugins



424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
# File 'lib/cloudmunch_Ruby_sdk_v2/InsightHelper.rb', line 424

def getInsightDataStores(paramHash)
  # /insights/{insight_id}/datastores/{datastore_id}
  paramInsightID  = paramHash["insightID"].nil? ? nil : paramHash["insightID"]

  if paramInsightID.nil? || paramInsightID.empty?
    log("DEBUG", "Insight id is not provided")
    return nil
  end

  paramFormatted = Hash.new
  paramFormatted = paramHash
  paramFormatted["context"]    = "insights"
  paramFormatted["subContext"] = "datastores"
  paramFormatted["contextID"]  = paramInsightID
  
  if !paramHash["dataStoreID"].nil?
    paramFormatted["subContextID"] = paramHash["dataStoreID"]
  end
  return getCloudmunchData(paramFormatted)          
end

#getInsightReportCards(paramHash) ⇒ Object

getInsightReportCards(paramHash) Get Insight Report Cards from Server Workspace Needed In Reporter Plugins



509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
# File 'lib/cloudmunch_Ruby_sdk_v2/InsightHelper.rb', line 509

def getInsightReportCards(paramHash)
  # /applications/{application_id}/insights/{insight_id}/insight_reports/{insight_report_id}/insight_cards/{insight_card_id}
  paramReportId  = paramHash["reportID"].nil? ? nil : paramHash["reportID"]
  paramInsightID = paramHash["insightID"].nil? ? nil : paramHash["insightID"]

  if paramInsightID.nil? || paramInsightID.empty? || paramReportId.nil? || paramReportId.empty?
    log("DEBUG", "Insight id and report id is needed to gets its report card details")
    return nil
  end

  paramFormatted = Hash.new
  paramFormatted = paramHash
  paramFormatted["context"]      = "insights"
  paramFormatted["subContext"]   = "insight_reports"
  paramFormatted["leafContext"]  = "insight_cards"
  paramFormatted["contextID"]    = paramInsightID
  paramFormatted["subContextID"] = paramReportId
  
  if !paramHash["cardID"].nil?
    paramFormatted["leafContextID"] = paramHash["cardID"]
  end

  return getCloudmunchData(paramFormatted)
end

#getInsightReportDataTemplateHash(reportTypeStr) ⇒ Object

getInsightReportDataTemplateHash(reportTypeStr) Gets the data template Hash that needs to be filled in for a given report type Needed In Reporter Plugins



747
748
749
# File 'lib/cloudmunch_Ruby_sdk_v2/InsightHelper.rb', line 747

def getInsightReportDataTemplateHash(reportTypeStr)

end

#getInsightReportKeyMetrics(paramHash) ⇒ Object

getInsightReportKeyMetrics(paramHash) Get Insight Report Key Metrics from Server Workspace Needed In Reporter Plugins



539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
# File 'lib/cloudmunch_Ruby_sdk_v2/InsightHelper.rb', line 539

def getInsightReportKeyMetrics(paramHash)
  # /applications/{application_id}/insights/{insight_id}/insight_reports/{insight_report_id}/key_metrics/{key_metric_id}
  paramReportId  = paramHash["reportID"].nil? ? nil : paramHash["reportID"]
  paramInsightID = paramHash["insightID"].nil? ? nil : paramHash["insightID"]

  if paramInsightID.nil? || paramInsightID.empty? || paramReportId.nil? || paramReportId.empty?
    log("DEBUG", "Insight id and report id is needed to gets its report key metric details")
    return nil
  end

  paramFormatted = Hash.new
  paramFormatted = paramHash
  paramFormatted["context"]      = "insights"
  paramFormatted["subContext"]   = "insight_reports"
  paramFormatted["leafContext"]  = "key_metrics"
  paramFormatted["contextID"]    = paramInsightID
  paramFormatted["subContextID"] = paramReportId
  
  if !paramHash["keyMetricID"].nil?
    paramFormatted["leafContextID"] = paramHash["keyMetricID"]
  end

  return getCloudmunchData(paramFormatted)
end

#getInsightReportMetaTemplateHash(reportTypeStr) ⇒ Object

getInsightReportMetaTemplateHash(reportTypeStr) Gets the meta template Hash that needs to be filled in for a given report type Needed In Reporter Plugins



756
757
758
# File 'lib/cloudmunch_Ruby_sdk_v2/InsightHelper.rb', line 756

def getInsightReportMetaTemplateHash(reportTypeStr)

end

#getInsightReports(paramHash) ⇒ Object

getInsightReports(paramHash) Get Insight Reports from Server Workspace Needed In Reporter Plugins



482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
# File 'lib/cloudmunch_Ruby_sdk_v2/InsightHelper.rb', line 482

def getInsightReports(paramHash)
  # /applications/{application_id}/insights/{insight_id}/insight_reports/{insight_report_id}
  paramInsightID = paramHash["insightID"].nil? ? nil : paramHash["insightID"]

  if paramInsightID.nil? || paramInsightID.empty?
    log("DEBUG", "Insight id is needed to gets its report details")
    return nil
  end

  paramFormatted = Hash.new
  paramFormatted = paramHash
  paramFormatted["context"]    = "insights"
  paramFormatted["subContext"] = "insight_reports"
  paramFormatted["contextID"]  = paramInsightID
  
  if !paramHash["reportID"].nil?
    paramFormatted["subContextID"] = paramHash["reportID"]
  end

  return getCloudmunchData(paramFormatted)
end

#getInsightReportVisualizationMapTemplateHash(reportTypeStr) ⇒ Object

getInsightReportVisualizationMapTemplateHash(reportTypeStr) Gets the visualization map template Hash that needs to be filled in for a given report type Needed In Reporter Plugins



765
766
767
# File 'lib/cloudmunch_Ruby_sdk_v2/InsightHelper.rb', line 765

def getInsightReportVisualizationMapTemplateHash(reportTypeStr)

end

#getInsights(paramHash) ⇒ Object

getInsights(paramHash) Get Insights from Server Workspace Needed In Reporter Plugins



403
404
405
406
407
408
409
410
411
412
413
414
415
416
# File 'lib/cloudmunch_Ruby_sdk_v2/InsightHelper.rb', line 403

def getInsights(paramHash)
  # /insights/{insight_id}
  paraminsightID = paramHash["insightID"].nil? ? nil : paramHash["insightID"]

  paramFormatted = Hash.new
  paramFormatted = paramHash
  paramFormatted["context"] = "insights"
  
  if !paraminsightID.nil? && !paraminsightID.empty?
      paramFormatted["contextID"]  = paramInsightID
  end    

  return getCloudmunchData(paramFormatted)          
end

#getKeyMetricID(insightID, reportID, keyMetricName) ⇒ Object

getKeyMetricID(insightID, reportID, keyMetricName) Gets Key Metric ID for a given report card <NOTE>



381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
# File 'lib/cloudmunch_Ruby_sdk_v2/InsightHelper.rb', line 381

def getKeyMetricID(insightID, reportID, keyMetricName)
    paramHash = Hash.new
    paramHash["insightID"] = insightID
    paramHash["reportID"] = reportID
    paramHash["filter"] = {"name" => keyMetricName}
    paramHash["count"]  = 1
    paramHash["fields"] = "id" 

    keyMetric = getInsightReportCards(paramHash)
    if keyMetric.nil? || !keyMetric.any?
      log("DEBUG", "Report key metric with name "+keyMetricName+" does not exist")
      return nil
    else
      return keyMetric[0]["id"]
    end
end

#getListOfDatesForADuration(durationUnitNameStr, durationUnitNumber) ⇒ Object

getListOfDatesForADuration(durationUnitNameStr, durationUnitNumber) durationUnitNameStr : days | weeks | months durationUnitNumber : Eg. 1 to N Get List(Array) of Dates (history) for a given duration from current day Needed In Reporter Plugins



706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
# File 'lib/cloudmunch_Ruby_sdk_v2/InsightHelper.rb', line 706

def getListOfDatesForADuration(durationUnitNameStr, durationUnitNumber)
      log("info", __method__.to_s + " method is invoked from InsightsGitHubOrgsReposWithSize")
      $i = 0
      duration_arr = []
      $curr_date = Date.today
      $tmp_unit = nil
      $tmp_days_in_month = nil

      case durationUnitNameStr.downcase
      when "days"
          while $i < durationUnitNumber
              $tmp_unit = $curr_date.strftime("%Y-%m-%d")
              duration_arr[$i] = $tmp_unit
              $curr_date -= 1
              $i += 1
          end
      when "weeks"
          while $i < durationUnitNumber
              $tmp_unit = $curr_date.strftime("%Y-%m-%d")
              duration_arr[$i] = $tmp_unit
              $curr_date -= 7
              $i += 1
          end
      when "months"
          while $i < durationUnitNumber
              $tmp_unit = $curr_date.strftime("%Y-%m-%d")
              $tmp_days_in_month = $curr_date.day
              duration_arr[$i] = $tmp_unit
              $curr_date -= $tmp_days_in_month
              $i += 1
          end
      end

      return duration_arr
end

#getReportCardID(insightID, reportID, cardName) ⇒ Object

getReportCardID(insightID, reportID, cardName) Gets Report Card ID for a given report card <NOTE>



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
# File 'lib/cloudmunch_Ruby_sdk_v2/InsightHelper.rb', line 349

def getReportCardID(insightID, reportID, cardName)
    if insightID.nil? || reportID.nil? || cardName.nil?
      log("DEBUG", "insight id, report id and card name is needed to get report card id")
      return nil
    end

    card = nil
    paramHash = Hash.new
    paramHash["insightID"] = insightID
    paramHash["reportID"] = reportID
    paramHash["filter"] = {"name" => cardName}
    paramHash["count"]  = 1
    paramHash["fields"] = "id" 

    card = getInsightReportCards(paramHash)

    if card.nil? 
      log("DEBUG", "Report with name "+cardName+" does not exist")
      return nil
    elsif (card.kind_of?(Array)) && (card.length.to_i > 0)
      return card[0]["id"]
    else
      log("DEBUG", "Report with name "+cardName+" does not exist")
      return nil
    end
end

#getReportID(insightID, reportName) ⇒ Object

getReportID(insightID, reportName) Gets Report ID for a given report <NOTE>



317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
# File 'lib/cloudmunch_Ruby_sdk_v2/InsightHelper.rb', line 317

def getReportID(insightID, reportName)
    if insightID.nil? || reportName.nil?
      log("DEBUG", "insight id and report name is needed to get report id")
      return nil
    end

    paramHash = Hash.new
    paramHash["insightID"] = insightID
    paramHash["filter"] = {"name" => reportName} 
    paramHash["count"]  = 1
    paramHash["fields"] = "id" 

    report = getInsightReports(paramHash)

    if report.nil? 
      log("DEBUG", "Report with name "+reportName+" does not exist")
      return nil
    elsif (report.kind_of?(Array)) && (report.length.to_i > 0)
      return report[0]["id"]
    else
      log("DEBUG", "Report with name "+reportName+" does not exist")
      return nil
    end
end

#updateInsight(insightID, data) ⇒ Object

updateInsight(insightID, data) Updates Insight Into Server Workspace Needed In Reporter Plugins



569
570
571
572
573
574
575
576
577
578
579
580
581
582
# File 'lib/cloudmunch_Ruby_sdk_v2/InsightHelper.rb', line 569

def updateInsight(insightID, data)
  # /applications/{application_id}/insights/{insight_id}

  if (insightID.nil? || insightID.empty?) && data.nil?
    log("DEBUG", "Insight id and data is needed to be update an existing data store")
    return nil
  end

  paramHash = {}
  paramHash["context"]   = "insights"
  paramHash["contextID"] = insightID
  paramHash["data"]      = data
  return updateCloudmunchData(paramHash)
end

#updateInsightDataStore(insightID, dataStoreID, data) ⇒ Object

updateInsightDataStore(insightID, dataStoreID, data) Updates Insight DataStore Into Server Workspace Needed In Reporter Plugins



590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
# File 'lib/cloudmunch_Ruby_sdk_v2/InsightHelper.rb', line 590

def updateInsightDataStore(insightID, dataStoreID, data)
  # /applications/{application_id}/insights/{insight_id}/datastores/{datastore_id}

  if (insightID.nil? || insightID.empty?) && (dataStoreID.nil? || dataStoreID.empty?) && data.nil?
    log("DEBUG", "Insight id, datastore id and data is needed to be update an existing data store")
    return nil
  end
      paramHash = {}
      paramHash["context"]      = "insights"
      paramHash["contextID"]    = insightID
      paramHash["subContext"]   = "datastores"
      paramHash["subContextID"] = dataStoreID
      paramHash["data"]         = data
      return updateCloudmunchData(paramHash)
end

#updateInsightDataStoreExtract(insightID, dataStoreID, extractID, data) ⇒ Object

updateInsightDataStoreExtract(insightID, dataStoreID, extractID, data) Updates Insight DataStore Extract In Server Workspace Needed In Reporter Plugins



611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
# File 'lib/cloudmunch_Ruby_sdk_v2/InsightHelper.rb', line 611

def updateInsightDataStoreExtract(insightID, dataStoreID, extractID, data)
  # /insights/{insight_id}/datastores/{datastore_id}/extracts/{extract_id}

  if (insightID.nil? || insightID.empty?) && (dataStoreID.nil? || dataStoreID.empty?) && (extractID.nil? || extractID.empty?) && data.nil?
    log("DEBUG", "Insight id, datastore id, extract id and data is needed to be update an existing extract")
    return nil
  end
      paramHash = {}
      paramHash["context"]       = "insights"
      paramHash["contextID"]     = insightID
      paramHash["subContext"]    = "datastores"
      paramHash["subContextID"]  = dataStoreID
      paramHash["leafContext"]   = "extracts"
      paramHash["leafContextID"] = extractID
      paramHash["data"]          = data
      return updateCloudmunchData(paramHash)
end

#updateInsightReport(insightID, reportID, data) ⇒ Object

updateInsightReport(insightID, reportID, data) Updates Insight Report In Server Workspace Needed In Reporter Plugins



634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
# File 'lib/cloudmunch_Ruby_sdk_v2/InsightHelper.rb', line 634

def updateInsightReport(insightID, reportID, data)
  # /applications/{application_id}/insights/{insight_id}/insight_reports/{insight_report_id}

  if (insightID.nil? || insightID.empty?) && (reportID.nil? || reportID.empty?) && data.nil?
    log("DEBUG", "Insight id, report id and data is needed to be update an existing report")
    return nil
  end
      paramHash = {}
      paramHash["context"]      = "insights"
      paramHash["contextID"]    = insightID
      paramHash["subContext"]   = "insight_reports"
      paramHash["subContextID"] = reportID
      paramHash["data"]         = data
      return updateCloudmunchData(paramHash)
end

#updateInsightReportCard(insightID, reportID, cardID, data) ⇒ Object

updateInsightReportCard(insightID, reportID, cardID, data) Updates Insight Report Card In Server Workspace Needed In Reporter Plugins



656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
# File 'lib/cloudmunch_Ruby_sdk_v2/InsightHelper.rb', line 656

def updateInsightReportCard(insightID, reportID, cardID, data)
  # /applications/{application_id}/insights/{insight_id}/insight_reports/{insight_report_id}/insight_cards/{insight_card_id}

  if (insightID.nil? || insightID.empty?) && (reportID.nil? || reportID.empty?) && (cardID.nil? || cardID.empty?) && data.nil?
    log("DEBUG", "Insight id, report id, cardID and data is needed to be update an existing report card")
    return nil
  end

  paramHash = {}
  paramHash["context"]       = "insights"
  paramHash["contextID"]     = insightID
  paramHash["subContext"]    = "insight_reports"
  paramHash["subContextID"]  = reportID
  paramHash["leafContext"]   = "insight_cards"
  paramHash["leafContextID"] = cardID
  paramHash["data"]          = data
  return updateCloudmunchData(paramHash)
end

#updateInsightReportKeyMetric(insightID, reportID, keyMetricID, data) ⇒ Object

updateInsightReportKeyMetric(insightID, reportID, keyMetricID, data) Updates Insight Report KeyMetric In Server Workspace Needed In Reporter Plugins



680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
# File 'lib/cloudmunch_Ruby_sdk_v2/InsightHelper.rb', line 680

def updateInsightReportKeyMetric(insightID, reportID, keyMetricID, data)
  # /applications/{application_id}/insights/{insight_id}/insight_reports/{insight_report_id}/key_metrics/{key_metric_id}

  if (insightID.nil? || insightID.empty?) && (reportID.nil? || reportID.empty?) && (keyMetricID.nil? || keyMetricID.empty?) && data.nil?
    log("DEBUG", "Insight id, report id, keyMetricID and data is needed to be update an existing report key metric")
    return nil
  end

  paramHash = {}
  paramHash["context"]       = "insights"
  paramHash["contextID"]     = insightID
  paramHash["subContext"]    = "insight_reports"
  paramHash["subContextID"]  = reportID
  paramHash["leafContext"]   = "key_metrics"
  paramHash["leafContextID"] = keyMetricID
  paramHash["data"]          = data
  return updateCloudmunchData(paramHash)
end