raas-client-rails 0.1.3 → 0.1.5
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: a39abf6c7b41855d8d3bfe4fd8c8a61aea4dd633d13097b755a75b4d708e3bfc
|
4
|
+
data.tar.gz: 66b9408baac8b9a1b5defa77b4bf867596539830f99989b74438693359864f5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64bba5b9c2d08770c9b3483a5c70d8951f1c46c2c07dbe171a39b69ec62d1f76400ecb4af38c3cc79d32df69450a69d419974e5e3a40158c8cc9cc69a7292def
|
7
|
+
data.tar.gz: 37fe0b7bead310581f1a3eeffc1f2b7e4eec625da1aff7130b3dc0c8941b376ade9bf65c6cd5ea16630bde1cf429f75ba5050ff58b10b15086e1bfe2000d12d2
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Raas::Client::Rails
|
2
2
|
|
3
|
-
Adding
|
3
|
+
Adding client to access Raas. This client allows you to call Raas API.
|
4
4
|
|
5
5
|
## Usage
|
6
6
|
|
@@ -21,11 +21,10 @@ This condifuration is **mandatory** please, do not forget before you start inter
|
|
21
21
|
|
22
22
|
### APIs
|
23
23
|
|
24
|
-
Once you install
|
24
|
+
Once you install gem and set it up, your application has several extra endpoints to interact with RaaS.
|
25
25
|
|
26
26
|
- `/raas/report/session` : Generate external session by using your credentials for report
|
27
|
-
- `/raas/datatraveler/session` : Generate external session by using your credentials for
|
28
|
-
- `/raas/health` : Ask RaaS to get current health condition
|
27
|
+
- `/raas/datatraveler/session` : Generate external session by using your credentials for datatraveler
|
29
28
|
|
30
29
|
## Installation
|
31
30
|
|
@@ -44,17 +43,34 @@ gem "raas-client-rails"
|
|
44
43
|
$ bundle install
|
45
44
|
```
|
46
45
|
|
47
|
-
3.
|
46
|
+
3. implement raas_controller.rb
|
48
47
|
|
49
48
|
```ruby
|
50
|
-
|
49
|
+
class RaasController < Raas::Client::Rails::RaasController
|
50
|
+
skip_before_action :verify_authenticity_token
|
51
|
+
|
52
|
+
def prepare_tenant_and_sub
|
53
|
+
super
|
54
|
+
|
55
|
+
@tenant = "xxxxx"
|
56
|
+
@sub = "xxxx"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
```
|
60
|
+
|
61
|
+
3. add endPoint on `config/routes.rb`
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
post '/raas/datatraveler/session', to: 'raas#datatraveler_session'
|
65
|
+
post '/raas/report/session', to: 'raas#report_session'
|
51
66
|
```
|
52
67
|
|
53
68
|
4. Launch your rails server
|
54
69
|
|
55
70
|
5. then you can use this with...
|
56
71
|
|
57
|
-
`/
|
72
|
+
`/raas/datatraveler/session`
|
73
|
+
`/raas/report/session`
|
58
74
|
|
59
75
|
## License
|
60
76
|
All the patents belong to SuTech
|
@@ -1,136 +1,8 @@
|
|
1
1
|
module Raas::Client::Rails
|
2
|
-
|
3
|
-
require_relative 'rest_client'
|
4
2
|
|
5
|
-
|
6
|
-
|
7
|
-
MSA_REPORT = "report";
|
8
|
-
MSA_DT = "datatraveler";
|
9
|
-
|
10
|
-
#/raas/health
|
11
|
-
def health()
|
12
|
-
prepare(params)
|
13
|
-
render plain: "Moving #{@tenant}/#{@sub}";
|
14
|
-
end
|
15
|
-
|
16
|
-
def prepare(params)
|
17
|
-
@backUrl = params[:backUrl]
|
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
|
25
|
-
@tenant = params[:tenant]
|
26
|
-
@sub = params[:sub]
|
27
|
-
end
|
28
|
-
|
29
|
-
def report_session()
|
30
|
-
Rails.logger.warn("session parameter=#{params}");
|
31
|
-
prepare(params)
|
32
|
-
response = @restClient.createExternalSession(MSA_REPORT,@backUrl,@subUrl)
|
33
|
-
render json: response.body
|
34
|
-
end
|
35
|
-
|
36
|
-
def datatraveler_session()
|
37
|
-
Rails.logger.warn("session parameter=#{params}")
|
38
|
-
prepare(params)
|
39
|
-
response = @restClient.createExternalSession(MSA_DT,@backUrl,@subUrl)
|
40
|
-
render json: response.body
|
41
|
-
end
|
42
|
-
|
43
|
-
MIME_TYPE_HTML = "html"
|
44
|
-
MIME_TYPE_FILE = "file"
|
45
|
-
MIME_TYPE_JSON = "json"
|
46
|
-
|
47
|
-
#/raas/get
|
48
|
-
def get()
|
49
|
-
prepare(params)
|
50
|
-
path = params[:path]
|
51
|
-
parameters = params[:parameters]
|
52
|
-
mimeType = params[:mimeType]
|
53
|
-
fileName = params[:fileName]
|
54
|
-
type = params[:type]
|
55
|
-
#by default return HTML
|
56
|
-
if mimeType.nil?
|
57
|
-
mimeType = MIME_TYPE_HTML
|
58
|
-
end
|
59
|
-
#by default return download.pdf
|
60
|
-
if fileName.nil?
|
61
|
-
fileName = "download"
|
62
|
-
end
|
63
|
-
if type.nil?
|
64
|
-
type = "application/pdf"
|
65
|
-
end
|
66
|
-
#by default empty Hash if nothing is assigned
|
67
|
-
if parameters.nil?
|
68
|
-
payload = Hash.new
|
69
|
-
else
|
70
|
-
payload = parameters
|
71
|
-
end
|
72
|
-
Rails.logger.warn("get path=#{path} parameters=#{payload}");
|
73
|
-
response = @restClient.get(path,payload)
|
74
|
-
handleMime(mimeType, fileName, type, response)
|
75
|
-
end
|
76
|
-
|
77
|
-
# How you return the value? This can be changed by passing mimeType through parameter
|
78
|
-
def handleMime(mimeType, fileName,type, response)
|
79
|
-
case mimeType
|
80
|
-
when MIME_TYPE_HTML
|
81
|
-
#sanitize response automatically
|
82
|
-
render html: response.body
|
83
|
-
when MIME_TYPE_JSON
|
84
|
-
render json: response.body
|
85
|
-
when MIME_TYPE_FILE
|
86
|
-
send_data(response, filename: fileName, type: type)
|
87
|
-
end
|
88
|
-
# p "#{fileName} #{type} #{mimeType}"
|
89
|
-
end
|
90
|
-
|
91
|
-
#/raas/delete
|
92
|
-
def delete()
|
93
|
-
prepare(params)
|
94
|
-
path = params[:path]
|
95
|
-
parameters = params[:parameters]
|
96
|
-
if parameters.nil?
|
97
|
-
payload = nil
|
98
|
-
else
|
99
|
-
payload = JSON.parse(parameters)
|
100
|
-
end
|
101
|
-
Rails.logger.warn("delete path=#{path} parameters=#{parameters}");
|
102
|
-
return @restClient.delete(path,payload)
|
103
|
-
end
|
104
|
-
|
105
|
-
#/raas/post
|
106
|
-
def post()
|
107
|
-
prepare(params)
|
108
|
-
path = params[:path]
|
109
|
-
requestBody = params[:requestbody]
|
110
|
-
if requestBody.nil?
|
111
|
-
payload = nil
|
112
|
-
else
|
113
|
-
payload = JSON.parse(requestBody)
|
114
|
-
end
|
115
|
-
Rails.logger.warn("post path=#{path} requestBody=#{requestBody}");
|
116
|
-
response = @restClient.post(path,payload)
|
117
|
-
return response.body;
|
118
|
-
end
|
119
|
-
|
120
|
-
#/raas/put
|
121
|
-
def put()
|
122
|
-
prepare(params)
|
123
|
-
path = params[:path]
|
124
|
-
requestBody = params[:requestbody]
|
125
|
-
if requestBody.nil?
|
126
|
-
payload = nil
|
127
|
-
else
|
128
|
-
payload = JSON.parse(requestBody)
|
129
|
-
end
|
130
|
-
Rails.logger.warn("post path=#{path} requestBody=#{requestBody}");
|
131
|
-
response = @restClient.put(path,payload)
|
132
|
-
return response.body;
|
133
|
-
end
|
3
|
+
require_relative 'raas_controller_module'
|
134
4
|
|
5
|
+
class RaasController < ApplicationController
|
6
|
+
include RaasControllerModule
|
135
7
|
end
|
136
8
|
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
module Raas::Client::Rails
|
2
|
+
|
3
|
+
require_relative 'rest_client'
|
4
|
+
|
5
|
+
module RaasControllerModule
|
6
|
+
|
7
|
+
MSA_REPORT = "report";
|
8
|
+
MSA_DT = "datatraveler";
|
9
|
+
|
10
|
+
#/raas/health
|
11
|
+
def health()
|
12
|
+
prepare(params)
|
13
|
+
render plain: "Moving #{@tenant}/#{@sub}";
|
14
|
+
end
|
15
|
+
|
16
|
+
def prepare(params)
|
17
|
+
@backUrl = params[:backUrl]
|
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
|
25
|
+
@tenant = params[:tenant]
|
26
|
+
@sub = params[:sub]
|
27
|
+
end
|
28
|
+
|
29
|
+
def report_session()
|
30
|
+
Rails.logger.warn("session parameter=#{params}");
|
31
|
+
prepare(params)
|
32
|
+
response = @restClient.createExternalSession(MSA_REPORT,@backUrl,@subUrl)
|
33
|
+
render json: response.body
|
34
|
+
end
|
35
|
+
|
36
|
+
def datatraveler_session()
|
37
|
+
Rails.logger.warn("session parameter=#{params}")
|
38
|
+
prepare(params)
|
39
|
+
response = @restClient.createExternalSession(MSA_DT,@backUrl,@subUrl)
|
40
|
+
render json: response.body
|
41
|
+
end
|
42
|
+
|
43
|
+
MIME_TYPE_HTML = "html"
|
44
|
+
MIME_TYPE_FILE = "file"
|
45
|
+
MIME_TYPE_JSON = "json"
|
46
|
+
|
47
|
+
#/raas/get
|
48
|
+
def get()
|
49
|
+
prepare(params)
|
50
|
+
path = params[:path]
|
51
|
+
parameters = params[:parameters]
|
52
|
+
mimeType = params[:mimeType]
|
53
|
+
fileName = params[:fileName]
|
54
|
+
type = params[:type]
|
55
|
+
#by default return HTML
|
56
|
+
if mimeType.nil?
|
57
|
+
mimeType = MIME_TYPE_HTML
|
58
|
+
end
|
59
|
+
#by default return download.pdf
|
60
|
+
if fileName.nil?
|
61
|
+
fileName = "download"
|
62
|
+
end
|
63
|
+
if type.nil?
|
64
|
+
type = "application/pdf"
|
65
|
+
end
|
66
|
+
#by default empty Hash if nothing is assigned
|
67
|
+
if parameters.nil?
|
68
|
+
payload = Hash.new
|
69
|
+
else
|
70
|
+
payload = parameters
|
71
|
+
end
|
72
|
+
Rails.logger.warn("get path=#{path} parameters=#{payload}");
|
73
|
+
response = @restClient.get(path,payload)
|
74
|
+
handleMime(mimeType, fileName, type, response)
|
75
|
+
end
|
76
|
+
|
77
|
+
# How you return the value? This can be changed by passing mimeType through parameter
|
78
|
+
def handleMime(mimeType, fileName,type, response)
|
79
|
+
case mimeType
|
80
|
+
when MIME_TYPE_HTML
|
81
|
+
#sanitize response automatically
|
82
|
+
render html: response.body
|
83
|
+
when MIME_TYPE_JSON
|
84
|
+
render json: response.body
|
85
|
+
when MIME_TYPE_FILE
|
86
|
+
send_data(response, filename: fileName, type: type)
|
87
|
+
end
|
88
|
+
# p "#{fileName} #{type} #{mimeType}"
|
89
|
+
end
|
90
|
+
|
91
|
+
#/raas/delete
|
92
|
+
def delete()
|
93
|
+
prepare(params)
|
94
|
+
path = params[:path]
|
95
|
+
parameters = params[:parameters]
|
96
|
+
if parameters.nil?
|
97
|
+
payload = nil
|
98
|
+
else
|
99
|
+
payload = JSON.parse(parameters)
|
100
|
+
end
|
101
|
+
Rails.logger.warn("delete path=#{path} parameters=#{parameters}");
|
102
|
+
return @restClient.delete(path,payload)
|
103
|
+
end
|
104
|
+
|
105
|
+
#/raas/post
|
106
|
+
def post()
|
107
|
+
prepare(params)
|
108
|
+
path = params[:path]
|
109
|
+
requestBody = params[:requestbody]
|
110
|
+
if requestBody.nil?
|
111
|
+
payload = nil
|
112
|
+
else
|
113
|
+
payload = JSON.parse(requestBody)
|
114
|
+
end
|
115
|
+
Rails.logger.warn("post path=#{path} requestBody=#{requestBody}");
|
116
|
+
response = @restClient.post(path,payload)
|
117
|
+
return response.body;
|
118
|
+
end
|
119
|
+
|
120
|
+
#/raas/put
|
121
|
+
def put()
|
122
|
+
prepare(params)
|
123
|
+
path = params[:path]
|
124
|
+
requestBody = params[:requestbody]
|
125
|
+
if requestBody.nil?
|
126
|
+
payload = nil
|
127
|
+
else
|
128
|
+
payload = JSON.parse(requestBody)
|
129
|
+
end
|
130
|
+
Rails.logger.warn("post path=#{path} requestBody=#{requestBody}");
|
131
|
+
response = @restClient.put(path,payload)
|
132
|
+
return response.body;
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: raas-client-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sunao Suzuki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- app/assets/stylesheets/raas/client/rails/application.css
|
39
39
|
- app/controllers/raas/client/rails/application_controller.rb
|
40
40
|
- app/controllers/raas/client/rails/raas_controller.rb
|
41
|
+
- app/controllers/raas/client/rails/raas_controller_module.rb
|
41
42
|
- app/controllers/raas/client/rails/rest_client.rb
|
42
43
|
- app/helpers/raas/client/rails/application_helper.rb
|
43
44
|
- app/helpers/raas/client/rails/raa_s_helper.rb
|