raas-client-rails 0.1.1 → 0.1.3
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7b6a84b9056a678c04d3ccda0b3e9e51f088ce762ff66f220290759dfa68581
|
4
|
+
data.tar.gz: 1078171ee29459bca2475b20b36e1aa4ec66ca12aeb1f6a9c261d3d325dedc25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a29156150876b44a236747e93ed2a0cd7b673dc3db0d432edf1213fdf63045f1811932c8f398a7f73b9049fa7e3e52f5bdc7965e78da34213e96fb73d0597010
|
7
|
+
data.tar.gz: d8c97c5576fca515e38ac04ebcd17df908bff8d323c673f1d39293e7467f21b25136b197b4a1cb4b21e29ccac23ed88ff265651198abcce1de32e9d8d6e609ca
|
@@ -3,7 +3,6 @@ module Raas::Client::Rails
|
|
3
3
|
require_relative 'rest_client'
|
4
4
|
|
5
5
|
class RaasController < ApplicationController
|
6
|
-
skip_before_action :verify_authenticity_token
|
7
6
|
|
8
7
|
MSA_REPORT = "report";
|
9
8
|
MSA_DT = "datatraveler";
|
@@ -11,32 +10,33 @@ module Raas::Client::Rails
|
|
11
10
|
#/raas/health
|
12
11
|
def health()
|
13
12
|
prepare(params)
|
14
|
-
render plain: "Moving #{@tenant}/#{@
|
13
|
+
render plain: "Moving #{@tenant}/#{@sub}";
|
15
14
|
end
|
16
15
|
|
17
16
|
def prepare(params)
|
18
|
-
# seven arguments are needed to make this work
|
19
|
-
application = Raas::Client::Rails::Engine.config.raas_client_rails.application
|
20
|
-
landscape = Raas::Client::Rails::Engine.config.raas_client_rails.landscape
|
21
|
-
token = Raas::Client::Rails::Engine.config.raas_client_rails.token
|
22
17
|
@backUrl = params[:backUrl]
|
23
18
|
@subUrl = params[:subUrl]
|
19
|
+
prepare_tenant_and_sub()
|
20
|
+
@restClient = RestClient.new(@tenant, @sub)
|
21
|
+
end
|
22
|
+
|
23
|
+
def prepare_tenant_and_sub()
|
24
|
+
# For Overload
|
24
25
|
@tenant = params[:tenant]
|
25
|
-
@
|
26
|
-
@restClient = RestClient.new(application,landscape,token)
|
26
|
+
@sub = params[:sub]
|
27
27
|
end
|
28
28
|
|
29
29
|
def report_session()
|
30
30
|
Rails.logger.warn("session parameter=#{params}");
|
31
31
|
prepare(params)
|
32
|
-
response = @restClient.createExternalSession(MSA_REPORT,@backUrl,@subUrl
|
32
|
+
response = @restClient.createExternalSession(MSA_REPORT,@backUrl,@subUrl)
|
33
33
|
render json: response.body
|
34
34
|
end
|
35
35
|
|
36
36
|
def datatraveler_session()
|
37
37
|
Rails.logger.warn("session parameter=#{params}")
|
38
38
|
prepare(params)
|
39
|
-
response = @restClient.createExternalSession(MSA_DT,@backUrl,@subUrl
|
39
|
+
response = @restClient.createExternalSession(MSA_DT,@backUrl,@subUrl)
|
40
40
|
render json: response.body
|
41
41
|
end
|
42
42
|
|
@@ -70,7 +70,7 @@ module Raas::Client::Rails
|
|
70
70
|
payload = parameters
|
71
71
|
end
|
72
72
|
Rails.logger.warn("get path=#{path} parameters=#{payload}");
|
73
|
-
response = @restClient.get(path,payload
|
73
|
+
response = @restClient.get(path,payload)
|
74
74
|
handleMime(mimeType, fileName, type, response)
|
75
75
|
end
|
76
76
|
|
@@ -99,7 +99,7 @@ module Raas::Client::Rails
|
|
99
99
|
payload = JSON.parse(parameters)
|
100
100
|
end
|
101
101
|
Rails.logger.warn("delete path=#{path} parameters=#{parameters}");
|
102
|
-
return @restClient.delete(path,payload
|
102
|
+
return @restClient.delete(path,payload)
|
103
103
|
end
|
104
104
|
|
105
105
|
#/raas/post
|
@@ -113,7 +113,7 @@ module Raas::Client::Rails
|
|
113
113
|
payload = JSON.parse(requestBody)
|
114
114
|
end
|
115
115
|
Rails.logger.warn("post path=#{path} requestBody=#{requestBody}");
|
116
|
-
response = @restClient.post(path,payload
|
116
|
+
response = @restClient.post(path,payload)
|
117
117
|
return response.body;
|
118
118
|
end
|
119
119
|
|
@@ -128,7 +128,7 @@ module Raas::Client::Rails
|
|
128
128
|
payload = JSON.parse(requestBody)
|
129
129
|
end
|
130
130
|
Rails.logger.warn("post path=#{path} requestBody=#{requestBody}");
|
131
|
-
response = @restClient.put(path,payload
|
131
|
+
response = @restClient.put(path,payload)
|
132
132
|
return response.body;
|
133
133
|
end
|
134
134
|
|
@@ -12,21 +12,20 @@ module Raas::Client::Rails
|
|
12
12
|
DELETE = "delete"
|
13
13
|
APEX_DOMAIN = "functions.asaservice.inc";
|
14
14
|
|
15
|
-
def initialize(
|
16
|
-
@application = application
|
17
|
-
@landscape = landscape
|
18
|
-
@token = token
|
15
|
+
def initialize(tenant, sub)
|
16
|
+
@application = Raas::Client::Rails::Engine.config.raas_client_rails.application
|
17
|
+
@landscape = Raas::Client::Rails::Engine.config.raas_client_rails.landscape
|
18
|
+
@token = Raas::Client::Rails::Engine.config.raas_client_rails.token
|
19
|
+
@tenant = tenant
|
20
|
+
@sub = sub
|
19
21
|
end
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
def createExternalSession(msa,backUrl,subUrl,tenant,subsystem)
|
23
|
+
def createExternalSession(msa,backUrl,subUrl)
|
25
24
|
body = Hash.new
|
26
25
|
body["backUrl"] = backUrl
|
27
26
|
body["subUrl"] = subUrl
|
28
|
-
body["tenant"] = tenant
|
29
|
-
body["sub"] =
|
27
|
+
body["tenant"] = @tenant
|
28
|
+
body["sub"] = @sub
|
30
29
|
return proxy(body,POST,"/#{msa}/external/session",nil,@token)
|
31
30
|
end
|
32
31
|
|
@@ -36,51 +35,41 @@ module Raas::Client::Rails
|
|
36
35
|
#Use Rails default cache system, this simply use cache otherwise fetch and store
|
37
36
|
Rails.logger.debug("Attempt to recycle token");
|
38
37
|
cacheName = "#{@tenant}+++#{@sub}"
|
39
|
-
@@t = @tenant
|
40
|
-
@@s = @sub
|
41
38
|
Rails.logger.debug("Cache name is #{cacheName}")
|
42
39
|
# p cacheName
|
43
40
|
return token = Rails.cache.fetch(cacheName) do
|
44
41
|
Rails.logger.debug("No cache found, fetch it by api");
|
45
|
-
Rails.logger.debug("tenant #=> #{
|
46
|
-
response = getUserTokenImpl(
|
42
|
+
Rails.logger.debug("tenant #=> #{@tenant} / sub #=> #{@sub}")
|
43
|
+
response = getUserTokenImpl("report");
|
47
44
|
Rails.logger.debug(response.body)
|
48
45
|
return JSON.parse(response.body);
|
49
46
|
end
|
50
47
|
end
|
51
48
|
|
52
49
|
# fetch token from RaaS because no cache
|
53
|
-
def getUserTokenImpl(msa
|
50
|
+
def getUserTokenImpl(msa)
|
54
51
|
body = Hash.new
|
55
|
-
body["tenant"] = tenant
|
56
|
-
body["sub"] = sub
|
52
|
+
body["tenant"] = @tenant
|
53
|
+
body["sub"] = @sub
|
57
54
|
response = proxy(body,POST,"/#{msa}/external/token",nil,@token);
|
58
55
|
end
|
59
56
|
|
60
|
-
def get(requestUrl, params
|
61
|
-
@tenant = tenant
|
62
|
-
@sub = sub
|
57
|
+
def get(requestUrl, params)
|
63
58
|
json = getUserToken()
|
64
59
|
return proxy(nil, GET,requestUrl,params,json["token"]);
|
65
60
|
end
|
66
61
|
|
67
|
-
def delete(requestUrl, params
|
68
|
-
@tenant = tenant
|
69
|
-
@sub = sub
|
62
|
+
def delete(requestUrl, params)
|
70
63
|
json = getUserToken()
|
71
64
|
return proxy(nil, DELETE,requestUrl,params,json["token"]);
|
72
65
|
end
|
73
66
|
|
74
|
-
def put(requestUrl,body
|
75
|
-
@tenant = tenant
|
76
|
-
@sub = sub
|
67
|
+
def put(requestUrl,body)
|
77
68
|
json = getUserToken()
|
78
69
|
return proxy(body , PUT,requestUrl,nil,json["token"]);
|
79
70
|
end
|
80
71
|
|
81
|
-
def post(requestUrl,body
|
82
|
-
@tenant = tenant
|
83
|
-
@sub = sub
|
72
|
+
def post(requestUrl,body)
|
84
73
|
json = getUserToken()
|
85
74
|
return proxy(body , POST,requestUrl,nil,json["token"]);
|
86
75
|
end
|
@@ -119,7 +108,7 @@ module Raas::Client::Rails
|
|
119
108
|
else
|
120
109
|
puts "method is not be defined..."
|
121
110
|
end
|
122
|
-
httpEntity['Accept-Encoding'] = ''
|
111
|
+
httpEntity['Accept-Encoding'] = 'gzip'
|
123
112
|
httpEntity.body = body.to_json if body
|
124
113
|
retry_count = 0
|
125
114
|
max_retries = 4
|