Class: RazorRisk::Cassini::Applications::Microservices::RESTful::Capabilities::CapabilitiesApp
- Inherits:
-
SecuredMicroservice
- Object
- SecuredMicroservice
- RazorRisk::Cassini::Applications::Microservices::RESTful::Capabilities::CapabilitiesApp
- Includes:
- Pantheios, RESTFramework::RouteVerbDispatch, RouteVerbAdaptors::Capabilities, RazorRisk::Core::Diagnostics::Logger
- Defined in:
- lib/razor_risk/cassini/applications/microservices/restful/capabilities/app.rb
Overview
Sinatra Application for the Capabilities Microservice.
Constant Summary collapse
- FULL_DESIGNATION =
'Capabilities'
- SHORT_DESIGNATION =
'capabilities'
- SERVICE_TYPE =
:microservice
- PROGRAM_FEATURES =
{ has_web_server: true, has_host_and_port: true, has_razor_connectivity: true, authentication: :with_credentials_algorithm, copyright_year: 2019, }
- SUPPORTED_ROUTES =
[ [ '/groups/?', :get, 'Get the capabilities of all groups.' ], [ '/groups/:id/?', :get, 'Get the capabilities of a specified group.' ], [ '/users/?', :get, 'Get the user specific capabilities of all users.' ], [ '/users/:group_id/?', :get, 'Get the user specific capabilities of all users in a specific group.' ], [ '/users/-/:id/?', :get, 'Get the user specific capabilities of a specific user.' ], [ '/subjects/?', :get, 'Get all the capability subjects and their actions.' ], [ '/subjects/:id/?', :get, 'Get the actions for a specific capability subject.' ], [ '/data-subjects/?', :get, 'Get all the capability data subjects and their actions.', ], [ '/data-subjects/:id/?', :get, 'Get all the capability data subjects and their actions.', ], [ '/adduser/:type/:user_id/:group_id/?', :get, 'Add capability user in group.', ], [ '/addgroup/:type/:group_id/?', :get, 'Add capability groups in group.', ], [ '/addsubjectgroup/:type/:group_id/:subjects/?', :get, 'Add capability groups in group.', ], [ '/createuser/:type/:userId/:name/:role/?', :get, 'create new user', ], [ '/updatesubject/:group_id', :post, 'update subject with group', ], [ '/filters/?', :get, 'Get all filters' ], [ '/batchsummaries/?', :get, 'Get all Batch Summaries' ], [ '/processedlog/:sys_id/:is_rejection/:startindex/:endindex/?', :get, 'Get all Batch Summaries' ], ]
- HTTP_ACCEPTS =
%w{ text/html application/json application/xml text/xml text/csv text/plain text/tab-separated-values text/tsv }
Class Method Summary collapse
Instance Method Summary collapse
-
#make_CSV_routes(routes) ⇒ Object
########################################################## routes helpers.
- #make_HTML_routes(routes, **options) ⇒ Object
- #make_JSON_routes(routes, **options) ⇒ Object
- #make_Plain_routes(routes) ⇒ Object
- #make_TSV_routes(routes) ⇒ Object
- #make_XML_routes(routes) ⇒ Object
Class Method Details
.on_init_service(options) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/razor_risk/cassini/applications/microservices/restful/capabilities/app.rb', line 96 def self.on_init_service trace ParamNames[ :options ], raise ArgumentError.new( 'missing keyword: razor_requester' ) unless .has_key? :razor_requester = [:request_options] || { validate: true } set :razor_requester, [:razor_requester] set :request_options, end |
Instance Method Details
#make_CSV_routes(routes) ⇒ Object
########################################################## routes helpers
256 257 258 259 260 261 262 |
# File 'lib/razor_risk/cassini/applications/microservices/restful/capabilities/app.rb', line 256 def make_CSV_routes routes CSV.generate do |csv| routes.each do |ar| csv << ar end end end |
#make_HTML_routes(routes, **options) ⇒ Object
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
# File 'lib/razor_risk/cassini/applications/microservices/restful/capabilities/app.rb', line 264 def make_HTML_routes routes, ** routes = routes.map do |ar| <<END_OF_tr <tr> <td>#{ar[0]}</td> <td>#{ar[1]}</td> <td>#{ar[2]}</td> </tr> END_OF_tr end <<END_OF_html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.we.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Razor Risk Web Service API - Internal Microservice - Capabilities</title> <meta name="revisit-after" content="24 hours" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <h1>Routes</h1> <table> <tr> <th>Route</th> <th>Verb</th> <th>Description</th> </tr> #{routes.map { |r| r.chomp("\n") }.join("\n")} </table> </body> </html> END_OF_html end |
#make_JSON_routes(routes, **options) ⇒ Object
298 299 300 301 302 303 304 |
# File 'lib/razor_risk/cassini/applications/microservices/restful/capabilities/app.rb', line 298 def make_JSON_routes routes, ** r = { 'routes' => [] } r['routes'] = SUPPORTED_ROUTES.map { |ar| { route: ar[0], verb: ar[1].to_s.upcase, description: ar[2] } } r.to_json end |
#make_Plain_routes(routes) ⇒ Object
306 307 308 |
# File 'lib/razor_risk/cassini/applications/microservices/restful/capabilities/app.rb', line 306 def make_Plain_routes routes make_TSV_routes routes end |
#make_TSV_routes(routes) ⇒ Object
310 311 312 |
# File 'lib/razor_risk/cassini/applications/microservices/restful/capabilities/app.rb', line 310 def make_TSV_routes routes routes.map { |ar| "#{ar[0]}\t#{ar[1]}\t#{ar[2]}\n" } end |
#make_XML_routes(routes) ⇒ Object
314 315 316 317 318 319 320 |
# File 'lib/razor_risk/cassini/applications/microservices/restful/capabilities/app.rb', line 314 def make_XML_routes routes <<END_OF_xml <?xml version="1.0"> <routes>#{routes.map { |ar| %Q{ <route route="#{ar[0]}" verb="#{ar[1].to_s.upcase}" description="#{ar[2]}"/>}}.join(%Q{\n})} </routes> END_OF_xml end |