Method: InsightHelper#createInsightReportKeyMetric

Defined in:
lib/cloudmunch_Ruby_sdk_v2/InsightHelper.rb

#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