Module: CloudmunchService

Includes:
Util
Included in:
AppAbstract
Defined in:
lib/cloudmunch_Ruby_sdk_v2/CloudmunchService.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util

generateReport, getJSONArgs, getJSONArgsTEMP, getTemplate, getUrlForViewCards, log, logClose, logInit, logIt, openJSONFile

Class Method Details

.getCustomDataContext(server, endpoint, param) ⇒ Object



67
68
69
# File 'lib/cloudmunch_Ruby_sdk_v2/CloudmunchService.rb', line 67

def self.getCustomDataContext(server, endpoint, param)
   return self.http_get(server, endpoint, param)
end

.getDataContext(server, endpoint, param) ⇒ Object



93
94
95
# File 'lib/cloudmunch_Ruby_sdk_v2/CloudmunchService.rb', line 93

def self.getDataContext(server, endpoint, param)
   getCustomDataContext(server, endpoint, param)     
end

.http_get(server, path, params) ⇒ Object



71
72
73
74
75
76
77
78
79
80
# File 'lib/cloudmunch_Ruby_sdk_v2/CloudmunchService.rb', line 71

def self.http_get(server,path,params)
   if params.nil?
    return Net::HTTP.get(server, path)
   else
      queryStr =  "#{path}?".concat(params.collect { |k,v| "#{k}=#{CGI::escape(v.to_s)}" }.join('&'))
      puts ("SDKDEBUG: Calling URL " + server+queryStr)
      uri = URI(server + "/" + queryStr)
      return Net::HTTP.get(uri) 
   end
end

.http_post(server, path, params) ⇒ Object



82
83
84
85
86
87
88
89
90
91
# File 'lib/cloudmunch_Ruby_sdk_v2/CloudmunchService.rb', line 82

def self.http_post(server,path,params)
     queryStr =  "#{path}?".concat(params.collect { |k,v| "#{k}=#{CGI::escape(v.to_s)}" }.join('&'))
     puts ("SDKDEBUG: Calling URL " + server+queryStr)
     if params.nil?
         return Net::HTTP.post(server, path)
     else
         uri = URI(server +  path)
         return Net::HTTP.post_form(uri, params)
     end
end

.putCustomDataContext(server, endpoint, param) ⇒ Object



56
57
58
59
60
61
62
63
64
# File 'lib/cloudmunch_Ruby_sdk_v2/CloudmunchService.rb', line 56

def self.putCustomDataContext(server, endpoint, param)
   result = self.http_post(server, endpoint, param)
   #p result.code.to_s 
   if result.code.to_s == "200"
     return true 
   else
     return false 
   end     
end

.updateDataContext(server, endpoint, param) ⇒ Object



98
99
100
# File 'lib/cloudmunch_Ruby_sdk_v2/CloudmunchService.rb', line 98

def self.updateDataContext(server, endpoint, param)
   putCustomDataContext(server, endpoint, param)  
end

Instance Method Details

#deleteCloudmunchData(context, contextid) ⇒ Object



47
48
49
50
51
# File 'lib/cloudmunch_Ruby_sdk_v2/CloudmunchService.rb', line 47

def deleteCloudmunchData(context,contextid)
 serverurl=applicationContext.get("{master_url}")+"/applications/"+applicationContext.get("{application}")+"/"+$context+"/"+$contextid;
 uri = URI.parse(serverurl)
 Net::HTTP::Delete(uri)
end

#getCloudmunchData(context, contextid, filterdata) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/cloudmunch_Ruby_sdk_v2/CloudmunchService.rb', line 27

def getCloudmunchData(context,contextid,filterdata)
 if contextid.nil? || contextid.empty?
  serverurl=applicationContext.get("{master_url}")+"/applications/"+applicationContext.get("{application}")+"/"+$context
  else
  serverurl=applicationContext.get("{master_url}")+"/applications/"+applicationContext.get("{application}")+"/"+$context+"/"+$contextid;
 end
 querystring=""
 if filterdata.nil? || filterdata.empty?
   serverurl=serverurl+"?apikey=".applicationContext.get("{api_key}")
 else
   querystring="filter="+to_json($filerdata);
   serverurl=serverurl+"?"+querystring+"&apikey=".applicationContext.get("{api_key}")
 
 end
uri = URI.parse(serverurl)
 
  return Net::HTTP.get(uri)
end

#initialize(appcontext) ⇒ Object



11
12
13
# File 'lib/cloudmunch_Ruby_sdk_v2/CloudmunchService.rb', line 11

def initialize(appcontext)
 @applicationContext=appcontext
end

#updateCloudmunchData(context, contextid, data) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/cloudmunch_Ruby_sdk_v2/CloudmunchService.rb', line 15

def updateCloudmunchData(context,contextid,data)
 
 serverurl=applicationContext.get("{master_url}")+"/applications/"+applicationContext.get("{application}")+"/"+$context+"/"+$contextid;
  uri = URI.parse(serverurl)
 
  response= Net::HTTP.post_form(uri,"data" => data12.to_json)
  
  return response.body
end