raas-client-rails 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b56a61195736f945cd1e9a2f5779a6d3db9386cc7cbcb8c77da0d68dd15f55f8
4
- data.tar.gz: 7c754de285006edc369ae879e11caf3cd42d86cb072209ba4767567b114bad16
3
+ metadata.gz: b7b6a84b9056a678c04d3ccda0b3e9e51f088ce762ff66f220290759dfa68581
4
+ data.tar.gz: 1078171ee29459bca2475b20b36e1aa4ec66ca12aeb1f6a9c261d3d325dedc25
5
5
  SHA512:
6
- metadata.gz: 7a9f769596c3fe3a69889adadaa56b0107a3ec6da4dae4b12e623bedca50b7b4437408d72f23088aa384d0c03e9771032dffe72199fcd1e9bbbf4638ef4a6026
7
- data.tar.gz: d16bb03dce672c082439305a686a8df2f0b2c551264d3a8841039ba11e9b98e0e1b53685206d329c4cf6b56bc1b3e9235c4d7d6f028829440b07310784a42fbc
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}/#{@subsystem}";
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
- @subsystem = params[:sub]
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,@tenant,@subsystem)
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,@tenant,@subsystem)
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,@tenant,@subsystem)
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,@tenant,@subsystem)
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,@tenant,@subsystem)
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,@tenant,@subsystem)
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(application,landscape,token)
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
- # ResponseEntity<String> resp = raasClient.createExternalSession(Constant.MSA_REPORT,req.getBackUrl(),req.getSubUrl(), saasContextProvider.getTenant(), saasContextProvider.getSub());
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"] = subsystem
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 #=> #{@@t} / sub #=> #{@@s}")
46
- response = getUserTokenImpl( "report" , @@t , @@s);
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,tenant,sub)
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,tenant,sub)
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,tenant,sub)
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,tenant,sub)
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,tenant,sub)
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'] = '' #delete acceptEncoding here
111
+ httpEntity['Accept-Encoding'] = 'gzip'
123
112
  httpEntity.body = body.to_json if body
124
113
  retry_count = 0
125
114
  max_retries = 4
@@ -1,7 +1,7 @@
1
1
  module Raas
2
2
  module Client
3
3
  module Rails
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.3"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raas-client-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sunao Suzuki