cloudmunch_sdk 0.7.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 235f0fb0275fa62d48de2cd67b378331beb99e02
|
4
|
+
data.tar.gz: 3acb35f525fe837908a1dfb8671118d7da5ac605
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4926e7a3b77dd1ba611f9d199bab152312ab70bb233383f8fa2217ba16f1dc7f1f373f2caefd32628f586e23d052b9ecd03ba5ccd5fdf4f7c82e360b526e0964
|
7
|
+
data.tar.gz: bcdd1c1925b55321135008b1f6e35f5a251f9ff8f72582d4aab28300e21f0f1c37aa158439d658120ec578ff403eaa9f93cee6bba621b1e03cc15e1b18662382
|
@@ -2,22 +2,21 @@
|
|
2
2
|
$LOAD_PATH << '.'
|
3
3
|
|
4
4
|
require_relative "CloudmunchService"
|
5
|
+
require_relative "InsightHelper"
|
5
6
|
require_relative "Util"
|
6
7
|
require_relative "ServiceProvider"
|
7
8
|
require_relative "AppContext"
|
8
9
|
|
9
10
|
class AppAbstract
|
10
11
|
include CloudmunchService
|
12
|
+
include InsightHelper
|
11
13
|
include Util
|
12
14
|
|
13
|
-
#@@config_path = ENV["SDK_CONFIG_PATH"]+"/sdk_config.json"
|
14
15
|
@@config = nil
|
15
16
|
|
16
17
|
def initialize(param = nil)
|
17
|
-
@domain, @project, @logfile = "", "", ""
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
20
|
def logInit(log_level)
|
22
21
|
@logger = @logger ? @logger : Util.logInit()
|
23
22
|
@log_level = log_level
|
@@ -52,106 +51,96 @@ class AppAbstract
|
|
52
51
|
@integration_input=JSON.load(integrations)
|
53
52
|
createAppContext();
|
54
53
|
return @json_input
|
55
|
-
end
|
54
|
+
end
|
56
55
|
|
57
56
|
def createAppContext()
|
57
|
+
@appContext = AppContext.new(@var_input)
|
58
|
+
end
|
58
59
|
|
59
|
-
|
60
|
-
|
60
|
+
def getAppContext()
|
61
|
+
return @appContext
|
61
62
|
end
|
62
63
|
|
64
|
+
# def getCloudmunchContext(context)
|
65
|
+
# begin
|
66
|
+
# return @@config[context+"_context"]
|
67
|
+
# rescue
|
68
|
+
# return false
|
69
|
+
# end
|
70
|
+
# end
|
71
|
+
|
63
72
|
def getCloudmunchService()
|
64
|
-
# @cloudmunchservice = @cloudmunchservice ? @cloudmunchservice : CloudmunchService.new(@var_input)
|
65
|
-
# @cloudmunchservice = @cloudmunchservice ? @cloudmunchservice : CloudmunchService.initialize(@appContext)
|
66
73
|
@cloudmunchservice = self.extend(CloudmunchService)
|
67
74
|
return @cloudmunchservice
|
68
|
-
end
|
69
|
-
def openJSONFile(fileNameWithPath)
|
70
|
-
Util.openJSONFile(fileNameWithPath)
|
71
75
|
end
|
72
76
|
|
73
|
-
def
|
74
|
-
|
75
|
-
|
77
|
+
def getInsightHelper()
|
78
|
+
@insightHelper = self.extend(InsightHelper)
|
79
|
+
return @insightHelper
|
80
|
+
end
|
76
81
|
|
77
82
|
def getIntegrationDetails(param = nil)
|
78
|
-
#@json_input = @json_input ? @json_input : getJSONArgs()
|
79
83
|
serviceProvider = ServiceProvider.new(@json_input["providername"])
|
80
84
|
serviceProvider.load_data(@integration_input)
|
81
85
|
return serviceProvider
|
82
86
|
end
|
83
|
-
|
84
|
-
def getAppContext()
|
85
|
-
return @appContext
|
86
|
-
end
|
87
|
-
|
88
|
-
def getDataContextFromCMDB(param)
|
89
|
-
appContext = getAppContext()
|
90
|
-
params = {
|
91
|
-
"username" => @@config['username'],
|
92
|
-
"customcontext" => param["job"] + "_" + param["context"],
|
93
|
-
"action" => "listcustomcontext"
|
94
|
-
}
|
95
|
-
param.delete("context")
|
96
|
-
params = param.merge(params)
|
97
|
-
|
98
|
-
return CloudmunchService.getDataContext(appContext.get_data('masterurl'), @@config["endpoint"], params)
|
99
|
-
end
|
100
|
-
|
101
|
-
def updateDataContextToCMDB(param)
|
102
|
-
appContext = getAppContext()
|
103
|
-
params = {
|
104
|
-
"username" => @@config['username'],
|
105
|
-
"customcontext" => param["job"] + "_" + param["context"],
|
106
|
-
"action" => "updatecustomcontext"
|
107
|
-
}
|
108
|
-
param.delete("context")
|
109
|
-
params = param.merge(params)
|
110
|
-
return CloudmunchService.updateDataContext(appContext.get_data('masterurl'), @@config['endpoint'], params)
|
111
|
-
end
|
112
|
-
|
113
|
-
|
114
|
-
def getCMContext(context)
|
115
|
-
begin
|
116
|
-
return @@config[context+"_context"]
|
117
|
-
rescue
|
118
|
-
return false
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
def getTemplate(template_name)
|
123
|
-
begin
|
124
|
-
Util.getTemplate(template_name)
|
125
|
-
rescue
|
126
|
-
return false
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
def load_config()
|
131
|
-
@@config = openJSONFile(@@config_path)
|
132
|
-
end
|
133
87
|
|
134
88
|
def initializeApp()
|
135
|
-
#puts "initializeApp from AppAbstract"
|
136
89
|
end
|
137
90
|
|
138
91
|
def process()
|
139
|
-
#puts "process func from AppAbstract"
|
140
92
|
end
|
141
93
|
|
142
94
|
def cleanupApp()
|
143
95
|
log("INFO", "\nExiting app")
|
144
|
-
#puts "cleanupApp from AppAbstract"
|
145
96
|
end
|
146
97
|
|
147
98
|
def start()
|
148
|
-
# load_config is commented out as this config file is not required now
|
149
|
-
#load_config()
|
150
99
|
initializeApp()
|
151
100
|
process()
|
152
101
|
cleanupApp()
|
153
102
|
end
|
154
103
|
|
155
|
-
|
104
|
+
# def openJSONFile(fileNameWithPath)
|
105
|
+
# Util.openJSONFile(fileNameWithPath)
|
106
|
+
# end
|
107
|
+
|
108
|
+
# def generateReport(reportFilename, reportString)
|
109
|
+
# Util.generateReport(reportFilename, reportString)
|
110
|
+
# end
|
111
|
+
|
112
|
+
# def getDataContextFromCMDB(param)
|
113
|
+
# appContext = getAppContext()
|
114
|
+
# params = {
|
115
|
+
# "username" => @@config['username'],
|
116
|
+
# "customcontext" => param["job"] + "_" + param["context"],
|
117
|
+
# "action" => "listcustomcontext"
|
118
|
+
# }
|
119
|
+
# param.delete("context")
|
120
|
+
# params = param.merge(params)
|
121
|
+
|
122
|
+
# return CloudmunchService.getDataContext(appContext.get_data('masterurl'), @@config["endpoint"], params)
|
123
|
+
# end
|
124
|
+
|
125
|
+
# def updateDataContextToCMDB(param)
|
126
|
+
# appContext = getAppContext()
|
127
|
+
# params = {
|
128
|
+
# "username" => @@config['username'],
|
129
|
+
# "customcontext" => param["job"] + "_" + param["context"],
|
130
|
+
# "action" => "updatecustomcontext"
|
131
|
+
# }
|
132
|
+
# param.delete("context")
|
133
|
+
# params = param.merge(params)
|
134
|
+
# return CloudmunchService.updateDataContext(appContext.get_data('masterurl'), @@config['endpoint'], params)
|
135
|
+
# end
|
136
|
+
|
137
|
+
# def getTemplate(template_name)
|
138
|
+
# begin
|
139
|
+
# Util.getTemplate(template_name)
|
140
|
+
# rescue
|
141
|
+
# return false
|
142
|
+
# end
|
143
|
+
# end
|
144
|
+
|
156
145
|
|
157
146
|
end
|
@@ -1,8 +1,49 @@
|
|
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
|
+
###
|
1
10
|
|
2
|
-
|
11
|
+
$LOAD_PATH << '.'
|
12
|
+
|
3
13
|
class AppContext
|
14
|
+
attr_accessor :masterurl
|
15
|
+
attr_accessor :cloudproviders
|
16
|
+
attr_accessor :domainName
|
17
|
+
attr_accessor :project
|
18
|
+
attr_accessor :job
|
19
|
+
attr_accessor :workspaceLocation
|
20
|
+
attr_accessor :archiveLocation
|
21
|
+
attr_accessor :stepid
|
22
|
+
attr_accessor :targetServer
|
23
|
+
attr_accessor :integrations
|
24
|
+
attr_accessor :reportsLocation
|
25
|
+
attr_accessor :runnumber
|
26
|
+
attr_accessor :apikey
|
27
|
+
attr_accessor :stepname
|
28
|
+
attr_accessor :environmentId
|
29
|
+
|
4
30
|
|
5
31
|
def initialize(param)
|
32
|
+
@masterurl = ""
|
33
|
+
@cloudproviders = ""
|
34
|
+
@domainName = ""
|
35
|
+
@project = ""
|
36
|
+
@job = ""
|
37
|
+
@workspaceLocation = ""
|
38
|
+
@archiveLocation = ""
|
39
|
+
@stepid = ""
|
40
|
+
@targetServer=""
|
41
|
+
@integrations=""
|
42
|
+
@reportsLocation=""
|
43
|
+
@runnumber=""
|
44
|
+
@apikey=""
|
45
|
+
@stepname=""
|
46
|
+
@environmentId=""
|
6
47
|
load_data(param)
|
7
48
|
end
|
8
49
|
|
@@ -14,4 +55,5 @@ class AppContext
|
|
14
55
|
@AppContextParams[keyname]
|
15
56
|
end
|
16
57
|
|
17
|
-
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,127 @@
|
|
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
|
+
|
23
|
+
def initialize(appContext)
|
24
|
+
@appContext = appContext
|
25
|
+
@cloudmunchDataService = CloudmunchService.new
|
26
|
+
end
|
27
|
+
|
28
|
+
def getAsset(assetID, filterData)
|
29
|
+
paramHash = {}
|
30
|
+
if !filterData.nil?
|
31
|
+
paramHash["filter"] = filterData.to_json
|
32
|
+
end
|
33
|
+
serverUrl = @appContext.getMasterURL() + "/applications/" + @appContext.getProject() + "/assets/" + assetID
|
34
|
+
assetResult = @cloudmunchDataService.getDataForContext(serverUrl, @appContext.getAPIJey(), paramHash)
|
35
|
+
|
36
|
+
if assetResult == nil then
|
37
|
+
log("ERROR", "Unable to get data from cloudmunch")
|
38
|
+
return nil
|
39
|
+
else
|
40
|
+
assetResult = JSON.parse(assetResult)
|
41
|
+
assetData = assetResult["data"]
|
42
|
+
if assetData.nil? then
|
43
|
+
log("ERROR", "Asset does not exist")
|
44
|
+
return nil
|
45
|
+
else
|
46
|
+
return assetData
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def addAsset(assetName, assetType, assetStatus, assetExternalRef, assetData)
|
52
|
+
if assetName.empty? || assetType.empty? || assetStatus.empty? then
|
53
|
+
log("ERROR", "Asset name ,status and type need to be provided")
|
54
|
+
return false
|
55
|
+
end
|
56
|
+
|
57
|
+
statusArray = [::STATUS_RUNNING, ::STATUS_STOPPED, ::STATUS_NIL]
|
58
|
+
if !statusArray.include?(assetStatus) then
|
59
|
+
log("ERROR", "Invalid status sent. Allowed values " + ::STATUS_RUNNING, ::STATUS_STOPPED, ::STATUS_NIL)
|
60
|
+
return false
|
61
|
+
end
|
62
|
+
|
63
|
+
assetData["name"] = assetName
|
64
|
+
assetData["type"] = assetType
|
65
|
+
assetData["status"] = assetStatus
|
66
|
+
assetData["external_reference"] = assetExternalRef
|
67
|
+
|
68
|
+
serverUrl = @appContext.getMasterURL() + "/applications/" + @appContext.getProject() + "/assets/"
|
69
|
+
retResult = @cloudmunchDataService.updateDataForContext(serverUrl, @appContext.getAPIKey(), assetData)
|
70
|
+
|
71
|
+
if retResult == nil then
|
72
|
+
return nil
|
73
|
+
else
|
74
|
+
retResult = JSON.parse(retResult)
|
75
|
+
retData = retResult["data"]
|
76
|
+
if retData.nil? then
|
77
|
+
return nil
|
78
|
+
else
|
79
|
+
return retData
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
def updateAsset(assetID, assetData)
|
87
|
+
serverUrl = @appContext.getMasterURL() + "/applications/" + @appContext.getProject() + "/assets/" + assetID
|
88
|
+
@cloudmunchDataService.updateDataForContext(serverUrl, @appContext.getAPIKey(), assetData)
|
89
|
+
end
|
90
|
+
|
91
|
+
def deleteAsset(assetID)
|
92
|
+
serverUrl = @appContext.getMasterURL() + "/applications/" + @appContext.getProject() + "/assets/" + assetID
|
93
|
+
@cloudmunchDataService.deleteDataForContext(serverUrl, @appContext.getAPIKey())
|
94
|
+
end
|
95
|
+
|
96
|
+
def updateStatus(assetID, status)
|
97
|
+
statusArray = [::STATUS_RUNNING, ::STATUS_STOPPED, ::STATUS_NIL]
|
98
|
+
if !statusArray.include?(status) then
|
99
|
+
log("ERROR", "Invalid status")
|
100
|
+
return false
|
101
|
+
end
|
102
|
+
|
103
|
+
assetData = {}
|
104
|
+
assetData["status"] = status
|
105
|
+
updateAsset(assetID, assetData)
|
106
|
+
end
|
107
|
+
|
108
|
+
def checkIfAssetExists(assetID)
|
109
|
+
serverUrl = @appContext.getMasterURL() + "/applications/" + @appContext.getProject() + "/assets/" + assetID
|
110
|
+
|
111
|
+
assetResult = @cloudmunchDataService.getDataForContext(serverUrl, @appContext.getAPIKey(), "")
|
112
|
+
if assetResult == nil then
|
113
|
+
return nil
|
114
|
+
else
|
115
|
+
assetResult = JSON.parse(assetResult)
|
116
|
+
assetData = assetResult["data"]
|
117
|
+
if assetData.nil? then
|
118
|
+
log("ERROR", "Asset does not exist")
|
119
|
+
return false
|
120
|
+
else
|
121
|
+
return true
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
|
127
|
+
end
|
@@ -0,0 +1,24 @@
|
|
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 CloudmunchConstants
|
14
|
+
#Assets
|
15
|
+
STATUS_RUNNING = 'running'
|
16
|
+
STATUS_STOPPED = 'stopped'
|
17
|
+
STATUS_NIL = 'NIL'
|
18
|
+
|
19
|
+
#Environments
|
20
|
+
STATUS_RUNNING_WITH_WARNING = 'running_with_warning'
|
21
|
+
STATUS_STOPPED_WITH_ERRORS = 'stopped_with_errors'
|
22
|
+
STATUS_ACTION_IN_PROGRESS = 'action_in_progress'
|
23
|
+
STATUS_CREATION_IN_PROGRESS = 'creation_in_progress'
|
24
|
+
end
|
@@ -7,411 +7,72 @@ require 'json'
|
|
7
7
|
require_relative "Util"
|
8
8
|
|
9
9
|
module CloudmunchService
|
10
|
-
include Util
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
return dataStore[0]["id"]
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def getReportID(insightID, reportName)
|
38
|
-
if insightID.nil? || reportName.nil?
|
39
|
-
log("DEBUG", "insight id and report name is needed to get report id")
|
40
|
-
return nil
|
41
|
-
end
|
42
|
-
|
43
|
-
paramHash = Hash.new
|
44
|
-
paramHash["insightID"] = insightID
|
45
|
-
paramHash["filter"] = {"name" => reportName}
|
46
|
-
paramHash["count"] = 1
|
47
|
-
paramHash["fields"] = "id"
|
48
|
-
|
49
|
-
report = getInsightReports(paramHash)
|
50
|
-
if report.nil? || !report.any?
|
51
|
-
log("DEBUG", "Report with name "+reportName+" does not exist")
|
52
|
-
return nil
|
53
|
-
else
|
54
|
-
return report[0]["id"]
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def getExtractID(insightID, dataStoreID, extractName)
|
59
|
-
if insightID.nil? || dataStoreID.nil? || extractName.nil?
|
60
|
-
log("DEBUG", "insight id, datastore id and extract name is needed to get extract id")
|
61
|
-
return nil
|
62
|
-
end
|
63
|
-
|
64
|
-
extract = nil
|
65
|
-
paramHash = Hash.new
|
66
|
-
paramHash["insightID"] = insightID
|
67
|
-
paramHash["dataStoreID"] = dataStoreID
|
68
|
-
paramHash["filter"] = {"name" => extractName}
|
69
|
-
paramHash["count"] = 1
|
70
|
-
paramHash["fields"] = "id"
|
71
|
-
|
72
|
-
extract = getInsightDataStoreExtracts(paramHash)
|
73
|
-
if extract.nil? || !extract.any?
|
74
|
-
log("DEBUG", "Data store with name "+extractName+" does not exist")
|
75
|
-
return nil
|
76
|
-
else
|
77
|
-
return extract[0]["id"]
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def getReportCardID(insightID, reportID, cardName)
|
82
|
-
if insightID.nil? || reportID.nil? || cardName.nil?
|
83
|
-
log("DEBUG", "insight id, report id and card name is needed to get report card id")
|
84
|
-
return nil
|
85
|
-
end
|
86
|
-
|
87
|
-
card = nil
|
88
|
-
paramHash = Hash.new
|
89
|
-
paramHash["insightID"] = insightID
|
90
|
-
paramHash["reportID"] = reportID
|
91
|
-
paramHash["filter"] = {"name" => cardName}
|
92
|
-
paramHash["count"] = 1
|
93
|
-
paramHash["fields"] = "id"
|
94
|
-
|
95
|
-
card = getInsightReportCards(paramHash)
|
96
|
-
if card.nil? || !card.any?
|
97
|
-
log("DEBUG", "Report with name "+cardName+" does not exist")
|
98
|
-
return nil
|
99
|
-
else
|
100
|
-
return card[0]["id"]
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
def getKeyMetricID(insightID, reportID, keyMetricName)
|
105
|
-
extract = nil
|
106
|
-
paramHash = Hash.new
|
107
|
-
paramHash["insightID"] = insightID
|
108
|
-
paramHash["reportID"] = reportID
|
109
|
-
paramHash["filter"] = {"name" => keyMetricName}
|
110
|
-
paramHash["count"] = 1
|
111
|
-
paramHash["fields"] = "id"
|
112
|
-
|
113
|
-
keyMetric = getInsightReportCards(paramHash)
|
114
|
-
if keyMetric.nil? || !keyMetric.any?
|
115
|
-
log("DEBUG", "Report key metric with name "+keyMetricName+" does not exist")
|
116
|
-
return nil
|
117
|
-
else
|
118
|
-
return keyMetric[0]["id"]
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
def createInsight(insightName)
|
123
|
-
if !insightName.nil?
|
124
|
-
insightID = nil
|
125
|
-
insightID = getInsightID(insightName)
|
126
|
-
|
127
|
-
if !insightID.nil?
|
128
|
-
log("DEBUG", "Insight with name "+insightName+" already exists!")
|
129
|
-
return insightID
|
130
|
-
else
|
131
|
-
paramHash = {}
|
132
|
-
paramHash["context"] = "insights"
|
133
|
-
paramHash["data"] = {"name" => insightName}
|
134
|
-
insight = updateCloudmunchData(paramHash)
|
135
|
-
|
136
|
-
if insight["id"].nil?
|
137
|
-
log("DEBUG", "Unable to create insight : "+insightName+"! refer log for more details")
|
138
|
-
return nil
|
139
|
-
else
|
140
|
-
return insight["id"]
|
141
|
-
end
|
142
|
-
end
|
143
|
-
else
|
144
|
-
log("DEBUG", "Insights name is needed for creating an insight")
|
145
|
-
return nil
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
def createInsightDataStore(insightID, dataStoreName)
|
150
|
-
if !dataStoreName.nil? && !dataStoreName.empty? && !insightID.nil?
|
151
|
-
dataStoreID = nil
|
152
|
-
dataStoreID = getDataStoreID(insightID, dataStoreName)
|
153
|
-
|
154
|
-
if !dataStoreID.nil?
|
155
|
-
log("DEBUG", "Data store with name "+dataStoreName+" already exists!")
|
156
|
-
return dataStoreID
|
157
|
-
else
|
158
|
-
paramHash = {}
|
159
|
-
paramHash["context"] = "insights"
|
160
|
-
paramHash["contextID"] = insightID
|
161
|
-
paramHash["subContext"] = "datastores"
|
162
|
-
paramHash["data"] = {"name" => dataStoreName}
|
163
|
-
dataStore = updateCloudmunchData(paramHash)
|
164
|
-
|
165
|
-
if dataStore["id"].nil?
|
166
|
-
return nil
|
167
|
-
else
|
168
|
-
return dataStore["id"]
|
169
|
-
end
|
170
|
-
end
|
171
|
-
else
|
172
|
-
log("DEBUG", "Datastore name and insights id is needed for creating a data store")
|
173
|
-
return nil
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
def createInsightDataStoreExtract(insightID, dataStoreID, extractName)
|
178
|
-
if !extractName.nil? && !extractName.empty? && !insightID.nil? && !dataStoreID.nil?
|
179
|
-
|
180
|
-
extractID = nil
|
181
|
-
extractID = getExtractID(insightID, dataStoreID, extractName)
|
182
|
-
|
183
|
-
if !extractID.nil?
|
184
|
-
return extractID
|
185
|
-
else
|
186
|
-
paramHash = Hash.new
|
187
|
-
paramHash["context"] = "insights"
|
188
|
-
paramHash["contextID"] = insightID
|
189
|
-
paramHash["subContext"] = "datastores"
|
190
|
-
paramHash["subContextID"] = dataStoreID
|
191
|
-
paramHash["leafContext"] = "extracts"
|
192
|
-
paramHash["data"] = {"name" => extractName}
|
193
|
-
|
194
|
-
log("DEBUG", "Attempting creation of extract with name " + extractName + "...")
|
195
|
-
extract = updateCloudmunchData(paramHash)
|
196
|
-
|
197
|
-
if extract["id"].nil? then return nil else extract["id"] end
|
198
|
-
end
|
199
|
-
else
|
200
|
-
log("DEBUG", "Extract name, insights id and datastore id is needed for creating an extract")
|
201
|
-
return nil
|
202
|
-
end
|
203
|
-
end
|
10
|
+
include Util
|
11
|
+
|
12
|
+
##################################################################################
|
13
|
+
###
|
14
|
+
### downloadKeys(filekey, context, contextid)
|
15
|
+
### deleteKeys()
|
16
|
+
### getCloudmunchData(paramHash)
|
17
|
+
### updateCloudmunchData(paramHash, method = "POST")
|
18
|
+
### deleteCloudmunchData(paramHash)
|
19
|
+
### parseResponse(responseJson)
|
20
|
+
### generateServerURL(paramHash, appendQueryParams = nil)
|
21
|
+
###
|
22
|
+
###
|
23
|
+
##################################################################################
|
24
|
+
|
25
|
+
def downloadKeys(filekey, context, contextid)
|
26
|
+
|
27
|
+
paramHash = Hash.new
|
28
|
+
paramHash["context"] = context
|
29
|
+
paramHash["contextID"] = contextid
|
30
|
+
paramHash["file"] = filekey
|
31
|
+
|
32
|
+
keyString = getCloudmunchData(paramHash)
|
204
33
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
cardID = nil
|
209
|
-
cardID = getReportCardID(insightID, reportID, cardName)
|
210
|
-
|
211
|
-
if !cardID.nil?
|
212
|
-
return cardID
|
213
|
-
else
|
214
|
-
paramHash = Hash.new
|
215
|
-
paramHash["context"] = "insights"
|
216
|
-
paramHash["contextID"] = insightID
|
217
|
-
paramHash["subContext"] = "insight_reports"
|
218
|
-
paramHash["subContextID"] = reportID
|
219
|
-
paramHash["leafContext"] = "insight_cards"
|
220
|
-
paramHash["data"] = {"name" => cardName}
|
221
|
-
|
222
|
-
log("DEBUG", "Attempting creation of report card with name " + cardName + "...")
|
223
|
-
card = updateCloudmunchData(paramHash)
|
224
|
-
|
225
|
-
if card["id"].nil? then return nil else card["id"] end
|
226
|
-
end
|
227
|
-
else
|
228
|
-
log("DEBUG", "Extract name, insight id and report id is needed for creating a report card")
|
229
|
-
return nil
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
|
-
def createInsightReportKeyMetric(insightID, reportID, keyMetricName)
|
234
|
-
if !keyMetricName.nil? && !keyMetricName.empty? && !insightID.nil? && !reportID.nil?
|
235
|
-
|
236
|
-
keyMetricID = nil
|
237
|
-
keyMetricID = getReportKeyMetricID(insightID, reportID, keyMetricName)
|
238
|
-
|
239
|
-
if !keyMetricID.nil?
|
240
|
-
return keyMetricID
|
241
|
-
else
|
242
|
-
paramHash = Hash.new
|
243
|
-
paramHash["context"] = "insights"
|
244
|
-
paramHash["contextID"] = insightID
|
245
|
-
paramHash["subContext"] = "insight_reports"
|
246
|
-
paramHash["subContextID"] = reportID
|
247
|
-
paramHash["leafContext"] = "insight_cards"
|
248
|
-
paramHash["data"] = {"name" => keyMetricName}
|
249
|
-
|
250
|
-
log("DEBUG", "Attempting creation of report key metric with name " + keyMetricName + "...")
|
251
|
-
keyMetric = updateCloudmunchData(paramHash)
|
252
|
-
|
253
|
-
if keyMetric["id"].nil? then return nil else keyMetric["id"] end
|
254
|
-
end
|
255
|
-
else
|
256
|
-
log("DEBUG", "Key metric name, insight id and report id is needed for creating a report key metric")
|
257
|
-
return nil
|
258
|
-
end
|
259
|
-
end
|
260
|
-
|
261
|
-
def createInsightReport(insightID, reportName)
|
262
|
-
if !reportName.nil? && !reportName.empty? && !insightID.nil?
|
263
|
-
|
264
|
-
reportID = nil
|
265
|
-
reportID = getExtractID(insightID, reportName)
|
266
|
-
|
267
|
-
if !reportID.nil?
|
268
|
-
return reportID
|
269
|
-
else
|
270
|
-
paramHash = Hash.new
|
271
|
-
paramHash["context"] = "insights"
|
272
|
-
paramHash["contextID"] = insightID
|
273
|
-
paramHash["subContext"] = "insight_reports"
|
274
|
-
paramHash["data"] = {"name" => reportName}
|
275
|
-
|
276
|
-
log("DEBUG", "Attempting creation of report with name " + reportName + "...")
|
277
|
-
report = updateCloudmunchData(paramHash)
|
278
|
-
|
279
|
-
if report["id"].nil? then return nil else report["id"] end
|
280
|
-
end
|
281
|
-
else
|
282
|
-
log("DEBUG", "Report name and insight id is needed for creating a report")
|
283
|
-
return nil
|
284
|
-
end
|
285
|
-
end
|
286
|
-
|
287
|
-
def updateInsightDataStoreExtract(insightID, dataStoreID, data)
|
288
|
-
# /applications/{application_id}/insights/{insight_id}/datastores/{datastore_id}
|
289
|
-
|
290
|
-
if (insightID.nil? || insightID.empty?) && (dataStoreID.nil? || dataStoreID.empty?) && data.nil?
|
291
|
-
log("DEBUG", "Insight id, datastore id and data is needed to be update an existing data store")
|
292
|
-
return nil
|
293
|
-
end
|
294
|
-
paramHash = {}
|
295
|
-
paramHash["context"] = "insights"
|
296
|
-
paramHash["contextID"] = insightID
|
297
|
-
paramHash["subContext"] = "datastores"
|
298
|
-
paramHash["subContextID"] = dataStoreID
|
299
|
-
paramHash["data"] = data
|
300
|
-
return updateCloudmunchData(paramHash)
|
301
|
-
end
|
302
|
-
|
303
|
-
def updateInsightReport(insightID, reportID, data)
|
304
|
-
# /applications/{application_id}/insights/{insight_id}/insight_reports/{insight_report_id}
|
305
|
-
|
306
|
-
if (insightID.nil? || insightID.empty?) && (reportID.nil? || reportID.empty?) && data.nil?
|
307
|
-
log("DEBUG", "Insight id, report id and data is needed to be update an existing report")
|
308
|
-
return nil
|
309
|
-
end
|
310
|
-
paramHash = {}
|
311
|
-
paramHash["context"] = "insights"
|
312
|
-
paramHash["contextID"] = insightID
|
313
|
-
paramHash["subContext"] = "insight_reports"
|
314
|
-
paramHash["subContextID"] = reportID
|
315
|
-
paramHash["data"] = data
|
316
|
-
return updateCloudmunchData(paramHash)
|
317
|
-
end
|
318
|
-
|
319
|
-
def updateInsightDataStoreExtract(insightID, dataStoreID, extractID, data)
|
320
|
-
# /insights/{insight_id}/datastores/{datastore_id}/extracts/{extract_id}
|
321
|
-
|
322
|
-
if (insightID.nil? || insightID.empty?) && (dataStoreID.nil? || dataStoreID.empty?) && (extractID.nil? || extractID.empty?) && data.nil?
|
323
|
-
log("DEBUG", "Insight id, datastore id, extract id and data is needed to be update an existing extract")
|
34
|
+
if !keyString.to_s == ""
|
35
|
+
log("ERROR", "downloaded key content is empty, please re-upload key and try")
|
324
36
|
return nil
|
325
37
|
end
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
end
|
336
|
-
|
337
|
-
|
338
|
-
def updateInsightReportCard(insightID, reportID, cardID, data)
|
339
|
-
# /applications/{application_id}/insights/{insight_id}/insight_reports/{insight_report_id}/insight_cards/{insight_card_id}
|
340
|
-
|
341
|
-
if (insightID.nil? || insightID.empty?) && (reportID.nil? || reportID.empty?) && (cardID.nil? || cardID.empty?) && data.nil?
|
342
|
-
log("DEBUG", "Insight id, report id, cardID and data is needed to be update an existing report card")
|
343
|
-
return nil
|
38
|
+
|
39
|
+
filename = "keyfile_" + Time.now.strftime('%Y%m%d%H%M%S%L')
|
40
|
+
file = @appContext.get_data("{workspace}")+"/"+filename
|
41
|
+
|
42
|
+
File.open(file, 'w') { |file| file.write(keyString) }
|
43
|
+
system('chmod 400 '+file)
|
44
|
+
|
45
|
+
if @keyArray.nil?
|
46
|
+
@keyArray = []
|
344
47
|
end
|
345
48
|
|
346
|
-
|
347
|
-
|
348
|
-
paramHash["contextID"] = insightID
|
349
|
-
paramHash["subContext"] = "insight_reports"
|
350
|
-
paramHash["subContextID"] = reportID
|
351
|
-
paramHash["leafContext"] = "insight_cards"
|
352
|
-
paramHash["leafContextID"] = cardID
|
353
|
-
paramHash["data"] = data
|
354
|
-
return updateCloudmunchData(paramHash)
|
49
|
+
@keyArray.push(file)
|
50
|
+
return file;
|
355
51
|
end
|
356
52
|
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
if (insightID.nil? || insightID.empty?) && (reportID.nil? || reportID.empty?) && (keyMetricID.nil? || keyMetricID.empty?) && data.nil?
|
362
|
-
log("DEBUG", "Insight id, report id, keyMetricID and data is needed to be update an existing report key metric")
|
363
|
-
return nil
|
364
|
-
end
|
365
|
-
|
366
|
-
paramHash = {}
|
367
|
-
paramHash["context"] = "insights"
|
368
|
-
paramHash["contextID"] = insightID
|
369
|
-
paramHash["subContext"] = "insight_reports"
|
370
|
-
paramHash["subContextID"] = reportID
|
371
|
-
paramHash["leafContext"] = "key_metrics"
|
372
|
-
paramHash["leafContextID"] = keyMetricID
|
373
|
-
paramHash["data"] = data
|
374
|
-
return updateCloudmunchData(paramHash)
|
53
|
+
def deleteKeys()
|
54
|
+
fileName = @appContext.get_data("{workspace}")+"/keyfile_*"
|
55
|
+
File.delete(fileName)
|
375
56
|
end
|
376
57
|
|
377
|
-
def
|
378
|
-
|
379
|
-
|
380
|
-
paramInsightID = paramHash["insightID"].nil? ? nil : paramHash["insightID"]
|
58
|
+
def getCloudmunchData(paramHash)
|
59
|
+
serverurl = nil
|
60
|
+
serverurl = generateServerURL(paramHash,true)
|
381
61
|
|
382
|
-
if
|
383
|
-
|
384
|
-
|
62
|
+
if serverurl.nil?
|
63
|
+
log("DEBUG", "Unable to generate server url")
|
64
|
+
log("ERROR", "Unable to get data from cloudmunch")
|
65
|
+
return nil
|
385
66
|
end
|
386
67
|
|
387
|
-
|
388
|
-
paramFormatted = paramHash
|
389
|
-
paramFormatted["context"] = "insights"
|
390
|
-
paramFormatted["subContext"] = "insight_reports"
|
391
|
-
paramFormatted["leafContext"] = "key_metrics"
|
392
|
-
paramFormatted["contextID"] = paramInsightID
|
393
|
-
paramFormatted["subContextID"] = paramReportId
|
68
|
+
uri = URI.parse(serverurl)
|
394
69
|
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
def updateInsight(insightID, data)
|
403
|
-
# /applications/{application_id}/insights/{insight_id}
|
404
|
-
|
405
|
-
if (insightID.nil? || insightID.empty?) && data.nil?
|
406
|
-
log("DEBUG", "Insight id and data is needed to be update an existing data store")
|
407
|
-
return nil
|
408
|
-
end
|
409
|
-
|
410
|
-
paramHash = {}
|
411
|
-
paramHash["context"] = "insights"
|
412
|
-
paramHash["contextID"] = insightID
|
413
|
-
paramHash["data"] = data
|
414
|
-
return updateCloudmunchData(paramHash)
|
70
|
+
log("DEBUG", "URI for get : ")
|
71
|
+
log("DEBUG", uri)
|
72
|
+
|
73
|
+
responseJson = Net::HTTP.get(uri)
|
74
|
+
|
75
|
+
parseResponse(responseJson)
|
415
76
|
end
|
416
77
|
|
417
78
|
def updateCloudmunchData(paramHash, method = "POST")
|
@@ -442,7 +103,28 @@ module CloudmunchService
|
|
442
103
|
return parseResponse(responseJson.body)
|
443
104
|
end
|
444
105
|
|
106
|
+
def deleteCloudmunchData(paramHash)
|
107
|
+
paramContext = paramHash["context"]
|
108
|
+
paramContextID = paramHash["contextID"]
|
109
|
+
|
110
|
+
if !paramContext.nil? && !paramContext.empty? && !paramContextID.nil? && !paramContextID.empty?
|
111
|
+
serverurl=@appContext.get_data("{master_url}")+"/applications/"+@appContext.get_data("{application}")+"/"+context+"/"+contextID;
|
112
|
+
serverurl=serverurl+"?apikey="+@appContext.get_data("{api_key}")
|
113
|
+
uri = URI.parse(serverurl)
|
114
|
+
Net::HTTP::Delete(uri)
|
115
|
+
return 1
|
116
|
+
else
|
117
|
+
return nil
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
445
121
|
def parseResponse(responseJson)
|
122
|
+
begin
|
123
|
+
JSON.parse(responseJson)
|
124
|
+
rescue
|
125
|
+
return responseJson
|
126
|
+
end
|
127
|
+
|
446
128
|
requestDetails = (JSON.load(responseJson))['request']
|
447
129
|
responseData = (JSON.load(responseJson))['data']
|
448
130
|
|
@@ -459,134 +141,7 @@ module CloudmunchService
|
|
459
141
|
end
|
460
142
|
end
|
461
143
|
|
462
|
-
|
463
|
-
serverurl = nil
|
464
|
-
serverurl = generateServerURL(paramHash,true)
|
465
|
-
|
466
|
-
if serverurl.nil?
|
467
|
-
log("DEBUG", "Unable to generate server url")
|
468
|
-
log("ERROR", "Unable to get data from cloudmunch")
|
469
|
-
return nil
|
470
|
-
end
|
471
|
-
|
472
|
-
uri = URI.parse(serverurl)
|
473
|
-
|
474
|
-
log("DEBUG", "URI for get : ")
|
475
|
-
log("DEBUG", uri)
|
476
|
-
|
477
|
-
responseJson = Net::HTTP.get(uri)
|
478
|
-
return parseResponse(responseJson)
|
479
|
-
end
|
480
|
-
|
481
|
-
def getInsights(paramHash)
|
482
|
-
# /insights/{insight_id}
|
483
|
-
paraminsightID = paramHash["insightID"].nil? ? nil : paramHash["insightID"]
|
484
|
-
|
485
|
-
paramFormatted = Hash.new
|
486
|
-
paramFormatted = paramHash
|
487
|
-
paramFormatted["context"] = "insights"
|
488
|
-
|
489
|
-
if !paraminsightID.nil? && !paraminsightID.empty?
|
490
|
-
paramFormatted["contextID"] = paramInsightID
|
491
|
-
end
|
492
|
-
|
493
|
-
return getCloudmunchData(paramFormatted)
|
494
|
-
end
|
495
|
-
|
496
|
-
def getInsightDataStoreExtracts(paramHash)
|
497
|
-
# /insights/{insight_id}/datastores/{datastore_id}/extracts/{extract_id}
|
498
|
-
paramDataStoreId = paramHash["dataStoreID"].nil? ? nil : paramHash["dataStoreID"]
|
499
|
-
paramInsightID = paramHash["insightID"].nil? ? nil : paramHash["insightID"]
|
500
|
-
|
501
|
-
serverurl = nil
|
502
|
-
|
503
|
-
if paramInsightID.nil? || paramInsightID.empty? || paramDataStoreId.nil? || paramDataStoreId.empty?
|
504
|
-
log("DEBUG", "Insight id and datastore id is needed to gets its extract details")
|
505
|
-
return nil
|
506
|
-
end
|
507
|
-
|
508
|
-
paramFormatted = Hash.new
|
509
|
-
paramFormatted = paramHash
|
510
|
-
paramFormatted["context"] = "insights"
|
511
|
-
paramFormatted["subContext"] = "datastores"
|
512
|
-
paramFormatted["leafContext"] = "extracts"
|
513
|
-
paramFormatted["contextID"] = paramInsightID
|
514
|
-
paramFormatted["subContextID"] = paramDataStoreId
|
515
|
-
|
516
|
-
if !paramHash["extractID"].nil?
|
517
|
-
paramFormatted["leafContextID"] = paramHash["extractID"]
|
518
|
-
end
|
519
|
-
|
520
|
-
return getCloudmunchData(paramFormatted)
|
521
|
-
end
|
522
|
-
|
523
|
-
def getInsightDataStores(paramHash)
|
524
|
-
# /insights/{insight_id}/datastores/{datastore_id}
|
525
|
-
paramInsightID = paramHash["insightID"].nil? ? nil : paramHash["insightID"]
|
526
|
-
|
527
|
-
if paramInsightID.nil? || paramInsightID.empty?
|
528
|
-
log("DEBUG", "Insight id is not provided")
|
529
|
-
return nil
|
530
|
-
end
|
531
|
-
|
532
|
-
paramFormatted = Hash.new
|
533
|
-
paramFormatted = paramHash
|
534
|
-
paramFormatted["context"] = "insights"
|
535
|
-
paramFormatted["subContext"] = "datastores"
|
536
|
-
paramFormatted["contextID"] = paramInsightID
|
537
|
-
|
538
|
-
if !paramHash["dataStoreID"].nil?
|
539
|
-
paramFormatted["subContextID"] = paramHash["dataStoreID"]
|
540
|
-
end
|
541
|
-
return getCloudmunchData(paramFormatted)
|
542
|
-
end
|
543
|
-
|
544
|
-
def getInsightReports(paramHash)
|
545
|
-
# /applications/{application_id}/insights/{insight_id}/insight_reports/{insight_report_id}
|
546
|
-
paramInsightID = paramHash["insightID"].nil? ? nil : paramHash["insightID"]
|
547
|
-
|
548
|
-
if paramInsightID.nil? || paramInsightID.empty?
|
549
|
-
log("DEBUG", "Insight id is needed to gets its report details")
|
550
|
-
return nil
|
551
|
-
end
|
552
|
-
|
553
|
-
paramFormatted = Hash.new
|
554
|
-
paramFormatted = paramHash
|
555
|
-
paramFormatted["context"] = "insights"
|
556
|
-
paramFormatted["subContext"] = "insight_reports"
|
557
|
-
paramFormatted["contextID"] = paramInsightID
|
558
|
-
|
559
|
-
if !paramHash["reportID"].nil?
|
560
|
-
paramFormatted["subContextID"] = paramHash["reportID"]
|
561
|
-
end
|
562
|
-
|
563
|
-
return getCloudmunchData(paramFormatted)
|
564
|
-
end
|
565
|
-
|
566
|
-
def getInsightReportCards(paramHash)
|
567
|
-
# /applications/{application_id}/insights/{insight_id}/insight_reports/{insight_report_id}/insight_cards/{insight_card_id}
|
568
|
-
paramReportId = paramHash["reportID"].nil? ? nil : paramHash["reportID"]
|
569
|
-
paramInsightID = paramHash["insightID"].nil? ? nil : paramHash["insightID"]
|
570
|
-
|
571
|
-
if paramInsightID.nil? || paramInsightID.empty? || paramReportId.nil? || paramReportId.empty?
|
572
|
-
log("DEBUG", "Insight id and report id is needed to gets its report card details")
|
573
|
-
return nil
|
574
|
-
end
|
575
|
-
|
576
|
-
paramFormatted = Hash.new
|
577
|
-
paramFormatted = paramHash
|
578
|
-
paramFormatted["context"] = "insights"
|
579
|
-
paramFormatted["subContext"] = "insight_reports"
|
580
|
-
paramFormatted["leafContext"] = "insight_cards"
|
581
|
-
paramFormatted["contextID"] = paramInsightID
|
582
|
-
paramFormatted["subContextID"] = paramReportId
|
583
|
-
|
584
|
-
if !paramHash["cardID"].nil?
|
585
|
-
paramFormatted["leafContextID"] = paramHash["cardID"]
|
586
|
-
end
|
587
|
-
|
588
|
-
return getCloudmunchData(paramFormatted)
|
589
|
-
end
|
144
|
+
|
590
145
|
|
591
146
|
def generateServerURL(paramHash, appendQueryParams = nil)
|
592
147
|
|
@@ -628,6 +183,7 @@ module CloudmunchService
|
|
628
183
|
|
629
184
|
if !appendQueryParams.nil?
|
630
185
|
queryString = queryString + "filter=" + paramHash["filter"].to_json + "&" if !paramHash["filter"].nil?
|
186
|
+
queryString = queryString + "file=" + paramHash["file"].to_s + "&" if !paramHash["file"].nil?
|
631
187
|
queryString = queryString + "fields=" + paramHash["fields"].to_s + "&" if !paramHash["fields"].nil?
|
632
188
|
queryString = queryString + "count=" + paramHash["count"].to_s + "&" if !paramHash["count"].nil?
|
633
189
|
queryString = queryString + "offset=" + paramHash["offset"].to_s + "&" if !paramHash["offset"].nil?
|
@@ -639,31 +195,9 @@ module CloudmunchService
|
|
639
195
|
return serverurl
|
640
196
|
end
|
641
197
|
|
642
|
-
def deleteCloudmunchData(paramHash)
|
643
|
-
paramContext = paramHash["context"]
|
644
|
-
paramContextID = paramHash["contextID"]
|
645
|
-
|
646
|
-
if !paramContext.nil? && !paramContext.empty? && !paramContextID.nil? && !paramContextID.empty?
|
647
|
-
serverurl=@appContext.get_data("{master_url}")+"/applications/"+@appContext.get_data("{application}")+"/"+context+"/"+contextID;
|
648
|
-
serverurl=serverurl+"?apikey="+@appContext.get_data("{api_key}")
|
649
|
-
uri = URI.parse(serverurl)
|
650
|
-
Net::HTTP::Delete(uri)
|
651
|
-
return 1
|
652
|
-
else
|
653
|
-
return nil
|
654
|
-
end
|
655
|
-
end
|
656
|
-
|
657
|
-
def deleteCloudmunchDataBKUP(context,contextID)
|
658
|
-
serverurl=@appContext.get_data("{master_url}")+"/applications/"+@appContext.get_data("{application}")+"/"+context+"/"+contextID;
|
659
|
-
serverurl=serverurl+"?apikey="+@appContext.get_data("{api_key}")
|
660
|
-
uri = URI.parse(serverurl)
|
661
|
-
Net::HTTP::Delete(uri)
|
662
|
-
end
|
663
|
-
|
664
198
|
def self.putCustomDataContext(server, endpoint, param)
|
665
199
|
result = self.http_post(server, endpoint, param)
|
666
|
-
|
200
|
+
|
667
201
|
if result.code.to_s == "200"
|
668
202
|
return true
|
669
203
|
else
|
@@ -697,11 +231,19 @@ module CloudmunchService
|
|
697
231
|
end
|
698
232
|
end
|
699
233
|
|
700
|
-
def self.getDataContext(server, endpoint, param)
|
701
|
-
|
234
|
+
# def self.getDataContext(server, endpoint, param)
|
235
|
+
# getCustomDataContext(server, endpoint, param)
|
236
|
+
# end
|
237
|
+
|
238
|
+
# def self.updateDataContext(server, endpoint, param)
|
239
|
+
# putCustomDataContext(server, endpoint, param)
|
240
|
+
# end
|
241
|
+
|
242
|
+
def getDataForContext(server, endpoint, param)
|
243
|
+
getCustomDataContext(server, endpoint, param)
|
702
244
|
end
|
703
245
|
|
704
|
-
def
|
246
|
+
def updateDataForContext(server, endpoint, param)
|
705
247
|
putCustomDataContext(server, endpoint, param)
|
706
248
|
end
|
707
249
|
end
|