cloudmunch_sdk 0.7.0 → 1.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.
- checksums.yaml +4 -4
- data/lib/cloudmunch_Ruby_sdk_v2/AppAbstract.rb +60 -71
- data/lib/cloudmunch_Ruby_sdk_v2/AppContext.rb +44 -2
- data/lib/cloudmunch_Ruby_sdk_v2/AssetHelper.rb +127 -0
- data/lib/cloudmunch_Ruby_sdk_v2/CloudmunchConstants.rb +24 -0
- data/lib/cloudmunch_Ruby_sdk_v2/CloudmunchService.rb +88 -546
- data/lib/cloudmunch_Ruby_sdk_v2/ElasticBeanStalkServer.rb +52 -0
- data/lib/cloudmunch_Ruby_sdk_v2/EnvironmentHelper.rb +292 -0
- data/lib/cloudmunch_Ruby_sdk_v2/InsightHelper.rb +770 -0
- data/lib/cloudmunch_Ruby_sdk_v2/IntegrationHelper.rb +69 -0
- data/lib/cloudmunch_Ruby_sdk_v2/PluginLoaderAbstract.rb +140 -0
- data/lib/cloudmunch_Ruby_sdk_v2/PluginReporterAbstract.rb +141 -0
- data/lib/cloudmunch_Ruby_sdk_v2/RoleHelper.rb +170 -0
- data/lib/cloudmunch_Ruby_sdk_v2/Server.rb +77 -0
- data/lib/cloudmunch_Ruby_sdk_v2/ServerHelper.rb +284 -0
- data/lib/cloudmunch_Ruby_sdk_v2/ServiceProvider.rb +10 -2
- data/lib/cloudmunch_Ruby_sdk_v2/Util.rb +30 -35
- data/lib/cloudmunch_Ruby_sdk_v2/version.rb +1 -1
- metadata +13 -11
- data/lib/cloudmunch_Ruby_sdk_v2/templates/costview_meta.json +0 -22
- data/lib/cloudmunch_Ruby_sdk_v2/templates/coverageview_meta.json +0 -34
- data/lib/cloudmunch_Ruby_sdk_v2/templates/defecttrendview_meta.json +0 -67
- data/lib/cloudmunch_Ruby_sdk_v2/templates/ilityview_meta.json +0 -66
- data/lib/cloudmunch_Ruby_sdk_v2/templates/inboundoutboundview_meta.json +0 -67
- data/lib/cloudmunch_Ruby_sdk_v2/templates/riskview_meta.json +0 -19
- data/lib/cloudmunch_Ruby_sdk_v2/templates/scopeview_meta.json +0 -60
- data/lib/cloudmunch_Ruby_sdk_v2/templates/timeview_meta.json +0 -60
- data/lib/cloudmunch_Ruby_sdk_v2/templates/velocityview_meta.json +0 -22
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
###
|
3
|
+
### (c) CloudMunch Inc.
|
4
|
+
### All Rights Reserved
|
5
|
+
### Un-authorized copying of this file, via any medium is strictly prohibited
|
6
|
+
### Proprietary and confidential
|
7
|
+
###
|
8
|
+
### ganesan@cloudmunch.com
|
9
|
+
###
|
10
|
+
|
11
|
+
$LOAD_PATH << '.'
|
12
|
+
|
13
|
+
class ElasticBeanStalkServer < Server
|
14
|
+
attr_accessor :servername
|
15
|
+
attr_accessor :envname
|
16
|
+
attr_accessor :bucketname
|
17
|
+
attr_accessor :applicationName
|
18
|
+
attr_accessor :templateName
|
19
|
+
attr_accessor :description
|
20
|
+
attr_accessor :dns
|
21
|
+
attr_accessor :appName
|
22
|
+
attr_accessor :deployTempLoc
|
23
|
+
attr_accessor :assettype
|
24
|
+
attr_accessor :status
|
25
|
+
attr_accessor :starttime
|
26
|
+
attr_accessor :provider
|
27
|
+
attr_accessor :provider
|
28
|
+
attr_accessor :region
|
29
|
+
attr_accessor :cmserver
|
30
|
+
attr_accessor :assetname
|
31
|
+
|
32
|
+
def initialize(appContext)
|
33
|
+
@servername = ""
|
34
|
+
@envname = ""
|
35
|
+
@bucketname = ""
|
36
|
+
@applicationName = ""
|
37
|
+
@templateName = ""
|
38
|
+
@description = ""
|
39
|
+
@dns = ""
|
40
|
+
@appName = ""
|
41
|
+
@deployTempLoc = ""
|
42
|
+
@assettype = ""
|
43
|
+
@status = ""
|
44
|
+
@starttime = ""
|
45
|
+
@provider = ""
|
46
|
+
@region = ""
|
47
|
+
@cmserver = ""
|
48
|
+
@assetname = ""
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,292 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
###
|
3
|
+
### (c) CloudMunch Inc.
|
4
|
+
### All Rights Reserved
|
5
|
+
### Un-authorized copying of this file, via any medium is strictly prohibited
|
6
|
+
### Proprietary and confidential
|
7
|
+
###
|
8
|
+
### ganesan@cloudmunch.com
|
9
|
+
###
|
10
|
+
|
11
|
+
$LOAD_PATH << '.'
|
12
|
+
require 'json'
|
13
|
+
require_relative "CloudmunchConstants"
|
14
|
+
|
15
|
+
class AssetHelper
|
16
|
+
include CloudmunchService
|
17
|
+
include Util
|
18
|
+
|
19
|
+
@appContext = nil
|
20
|
+
@cmDataManager = nil
|
21
|
+
@logHelper = nil
|
22
|
+
@defaultRole = "Area_51"
|
23
|
+
|
24
|
+
def initialize(appContext)
|
25
|
+
@appContext = appContext
|
26
|
+
@cloudmunchDataService = CloudmunchService.new
|
27
|
+
@roleHelper = RoleHelper.new
|
28
|
+
end
|
29
|
+
|
30
|
+
# ##
|
31
|
+
# ##
|
32
|
+
# ## @param Json Object filterData In the format {"filterfield":"=value"}
|
33
|
+
# ## @return json object environmentdetails
|
34
|
+
# ##
|
35
|
+
# ##
|
36
|
+
def getExistingEnvironments(filterData)
|
37
|
+
paramHash = {}
|
38
|
+
if !filterData.nil?
|
39
|
+
paramHash["filter"] = filterData.to_json
|
40
|
+
end
|
41
|
+
|
42
|
+
serverUrl = @appContext.getMasterURL() + "/applications/" + @appContext.getProject() + "/environments"
|
43
|
+
envResult = @cloudmunchDataService.getDataForContext(serverUrl, @appContext.getAPIJey(), paramHash)
|
44
|
+
|
45
|
+
if envResult == nil then
|
46
|
+
log("ERROR", "Unable to get data from cloudmunch")
|
47
|
+
return nil
|
48
|
+
else
|
49
|
+
envResult = JSON.parse(envResult)
|
50
|
+
envData = envResult["data"]
|
51
|
+
if envData.nil? then
|
52
|
+
log("ERROR", "environments do not exist")
|
53
|
+
return nil
|
54
|
+
else
|
55
|
+
return envData
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# ###
|
61
|
+
# ###
|
62
|
+
# ### @param String environmentID
|
63
|
+
# ### @param Json Object filterData In the format {"filterfield":"=value"}
|
64
|
+
# ### @return json object environmentdetails
|
65
|
+
# ###
|
66
|
+
# ###
|
67
|
+
def getEnvironment(environmentID, filterData)
|
68
|
+
paramHash = {}
|
69
|
+
if !filterData.nil?
|
70
|
+
paramHash["filter"] = filterData.to_json
|
71
|
+
end
|
72
|
+
serverUrl = @appContext.getMasterURL() + "/applications/" + @appContext.getProject() + "/environments/" + environmentID
|
73
|
+
envResult = @cloudmunchDataService.getDataForContext(serverUrl, @appContext.getAPIJey(), paramHash)
|
74
|
+
|
75
|
+
if envResult == nil then
|
76
|
+
log("ERROR", "Unable to get data from cloudmunch")
|
77
|
+
return nil
|
78
|
+
else
|
79
|
+
envResult = JSON.parse(envResult)
|
80
|
+
envData = envResult["data"]
|
81
|
+
if envData.nil? then
|
82
|
+
log("DEBUG", "Environment does not exist")
|
83
|
+
return nil
|
84
|
+
else
|
85
|
+
return envData
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# ###
|
91
|
+
# ###
|
92
|
+
# ### @param string environmentName Name of the environment
|
93
|
+
# ### @param string environmentStatus Environment status ,valid values are success,failed,in-progress
|
94
|
+
# ### @param array environmentData Array of environment properties
|
95
|
+
# ###
|
96
|
+
def addEnvironment(environmentName, environmentStatus, environmentData)
|
97
|
+
if environmentName.empty? || environmentStatus.empty? then
|
98
|
+
log("ERROR", "Environment name ,status and type need to be provided")
|
99
|
+
return false
|
100
|
+
end
|
101
|
+
|
102
|
+
statusArray = [STATUS_CREATION_IN_PROGRESS, STATUS_RUNNING, STATUS_STOPPED, STATUS_STOPPED_WITH_ERRORS, STATUS_RUNNING_WITH_WARNINGS, STATUS_ACTION_IN_PROGRESS]
|
103
|
+
if !statusArray.include?(assetStatus) then
|
104
|
+
log("ERROR", "Invalid status sent. Allowed values " + STATUS_CREATION_IN_PROGRESS + "," + STATUS_RUNNING + "," + STATUS_STOPPED + "," + STATUS_STOPPED_WITH_ERRORS + "," STATUS_RUNNING_WITH_WARNINGS + "," + STATUS_ACTION_IN_PROGRESS)
|
105
|
+
return false
|
106
|
+
end
|
107
|
+
|
108
|
+
environmentData["name"] = environmentName
|
109
|
+
environmentData["status"] = environmentStatus
|
110
|
+
|
111
|
+
serverUrl = @appContext.getMasterURL() + "/applications/" + @appContext.getProject() + "/environments/"
|
112
|
+
retResult = @cloudmunchDataService.updateDataForContext(serverUrl, @appContext.getAPIKey(), environmentData)
|
113
|
+
|
114
|
+
if retResult == nil then
|
115
|
+
return nil
|
116
|
+
else
|
117
|
+
retResult = JSON.parse(retResult)
|
118
|
+
retData = retResult["data"]
|
119
|
+
if retData.nil? then
|
120
|
+
return nil
|
121
|
+
else
|
122
|
+
return retData
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
# ###
|
128
|
+
# ###
|
129
|
+
# ### @param String Environment ID
|
130
|
+
# ### @param JsonObject Environment Data
|
131
|
+
# ###
|
132
|
+
def updateEnvironment(environmentID, environmentData, comment)
|
133
|
+
serverUrl = @appContext.getMasterURL() + "/applications/" + @appContext.getProject() + "/environments/" + environmentID
|
134
|
+
retResult = @cloudmunchDataService.updateDataForContext(serverUrl, @appContext.getAPIKey(), environmentData)
|
135
|
+
end
|
136
|
+
|
137
|
+
# ###
|
138
|
+
# ###
|
139
|
+
# ### @param String Environment ID
|
140
|
+
# ### @param URL Environment Data
|
141
|
+
# ###
|
142
|
+
def updateEnvironmentURL(environmentID, environmentURL)
|
143
|
+
if environmentURL.nil? || environmentURL.empty then
|
144
|
+
log("ERROR", "Environment URL is not provided to update environment details")
|
145
|
+
return false
|
146
|
+
else
|
147
|
+
comment = "Setting application URL";
|
148
|
+
paramHash = {}
|
149
|
+
paramHash["application_url"] = environmentURL
|
150
|
+
updateEnvironment(environmentID, paramHash, comment);
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
# ###
|
155
|
+
# ###
|
156
|
+
# ### @param String Environment ID
|
157
|
+
# ### @param URL Environment Data
|
158
|
+
# ###
|
159
|
+
def updateEnvironmentBuildVersion(environmentID, buildNumber)
|
160
|
+
if buildNumber.nil? || buildNumber.empty then
|
161
|
+
log("ERROR", "Build Number is not provided to update environment details")
|
162
|
+
return false
|
163
|
+
else
|
164
|
+
comment = "Setting application build version";
|
165
|
+
paramHash = {}
|
166
|
+
paramInnerHash = {}
|
167
|
+
paramInnerHash["version"] = ""
|
168
|
+
paramInnerHash["build"] = buildNumber
|
169
|
+
paramHash["application"] = paramInnerHash
|
170
|
+
updateEnvironment(environmentID, paramHash, comment);
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
# ###
|
175
|
+
# ###
|
176
|
+
# ### @param String Environment ID
|
177
|
+
# ### @param Array AssetArray
|
178
|
+
# ### @param String Role Id
|
179
|
+
# ###
|
180
|
+
def updateAsset(environmentID, assetHash, roleID)
|
181
|
+
if assetHash.nil? || assetHash.empty? then
|
182
|
+
log("DEBUG","An array of asset ids are excpected for updating asset details to an environment")
|
183
|
+
return false
|
184
|
+
end
|
185
|
+
|
186
|
+
if !assetHash.is_h? then
|
187
|
+
log("INFO", "Role is not provided, creating a default role with name " + @defaultRole )
|
188
|
+
return false
|
189
|
+
end
|
190
|
+
|
191
|
+
if roleID.nil? || roleID.empty? then
|
192
|
+
filter = '{"name":"' + @defaultRole + '"}'
|
193
|
+
defaultRoleDetails = @roleHelper.getExistingRoles(filter)
|
194
|
+
|
195
|
+
if defaultRoleDetails.empty? then
|
196
|
+
log("INFO", "Role is not provided, creating a default role with name " + @defaultRole )
|
197
|
+
newRoleDetails = @roleHelper.addRole(@defaultRole)
|
198
|
+
roleID = newRoleDetails.id
|
199
|
+
paramHash = {}
|
200
|
+
paramInnerHash = {}
|
201
|
+
paramDataHash = {}
|
202
|
+
paramDataHash["id"] = roleID
|
203
|
+
paramDataHash["name"] = @defaultRole
|
204
|
+
paramDataHash["assets"] = assetHash
|
205
|
+
paramInnerHash[roleID] = paramDataHash
|
206
|
+
paramHash["tiers"] = paramInnerHash
|
207
|
+
else
|
208
|
+
log("INFO", "Role is not provided, linking with default role : " + @defaultRole)
|
209
|
+
roleID = defaultRoleDetails[0]["id"]
|
210
|
+
paramHash = {}
|
211
|
+
paramInnerHash = {}
|
212
|
+
paramDataHash = {}
|
213
|
+
paramDataHash["id"] = roleID
|
214
|
+
paramDataHash["name"] = '{$tiers/' + roleID + '.name}'
|
215
|
+
paramDataHash["assets"] = assetHash
|
216
|
+
paramInnerHash[roleID] = paramDataHash
|
217
|
+
paramHash["tiers"] = paramInnerHash
|
218
|
+
end
|
219
|
+
else
|
220
|
+
paramHash = {}
|
221
|
+
paramInnerHash = {}
|
222
|
+
paramDataHash = {}
|
223
|
+
paramDataHash["id"] = roleID
|
224
|
+
paramDataHash["name"] = @defaultRole
|
225
|
+
paramDataHash["assets"] = assetHash
|
226
|
+
paramInnerHash[roleID] = paramDataHash
|
227
|
+
paramHash["tiers"] = paramInnerHash
|
228
|
+
end
|
229
|
+
|
230
|
+
comment = "Updating role asset mapping"
|
231
|
+
updateEnvironment(environmentID, paramHash, comment)
|
232
|
+
end
|
233
|
+
|
234
|
+
# ###
|
235
|
+
# ###
|
236
|
+
# ### @param String environmentID
|
237
|
+
# ### @param array key value pairs to be updated to environment details
|
238
|
+
# ###
|
239
|
+
def updateVariables(environmentID, envVariables)
|
240
|
+
if environmentID.nil? then
|
241
|
+
log("DEBUG", "Environment id value is needed for variables update on an environment")
|
242
|
+
else
|
243
|
+
variablesHash = {}
|
244
|
+
variablesHash["variables"] = envVariables
|
245
|
+
comment = "Updating variables"
|
246
|
+
updateEnvironment(environmentID, variablesHash, comment)
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
# ###
|
251
|
+
# ###
|
252
|
+
# ### @param String Environment ID
|
253
|
+
# ### @param String Environment status
|
254
|
+
# ###
|
255
|
+
def updateStatus(environmentID, status)
|
256
|
+
statusArray = [::STATUS_CREATION_IN_PROGRESS, ::STATUS_RUNNING, ::STATUS_STOPPED, ::STATUS_STOPPED_WITH_ERRORS, ::STATUS_RUNNING_WITH_WARNINGS, ::STATUS_ACTION_IN_PROGRESS]
|
257
|
+
if !statusArray.include?(status) then
|
258
|
+
log("ERROR", "Invalid status, valid values are " + ::STATUS_CREATION_IN_PROGRESS + "," + ::STATUS_RUNNING + "," + ::STATUS_STOPPED + "," + ::STATUS_STOPPED_WITH_ERRORS + "," + ::STATUS_RUNNING_WITH_WARNINGS + "," + ::STATUS_ACTION_IN_PROGRESS)
|
259
|
+
return false
|
260
|
+
end
|
261
|
+
|
262
|
+
statusHash = {}
|
263
|
+
statusHash["status"] = status
|
264
|
+
updateEnvironment(environmentID, statusHash)
|
265
|
+
end
|
266
|
+
|
267
|
+
# ###
|
268
|
+
# ### Checks if Environment exists in cloudmunch.
|
269
|
+
# ### @param string $environmentID
|
270
|
+
# ### @return boolean
|
271
|
+
# ###
|
272
|
+
def checkIfEnvironmentExists(environmentID)
|
273
|
+
serverUrl = @appContext.getMasterURL() + "/applications/" + @appContext.getProject() + "/environments/" + environmentID
|
274
|
+
|
275
|
+
envResult = @cloudmunchDataService.getDataForContext(serverUrl, @appContext.getAPIKey(), "")
|
276
|
+
if envResult == nil then
|
277
|
+
log("DEBUG", "Could not retreive data from cloudmunch")
|
278
|
+
return nil
|
279
|
+
else
|
280
|
+
envResult = JSON.parse(envResult)
|
281
|
+
envData = envResult["data"]
|
282
|
+
if envData.nil? then
|
283
|
+
log("ERROR", "Environment does not exist")
|
284
|
+
return false
|
285
|
+
else
|
286
|
+
return true
|
287
|
+
end
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
|
292
|
+
end
|
@@ -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"] = "insights"
|
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"] = "insights"
|
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"] = "insights"
|
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"] = "insights"
|
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"] = "insights"
|
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"] = "insights"
|
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"] = "insights"
|
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"] = "insights"
|
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"] = "insights"
|
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"] = "insights"
|
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"] = "insights"
|
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"] = "insights"
|
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"] = "insights"
|
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"] = "insights"
|
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"] = "insights"
|
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"] = "insights"
|
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"] = "insights"
|
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"] = "insights"
|
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
|
+
|